mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-25 20:22:30 +01:00
gl: Use fill_gragment_constans_buffer
This commit is contained in:
parent
f438554fc1
commit
7a996648bb
@ -28,7 +28,7 @@ std::string GLFragmentDecompilerThread::compareFunction(COMPARE f, const std::st
|
||||
|
||||
void GLFragmentDecompilerThread::insertHeader(std::stringstream & OS)
|
||||
{
|
||||
OS << "#version 140" << std::endl;
|
||||
OS << "#version 420" << std::endl;
|
||||
}
|
||||
|
||||
void GLFragmentDecompilerThread::insertIntputs(std::stringstream & OS)
|
||||
@ -68,13 +68,18 @@ void GLFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
||||
|
||||
}
|
||||
|
||||
OS << "layout(std140, binding = 2) uniform FragmentConstantsBuffer" << std::endl;
|
||||
OS << "{" << std::endl;
|
||||
for (ParamType PT : m_parr.params[PF_PARAM_UNIFORM])
|
||||
{
|
||||
if (PT.type == "sampler2D")
|
||||
continue;
|
||||
for (ParamItem PI : PT.items)
|
||||
OS << "uniform " << PT.type << " " << PI.name << ";" << std::endl;
|
||||
OS << " " << PT.type << " " << PI.name << ";" << std::endl;
|
||||
}
|
||||
// A dummy value otherwise it's invalid to create an empty uniform buffer
|
||||
OS << " vec4 void_value;" << std::endl;
|
||||
OS << "};" << std::endl;
|
||||
}
|
||||
|
||||
void GLFragmentDecompilerThread::insertMainStart(std::stringstream & OS)
|
||||
|
@ -1065,9 +1065,11 @@ void GLGSRender::oninit_thread()
|
||||
m_ebo.create();
|
||||
m_scale_offset_buffer.create(16 * sizeof(float));
|
||||
m_vertex_constants_buffer.create(512 * 4 * sizeof(float));
|
||||
m_fragment_constants_buffer.create();
|
||||
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, 0, m_scale_offset_buffer.id());
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, 1, m_vertex_constants_buffer.id());
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, 2, m_fragment_constants_buffer.id());
|
||||
|
||||
m_vao.array_buffer = m_vbo;
|
||||
m_vao.element_array_buffer = m_ebo;
|
||||
@ -1275,17 +1277,12 @@ bool GLGSRender::load_program()
|
||||
fill_vertex_program_constants_data(buffer);
|
||||
glUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
|
||||
for (u32 constant_offset : m_prog_buffer.getFragmentConstantOffsetsCache(&fragment_program))
|
||||
{
|
||||
auto data = vm::ps3::_ptr<u32>(fragment_program.addr + constant_offset);
|
||||
|
||||
u32 c0 = (data[0] >> 16 | data[0] << 16);
|
||||
u32 c1 = (data[1] >> 16 | data[1] << 16);
|
||||
u32 c2 = (data[2] >> 16 | data[2] << 16);
|
||||
u32 c3 = (data[3] >> 16 | data[3] << 16);
|
||||
|
||||
m_program->uniforms["fc" + std::to_string(constant_offset)] = color4f{ (f32&)c0, (f32&)c1, (f32&)c2, (f32&)c3 };
|
||||
}
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, m_fragment_constants_buffer.id());
|
||||
size_t buffer_size = m_prog_buffer.get_fragment_constants_buffer_size(&fragment_program);
|
||||
glBufferData(GL_UNIFORM_BUFFER, buffer_size, nullptr, GL_STATIC_DRAW);
|
||||
buffer = glMapBuffer(GL_UNIFORM_BUFFER, GL_WRITE_ONLY);
|
||||
m_prog_buffer.fill_fragment_constans_buffer(buffer, &fragment_program);
|
||||
glUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ private:
|
||||
|
||||
gl::buffer m_scale_offset_buffer;
|
||||
gl::buffer m_vertex_constants_buffer;
|
||||
gl::buffer m_fragment_constants_buffer;
|
||||
|
||||
gl::buffer m_vbo;
|
||||
gl::buffer m_ebo;
|
||||
|
Loading…
Reference in New Issue
Block a user