1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-21 18:22:33 +01:00

GL: minor fixes (#2105)

* Minor fixes

* temporary disable 2-sided lighting

* Disable user clip planes until they are properly handled
This commit is contained in:
raven02 2016-08-27 14:12:44 +08:00 committed by GitHub
parent 6e07e07cd0
commit bb66b97251
3 changed files with 30 additions and 142 deletions

View File

@ -46,15 +46,6 @@ void GLFragmentDecompilerThread::insertIntputs(std::stringstream & OS)
{
for (const ParamItem& PI : PT.items)
{
if (m_prog.front_back_color_enabled)
{
if (PI.name == "diff_color" && m_prog.back_color_diffuse_output)
OS << "in vec4 back_diff_color;" << std::endl;
if (PI.name == "spec_color" && m_prog.back_color_specular_output)
OS << "in vec4 back_spec_color;" << std::endl;
}
//Rename fogc to fog_c to differentiate the input register from the variable
if (PI.name == "fogc")
OS << "in vec4 fog_c;" << std::endl;
@ -62,16 +53,6 @@ void GLFragmentDecompilerThread::insertIntputs(std::stringstream & OS)
OS << "in " << PT.type << " " << PI.name << ";" << std::endl;
}
}
if (m_prog.front_back_color_enabled)
{
if (m_prog.front_color_diffuse_output)
OS << "in vec4 front_diff_color;" << std::endl;
if (m_prog.front_color_specular_output)
OS << "in vec4 front_spec_color;" << std::endl;
}
}
void GLFragmentDecompilerThread::insertOutputs(std::stringstream & OS)
@ -207,20 +188,6 @@ void GLFragmentDecompilerThread::insertMainStart(std::stringstream & OS)
{
for (const ParamItem& PI : PT.items)
{
if (m_prog.front_back_color_enabled)
{
if (PI.name == "spec_color" && m_prog.back_color_specular_output)
{
OS << " vec4 spec_color = gl_FrontFacing ? front_spec_color : spec_color;\n";
continue;
}
if (PI.name == "diff_color" && m_prog.back_color_diffuse_output)
{
OS << " vec4 diff_color = gl_FrontFacing ? front_diff_color : diff_color;\n";
continue;
}
}
if (PI.name == "fogc")
{
insert_fog_declaration(OS, m_prog.fog_equation);

View File

@ -600,40 +600,6 @@ bool GLGSRender::do_method(u32 cmd, u32 arg)
return true;
}
struct alignas(4) glsl_scale_buffer
{
float viewport_matrix[4][4];
float window_matrix[4][4];
float normalize_matrix[4][4];
};
struct alignas(4) glsl_vertex_constants_buffer
{
float vc[468][4];
};
struct alignas(4) glsl_fragment_constants_buffer
{
float fc[2048][4];
};
struct alignas(4) glsl_fragment_state_buffer
{
float fog_param0;
float fog_param1;
uint alpha_test;
float alpha_ref;
};
static void fill_fragment_state_buffer(glsl_fragment_state_buffer *buffer)
{
const float fog_params[2] = { rsx::method_registers.fog_params_0(), rsx::method_registers.fog_params_1() };
std::memcpy(&buffer->fog_param0, fog_params, sizeof(float) * 2);
buffer->alpha_test = rsx::method_registers.alpha_test_enabled();
buffer->alpha_ref = rsx::method_registers.alpha_ref() / 255.f;
}
bool GLGSRender::load_program()
{
RSXVertexProgram vertex_program = get_current_vertex_program();
@ -644,59 +610,53 @@ bool GLGSRender::load_program()
u32 fragment_constants_size = m_prog_buffer.get_fragment_constants_buffer_size(fragment_program);
fragment_constants_size = std::max(32U, fragment_constants_size);
u32 max_buffer_sz =
align(sizeof(glsl_scale_buffer), m_uniform_buffer_offset_align) +
align(sizeof(glsl_vertex_constants_buffer), m_uniform_buffer_offset_align) +
align(fragment_constants_size, m_uniform_buffer_offset_align) +
align(sizeof(glsl_fragment_state_buffer), m_uniform_buffer_offset_align);
u32 max_buffer_sz = 512 + 8192 + align(fragment_constants_size, m_uniform_buffer_offset_align);
m_uniform_ring_buffer.reserve_and_map(max_buffer_sz);
u8 *buf;
u32 scale_offset_offset;
u32 vertex_constants_offset;
u32 fragment_constants_offset;
u32 fragment_state_offset;
m_uniform_ring_buffer.reserve_and_map(max_buffer_sz);
// Scale offset
{
auto mapping = m_uniform_ring_buffer.alloc_from_reserve(sizeof(glsl_scale_buffer), m_uniform_buffer_offset_align);
fill_scale_offset_data((glsl_scale_buffer *)mapping.first, false);
scale_offset_offset = mapping.second;
}
auto mapping = m_uniform_ring_buffer.alloc_from_reserve(512);
buf = static_cast<u8*>(mapping.first);
scale_offset_offset = mapping.second;
fill_scale_offset_data(buf, false);
// Fragment state
{
auto mapping = m_uniform_ring_buffer.alloc_from_reserve(sizeof(glsl_fragment_state_buffer), m_uniform_buffer_offset_align);
fill_fragment_state_buffer((glsl_fragment_state_buffer *)mapping.first);
fragment_state_offset = mapping.second;
}
// Fragment state
u32 is_alpha_tested = rsx::method_registers.alpha_test_enabled();
float alpha_ref = rsx::method_registers.alpha_ref() / 255.f;
f32 fog0 = rsx::method_registers.fog_params_0();
f32 fog1 = rsx::method_registers.fog_params_1();
memcpy(buf + 16 * sizeof(float), &fog0, sizeof(float));
memcpy(buf + 17 * sizeof(float), &fog1, sizeof(float));
memcpy(buf + 18 * sizeof(float), &is_alpha_tested, sizeof(u32));
memcpy(buf + 19 * sizeof(float), &alpha_ref, sizeof(float));
// Vertex constants
{
auto mapping = m_uniform_ring_buffer.alloc_from_reserve(sizeof(glsl_vertex_constants_buffer), m_uniform_buffer_offset_align);
fill_vertex_program_constants_data(mapping.first);
vertex_constants_offset = mapping.second;
}
mapping = m_uniform_ring_buffer.alloc_from_reserve(8192);
buf = static_cast<u8*>(mapping.first);
vertex_constants_offset = mapping.second;
fill_vertex_program_constants_data(buf);
// Fragment constants
if (fragment_constants_size)
{
auto mapping = m_uniform_ring_buffer.alloc_from_reserve(fragment_constants_size, m_uniform_buffer_offset_align);
u8 *buf = static_cast<u8*>(mapping.first);
m_prog_buffer.fill_fragment_constants_buffer({ reinterpret_cast<float*>(buf), gsl::narrow<int>(fragment_constants_size) }, fragment_program);
mapping = m_uniform_ring_buffer.alloc_from_reserve(fragment_constants_size);
buf = static_cast<u8*>(mapping.first);
fragment_constants_offset = mapping.second;
m_prog_buffer.fill_fragment_constants_buffer({ reinterpret_cast<float*>(buf), gsl::narrow<int>(fragment_constants_size) }, fragment_program);
}
m_uniform_ring_buffer.unmap();
m_uniform_ring_buffer.bind_range(0, scale_offset_offset, sizeof(glsl_scale_buffer));
m_uniform_ring_buffer.bind_range(1, vertex_constants_offset, sizeof(glsl_vertex_constants_buffer));
m_uniform_ring_buffer.bind_range(0, scale_offset_offset, 512);
m_uniform_ring_buffer.bind_range(1, vertex_constants_offset, 8192);
if (fragment_constants_size)
{
m_uniform_ring_buffer.bind_range(2, fragment_constants_offset, fragment_constants_size);
}
m_uniform_ring_buffer.bind_range(3, fragment_state_offset, sizeof(glsl_fragment_state_buffer));
return true;
}
@ -846,4 +806,4 @@ bool GLGSRender::on_access_violation(u32 address, bool is_writing)
{
if (is_writing) return m_gl_texture_cache.mark_as_dirty(address);
return false;
}
}

View File

@ -114,9 +114,10 @@ static const reg_info reg_table[] =
{ "gl_ClipDistance[1]", false, "dst_reg5", ".z", false },
{ "gl_ClipDistance[2]", false, "dst_reg5", ".w", false },
{ "gl_PointSize", false, "dst_reg6", ".x", false },
{ "gl_ClipDistance[3]", false, "dst_reg6", ".y", false },
{ "gl_ClipDistance[4]", false, "dst_reg6", ".z", false },
{ "gl_ClipDistance[5]", false, "dst_reg6", ".w", false },
//Disable user clip planes until they are properly handled
//{ "gl_ClipDistance[3]", false, "dst_reg6", ".y", false },
//{ "gl_ClipDistance[4]", false, "dst_reg6", ".z", false },
//{ "gl_ClipDistance[5]", false, "dst_reg6", ".w", false },
{ "tc0", true, "dst_reg7", "", false },
{ "tc1", true, "dst_reg8", "", false },
{ "tc2", true, "dst_reg9", "", false },
@ -225,53 +226,15 @@ GLVertexProgram::GLVertexProgram()
GLVertexProgram::~GLVertexProgram()
{
//if (m_decompiler_thread)
//{
// Wait();
// if (m_decompiler_thread->IsAlive())
// {
// m_decompiler_thread->Stop();
// }
// delete m_decompiler_thread;
// m_decompiler_thread = nullptr;
//}
Delete();
}
//void GLVertexProgram::Wait()
//{
// if (m_decompiler_thread && m_decompiler_thread->IsAlive())
// {
// m_decompiler_thread->Join();
// }
//}
void GLVertexProgram::Decompile(const RSXVertexProgram& prog)
{
GLVertexDecompilerThread decompiler(prog, shader, parr);
decompiler.Task();
}
//void GLVertexProgram::DecompileAsync(RSXVertexProgram& prog)
//{
// if (m_decompiler_thread)
// {
// Wait();
// if (m_decompiler_thread->IsAlive())
// {
// m_decompiler_thread->Stop();
// }
//
// delete m_decompiler_thread;
// m_decompiler_thread = nullptr;
// }
//
// m_decompiler_thread = new GLVertexDecompilerThread(prog.data, shader, parr);
// m_decompiler_thread->Start();
//}
void GLVertexProgram::Compile()
{
if (id)
@ -305,8 +268,6 @@ void GLVertexProgram::Compile()
LOG_NOTICE(RSX, "%s", shader.c_str());
Emu.Pause();
}
//else LOG_WARNING(RSX, "Vertex shader compiled successfully!");
}
void GLVertexProgram::Delete()