Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10836 from iwubcode/d3d_uint_fix
VideoCommon: fix uint shader compiler error when using d3d
  • Loading branch information
JMC47 committed Oct 18, 2022
2 parents ee5a93c + 637dca6 commit 9aece18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
19 changes: 14 additions & 5 deletions Source/Core/VideoCommon/PixelShaderGen.cpp
Expand Up @@ -1665,9 +1665,17 @@ static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_dat
else
out.Write(")) {{\n");

out.Write("\t\tocol0 = float4(0.0, 0.0, 0.0, 0.0);\n");
if (use_dual_source && !(api_type == APIType::D3D && uid_data->uint_output))
out.Write("\t\tocol1 = float4(0.0, 0.0, 0.0, 0.0);\n");
if (uid_data->uint_output)
out.Write("\t\tocol0 = uint4(0, 0, 0, 0);\n");
else
out.Write("\t\tocol0 = float4(0.0, 0.0, 0.0, 0.0);\n");
if (use_dual_source)
{
if (uid_data->uint_output)
out.Write("\t\tocol1 = uint4(0, 0, 0, 0);\n");
else
out.Write("\t\tocol1 = float4(0.0, 0.0, 0.0, 0.0);\n");
}
if (per_pixel_depth)
{
out.Write("\t\tdepth = {};\n",
Expand Down Expand Up @@ -1795,8 +1803,9 @@ static void WriteLogicOp(ShaderCode& out, const pixel_shader_uid_data* uid_data)
static void WriteColor(ShaderCode& out, APIType api_type, const pixel_shader_uid_data* uid_data,
bool use_dual_source)
{
// D3D requires that the shader outputs be uint when writing to a uint render target for logic op.
if (api_type == APIType::D3D && uid_data->uint_output)
// Some backends require the shader outputs be uint when writing to a uint render target for logic
// op.
if (uid_data->uint_output)
{
if (uid_data->rgba6_format)
out.Write("\tocol0 = uint4(prev & 0xFC);\n");
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/VideoCommon/UberShaderPixel.cpp
Expand Up @@ -1093,8 +1093,9 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
" }}\n");
}

// D3D requires that the shader outputs be uint when writing to a uint render target for logic op.
if (api_type == APIType::D3D && uid_data->uint_output)
// Some backends require that the shader outputs be uint when writing to a uint render target for
// logic op.
if (uid_data->uint_output)
{
out.Write(" if (bpmem_rgba6_format)\n"
" ocol0 = uint4(TevResult & 0xFC);\n"
Expand Down

0 comments on commit 9aece18

Please sign in to comment.