gl: Use uniform buffer for transform constants.

This commit is contained in:
Vincent Lejeune 2015-11-17 21:02:45 +01:00
parent 247af0ebbf
commit 5447521ce5
3 changed files with 11 additions and 11 deletions

View File

@ -1064,8 +1064,10 @@ void GLGSRender::oninit_thread()
m_vbo.create();
m_ebo.create();
m_scale_offset_buffer.create(16 * sizeof(float));
m_vertex_constants_buffer.create(512 * 4 * sizeof(float));
glBindBufferBase(GL_UNIFORM_BUFFER, 0, m_scale_offset_buffer.id());
glBindBufferBase(GL_UNIFORM_BUFFER, 1, m_vertex_constants_buffer.id());
m_vao.array_buffer = m_vbo;
m_vao.element_array_buffer = m_ebo;
@ -1268,12 +1270,10 @@ bool GLGSRender::load_program()
fill_scale_offset_data(buffer, false);
glUnmapBuffer(GL_UNIFORM_BUFFER);
for (auto &constant : transform_constants)
{
//LOG_WARNING(RSX, "vc[%u] = (%f, %f, %f, %f)", constant.first, constant.second.r, constant.second.g, constant.second.b, constant.second.a);
__glcheck m_program->uniforms["vc[" + std::to_string(constant.first) + "]"] = constant.second;
}
glBindBuffer(GL_UNIFORM_BUFFER, m_vertex_constants_buffer.id());
buffer = glMapBuffer(GL_UNIFORM_BUFFER, GL_WRITE_ONLY);
fill_vertex_program_constants_data(buffer);
glUnmapBuffer(GL_UNIFORM_BUFFER);
for (u32 constant_offset : m_prog_buffer.getFragmentConstantOffsetsCache(&fragment_program))
{

View File

@ -76,6 +76,7 @@ private:
gl::texture m_flip_tex_color;
gl::buffer m_scale_offset_buffer;
gl::buffer m_vertex_constants_buffer;
gl::buffer m_vbo;
gl::buffer m_ebo;

View File

@ -46,11 +46,10 @@ void GLVertexDecompilerThread::insertInputs(std::stringstream & OS, const std::v
void GLVertexDecompilerThread::insertConstants(std::stringstream & OS, const std::vector<ParamType> & constants)
{
for (const ParamType PT : constants)
{
for (const ParamItem &PI : PT.items)
OS << "uniform " << PT.type << " " << PI.name << ";" << std::endl;
}
OS << "layout(std140, binding = 1) uniform VertexConstantsBuffer" << std::endl;
OS << "{" << std::endl;
OS << " vec4 vc[468];" << std::endl;
OS << "};" << std::endl;
}
struct reg_info