[Mesa-dev] [PATCH 8/9] tgsi: Add code for handling lodq opcode
Brian Paul
brianp at vmware.com
Wed Sep 9 08:26:17 PDT 2015
On 09/09/2015 04:35 AM, Krzesimir Nowak wrote:
> This introduces new vfunc in tgsi_sampler just for this opcode. I
> decided against extending get_samples vfunc to return the mipmap level
> and LOD - the function's prototype is already too scary and doing the
> sampling for textureQueryLod would be a waste of time.
> ---
> src/gallium/auxiliary/tgsi/tgsi_exec.c | 44 ++++++++++++++++++++++++++++++++++
> src/gallium/auxiliary/tgsi/tgsi_exec.h | 10 ++++++++
> 2 files changed, 54 insertions(+)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
> index 9544623..054ad08 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
> @@ -2132,6 +2132,44 @@ exec_tex(struct tgsi_exec_machine *mach,
> }
> }
>
> +static void
> +exec_lodq(struct tgsi_exec_machine *mach,
> + const struct tgsi_full_instruction *inst)
> +{
> + uint unit;
> + int dim;
> + int i;
> + union tgsi_exec_channel coords[4];
> + const union tgsi_exec_channel *args[Elements(coords)];
> + union tgsi_exec_channel r[2];
> +
> + unit = fetch_sampler_unit(mach, inst, 1);
> + dim = tgsi_util_get_texture_coord_dim(inst->Texture.Texture, NULL);
> + assert(dim <= Elements(coords));
> + /* fetch coordinates */
> + for (i = 0; i < dim; i++) {
> + FETCH(&coords[i], 0, TGSI_CHAN_X + i);
> + args[i] = &coords[i];
> + }
> + for (i = dim; i < Elements(coords); i++) {
> + args[i] = &ZeroVec;
> + }
> + mach->Sampler->query_lod(mach->Sampler, unit, unit,
> + args[0]->f,
> + args[1]->f,
> + args[2]->f,
> + args[3]->f,
> + tgsi_sampler_lod_none,
> + r[0].f,
> + r[1].f);
> +
> + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) {
> + store_dest(mach, &r[0], &inst->Dst[0], inst, TGSI_CHAN_X, TGSI_EXEC_DATA_FLOAT);
> + }
> + if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) {
> + store_dest(mach, &r[1], &inst->Dst[0], inst, TGSI_CHAN_Y, TGSI_EXEC_DATA_FLOAT);
> + }
> +}
>
> static void
> exec_txd(struct tgsi_exec_machine *mach,
> @@ -4378,6 +4416,12 @@ exec_instruction(
> exec_tex(mach, inst, TEX_MODIFIER_GATHER, 2);
> break;
>
> + case TGSI_OPCODE_LODQ:
> + /* src[0] = texcoord */
> + /* src[1] = sampler unit */
> + exec_lodq(mach, inst);
> + break;
> +
> case TGSI_OPCODE_UP2H:
> assert (0);
> break;
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
> index 5d56aab..556e0af 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
> @@ -138,6 +138,16 @@ struct tgsi_sampler
> const int j[TGSI_QUAD_SIZE], const int k[TGSI_QUAD_SIZE],
> const int lod[TGSI_QUAD_SIZE], const int8_t offset[3],
> float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);
> + void (*query_lod)(struct tgsi_sampler *tgsi_sampler,
Can tgsi_sampler be const-qualified?
> + const unsigned sview_index,
> + const unsigned sampler_index,
> + const float s[TGSI_QUAD_SIZE],
> + const float t[TGSI_QUAD_SIZE],
> + const float p[TGSI_QUAD_SIZE],
> + const float c0[TGSI_QUAD_SIZE],
> + enum tgsi_sampler_control control,
> + float mipmap[TGSI_QUAD_SIZE],
> + float lod[TGSI_QUAD_SIZE]);
> };
>
> #define TGSI_EXEC_NUM_TEMPS 4096
>
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the mesa-dev
mailing list