summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorRodrigo Locatti <reinuseslisp@airmail.cc>2021-02-13 22:08:50 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-03-13 18:16:03 +0100
commit2f30c105849c214345e2201f4bd6f9b4b76ab4a1 (patch)
tree5e5889a44af4194fcf22d1375bdf9f91b5302dc1 /src/video_core/renderer_opengl
parentastc_decoder: Fix out of bounds memory access (diff)
downloadyuzu-2f30c105849c214345e2201f4bd6f9b4b76ab4a1.tar
yuzu-2f30c105849c214345e2201f4bd6f9b4b76ab4a1.tar.gz
yuzu-2f30c105849c214345e2201f4bd6f9b4b76ab4a1.tar.bz2
yuzu-2f30c105849c214345e2201f4bd6f9b4b76ab4a1.tar.lz
yuzu-2f30c105849c214345e2201f4bd6f9b4b76ab4a1.tar.xz
yuzu-2f30c105849c214345e2201f4bd6f9b4b76ab4a1.tar.zst
yuzu-2f30c105849c214345e2201f4bd6f9b4b76ab4a1.zip
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/util_shaders.cpp53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/video_core/renderer_opengl/util_shaders.cpp b/src/video_core/renderer_opengl/util_shaders.cpp
index d0979dab1..85722c54a 100644
--- a/src/video_core/renderer_opengl/util_shaders.cpp
+++ b/src/video_core/renderer_opengl/util_shaders.cpp
@@ -110,7 +110,6 @@ void UtilShaders::ASTCDecode(Image& image, const ImageBufferMap& map,
static constexpr GLuint BINDING_OUTPUT_IMAGE = 0;
static constexpr GLuint LOC_NUM_IMAGE_BLOCKS = 0;
static constexpr GLuint LOC_BLOCK_DIMS = 1;
- static constexpr GLuint LOC_LAYER = 2;
const Extent3D tile_size = {
VideoCore::Surface::DefaultBlockWidth(image.info.format),
@@ -130,35 +129,31 @@ void UtilShaders::ASTCDecode(Image& image, const ImageBufferMap& map,
glFlushMappedNamedBufferRange(map.buffer, map.offset, image.guest_size_bytes);
glUniform2ui(LOC_BLOCK_DIMS, tile_size.width, tile_size.height);
+ for (const SwizzleParameters& swizzle : swizzles) {
+ glBindImageTexture(BINDING_OUTPUT_IMAGE, image.StorageHandle(), swizzle.level, GL_TRUE, 0,
+ GL_WRITE_ONLY, GL_RGBA8);
+ const size_t input_offset = swizzle.buffer_offset + map.offset;
+ const auto num_dispatches_x = Common::DivCeil(swizzle.num_tiles.width, 32U);
+ const auto num_dispatches_y = Common::DivCeil(swizzle.num_tiles.height, 32U);
- for (u32 layer = 0; layer < image.info.resources.layers; layer++) {
- for (const SwizzleParameters& swizzle : swizzles) {
- glBindImageTexture(BINDING_OUTPUT_IMAGE, image.StorageHandle(), swizzle.level, GL_FALSE,
- layer, GL_WRITE_ONLY, GL_RGBA8);
- const size_t input_offset = swizzle.buffer_offset + map.offset;
- const auto num_dispatches_x = Common::DivCeil(swizzle.num_tiles.width, 32U);
- const auto num_dispatches_y = Common::DivCeil(swizzle.num_tiles.height, 32U);
-
- glUniform2ui(LOC_NUM_IMAGE_BLOCKS, swizzle.num_tiles.width, swizzle.num_tiles.height);
- glUniform1ui(LOC_LAYER, layer);
-
- // To unswizzle the ASTC data
- const auto params = MakeBlockLinearSwizzle2DParams(swizzle, image.info);
- glUniform3uiv(3, 1, params.origin.data());
- glUniform3iv(4, 1, params.destination.data());
- glUniform1ui(5, params.bytes_per_block_log2);
- glUniform1ui(6, params.layer_stride);
- glUniform1ui(7, params.block_size);
- glUniform1ui(8, params.x_shift);
- glUniform1ui(9, params.block_height);
- glUniform1ui(10, params.block_height_mask);
-
- // ASTC texture data
- glBindBufferRange(GL_SHADER_STORAGE_BUFFER, BINDING_INPUT_BUFFER, map.buffer,
- input_offset, image.guest_size_bytes - swizzle.buffer_offset);
-
- glDispatchCompute(num_dispatches_x, num_dispatches_y, 1);
- }
+ glUniform2ui(LOC_NUM_IMAGE_BLOCKS, swizzle.num_tiles.width, swizzle.num_tiles.height);
+
+ // To unswizzle the ASTC data
+ const auto params = MakeBlockLinearSwizzle2DParams(swizzle, image.info);
+ glUniform3uiv(2, 1, params.origin.data());
+ glUniform3iv(3, 1, params.destination.data());
+ glUniform1ui(4, params.bytes_per_block_log2);
+ glUniform1ui(5, params.layer_stride);
+ glUniform1ui(6, params.block_size);
+ glUniform1ui(7, params.x_shift);
+ glUniform1ui(8, params.block_height);
+ glUniform1ui(9, params.block_height_mask);
+
+ // ASTC texture data
+ glBindBufferRange(GL_SHADER_STORAGE_BUFFER, BINDING_INPUT_BUFFER, map.buffer, input_offset,
+ image.guest_size_bytes - swizzle.buffer_offset);
+
+ glDispatchCompute(num_dispatches_x, num_dispatches_y, image.info.resources.layers);
}
program_manager.RestoreGuestCompute();
}