DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

[SPIR-V] Non semantic shader information issue (-fspv-debug=vulkan-with-source)

Open Goshido opened this issue 5 months ago • 7 comments

Description I'm using Vulkan + HLSL workflow. After editing shader in RenderDoc and press compile there is a compilation error:

Running "D:/Development/VulkanSDK/1.3.290.0/Bin/dxc.exe" -T ps_6_0 -E PS -spirv -fspv-target-env=vulkan1.1 -Fo C:/Users/Goshido/AppData/Local/Temp/shader_output C:/Users/Goshido/AppData/Local/Temp/shader_input
error: missing entry point definition


Process crashed with code -2147467259.
Output file is 0 bytes

I also noticed that SPIR-V blobs produced by DXC v1.8.2407.10013 a2a220bc616ca28848ec0af77ad33a09f92fa43a showed exactly the same compilation flag information in RenderDoc:

-T {hlsl_stage2}_6_0 -E {entry_point} -spirv -fspv-target-env={vulkan_ver}  -E PS -T ps_6_8 -HV 2021 -spirv 
-fvk-use-dx-layout -fspv-reduce-load-size -fspv-target-env=vulkan1.1 -enable-16bit-types -WX -I tools\editor\hlsl
-I tools\editor\include -I app\src\main\hlsl -I app\src\main\cpp\include\pbr -Od -fspv-debug=vulkan-with-source
-Fo tools\editor\editor-assets\shaders\blit.ps.spv -Qembed_debug

Now SPIR-V blobs compiled by recent DXC v1.8.2407.10091 75ff50caa046a054747ae15b5c1910a4c8aa1917 shows less information:

-T {hlsl_stage2}_6_0 -E {entry_point} -spirv -fspv-target-env={vulkan_ver}

Steps to Reproduce

  1. Take the following shader code:

blit_program.ps:

#include "blit_program.inc"
#include "color_space.ps"
#include "srgb_program.inc"


// 1.0H / 2.4H
#define INVERSE_GAMMA           4.16667e-1F

[[vk::constant_id ( CONST_INVERSE_GAMMA )]]
float const                     g_inverseGamma = INVERSE_GAMMA;

[[vk::binding ( BIND_IMAGE, SET_BLIT )]]
Texture2D<float32_t4>           g_image:        register ( t0 );

[[vk::binding ( BIND_SAMPLER, SET_BLIT )]]
SamplerState                    g_sampler:      register ( s0 );

struct InputData
{
    [[vk::location ( ATT_SLOT_UV )]]
    noperspective float32_t2    _uv:            UV;
};

//----------------------------------------------------------------------------------------------------------------------

float32_t4 PS ( in InputData inputData ): SV_Target0
{
    float16_t3 const color = (float16_t3)g_image.SampleLevel ( g_sampler, inputData._uv, 0.0F ).xyz;
    return float32_t4 ( LinearToSRGB ( color, (float16_t)g_inverseGamma ), 1.0F );
}

color_space.ps:

#ifndef COLOR_SPACE_PS
#define COLOR_SPACE_PS


float32_t3 LinearToSRGB ( in float16_t3 ldr, in float16_t inverseGamma )
{
    // See https://entropymine.com/imageworsener/srgbformula/
    float16_t3 const a = ldr * 12.92H;
    float16_t3 const b = 1.055H * pow ( ldr, inverseGamma ) - 0.055H;
    return (float32_t3)lerp ( a, b, (float16_t3)( ldr > 3.1308e-3H ) );
}


#endif // COLOR_SPACE_PS

blit_program.inc:

#ifndef BLIT_PROGRAM_INC
#define BLIT_PROGRAM_INC


#define ATT_SLOT_UV     0

#define SET_BLIT        0
#define BIND_IMAGE      0
#define BIND_SAMPLER    1


#endif // BLIT_PROGRAM_INC

srgb_program.inc:

#ifndef SRGB_PROGRAM_INC
#define SRGB_PROGRAM_INC


#define CONST_INVERSE_GAMMA     0


#endif // SRGB_PROGRAM_INC
  1. Compile it with the following flags:
dxc.exe                                                     ^
    -HV 2021                                                ^
    -spirv                                                  ^
    -fvk-use-dx-layout                                      ^
    -fspv-reduce-load-size                                  ^
    -fspv-target-env=vulkan1.1                              ^
    -enable-16bit-types                                     ^
    -WX                                                     ^
    -I tools\editor\hlsl                                    ^
    -I tools\editor\include                                 ^
    -I app\src\main\hlsl                                    ^
    -I app\src\main\cpp\include\pbr                         ^
    -Od                                                     ^
    -fspv-debug=vulkan-with-source                          ^
    -E PS                                                   ^
    -T ps_6_8                                               ^
    -Fo tools\editor\editor-assets\shaders\blit.ps.spv      ^
    tools\editor\hlsl\blit.ps
  1. Use this program and made capture.
  2. Try to edit program blit_program.ps by multiplying color variable by 0.5H.
...

float32_t4 PS ( in InputData inputData ): SV_Target0
{
    float16_t3 const color = (float16_t3)g_image.SampleLevel ( g_sampler, inputData._uv, 0.0F ).xyz;
    return float32_t4 ( LinearToSRGB ( color * 0.5H, (float16_t)g_inverseGamma ), 1.0F ); <--------------------------
}
  1. Press apply changes.

Actual Behavior Compilation fails:

Running "D:/Development/VulkanSDK/1.3.290.0/Bin/dxc.exe" -T ps_6_0 -E PS -spirv
-fspv-target-env=vulkan1.1 -Fo C:/Users/Goshido/AppData/Local/Temp/shader_output
C:/Users/Goshido/AppData/Local/Temp/shader_input
error: missing entry point definition


Process crashed with code -2147467259.
Output file is 0 bytes

Expected: Compilation success.

Would you kindly help?

Environment

  • git submodule update --init has been invoked before build
  • hctbuild build parameters: -official -rel -x64 -vs2022 -speak-up -no-dxilconv -spirv
  • Visual Studio 2022 Community components were up to date.
  • Windows 11 Pro (23H2, Build 22631.4169)
  • dxc.exe v1.8.2407.10091 executable, commit SHA-1 75ff50caa046a054747ae15b5c1910a4c8aa1917
  • RenderDoc v1.35

Additional information

Here is blobs from old and new DXC: SPIR-V blobs.zip.

The video with problem:

https://github.com/user-attachments/assets/f0ef8f84-19f0-4230-9219-11175e0bf62c

Initially I created issue for RenderDoc: #3448. Issue has been closed because it's not RenderDoc issue in the first place.

Goshido avatar Sep 29 '24 10:09 Goshido