summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <nroberts@igalia.com>2020-09-29 17:24:51 +0200
committerNeil Roberts <nroberts@igalia.com>2020-10-04 15:29:54 +0200
commit9a899e579a6c7845cd94961b22e3a2c475f50a62 (patch)
treedf4a03d0072ebecd512447d14e115fd288ce1807
parente2f037e96cb40be4412544551d10376ddc211bf3 (diff)
v3d: Update the TEXTURE_SHADER_STATE when there’s a new buf for a tex
When a texture is mapped with the DISCARD_WHOLE_RESOURCE flag set, v3d_map_usage_prep will try to allocate a new buffer for the resource. Previously, if the resource was used in a bound texture then nothing would cause it to update the sampler view with the offset for the new buffer. This commit just adds that in by looking at all sampler views and calling v3d_create_texture_shader_state_bo for each one that references this resource. Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6914>
-rw-r--r--src/gallium/drivers/v3d/v3d_resource.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gallium/drivers/v3d/v3d_resource.c b/src/gallium/drivers/v3d/v3d_resource.c
index c3990cd05e1..38ff848d0bf 100644
--- a/src/gallium/drivers/v3d/v3d_resource.c
+++ b/src/gallium/drivers/v3d/v3d_resource.c
@@ -147,6 +147,29 @@ v3d_resource_transfer_unmap(struct pipe_context *pctx,
}
static void
+rebind_sampler_views(struct v3d_context *v3d,
+ struct v3d_resource *rsc)
+{
+ for (int st = 0; st < PIPE_SHADER_TYPES; st++) {
+ struct v3d_texture_stateobj *tex = v3d->tex + st;
+
+ for (unsigned i = 0; i < tex->num_textures; i++) {
+ struct pipe_sampler_view *psview = tex->textures[i];
+
+ if (psview->texture != &rsc->base)
+ continue;
+
+ struct v3d_sampler_view *sview =
+ v3d_sampler_view(psview);
+
+ v3d_create_texture_shader_state_bo(v3d, sview);
+
+ v3d_flag_dirty_sampler_state(v3d, st);
+ }
+ }
+}
+
+static void
v3d_map_usage_prep(struct pipe_context *pctx,
struct pipe_resource *prsc,
unsigned usage)
@@ -164,6 +187,8 @@ v3d_map_usage_prep(struct pipe_context *pctx,
v3d->dirty |= VC5_DIRTY_VTXBUF;
if (prsc->bind & PIPE_BIND_CONSTANT_BUFFER)
v3d->dirty |= VC5_DIRTY_CONSTBUF;
+ if (prsc->bind & PIPE_BIND_SAMPLER_VIEW)
+ rebind_sampler_views(v3d, rsc);
} else {
/* If we failed to reallocate, flush users so that we
* don't violate any syncing requirements.