gfx-rs / naga

Universal shader translation in Rust

Home Page:https://github.com/gfx-rs/wgpu/tree/trunk/naga

Repository from Github https://github.comgfx-rs/nagaRepository from Github https://github.comgfx-rs/naga

[hlsl-out] D3DCompile error: syntax error: unexpected token 'texture'

zachreizner opened this issue · comments

I noticed the unexpected token 'texture' error while using wgpu and wgsl on Windows. Digging into it, I noticed the generated shader had the reserved texture keyword in a generated helper:

int2 NagaDimensions2D(Texture2D<float4> texture)
{
    uint4 ret;
    texture.GetDimensions(0, ret.x, ret.y, ret.z);
    return ret.xy;
}

It seems this texture name was coming from this line of code:

const ARGUMENT_VARIABLE_NAME: &str = "texture";

As an experiment, I changed the name to another name that was not a reserved keyword. The result was that the error went away, and my shader worked as expected.

Thank you for filing!
What is the exact error you are seeing?
Edit: nvm, got it:

---> SharpDX.CompilationException: D:\local\Temp\07b8e0aa-3f03-4634-936d-0be1d0ae92ee.hlsl(1,41-47): error X3000: syntax error: unexpected token 'texture'
D:\local\Temp\07b8e0aa-3f03-4634-936d-0be1d0ae92ee.hlsl(4,12): error X3000: syntax error: unexpected token '.'

The exact error I got was:

    Caused by:
        In Device::create_render_pipeline
          note: label = `label`
        Internal error in VERTEX shader: D3DCompile error (0x80004005): C:\Users\Zach\rivos\corvis\Shader@0x00000285BD8B0D10(51,41-47): error X3000: syntax error: unexpected token 'texture'
    C:\Users\Zach\rivos\corvis\Shader@0x00000285BD8B0D10(54,5-11): error X3086: untyped textures are deprecated in strict mode