zink: fix up color_write_enable workaround

this needs to only swizzle to dummy surfaces if it's the workaround,
not just if color_write_enable is active

Fixes: 3892c13381 ("zink: add an alternate path for EXT_color_write_enable usage")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15568>
This commit is contained in:
Mike Blumenkrantz 2022-03-24 15:44:02 -04:00 committed by Marge Bot
parent c0f52f08a1
commit 4c6931fca9
3 changed files with 13 additions and 4 deletions

View File

@ -1950,7 +1950,7 @@ get_render_pass(struct zink_context *ctx)
for (int i = 0; i < fb->nr_cbufs; i++) {
struct pipe_surface *surf = fb->cbufs[i];
if (surf) {
if (surf && !zink_use_dummy_attachments(ctx)) {
struct zink_surface *transient = zink_transient_surface(surf);
state.rts[i].format = zink_get_format(screen, surf->format);
state.rts[i].samples = MAX3(transient ? transient->base.nr_samples : 0, surf->texture->nr_samples, 1);
@ -2092,7 +2092,7 @@ setup_framebuffer(struct zink_context *ctx)
static VkImageView
prep_fb_attachment(struct zink_context *ctx, struct zink_surface *surf, unsigned i)
{
if (!surf)
if (!surf || (i < ctx->fb_state.nr_cbufs && zink_use_dummy_attachments(ctx)))
return zink_csurface(ctx->dummy_surface[util_logbase2_ceil(ctx->fb_state.samples)])->image_view;
zink_batch_resource_usage_set(&ctx->batch, zink_resource(surf->base.texture), true);
@ -2581,6 +2581,7 @@ zink_set_color_write_enables(struct zink_context *ctx)
if (zink_screen(ctx->base.screen)->driver_workarounds.color_write_missing) {
/* use dummy color buffers instead of the more sane option */
zink_end_render_pass(ctx);
ctx->rp_changed = true;
update_framebuffer_state(ctx, ctx->fb_state.width, ctx->fb_state.height);
} else {
VKCTX(CmdSetColorWriteEnableEXT)(ctx->batch.state->cmdbuf, max_att, disable_color_writes ? disables : enables);

View File

@ -527,6 +527,8 @@ zink_resource_rebind(struct zink_context *ctx, struct zink_resource *res);
void
zink_rebind_framebuffer(struct zink_context *ctx, struct zink_resource *res);
bool
zink_use_dummy_attachments(const struct zink_context *ctx);
void
zink_set_color_write_enables(struct zink_context *ctx);
void

View File

@ -137,6 +137,12 @@ fail:
return NULL;
}
bool
zink_use_dummy_attachments(const struct zink_context *ctx)
{
return ctx->disable_color_writes && zink_screen(ctx->base.screen)->driver_workarounds.color_write_missing;
}
struct zink_framebuffer *
zink_get_framebuffer_imageless(struct zink_context *ctx)
{
@ -149,7 +155,7 @@ zink_get_framebuffer_imageless(struct zink_context *ctx)
unsigned num_resolves = 0;
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
if (!psurf || ctx->disable_color_writes)
if (!psurf || zink_use_dummy_attachments(ctx))
psurf = ctx->dummy_surface[util_logbase2_ceil(ctx->gfx_pipeline_state.rast_samples+1)];
struct zink_surface *surface = zink_csurface(psurf);
struct zink_surface *transient = zink_transient_surface(psurf);
@ -300,7 +306,7 @@ zink_get_framebuffer(struct zink_context *ctx)
unsigned num_resolves = 0;
struct zink_framebuffer_state state = {0};
if (!ctx->disable_color_writes) {
if (!zink_use_dummy_attachments(ctx)) {
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
if (psurf) {