Description
When using vk::RawBufferLoad<T> when T is a structure containing at least one 64-bit scalar (such as uint64_t or double, but not uint2 or float2), the generated SPIR-V improperly tries to load from the address using a 4-byte alignment which should be 8-byte.
Steps to Reproduce
- Source Code: https://godbolt.org/z/o9e1djnce
Or Simplified Code:
struct StructureWith64BitScalarMember {
uint64_t member;
double member2; //also fails
};
void main() {
uint64_t someAddress;
/* line below produces invalid SPIR-V */
StructureWith64BitScalarMember data64 = vk::RawBufferLoad<StructureWith64BitScalarMember>(someAddress);
vk::RawBufferStore<StructureWith64BitScalarMember>(someAddress, data64);
}
- Command Run:
dxc.exe -T cs_6_0 -E main -spirv source.hlsl -Fo out.spv (note: my dxc executable was sourced from LunarG's VulkanSDK version 1.4.335.0)
Actual Behavior 1
StructureWith64BitScalarMember data64 = vk::RawBufferLoad<StructureWith64BitScalarMember>(someAddress);
The above HLSL code (see the source code link in Steps to Reproduce) compiles to %75 = OpLoad %StructureWith64BitScalarMember %74 Aligned 4, which is then validated within DXC's pipeline and is found to be invalid.
fatal error: generated SPIR-V is invalid: [VUID-StandaloneSpirv-PhysicalStorageBuffer64-06314] Memory accesses Aligned operand value 4 is too small, the largest scalar type is 8 bytes.
%75 = OpLoad %StructureWith64BitScalarMember %74 Aligned 4
note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible
Actual Behavior 2
vk::RawBufferStore<StructureWith64BitScalarMember>(someAddress, data64);
The above HLSL code (see the source code link in Steps to Reproduce) compiles to OpStore %57 %58 Aligned 4, which is then validated within DXC's pipeline and is found to be invalid.
fatal error: generated SPIR-V is invalid: [VUID-StandaloneSpirv-PhysicalStorageBuffer64-06314] Memory accesses Aligned operand value 4 is too small, the largest scalar type is 8 bytes.
OpStore %57 %58 Aligned 4
note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible
Environment
- DXC version:
dxcompiler.dll: 1.10 - 1.8.0.5123 (3f85295cf)
- Host Operating System:
Windows 11 25H2 (OS Build 26200.8655)
NOTE
Both actual behaviors are not visible at the same time. This is because when a single SPIR-V validation check fails, no further validation is continued. So, when the load is determined to be invalid, it doesn't attempt to report the equally as invalid store later.
Description
When using
vk::RawBufferLoad<T>whenTis a structure containing at least one 64-bit scalar (such asuint64_tordouble, but notuint2orfloat2), the generated SPIR-V improperly tries to load from the address using a 4-byte alignment which should be 8-byte.Steps to Reproduce
Or Simplified Code:
dxc.exe -T cs_6_0 -E main -spirv source.hlsl -Fo out.spv(note: my dxc executable was sourced from LunarG's VulkanSDK version 1.4.335.0)Actual Behavior 1
The above HLSL code (see the source code link in Steps to Reproduce) compiles to
%75 = OpLoad %StructureWith64BitScalarMember %74 Aligned 4, which is then validated within DXC's pipeline and is found to be invalid.Actual Behavior 2
The above HLSL code (see the source code link in Steps to Reproduce) compiles to
OpStore %57 %58 Aligned 4, which is then validated within DXC's pipeline and is found to be invalid.Environment
dxcompiler.dll: 1.10 - 1.8.0.5123 (3f85295cf)Windows 11 25H2 (OS Build 26200.8655)NOTE
Both actual behaviors are not visible at the same time. This is because when a single SPIR-V validation check fails, no further validation is continued. So, when the load is determined to be invalid, it doesn't attempt to report the equally as invalid store later.