I cannot reproduce this based on that data. I tried compiling the shaders on that godbolt link, but they compile just fine. Please just provide a reproducing .dxil file so I don't have to fumble in the dark.
@HansKristian-Work you're entirely right, I slightly reformatted the shader and by that, it no longer reproduces, my apologies.
Specifically I moved RayQuery<RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH> q; down to where it is needed, and that affects the reproducability. This apparently does not hit the error:
RAY_FLAG flags = 0;
if (!alphaTest)
flags |= RAY_FLAG_FORCE_OPAQUE;
RayQuery<RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH> q;
RaytracingAccelerationStructure tlas = ResourceDescriptorHeap[bnd.tlasSrv];
q.TraceRayInline(tlas, flags, 0xff, ray);
But if it's anywhere above the conditional, it seems to error out:
// RayQuery<RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH> q;
RAY_FLAG flags = 0;
RayQuery<RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH> q;
if (!alphaTest)
flags |= RAY_FLAG_FORCE_OPAQUE;
RaytracingAccelerationStructure tlas = ResourceDescriptorHeap[bnd.tlasSrv];
q.TraceRayInline(tlas, flags, 0xff, ray);
GitHub doesn't like dxil files, even when renaming them to .txt or attaching as .tgz, give a me a bit to upload it elsewhere.
I reproduced it now. Completely bogus DXIL where DXC somehow invents a phi where it makes zero sense to do so ...
It seems I forgot to mention that we were also seeing the exact same shader fail to load on Dx12 (native Windows installation) on an Intel GPU, and that was fixed with the exact same workaround. I was almost already assuming something to be "wrong" (or very unexpected) with this DXIL produced by DXC rather than both implementations being broken.
It is legal DXIL (sadly), so it's a bug that will be fixed, but patterns like this will most likely run like absolute ass in practice.
Nothing extracted yet.
Hey, not sure if this is the right place (as I'm running the full
vkd3d-protonpackage) or if this should be transferred to https://github.com/HansKristian-Work/dxil-spirv.We're hitting
dxil-spirv: Invalid type ID in cast<T>.in one of our HLSL shaders with a ray query, when testing latestmaster@ 298eaf00036f8f1cb4410c9e21b5208ed9a66c67, and bisected it down to the following code changes. The only other issue mentioning this here is #602.Using "the latest"
v1.8.2505.1DXC with a simple-T cs_6_6 -E main, creating a conditionalRAY_FLAGvariable forRayQuery::TraceRayInline()based on two short-circuiting||or&&results indxil-spirv: Invalid type ID in cast<T>.. Replacing one of those ops with a binary variant (|or&), or making at least one of the expression sources a properconst(where the RHS is actually a compile time constant) for example solves this issue.The full shader source and comparison is available on GodBolt, with this being the most important code snippet:
Additionally, as mentioned, here is an example changing between
uint bounce = 0;andconst uint bounce = 0;to also trigger this issue.If convenient, let me know and I can provide the compiled DXIL for these sources; though I assume being able to live tweak and recompile it is also useful?