From 3b752c4d5d46cfda50a51c47c346e94257e9c3d9 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 1 Aug 2021 15:09:20 -0700 Subject: [PATCH] UberShaderPixel: Rename ApiType to api_type --- Source/Core/VideoCommon/UberShaderPixel.cpp | 36 ++++++++++----------- Source/Core/VideoCommon/UberShaderPixel.h | 4 +-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Source/Core/VideoCommon/UberShaderPixel.cpp b/Source/Core/VideoCommon/UberShaderPixel.cpp index d6aa505f69..f7c5d4c309 100644 --- a/Source/Core/VideoCommon/UberShaderPixel.cpp +++ b/Source/Core/VideoCommon/UberShaderPixel.cpp @@ -34,7 +34,7 @@ PixelShaderUid GetPixelShaderUid() return out; } -void ClearUnusedPixelShaderUidBits(APIType ApiType, const ShaderHostConfig& host_config, +void ClearUnusedPixelShaderUidBits(APIType api_type, const ShaderHostConfig& host_config, PixelShaderUid* uid) { pixel_ubershader_uid_data* const uid_data = uid->GetUidData(); @@ -42,11 +42,11 @@ void ClearUnusedPixelShaderUidBits(APIType ApiType, const ShaderHostConfig& host // 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. We also disable the // uint output when logic op is not supported (i.e. driver/device does not support D3D11.1). - if (ApiType != APIType::D3D || !host_config.backend_logic_op) + if (api_type != APIType::D3D || !host_config.backend_logic_op) uid_data->uint_output = 0; } -ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, +ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config, const pixel_ubershader_uid_data* uid_data) { const bool per_pixel_lighting = host_config.per_pixel_lighting; @@ -63,13 +63,13 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, out.Write("// Pixel UberShader for {} texgens{}{}\n", numTexgen, early_depth ? ", early-depth" : "", per_pixel_depth ? ", per-pixel depth" : ""); - WritePixelShaderCommonHeader(out, ApiType, host_config, bounding_box); - WriteUberShaderCommonHeader(out, ApiType, host_config); + WritePixelShaderCommonHeader(out, api_type, host_config, bounding_box); + WriteUberShaderCommonHeader(out, api_type, host_config); if (per_pixel_lighting) WriteLightingFunction(out); // Shader inputs/outputs in GLSL (HLSL is in main). - if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan) + if (api_type == APIType::OpenGL || api_type == APIType::Vulkan) { if (use_dual_source) { @@ -110,7 +110,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, if (host_config.backend_geometry_shaders) { out.Write("VARYING_LOCATION(0) in VertexData {{\n"); - GenerateVSOutputMembers(out, ApiType, numTexgen, host_config, + GenerateVSOutputMembers(out, api_type, numTexgen, host_config, GetInterpolationQualifier(msaa, ssaa, true, true)); if (stereo) @@ -158,7 +158,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, out.Write(", int2 fixpoint_uv{}", i); out.Write(") {{\n"); - if (ApiType == APIType::D3D) + if (api_type == APIType::D3D) { out.Write(" switch (index) {{\n"); for (u32 i = 0; i < numTexgen; i++) @@ -227,9 +227,9 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, // Doesn't look like DirectX supports this. Oh well the code path is here just in case it // supports this in the future. out.Write("int4 sampleTexture(uint sampler_num, float3 uv) {{\n"); - if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan) + if (api_type == APIType::OpenGL || api_type == APIType::Vulkan) out.Write(" return iround(texture(samp[sampler_num], uv) * 255.0);\n"); - else if (ApiType == APIType::D3D) + else if (api_type == APIType::D3D) out.Write(" return iround(Tex[sampler_num].Sample(samp[sampler_num], uv) * 255.0);\n"); out.Write("}}\n\n"); } @@ -243,9 +243,9 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, " switch(sampler_num) {{\n"); for (int i = 0; i < 8; i++) { - if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan) + if (api_type == APIType::OpenGL || api_type == APIType::Vulkan) out.Write(" case {}u: return iround(texture(samp[{}], uv) * 255.0);\n", i, i); - else if (ApiType == APIType::D3D) + else if (api_type == APIType::D3D) out.Write(" case {}u: return iround(Tex[{}].Sample(samp[{}], uv) * 255.0);\n", i, i, i); } out.Write(" }}\n" @@ -404,7 +404,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, // The switch statements in these functions appear to get transformed into an if..else chain // on NVIDIA's OpenGL/Vulkan drivers, resulting in lower performance than the D3D counterparts. // Transforming the switch into a binary tree of ifs can increase performance by up to 20%. - if (ApiType == APIType::D3D) + if (api_type == APIType::D3D) { out.Write("// Helper function for Alpha Test\n" "bool alphaCompare(int a, int b, uint compare) {{\n" @@ -669,7 +669,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, out.Write(")\n\n"); } - if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan) + if (api_type == APIType::OpenGL || api_type == APIType::Vulkan) { if (early_depth && host_config.backend_early_z) out.Write("FORCE_EARLY_Z;\n"); @@ -745,7 +745,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, " float4 lit_colors_1 = colors_1;\n" " float3 lit_normal = normalize(Normal.xyz);\n" " float3 lit_pos = WorldPos.xyz;\n"); - WriteVertexLighting(out, ApiType, "lit_pos", "lit_normal", "colors_0", "colors_1", + WriteVertexLighting(out, api_type, "lit_pos", "lit_normal", "colors_0", "colors_1", "lit_colors_0", "lit_colors_1"); color_input_prefix = "lit_"; } @@ -754,7 +754,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, BitfieldExtract<&GenMode::numtevstages>("bpmem_genmode")); out.Write(" // Main tev loop\n"); - if (ApiType == APIType::D3D) + if (api_type == APIType::D3D) { // Tell DirectX we don't want this loop unrolled (it crashes if it tries to) out.Write(" [loop]\n"); @@ -1092,7 +1092,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, " if ((bpmem_genmode & {}u) != 0u) {{\n", 1 << GenMode().zfreeze.StartBit()); out.Write(" float2 screenpos = rawpos.xy * " I_EFBSCALE ".xy;\n"); - if (ApiType == APIType::OpenGL) + if (api_type == APIType::OpenGL) { out.Write(" // OpenGL has reversed vertical screenspace coordinates\n" " screenpos.y = 528.0 - screenpos.y;\n"); @@ -1233,7 +1233,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, "\n"); // D3D requires that the shader outputs be uint when writing to a uint render target for logic op. - if (ApiType == APIType::D3D && uid_data->uint_output) + if (api_type == APIType::D3D && uid_data->uint_output) { out.Write(" if (bpmem_rgba6_format)\n" " ocol0 = uint4(TevResult & 0xFC);\n" diff --git a/Source/Core/VideoCommon/UberShaderPixel.h b/Source/Core/VideoCommon/UberShaderPixel.h index 5de268c250..2ae7811050 100644 --- a/Source/Core/VideoCommon/UberShaderPixel.h +++ b/Source/Core/VideoCommon/UberShaderPixel.h @@ -27,10 +27,10 @@ using PixelShaderUid = ShaderUid; PixelShaderUid GetPixelShaderUid(); -ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config, +ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config, const pixel_ubershader_uid_data* uid_data); void EnumeratePixelShaderUids(const std::function& callback); -void ClearUnusedPixelShaderUidBits(APIType ApiType, const ShaderHostConfig& host_config, +void ClearUnusedPixelShaderUidBits(APIType api_type, const ShaderHostConfig& host_config, PixelShaderUid* uid); } // namespace UberShader