Closed smeunier-amd closed 11 months ago
A common pattern for implementing constant buffer is to share a header between C++ and HLSL :
#ifndef GPU_SHARED_H #define GPU_SHARED_H #ifdef __cplusplus #include <glm/gtx/type_aligned.hpp> #include <glm/gtx/compatibility.hpp> typedef uint32_t uint; typedef glm::ivec2 int2; typedef glm::ivec4 int4; typedef glm::uvec2 uint2; typedef glm::aligned_uvec3 uint3; typedef glm::uvec4 uint4; typedef glm::aligned_vec4 float4; typedef glm::aligned_vec3 float3; typedef glm::aligned_vec2 float2; typedef glm::bool3 bool3; typedef glm::mat4 float4x4; #endif // __cplusplus enum MyEnum { VALUE1 = 0, VALUE2 }; struct MyContants { float attribute0; uint attribute1; uint2 attribute2; uint attribute3; uint attribute4; MyEnum attribute5; }; #endif // GPU_SHARED_H
These typedef declarations are probably wrong :
float2
int2
bool3
HLSL contant buffer alignment rules aren't obvious, and we still can't use -not_use_legacy_cbuf_load with DXC.
I propose gfx provide a small set (subset?) of types we can use and arrange freely in constant buffers.
Closing due to inactivity.
A common pattern for implementing constant buffer is to share a header between C++ and HLSL :
These typedef declarations are probably wrong :
float2
andint2
don't match ?bool3
?HLSL contant buffer alignment rules aren't obvious, and we still can't use -not_use_legacy_cbuf_load with DXC.
I propose gfx provide a small set (subset?) of types we can use and arrange freely in constant buffers.