From e009dce47aed4cc55f8b0200b8a8348a66512f66 Mon Sep 17 00:00:00 2001 From: myT <> Date: Mon, 16 Oct 2023 02:33:43 +0200 Subject: [PATCH] r_rtColorFormat is now a UNORM format, fixed shader data for PIX debugging --- code/renderer/grp_main.cpp | 2 +- code/renderer/hlsl/post_gamma.hlsl | 3 +-- code/renderer/hlsl/post_inverse_gamma.hlsl | 3 +-- code/renderer/rhi_d3d12.cpp | 12 ++++++++---- code/renderer/rhi_local.h | 1 + code/shadercomp/shadercomp.cpp | 4 +++- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/code/renderer/grp_main.cpp b/code/renderer/grp_main.cpp index de6562a..48d37ad 100644 --- a/code/renderer/grp_main.cpp +++ b/code/renderer/grp_main.cpp @@ -260,7 +260,7 @@ void GRP::Init() renderTargetFormat = TextureFormat::R10G10B10A2_UNorm; break; case RTCF_R16G16B16A16: - renderTargetFormat = TextureFormat::RGBA64_Float; + renderTargetFormat = TextureFormat::RGBA64_UNorm; break; case RTCF_R8G8B8A8: default: diff --git a/code/renderer/hlsl/post_gamma.hlsl b/code/renderer/hlsl/post_gamma.hlsl index 1693bcb..4bab28f 100644 --- a/code/renderer/hlsl/post_gamma.hlsl +++ b/code/renderer/hlsl/post_gamma.hlsl @@ -73,8 +73,7 @@ SamplerState sampler0 : register(s0); float4 ps(VOut input) : SV_Target { - float3 raw = texture0.Sample(sampler0, input.texCoords).rgb; - float3 base = saturate(raw); // can have negative values in the float render target + float3 base = texture0.Sample(sampler0, input.texCoords).rgb; float3 gc = pow(base, invGamma) * brightness; return MakeGreyscale(float4(gc.rgb, 1.0), greyscale); diff --git a/code/renderer/hlsl/post_inverse_gamma.hlsl b/code/renderer/hlsl/post_inverse_gamma.hlsl index 497acae..9ab4d4a 100644 --- a/code/renderer/hlsl/post_inverse_gamma.hlsl +++ b/code/renderer/hlsl/post_inverse_gamma.hlsl @@ -62,8 +62,7 @@ SamplerState sampler0 : register(s0); float4 ps(VOut input) : SV_Target { - float3 raw = texture0.Sample(sampler0, input.texCoords).rgb; - float3 base = saturate(raw); // can have negative values in the float render target + float3 base = texture0.Sample(sampler0, input.texCoords).rgb; float3 linearSpace = pow(base * invBrightness, gamma); return float4(linearSpace, 1.0f); diff --git a/code/renderer/rhi_d3d12.cpp b/code/renderer/rhi_d3d12.cpp index 73d090b..89c2d7e 100644 --- a/code/renderer/rhi_d3d12.cpp +++ b/code/renderer/rhi_d3d12.cpp @@ -1497,6 +1497,7 @@ namespace RHI switch(format) { case TextureFormat::RGBA32_UNorm: return DXGI_FORMAT_R8G8B8A8_UNORM; + case TextureFormat::RGBA64_UNorm: return DXGI_FORMAT_R16G16B16A16_UNORM; case TextureFormat::RGBA64_Float: return DXGI_FORMAT_R16G16B16A16_FLOAT; case TextureFormat::Depth32_Float: return DXGI_FORMAT_D32_FLOAT; case TextureFormat::Depth24_Stencil8: return DXGI_FORMAT_D24_UNORM_S8_UINT; @@ -3809,14 +3810,17 @@ namespace RHI PushArg(entryPointW); PushArg(L"-T"); PushArg(targetW); - PushArg(DXC_ARG_WARNINGS_ARE_ERRORS); + PushArg(DXC_ARG_WARNINGS_ARE_ERRORS); // -WX #if defined(D3D_DEBUG) - PushArg(DXC_ARG_DEBUG); - PushArg(DXC_ARG_SKIP_OPTIMIZATIONS); + PushArg(DXC_ARG_DEBUG); // -Zi embeds debug info + PushArg(DXC_ARG_SKIP_OPTIMIZATIONS); // -Od disables optimizations + PushArg(DXC_ARG_ENABLE_STRICTNESS); // -Ges enables strict mode + PushArg(DXC_ARG_IEEE_STRICTNESS); // -Gis forces IEEE strictness + PushArg(L"-Qembed_debug"); // -Qembed_debug embeds debug info in shader container #else PushArg(L"-Qstrip_debug"); PushArg(L"-Qstrip_reflect"); - PushArg(DXC_ARG_OPTIMIZATION_LEVEL3); + PushArg(DXC_ARG_OPTIMIZATION_LEVEL3); // -O3 #endif PushArg(L"-D"); PushArg(desc.stage == ShaderStage::Vertex ? L"VERTEX_SHADER=1" : L"VERTEX_SHADER=0"); diff --git a/code/renderer/rhi_local.h b/code/renderer/rhi_local.h index 5fe4dad..a4f3ca6 100644 --- a/code/renderer/rhi_local.h +++ b/code/renderer/rhi_local.h @@ -158,6 +158,7 @@ namespace RHI enum Id { RGBA32_UNorm, + RGBA64_UNorm, RGBA64_Float, Depth32_Float, RG16_UNorm, diff --git a/code/shadercomp/shadercomp.cpp b/code/shadercomp/shadercomp.cpp index 0687aeb..3f7ca66 100644 --- a/code/shadercomp/shadercomp.cpp +++ b/code/shadercomp/shadercomp.cpp @@ -51,7 +51,9 @@ void CompileShader(const ShaderArgs& args, int extraCount = 0, const char** extr // -Ges: Enable strict mode // -Gis: Force IEEE strictness - strcpy(temp, va("dxc.exe -Fh %s -E %s -T %s -WX -Ges -Gis", + // -Zi: Embed debug info + // -Qembed_debug: Embed debug info in shader container + strcpy(temp, va("dxc.exe -Fh %s -E %s -T %s -WX -Ges -Gis -Zi -Qembed_debug", args.headerPath, args.entryPoint, args.targetProfile)); for(int i = 0; i < extraCount; ++i)