Load new set of geometry per frame in Vulkan - graphics

I try to develop a render server thats draw an any scene per request.
I need to destroy the previous scene and load new one when new request is incoming. But also I need create a new pipeline with new VkPipelineVertexInputStateCreateInfo.
Can I do without pipeline recreation ?
IMO the best approach is to create just 1 VBO and 1 IBO, but I dont understand how to use offset in IBO to perform drawing. Is it possible ?

Related

Creating Three.js meshes in a WebWorker

I'm trying to offload as many Threejs computations as possible to a Web Worker. It seems to be relatively doable when just wanting the worker to create geometries. However, I still need to create a significant amount of meshes, which implies a hefty cycle on the main thread.
Is it possible to offload mesh creation to a web worker and just have the main thread add it to the scene (when ready)?
The idea would be to have the worker create an array of meshes, based on some data, and have it send it over to the main thread.
Many thanks
I am currently willing to tackle this problem in one of my projects. If you haven't started yet yours, I would suggest to have a look at https://github.com/kripken/webgl-worker first. There are two examples (one simple, one a bit more complex) that could help to start with.
I will update later this answer with more details about how to integrate wegl-worker with three.js, which might require more setup than simple webgl/worker implementation.
Unfortunately, THREEJS 3D objects (classes) are to "heavy" to be used in workers (object can't pass through "worker thread"-"main thread" boundary, even after I patched threejs lib to be used inside worker).
But I successfully use workers to load pretty large objects asynchronously.
I use Catiline.js for convenience.
The idea is to use THREEJS objects native format (and buffer geometry) and simply parse it to js object inside worker. After it, you can use THREE.ObjectLoader in the main thread to get real scene object. The benefit from such approach is to move parsing (which can take quite a long time for the large object) to background and minify freezing.
I use 6 workers, choose worker randomly, pass data url to it and additionaly get benefits from XMLHttpRequest caching
Threejs objects can't be passed through a postMessage.
Instead we want to set up a connection back to the main page via web-sockets. This should let us freely pass whatever is needed.
This thread might be helpful to you... I recently had to do some SSR with Three.js and the concepts are similar expect you are parsing Buffer Geometries with ObjectLoader in the worker.
https://discourse.threejs.org/t/error-with-ssr-three-js-objects/8643

JavaFX paus thread on scene change and resume

im searching for a way to paus a thread that for example displays some animation on a scene by switching to a different one. The background is to save cpu load of to mutch executing tasks. I also want to resume the Thread after i switch back to the scene. I know that i can do this in the method, in which i load the new scene but i cant find a way to pause and resume on that point the thread stoped. Is there an build in function in task, futuretask? My only idea was, to save the current state and by switching back i start a new task and restore the saved values/state. Are there any experts, who can give me the best practise/solution? Thanks for your help!
Sry for no code, but i think you can awnser it without any example. When not i will add some example code for sure.

J2me Update Container List with changed ListModel

I'm using lwuit Container list with Cell Renderer to display an image grid. For network availability purposes, I want to display a default image and change it to the fetched image after download completes. I'm also having problems detecting the completed download. I'm using a thread queue to minimize amount of threads running. How can i notify a method that updates the model when download is complete? How best can I update the list with the new model? Thanks in advance.
Apparently you can change the list model on the fly. That way you can fetch the images with a thread queue and the update the model when the image fetching is complete

How can I load a texture in separate thread in cocos2d-x?

I faced the need to use multi-threading to load an additional texture on-the-fly in order to reduce the memory footprint.
The example case is that I have 10 types of enemy to use in the a single level but the enemies will come out type by type. The context of "type by type" means one type of enemy comes out and the player kills all of its instances, then it's time to call in another type. The process goes like this until all types come out, then the level is complete.
You can see it's better to not initially load all enemy's texture at once in the starting time (it's pretty big 2048*2048 with lots of animation frames inside which I need to create them in time of creation for each type of enemy). I turn this to multi-thread to load an additional texture when I need it. But I knew that cocos2d-x is not thread-safe. I planned to use CCSpriteFrameCache class to load a texture from .plist + .png file then re-create animation there and finally create a CCSprite from it to represent a new type of enemy instance. If I don't use multi-thread, I might suffer from delay of lag that would occur of loading a large size of texture.
So how can I load a texture in separate thread in cocos2d-x following my goal above? Any idea to avoid thread-safe issue but still can accomplish my goal is also appreciated.
Note: I'm developing on iOS platform.
I found that async-loading of image is already there inside cocos2d-x.
You can build a testing project of cocos2d-x and look into "Texture2DTest", then tap on the left arrow to see how async-loading look like.
I have taken a look inside the code.
You can use addImageAsync method of CCtextureCache to load additional texture on-the-fly without interfere or slow down other parts such as the current animation that is running.
In fact, addImageAsync of CCTextureCache will load CCTexture2D object for you and return back to its callback method to receive. You have additional task to make use of it on your behalf.
Please note that CCSpriteFrameCache uses CCTextureCache to load frames. So this applies to it as well for my case to load spritesheet consisting of frames to be used in animation creation. But unfortunately async type of method is not provided for CCSpriteFrameCache class. You have to manually load texture object via CCTextureCache then plug it in
void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, CCTexture2D *pobTexture)
There's 2 file in testing project you can take a look at.
Texture2dTest.cpp
TextureCacheTest.cpp

Nested NSManagedObjectContext for core data, how to share and manage data properly?

This is the first post in stackoverflow for me. Because I encountered the problem that I can't solve even by looking up in google and documents.
I get a small iOS project, which is a weather searching app. Basically it is easy to implement overall, but there are some rules I have to follow:
One parent context on a background thread which is linked to the persistent store (on disk);
one child context on the main thread for the UI;
one child context on a background thread for talking to the web service.
After seeing this, I found an image online:
This image shows what exactly should do for this project. And I get few problems right now.
As image shows, I use [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType] to define my main UI MOC, and use NSPrivateQueueConcurrencyType to define my webMOC and diskMOC. Question is that, shall I put everything into [UIMOC performBlock: ^{......}] ?
I am quite confused right now, isn't UI runs on main thread? so what is the point of NSMainQueueConcurrencyType?
After reading lot of documents, I found that the way to share data between childMOC and parentMOC are either make childMOC run "save" function, or call merge function through notification.
(a) for the first one, do I need to [childMOC save] then do [parentMOC save]? or after [childMOC save], parentMOC automatically get updated?
(b) I am not sure which way is more appropriate.
The image above have 3 levels MOC. If I do "save" function at the lowest level MOC and can highest level MOC get data shared?
As what I thought about, why couln't the lowest level MOC combined with highest level MOC and to read and write? meantime, the UIMOC in the middle, do I have to put it into performBlock function of Context to run NSFetchedResultController?

Resources