Description
Describe the bug
Bufferviews with a format, that is not R32, do not work correctly in the BindlessSRG, for DX12.
The Bufferviews are in the m_ByteAddressBuffer
array of the SRG.
If a Bufferview has a type of R32, or a type with the same size, they can be used without problems.
However, if a Bufferview has a type, with elements larger than 4 bytes, the Load
function returns zero values for parts of the buffer.
E.g. if the element size is 8 bytes (R32G32), we get zero values for half of the buffer.
If the element size is 12 bytes, we get zero values for two thirds of the buffer.
It appears, that there is some kind of bounds check, and it only checks with the number of elements, and assumes an element size of 4 bytes.
Unfortunately, I don't know enough about DX12 to know where the problem really lies.
I assume it has something to do, with the fact that the Bindless Bufferviews are just copies of the non-Bindless ones.
Meaning they have a format, and are not raw Bufferviews (See DescriptorContext::CreateShaderResourceView
)
As to why this is not a problem currently:
As far as I see, the only code that uses the Bindless buffer views, is in the RayTracingSceneUtils.azsli
.
This works, because the MeshFeatureProcessor
creates raw buffer views for all the vertex attribute buffers (see ModelDataInstance::SetRayTracingData
).
We use the BufferViews of the RPI buffers directly, because it seemed wasteful to create new Views, that are essentially the same.
This image shows a cube mesh. We show the uv coordinate of the first vertex in a triangle.
Here 3 sides of the cube are colored correctly, the other 3 sides are just black.
The same scene works correctly with Vulkan.
Found in Branch
2305.0
Activity