mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-05-12 16:19:44 -06:00
gl: Implement emulated Z comparison support
This commit is contained in:
parent
0df9096e90
commit
c7ff1e726c
@ -543,6 +543,15 @@ void GLGSRender::bind_texture_env()
|
||||
cmd->bind_texture(GL_VERTEX_TEXTURES_START + i, GL_TEXTURE_2D, GL_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (current_fragment_program.ctrl & RSX_SHADER_CONTROL_EMULATE_DEPTH_COMPARE)
|
||||
{
|
||||
ensure(m_rtts.m_bound_depth_stencil.first, "Invalid FBO setup");
|
||||
gl::insert_texture_barrier();
|
||||
|
||||
auto view = m_rtts.m_bound_depth_stencil.second->get_view(rsx::default_remap_vector, gl::image_aspect::depth);
|
||||
view->bind(cmd, GL_TEMP_IMAGE_SLOT(0));
|
||||
}
|
||||
}
|
||||
|
||||
void GLGSRender::bind_interpreter_texture_env()
|
||||
|
||||
@ -167,6 +167,11 @@ void GLFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_prog.ctrl & RSX_SHADER_CONTROL_EMULATE_DEPTH_COMPARE)
|
||||
{
|
||||
OS << "uniform sampler2D frag_depth;\n";
|
||||
}
|
||||
|
||||
OS << "\n";
|
||||
|
||||
if (!properties.constant_offsets.empty())
|
||||
@ -238,6 +243,7 @@ void GLFragmentDecompilerThread::insertGlobalFunctions(std::stringstream &OS)
|
||||
m_shader_props.require_shadowProj_ops = properties.shadow_sampler_mask != 0 && properties.has_texShadowProj;
|
||||
m_shader_props.require_alpha_kill = !!(m_prog.ctrl & RSX_SHADER_CONTROL_TEXTURE_ALPHA_KILL);
|
||||
m_shader_props.require_color_format_convert = !!(m_prog.ctrl & RSX_SHADER_CONTROL_TEXTURE_FORMAT_CONVERT);
|
||||
m_shader_props.emulate_depth_compare = !!(m_prog.ctrl & RSX_SHADER_CONTROL_EMULATE_DEPTH_COMPARE);
|
||||
|
||||
glsl::insert_glsl_legacy_function(OS, m_shader_props);
|
||||
}
|
||||
|
||||
@ -101,6 +101,13 @@ struct GLTraits
|
||||
// Bind locations 0 and 1 to the stream buffers
|
||||
program->uniforms[0] = GL_STREAM_BUFFER_START + 0;
|
||||
program->uniforms[1] = GL_STREAM_BUFFER_START + 1;
|
||||
|
||||
// Optional inputs
|
||||
int location = 0;
|
||||
if (program->uniforms.has_location("frag_depth", &location))
|
||||
{
|
||||
program->uniforms[location] = GL_TEMP_IMAGE_SLOT(0);
|
||||
}
|
||||
};
|
||||
|
||||
auto pipeline = compiler->compile(flags, post_create_func, post_link_func, callback);
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include "Emu/RSX/GL/GLTexture.h"
|
||||
#include "GLRenderTargets.h"
|
||||
#include "glutils/barriers.h"
|
||||
#include "glutils/blitter.h"
|
||||
#include "glutils/sync.hpp"
|
||||
|
||||
@ -804,12 +805,7 @@ namespace gl
|
||||
|
||||
void insert_texture_barrier(gl::command_context&, gl::texture*, bool) override
|
||||
{
|
||||
auto &caps = gl::get_driver_caps();
|
||||
|
||||
if (caps.ARB_texture_barrier_supported)
|
||||
glTextureBarrier();
|
||||
else if (caps.NV_texture_barrier_supported)
|
||||
glTextureBarrierNV();
|
||||
gl::insert_texture_barrier();
|
||||
}
|
||||
|
||||
bool render_target_format_is_compatible(gl::texture* tex, u32 gcm_format) override
|
||||
|
||||
16
rpcs3/Emu/RSX/GL/glutils/barriers.h
Normal file
16
rpcs3/Emu/RSX/GL/glutils/barriers.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
namespace gl
|
||||
{
|
||||
static inline void insert_texture_barrier()
|
||||
{
|
||||
auto& caps = gl::get_driver_caps();
|
||||
|
||||
if (caps.ARB_texture_barrier_supported)
|
||||
glTextureBarrier();
|
||||
else if (caps.NV_texture_barrier_supported)
|
||||
glTextureBarrierNV();
|
||||
}
|
||||
}
|
||||
@ -61,6 +61,7 @@
|
||||
<ClInclude Include="Emu\RSX\GL\GLProcTable.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLProgramBuffer.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLResolveHelper.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\glutils\barriers.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\glutils\blitter.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\glutils\buffer_object.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\glutils\capabilities.h" />
|
||||
|
||||
@ -122,6 +122,9 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\RSX\GL\GLDMA.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\GLResolveHelper.h" />
|
||||
<ClInclude Include="Emu\RSX\GL\glutils\barriers.h">
|
||||
<Filter>glutils</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="glutils">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user