summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2022-07-08 18:46:29 -0400
committerGitHub <noreply@github.com>2022-07-08 18:46:29 -0400
commitfac66897af7336b5e2dc2e3b879effb98b30fe47 (patch)
treebb9c79964a90f159554daf8fa62f53043a2b6d29 /Source/Core/VideoCommon
parentf50e7e6e6d4f8d814636095d098aeeca99666f14 (diff)
parente1e0f42b37dd7f2343b9df99222f32ae56963456 (diff)
Merge pull request #10819 from Dentomologist/fix_shader_compilation_warnings
VideoCommon: Fix D3D shader compilation warnings
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/GeometryShaderGen.cpp10
-rw-r--r--Source/Core/VideoCommon/TextureConversionShader.cpp4
-rw-r--r--Source/Core/VideoCommon/TextureConverterShaderGen.cpp4
-rw-r--r--Source/Core/VideoCommon/UberShaderPixel.cpp4
4 files changed, 14 insertions, 8 deletions
diff --git a/Source/Core/VideoCommon/GeometryShaderGen.cpp b/Source/Core/VideoCommon/GeometryShaderGen.cpp
index 10895ccf88..818a22bfa4 100644
--- a/Source/Core/VideoCommon/GeometryShaderGen.cpp
+++ b/Source/Core/VideoCommon/GeometryShaderGen.cpp
@@ -219,7 +219,11 @@ ShaderCode GenerateGeometryShaderCode(APIType api_type, const ShaderHostConfig&
if (wireframe)
out.Write("\tVS_OUTPUT first;\n");
- out.Write("\tfor (int i = 0; i < {}; ++i) {{\n", vertex_in);
+ // Avoid D3D warning about forced unrolling of single-iteration loop
+ if (vertex_in > 1)
+ out.Write("\tfor (int i = 0; i < {}; ++i) {{\n", vertex_in);
+ else
+ out.Write("\tint i = 0;\n");
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
@@ -310,7 +314,9 @@ ShaderCode GenerateGeometryShaderCode(APIType api_type, const ShaderHostConfig&
EmitVertex(out, host_config, uid_data, "f", api_type, wireframe, stereo, true);
}
- out.Write("\t}}\n");
+ // Only close loop if previous code was in one (See D3D warning above)
+ if (vertex_in > 1)
+ out.Write("\t}}\n");
EndPrimitive(out, host_config, uid_data, api_type, wireframe, stereo);
diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp
index dd87dfe0af..ed97c48144 100644
--- a/Source/Core/VideoCommon/TextureConversionShader.cpp
+++ b/Source/Core/VideoCommon/TextureConversionShader.cpp
@@ -712,8 +712,8 @@ static void WriteXFBEncoder(ShaderCode& code, APIType api_type, const EFBCopyPar
WriteSampleColor(code, "rgb", "color1", 1, api_type, params);
// Gamma is only applied to XFB copies.
- code.Write(" color0 = pow(color0, float3(gamma_rcp, gamma_rcp, gamma_rcp));\n"
- " color1 = pow(color1, float3(gamma_rcp, gamma_rcp, gamma_rcp));\n");
+ code.Write(" color0 = pow(abs(color0), float3(gamma_rcp, gamma_rcp, gamma_rcp));\n"
+ " color1 = pow(abs(color1), float3(gamma_rcp, gamma_rcp, gamma_rcp));\n");
// Convert to YUV.
code.Write(" const float3 y_const = float3(0.257, 0.504, 0.098);\n"
diff --git a/Source/Core/VideoCommon/TextureConverterShaderGen.cpp b/Source/Core/VideoCommon/TextureConverterShaderGen.cpp
index 5b6c027c70..ae09871b98 100644
--- a/Source/Core/VideoCommon/TextureConverterShaderGen.cpp
+++ b/Source/Core/VideoCommon/TextureConverterShaderGen.cpp
@@ -278,8 +278,8 @@ ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data)
break;
case EFBCopyFormat::XFB:
- out.Write(
- " ocol0 = float4(pow(texcol.rgb, float3(gamma_rcp, gamma_rcp, gamma_rcp)), 1.0f);\n");
+ out.Write(" ocol0 = float4(pow(abs(texcol.rgb), float3(gamma_rcp, gamma_rcp, gamma_rcp)), "
+ "1.0f);\n");
break;
default:
diff --git a/Source/Core/VideoCommon/UberShaderPixel.cpp b/Source/Core/VideoCommon/UberShaderPixel.cpp
index de1aaa72f7..01df6fe5c6 100644
--- a/Source/Core/VideoCommon/UberShaderPixel.cpp
+++ b/Source/Core/VideoCommon/UberShaderPixel.cpp
@@ -827,8 +827,8 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
out.Write(
" uint alpha_compare_op = alpha_scale << 1 | uint(alpha_op);\n"
"\n"
- " int alpha_A;\n"
- " int alpha_B;\n"
+ " int alpha_A = 0;\n"
+ " int alpha_B = 0;\n"
" if (alpha_bias != 3u || alpha_compare_op > 5u) {{\n"
" // Small optimisation here: alpha_A and alpha_B are unused by compare ops 0-5\n"
" alpha_A = selectAlphaInput(s, ss, {0}colors_0, {0}colors_1, alpha_a) & 255;\n"