Comments (2)
If lod.meshletOffset is not divisible by 32, can we still derive the correct meshlet index in task shader?
So with the current structure meshlet offsets are rounded to 32, but it doesn't have to be the case - this just made sense to me when I was writing the code, but you can keep firstTask
as 0 and derive the index of the meshlet yourself if you pass meshletOffset via a separate field in MeshDrawCommand
that's not part of VkDrawMeshTasksIndirectCommandNV. Then in the task shader you just need to read the meshlet data using the computed meshlet index that uses the offset read from drawCommands[gl_DrawIDARB]
. This should be a simple change, it just was easier to pad the data and use firstTask.
Is it possible to compute LOD level in task shader, as described in this NVIDIA blog?
This is a bit more difficult because it requires restructuring the code and may have performance implications. What happens right now is that the task shader is ran for every meshlet, with one thread in the task shader producing one meshlet - or not producing one, because the task shader runs the culling. If you don't do the culling - you can run a thread of the task shader per object, which I suspect is what the NV demo is doing, and there cull the object, select the LOD and leave the rest to the mesh shader. The mesh shader would need to cull meshlets and then transform vertices / output triangles.
The problem with this approach is that you need to span as many meshlet threads as you have meshlets times 32 or some amplification factor like that, because you want the number of threads to closely track number of vertices/triangles in the entire object, to make transformation and index output efficient.
This is completely fine if you don't cull individual meshlets. However, this renderer culls individual meshlets using the meshlet cone, and really could also cull using frustum and also do per-meshlet occlusion checks, I just didn't get to that.
To keep these checks efficient is difficult with that approach. The approach taken by the current code maximizes the degree of parallelism during culling (by running culling in the task shader) and maximizes the degree of parallelism during meshlet transform/output (by running that in the mesh shader). A different structure feels like it will be less performant if you want do cull individual meshlets.
If you don't - it doesn't matter, but then you lose a big part of the attraction of mesh shaders.
from niagara.
Sorry for my late reply. As far as I know, there are three ways to implement dynamic LOD with mesh shader:
- Spawn a workgroup per object in task shader, with workgroup size is 1. Then compute LOD, and spawn a workgroup per meshlet in mesh shader.
- Spawn a thread per object in task shader, with workgroup size is 32. Then compute LOD for each object and accumulate total number of meshlet in each workgroup. Finally, still spawn a workgroup per meshlet in mesh shader.
- Combine indirect draw and task/mesh shader, as you did on stream.
The 1st method is OK and easy to implement, but it does not take the full advantage of parallelism of task shader. The 2nd method is fully parallelized, however, computing meshlet index in mesh shader is complicated and the number of task spawn by a task shader workgroup may exceed the hardware limit (which is 65536 on my machine). The 3rd method is fine, but synchronization is need between compute shader dispatch and mesh shader draw call.
To compare the performance for 2nd and 3rd methods, I did a test in a rough scene (with just a large amount of high-poly meshes), and find that the GPU frame time of 3rd method (80.1ms) is much less than 2nd method (118.2ms). Both methods should be fully parallelized, I am wondering where is the performance benefit comes from for 3rd method.
from niagara.
Related Issues (20)
- VkPhysicalDeviceVulkan12Features shaderFloat16 not supported on Nvidia Maxwell
- Simple Flycam HOT 2
- Could you support CMake to build? HOT 1
- Frustum culling with symmetry doesn't work for non-identity view matrix. HOT 4
- Fauly occlusion with camera HOT 2
- AMD RX 560: cannot create VkDevice due Failed in ICD HOT 2
- Doesn't run on AMD GPUs on Win because drivers missing VK_KHR_push_descriptor.. HOT 2
- Assertion Failed HOT 2
- Possible negation error in frustum culling code. HOT 1
- Call `SetMeshOutputsEXT` before writing to `gl_MeshVerticesEXT`/`gl_PrimitiveTriangleIndicesEXT` HOT 1
- Custom Build tool Cmd line needs some quotes HOT 1
- Mesh shader discussion HOT 15
- SEGFAULT on an AMD 6900XT when enabling `VK_EXT_mesh_shader` HOT 3
- Correctly handle maxTaskWorkGroupCount restriction
- Device extension VK_EXT_mesh_shader not supported by selected physical device or enabled layers. HOT 1
- Kitten starts to flicker when turn off frustum culling and lod together HOT 5
- Incorrect frustum symmetry culling in bottom right quadrant HOT 2
- Just want to say a big thanks
- The project doesn't compile on Vulkan SDK 1.2.135.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from niagara.