Lax wrote: ↑Sat Sep 26, 2020 10:38 am
just another important question: As I'm comparing what has changed in the hlms tutorials, I see that vulkan has been introduced everywhere. Since I do not use vulkan yet, is this automatically detected? Because I'm afraid, that when I merge everything, that nothing will work anymore.
Major changes are 2:
1. RootLayouts. This is, at least for now (and quite possibly foreseable future) Vulkan-only. i.e. failure to setup a RootLayout will only impact Vulkan (it's ignored by the other RenderSystems)
2. ReadOnlyBuffers. This affects all RS and is a performance optimization (also we needed this to support Android). To quote documentation:
Represents the best way to access read-only data.
But how it is implemented depends largely on which HW/API it is running on:
- Buffer<> aka texture buffer in D3D11 on D3D10+ HW
- samplerBuffer aka texture buffer in GL3 on GL3/D3D10 HW
- SSBO aka UAV buffer in GL4 on GL4/D3D11 HW
- SSBO aka UAV buffer in Vulkan
- Metal doesn't matter, there are no differences between TexBuffer & UavBuffer,
however we consume the slots reserved for tex buffers.
In short, it either behaves as a TexBufferPacked or as an UavBufferPacked (but read only)
depending on HW and API being used.
Some existing code has changed to use ReadOnlyBufferPacked where it originally used TexBufferPacked.
This means in shader code, these buffers should be accessed via the readOnlyFetch() macro.
i.e.
Code: Select all
// GLSL
// old code:
float4 value = texelFetch( matrixBuf, idx );
// new code
float4 value = readOnlyFetch( matrixBuf, idx );
// Note that readOnlyFetch macro may expand to either
float4 value = matrixBuf[idx]; // Modern GPUs
float4 value = texelFetch( matrixBuf, idx ); // Old GPUs
In HLSL the difference is less noticeable, but variables are now declared as StructuredBuffer<floatN> instead of Buffer<floatN>
Additionally, Matrix functions in Matrix_piece_all.glsl/hlsl have been modified to only work with matrices stored in ReadOnly buffers instead of Tex buffers.
If your custom modifications to Hlms access buffers that are now ReadOnlyBufferPacked, you need to change your shaders to use readOnlyFetch. This may sound scary but it's just routinely changing code that refuses to compile with the new syntax.