summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2018-10-12 01:11:47 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2018-10-13 21:25:18 +0200
commite0ca938b222584cdbf9e03460171c03484882bd4 (patch)
tree508abef3fcef21a6fecc6c783bf7da1d93b198f0 /src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
parentRemove old Swizzle algorithms and use 3d Swizzle (diff)
downloadyuzu-e0ca938b222584cdbf9e03460171c03484882bd4.tar
yuzu-e0ca938b222584cdbf9e03460171c03484882bd4.tar.gz
yuzu-e0ca938b222584cdbf9e03460171c03484882bd4.tar.bz2
yuzu-e0ca938b222584cdbf9e03460171c03484882bd4.tar.lz
yuzu-e0ca938b222584cdbf9e03460171c03484882bd4.tar.xz
yuzu-e0ca938b222584cdbf9e03460171c03484882bd4.tar.zst
yuzu-e0ca938b222584cdbf9e03460171c03484882bd4.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.cpp')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp32
1 files changed, 18 insertions, 14 deletions
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 <bool morton_to_gl, PixelFormat format>
-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<u8> 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<void (*)(u32, u32, u32, u8*, std::size_t, VAddr),
+static constexpr std::array<void (*)(u32, u32, u32, u32, u32, u8*, std::size_t, VAddr),
SurfaceParams::MaxPixelFormat>
morton_to_gl_fns = {
// clang-format off
@@ -403,7 +403,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, std::size_t, VAddr),
// clang-format on
};
-static constexpr std::array<void (*)(u32, u32, u32, u8*, std::size_t, VAddr),
+static constexpr std::array<void (*)(u32, u32, u32, u32, u32, u8*, std::size_t, VAddr),
SurfaceParams::MaxPixelFormat>
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<u32>(params.target));
- ASSERT_MSG(params.block_depth == 1, "Block depth is defined as {} on texture type {}",
- params.block_depth, static_cast<u32>(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<std::size_t>(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<std::size_t>(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);