diff options
author | Eric Anholt <[email protected]> | 2014-10-01 17:32:50 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-10-09 21:47:06 +0200 |
commit | 5c72d7706c55d2832b816af4192afa010de51636 (patch) | |
tree | e9c0a9e26c4dd1ba2910de6fdf64f28db99171cf /src/gallium/drivers/vc4/vc4_program.c | |
parent | 5cfab07639c650e4e9bae063c72e08a27a5e209d (diff) |
vc4: Add #defines for the texture uniform fields.
I wanted to make another set of texture uploads for handling reladdr
constants, and duplicating all the bitshifting looked like a terrible
idea. In the process, this fixes a swap of the s/t texture wrap modes.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_program.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index ec66dae7861..3995eccf54a 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -1997,12 +1997,12 @@ write_texture_p0(struct vc4_context *vc4, struct pipe_sampler_view *texture = texstate->textures[unit]; struct vc4_resource *rsc = vc4_resource(texture->texture); - bool is_cube = texture->target == PIPE_TEXTURE_CUBE; - cl_reloc(vc4, &vc4->uniforms, rsc->bo, - rsc->slices[0].offset | texture->u.tex.last_level | - is_cube << 9 | - ((rsc->vc4_format & 7) << 4)); + VC4_SET_FIELD(rsc->slices[0].offset >> 12, VC4_TEX_P0_OFFSET) | + VC4_SET_FIELD(texture->u.tex.last_level, VC4_TEX_P0_MIPLVLS) | + VC4_SET_FIELD(texture->target == PIPE_TEXTURE_CUBE, + VC4_TEX_P0_CMMODE) | + VC4_SET_FIELD(rsc->vc4_format & 7, VC4_TEX_P0_TYPE)); } static void @@ -2014,13 +2014,16 @@ write_texture_p1(struct vc4_context *vc4, struct vc4_resource *rsc = vc4_resource(texture->texture); struct pipe_sampler_state *sampler = texstate->samplers[unit]; static const uint8_t minfilter_map[6] = { - 2, 4, /* mipfilter nearest */ - 3, 5, /* mipfilter linear */ - 1, 0, /* mipfilter none */ + VC4_TEX_P1_MINFILT_NEAR_MIP_NEAR, + VC4_TEX_P1_MINFILT_LIN_MIP_NEAR, + VC4_TEX_P1_MINFILT_NEAR_MIP_LIN, + VC4_TEX_P1_MINFILT_LIN_MIP_LIN, + VC4_TEX_P1_MINFILT_NEAREST, + VC4_TEX_P1_MINFILT_LINEAR, }; static const uint32_t magfilter_map[] = { - [PIPE_TEX_FILTER_NEAREST] = 1, - [PIPE_TEX_FILTER_LINEAR] = 0, + [PIPE_TEX_FILTER_NEAREST] = VC4_TEX_P1_MAGFILT_NEAREST, + [PIPE_TEX_FILTER_LINEAR] = VC4_TEX_P1_MAGFILT_LINEAR, }; bool either_nearest = @@ -2028,14 +2031,20 @@ write_texture_p1(struct vc4_context *vc4, sampler->min_img_filter == PIPE_TEX_MIPFILTER_NEAREST); cl_u32(&vc4->uniforms, - ((rsc->vc4_format >> 4) << 31) | - (texture->texture->height0 << 20) | - (texture->texture->width0 << 8) | - (magfilter_map[sampler->mag_img_filter] << 7) | - (minfilter_map[sampler->min_mip_filter * 2 + - sampler->min_img_filter] << 4) | - (translate_wrap(sampler->wrap_t, either_nearest) << 2) | - (translate_wrap(sampler->wrap_s, either_nearest) << 0)); + VC4_SET_FIELD(rsc->vc4_format >> 4, VC4_TEX_P1_TYPE4) | + VC4_SET_FIELD(texture->texture->height0 & 2047, + VC4_TEX_P1_HEIGHT) | + VC4_SET_FIELD(texture->texture->width0 & 2047, + VC4_TEX_P1_WIDTH) | + VC4_SET_FIELD(magfilter_map[sampler->mag_img_filter], + VC4_TEX_P1_MAGFILT) | + VC4_SET_FIELD(minfilter_map[sampler->min_mip_filter * 2 + + sampler->min_img_filter], + VC4_TEX_P1_MINFILT) | + VC4_SET_FIELD(translate_wrap(sampler->wrap_s, either_nearest), + VC4_TEX_P1_WRAP_S) | + VC4_SET_FIELD(translate_wrap(sampler->wrap_t, either_nearest), + VC4_TEX_P1_WRAP_T)); } static void @@ -2046,7 +2055,10 @@ write_texture_p2(struct vc4_context *vc4, struct pipe_sampler_view *texture = texstate->textures[unit]; struct vc4_resource *rsc = vc4_resource(texture->texture); - cl_u32(&vc4->uniforms, (1 << 30) | rsc->cube_map_stride); + cl_u32(&vc4->uniforms, + VC4_SET_FIELD(VC4_TEX_P2_PTYPE_CUBE_MAP_STRIDE, + VC4_TEX_P2_PTYPE) | + VC4_SET_FIELD(rsc->cube_map_stride >> 12, VC4_TEX_P2_CMST)); } |