shader-slang / slang

Making it easier to work with shaders
http://shader-slang.com
MIT License
2.16k stars 186 forks source link

CPP/Metal/CUDA: does not follow HLSL memory packing #4627

Closed ArielG-NV closed 3 months ago

ArielG-NV commented 3 months ago

Assume the following:

//TEST_INPUT:cbuffer(data=[1.0 2.0 3.0 0.0  4.0 5.0 6.0 0.0  7.0 8.0 9.0 0]):name matrixTestCBuf1
ConstantBuffer<row_major float3x3> matrixTestCBuf1;

//TEST_INPUT:cbuffer(data=[1.0 4.0 7.0 0.0  2.0 5.0 8.0 0.0  3.0 6.0 9.0 0.0]):name matrixTestCBuf2
ConstantBuffer<column_major float3x3> matrixTestCBuf2;

// struct float3x3{float3[3]
// {
//     float3 data1; 
//     float pad1;
//     float3 data2;
//     float pad2;
//     float3 data3;
//     float pad3;
// }

//TEST_INPUT:cbuffer(data=[1.0 2.0 3.0 0.0  4.0 5.0 6.0 0.0]):name NeedsPadding
cbuffer NeedsPadding
{
    float3 data1;
    // float pad1;
    float3 data2;
};

Currently CPP/CUDA/Metal load these as tightly packed (different behavior than HLSL/GLSL/SPIRV), this requires legalization/handling

ArielG-NV commented 3 months ago

Closed for-now unless the issue becomes a problem

bmillsNV commented 3 months ago

No actionable item here. Closing.