diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-12-19 10:35:18 -0500 |
---|---|---|
committer | Tomeu Vizoso <[email protected]> | 2019-12-20 09:10:26 +0100 |
commit | ccbc9a4e6785babb832bf11499fe7538c2a30952 (patch) | |
tree | 16acc898c3d574ab2b1ed6b73d5b55f6a3328b35 /src/panfrost/midgard/midgard_ra.c | |
parent | 2eef9e050f6228d134aec07e2c7fadc9d0961049 (diff) |
pan/midgard: Implement textureOffset for 2D textures
Fixes dEQP-GLES3.functional.shaders.texture_functions.textureoffset.sampler2d_fixed_fragment.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Tomeu Vizoso <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3169>
Diffstat (limited to 'src/panfrost/midgard/midgard_ra.c')
-rw-r--r-- | src/panfrost/midgard/midgard_ra.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/panfrost/midgard/midgard_ra.c b/src/panfrost/midgard/midgard_ra.c index c5c77790e7c..80d3d5488ec 100644 --- a/src/panfrost/midgard/midgard_ra.c +++ b/src/panfrost/midgard/midgard_ra.c @@ -513,6 +513,7 @@ allocate_registers(compiler_context *ctx, bool *spilled) set_class(l->class, ins->src[0], REG_CLASS_TEXR); set_class(l->class, ins->src[1], REG_CLASS_TEXR); set_class(l->class, ins->src[2], REG_CLASS_TEXR); + set_class(l->class, ins->src[3], REG_CLASS_TEXR); } } @@ -544,6 +545,14 @@ allocate_registers(compiler_context *ctx, bool *spilled) return l; } +/* Reverses 2 bits, used to pack swizzles of offsets for some reason */ + +static unsigned +mir_reverse2(unsigned in) +{ + return (in >> 1) | ((in & 1) << 1); +} + /* Once registers have been decided via register allocation * (allocate_registers), we need to rewrite the MIR to use registers instead of * indices */ @@ -650,6 +659,7 @@ install_registers_instr( struct phys_reg dest = index_to_reg(ctx, l, ins->dest, mir_typesize(ins)); struct phys_reg coord = index_to_reg(ctx, l, ins->src[1], mir_srcsize(ins, 1)); struct phys_reg lod = index_to_reg(ctx, l, ins->src[2], mir_srcsize(ins, 2)); + struct phys_reg offset = index_to_reg(ctx, l, ins->src[3], mir_srcsize(ins, 2)); /* First, install the texture coordinate */ ins->texture.in_reg_full = 1; @@ -668,7 +678,7 @@ install_registers_instr( if (ins->src[2] != ~0) { assert(!(lod.offset & 3)); midgard_tex_register_select sel = { - .select = lod.reg, + .select = lod.reg & 1, .full = 1, .component = lod.offset / 4 }; @@ -678,6 +688,24 @@ install_registers_instr( ins->texture.bias = packed; } + /* If there is an offset register, install it */ + if (ins->src[3] != ~0) { + ins->texture.offset_x = + (1) | /* full */ + (offset.reg & 1) << 1 | /* select */ + 0 << 2; /* upper */ + + unsigned x = offset.offset / 4; + unsigned y = x + 1; + unsigned z = x + 2; + + ins->texture.offset_y = + mir_reverse2(y) | (mir_reverse2(x) << 2); + + ins->texture.offset_z = + mir_reverse2(z); + } + break; } |