yuzu-emu
/
yuzu
Archived
1
0
Fork 0

error/void extent funcs

This commit is contained in:
Ameer J 2023-08-01 23:33:47 -04:00
parent 441b847107
commit 75ac7845ce
1 changed files with 43 additions and 48 deletions

View File

@ -40,9 +40,6 @@ struct TexelWeightParams {
uvec2 size; uvec2 size;
uint max_weight; uint max_weight;
bool dual_plane; bool dual_plane;
bool error_state;
bool void_extent_ldr;
bool void_extent_hdr;
}; };
layout(binding = BINDING_INPUT_BUFFER, std430) readonly restrict buffer InputBufferU32 { layout(binding = BINDING_INPUT_BUFFER, std430) readonly restrict buffer InputBufferU32 {
@ -983,28 +980,54 @@ int FindLayout(uint mode) {
return 5; return 5;
} }
TexelWeightParams DecodeBlockInfo() {
TexelWeightParams params = TexelWeightParams(uvec2(0), 0, false, false, false, false); void FillError(ivec3 coord) {
uint mode = StreamBits(11); for (uint j = 0; j < block_dims.y; j++) {
for (uint i = 0; i < block_dims.x; i++) {
imageStore(dest_image, coord + ivec3(i, j, 0), vec4(0.0, 0.0, 0.0, 0.0));
}
}
}
void FillVoidExtentLDR(ivec3 coord) {
SkipBits(52);
const uint r_u = StreamBits(16);
const uint g_u = StreamBits(16);
const uint b_u = StreamBits(16);
const uint a_u = StreamBits(16);
const float a = float(a_u) / 65535.0f;
const float r = float(r_u) / 65535.0f;
const float g = float(g_u) / 65535.0f;
const float b = float(b_u) / 65535.0f;
for (uint j = 0; j < block_dims.y; j++) {
for (uint i = 0; i < block_dims.x; i++) {
imageStore(dest_image, coord + ivec3(i, j, 0), vec4(r, g, b, a));
}
}
}
bool IsError(uint mode) {
if ((mode & 0x1ff) == 0x1fc) { if ((mode & 0x1ff) == 0x1fc) {
if ((mode & 0x200) != 0) { if ((mode & 0x200) != 0) {
params.void_extent_hdr = true; // params.void_extent_hdr = true;
} else { return true;
params.void_extent_ldr = true;
} }
if ((mode & 0x400) == 0 || StreamBits(1) == 0) { if ((mode & 0x400) == 0 || StreamBits(1) == 0) {
params.error_state = true; return true;
} }
return params; return false;
} }
if ((mode & 0xf) == 0) { if ((mode & 0xf) == 0) {
params.error_state = true; return true;
return params;
} }
if ((mode & 3) == 0 && (mode & 0x1c0) == 0x1c0) { if ((mode & 3) == 0 && (mode & 0x1c0) == 0x1c0) {
params.error_state = true; return true;
return params;
} }
return false;
}
TexelWeightParams DecodeBlockInfo(uint mode) {
TexelWeightParams params = TexelWeightParams(uvec2(0), 0, false);
uint A, B; uint A, B;
uint mode_layout = FindLayout(mode); uint mode_layout = FindLayout(mode);
switch (mode_layout) { switch (mode_layout) {
@ -1053,7 +1076,6 @@ TexelWeightParams DecodeBlockInfo() {
params.size = uvec2(A + 6, B + 6); params.size = uvec2(A + 6, B + 6);
break; break;
default: default:
params.error_state = true;
break; break;
} }
params.dual_plane = (mode_layout != 9) && ((mode & 0x400) != 0); params.dual_plane = (mode_layout != 9) && ((mode & 0x400) != 0);
@ -1072,42 +1094,15 @@ TexelWeightParams DecodeBlockInfo() {
return params; return params;
} }
void FillError(ivec3 coord) {
for (uint j = 0; j < block_dims.y; j++) {
for (uint i = 0; i < block_dims.x; i++) {
imageStore(dest_image, coord + ivec3(i, j, 0), vec4(0.0, 0.0, 0.0, 0.0));
}
}
}
void FillVoidExtentLDR(ivec3 coord) {
SkipBits(52);
const uint r_u = StreamBits(16);
const uint g_u = StreamBits(16);
const uint b_u = StreamBits(16);
const uint a_u = StreamBits(16);
const float a = float(a_u) / 65535.0f;
const float r = float(r_u) / 65535.0f;
const float g = float(g_u) / 65535.0f;
const float b = float(b_u) / 65535.0f;
for (uint j = 0; j < block_dims.y; j++) {
for (uint i = 0; i < block_dims.x; i++) {
imageStore(dest_image, coord + ivec3(i, j, 0), vec4(r, g, b, a));
}
}
}
void DecompressBlock(ivec3 coord) { void DecompressBlock(ivec3 coord) {
const TexelWeightParams params = DecodeBlockInfo(); uint mode = StreamBits(11);
if (params.error_state) { const TexelWeightParams params = DecodeBlockInfo(mode);
if (IsError(mode)) {
FillError(coord); FillError(coord);
return; return;
} }
if (params.void_extent_hdr) { if ((mode & 0x1ff) == 0x1fc) {
FillError(coord); // params.void_extent_ldr = true;
return;
}
if (params.void_extent_ldr) {
FillVoidExtentLDR(coord); FillVoidExtentLDR(coord);
return; return;
} }