summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar wwylele2017-07-11 20:06:26 +0300
committerGravatar wwylele2017-07-11 20:06:26 +0300
commitefc655aec00d43d53c41b55d9a94d17ce81e5942 (patch)
tree1534d2076c1e88f43cfe89dd257702ffbeebf42e /src
parentvector_math: remove broken SFINAE stuff (diff)
downloadyuzu-efc655aec00d43d53c41b55d9a94d17ce81e5942.tar.gz
yuzu-efc655aec00d43d53c41b55d9a94d17ce81e5942.tar.xz
yuzu-efc655aec00d43d53c41b55d9a94d17ce81e5942.zip
SwRasterizer/Lighting: pass lighting state as parameter
Diffstat (limited to 'src')
-rw-r--r--src/video_core/swrasterizer/rasterizer.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp
index 2c7a1a815..b108a0f86 100644
--- a/src/video_core/swrasterizer/rasterizer.cpp
+++ b/src/video_core/swrasterizer/rasterizer.cpp
@@ -116,7 +116,7 @@ static std::tuple<float24, float24, PAddr> ConvertCubeCoord(float24 u, float24 v
116} 116}
117 117
118static float LookupLightingLut(const Pica::State::Lighting& lighting, size_t lut_index, u8 index, 118static float LookupLightingLut(const Pica::State::Lighting& lighting, size_t lut_index, u8 index,
119 float delta) { 119 float delta) {
120 ASSERT_MSG(lut_index < lighting.luts.size(), "Out of range lut"); 120 ASSERT_MSG(lut_index < lighting.luts.size(), "Out of range lut");
121 ASSERT_MSG(index < lighting.luts[0].size(), "Out of range index"); 121 ASSERT_MSG(index < lighting.luts[0].size(), "Out of range index");
122 122
@@ -129,8 +129,8 @@ static float LookupLightingLut(const Pica::State::Lighting& lighting, size_t lut
129} 129}
130 130
131std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors( 131std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
132 const Pica::LightingRegs& lighting, const Math::Quaternion<float>& normquat, 132 const Pica::LightingRegs& lighting, const Pica::State::Lighting& lighting_state,
133 const Math::Vec3<float>& view) { 133 const Math::Quaternion<float>& normquat, const Math::Vec3<float>& view) {
134 134
135 // TODO(Subv): Bump mapping 135 // TODO(Subv): Bump mapping
136 Math::Vec3<float> surface_normal = {0.0f, 0.0f, 1.0f}; 136 Math::Vec3<float> surface_normal = {0.0f, 0.0f, 1.0f};
@@ -148,7 +148,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
148 148
149 for (unsigned light_index = 0; light_index <= lighting.max_light_index; ++light_index) { 149 for (unsigned light_index = 0; light_index <= lighting.max_light_index; ++light_index) {
150 unsigned num = lighting.light_enable.GetNum(light_index); 150 unsigned num = lighting.light_enable.GetNum(light_index);
151 const auto& light_config = g_state.regs.lighting.light[num]; 151 const auto& light_config = lighting.light[num];
152 152
153 Math::Vec3<float> refl_value = {}; 153 Math::Vec3<float> refl_value = {};
154 Math::Vec3<float> position = {float16::FromRaw(light_config.x).ToFloat32(), 154 Math::Vec3<float> position = {float16::FromRaw(light_config.x).ToFloat32(),
@@ -176,7 +176,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
176 u8 lutindex = 176 u8 lutindex =
177 static_cast<u8>(MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f)); 177 static_cast<u8>(MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f));
178 float delta = sample_loc * 256 - lutindex; 178 float delta = sample_loc * 256 - lutindex;
179 dist_atten = LookupLightingLut(g_state.lighting, lut, lutindex, delta); 179 dist_atten = LookupLightingLut(lighting_state, lut, lutindex, delta);
180 } 180 }
181 181
182 auto GetLutIndex = [&](unsigned num, LightingRegs::LightingLutInput input, 182 auto GetLutIndex = [&](unsigned num, LightingRegs::LightingLutInput input,
@@ -243,7 +243,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
243 243
244 d0_lut_value = 244 d0_lut_value =
245 scale * 245 scale *
246 LookupLightingLut(g_state.lighting, 246 LookupLightingLut(lighting_state,
247 static_cast<size_t>(LightingRegs::LightingSampler::Distribution0), 247 static_cast<size_t>(LightingRegs::LightingSampler::Distribution0),
248 index, delta); 248 index, delta);
249 } 249 }
@@ -264,7 +264,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
264 264
265 refl_value.x = 265 refl_value.x =
266 scale * 266 scale *
267 LookupLightingLut(g_state.lighting, 267 LookupLightingLut(lighting_state,
268 static_cast<size_t>(LightingRegs::LightingSampler::ReflectRed), 268 static_cast<size_t>(LightingRegs::LightingSampler::ReflectRed),
269 index, delta); 269 index, delta);
270 } else { 270 } else {
@@ -285,7 +285,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
285 285
286 refl_value.y = 286 refl_value.y =
287 scale * 287 scale *
288 LookupLightingLut(g_state.lighting, 288 LookupLightingLut(lighting_state,
289 static_cast<size_t>(LightingRegs::LightingSampler::ReflectGreen), 289 static_cast<size_t>(LightingRegs::LightingSampler::ReflectGreen),
290 index, delta); 290 index, delta);
291 } else { 291 } else {
@@ -306,7 +306,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
306 306
307 refl_value.z = 307 refl_value.z =
308 scale * 308 scale *
309 LookupLightingLut(g_state.lighting, 309 LookupLightingLut(lighting_state,
310 static_cast<size_t>(LightingRegs::LightingSampler::ReflectBlue), 310 static_cast<size_t>(LightingRegs::LightingSampler::ReflectBlue),
311 index, delta); 311 index, delta);
312 } else { 312 } else {
@@ -328,7 +328,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
328 328
329 d1_lut_value = 329 d1_lut_value =
330 scale * 330 scale *
331 LookupLightingLut(g_state.lighting, 331 LookupLightingLut(lighting_state,
332 static_cast<size_t>(LightingRegs::LightingSampler::Distribution1), 332 static_cast<size_t>(LightingRegs::LightingSampler::Distribution1),
333 index, delta); 333 index, delta);
334 } 334 }
@@ -350,7 +350,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
350 350
351 float lut_value = 351 float lut_value =
352 scale * 352 scale *
353 LookupLightingLut(g_state.lighting, 353 LookupLightingLut(lighting_state,
354 static_cast<size_t>(LightingRegs::LightingSampler::Fresnel), 354 static_cast<size_t>(LightingRegs::LightingSampler::Fresnel),
355 index, delta); 355 index, delta);
356 356
@@ -729,8 +729,8 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
729 Math::Vec4<u8> secondary_fragment_color = {0, 0, 0, 0}; 729 Math::Vec4<u8> secondary_fragment_color = {0, 0, 0, 0};
730 730
731 if (!g_state.regs.lighting.disable) { 731 if (!g_state.regs.lighting.disable) {
732 std::tie(primary_fragment_color, secondary_fragment_color) = 732 std::tie(primary_fragment_color, secondary_fragment_color) = ComputeFragmentsColors(
733 ComputeFragmentsColors(g_state.regs.lighting, normquat, fragment_position); 733 g_state.regs.lighting, g_state.lighting, normquat, fragment_position);
734 } 734 }
735 735
736 for (unsigned tev_stage_index = 0; tev_stage_index < tev_stages.size(); 736 for (unsigned tev_stage_index = 0; tev_stage_index < tev_stages.size();