diff options
| author | Tilka <tilkax@gmail.com> | 2023-12-12 22:20:23 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-12 22:20:23 +0000 |
| commit | 53a51a6f1bd166539836a2c3eee57b7b42e47cd4 (patch) | |
| tree | 36170c66b029155bf63e0e6ad635e2931dba44be /Source/Core/VideoCommon | |
| parent | 8c99198251be5c1857f8f86d0a61badffa8bdc3e (diff) | |
| parent | e883bbc57a18ade43e812e51a522258b0293ce63 (diff) | |
Merge pull request #12405 from lioncash/shadow2
General: Resolve lingering -Wshadow warnings
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/LightingShaderGen.cpp | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/Source/Core/VideoCommon/LightingShaderGen.cpp b/Source/Core/VideoCommon/LightingShaderGen.cpp index 646f7277b5..4fb2c98ebd 100644 --- a/Source/Core/VideoCommon/LightingShaderGen.cpp +++ b/Source/Core/VideoCommon/LightingShaderGen.cpp @@ -214,43 +214,44 @@ void GenerateCustomLightingHeaderDetails(ShaderCode* out, u32 enablelighting, u3 out->Write("\tint light_count;\n"); } -void GenerateCustomLightingImplementation(ShaderCode* out, const LightingUidData& uid_data, - std::string_view in_color_name) +static void GenerateLighting(ShaderCode* out, const LightingUidData& uid_data, int index, + int litchan_index, u32 channel_index, u32 custom_light_index, + bool alpha) { - auto generate_lighting = [](ShaderCode* out, const LightingUidData& uid_data, int index, - int litchan_index, u32 channel_index, u32 custom_light_index, - bool alpha) { - const auto attnfunc = - static_cast<AttenuationFunc>((uid_data.attnfunc >> (2 * litchan_index)) & 0x3); + const auto attnfunc = + static_cast<AttenuationFunc>((uid_data.attnfunc >> (2 * litchan_index)) & 0x3); - const std::string_view light_type = alpha ? "alpha" : "color"; - const std::string name = fmt::format("lights_chan{}_{}", channel_index, light_type); + const std::string_view light_type = alpha ? "alpha" : "color"; + const std::string name = fmt::format("lights_chan{}_{}", channel_index, light_type); - out->Write("\t{{\n"); - out->Write("\t\tcustom_data.{}[{}].direction = " LIGHT_DIR ".xyz;\n", name, custom_light_index, - LIGHT_DIR_PARAMS(index)); - out->Write("\t\tcustom_data.{}[{}].position = " LIGHT_POS ".xyz;\n", name, custom_light_index, - LIGHT_POS_PARAMS(index)); - out->Write("\t\tcustom_data.{}[{}].cosatt = " LIGHT_COSATT ";\n", name, custom_light_index, - LIGHT_COSATT_PARAMS(index)); - out->Write("\t\tcustom_data.{}[{}].distatt = " LIGHT_DISTATT ";\n", name, custom_light_index, - LIGHT_DISTATT_PARAMS(index)); - out->Write("\t\tcustom_data.{}[{}].attenuation_type = {};\n", name, custom_light_index, - static_cast<u32>(attnfunc)); - if (alpha) - { - out->Write("\t\tcustom_data.{}[{}].color = float3(" LIGHT_COL - ") / float3(255.0, 255.0, 255.0);\n", - name, custom_light_index, LIGHT_COL_PARAMS(index, alpha ? "a" : "rgb")); - } - else - { - out->Write("\t\tcustom_data.{}[{}].color = " LIGHT_COL " / float3(255.0, 255.0, 255.0);\n", - name, custom_light_index, LIGHT_COL_PARAMS(index, alpha ? "a" : "rgb")); - } - out->Write("\t}}\n"); - }; + out->Write("\t{{\n"); + out->Write("\t\tcustom_data.{}[{}].direction = " LIGHT_DIR ".xyz;\n", name, custom_light_index, + LIGHT_DIR_PARAMS(index)); + out->Write("\t\tcustom_data.{}[{}].position = " LIGHT_POS ".xyz;\n", name, custom_light_index, + LIGHT_POS_PARAMS(index)); + out->Write("\t\tcustom_data.{}[{}].cosatt = " LIGHT_COSATT ";\n", name, custom_light_index, + LIGHT_COSATT_PARAMS(index)); + out->Write("\t\tcustom_data.{}[{}].distatt = " LIGHT_DISTATT ";\n", name, custom_light_index, + LIGHT_DISTATT_PARAMS(index)); + out->Write("\t\tcustom_data.{}[{}].attenuation_type = {};\n", name, custom_light_index, + static_cast<u32>(attnfunc)); + if (alpha) + { + out->Write("\t\tcustom_data.{}[{}].color = float3(" LIGHT_COL + ") / float3(255.0, 255.0, 255.0);\n", + name, custom_light_index, LIGHT_COL_PARAMS(index, alpha ? "a" : "rgb")); + } + else + { + out->Write("\t\tcustom_data.{}[{}].color = " LIGHT_COL " / float3(255.0, 255.0, 255.0);\n", + name, custom_light_index, LIGHT_COL_PARAMS(index, alpha ? "a" : "rgb")); + } + out->Write("\t}}\n"); +} +void GenerateCustomLightingImplementation(ShaderCode* out, const LightingUidData& uid_data, + std::string_view in_color_name) +{ for (u32 i = 0; i < 8; i++) { for (u32 channel_index = 0; channel_index < NUM_XF_COLOR_CHANNELS; channel_index++) @@ -330,7 +331,7 @@ void GenerateCustomLightingImplementation(ShaderCode* out, const LightingUidData { if ((uid_data.light_mask & (1 << (i + 8 * j))) != 0) { - generate_lighting(out, uid_data, i, j, j, light_count, false); + GenerateLighting(out, uid_data, i, j, j, light_count, false); light_count++; } } @@ -344,7 +345,7 @@ void GenerateCustomLightingImplementation(ShaderCode* out, const LightingUidData { if ((uid_data.light_mask & (1 << (i + 8 * (j + 2)))) != 0) { - generate_lighting(out, uid_data, i, j + 2, j, light_count, true); + GenerateLighting(out, uid_data, i, j + 2, j, light_count, true); light_count++; } } |
