diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c index 87938e33501..49ce3a6b92e 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c @@ -394,7 +394,7 @@ fd6_emit_textures(struct fd_context *ctx, struct fd_ringbuffer *ring, if (tex->textures[i]) { view = fd6_pipe_sampler_view(tex->textures[i]); - if (unlikely(view->rsc_seqno != view->ptr1->seqno)) { + if (unlikely(view->rsc_seqno != fd_resource(view->base.texture)->seqno)) { fd6_sampler_view_update(ctx, fd6_pipe_sampler_view(tex->textures[i])); } diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_image.c b/src/gallium/drivers/freedreno/a6xx/fd6_image.c index 1fa6bd0c890..683664e01b5 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_image.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_image.c @@ -318,6 +318,7 @@ static void fd6_set_shader_images(struct pipe_context *pctx, unsigned start, unsigned count, unsigned unbind_num_trailing_slots, const struct pipe_image_view *images) + in_dt { struct fd_context *ctx = fd_context(pctx); struct fd_shaderimg_stateobj *so = &ctx->shaderimg[shader]; diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c index 26157fd2bf6..951f8a261fd 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c @@ -111,7 +111,6 @@ can_do_ubwc(struct pipe_resource *prsc) void fd6_validate_format(struct fd_context *ctx, struct fd_resource *rsc, enum pipe_format format) - in_dt /* TODO this will be re-worked with threaded-ctx, this is just temporary */ { if (!rsc->layout.ubwc) return; diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_resource.h b/src/gallium/drivers/freedreno/a6xx/fd6_resource.h index 6eec087e10f..2563a21eb50 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_resource.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_resource.h @@ -31,7 +31,7 @@ #include "freedreno_resource.h" void fd6_validate_format(struct fd_context *ctx, struct fd_resource *rsc, - enum pipe_format format); + enum pipe_format format) assert_dt; void fd6_emit_flag_reference(struct fd_ringbuffer *ring, struct fd_resource *rsc, int level, int layer); void fd6_resource_screen_init(struct pipe_screen *pscreen); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index d34c5e05b3d..614e04b5357 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -160,24 +160,48 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, const struct pipe_sampler_view *cso) { struct fd6_pipe_sampler_view *so = CALLOC_STRUCT(fd6_pipe_sampler_view); - struct fd_resource *rsc = fd_resource(prsc); if (!so) return NULL; - fd6_validate_format(fd_context(pctx), rsc, cso->format); - so->base = *cso; pipe_reference(NULL, &prsc->reference); so->base.texture = prsc; so->base.reference.count = 1; so->base.context = pctx; - - fd6_sampler_view_update(fd_context(pctx), so); + so->needs_validate = true; return &so->base; } +static void +fd6_set_sampler_views(struct pipe_context *pctx, enum pipe_shader_type shader, + unsigned start, unsigned nr, unsigned unbind_num_trailing_slots, + struct pipe_sampler_view **views) + in_dt +{ + struct fd_context *ctx = fd_context(pctx); + + fd_set_sampler_views(pctx, shader, start, nr, unbind_num_trailing_slots, views); + + if (!views) + return; + + for (unsigned i = 0; i < nr; i++) { + struct fd6_pipe_sampler_view *so = fd6_pipe_sampler_view(views[i]); + + if (!(so && so->needs_validate)) + continue; + + struct fd_resource *rsc = fd_resource(so->base.texture); + + fd6_validate_format(ctx, rsc, so->base.format); + fd6_sampler_view_update(ctx, so); + + so->needs_validate = false; + } +} + void fd6_sampler_view_update(struct fd_context *ctx, struct fd6_pipe_sampler_view *so) { @@ -188,6 +212,8 @@ fd6_sampler_view_update(struct fd_context *ctx, struct fd6_pipe_sampler_view *so bool ubwc_enabled = false; unsigned lvl, layers = 0; + fd6_validate_format(ctx, rsc, cso->format); + if (format == PIPE_FORMAT_X32_S8X24_UINT) { rsc = rsc->stencil; format = rsc->b.b.format; @@ -195,7 +221,7 @@ fd6_sampler_view_update(struct fd_context *ctx, struct fd6_pipe_sampler_view *so so->seqno = ++fd6_context(ctx)->tex_seqno; so->ptr1 = rsc; - so->rsc_seqno = so->ptr1->seqno; + so->rsc_seqno = rsc->seqno; if (cso->target == PIPE_BUFFER) { unsigned elements = cso->u.buf.size / util_format_get_blocksize(format); @@ -479,7 +505,7 @@ fd6_texture_init(struct pipe_context *pctx) pctx->create_sampler_view = fd6_sampler_view_create; pctx->sampler_view_destroy = fd6_sampler_view_destroy; - pctx->set_sampler_views = fd_set_sampler_views; + pctx->set_sampler_views = fd6_set_sampler_views; ctx->rebind_resource = fd6_rebind_resource; diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.h b/src/gallium/drivers/freedreno/a6xx/fd6_texture.h index 02711541140..0ea68f8b3ff 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.h @@ -61,6 +61,8 @@ struct fd6_pipe_sampler_view { * to uncompressed, which means the sampler state needs to be updated */ uint16_t rsc_seqno; + + bool needs_validate; }; static inline struct fd6_pipe_sampler_view * @@ -69,7 +71,7 @@ fd6_pipe_sampler_view(struct pipe_sampler_view *pview) return (struct fd6_pipe_sampler_view *)pview; } -void fd6_sampler_view_update(struct fd_context *ctx, struct fd6_pipe_sampler_view *so); +void fd6_sampler_view_update(struct fd_context *ctx, struct fd6_pipe_sampler_view *so) assert_dt; void fd6_texture_init(struct pipe_context *pctx); void fd6_texture_fini(struct pipe_context *pctx);