mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-12-27 05:36:42 +00:00
gl_rasterizer: Use the shared texture buffer for the proctex lut.
This commit is contained in:
parent
1ca6d2ea8d
commit
831d4f9aeb
|
@ -135,26 +135,6 @@ RasterizerOpenGL::RasterizerOpenGL()
|
|||
glActiveTexture(TextureUnits::TextureBufferLUT_RGBA.Enum());
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, texture_buffer.GetHandle());
|
||||
|
||||
// Setup the LUT for proctex
|
||||
proctex_lut.Create();
|
||||
state.proctex_lut.texture_buffer = proctex_lut.handle;
|
||||
state.Apply();
|
||||
proctex_lut_buffer.Create();
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, proctex_lut_buffer.handle);
|
||||
glBufferData(GL_TEXTURE_BUFFER, sizeof(GLfloat) * 4 * 256, nullptr, GL_DYNAMIC_DRAW);
|
||||
glActiveTexture(TextureUnits::ProcTexLUT.Enum());
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, proctex_lut_buffer.handle);
|
||||
|
||||
// Setup the difference LUT for proctex
|
||||
proctex_diff_lut.Create();
|
||||
state.proctex_diff_lut.texture_buffer = proctex_diff_lut.handle;
|
||||
state.Apply();
|
||||
proctex_diff_lut_buffer.Create();
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, proctex_diff_lut_buffer.handle);
|
||||
glBufferData(GL_TEXTURE_BUFFER, sizeof(GLfloat) * 4 * 256, nullptr, GL_DYNAMIC_DRAW);
|
||||
glActiveTexture(TextureUnits::ProcTexDiffLUT.Enum());
|
||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, proctex_diff_lut_buffer.handle);
|
||||
|
||||
// Bind index buffer for hardware shader path
|
||||
state.draw.vertex_array = hw_vao.handle;
|
||||
state.Apply();
|
||||
|
@ -1996,7 +1976,7 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
|||
}
|
||||
|
||||
// Sync the proctex lut
|
||||
if (uniform_block_data.proctex_lut_dirty) {
|
||||
if (uniform_block_data.proctex_lut_dirty || invalidate) {
|
||||
std::array<GLvec4, 256> new_data;
|
||||
|
||||
std::transform(Pica::g_state.proctex.color_table.begin(),
|
||||
|
@ -2006,17 +1986,18 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
|||
return GLvec4{rgba.r(), rgba.g(), rgba.b(), rgba.a()};
|
||||
});
|
||||
|
||||
if (new_data != proctex_lut_data) {
|
||||
if (new_data != proctex_lut_data || invalidate) {
|
||||
proctex_lut_data = new_data;
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, proctex_lut_buffer.handle);
|
||||
glBufferSubData(GL_TEXTURE_BUFFER, 0, new_data.size() * sizeof(GLvec4),
|
||||
new_data.data());
|
||||
std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(GLvec4));
|
||||
uniform_block_data.data.proctex_lut_offset = (offset + bytes_used) / sizeof(GLvec4);
|
||||
uniform_block_data.dirty = true;
|
||||
bytes_used += new_data.size() * sizeof(GLvec4);
|
||||
}
|
||||
uniform_block_data.proctex_lut_dirty = false;
|
||||
}
|
||||
|
||||
// Sync the proctex difference lut
|
||||
if (uniform_block_data.proctex_diff_lut_dirty) {
|
||||
if (uniform_block_data.proctex_diff_lut_dirty || invalidate) {
|
||||
std::array<GLvec4, 256> new_data;
|
||||
|
||||
std::transform(Pica::g_state.proctex.color_diff_table.begin(),
|
||||
|
@ -2026,11 +2007,13 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
|||
return GLvec4{rgba.r(), rgba.g(), rgba.b(), rgba.a()};
|
||||
});
|
||||
|
||||
if (new_data != proctex_diff_lut_data) {
|
||||
if (new_data != proctex_diff_lut_data || invalidate) {
|
||||
proctex_diff_lut_data = new_data;
|
||||
glBindBuffer(GL_TEXTURE_BUFFER, proctex_diff_lut_buffer.handle);
|
||||
glBufferSubData(GL_TEXTURE_BUFFER, 0, new_data.size() * sizeof(GLvec4),
|
||||
new_data.data());
|
||||
std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(GLvec4));
|
||||
uniform_block_data.data.proctex_diff_lut_offset =
|
||||
(offset + bytes_used) / sizeof(GLvec4);
|
||||
uniform_block_data.dirty = true;
|
||||
bytes_used += new_data.size() * sizeof(GLvec4);
|
||||
}
|
||||
uniform_block_data.proctex_diff_lut_dirty = false;
|
||||
}
|
||||
|
|
|
@ -294,13 +294,7 @@ private:
|
|||
std::array<GLvec2, 128> proctex_noise_lut_data{};
|
||||
std::array<GLvec2, 128> proctex_color_map_data{};
|
||||
std::array<GLvec2, 128> proctex_alpha_map_data{};
|
||||
|
||||
OGLBuffer proctex_lut_buffer;
|
||||
OGLTexture proctex_lut;
|
||||
std::array<GLvec4, 256> proctex_lut_data{};
|
||||
|
||||
OGLBuffer proctex_diff_lut_buffer;
|
||||
OGLTexture proctex_diff_lut;
|
||||
std::array<GLvec4, 256> proctex_diff_lut_data{};
|
||||
|
||||
bool allow_shadow;
|
||||
|
|
|
@ -1171,15 +1171,16 @@ float ProcTexNoiseCoef(vec2 x) {
|
|||
out += "int lut_index_i = int(lut_coord) + " +
|
||||
std::to_string(config.state.proctex.lut_offset) + ";\n";
|
||||
out += "float lut_index_f = fract(lut_coord);\n";
|
||||
out += "vec4 final_color = texelFetch(proctex_lut, lut_index_i + proctex_lut_offset) + "
|
||||
out += "vec4 final_color = texelFetch(texture_buffer_lut_rgba, lut_index_i + "
|
||||
"proctex_lut_offset) + "
|
||||
"lut_index_f * "
|
||||
"texelFetch(proctex_diff_lut, lut_index_i + proctex_diff_lut_offset);\n";
|
||||
"texelFetch(texture_buffer_lut_rgba, lut_index_i + proctex_diff_lut_offset);\n";
|
||||
break;
|
||||
case ProcTexFilter::Nearest:
|
||||
case ProcTexFilter::NearestMipmapLinear:
|
||||
case ProcTexFilter::NearestMipmapNearest:
|
||||
out += "lut_coord += " + std::to_string(config.state.proctex.lut_offset) + ";\n";
|
||||
out += "vec4 final_color = texelFetch(proctex_lut, int(round(lut_coord)) + "
|
||||
out += "vec4 final_color = texelFetch(texture_buffer_lut_rgba, int(round(lut_coord)) + "
|
||||
"proctex_lut_offset);\n";
|
||||
break;
|
||||
}
|
||||
|
@ -1224,8 +1225,6 @@ uniform sampler2D tex2;
|
|||
uniform samplerCube tex_cube;
|
||||
uniform samplerBuffer texture_buffer_lut_rg;
|
||||
uniform samplerBuffer texture_buffer_lut_rgba;
|
||||
uniform samplerBuffer proctex_lut;
|
||||
uniform samplerBuffer proctex_diff_lut;
|
||||
|
||||
#if ALLOW_SHADOW
|
||||
layout(r32ui) uniform readonly uimage2D shadow_texture_px;
|
||||
|
|
|
@ -57,8 +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, "proctex_lut", TextureUnits::ProcTexLUT);
|
||||
SetShaderSamplerBinding(shader, "proctex_diff_lut", TextureUnits::ProcTexDiffLUT);
|
||||
|
||||
SetShaderImageBinding(shader, "shadow_buffer", ImageUnits::ShadowBuffer);
|
||||
SetShaderImageBinding(shader, "shadow_texture_px", ImageUnits::ShadowTexturePX);
|
||||
|
|
|
@ -58,9 +58,6 @@ OpenGLState::OpenGLState() {
|
|||
texture_buffer_lut_rg.texture_buffer = 0;
|
||||
texture_buffer_lut_rgba.texture_buffer = 0;
|
||||
|
||||
proctex_lut.texture_buffer = 0;
|
||||
proctex_diff_lut.texture_buffer = 0;
|
||||
|
||||
image_shadow_buffer = 0;
|
||||
image_shadow_texture_px = 0;
|
||||
image_shadow_texture_nx = 0;
|
||||
|
@ -230,18 +227,6 @@ void OpenGLState::Apply() const {
|
|||
glBindTexture(GL_TEXTURE_BUFFER, texture_buffer_lut_rgba.texture_buffer);
|
||||
}
|
||||
|
||||
// ProcTex LUT
|
||||
if (proctex_lut.texture_buffer != cur_state.proctex_lut.texture_buffer) {
|
||||
glActiveTexture(TextureUnits::ProcTexLUT.Enum());
|
||||
glBindTexture(GL_TEXTURE_BUFFER, proctex_lut.texture_buffer);
|
||||
}
|
||||
|
||||
// ProcTex Diff LUT
|
||||
if (proctex_diff_lut.texture_buffer != cur_state.proctex_diff_lut.texture_buffer) {
|
||||
glActiveTexture(TextureUnits::ProcTexDiffLUT.Enum());
|
||||
glBindTexture(GL_TEXTURE_BUFFER, proctex_diff_lut.texture_buffer);
|
||||
}
|
||||
|
||||
// Shadow Images
|
||||
if (image_shadow_buffer != cur_state.image_shadow_buffer) {
|
||||
glBindImageTexture(ImageUnits::ShadowBuffer, image_shadow_buffer, 0, GL_FALSE, 0,
|
||||
|
@ -357,10 +342,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 (proctex_lut.texture_buffer == handle)
|
||||
proctex_lut.texture_buffer = 0;
|
||||
if (proctex_diff_lut.texture_buffer == handle)
|
||||
proctex_diff_lut.texture_buffer = 0;
|
||||
if (image_shadow_buffer == handle)
|
||||
image_shadow_buffer = 0;
|
||||
if (image_shadow_texture_px == handle)
|
||||
|
|
|
@ -20,8 +20,6 @@ constexpr TextureUnit PicaTexture(int unit) {
|
|||
return TextureUnit{unit};
|
||||
}
|
||||
|
||||
constexpr TextureUnit ProcTexLUT{8};
|
||||
constexpr TextureUnit ProcTexDiffLUT{9};
|
||||
constexpr TextureUnit TextureCube{10};
|
||||
constexpr TextureUnit TextureBufferLUT_RG{11};
|
||||
constexpr TextureUnit TextureBufferLUT_RGBA{12};
|
||||
|
@ -108,14 +106,6 @@ public:
|
|||
GLuint texture_buffer; // GL_TEXTURE_BINDING_BUFFER
|
||||
} texture_buffer_lut_rgba;
|
||||
|
||||
struct {
|
||||
GLuint texture_buffer; // GL_TEXTURE_BINDING_BUFFER
|
||||
} proctex_lut;
|
||||
|
||||
struct {
|
||||
GLuint texture_buffer; // GL_TEXTURE_BINDING_BUFFER
|
||||
} proctex_diff_lut;
|
||||
|
||||
// GL_IMAGE_BINDING_NAME
|
||||
GLuint image_shadow_buffer;
|
||||
GLuint image_shadow_texture_px;
|
||||
|
|
Loading…
Reference in a new issue