From b4e29ccb8143ed54d9efeb378db9f45d0153b2e2 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 12 Oct 2018 22:28:02 -0400 Subject: [PATCH] gl_rasterizer_cache: Remove usage of Memory::Read/Write functions. - These cannot be used within the cache, as they change cache state. --- .../renderer_opengl/gl_rasterizer_cache.cpp | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 24781a3c1..3eedb0d50 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -668,8 +668,10 @@ static void CopySurface(const Surface& src_surface, const Surface& dst_surface, std::size_t remaining_size = dst_params.size_in_bytes_total - src_params.size_in_bytes_total; std::vector data(remaining_size); - Memory::ReadBlock(dst_params.addr + src_params.size_in_bytes_total, data.data(), - data.size()); + std::memcpy(data.data(), + Memory::GetPointer(dst_params.addr + src_params.size_in_bytes_total), + data.size()); + glBufferSubData(GL_PIXEL_PACK_BUFFER, src_params.size_in_bytes_total, remaining_size, data.data()); } @@ -916,13 +918,8 @@ void CachedSurface::LoadGLBuffer() { MICROPROFILE_DEFINE(OpenGL_SurfaceFlush, "OpenGL", "Surface Flush", MP_RGB(128, 192, 64)); void CachedSurface::FlushGLBuffer() { MICROPROFILE_SCOPE(OpenGL_SurfaceFlush); - const auto& rect{params.GetRect()}; + // Load data from memory to the surface - const GLint x0 = static_cast(rect.left); - const GLint y0 = static_cast(rect.bottom); - const size_t buffer_offset = - static_cast(static_cast(y0) * params.width + static_cast(x0)) * - GetGLBytesPerPixel(params.pixel_format); const u32 bytes_per_pixel = GetGLBytesPerPixel(params.pixel_format); const u32 copy_size = params.width * params.height * bytes_per_pixel; gl_buffer.resize(static_cast(params.depth) * copy_size); @@ -931,7 +928,6 @@ void CachedSurface::FlushGLBuffer() { ASSERT(params.width * GetGLBytesPerPixel(params.pixel_format) % 4 == 0); glPixelStorei(GL_PACK_ROW_LENGTH, static_cast(params.width)); ASSERT(!tuple.compressed); - ASSERT(x0 == 0 && y0 == 0); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); glGetTextureImage(texture.handle, 0, tuple.format, tuple.type, gl_buffer.size(), gl_buffer.data()); @@ -954,11 +950,10 @@ void CachedSurface::FlushGLBuffer() { block_depth = 1U; } gl_to_morton_fns[static_cast(params.pixel_format)]( - params.width, params.block_height, params.height, block_depth, depth, - &gl_buffer[buffer_offset], copy_size, params.addr + buffer_offset); + params.width, params.block_height, params.height, block_depth, depth, gl_buffer.data(), + copy_size, GetAddr()); } else { - Memory::WriteBlock(params.addr + buffer_offset, &gl_buffer[buffer_offset], - gl_buffer.size() - buffer_offset); + std::memcpy(Memory::GetPointer(GetAddr()), gl_buffer.data(), GetSizeInBytes()); } }