diff options
author | Rob Clark <[email protected]> | 2019-04-28 09:23:29 -0700 |
---|---|---|
committer | Rob Clark <[email protected]> | 2019-04-29 17:01:01 -0700 |
commit | 8506ebfb951f88654a1ffda7d2c24a8004ca50b9 (patch) | |
tree | 20c5fc541e7c8ed26b6af7449a6e5f41f91fa994 /src/gallium/drivers | |
parent | da327afb2a4a9b8e1c047ff12aebbd75d71b1b64 (diff) |
freedreno/a6xx: small texture emit cleanup
Prep work for fb_read (blend_equation_advanced)
Switch to using 'enum pipe_shader_type' everywhere, and (optional, in
non-cache / slowpath case) pass ctx instead of image/ssbo state. In the
fb_read case we also need to access the framebuffer state, so having
the ctx simplifies things.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/freedreno/a6xx/fd6_emit.c | 52 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a6xx/fd6_emit.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a6xx/fd6_texture.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/freedreno/a6xx/fd6_texture.h | 6 |
4 files changed, 34 insertions, 37 deletions
diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c index 7b8184d2993..f0aa854888c 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c @@ -342,29 +342,32 @@ emit_border_color(struct fd_context *ctx, struct fd_ringbuffer *ring) bool fd6_emit_textures(struct fd_pipe *pipe, struct fd_ringbuffer *ring, - enum a6xx_state_block sb, struct fd_texture_stateobj *tex, + enum pipe_shader_type type, struct fd_texture_stateobj *tex, unsigned bcolor_offset, /* can be NULL if no image/SSBO state to merge in: */ - const struct ir3_shader_variant *v, struct fd_shaderbuf_stateobj *buf, - struct fd_shaderimg_stateobj *img) + const struct ir3_shader_variant *v, struct fd_context *ctx) { bool needs_border = false; unsigned opcode, tex_samp_reg, tex_const_reg, tex_count_reg; + enum a6xx_state_block sb; - switch (sb) { - case SB6_VS_TEX: + switch (type) { + case PIPE_SHADER_VERTEX: + sb = SB6_VS_TEX; opcode = CP_LOAD_STATE6_GEOM; tex_samp_reg = REG_A6XX_SP_VS_TEX_SAMP_LO; tex_const_reg = REG_A6XX_SP_VS_TEX_CONST_LO; tex_count_reg = REG_A6XX_SP_VS_TEX_COUNT; break; - case SB6_FS_TEX: + case PIPE_SHADER_FRAGMENT: + sb = SB6_FS_TEX; opcode = CP_LOAD_STATE6_FRAG; tex_samp_reg = REG_A6XX_SP_FS_TEX_SAMP_LO; tex_const_reg = REG_A6XX_SP_FS_TEX_CONST_LO; tex_count_reg = REG_A6XX_SP_FS_TEX_COUNT; break; - case SB6_CS_TEX: + case PIPE_SHADER_COMPUTE: + sb = SB6_CS_TEX; opcode = CP_LOAD_STATE6_FRAG; tex_samp_reg = REG_A6XX_SP_CS_TEX_SAMP_LO; tex_const_reg = REG_A6XX_SP_CS_TEX_CONST_LO; @@ -467,6 +470,8 @@ fd6_emit_textures(struct fd_pipe *pipe, struct fd_ringbuffer *ring, if (v) { const struct ir3_ibo_mapping *mapping = &v->image_mapping; + struct fd_shaderbuf_stateobj *buf = &ctx->shaderbuf[type]; + struct fd_shaderimg_stateobj *img = &ctx->shaderimg[type]; for (unsigned i = 0; i < mapping->num_tex; i++) { unsigned idx = mapping->tex_to_image[i]; @@ -518,15 +523,12 @@ fd6_emit_combined_textures(struct fd_ringbuffer *ring, struct fd6_emit *emit, struct fd_context *ctx = emit->ctx; bool needs_border = false; - static const struct { - enum a6xx_state_block sb; - enum fd6_state_id state_id; - } s[PIPE_SHADER_TYPES] = { - [PIPE_SHADER_VERTEX] = { SB6_VS_TEX, FD6_GROUP_VS_TEX }, - [PIPE_SHADER_FRAGMENT] = { SB6_FS_TEX, FD6_GROUP_FS_TEX }, + static const enum fd6_state_id state_id[PIPE_SHADER_TYPES] = { + [PIPE_SHADER_VERTEX] = FD6_GROUP_VS_TEX, + [PIPE_SHADER_FRAGMENT] = FD6_GROUP_FS_TEX, }; - debug_assert(s[type].state_id); + debug_assert(state_id[type]); if (!v->image_mapping.num_tex) { /* in the fast-path, when we don't have to mix in any image/SSBO @@ -536,11 +538,11 @@ fd6_emit_combined_textures(struct fd_ringbuffer *ring, struct fd6_emit *emit, if ((ctx->dirty_shader[type] & FD_DIRTY_SHADER_TEX) && ctx->tex[type].num_textures > 0) { struct fd6_texture_state *tex = fd6_texture_state(ctx, - s[type].sb, &ctx->tex[type]); + type, &ctx->tex[type]); needs_border |= tex->needs_border; - fd6_emit_add_group(emit, tex->stateobj, s[type].state_id, 0x7); + fd6_emit_add_group(emit, tex->stateobj, state_id[type], 0x7); } } else { /* In the slow-path, create a one-shot texture state object @@ -550,18 +552,16 @@ fd6_emit_combined_textures(struct fd_ringbuffer *ring, struct fd6_emit *emit, (FD_DIRTY_SHADER_TEX | FD_DIRTY_SHADER_PROG | FD_DIRTY_SHADER_IMAGE | FD_DIRTY_SHADER_SSBO)) { struct fd_texture_stateobj *tex = &ctx->tex[type]; - struct fd_shaderbuf_stateobj *buf = &ctx->shaderbuf[type]; - struct fd_shaderimg_stateobj *img = &ctx->shaderimg[type]; struct fd_ringbuffer *stateobj = fd_submit_new_ringbuffer(ctx->batch->submit, 0x1000, FD_RINGBUFFER_STREAMING); unsigned bcolor_offset = - fd6_border_color_offset(ctx, s[type].sb, tex); + fd6_border_color_offset(ctx, type, tex); - needs_border |= fd6_emit_textures(ctx->pipe, stateobj, s[type].sb, tex, - bcolor_offset, v, buf, img); + needs_border |= fd6_emit_textures(ctx->pipe, stateobj, type, tex, + bcolor_offset, v, ctx); - fd6_emit_add_group(emit, stateobj, s[type].state_id, 0x7); + fd6_emit_add_group(emit, stateobj, state_id[type], 0x7); fd_ringbuffer_del(stateobj); } @@ -1024,12 +1024,10 @@ fd6_emit_cs_state(struct fd_context *ctx, struct fd_ringbuffer *ring, if (dirty & (FD_DIRTY_SHADER_TEX | FD_DIRTY_SHADER_PROG | FD_DIRTY_SHADER_IMAGE | FD_DIRTY_SHADER_SSBO)) { struct fd_texture_stateobj *tex = &ctx->tex[PIPE_SHADER_COMPUTE]; - struct fd_shaderbuf_stateobj *buf = &ctx->shaderbuf[PIPE_SHADER_COMPUTE]; - struct fd_shaderimg_stateobj *img = &ctx->shaderimg[PIPE_SHADER_COMPUTE]; - unsigned bcolor_offset = fd6_border_color_offset(ctx, SB6_CS_TEX, tex); + unsigned bcolor_offset = fd6_border_color_offset(ctx, PIPE_SHADER_COMPUTE, tex); - bool needs_border = fd6_emit_textures(ctx->pipe, ring, SB6_CS_TEX, tex, - bcolor_offset, cp, buf, img); + bool needs_border = fd6_emit_textures(ctx->pipe, ring, PIPE_SHADER_COMPUTE, tex, + bcolor_offset, cp, ctx); if (needs_border) emit_border_color(ctx, ring); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_emit.h b/src/gallium/drivers/freedreno/a6xx/fd6_emit.h index 6c02bd9459c..1780ae0bda9 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_emit.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_emit.h @@ -201,10 +201,9 @@ fd6_stage2shadersb(gl_shader_stage type) } bool fd6_emit_textures(struct fd_pipe *pipe, struct fd_ringbuffer *ring, - enum a6xx_state_block sb, struct fd_texture_stateobj *tex, + enum pipe_shader_type type, struct fd_texture_stateobj *tex, unsigned bcolor_offset, - const struct ir3_shader_variant *v, struct fd_shaderbuf_stateobj *buf, - struct fd_shaderimg_stateobj *img); + const struct ir3_shader_variant *v, struct fd_context *ctx); void fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index f5f747cd14c..54f49861e06 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -360,7 +360,7 @@ key_equals(const void *_a, const void *_b) } struct fd6_texture_state * -fd6_texture_state(struct fd_context *ctx, enum a6xx_state_block sb, +fd6_texture_state(struct fd_context *ctx, enum pipe_shader_type type, struct fd_texture_stateobj *tex) { struct fd6_context *fd6_ctx = fd6_context(ctx); @@ -392,7 +392,7 @@ fd6_texture_state(struct fd_context *ctx, enum a6xx_state_block sb, needs_border |= sampler->needs_border; } - key.bcolor_offset = fd6_border_color_offset(ctx, sb, tex); + key.bcolor_offset = fd6_border_color_offset(ctx, type, tex); uint32_t hash = key_hash(&key); struct hash_entry *entry = @@ -408,8 +408,8 @@ fd6_texture_state(struct fd_context *ctx, enum a6xx_state_block sb, state->stateobj = fd_ringbuffer_new_object(ctx->pipe, 0x1000); state->needs_border = needs_border; - fd6_emit_textures(ctx->pipe, state->stateobj, sb, tex, key.bcolor_offset, - NULL, NULL, NULL); + fd6_emit_textures(ctx->pipe, state->stateobj, type, tex, key.bcolor_offset, + NULL, NULL); /* NOTE: uses copy of key in state obj, because pointer passed by caller * is probably on the stack diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.h b/src/gallium/drivers/freedreno/a6xx/fd6_texture.h index 9ca4cfbdf89..73a17a5087d 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.h @@ -91,7 +91,7 @@ fd6_tex_type(unsigned target) } static inline unsigned -fd6_border_color_offset(struct fd_context *ctx, enum a6xx_state_block sb, +fd6_border_color_offset(struct fd_context *ctx, enum pipe_shader_type type, struct fd_texture_stateobj *tex) { /* Currently we put the FS border-color state after VS. Possibly @@ -99,7 +99,7 @@ fd6_border_color_offset(struct fd_context *ctx, enum a6xx_state_block sb, * * This will need update for HS/DS/GS */ - if (sb != SB6_FS_TEX) + if (type != PIPE_SHADER_FRAGMENT) return 0; unsigned needs_border = false; @@ -152,6 +152,6 @@ struct fd6_texture_state { }; struct fd6_texture_state * fd6_texture_state(struct fd_context *ctx, - enum a6xx_state_block sb, struct fd_texture_stateobj *tex); + enum pipe_shader_type type, struct fd_texture_stateobj *tex); #endif /* FD6_TEXTURE_H_ */ |