Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10819 from Dentomologist/fix_shader_compilation_w…
…arnings

VideoCommon: Fix D3D shader compilation warnings
  • Loading branch information
JMC47 committed Jul 8, 2022
2 parents f50e7e6 + e1e0f42 commit fac6689
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions Source/Core/VideoCommon/GeometryShaderGen.cpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/TextureConversionShader.cpp
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/TextureConverterShaderGen.cpp
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoCommon/UberShaderPixel.cpp
Expand Up @@ -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"
Expand Down

0 comments on commit fac6689

Please sign in to comment.