freedreno/a6xx: Move UBWC demotion to first sampler view bind
With threaded_context, CSO creation happens in the frontend thread, which means it is no longer safe to do blits (if needed, for sampler views with format that cannot be UBWC). So move this to the first time that the sampler view is bound. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9323>
This commit is contained in:
@@ -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]));
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user