1
0
Fork 0
forked from suyu/suyu

flatten result vector

This commit is contained in:
Ameer J 2023-08-09 18:34:57 -04:00
parent 70f8ffb787
commit 71857e889e

View file

@ -77,7 +77,7 @@ int color_bitsread = 0;
#define DIVCEIL(number, divisor) (number + divisor - 1) / divisor #define DIVCEIL(number, divisor) (number + divisor - 1) / divisor
#define ARRAY_NUM_ELEMENTS 144 #define ARRAY_NUM_ELEMENTS 144
#define VECTOR_ARRAY_SIZE DIVCEIL(ARRAY_NUM_ELEMENTS * 2, 4) #define VECTOR_ARRAY_SIZE DIVCEIL(ARRAY_NUM_ELEMENTS * 2, 4)
uvec4 result_vector[VECTOR_ARRAY_SIZE]; uint result_vector[ARRAY_NUM_ELEMENTS * 2];
int result_index = 0; int result_index = 0;
uint result_vector_max_index; uint result_vector_max_index;
@ -122,9 +122,7 @@ void ResultEmplaceBack(EncodingData val) {
result_limit_reached = true; result_limit_reached = true;
return; return;
} }
const uint array_index = result_index / 4; result_vector[result_index] = val.data;
const uint vector_index = result_index % 4;
result_vector[array_index][vector_index] = val.data;
++result_index; ++result_index;
} }
@ -309,10 +307,7 @@ uint StreamColorBits(uint num_bits) {
} }
EncodingData GetEncodingFromVector(uint index) { EncodingData GetEncodingFromVector(uint index) {
const uint array_index = index / 4; const uint data = result_vector[index];
const uint vector_index = index % 4;
const uint data = result_vector[array_index][vector_index];
return EncodingData(data); return EncodingData(data);
} }
@ -809,18 +804,14 @@ void UnquantizeTexelWeights(uvec2 size, bool is_dual_plane) {
const uint area = size.x * size.y; const uint area = size.x * size.y;
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; result_vector[itr] =
const uint vector_index = itr % 4;
result_vector[array_index][vector_index] =
UnquantizeTexelWeight(GetEncodingFromVector(itr)); UnquantizeTexelWeight(GetEncodingFromVector(itr));
} }
} }
uint GetUnquantizedTexelWieght(uint offset_base, uint plane, bool is_dual_plane) { uint GetUnquantizedTexelWieght(uint offset_base, uint plane, bool is_dual_plane) {
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; return result_vector[offset];
const uint vector_index = offset % 4;
return result_vector[array_index][vector_index];
} }
uvec4 GetUnquantizedWeightVector(uint t, uint s, uvec2 size, uint plane_index, bool is_dual_plane) { uvec4 GetUnquantizedWeightVector(uint t, uint s, uvec2 size, uint plane_index, bool is_dual_plane) {