mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-15 17:50:06 +00:00
SwRasterizer/Lighting: Do not use global state in LookupLightingLut.
This commit is contained in:
parent
37ac2b6657
commit
7bc467e872
@ -79,7 +79,7 @@ struct State {
|
|||||||
std::array<ColorDifferenceEntry, 256> color_diff_table;
|
std::array<ColorDifferenceEntry, 256> color_diff_table;
|
||||||
} proctex;
|
} proctex;
|
||||||
|
|
||||||
struct {
|
struct Lighting {
|
||||||
union LutEntry {
|
union LutEntry {
|
||||||
// Used for raw access
|
// Used for raw access
|
||||||
u32 raw;
|
u32 raw;
|
||||||
|
@ -115,12 +115,15 @@ static std::tuple<float24, float24, PAddr> ConvertCubeCoord(float24 u, float24 v
|
|||||||
return std::make_tuple(x / z * half + half, y / z * half + half, addr);
|
return std::make_tuple(x / z * half + half, y / z * half + half, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
float LookupLightingLut(size_t lut_index, u8 index, float delta) {
|
static float LookupLightingLut(const Pica::State::Lighting& lighting, size_t lut_index, u8 index,
|
||||||
ASSERT_MSG(lut_index < g_state.lighting.luts.size(), "Out of range lut");
|
float delta) {
|
||||||
ASSERT_MSG(index < g_state.lighting.luts[0].size(), "Out of range index");
|
ASSERT_MSG(lut_index < lighting.luts.size(), "Out of range lut");
|
||||||
|
ASSERT_MSG(index < lighting.luts[0].size(), "Out of range index");
|
||||||
|
|
||||||
float lut_value = g_state.lighting.luts[lut_index][index].ToFloat();
|
const auto& lut = lighting.luts[lut_index][index];
|
||||||
float lut_diff = g_state.lighting.luts[lut_index][index].DiffToFloat();
|
|
||||||
|
float lut_value = lut.ToFloat();
|
||||||
|
float lut_diff = lut.DiffToFloat();
|
||||||
|
|
||||||
return lut_value + lut_diff * delta;
|
return lut_value + lut_diff * delta;
|
||||||
}
|
}
|
||||||
@ -184,7 +187,7 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
|
|||||||
u8 lutindex =
|
u8 lutindex =
|
||||||
static_cast<u8>(MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f));
|
static_cast<u8>(MathUtil::Clamp(std::floor(sample_loc * 256.f), 0.0f, 255.0f));
|
||||||
float delta = sample_loc * 256 - lutindex;
|
float delta = sample_loc * 256 - lutindex;
|
||||||
dist_atten = LookupLightingLut(lut, lutindex, delta);
|
dist_atten = LookupLightingLut(g_state.lighting, lut, lutindex, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
float clamp_highlights = 1.0f;
|
float clamp_highlights = 1.0f;
|
||||||
@ -260,7 +263,8 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
|
|||||||
|
|
||||||
d0_lut_value =
|
d0_lut_value =
|
||||||
scale *
|
scale *
|
||||||
LookupLightingLut(static_cast<size_t>(LightingRegs::LightingSampler::Distribution0),
|
LookupLightingLut(g_state.lighting,
|
||||||
|
static_cast<size_t>(LightingRegs::LightingSampler::Distribution0),
|
||||||
index, delta);
|
index, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +284,8 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
|
|||||||
|
|
||||||
refl_value.x =
|
refl_value.x =
|
||||||
scale *
|
scale *
|
||||||
LookupLightingLut(static_cast<size_t>(LightingRegs::LightingSampler::ReflectRed),
|
LookupLightingLut(g_state.lighting,
|
||||||
|
static_cast<size_t>(LightingRegs::LightingSampler::ReflectRed),
|
||||||
index, delta);
|
index, delta);
|
||||||
} else {
|
} else {
|
||||||
refl_value.x = 1.0f;
|
refl_value.x = 1.0f;
|
||||||
@ -300,7 +305,8 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
|
|||||||
|
|
||||||
refl_value.y =
|
refl_value.y =
|
||||||
scale *
|
scale *
|
||||||
LookupLightingLut(static_cast<size_t>(LightingRegs::LightingSampler::ReflectGreen),
|
LookupLightingLut(g_state.lighting,
|
||||||
|
static_cast<size_t>(LightingRegs::LightingSampler::ReflectGreen),
|
||||||
index, delta);
|
index, delta);
|
||||||
} else {
|
} else {
|
||||||
refl_value.y = refl_value.x;
|
refl_value.y = refl_value.x;
|
||||||
@ -320,7 +326,8 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
|
|||||||
|
|
||||||
refl_value.z =
|
refl_value.z =
|
||||||
scale *
|
scale *
|
||||||
LookupLightingLut(static_cast<size_t>(LightingRegs::LightingSampler::ReflectBlue),
|
LookupLightingLut(g_state.lighting,
|
||||||
|
static_cast<size_t>(LightingRegs::LightingSampler::ReflectBlue),
|
||||||
index, delta);
|
index, delta);
|
||||||
} else {
|
} else {
|
||||||
refl_value.z = refl_value.x;
|
refl_value.z = refl_value.x;
|
||||||
@ -341,7 +348,8 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
|
|||||||
|
|
||||||
d1_lut_value =
|
d1_lut_value =
|
||||||
scale *
|
scale *
|
||||||
LookupLightingLut(static_cast<size_t>(LightingRegs::LightingSampler::Distribution1),
|
LookupLightingLut(g_state.lighting,
|
||||||
|
static_cast<size_t>(LightingRegs::LightingSampler::Distribution1),
|
||||||
index, delta);
|
index, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +370,8 @@ std::tuple<Math::Vec4<u8>, Math::Vec4<u8>> ComputeFragmentsColors(
|
|||||||
|
|
||||||
float lut_value =
|
float lut_value =
|
||||||
scale *
|
scale *
|
||||||
LookupLightingLut(static_cast<size_t>(LightingRegs::LightingSampler::Fresnel),
|
LookupLightingLut(g_state.lighting,
|
||||||
|
static_cast<size_t>(LightingRegs::LightingSampler::Fresnel),
|
||||||
index, delta);
|
index, delta);
|
||||||
|
|
||||||
// Enabled for diffuse lighting alpha component
|
// Enabled for diffuse lighting alpha component
|
||||||
|
Loading…
Reference in New Issue
Block a user