mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-23 03:02:53 +01:00
gl: Rewrite texture cache
gl: scale downloaded RTT images
This commit is contained in:
parent
bd85f23ed9
commit
96561c16ad
@ -546,7 +546,6 @@ void GLGSRender::on_init_thread()
|
|||||||
m_index_ring_buffer->create(gl::buffer::target::element_array, 16 * 0x100000);
|
m_index_ring_buffer->create(gl::buffer::target::element_array, 16 * 0x100000);
|
||||||
|
|
||||||
m_vao.element_array_buffer = *m_index_ring_buffer;
|
m_vao.element_array_buffer = *m_index_ring_buffer;
|
||||||
m_gl_texture_cache.initialize_rtt_cache();
|
|
||||||
|
|
||||||
if (g_cfg_rsx_overlay)
|
if (g_cfg_rsx_overlay)
|
||||||
m_text_printer.init();
|
m_text_printer.init();
|
||||||
@ -644,7 +643,7 @@ void nv4097_clear_surface(u32 arg, GLGSRender* renderer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
glClear(mask);
|
glClear(mask);
|
||||||
renderer->write_buffers();
|
//renderer->write_buffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
using rsx_method_impl_t = void(*)(u32, GLGSRender*);
|
using rsx_method_impl_t = void(*)(u32, GLGSRender*);
|
||||||
@ -698,7 +697,6 @@ bool GLGSRender::load_program()
|
|||||||
RSXVertexProgram vertex_program = get_current_vertex_program();
|
RSXVertexProgram vertex_program = get_current_vertex_program();
|
||||||
RSXFragmentProgram fragment_program = get_current_fragment_program(rtt_lookup_func);
|
RSXFragmentProgram fragment_program = get_current_fragment_program(rtt_lookup_func);
|
||||||
|
|
||||||
std::array<float, 16> rtt_scaling;
|
|
||||||
u32 unnormalized_rtts = 0;
|
u32 unnormalized_rtts = 0;
|
||||||
|
|
||||||
for (auto &vtx : vertex_program.rsx_vertex_inputs)
|
for (auto &vtx : vertex_program.rsx_vertex_inputs)
|
||||||
@ -946,6 +944,8 @@ u64 GLGSRender::timestamp() const
|
|||||||
|
|
||||||
bool GLGSRender::on_access_violation(u32 address, bool is_writing)
|
bool GLGSRender::on_access_violation(u32 address, bool is_writing)
|
||||||
{
|
{
|
||||||
if (is_writing) return m_gl_texture_cache.mark_as_dirty(address);
|
if (is_writing)
|
||||||
return false;
|
return m_gl_texture_cache.mark_as_dirty(address);
|
||||||
|
else
|
||||||
|
return m_gl_texture_cache.flush_section(address);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ private:
|
|||||||
|
|
||||||
gl_render_targets m_rtts;
|
gl_render_targets m_rtts;
|
||||||
|
|
||||||
gl::gl_texture_cache m_gl_texture_cache;
|
gl::texture_cache m_gl_texture_cache;
|
||||||
|
|
||||||
gl::texture m_gl_attrib_buffers[rsx::limits::vertex_count];
|
gl::texture m_gl_attrib_buffers[rsx::limits::vertex_count];
|
||||||
|
|
||||||
|
@ -170,6 +170,8 @@ OPENGL_PROC(PFNGLBINDBUFFERBASEPROC, BindBufferBase);
|
|||||||
|
|
||||||
OPENGL_PROC(PFNGLMULTIDRAWARRAYSPROC, MultiDrawArrays);
|
OPENGL_PROC(PFNGLMULTIDRAWARRAYSPROC, MultiDrawArrays);
|
||||||
|
|
||||||
|
OPENGL_PROC(PFNGLGETTEXTUREIMAGEPROC, GetTextureImage);
|
||||||
|
|
||||||
//Texture Buffers
|
//Texture Buffers
|
||||||
OPENGL_PROC(PFNGLTEXBUFFERPROC, TexBuffer);
|
OPENGL_PROC(PFNGLTEXBUFFERPROC, TexBuffer);
|
||||||
OPENGL_PROC(PFNGLTEXTUREBUFFERRANGEEXTPROC, TextureBufferRangeEXT);
|
OPENGL_PROC(PFNGLTEXTUREBUFFERRANGEEXTPROC, TextureBufferRangeEXT);
|
||||||
|
@ -228,7 +228,7 @@ void GLGSRender::read_buffers()
|
|||||||
rsx::tiled_region color_buffer = get_tiled_address(offset, location & 0xf);
|
rsx::tiled_region color_buffer = get_tiled_address(offset, location & 0xf);
|
||||||
u32 texaddr = (u32)((u64)color_buffer.ptr - (u64)vm::base(0));
|
u32 texaddr = (u32)((u64)color_buffer.ptr - (u64)vm::base(0));
|
||||||
|
|
||||||
bool success = m_gl_texture_cache.explicit_writeback((*std::get<1>(m_rtts.m_bound_render_targets[i])), texaddr, pitch);
|
bool success = m_gl_texture_cache.load_rtt((*std::get<1>(m_rtts.m_bound_render_targets[i])), texaddr, pitch);
|
||||||
|
|
||||||
//Fall back to slower methods if the image could not be fetched from cache.
|
//Fall back to slower methods if the image could not be fetched from cache.
|
||||||
if (!success)
|
if (!success)
|
||||||
@ -240,7 +240,7 @@ void GLGSRender::read_buffers()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
u32 range = pitch * height;
|
u32 range = pitch * height;
|
||||||
m_gl_texture_cache.remove_in_range(texaddr, range);
|
m_gl_texture_cache.invalidate_range(texaddr, range);
|
||||||
|
|
||||||
std::unique_ptr<u8[]> buffer(new u8[pitch * height]);
|
std::unique_ptr<u8[]> buffer(new u8[pitch * height]);
|
||||||
color_buffer.read(buffer.get(), width, height, pitch);
|
color_buffer.read(buffer.get(), width, height, pitch);
|
||||||
@ -287,7 +287,7 @@ void GLGSRender::read_buffers()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
u32 depth_address = rsx::get_address(rsx::method_registers.surface_z_offset(), rsx::method_registers.surface_z_dma());
|
u32 depth_address = rsx::get_address(rsx::method_registers.surface_z_offset(), rsx::method_registers.surface_z_dma());
|
||||||
bool in_cache = m_gl_texture_cache.explicit_writeback((*std::get<1>(m_rtts.m_bound_depth_stencil)), depth_address, pitch);
|
bool in_cache = m_gl_texture_cache.load_rtt((*std::get<1>(m_rtts.m_bound_depth_stencil)), depth_address, pitch);
|
||||||
|
|
||||||
if (in_cache)
|
if (in_cache)
|
||||||
return;
|
return;
|
||||||
@ -332,9 +332,6 @@ void GLGSRender::write_buffers()
|
|||||||
if (!draw_fbo)
|
if (!draw_fbo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//TODO: Detect when the data is actually being used by cell and issue download command on-demand (mark as not present?)
|
|
||||||
//Should also mark cached resources as dirty so that read buffers works out-of-the-box without modification
|
|
||||||
|
|
||||||
if (g_cfg_rsx_write_color_buffers)
|
if (g_cfg_rsx_write_color_buffers)
|
||||||
{
|
{
|
||||||
auto color_format = rsx::internals::surface_color_format_to_gl(rsx::method_registers.surface_color());
|
auto color_format = rsx::internals::surface_color_format_to_gl(rsx::method_registers.surface_color());
|
||||||
@ -366,7 +363,7 @@ void GLGSRender::write_buffers()
|
|||||||
* but using the GPU to perform the caching is many times faster.
|
* but using the GPU to perform the caching is many times faster.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
__glcheck m_gl_texture_cache.save_render_target(texaddr, range, (*std::get<1>(m_rtts.m_bound_render_targets[i])));
|
__glcheck m_gl_texture_cache.save_rtt(texaddr, range, (*std::get<1>(m_rtts.m_bound_render_targets[i])), width, height, pitch, color_format.format, color_format.type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -405,12 +402,14 @@ void GLGSRender::write_buffers()
|
|||||||
if (pitch <= 64)
|
if (pitch <= 64)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
u32 width = rsx::method_registers.surface_clip_width();
|
||||||
|
u32 height = rsx::method_registers.surface_clip_height();
|
||||||
|
u32 range = width * height * 2;
|
||||||
auto depth_format = rsx::internals::surface_depth_format_to_gl(rsx::method_registers.surface_depth_fmt());
|
auto depth_format = rsx::internals::surface_depth_format_to_gl(rsx::method_registers.surface_depth_fmt());
|
||||||
u32 depth_address = rsx::get_address(rsx::method_registers.surface_z_offset(), rsx::method_registers.surface_z_dma());
|
u32 depth_address = rsx::get_address(rsx::method_registers.surface_z_offset(), rsx::method_registers.surface_z_dma());
|
||||||
u32 range = std::get<1>(m_rtts.m_bound_depth_stencil)->width() * std::get<1>(m_rtts.m_bound_depth_stencil)->height() * 2;
|
|
||||||
|
|
||||||
if (rsx::method_registers.surface_depth_fmt() != rsx::surface_depth_format::z16) range *= 2;
|
if (rsx::method_registers.surface_depth_fmt() != rsx::surface_depth_format::z16) range *= 2;
|
||||||
|
|
||||||
m_gl_texture_cache.save_render_target(depth_address, range, (*std::get<1>(m_rtts.m_bound_depth_stencil)));
|
m_gl_texture_cache.save_rtt(depth_address, range, (*std::get<1>(m_rtts.m_bound_depth_stencil)), width, height, pitch, depth_format.format, depth_format.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user