From 4dbcfca343fe5582c27b2e1fd080a985233b526a Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 5 May 2025 14:49:24 +0100 Subject: [PATCH] Fix reflection of structs containing 16-bit types. Closes #3605 * It is impossible to emit a true 16-bit type on fxc, the minXX types we round up internally to a 32-bit type since that's how they are defined to appear in external resources like cbuffers and SRV/UAVs. * The new 16-bit type enums that are shared between fxc/dxc structs are not actually ever emitted by fxc for RDEF types. --- renderdoc/driver/shaders/dxbc/dxbc_reflect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/shaders/dxbc/dxbc_reflect.cpp b/renderdoc/driver/shaders/dxbc/dxbc_reflect.cpp index f9d91daf8..d143db320 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_reflect.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_reflect.cpp @@ -61,12 +61,12 @@ static ShaderConstantType MakeShaderConstantType(bool cbufferPacking, DXBC::CBuf type.varClass == DXBC::CLASS_SCALAR) ret.flags |= ShaderVariableFlags::RowMajorMatrix; - uint32_t baseElemSize = (ret.baseType == VarType::Double) ? 8 : 4; + uint32_t baseElemSize = VarTypeByteSize(ret.baseType); // in D3D matrices in cbuffers always take up a float4 per row/column. Structured buffers in // SRVs/UAVs are tightly packed if(cbufferPacking) - ret.matrixByteStride = uint8_t(baseElemSize * 4); + ret.matrixByteStride = AlignUp16(uint8_t(baseElemSize * 4)); else ret.matrixByteStride = uint8_t(baseElemSize * (ret.RowMajor() ? ret.columns : ret.rows));