bfe instead of mod
This commit is contained in:
parent
6b0b584eba
commit
5c16559694
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define bfe bitfieldExtract
|
||||||
|
|
||||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||||
|
|
||||||
BEGIN_PUSH_CONSTANTS
|
BEGIN_PUSH_CONSTANTS
|
||||||
|
@ -132,7 +134,7 @@ void ResultEmplaceBack(EncodingData val) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const uint array_index = result_index / 4;
|
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_vector[array_index][vector_index] = val.data;
|
||||||
++result_index;
|
++result_index;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +386,7 @@ uint StreamColorBits(uint num_bits) {
|
||||||
|
|
||||||
EncodingData GetEncodingFromVector(uint index) {
|
EncodingData GetEncodingFromVector(uint index) {
|
||||||
const uint array_index = index / 4;
|
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];
|
const uint data = result_vector[array_index][vector_index];
|
||||||
return EncodingData(data);
|
return EncodingData(data);
|
||||||
|
@ -393,7 +395,7 @@ EncodingData GetEncodingFromVector(uint index) {
|
||||||
// Returns the number of bits required to encode n_vals values.
|
// Returns the number of bits required to encode n_vals values.
|
||||||
uint GetBitLength(uint n_vals, uint encoding_index) {
|
uint GetBitLength(uint n_vals, uint encoding_index) {
|
||||||
const EncodingData encoding_value =
|
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);
|
const uint encoding = Encoding(encoding_value);
|
||||||
uint total_bits = NumBits(encoding_value) * n_vals;
|
uint total_bits = NumBits(encoding_value) * n_vals;
|
||||||
if (encoding == TRIT) {
|
if (encoding == TRIT) {
|
||||||
|
@ -513,7 +515,7 @@ void DecodeTritBlock(uint num_bits) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecodeIntegerSequence(uint max_range, uint num_values) {
|
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 encoding = Encoding(val);
|
||||||
const uint num_bits = NumBits(val);
|
const uint num_bits = NumBits(val);
|
||||||
uint vals_decoded = 0;
|
uint vals_decoded = 0;
|
||||||
|
@ -565,7 +567,7 @@ void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits) {
|
||||||
A = ReplicateBitTo9((bitval & 1));
|
A = ReplicateBitTo9((bitval & 1));
|
||||||
switch (encoding) {
|
switch (encoding) {
|
||||||
case JUST_BITS:
|
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;
|
++out_index;
|
||||||
break;
|
break;
|
||||||
case TRIT: {
|
case TRIT: {
|
||||||
|
@ -645,7 +647,7 @@ void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits) {
|
||||||
uint T = (D * C) + B;
|
uint T = (D * C) + B;
|
||||||
T ^= A;
|
T ^= A;
|
||||||
T = (A & 0x80) | (T >> 2);
|
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;
|
++out_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -676,14 +678,14 @@ void ComputeEndpoints(out uvec4 ep1, out uvec4 ep2, uint color_endpoint_mode,
|
||||||
#define READ_UINT_VALUES(N) \
|
#define READ_UINT_VALUES(N) \
|
||||||
uint v[N]; \
|
uint v[N]; \
|
||||||
for (uint i = 0; i < N; i++) { \
|
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; \
|
++colvals_index; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ_INT_VALUES(N) \
|
#define READ_INT_VALUES(N) \
|
||||||
int v[N]; \
|
int v[N]; \
|
||||||
for (uint i = 0; i < N; i++) { \
|
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; \
|
++colvals_index; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,7 +896,7 @@ void UnquantizeTexelWeights(uvec2 size, bool is_dual_plane) {
|
||||||
const uint loop_count = min(result_index, area * num_planes);
|
const uint loop_count = min(result_index, area * num_planes);
|
||||||
for (uint itr = 0; itr < loop_count; ++itr) {
|
for (uint itr = 0; itr < loop_count; ++itr) {
|
||||||
const uint array_index = itr / 4;
|
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] =
|
result_vector[array_index][vector_index] =
|
||||||
UnquantizeTexelWeight(GetEncodingFromVector(itr));
|
UnquantizeTexelWeight(GetEncodingFromVector(itr));
|
||||||
}
|
}
|
||||||
|
@ -921,7 +923,7 @@ void UnquantizeTexelWeights(uvec2 size, bool is_dual_plane) {
|
||||||
#define VectorIndicesFromBase(offset_base) \
|
#define VectorIndicesFromBase(offset_base) \
|
||||||
const uint offset = is_dual_plane ? 2 * offset_base + plane : offset_base; \
|
const uint offset = is_dual_plane ? 2 * offset_base + plane : offset_base; \
|
||||||
const uint array_index = offset / 4; \
|
const uint array_index = offset / 4; \
|
||||||
const uint vector_index = offset % 4;
|
const uint vector_index = bfe(offset, 0, 2);
|
||||||
|
|
||||||
if (v0 < area) {
|
if (v0 < area) {
|
||||||
const uint offset_base = v0;
|
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 offset = (t * block_dims.x + s) + ARRAY_NUM_ELEMENTS * plane;
|
||||||
const uint array_index = offset / 4;
|
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;
|
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 uvec4 C1 = ReplicateByteTo16(endpoints1[local_partition]);
|
||||||
const uint weight_offset = (j * block_dims.x + i);
|
const uint weight_offset = (j * block_dims.x + i);
|
||||||
const uint array_index = weight_offset / 4;
|
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];
|
const uint primary_weight = unquantized_texel_weights[array_index][vector_index];
|
||||||
uvec4 weight_vec = uvec4(primary_weight);
|
uvec4 weight_vec = uvec4(primary_weight);
|
||||||
if (params.dual_plane) {
|
if (params.dual_plane) {
|
||||||
const uint secondary_weight_offset = (j * block_dims.x + i) + ARRAY_NUM_ELEMENTS;
|
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_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 =
|
const uint secondary_weight =
|
||||||
unquantized_texel_weights[secondary_array_index][secondary_vector_index];
|
unquantized_texel_weights[secondary_array_index][secondary_vector_index];
|
||||||
for (uint c = 0; c < 4; c++) {
|
for (uint c = 0; c < 4; c++) {
|
||||||
|
|
Loading…
Reference in New Issue