summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-10-12 22:28:02 -0400
committerGravatar bunnei2018-10-16 11:31:00 -0400
commitb4e29ccb8143ed54d9efeb378db9f45d0153b2e2 (patch)
tree681442d561a2f0f50791be49eaaed05614964d83 /src
parentgl_rasterizer_cache: Clamp cached surface size to mapped GPU region size. (diff)
downloadyuzu-b4e29ccb8143ed54d9efeb378db9f45d0153b2e2.tar.gz
yuzu-b4e29ccb8143ed54d9efeb378db9f45d0153b2e2.tar.xz
yuzu-b4e29ccb8143ed54d9efeb378db9f45d0153b2e2.zip
gl_rasterizer_cache: Remove usage of Memory::Read/Write functions.
- These cannot be used within the cache, as they change cache state.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp21
1 files 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,
668 std::size_t remaining_size = 668 std::size_t remaining_size =
669 dst_params.size_in_bytes_total - src_params.size_in_bytes_total; 669 dst_params.size_in_bytes_total - src_params.size_in_bytes_total;
670 std::vector<u8> data(remaining_size); 670 std::vector<u8> data(remaining_size);
671 Memory::ReadBlock(dst_params.addr + src_params.size_in_bytes_total, data.data(), 671 std::memcpy(data.data(),
672 data.size()); 672 Memory::GetPointer(dst_params.addr + src_params.size_in_bytes_total),
673 data.size());
674
673 glBufferSubData(GL_PIXEL_PACK_BUFFER, src_params.size_in_bytes_total, remaining_size, 675 glBufferSubData(GL_PIXEL_PACK_BUFFER, src_params.size_in_bytes_total, remaining_size,
674 data.data()); 676 data.data());
675 } 677 }
@@ -916,13 +918,8 @@ void CachedSurface::LoadGLBuffer() {
916MICROPROFILE_DEFINE(OpenGL_SurfaceFlush, "OpenGL", "Surface Flush", MP_RGB(128, 192, 64)); 918MICROPROFILE_DEFINE(OpenGL_SurfaceFlush, "OpenGL", "Surface Flush", MP_RGB(128, 192, 64));
917void CachedSurface::FlushGLBuffer() { 919void CachedSurface::FlushGLBuffer() {
918 MICROPROFILE_SCOPE(OpenGL_SurfaceFlush); 920 MICROPROFILE_SCOPE(OpenGL_SurfaceFlush);
919 const auto& rect{params.GetRect()}; 921
920 // Load data from memory to the surface 922 // Load data from memory to the surface
921 const GLint x0 = static_cast<GLint>(rect.left);
922 const GLint y0 = static_cast<GLint>(rect.bottom);
923 const size_t buffer_offset =
924 static_cast<size_t>(static_cast<size_t>(y0) * params.width + static_cast<size_t>(x0)) *
925 GetGLBytesPerPixel(params.pixel_format);
926 const u32 bytes_per_pixel = GetGLBytesPerPixel(params.pixel_format); 923 const u32 bytes_per_pixel = GetGLBytesPerPixel(params.pixel_format);
927 const u32 copy_size = params.width * params.height * bytes_per_pixel; 924 const u32 copy_size = params.width * params.height * bytes_per_pixel;
928 gl_buffer.resize(static_cast<size_t>(params.depth) * copy_size); 925 gl_buffer.resize(static_cast<size_t>(params.depth) * copy_size);
@@ -931,7 +928,6 @@ void CachedSurface::FlushGLBuffer() {
931 ASSERT(params.width * GetGLBytesPerPixel(params.pixel_format) % 4 == 0); 928 ASSERT(params.width * GetGLBytesPerPixel(params.pixel_format) % 4 == 0);
932 glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(params.width)); 929 glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(params.width));
933 ASSERT(!tuple.compressed); 930 ASSERT(!tuple.compressed);
934 ASSERT(x0 == 0 && y0 == 0);
935 glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); 931 glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
936 glGetTextureImage(texture.handle, 0, tuple.format, tuple.type, gl_buffer.size(), 932 glGetTextureImage(texture.handle, 0, tuple.format, tuple.type, gl_buffer.size(),
937 gl_buffer.data()); 933 gl_buffer.data());
@@ -954,11 +950,10 @@ void CachedSurface::FlushGLBuffer() {
954 block_depth = 1U; 950 block_depth = 1U;
955 } 951 }
956 gl_to_morton_fns[static_cast<size_t>(params.pixel_format)]( 952 gl_to_morton_fns[static_cast<size_t>(params.pixel_format)](
957 params.width, params.block_height, params.height, block_depth, depth, 953 params.width, params.block_height, params.height, block_depth, depth, gl_buffer.data(),
958 &gl_buffer[buffer_offset], copy_size, params.addr + buffer_offset); 954 copy_size, GetAddr());
959 } else { 955 } else {
960 Memory::WriteBlock(params.addr + buffer_offset, &gl_buffer[buffer_offset], 956 std::memcpy(Memory::GetPointer(GetAddr()), gl_buffer.data(), GetSizeInBytes());
961 gl_buffer.size() - buffer_offset);
962 } 957 }
963} 958}
964 959