Repository navigation
Closed
Description
The following reproducer does not compile, leading to the error message:
fatal error : generated SPIR-V is invalid: ID '52[%52]' has not been defined
1> %51 = OpExtInst %void %1 DebugTypeFunction %uint_3 %52 %48 %49
1>
1>note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible
Reproducer:
StructuredBuffer<uint16_t> myIntersectionMaskBuffer_BitCompressed : register(t0);
class CompressedIntersectionBits
{
uint16_t myCompressedData;
static CompressedIntersectionBits read_const(StructuredBuffer<uint16_t> aIntersectionMaskBuffer_BitCompressed_in, const uint aRayIndex_in)
{
CompressedIntersectionBits aCompressedIntersectionBits;
aCompressedIntersectionBits.myCompressedData = aIntersectionMaskBuffer_BitCompressed_in[aRayIndex_in];
return aCompressedIntersectionBits;
}
};
class CompressedIntersectionBits_Test
{
static CompressedIntersectionBits read_const(StructuredBuffer<uint16_t> aIntersectionMaskBuffer_BitCompressed_in, const uint aRayIndex_in)
{
CompressedIntersectionBits aCompressedIntersectionBits;
aCompressedIntersectionBits.myCompressedData = aIntersectionMaskBuffer_BitCompressed_in[aRayIndex_in];
return aCompressedIntersectionBits;
}
};
void runKernel(const uint aIndexX_in, const uint aIndexY_in)
{
uint aRayIndex = aIndexY_in * 512 + aIndexX_in;
CompressedIntersectionBits aCompressedIntersectionBits = CompressedIntersectionBits::read_const(myIntersectionMaskBuffer_BitCompressed, aRayIndex);
//CompressedIntersectionBits aCompressedIntersectionBits = CompressedIntersectionBits_Test::read_const(myIntersectionMaskBuffer_BitCompressed, aRayIndex);
}
[numthreads(8, 8, 1)]
void main(uint3 GlobalInvocationID : SV_DispatchThreadID, uint3 LocalInvocationID : SV_GroupThreadID)
{
runKernel(GlobalInvocationID[0], GlobalInvocationID[1]);
}Command Line used:
dxc.exe -spirv -T cs_6_7 -fvk-use-scalar-layout -enable-16bit-types -fspv-target-env=vulkan1.3 -fspv-debug=vulkan-with-source -E main
dxc version used:
dxcompiler.dll: 1.7 - 1.7.0.3774 (2168dcb4f)
Operating System used:
Windows 10
When removing the option
-fspv-debug=vulkan-with-source
the file compiles without a problem.
The issue also vanishes, when calling
CompressedIntersectionBits_Test::read_const(myIntersectionMaskBuffer_BitCompressed, aRayIndex);instead of
CompressedIntersectionBits::read_const(myIntersectionMaskBuffer_BitCompressed, aRayIndex);
Activity
[-]Shader failes to compile when activating debug infos[/-][+][SPIR-V] Shader failes to compile when activating debug infos[/+]Keenuts commentedon Jan 5, 2023
Hi! Thanks for complete the report!
Was able to reproduce at head with:
The issue seems to be linked to the optimizer, and the compact-ids pass, IDs gets rearranged, and the ID ends up being used before being defined:
Keenuts commentedon Jan 5, 2023
Not a compact-ids pass issue, the initial code also contains other debug instructions with IDs defined later on. Also, from other generated spv, the use-before-declaration seems to be OK. Looking into it.
webez commentedon Mar 6, 2023
Hi.
I could reproduce the same bug with this code
Keenuts commentedon May 22, 2023
Hello! Sorry haven't had much time for DXC.
Seems like this issue is related to KhronosGroup/SPIRV-Tools#5229 but this is not enough to fix it.
Seems like there is also a fix to do in the debug instruction ordering code.
Clothoid1 commentedon Jul 18, 2023
I just tested this issue with latest DXC compiler.
I can now no longer reproduce this issue.
Instead i only get the warning:
warning : Member functions will not be linked to their class in the debug information. See KhronosGroup/SPIRV-Registry#203
Theoretically this issue could now be closed.
Or should it be kept open until also the warning is solved?
Clothoid1 commentedon Jul 18, 2023
When activating debug infos now all of our shaders compile - with the exception of our raytracing shaders.
But it seems to me that this remaining issue was already reported:
#5113
Keenuts commentedon Jul 18, 2023
Hello! So yes, thanks, for now, the issue is "resolved" as "it doesn't crash".
We can close this, but we now need to change the SPIR-V spec to solve this long-term.
(This will take longer, as we need to define the spec, and figure out how to propagate it, maybe wait a spirv release?)
For the second issue, seems unrelated to this (as in it's a different error/crash).