summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorStenzek <stenzek@users.noreply.github.com>2017-09-06 18:33:47 +1000
committerGitHub <noreply@github.com>2017-09-06 18:33:47 +1000
commit1073053df98cb019d49266c45dfe716367da0d52 (patch)
tree878f99f2bfa98f5993cfc0bfcb9b005ec2ebf0ff /Source/Core/VideoCommon
parent2e20cd0ffdfb909a52a70217474fa5b53bd12996 (diff)
parent84f8ebd95fc70bc3482a53f31d5ebcc5266bb4b7 (diff)
Merge pull request #6026 from stenzek/d3d-ubershader-logicop
ShaderGen: Output uint when logic op is enabled for D3D ubershaders
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp10
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.h2
-rw-r--r--Source/Core/VideoCommon/UberShaderPixel.cpp42
-rw-r--r--Source/Core/VideoCommon/UberShaderPixel.h1
4 files changed, 41 insertions, 14 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index 5e561456ab..990f5f938f 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -322,6 +322,16 @@ PixelShaderUid GetPixelShaderUid()
return out;
}
+void ClearUnusedPixelShaderUidBits(APIType ApiType, PixelShaderUid* uid)
+{
+ pixel_shader_uid_data* uid_data = uid->GetUidData<pixel_shader_uid_data>();
+
+ // OpenGL and Vulkan convert implicitly normalized color outputs to their uint representation.
+ // Therefore, it is not necessary to use a uint output on these backends.
+ if (ApiType != APIType::D3D)
+ uid_data->uint_output = 0;
+}
+
void WritePixelShaderCommonHeader(ShaderCode& out, APIType ApiType, u32 num_texgens,
bool per_pixel_lighting, bool bounding_box)
{
diff --git a/Source/Core/VideoCommon/PixelShaderGen.h b/Source/Core/VideoCommon/PixelShaderGen.h
index 253dc59e22..b480777c41 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.h
+++ b/Source/Core/VideoCommon/PixelShaderGen.h
@@ -162,5 +162,5 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const ShaderHostConfig& host
const pixel_shader_uid_data* uid_data);
void WritePixelShaderCommonHeader(ShaderCode& out, APIType ApiType, u32 num_texgens,
bool per_pixel_lighting, bool bounding_box);
-ShaderCode GeneratePixelShaderCode(APIType ApiType, const pixel_shader_uid_data* uid_data);
+void ClearUnusedPixelShaderUidBits(APIType ApiType, PixelShaderUid* uid);
PixelShaderUid GetPixelShaderUid();
diff --git a/Source/Core/VideoCommon/UberShaderPixel.cpp b/Source/Core/VideoCommon/UberShaderPixel.cpp
index 4e760408c5..494adca95d 100644
--- a/Source/Core/VideoCommon/UberShaderPixel.cpp
+++ b/Source/Core/VideoCommon/UberShaderPixel.cpp
@@ -29,6 +29,16 @@ PixelShaderUid GetPixelShaderUid()
return out;
}
+void ClearUnusedPixelShaderUidBits(APIType ApiType, PixelShaderUid* uid)
+{
+ pixel_ubershader_uid_data* uid_data = uid->GetUidData<pixel_ubershader_uid_data>();
+
+ // OpenGL and Vulkan convert implicitly normalized color outputs to their uint representation.
+ // Therefore, it is not necessary to use a uint output on these backends.
+ if (ApiType != APIType::D3D)
+ uid_data->uint_output = 0;
+}
+
ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
const pixel_ubershader_uid_data* uid_data)
{
@@ -654,13 +664,19 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
if (early_depth && host_config.backend_early_z)
out.Write("[earlydepthstencil]\n");
- out.Write("void main(\n"
- " out float4 ocol0 : SV_Target0,\n"
- " out float4 ocol1 : SV_Target1,\n"
- " %s\n",
- per_pixel_depth ? "\n out float depth : SV_Depth," : "");
+ out.Write("void main(\n");
+ if (uid_data->uint_output)
+ {
+ out.Write(" out uint4 ocol0 : SV_Target,\n");
+ }
+ else
+ {
+ out.Write(" out float4 ocol0 : SV_Target0,\n"
+ " out float4 ocol1 : SV_Target1,\n");
+ }
+ if (per_pixel_depth)
+ out.Write(" out float depth : SV_Depth,\n");
out.Write(" in float4 rawpos : SV_Position,\n");
-
out.Write(" in %s float4 colors_0 : COLOR0,\n", GetInterpolationQualifier(msaa, ssaa));
out.Write(" in %s float4 colors_1 : COLOR1", GetInterpolationQualifier(msaa, ssaa));
@@ -1186,14 +1202,14 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
out.Write(" else\n"
" ocol0.a = float(TevResult.a >> 2) / 63.0;\n"
" \n");
- }
- if (use_dual_source)
- {
- out.Write(" // Dest alpha override (dual source blending)\n"
- " // Colors will be blended against the alpha from ocol1 and\n"
- " // the alpha from ocol0 will be written to the framebuffer.\n"
- " ocol1 = float4(0.0, 0.0, 0.0, float(TevResult.a) / 255.0);\n");
+ if (use_dual_source)
+ {
+ out.Write(" // Dest alpha override (dual source blending)\n"
+ " // Colors will be blended against the alpha from ocol1 and\n"
+ " // the alpha from ocol0 will be written to the framebuffer.\n"
+ " ocol1 = float4(0.0, 0.0, 0.0, float(TevResult.a) / 255.0);\n");
+ }
}
if (bounding_box)
diff --git a/Source/Core/VideoCommon/UberShaderPixel.h b/Source/Core/VideoCommon/UberShaderPixel.h
index 3a5a8f8435..5bacf68a43 100644
--- a/Source/Core/VideoCommon/UberShaderPixel.h
+++ b/Source/Core/VideoCommon/UberShaderPixel.h
@@ -29,4 +29,5 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
const pixel_ubershader_uid_data* uid_data);
void EnumeratePixelShaderUids(const std::function<void(const PixelShaderUid&)>& callback);
+void ClearUnusedPixelShaderUidBits(APIType ApiType, PixelShaderUid* uid);
}