From e0ca938b222584cdbf9e03460171c03484882bd4 Mon Sep 17 00:00:00 2001 From: FernandoS27 Date: Thu, 11 Oct 2018 19:11:47 -0400 Subject: Propagate depth and depth_block on modules using decoders --- .../renderer_opengl/gl_rasterizer_cache.cpp | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 65a220c41..86cb62dae 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -323,8 +323,8 @@ static bool IsFormatBCn(PixelFormat format) { } template -void MortonCopy(u32 stride, u32 block_height, u32 height, u8* gl_buffer, std::size_t gl_buffer_size, - VAddr addr) { +void MortonCopy(u32 stride, u32 block_height, u32 height, u32 block_depth, u32 depth, u8* gl_buffer, + std::size_t gl_buffer_size, VAddr addr) { constexpr u32 bytes_per_pixel = SurfaceParams::GetFormatBpp(format) / CHAR_BIT; constexpr u32 gl_bytes_per_pixel = CachedSurface::GetGLBytesPerPixel(format); @@ -333,7 +333,7 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, u8* gl_buffer, std::si // pixel values. const u32 tile_size{IsFormatBCn(format) ? 4U : 1U}; const std::vector data = Tegra::Texture::UnswizzleTexture( - addr, tile_size, bytes_per_pixel, stride, height, block_height); + addr, tile_size, bytes_per_pixel, stride, height, depth, block_height, block_depth); const std::size_t size_to_copy{std::min(gl_buffer_size, data.size())}; memcpy(gl_buffer, data.data(), size_to_copy); } else { @@ -345,7 +345,7 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, u8* gl_buffer, std::si } } -static constexpr std::array morton_to_gl_fns = { // clang-format off @@ -403,7 +403,7 @@ static constexpr std::array gl_to_morton_fns = { // clang-format off @@ -827,25 +827,27 @@ void CachedSurface::LoadGLBuffer() { if (params.is_tiled) { gl_buffer.resize(total_size); + u32 depth = params.depth; + u32 block_depth = params.block_depth; ASSERT_MSG(params.block_width == 1, "Block width is defined as {} on texture type {}", params.block_width, static_cast(params.target)); - ASSERT_MSG(params.block_depth == 1, "Block depth is defined as {} on texture type {}", - params.block_depth, static_cast(params.target)); - // TODO(bunnei): This only unswizzles and copies a 2D texture - we do not yet know how to do - // this for 3D textures, etc. switch (params.target) { case SurfaceParams::SurfaceTarget::Texture2D: - // Pass impl. to the fallback code below + // TODO(Blinkhawk): Eliminate this condition once all texture types are implemented. + depth = 1U; + block_depth = 1U; break; case SurfaceParams::SurfaceTarget::Texture2DArray: case SurfaceParams::SurfaceTarget::TextureCubemap: + depth = 1U; + block_depth = 1U; for (std::size_t index = 0; index < params.depth; ++index) { const std::size_t offset{index * copy_size}; morton_to_gl_fns[static_cast(params.pixel_format)]( - params.width, params.block_height, params.height, gl_buffer.data() + offset, - copy_size, params.addr + offset); + params.width, params.block_height, params.height, 1U, 1U, + gl_buffer.data() + offset, copy_size, params.addr + offset); } break; default: @@ -854,9 +856,11 @@ void CachedSurface::LoadGLBuffer() { UNREACHABLE(); } + const std::size_t size = copy_size * depth; + morton_to_gl_fns[static_cast(params.pixel_format)]( - params.width, params.block_height, params.height, gl_buffer.data(), copy_size, - params.addr); + params.width, params.block_height, params.height, block_depth, depth, gl_buffer.data(), + size, params.addr); } else { const u8* const texture_src_data_end{texture_src_data + total_size}; gl_buffer.assign(texture_src_data, texture_src_data_end); -- cgit v1.2.3