diff options
Diffstat (limited to 'src/gallium/drivers/freedreno/freedreno_resource.c')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_resource.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 427ada8b667..3b067095523 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -51,23 +51,13 @@ static void fd_invalidate_resource(struct fd_context *ctx, struct pipe_resource *prsc) { - int i; - /* Go through the entire state and see if the resource is bound * anywhere. If it is, mark the relevant state as dirty. This is called on * realloc_bo. */ - /* Constbufs */ - for (i = 1; i < PIPE_MAX_CONSTANT_BUFFERS && !(ctx->dirty & FD_DIRTY_CONSTBUF); i++) { - if (ctx->constbuf[PIPE_SHADER_VERTEX].cb[i].buffer == prsc) - ctx->dirty |= FD_DIRTY_CONSTBUF; - if (ctx->constbuf[PIPE_SHADER_FRAGMENT].cb[i].buffer == prsc) - ctx->dirty |= FD_DIRTY_CONSTBUF; - } - /* VBOs */ - for (i = 0; i < ctx->vtx.vertexbuf.count && !(ctx->dirty & FD_DIRTY_VTXBUF); i++) { + for (unsigned i = 0; i < ctx->vtx.vertexbuf.count && !(ctx->dirty & FD_DIRTY_VTXBUF); i++) { if (ctx->vtx.vertexbuf.vb[i].buffer == prsc) ctx->dirty |= FD_DIRTY_VTXBUF; } @@ -76,14 +66,26 @@ fd_invalidate_resource(struct fd_context *ctx, struct pipe_resource *prsc) if (ctx->indexbuf.buffer == prsc) ctx->dirty |= FD_DIRTY_INDEXBUF; - /* Textures */ - 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->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; + /* per-shader-stage resources: */ + for (unsigned stage = 0; stage < PIPE_SHADER_TYPES; stage++) { + /* Constbufs.. note that constbuf[0] is normal uniforms emitted in + * cmdstream rather than by pointer.. + */ + const unsigned num_ubos = util_last_bit(ctx->constbuf[stage].enabled_mask); + for (unsigned i = 1; i < num_ubos; i++) { + if (ctx->dirty_shader[stage] & FD_DIRTY_SHADER_CONST) + break; + if (ctx->constbuf[stage].cb[i].buffer == prsc) + ctx->dirty_shader[stage] |= FD_DIRTY_SHADER_CONST; + } + + /* Textures */ + for (unsigned i = 0; i < ctx->tex[stage].num_textures; i++) { + if (ctx->dirty_shader[stage] & FD_DIRTY_SHADER_TEX) + break; + if (ctx->tex[stage].textures[i] && (ctx->tex[stage].textures[i]->texture == prsc)) + ctx->dirty_shader[stage] |= FD_DIRTY_SHADER_TEX; + } } } |