summaryrefslogtreecommitdiff
path: root/src/video_core/host_shaders
diff options
context:
space:
mode:
authorGravatar ameerj2021-02-13 16:49:24 -0500
committerGravatar ameerj2021-03-13 12:16:03 -0500
commit20eb368e147e1c27f05d6923c51596f8dfe24e89 (patch)
treea8b1c8eb79eb55e189a10dfd43b8b6bb1449220f /src/video_core/host_shaders
parenthost_shaders: Modify shader cmake integration to allow for larger shaders (diff)
downloadyuzu-20eb368e147e1c27f05d6923c51596f8dfe24e89.tar.gz
yuzu-20eb368e147e1c27f05d6923c51596f8dfe24e89.tar.xz
yuzu-20eb368e147e1c27f05d6923c51596f8dfe24e89.zip
renderer_vulkan: Accelerate ASTC decoding
Co-Authored-By: Rodrigo Locatti <reinuseslisp@airmail.cc>
Diffstat (limited to 'src/video_core/host_shaders')
-rw-r--r--src/video_core/host_shaders/astc_decoder.comp43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp
index 070190a5c..2ddac2e1d 100644
--- a/src/video_core/host_shaders/astc_decoder.comp
+++ b/src/video_core/host_shaders/astc_decoder.comp
@@ -16,7 +16,7 @@
16#define BINDING_7_TO_8_BUFFER 4 16#define BINDING_7_TO_8_BUFFER 4
17#define BINDING_8_TO_8_BUFFER 5 17#define BINDING_8_TO_8_BUFFER 5
18#define BINDING_BYTE_TO_16_BUFFER 6 18#define BINDING_BYTE_TO_16_BUFFER 6
19#define BINDING_OUTPUT_IMAGE 3 19#define BINDING_OUTPUT_IMAGE 7
20 20
21#else // ^^^ Vulkan ^^^ // vvv OpenGL vvv 21#else // ^^^ Vulkan ^^^ // vvv OpenGL vvv
22 22
@@ -85,7 +85,26 @@ layout(binding = BINDING_SWIZZLE_BUFFER, std430) readonly buffer SwizzleTable {
85layout(binding = BINDING_INPUT_BUFFER, std430) buffer InputBufferU32 { 85layout(binding = BINDING_INPUT_BUFFER, std430) buffer InputBufferU32 {
86 uint astc_data[]; 86 uint astc_data[];
87}; 87};
88layout(binding = BINDING_OUTPUT_IMAGE) uniform writeonly image2D dest_image; 88
89// ASTC Encodings data
90layout(binding = BINDING_ENC_BUFFER, std430) readonly buffer EncodingsValues {
91 EncodingData encoding_values[];
92};
93// ASTC Precompiled tables
94layout(binding = BINDING_6_TO_8_BUFFER, std430) readonly buffer REPLICATE_6_BIT_TO_8 {
95 uint REPLICATE_6_BIT_TO_8_TABLE[];
96};
97layout(binding = BINDING_7_TO_8_BUFFER, std430) readonly buffer REPLICATE_7_BIT_TO_8 {
98 uint REPLICATE_7_BIT_TO_8_TABLE[];
99};
100layout(binding = BINDING_8_TO_8_BUFFER, std430) readonly buffer REPLICATE_8_BIT_TO_8 {
101 uint REPLICATE_8_BIT_TO_8_TABLE[];
102};
103layout(binding = BINDING_BYTE_TO_16_BUFFER, std430) readonly buffer REPLICATE_BYTE_TO_16 {
104 uint REPLICATE_BYTE_TO_16_TABLE[];
105};
106
107layout(binding = BINDING_OUTPUT_IMAGE, rgba8) uniform writeonly image2D dest_image;
89 108
90const uint GOB_SIZE_X = 64; 109const uint GOB_SIZE_X = 64;
91const uint GOB_SIZE_Y = 8; 110const uint GOB_SIZE_Y = 8;
@@ -109,23 +128,6 @@ uint ReadTexel(uint offset) {
109 return bitfieldExtract(astc_data[offset / 4], int((offset * 8) & 24), 8); 128 return bitfieldExtract(astc_data[offset / 4], int((offset * 8) & 24), 8);
110} 129}
111 130
112// ASTC Encodings data
113layout(binding = BINDING_ENC_BUFFER, std430) readonly buffer EncodingsValues {
114 EncodingData encoding_values[256];
115};
116// ASTC Precompiled tables
117layout(binding = BINDING_6_TO_8_BUFFER, std430) readonly buffer REPLICATE_6_BIT_TO_8 {
118 uint REPLICATE_6_BIT_TO_8_TABLE[];
119};
120layout(binding = BINDING_7_TO_8_BUFFER, std430) readonly buffer REPLICATE_7_BIT_TO_8 {
121 uint REPLICATE_7_BIT_TO_8_TABLE[];
122};
123layout(binding = BINDING_8_TO_8_BUFFER, std430) readonly buffer REPLICATE_8_BIT_TO_8 {
124 uint REPLICATE_8_BIT_TO_8_TABLE[];
125};
126layout(binding = BINDING_BYTE_TO_16_BUFFER, std430) readonly buffer REPLICATE_BYTE_TO_16 {
127 uint REPLICATE_BYTE_TO_16_TABLE[];
128};
129 131
130const int BLOCK_SIZE_IN_BYTES = 16; 132const int BLOCK_SIZE_IN_BYTES = 16;
131 133
@@ -1275,8 +1277,7 @@ void main() {
1275 offset += (pos.x >> GOB_SIZE_X_SHIFT) << x_shift; 1277 offset += (pos.x >> GOB_SIZE_X_SHIFT) << x_shift;
1276 offset += swizzle; 1278 offset += swizzle;
1277 1279
1278 const ivec3 invocation_destination = ivec3(gl_GlobalInvocationID + destination); 1280 const ivec3 coord = ivec3(gl_GlobalInvocationID * uvec3(block_dims, 1.0));
1279 const ivec3 coord = ivec3(invocation_destination * uvec3(block_dims, 1.0));
1280 uint block_index = 1281 uint block_index =
1281 layer * num_image_blocks.x * num_image_blocks.y + pos.y * num_image_blocks.x + pos.x; 1282 layer * num_image_blocks.x * num_image_blocks.y + pos.y * num_image_blocks.x + pos.x;
1282 current_index = 0; 1283 current_index = 0;