Skip to content

Vulkan HLSL with source edit issue #3425

Closed

Description

@Goshido

Description

I added VK_KHR_shader_non_semantic_info device extension and made capture from RenderDoc.

I do get HLSL shader code. But if I try to modify shader source I get compilation error from DXC under RenderDoc. For example

#include "blit_program.inc"


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

...
Running "D:/Development/VulkanSDK/1.3.290.0/Bin/dxc.exe" ...
C:/Users/Goshido/AppData/Local/Temp/shader_input:8:17: error: use of undeclared identifier 'BIND_IMAGE'
[[vk::binding ( BIND_IMAGE, SET_BLIT )]]
                ^

I started experimenting. I modified each -I parameter to compiler in RenderDoc command window and provided absolute paths to every single include directory. Still got same error.

My next experiment: I intentionally made mistake in include file name like this

#include "blit_program-oopsy.inc"

...

Compiler error did not change again. It looks like RenderDoc removes #include from source files and fed them into DXC. Would you kindly help?

Steps to reproduce

  1. Take Vulkan HLSL shader code which contains #include's
  2. Compile it with -Od and -fspv-debug=vulkan-with-source
  3. Use that SPIR-V blob in Vulkan 1.1 application with extension VK_KHR_shader_non_semantic_info enabled
  4. Capture application
  5. Go to corresponding drawcall/dispatch and try to modify shader
  6. Apply changes

Problem: RenderDoc reports compilation error from DXC backend.

Expected: Shader source compiled successfully and changes are visible in RenderDoc

Environment

  • RenderDoc version: 1.34
  • Operating System: Windows 11 Pro (23H2, Build 22631.4112)
  • Graphics API: Vulkan 1.1
  • GPU: NVIDIA GeForce RTX 4080, game ready driver 560.94
  • DXC:
    • RenderDoc uses binary from official Vulkan SKD 1.3.290.0, v1.8.0.4650(49d1ae9a0)
    • SPIR-V blobs are compiled with v1.8.2407.10013 from commit a2a220bc616ca28848ec0af77ad33a09f92fa43a

Additional information

Default compilation command after Edit shader button press:

-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

Link to device report on Vulkan GPU info web-resource.

Activity

  1. added
    Bug
    Unresolved
    on Sep 9, 2024
  2. baldurk commented on Sep 9, 2024

    @baldurk
    Owner

    I can't verify with 100% certainty as you didn't include a full reproducible test case but this looks like a DXC bug to me. From a bit of experimentation and checking the source, it looks like the SPIR-V backend doesn't include debug information for include files that only have definitions but no code. You should be able to see that the shader viewer/editor doesn't have source tabs for any such include files.

    Without those files it is impossible for RenderDoc to recompile the edited shaders.

    This setup:

    // test.hlsl
    #define OUT_COL float4(1, 0, 1, 1)
    
    // source.hlsl
    #include "test.hlsl"
    
    float4 main() : SV_Target0 {
      return OUT_COL;
    }
    

    built with dxc -spirv -fspv-debug=vulkan-with-source source.hlsl -T ps_6_0 -Fo test.spv only includes the source of source.hlsl in the output, as verified with spirv-dis.

    If I make a small change:

    // test.hlsl
    #define OUT_COL float4(1, 0, 1, 1)
    
    void helper() { }
    
    // source.hlsl
    #include "test.hlsl"
    
    float4 main() : SV_Target0 {
      helper();
      return OUT_COL;
    }
    

    Then the same build works correctly and includes the test.hlsl source. You could use this as a workaround until the compiler is fixed.

    If you do see the source for those include files in RenderDoc when editing then it's a different bug, but in that case you need to provide a specific repro case as I followed your steps and only by partial luck managed to reproduce this, as if I had used a function in the first place I would not have been able to repro the bug.

  3. Goshido commented on Sep 9, 2024

    @Goshido
    Author

    Thanks for investigation @baldurk !👍

    I created an issue in DXC repo.

  4. locked as resolved and limited conversation to collaborators on May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugUnresolved

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions