summaryrefslogtreecommitdiffstats
path: root/src/video_core/host_shaders
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/host_shaders')
-rw-r--r--src/video_core/host_shaders/astc_decoder.comp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp
index fd38dcfe5..5346cba0c 100644
--- a/src/video_core/host_shaders/astc_decoder.comp
+++ b/src/video_core/host_shaders/astc_decoder.comp
@@ -21,6 +21,8 @@
#endif
+#define bfe bitfieldExtract
+
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
BEGIN_PUSH_CONSTANTS
@@ -132,7 +134,7 @@ void ResultEmplaceBack(EncodingData val) {
return;
}
const uint array_index = result_index / 4;
- const uint vector_index = result_index % 4;
+ const uint vector_index = bfe(result_index, 0, 2);
result_vector[array_index][vector_index] = val.data;
++result_index;
}
@@ -384,7 +386,7 @@ uint StreamColorBits(uint num_bits) {
EncodingData GetEncodingFromVector(uint index) {
const uint array_index = index / 4;
- const uint vector_index = index % 4;
+ const uint vector_index = bfe(index, 0, 2);
const uint data = result_vector[array_index][vector_index];
return EncodingData(data);
@@ -393,7 +395,7 @@ EncodingData GetEncodingFromVector(uint index) {
// Returns the number of bits required to encode n_vals values.
uint GetBitLength(uint n_vals, uint encoding_index) {
const EncodingData encoding_value =
- EncodingData(encoding_values[encoding_index / 4][encoding_index % 4]);
+ EncodingData(encoding_values[encoding_index / 4][bfe(encoding_index, 0, 2)]);
const uint encoding = Encoding(encoding_value);
uint total_bits = NumBits(encoding_value) * n_vals;
if (encoding == TRIT) {
@@ -513,7 +515,7 @@ void DecodeTritBlock(uint num_bits) {
}
void DecodeIntegerSequence(uint max_range, uint num_values) {
- EncodingData val = EncodingData(encoding_values[max_range / 4][max_range % 4]);
+ EncodingData val = EncodingData(encoding_values[max_range / 4][bfe(max_range, 0, 2)]);
const uint encoding = Encoding(val);
const uint num_bits = NumBits(val);
uint vals_decoded = 0;
@@ -565,7 +567,7 @@ void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits) {
A = ReplicateBitTo9((bitval & 1));
switch (encoding) {
case JUST_BITS:
- color_values[out_index / 4][out_index % 4] = FastReplicateTo8(bitval, bitlen);
+ color_values[out_index / 4][bfe(out_index, 0, 2)] = FastReplicateTo8(bitval, bitlen);
++out_index;
break;
case TRIT: {
@@ -645,7 +647,7 @@ void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits) {
uint T = (D * C) + B;
T ^= A;
T = (A & 0x80) | (T >> 2);
- color_values[out_index / 4][out_index % 4] = T;
+ color_values[out_index / 4][bfe(out_index, 0, 2)] = T;
++out_index;
}
}
@@ -676,14 +678,14 @@ void ComputeEndpoints(out uvec4 ep1, out uvec4 ep2, uint color_endpoint_mode,
#define READ_UINT_VALUES(N) \
uint v[N]; \
for (uint i = 0; i < N; i++) { \
- v[i] = color_values[colvals_index / 4][colvals_index % 4]; \
+ v[i] = color_values[colvals_index / 4][bfe(colvals_index, 0, 2)]; \
++colvals_index; \
}
#define READ_INT_VALUES(N) \
int v[N]; \
for (uint i = 0; i < N; i++) { \
- v[i] = int(color_values[colvals_index / 4][colvals_index % 4]); \
+ v[i] = int(color_values[colvals_index / 4][bfe(colvals_index, 0, 2)]); \
++colvals_index; \
}
@@ -894,7 +896,7 @@ void UnquantizeTexelWeights(uvec2 size, bool is_dual_plane) {
const uint loop_count = min(result_index, area * num_planes);
for (uint itr = 0; itr < loop_count; ++itr) {
const uint array_index = itr / 4;
- const uint vector_index = itr % 4;
+ const uint vector_index = bfe(itr, 0, 2);
result_vector[array_index][vector_index] =
UnquantizeTexelWeight(GetEncodingFromVector(itr));
}
@@ -921,7 +923,7 @@ void UnquantizeTexelWeights(uvec2 size, bool is_dual_plane) {
#define VectorIndicesFromBase(offset_base) \
const uint offset = is_dual_plane ? 2 * offset_base + plane : offset_base; \
const uint array_index = offset / 4; \
- const uint vector_index = offset % 4;
+ const uint vector_index = bfe(offset, 0, 2);
if (v0 < area) {
const uint offset_base = v0;
@@ -945,7 +947,7 @@ void UnquantizeTexelWeights(uvec2 size, bool is_dual_plane) {
}
const uint offset = (t * block_dims.x + s) + ARRAY_NUM_ELEMENTS * plane;
const uint array_index = offset / 4;
- const uint vector_index = offset % 4;
+ const uint vector_index = bfe(offset, 0, 2);
unquantized_texel_weights[array_index][vector_index] = (uint(dot(p, w)) + 8) >> 4;
}
}
@@ -1249,13 +1251,13 @@ void DecompressBlock(ivec3 coord) {
const uvec4 C1 = ReplicateByteTo16(endpoints1[local_partition]);
const uint weight_offset = (j * block_dims.x + i);
const uint array_index = weight_offset / 4;
- const uint vector_index = weight_offset % 4;
+ const uint vector_index = bfe(weight_offset, 0, 2);
const uint primary_weight = unquantized_texel_weights[array_index][vector_index];
uvec4 weight_vec = uvec4(primary_weight);
if (params.dual_plane) {
const uint secondary_weight_offset = (j * block_dims.x + i) + ARRAY_NUM_ELEMENTS;
const uint secondary_array_index = secondary_weight_offset / 4;
- const uint secondary_vector_index = secondary_weight_offset % 4;
+ const uint secondary_vector_index = bfe(secondary_weight_offset, 0, 2);
const uint secondary_weight =
unquantized_texel_weights[secondary_array_index][secondary_vector_index];
for (uint c = 0; c < 4; c++) {