Skip to content

Commit

Permalink
Use sampler buffers in vertex shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
O1L authored and DHrpcs3 committed Jun 21, 2016
1 parent 8637754 commit 1778113
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/GL/GLGSRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ bool GLGSRender::load_program()

glBindBufferRange(GL_UNIFORM_BUFFER, 0, m_uniform_ring_buffer->get_buffer().id(), scale_offset_offset, 512);
glBindBufferRange(GL_UNIFORM_BUFFER, 1, m_uniform_ring_buffer->get_buffer().id(), vertex_constants_offset, 512 * 16);
glBindBufferRange(GL_UNIFORM_BUFFER, 2, m_uniform_ring_buffer->get_buffer().id(), fragment_constants_offset, fragment_constants_sz);
//glBindBufferRange(GL_UNIFORM_BUFFER, 2, m_uniform_ring_buffer->get_buffer().id(), fragment_constants_offset, fragment_constants_sz);

return true;
}
Expand Down
14 changes: 11 additions & 3 deletions rpcs3/Emu/RSX/GL/rsx_gl_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rsx::complete_shader glsl_complete_shader(const rsx::decompiled_shader &shader,
{
rsx::complete_shader result;
result.decompiled = &shader;
result.code = "#version 420\n\n";
result.code = "#version 430\n\n";

if (shader.raw->type == rsx::program_type::vertex)
{
Expand Down Expand Up @@ -80,6 +80,7 @@ rsx::complete_shader glsl_complete_shader(const rsx::decompiled_shader &shader,

std::string prepare;
std::string finalize;
int location = 1;

switch (shader.raw->type)
{
Expand Down Expand Up @@ -244,10 +245,12 @@ rsx::complete_shader glsl_complete_shader(const rsx::decompiled_shader &shader,
case rsx::program_type::vertex:

result.code += "out vec4 wpos;\n";


// TODO
if (1)
{
finalize += "\tgl_Position = o0;\n";
finalize += "\tgl_Position = gl_Position * viewport_matrix;\n";
}
else
{
Expand All @@ -261,7 +264,12 @@ rsx::complete_shader glsl_complete_shader(const rsx::decompiled_shader &shader,
{
if (shader.input_attributes & (1 << index))
{
result.code += "in vec4 " + rsx::vertex_program::input_attrib_names[index] + ";\n";
// result.code += "in vec4 " + rsx::vertex_program::input_attrib_names[index] + ";\n";

// TODO: use actual information about vertex inputs
result.code += "layout(location=" + std::to_string(location++) + ") uniform samplerBuffer " + rsx::vertex_program::input_attrib_names[index] + "_buffer" + ";\n";
result.code += "vec4 " + rsx::vertex_program::input_attrib_names[index]
+ " = texelFetch(" + rsx::vertex_program::input_attrib_names[index] + "_buffer, gl_VertexID).rgba;\n";
}
}

Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/RSX/GL/vertex_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ u32 GLGSRender::set_vertex_buffer()
auto &vertex_info = vertex_arrays_info[index];

int location;
if (!m_program->attribs.has_location(rsx::vertex_program::input_attrib_names[index], &location))
if (!m_program->uniforms.has_location(rsx::vertex_program::input_attrib_names[index] + "_buffer", &location))
continue;

if (!vertex_info.size) // disabled, bind a null sampler
Expand Down Expand Up @@ -303,7 +303,7 @@ u32 GLGSRender::set_vertex_buffer()
for (int index = 0; index < rsx::limits::vertex_count; ++index)
{
int location;
if (!m_program->attribs.has_location(rsx::vertex_program::input_attrib_names[index], &location))
if (!m_program->uniforms.has_location(rsx::vertex_program::input_attrib_names[index] + "_buffer", &location))
continue;

bool enabled = !!(input_mask & (1 << index));
Expand Down

0 comments on commit 1778113

Please sign in to comment.