Closed ngcg closed 3 years ago
Pfew, I was actually able to bisect it down to code in another included file:
// inside function, inside while loop
if (condition) {
int local = (g_constants.foo >= 0 ? g_constants.foo : g_variables[PrimitiveIndex()]);
// do stuff
}
where g_constants is ConstantBuffer<SomeStruct>
('b' register, CBV) and g_variables is Buffer<int>
('t' register, SRV).
Replacing PrimitiveIndex() with plain 0 avoids the exception. Extracting the index to a separate local (const) variable doesn't help.
Restructuring the code to this equivalent also doesn't help:
int local = g_constants.foo;
if (local < 0)
local = g_variables[PrimitiveIndex()]);
We have one other file that uses PrimitiveIndex similarly (stored in a local variable and then used with an array) - it too raises this exception. When I replace PrimitiveIndex() with 0 the extension parses all sources without raising exceptions, even though the total code length is way over 10K lines when accounting for includes. Interestingly other raytracing intrinsics like InstanceID() don't cause issues.
I can confirm that PrimitiveIndex()
breaks the extension.
With PrimitiveIndex()
:
Without PrimitiveIndex()
, more highlighting:
The cause of the error seems to be that "PrimitiveIndex"
appears in IntrinsicFunctions.SM6.cs twice:
Removing the extra "PrimitiveIndex"
block from IntrinsicFunctions.SM6.cs fixes the bug:
-->
When you re-build you'll find the .vsix
here:
HlslTools-master\src\ShaderTools.Editor.VisualStudio\bin\Release
Thanks @ngcg for reporting this, and thanks @MattTree for the fix!
VS 2019 (16.7.2), HlslTools 1.1.302
This looks similar to #203, but the stack trace is a bit different. It happens in a very large HLSL file, so I don't know what code exactly triggered it. Other files in the same project are ok.
This extension looks great otherwise - makes VS an actual IDE for HLSL, instead of a glorified notepad. Thanks for your work!
VS xml log event with some newlines added for readability: