summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/vc4_program.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_program.c')
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c50
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));
}