mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Merge pull request #1512 from kd-11/gl_sampler_fix
gl: Always bind null for unused shader inputs
This commit is contained in:
commit
6353575208
@ -386,11 +386,6 @@ void GLGSRender::end()
|
||||
//setup textures
|
||||
for (int i = 0; i < rsx::limits::textures_count; ++i)
|
||||
{
|
||||
if (!textures[i].enabled())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int location;
|
||||
if (m_program->uniforms.has_location("tex" + std::to_string(i), &location))
|
||||
{
|
||||
@ -398,6 +393,14 @@ void GLGSRender::end()
|
||||
if (textures[i].format() & CELL_GCM_TEXTURE_UN)
|
||||
target = GL_TEXTURE_RECTANGLE;
|
||||
|
||||
if (!textures[i].enabled())
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + i);
|
||||
glBindTexture(target, NULL);
|
||||
glProgramUniform1i(m_program->id(), location, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_gl_textures[i].set_target(target);
|
||||
|
||||
__glcheck m_gl_texture_cache.upload_texture(i, textures[i], m_gl_textures[i]);
|
||||
@ -469,13 +472,18 @@ void GLGSRender::end()
|
||||
{
|
||||
auto &vertex_info = vertex_arrays_info[index];
|
||||
|
||||
if (!vertex_info.size) // disabled
|
||||
continue;
|
||||
|
||||
int location;
|
||||
if (!m_program->uniforms.has_location(reg_table[index] + "_buffer", &location))
|
||||
continue;
|
||||
|
||||
if (!vertex_info.size) // disabled, bind a null sampler
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + index + rsx::limits::textures_count);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, NULL);
|
||||
glProgramUniform1i(m_program->id(), location, index + rsx::limits::textures_count);
|
||||
continue;
|
||||
}
|
||||
|
||||
const u32 element_size = rsx::get_vertex_type_size_on_host(vertex_info.type, vertex_info.size);
|
||||
u32 data_size = element_size * vertex_draw_count;
|
||||
u32 gl_type = to_gl_internal_type(vertex_info.type, vertex_info.size);
|
||||
@ -536,7 +544,7 @@ void GLGSRender::end()
|
||||
texture->copy_from(*buffer, gl_type);
|
||||
|
||||
//Link texture to uniform
|
||||
m_program->uniforms.texture(location, index + rsx::limits::vertex_count, *texture);
|
||||
m_program->uniforms.texture(location, index + rsx::limits::textures_count, *texture);
|
||||
}
|
||||
}
|
||||
|
||||
@ -552,14 +560,19 @@ void GLGSRender::end()
|
||||
{
|
||||
for (int index = 0; index < rsx::limits::vertex_count; ++index)
|
||||
{
|
||||
bool enabled = !!(input_mask & (1 << index));
|
||||
if (!enabled)
|
||||
continue;
|
||||
|
||||
int location;
|
||||
if (!m_program->uniforms.has_location(reg_table[index]+"_buffer", &location))
|
||||
continue;
|
||||
|
||||
bool enabled = !!(input_mask & (1 << index));
|
||||
if (!enabled)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + index + rsx::limits::textures_count);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, NULL);
|
||||
glProgramUniform1i(m_program->id(), location, index + rsx::limits::textures_count);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (vertex_arrays_info[index].size > 0)
|
||||
{
|
||||
auto &vertex_info = vertex_arrays_info[index];
|
||||
@ -637,7 +650,7 @@ void GLGSRender::end()
|
||||
texture->copy_from(*buffer, gl_type);
|
||||
|
||||
//Link texture to uniform
|
||||
m_program->uniforms.texture(location, index + rsx::limits::vertex_count, *texture);
|
||||
m_program->uniforms.texture(location, index + rsx::limits::textures_count, *texture);
|
||||
}
|
||||
else if (register_vertex_info[index].size > 0)
|
||||
{
|
||||
@ -663,7 +676,7 @@ void GLGSRender::end()
|
||||
texture->copy_from(*buffer, gl_type);
|
||||
|
||||
//Link texture to uniform
|
||||
m_program->uniforms.texture(location, index + rsx::limits::vertex_count, *texture);
|
||||
m_program->uniforms.texture(location, index + rsx::limits::textures_count, *texture);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -671,6 +684,13 @@ void GLGSRender::end()
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + index + rsx::limits::textures_count);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, NULL);
|
||||
glProgramUniform1i(m_program->id(), location, index + rsx::limits::textures_count);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user