DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

[SPIR-V] Compile and generate reflection information for shader in a single command.

Open wookie41 opened this issue 2 years ago • 2 comments

Hello.

I've been trying to get dxc to compile to SPIRV, stripping reflection infro from the shader and generate reflection info for SPIRV-reflect using a single command like this:

dxc -Qstrip_reflect -spirv -fspv-reflect -fspv-target-env=vulkan1.3 -HV 2021 -T ps_6_7 -Fre reflect/base.frag.ref -Fo bin/base.frag.spv base.frag.hlsl

But instead of two files - one .ref and .spv, I only get the .spv one, with (what it looks like) reflection info in it, as SPIRV-Reflect is able to read the reflection info from it. I've been trying to do it according to the description in this issue, but wasn't able to and this issue was closed, as the OP was using the SDK and I have to use the commandline.

Any suggestions?

wookie41 avatar Jun 02 '22 12:06 wookie41

@sudonatalie @kuhar. I've confirmed that this only happens with spirv

pow2clk avatar Jun 13 '22 20:06 pow2clk

The -Qstrip_reflect and -Fre options are not currently supported by the SPIR-V backend and we don't have any current plans to implement them, although PR contributions are welcome and will be reviewed.

As a workaround, you can follow up your compilation with -fspv-reflect by running spirv-opt --strip-nonsemantic on the results to output a SPIR-V module with all reflection information removed. spirv-opt is distributed as part of the Vulkan SDK and at KhronosGroup/SPIRV-Tools.

sudonatalie avatar Jun 14 '22 21:06 sudonatalie