Skip to content

Commit

Permalink
hot-fix: detiler: forgotten lut optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
psucien committed Jan 1, 2025
1 parent 65cd3be commit d69341f
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/video_core/amdgpu/liverpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, u32 vqid) {
}
if (rasterizer && (cs_program.dispatch_initiator & 1)) {
const auto cmd_address = reinterpret_cast<const void*>(header);
rasterizer->ScopeMarkerBegin(fmt::format("acb[{}]:{}:Dispatch", vqid, cmd_address));
rasterizer->ScopeMarkerBegin(fmt::format("acb[{}]:{}:DispatchIndirect", vqid, cmd_address));
rasterizer->DispatchDirect();
rasterizer->ScopeMarkerEnd();
}
Expand Down
2 changes: 1 addition & 1 deletion src/video_core/host_shaders/detile_m32x1.comp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ layout(push_constant) uniform image_info {
} info;

// Inverse morton LUT, small enough to fit into K$
uint rmort[16] = {
const uint rmort[16] = {
0x11011000, 0x31213020,
0x13031202, 0x33233222,
0x51415040, 0x71617060,
Expand Down
2 changes: 1 addition & 1 deletion src/video_core/host_shaders/detile_m32x2.comp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ layout(push_constant) uniform image_info {
} info;

// Inverse morton LUT, small enough to fit into K$
uint rmort[16] = {
const uint rmort[16] = {
0x11011000, 0x31213020,
0x13031202, 0x33233222,
0x51415040, 0x71617060,
Expand Down
2 changes: 1 addition & 1 deletion src/video_core/host_shaders/detile_m32x4.comp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ layout(push_constant) uniform image_info {
} info;

// Inverse morton LUT, small enough to fit into K$
uint rmort[16] = {
const uint rmort[16] = {
0x11011000, 0x31213020,
0x13031202, 0x33233222,
0x51415040, 0x71617060,
Expand Down
2 changes: 1 addition & 1 deletion src/video_core/host_shaders/detile_m8x1.comp
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ void main() {
uint dw_ofs_x = target_tile_x * 2 + col; // 2 = uints
uint dw_ofs_y = (target_tile_y * MICRO_TILE_DIM + row) * tiles_per_pitch * 2; // 2 = uints
out_data[dw_ofs_x + dw_ofs_y] = dst_tx;
}
}
2 changes: 1 addition & 1 deletion src/video_core/host_shaders/detile_m8x2.comp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ layout(push_constant) uniform image_info {
#define TEXELS_PER_ELEMENT 2

// Inverse morton LUT, small enough to fit into K$
uint rmort[16] = {
const uint rmort[16] = {
0x11011000, 0x31213020,
0x13031202, 0x33233222,
0x51415040, 0x71617060,
Expand Down
70 changes: 36 additions & 34 deletions src/video_core/host_shaders/detile_macro32x1.comp
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,46 @@ layout(push_constant) uniform image_info {
} info;

// Each LUT is 64 bytes, so should fit into K$ given tiled slices locality
const uint lut_32bpp[][64] = {
const uint lut_32bpp[][16] = {
{
0x00, 0x01, 0x04, 0x05, 0x40, 0x41, 0x44, 0x45,
0x02, 0x03, 0x06, 0x07, 0x42, 0x43, 0x46, 0x47,
0x10, 0x11, 0x14, 0x15, 0x50, 0x51, 0x54, 0x55,
0x12, 0x13, 0x16, 0x17, 0x52, 0x53, 0x56, 0x57,
0x80, 0x81, 0x84, 0x85, 0xc0, 0xc1, 0xc4, 0xc5,
0x82, 0x83, 0x86, 0x87, 0xc2, 0xc3, 0xc6, 0xc7,
0x90, 0x91, 0x94, 0x95, 0xd0, 0xd1, 0xd4, 0xd5,
0x92, 0x93, 0x96, 0x97, 0xd2, 0xd3, 0xd6, 0xd7,
0x05040100, 0x45444140,
0x07060302, 0x47464342,
0x15141110, 0x55545150,
0x17161312, 0x57565352,
0x85848180, 0xc5c4c1c0,
0x87868382, 0xc7c6c3c2,
0x95949190, 0xd5d4d1d0,
0x97969392, 0xd7d6d3d2,
},
{
0x08, 0x09, 0x0c, 0x0d, 0x48, 0x49, 0x4c, 0x4d,
0x0a, 0x0b, 0x0e, 0x0f, 0x4a, 0x4b, 0x4e, 0x4f,
0x18, 0x19, 0x1c, 0x1d, 0x58, 0x59, 0x5c, 0x5d,
0x1a, 0x1b, 0x1e, 0x1f, 0x5a, 0x5b, 0x5e, 0x5f,
0x88, 0x89, 0x8c, 0x8d, 0xc8, 0xc9, 0xcc, 0xcd,
0x8a, 0x8b, 0x8e, 0x8f, 0xca, 0xcb, 0xce, 0xcf,
0x98, 0x99, 0x9c, 0x9d, 0xd8, 0xd9, 0xdc, 0xdd,
0x9a, 0x9b, 0x9e, 0x9f, 0xda, 0xdb, 0xde, 0xdf,
0x0d0c0908, 0x4d4c4948,
0x0f0e0b0a, 0x4f4e4b4a,
0x1d1c1918, 0x5d5c5958,
0x1f1e1b1a, 0x5f5e5b5a,
0x8d8c8988, 0xcdccc9c8,
0x8f8e8b8a, 0xcfcecbca,
0x9d9c9998, 0xdddcd9d8,
0x9f9e9b9a, 0xdfdedbda,
},
{
0x20, 0x21, 0x24, 0x25, 0x60, 0x61, 0x64, 0x65,
0x22, 0x23, 0x26, 0x27, 0x62, 0x63, 0x66, 0x67,
0x30, 0x31, 0x34, 0x35, 0x70, 0x71, 0x74, 0x75,
0x32, 0x33, 0x36, 0x37, 0x72, 0x73, 0x76, 0x77,
0xa0, 0xa1, 0xa4, 0xa5, 0xe0, 0xe1, 0xe4, 0xe5,
0xa2, 0xa3, 0xa6, 0xa7, 0xe2, 0xe3, 0xe6, 0xe7,
0xb0, 0xb1, 0xb4, 0xb5, 0xf0, 0xf1, 0xf4, 0xf5,
0xb2, 0xb3, 0xb6, 0xb7, 0xf2, 0xf3, 0xf6, 0xf7,
0x25242120, 0x65646160,
0x27262322, 0x67666362,
0x35343130, 0x75747170,
0x37363332, 0x77767372,
0xa5a4a1a0, 0xe5e4e1e0,
0xa7a6a3a2, 0xe7e6e3e2,
0xb5b4b1b0, 0xf5f4f1f0,
0xb7b6b3b2, 0xf7f6f3f2,
},
{
0x28, 0x29, 0x2c, 0x2d, 0x68, 0x69, 0x6c, 0x6d,
0x2a, 0x2b, 0x2e, 0x2f, 0x6a, 0x6b, 0x6e, 0x6f,
0x38, 0x39, 0x3c, 0x3d, 0x78, 0x79, 0x7c, 0x7d,
0x3a, 0x3b, 0x3e, 0x3f, 0x7a, 0x7b, 0x7e, 0x7f,
0xa8, 0xa9, 0xac, 0xad, 0xe8, 0xe9, 0xec, 0xed,
0xaa, 0xab, 0xae, 0xaf, 0xea, 0xeb, 0xee, 0xef,
0xb8, 0xb9, 0xbc, 0xbd, 0xf8, 0xf9, 0xfc, 0xfd,
0xba, 0xbb, 0xbe, 0xbf, 0xfa, 0xfb, 0xfe, 0xff,
0x2d2c2928, 0x6d6c6968,
0x2f2e2b2a, 0x6f6e6b6a,
0x3d3c3938, 0x7d7c7978,
0x3f3e3b3a, 0x7f7e7b7a,
0xadaca9a8, 0xedece9e8,
0xafaeabaa, 0xefeeebea,
0xbdbcb9b8, 0xfdfcf9f8,
0xbfbebbba, 0xfffefbfa,
}
};

Expand All @@ -77,7 +77,9 @@ void main() {
uint col = bitfieldExtract(x, 0, 3);
uint row = bitfieldExtract(y, 0, 3);
uint lut = bitfieldExtract(z, 0, 2);
uint idx = lut_32bpp[lut][col + row * MICRO_TILE_DIM];
uint idx_dw = lut_32bpp[lut][(col + row * MICRO_TILE_DIM) >> 2u];
uint byte_ofs = gl_LocalInvocationID.x & 3u;
uint idx = bitfieldExtract(idx_dw >> (8 * byte_ofs), 0, 8);

uint slice_offs = (z >> 2u) * info.c1 * MICRO_TILE_SZ;
uint tile_row = y / MICRO_TILE_DIM;
Expand Down
70 changes: 36 additions & 34 deletions src/video_core/host_shaders/detile_macro32x2.comp
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,46 @@ layout(push_constant) uniform image_info {
uint c1;
} info;

const uint lut_64bpp[][64] = {
const uint lut_64bpp[][16] = {
{
0x00, 0x01, 0x08, 0x09, 0x40, 0x41, 0x48, 0x49,
0x02, 0x03, 0x0a, 0x0b, 0x42, 0x43, 0x4a, 0x4b,
0x10, 0x11, 0x18, 0x19, 0x50, 0x51, 0x58, 0x59,
0x12, 0x13, 0x1a, 0x1b, 0x52, 0x53, 0x5a, 0x5b,
0x80, 0x81, 0x88, 0x89, 0xc0, 0xc1, 0xc8, 0xc9,
0x82, 0x83, 0x8a, 0x8b, 0xc2, 0xc3, 0xca, 0xcb,
0x90, 0x91, 0x98, 0x99, 0xd0, 0xd1, 0xd8, 0xd9,
0x92, 0x93, 0x9a, 0x9b, 0xd2, 0xd3, 0xda, 0xdb,
0x09080100, 0x49484140,
0x0b0a0302, 0x4a4b4342,
0x19181110, 0x59585150,
0x1b1a1312, 0x5a5b5352,
0x89888180, 0xc9c8c1c0,
0x8b8a8382, 0xcacbc3c2,
0x99989190, 0xd9d8d1d0,
0x9b9a9392, 0xdbdad3d2,
},
{
0x04, 0x05, 0x0c, 0x0d, 0x44, 0x45, 0x4c, 0x4d,
0x06, 0x07, 0x0e, 0x0f, 0x46, 0x47, 0x4e, 0x4f,
0x14, 0x15, 0x1c, 0x1d, 0x54, 0x55, 0x5c, 0x5d,
0x16, 0x17, 0x1e, 0x1f, 0x56, 0x57, 0x5e, 0x5f,
0x84, 0x85, 0x8c, 0x8d, 0xc4, 0xc5, 0xcc, 0xcd,
0x86, 0x87, 0x8e, 0x8f, 0xc6, 0xc7, 0xce, 0xcf,
0x94, 0x95, 0x9c, 0x9d, 0xd4, 0xd5, 0xdc, 0xdd,
0x96, 0x97, 0x9e, 0x9f, 0xd6, 0xd7, 0xde, 0xdf,
0x0d0c0504, 0x4d4c4544,
0x0f0e0706, 0x4f4e4746,
0x1d1c1514, 0x5d5c5554,
0x1f1e1716, 0x5f5e5756,
0x8d8c8584, 0xcdccc5c4,
0x8f8e8786, 0xcfcec7c6,
0x9d9c9594, 0xdddcd5d4,
0x9f9e9796, 0xdfded7d6,
},
{
0x20, 0x21, 0x28, 0x29, 0x60, 0x61, 0x68, 0x69,
0x22, 0x23, 0x2a, 0x2b, 0x62, 0x63, 0x6a, 0x6b,
0x30, 0x31, 0x38, 0x39, 0x70, 0x71, 0x78, 0x79,
0x32, 0x33, 0x3a, 0x3b, 0x72, 0x73, 0x7a, 0x7b,
0xa0, 0xa1, 0xa8, 0xa9, 0xe0, 0xe1, 0xe8, 0xe9,
0xa2, 0xa3, 0xaa, 0xab, 0xe2, 0xe3, 0xea, 0xeb,
0xb0, 0xb1, 0xb8, 0xb9, 0xf0, 0xf1, 0xf8, 0xf9,
0xb2, 0xb3, 0xba, 0xbb, 0xf2, 0xf3, 0xfa, 0xfb,
0x29282120, 0x69686160,
0x2b2a2322, 0x6b6a6362,
0x39383130, 0x79787170,
0x3b3a3332, 0x7b7a7372,
0xa9a8a1a0, 0xe9e8e1e0,
0xabaaa3a2, 0xebeae3e2,
0xb9b8b1b0, 0xf9f8f1f0,
0xbbbab3b2, 0xfbfaf3f2,
},
{
0x24, 0x25, 0x2c, 0x2d, 0x64, 0x65, 0x6c, 0x6d,
0x26, 0x27, 0x2e, 0x2f, 0x66, 0x67, 0x6e, 0x6f,
0x34, 0x35, 0x3c, 0x3d, 0x74, 0x75, 0x7c, 0x7d,
0x36, 0x37, 0x3e, 0x3f, 0x76, 0x77, 0x7e, 0x7f,
0xa4, 0xa5, 0xac, 0xad, 0xe4, 0xe5, 0xec, 0xed,
0xa6, 0xa7, 0xae, 0xaf, 0xe6, 0xe7, 0xee, 0xef,
0xb4, 0xb5, 0xbc, 0xbd, 0xf4, 0xf5, 0xfc, 0xfd,
0xb6, 0xb7, 0xbe, 0xbf, 0xf6, 0xf7, 0xfe, 0xff,
0x2d2c2524, 0x6d6c6564,
0x2f2e2726, 0x6f6e6766,
0x3d3c3534, 0x7d7c7574,
0x3f3e3736, 0x7f7e7776,
0xadaca5a4, 0xedece5e4,
0xafaea7a6, 0xefeee7e6,
0xbdbcb5b4, 0xfdfcf5f4,
0xbfbeb7b6, 0xfffef7f6,
},
};

Expand All @@ -76,7 +76,9 @@ void main() {
uint col = bitfieldExtract(x, 0, 3);
uint row = bitfieldExtract(y, 0, 3);
uint lut = bitfieldExtract(z, 0, 2);
uint idx = lut_64bpp[lut][col + row * MICRO_TILE_DIM];
uint idx_dw = lut_64bpp[lut][(col + row * MICRO_TILE_DIM) >> 2u];
uint byte_ofs = gl_LocalInvocationID.x & 3u;
uint idx = bitfieldExtract(idx_dw >> (8 * byte_ofs), 0, 8);

uint slice_offs = (z >> 2u) * info.c1 * MICRO_TILE_SZ;
uint tile_row = y / MICRO_TILE_DIM;
Expand Down

0 comments on commit d69341f

Please sign in to comment.