diff options
| author | Andre Weissflog <floooh@gmail.com> | 2024-09-01 15:46:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-01 15:46:52 +0200 |
| commit | 189843bf4f86969ca4cc4b6d94e793a37c5128a7 (patch) | |
| tree | 30d432b7d004b7f12630851a232bc58cdf0d361b | |
| parent | f5bf1a28ac8cb2a5e059d40d70ac345d8c292d42 (diff) | |
sokol_gfx.h d3d11: add sg_desc.d3d11_shader_debugging bool flag (#1101)
Fixes #1043
| -rw-r--r-- | CHANGELOG.md | 14 | ||||
| -rw-r--r-- | sokol_gfx.h | 15 |
2 files changed, 28 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 3038841c..d73e84c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ ## Updates +### 01-Sep-2024 + +- sokol_gfx.h d3d11: added a new configuration flag `d3d11_shader_debugging` + to the `sg_desc` struct. When this is true, D3D11 shaders which are provided + as HLSL source code will be compiled with debug information and no optimization + which allows shader debugging in tools like RenderDoc. If you use `sokol-shdc` + to build shaders, just omit the `--bytecode / -b` cmdline option to get + HLSL source code instead of bytecode, if you use the `fips` build system + wrapper (like the `sokol-samples` project), just replace the cmake macro + `sokol_shader()` with `sokol_shader_debuggable()`. + + For details see issue https://github.com/floooh/sokol/issues/1043 + and PR: https://github.com/floooh/sokol/pull/1101. + ### 31-Aug-2024 - Some cleanup work in the WebGPU backend bindgroups cache which fixes diff --git a/sokol_gfx.h b/sokol_gfx.h index 9e573926..7e94f9d1 100644 --- a/sokol_gfx.h +++ b/sokol_gfx.h @@ -3889,6 +3889,12 @@ typedef enum sg_log_item { before sg_setup() is called .environment.d3d11.device_context a pointer to the ID3D11DeviceContext object + .d3d11_shader_debugging + set this to true to compile shaders which are provided as HLSL source + code with debug information and without optimization, this allows + shader debugging in tools like RenderDoc, to output source code + instead of byte code from sokol-shdc, omit the `--binary` cmdline + option WebGPU specific: .wgpu_disable_bindgroups_cache @@ -4001,6 +4007,7 @@ typedef struct sg_desc { int uniform_buffer_size; int max_commit_listeners; bool disable_validation; // disable validation layer even in debug mode, useful for tests + bool d3d11_shader_debugging; // if true, HLSL shaders are compiled with D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION bool mtl_force_managed_storage_mode; // for debugging: use Metal managed storage mode for resources even with UMA bool mtl_use_command_buffer_with_retained_references; // Metal: use a managed MTLCommandBuffer which ref-counts used resources bool wgpu_disable_bindgroups_cache; // set to true to disable the WebGPU backend BindGroup cache @@ -10712,6 +10719,12 @@ _SOKOL_PRIVATE ID3DBlob* _sg_d3d11_compile_shader(const sg_shader_stage_desc* st return NULL; } SOKOL_ASSERT(stage_desc->d3d11_target); + UINT flags1 = D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR; + if (_sg.desc.d3d11_shader_debugging) { + flags1 |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; + } else { + flags1 |= D3DCOMPILE_OPTIMIZATION_LEVEL3; + } ID3DBlob* output = NULL; ID3DBlob* errors_or_warnings = NULL; HRESULT hr = _sg.d3d11.D3DCompile_func( @@ -10722,7 +10735,7 @@ _SOKOL_PRIVATE ID3DBlob* _sg_d3d11_compile_shader(const sg_shader_stage_desc* st NULL, // pInclude stage_desc->entry ? stage_desc->entry : "main", // pEntryPoint stage_desc->d3d11_target, // pTarget - D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR | D3DCOMPILE_OPTIMIZATION_LEVEL3, // Flags1 + flags1, // Flags1 0, // Flags2 &output, // ppCode &errors_or_warnings); // ppErrorMsgs |