summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2017-04-16 11:49:54 -0400
committerRob Clark <robdclark@gmail.com>2017-04-18 16:32:00 -0400
commit0cc23ae77995bb258505a390dd57efd3e00803e6 (patch)
tree88bdf92618ed26ac18b7713a2acf86fb76650c43
parent5845b2045557681701c1aebd78755c5b65465344 (diff)
freedreno: make texture state an array
Make this an array indexed by shader stage, as is done elsewhere for other per-shader-stage state. This will simplify things as more shader stages are eventually added. Signed-off-by: Rob Clark <robdclark@gmail.com>
-rw-r--r--src/gallium/drivers/freedreno/a2xx/fd2_emit.c14
-rw-r--r--src/gallium/drivers/freedreno/a2xx/fd2_program.c4
-rw-r--r--src/gallium/drivers/freedreno/a2xx/fd2_texture.c6
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_emit.c4
-rw-r--r--src/gallium/drivers/freedreno/a4xx/fd4_emit.c4
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_emit.c17
-rw-r--r--src/gallium/drivers/freedreno/freedreno_context.h2
-rw-r--r--src/gallium/drivers/freedreno/freedreno_draw.c8
-rw-r--r--src/gallium/drivers/freedreno/freedreno_resource.c15
-rw-r--r--src/gallium/drivers/freedreno/freedreno_texture.c10
10 files changed, 45 insertions, 39 deletions
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c
index b3a1b3d29ab..5193b896ffc 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c
@@ -152,16 +152,18 @@ emit_texture(struct fd_ringbuffer *ring, struct fd_context *ctx,
static void
emit_textures(struct fd_ringbuffer *ring, struct fd_context *ctx)
{
+ struct fd_texture_stateobj *fragtex = &ctx->tex[PIPE_SHADER_FRAGMENT];
+ struct fd_texture_stateobj *verttex = &ctx->tex[PIPE_SHADER_VERTEX];
texmask emitted = 0;
unsigned i;
- for (i = 0; i < ctx->verttex.num_samplers; i++)
- if (ctx->verttex.samplers[i])
- emitted |= emit_texture(ring, ctx, &ctx->verttex, i, emitted);
+ for (i = 0; i < verttex->num_samplers; i++)
+ if (verttex->samplers[i])
+ emitted |= emit_texture(ring, ctx, verttex, i, emitted);
- for (i = 0; i < ctx->fragtex.num_samplers; i++)
- if (ctx->fragtex.samplers[i])
- emitted |= emit_texture(ring, ctx, &ctx->fragtex, i, emitted);
+ for (i = 0; i < fragtex->num_samplers; i++)
+ if (fragtex->samplers[i])
+ emitted |= emit_texture(ring, ctx, fragtex, i, emitted);
}
void
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_program.c b/src/gallium/drivers/freedreno/a2xx/fd2_program.c
index 4f317721db0..8dcbb979383 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_program.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_program.c
@@ -259,8 +259,8 @@ fd2_program_validate(struct fd_context *ctx)
/* if necessary, fix up texture fetch instructions: */
if (ctx->dirty & (FD_DIRTY_TEXSTATE | FD_DIRTY_PROG)) {
- patch_tex_fetches(ctx, prog->vp, &ctx->verttex);
- patch_tex_fetches(ctx, prog->fp, &ctx->fragtex);
+ patch_tex_fetches(ctx, prog->vp, &ctx->tex[PIPE_SHADER_VERTEX]);
+ patch_tex_fetches(ctx, prog->fp, &ctx->tex[PIPE_SHADER_FRAGMENT]);
}
}
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_texture.c b/src/gallium/drivers/freedreno/a2xx/fd2_texture.c
index 932383a528e..c500fbc9b87 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_texture.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_texture.c
@@ -116,7 +116,7 @@ fd2_sampler_states_bind(struct pipe_context *pctx,
* a change in # of fragment textures/samplers will trigger patching and
* re-emitting the vertex shader:
*/
- if (nr != ctx->fragtex.num_samplers)
+ if (nr != ctx->tex[PIPE_SHADER_FRAGMENT].num_samplers)
ctx->dirty |= FD_DIRTY_TEXSTATE;
}
@@ -166,9 +166,9 @@ unsigned
fd2_get_const_idx(struct fd_context *ctx, struct fd_texture_stateobj *tex,
unsigned samp_id)
{
- if (tex == &ctx->fragtex)
+ if (tex == &ctx->tex[PIPE_SHADER_FRAGMENT])
return samp_id;
- return samp_id + ctx->fragtex.num_samplers;
+ return samp_id + ctx->tex[PIPE_SHADER_FRAGMENT].num_samplers;
}
void
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index 6c3458a3b08..377085e7159 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -788,14 +788,14 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
if (dirty & FD_DIRTY_VERTTEX) {
if (vp->has_samp)
- emit_textures(ctx, ring, SB_VERT_TEX, &ctx->verttex);
+ emit_textures(ctx, ring, SB_VERT_TEX, &ctx->tex[PIPE_SHADER_VERTEX]);
else
dirty &= ~FD_DIRTY_VERTTEX;
}
if (dirty & FD_DIRTY_FRAGTEX) {
if (fp->has_samp)
- emit_textures(ctx, ring, SB_FRAG_TEX, &ctx->fragtex);
+ emit_textures(ctx, ring, SB_FRAG_TEX, &ctx->tex[PIPE_SHADER_FRAGMENT]);
else
dirty &= ~FD_DIRTY_FRAGTEX;
}
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
index 733e4a8c171..adda4a0460b 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
@@ -742,14 +742,14 @@ fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
if (dirty & FD_DIRTY_VERTTEX) {
if (vp->has_samp)
- emit_textures(ctx, ring, SB4_VS_TEX, &ctx->verttex, vp);
+ emit_textures(ctx, ring, SB4_VS_TEX, &ctx->tex[PIPE_SHADER_VERTEX], vp);
else
dirty &= ~FD_DIRTY_VERTTEX;
}
if (dirty & FD_DIRTY_FRAGTEX) {
if (fp->has_samp)
- emit_textures(ctx, ring, SB4_FS_TEX, &ctx->fragtex, fp);
+ emit_textures(ctx, ring, SB4_FS_TEX, &ctx->tex[PIPE_SHADER_FRAGMENT], fp);
else
dirty &= ~FD_DIRTY_FRAGTEX;
}
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
index e9dbab93b1a..b3307422ea3 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
@@ -260,8 +260,9 @@ emit_border_color(struct fd_context *ctx, struct fd_ringbuffer *ring)
entries = ptr;
- setup_border_colors(&ctx->verttex, &entries[0]);
- setup_border_colors(&ctx->fragtex, &entries[ctx->verttex.num_samplers]);
+ setup_border_colors(&ctx->tex[PIPE_SHADER_VERTEX], &entries[0]);
+ setup_border_colors(&ctx->tex[PIPE_SHADER_FRAGMENT],
+ &entries[ctx->tex[PIPE_SHADER_VERTEX].num_samplers]);
OUT_PKT4(ring, REG_A5XX_TPL1_TP_BORDER_COLOR_BASE_ADDR_LO, 2);
OUT_RELOC(ring, fd_resource(fd5_ctx->border_color_buf)->bo, off, 0, 0);
@@ -274,7 +275,7 @@ emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring,
enum a4xx_state_block sb, struct fd_texture_stateobj *tex)
{
bool needs_border = false;
- unsigned bcolor_offset = (sb == SB4_FS_TEX) ? ctx->verttex.num_samplers : 0;
+ unsigned bcolor_offset = (sb == SB4_FS_TEX) ? ctx->tex[PIPE_SHADER_VERTEX].num_samplers : 0;
unsigned i;
if (tex->num_samplers > 0) {
@@ -648,9 +649,10 @@ fd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
if (dirty & FD_DIRTY_VERTTEX) {
if (vp->has_samp) {
- needs_border |= emit_textures(ctx, ring, SB4_VS_TEX, &ctx->verttex);
+ needs_border |= emit_textures(ctx, ring, SB4_VS_TEX,
+ &ctx->tex[PIPE_SHADER_VERTEX]);
OUT_PKT4(ring, REG_A5XX_TPL1_VS_TEX_COUNT, 1);
- OUT_RING(ring, ctx->verttex.num_textures);
+ OUT_RING(ring, ctx->tex[PIPE_SHADER_VERTEX].num_textures);
} else {
dirty &= ~FD_DIRTY_VERTTEX;
}
@@ -658,9 +660,10 @@ fd5_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
if (dirty & FD_DIRTY_FRAGTEX) {
if (fp->has_samp) {
- needs_border |= emit_textures(ctx, ring, SB4_FS_TEX, &ctx->fragtex);
+ needs_border |= emit_textures(ctx, ring, SB4_FS_TEX,
+ &ctx->tex[PIPE_SHADER_FRAGMENT]);
OUT_PKT4(ring, REG_A5XX_TPL1_FS_TEX_COUNT, 1);
- OUT_RING(ring, ctx->fragtex.num_textures);
+ OUT_RING(ring, ctx->tex[PIPE_SHADER_FRAGMENT].num_textures);
} else {
dirty &= ~FD_DIRTY_FRAGTEX;
}
diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h
index cb33b8c0dfc..67291a097cc 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.h
+++ b/src/gallium/drivers/freedreno/freedreno_context.h
@@ -229,7 +229,7 @@ struct fd_context {
struct pipe_rasterizer_state *rasterizer;
struct pipe_depth_stencil_alpha_state *zsa;
- struct fd_texture_stateobj verttex, fragtex;
+ struct fd_texture_stateobj tex[PIPE_SHADER_TYPES];
struct fd_program_stateobj prog;
diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c
index a3c35cbce96..22d20c489c5 100644
--- a/src/gallium/drivers/freedreno/freedreno_draw.c
+++ b/src/gallium/drivers/freedreno/freedreno_draw.c
@@ -160,10 +160,10 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
resource_read(batch, ctx->indexbuf.buffer);
/* Mark textures as being read */
- foreach_bit(i, ctx->verttex.valid_textures)
- resource_read(batch, ctx->verttex.textures[i]->texture);
- foreach_bit(i, ctx->fragtex.valid_textures)
- resource_read(batch, ctx->fragtex.textures[i]->texture);
+ foreach_bit(i, ctx->tex[PIPE_SHADER_VERTEX].valid_textures)
+ resource_read(batch, ctx->tex[PIPE_SHADER_VERTEX].textures[i]->texture);
+ foreach_bit(i, ctx->tex[PIPE_SHADER_FRAGMENT].valid_textures)
+ resource_read(batch, ctx->tex[PIPE_SHADER_FRAGMENT].textures[i]->texture);
/* Mark streamout buffers as being written.. */
for (i = 0; i < ctx->streamout.num_targets; i++)
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index a24f3f30903..427ada8b667 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -77,12 +77,12 @@ fd_invalidate_resource(struct fd_context *ctx, struct pipe_resource *prsc)
ctx->dirty |= FD_DIRTY_INDEXBUF;
/* Textures */
- for (i = 0; i < ctx->verttex.num_textures && !(ctx->dirty & FD_DIRTY_VERTTEX); i++) {
- if (ctx->verttex.textures[i] && (ctx->verttex.textures[i]->texture == prsc))
+ for (i = 0; i < ctx->tex[PIPE_SHADER_VERTEX].num_textures && !(ctx->dirty & FD_DIRTY_VERTTEX); i++) {
+ if (ctx->tex[PIPE_SHADER_VERTEX].textures[i] && (ctx->tex[PIPE_SHADER_VERTEX].textures[i]->texture == prsc))
ctx->dirty |= FD_DIRTY_VERTTEX;
}
- for (i = 0; i < ctx->fragtex.num_textures && !(ctx->dirty & FD_DIRTY_FRAGTEX); i++) {
- if (ctx->fragtex.textures[i] && (ctx->fragtex.textures[i]->texture == prsc))
+ for (i = 0; i < ctx->tex[PIPE_SHADER_FRAGMENT].num_textures && !(ctx->dirty & FD_DIRTY_FRAGTEX); i++) {
+ if (ctx->tex[PIPE_SHADER_FRAGMENT].textures[i] && (ctx->tex[PIPE_SHADER_FRAGMENT].textures[i]->texture == prsc))
ctx->dirty |= FD_DIRTY_FRAGTEX;
}
}
@@ -1079,10 +1079,11 @@ fd_blitter_pipe_begin(struct fd_context *ctx, bool render_cond, bool discard,
util_blitter_save_framebuffer(ctx->blitter,
ctx->batch ? &ctx->batch->framebuffer : NULL);
util_blitter_save_fragment_sampler_states(ctx->blitter,
- ctx->fragtex.num_samplers,
- (void **)ctx->fragtex.samplers);
+ ctx->tex[PIPE_SHADER_FRAGMENT].num_samplers,
+ (void **)ctx->tex[PIPE_SHADER_FRAGMENT].samplers);
util_blitter_save_fragment_sampler_views(ctx->blitter,
- ctx->fragtex.num_textures, ctx->fragtex.textures);
+ ctx->tex[PIPE_SHADER_FRAGMENT].num_textures,
+ ctx->tex[PIPE_SHADER_FRAGMENT].textures);
if (!render_cond)
util_blitter_save_render_condition(ctx->blitter,
ctx->cond_query, ctx->cond_cond, ctx->cond_mode);
diff --git a/src/gallium/drivers/freedreno/freedreno_texture.c b/src/gallium/drivers/freedreno/freedreno_texture.c
index 2d038927a5a..d27f47eb29f 100644
--- a/src/gallium/drivers/freedreno/freedreno_texture.c
+++ b/src/gallium/drivers/freedreno/freedreno_texture.c
@@ -91,12 +91,12 @@ fd_sampler_states_bind(struct pipe_context *pctx,
{
struct fd_context *ctx = fd_context(pctx);
+ bind_sampler_states(&ctx->tex[shader], start, nr, hwcso);
+
if (shader == PIPE_SHADER_FRAGMENT) {
- bind_sampler_states(&ctx->fragtex, start, nr, hwcso);
ctx->dirty |= FD_DIRTY_FRAGTEX;
}
else if (shader == PIPE_SHADER_VERTEX) {
- bind_sampler_states(&ctx->verttex, start, nr, hwcso);
ctx->dirty |= FD_DIRTY_VERTTEX;
}
}
@@ -108,6 +108,8 @@ fd_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
{
struct fd_context *ctx = fd_context(pctx);
+ set_sampler_views(&ctx->tex[shader], start, nr, views);
+
switch (shader) {
case PIPE_SHADER_FRAGMENT:
/* on a2xx, since there is a flat address space for textures/samplers,
@@ -116,14 +118,12 @@ fd_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader,
*
* (note: later gen's ignore FD_DIRTY_TEXSTATE so fine to set it)
*/
- if (nr != ctx->fragtex.num_textures)
+ if (nr != ctx->tex[PIPE_SHADER_FRAGMENT].num_textures)
ctx->dirty |= FD_DIRTY_TEXSTATE;
- set_sampler_views(&ctx->fragtex, start, nr, views);
ctx->dirty |= FD_DIRTY_FRAGTEX;
break;
case PIPE_SHADER_VERTEX:
- set_sampler_views(&ctx->verttex, start, nr, views);
ctx->dirty |= FD_DIRTY_VERTTEX;
break;
default: