gl_rasterizer: Use the shared texture buffer for the fog lut.
This commit is contained in:
parent
4679487640
commit
63fb7dcc1b
|
@ -135,16 +135,6 @@ RasterizerOpenGL::RasterizerOpenGL()
|
|||
glActiveTexture(TextureUnits::TextureBufferLUT_RGBA.Enum());
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, texture_buffer.GetHandle());
|
||||
|
||||
// Setup the LUT for the fog
|
||||
fog_lut.Create();
|
||||
state.fog_lut.texture_buffer = fog_lut.handle;
|
||||
state.Apply();
|
||||
fog_lut_buffer.Create();
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, fog_lut_buffer.handle);
|
||||
glBufferData(GL_TEXTURE_BUFFER, sizeof(GLfloat) * 2 * 128, nullptr, GL_DYNAMIC_DRAW);
|
||||
glActiveTexture(TextureUnits::FogLUT.Enum());
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RG32F, fog_lut_buffer.handle);
|
||||
|
||||
// Setup the noise LUT for proctex
|
||||
proctex_noise_lut.Create();
|
||||
state.proctex_noise_lut.texture_buffer = proctex_noise_lut.handle;
|
||||
|
@ -1978,7 +1968,7 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
|||
uniform_block_data.lighting_lut_dirty_any = false;
|
||||
|
||||
// Sync the fog lut
|
||||
if (uniform_block_data.fog_lut_dirty) {
|
||||
if (uniform_block_data.fog_lut_dirty || invalidate) {
|
||||
std::array<GLvec2, 128> new_data;
|
||||
|
||||
std::transform(Pica::g_state.fog.lut.begin(), Pica::g_state.fog.lut.end(), new_data.begin(),
|
||||
|
@ -1986,11 +1976,12 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
|||
return GLvec2{entry.ToFloat(), entry.DiffToFloat()};
|
||||
});
|
||||
|
||||
if (new_data != fog_lut_data) {
|
||||
if (new_data != fog_lut_data || invalidate) {
|
||||
fog_lut_data = new_data;
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, fog_lut_buffer.handle);
|
||||
glBufferSubData(GL_TEXTURE_BUFFER, 0, new_data.size() * sizeof(GLvec2),
|
||||
new_data.data());
|
||||
std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(GLvec2));
|
||||
uniform_block_data.data.fog_lut_offset = (offset + bytes_used) / sizeof(GLvec2);
|
||||
uniform_block_data.dirty = true;
|
||||
bytes_used += new_data.size() * sizeof(GLvec2);
|
||||
}
|
||||
uniform_block_data.fog_lut_dirty = false;
|
||||
}
|
||||
|
|
|
@ -290,9 +290,6 @@ private:
|
|||
OGLTexture texture_buffer_lut_rgba;
|
||||
|
||||
std::array<std::array<GLvec2, 256>, Pica::LightingRegs::NumLightingSampler> lighting_lut_data{};
|
||||
|
||||
OGLBuffer fog_lut_buffer;
|
||||
OGLTexture fog_lut;
|
||||
std::array<GLvec2, 128> fog_lut_data{};
|
||||
|
||||
OGLBuffer proctex_noise_lut_buffer;
|
||||
|
|
|
@ -1224,7 +1224,6 @@ uniform sampler2D tex2;
|
|||
uniform samplerCube tex_cube;
|
||||
uniform samplerBuffer texture_buffer_lut_rg;
|
||||
uniform samplerBuffer texture_buffer_lut_rgba;
|
||||
uniform samplerBuffer fog_lut;
|
||||
uniform samplerBuffer proctex_noise_lut;
|
||||
uniform samplerBuffer proctex_color_map;
|
||||
uniform samplerBuffer proctex_alpha_map;
|
||||
|
@ -1494,7 +1493,8 @@ vec4 secondary_fragment_color = vec4(0.0);
|
|||
// Generate clamped fog factor from LUT for given fog index
|
||||
out += "float fog_i = clamp(floor(fog_index), 0.0, 127.0);\n";
|
||||
out += "float fog_f = fog_index - fog_i;\n";
|
||||
out += "vec2 fog_lut_entry = texelFetch(fog_lut, int(fog_i) + fog_lut_offset).rg;\n";
|
||||
out += "vec2 fog_lut_entry = texelFetch(texture_buffer_lut_rg, int(fog_i) + "
|
||||
"fog_lut_offset).rg;\n";
|
||||
out += "float fog_factor = fog_lut_entry.r + fog_lut_entry.g * fog_f;\n";
|
||||
out += "fog_factor = clamp(fog_factor, 0.0, 1.0);\n";
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ static void SetShaderSamplerBindings(GLuint shader) {
|
|||
// Set the texture samplers to correspond to different lookup table texture units
|
||||
SetShaderSamplerBinding(shader, "texture_buffer_lut_rg", TextureUnits::TextureBufferLUT_RG);
|
||||
SetShaderSamplerBinding(shader, "texture_buffer_lut_rgba", TextureUnits::TextureBufferLUT_RGBA);
|
||||
SetShaderSamplerBinding(shader, "fog_lut", TextureUnits::FogLUT);
|
||||
SetShaderSamplerBinding(shader, "proctex_noise_lut", TextureUnits::ProcTexNoiseLUT);
|
||||
SetShaderSamplerBinding(shader, "proctex_color_map", TextureUnits::ProcTexColorMap);
|
||||
SetShaderSamplerBinding(shader, "proctex_alpha_map", TextureUnits::ProcTexAlphaMap);
|
||||
|
|
|
@ -58,8 +58,6 @@ OpenGLState::OpenGLState() {
|
|||
texture_buffer_lut_rg.texture_buffer = 0;
|
||||
texture_buffer_lut_rgba.texture_buffer = 0;
|
||||
|
||||
fog_lut.texture_buffer = 0;
|
||||
|
||||
proctex_lut.texture_buffer = 0;
|
||||
proctex_diff_lut.texture_buffer = 0;
|
||||
proctex_color_map.texture_buffer = 0;
|
||||
|
@ -235,12 +233,6 @@ void OpenGLState::Apply() const {
|
|||
glBindTexture(GL_TEXTURE_BUFFER, texture_buffer_lut_rgba.texture_buffer);
|
||||
}
|
||||
|
||||
// Fog LUT
|
||||
if (fog_lut.texture_buffer != cur_state.fog_lut.texture_buffer) {
|
||||
glActiveTexture(TextureUnits::FogLUT.Enum());
|
||||
glBindTexture(GL_TEXTURE_BUFFER, fog_lut.texture_buffer);
|
||||
}
|
||||
|
||||
// ProcTex Noise LUT
|
||||
if (proctex_noise_lut.texture_buffer != cur_state.proctex_noise_lut.texture_buffer) {
|
||||
glActiveTexture(TextureUnits::ProcTexNoiseLUT.Enum());
|
||||
|
@ -386,8 +378,6 @@ OpenGLState& OpenGLState::ResetTexture(GLuint handle) {
|
|||
texture_buffer_lut_rg.texture_buffer = 0;
|
||||
if (texture_buffer_lut_rgba.texture_buffer == handle)
|
||||
texture_buffer_lut_rgba.texture_buffer = 0;
|
||||
if (fog_lut.texture_buffer == handle)
|
||||
fog_lut.texture_buffer = 0;
|
||||
if (proctex_noise_lut.texture_buffer == handle)
|
||||
proctex_noise_lut.texture_buffer = 0;
|
||||
if (proctex_color_map.texture_buffer == handle)
|
||||
|
|
|
@ -20,7 +20,6 @@ constexpr TextureUnit PicaTexture(int unit) {
|
|||
return TextureUnit{unit};
|
||||
}
|
||||
|
||||
constexpr TextureUnit FogLUT{4};
|
||||
constexpr TextureUnit ProcTexNoiseLUT{5};
|
||||
constexpr TextureUnit ProcTexColorMap{6};
|
||||
constexpr TextureUnit ProcTexAlphaMap{7};
|
||||
|
@ -112,10 +111,6 @@ public:
|
|||
GLuint texture_buffer; // GL_TEXTURE_BINDING_BUFFER
|
||||
} texture_buffer_lut_rgba;
|
||||
|
||||
struct {
|
||||
GLuint texture_buffer; // GL_TEXTURE_BINDING_BUFFER
|
||||
} fog_lut;
|
||||
|
||||
struct {
|
||||
GLuint texture_buffer; // GL_TEXTURE_BINDING_BUFFER
|
||||
} proctex_noise_lut;
|
||||
|
|
Reference in New Issue