You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
I'm trying to access vertex and index buffers from fragment shader. I tried to get vertex world position without getting data from vertex shader, only using acceleration structure. For that i needed to get primitive id by using RayQuery, then get vertex id based on primitive id and then get position of that vertex. So i added two buffer bindings to my render pipeline - one for indices and another for vertices. They are pointers to index and vertex buffers respectively.
Honorable mention: #1040. I think this is relevant, because i'm trying to replicate some concepts from vk_mini_path_tracer (See ./checkpoints/11_specular/. The shader makes use of two storage buffers which are pointing to vertex and index buffers).
Expected vs observed behavior
I noticed that no matter what value of vertex buffer i'm trying to access - it's always zero, however index values are proper and indbuf[rayQueryGetIntersectionPrimitiveIndexEXT(rq, true)] returns correct vertex number. I investigated further and found out that layout(set = 0, binding = 2) buffer ind_buf { uint indbuf[]; }; and layout(set = 0, binding = 3) buffer vtx_buf { Vertex vtxbuf[]; }; point to the same address (see nsight screenshot). In my program it is stated like this:
Sorry for congestion. The solution was to change resource_index in the fourth BindGroupEntry. Is it worth documenting? Like if you want to bind multiple instances of the same binding type you should mark them with respective resource index.
Description
I'm trying to access vertex and index buffers from fragment shader. I tried to get vertex world position without getting data from vertex shader, only using acceleration structure. For that i needed to get primitive id by using RayQuery, then get vertex id based on primitive id and then get position of that vertex. So i added two buffer bindings to my render pipeline - one for indices and another for vertices. They are pointers to index and vertex buffers respectively.
Honorable mention: #1040. I think this is relevant, because i'm trying to replicate some concepts from vk_mini_path_tracer (See
./checkpoints/11_specular/
. The shader makes use of two storage buffers which are pointing to vertex and index buffers).Repro steps
This is probably runnable:
https://gitlab.com/robostep9829/hal-path-tracing-rs/-/tree/ssbo-error
See
./shaders/shader.frag
,./src/main.rs
and./src/resources.rs
Expected vs observed behavior
I noticed that no matter what value of vertex buffer i'm trying to access - it's always zero, however index values are proper and
indbuf[rayQueryGetIntersectionPrimitiveIndexEXT(rq, true)]
returns correct vertex number. I investigated further and found out thatlayout(set = 0, binding = 2) buffer ind_buf { uint indbuf[]; };
andlayout(set = 0, binding = 3) buffer vtx_buf { Vertex vtxbuf[]; };
point to the same address (see nsight screenshot). In my program it is stated like this:Extra materials
Here we can see that
ind_buf
andvtx_buf
are the same bufferGraphics-wgpu__2024_03_09__19_25_05.zip
Platform
OS: Windows 11 22H2, GPU: Radeon RX 6600, IDE: RustRover 233.14015.155, Vulkan SDK: 1.3.275.0, Rust: 1.71-msvc.
The text was updated successfully, but these errors were encountered: