X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=rans.shader;h=47d0c8b7f9ad2a5c4cbac0ee959b0efd7adbe5ca;hb=HEAD;hp=3e19c83eae83e4f31f6c0c47bd4f0bc4263a7cc5;hpb=dc5d2b35a4efc8d14b55387bf2af022a95775060;p=narabu diff --git a/rans.shader b/rans.shader index 3e19c83..47d0c8b 100644 --- a/rans.shader +++ b/rans.shader @@ -9,6 +9,7 @@ const uint BLOCKS_PER_STREAM = 320; const uint STREAM_BUF_SIZE = 256; // In uint32s. 1 kB per stream ought to be enough for everyone :-) const uint NUM_SYMS = 256; const uint ESCAPE_LIMIT = NUM_SYMS - 1; +const uint WIDTH_BLOCKS = 160; // TODO: send in as a uniform. #define MAPPING(s0, s1, s2, s3, s4, s5, s6, s7) ((s0) | (s1 << 2) | (s2 << 4) | (s3 << 6) | (s4 << 8) | (s5 << 10) | (s6 << 12) | (s7 << 14)) @@ -167,8 +168,8 @@ void encode_9_7(uint streamgroup_num, uint coeff_row, layout(r16ui) restrict rea for (uint subblock_idx = 0; subblock_idx < BLOCKS_PER_STREAM; ++subblock_idx) { // TODO: Use SSBOs instead of a texture? - uint x = (streamgroup_num * BLOCKS_PER_STREAM + subblock_idx) % 160; - uint y = (streamgroup_num * BLOCKS_PER_STREAM + subblock_idx) / 160; + uint x = (streamgroup_num * BLOCKS_PER_STREAM + subblock_idx) % WIDTH_BLOCKS; + uint y = (streamgroup_num * BLOCKS_PER_STREAM + subblock_idx) / WIDTH_BLOCKS; uint f = imageLoad(tex, ivec2(x, y * 8 + coeff_row)).x; encode_coeff(sign_extend(f & 0x1ffu, 9), enc1); @@ -186,8 +187,8 @@ void encode_8(uint streamgroup_num, uint coeff_row, layout(r8i) restrict readonl for (uint subblock_idx = 0; subblock_idx < BLOCKS_PER_STREAM; ++subblock_idx) { // TODO: Use SSBOs instead of a texture? - uint x = (streamgroup_num * BLOCKS_PER_STREAM + subblock_idx) % 160; - uint y = (streamgroup_num * BLOCKS_PER_STREAM + subblock_idx) / 160; + uint x = (streamgroup_num * BLOCKS_PER_STREAM + subblock_idx) % WIDTH_BLOCKS; + uint y = (streamgroup_num * BLOCKS_PER_STREAM + subblock_idx) / WIDTH_BLOCKS; int f = imageLoad(tex, ivec2(x, y * 8 + coeff_row)).x; encode_coeff(f, enc);