mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 04:40:09 +01:00
zink: add an alternate path for EXT_color_write_enable usage
for drivers where this is broken/missing, the same effect can be achieved by feeding the renderpass a framebuffer with null/dummy attachments Acked-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15392>
This commit is contained in:
parent
447099629e
commit
3892c13381
3 changed files with 27 additions and 17 deletions
|
|
@ -2572,8 +2572,15 @@ void
|
|||
zink_set_color_write_enables(struct zink_context *ctx)
|
||||
{
|
||||
const VkBool32 enables[PIPE_MAX_COLOR_BUFS] = {1, 1, 1, 1, 1, 1, 1, 1};
|
||||
const VkBool32 disables[PIPE_MAX_COLOR_BUFS] = {0};
|
||||
const unsigned max_att = MIN2(PIPE_MAX_COLOR_BUFS, zink_screen(ctx->base.screen)->info.props.limits.maxColorAttachments);
|
||||
VKCTX(CmdSetColorWriteEnableEXT)(ctx->batch.state->cmdbuf, max_att, enables);
|
||||
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);
|
||||
update_framebuffer_state(ctx, ctx->fb_state.width, ctx->fb_state.height);
|
||||
} else {
|
||||
VKCTX(CmdSetColorWriteEnableEXT)(ctx->batch.state->cmdbuf, max_att, enables);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -290,6 +290,7 @@ struct zink_context {
|
|||
struct list_head suspended_queries;
|
||||
struct list_head primitives_generated_queries;
|
||||
struct zink_query *vertices_query;
|
||||
bool disable_color_writes;
|
||||
bool primitives_generated_active;
|
||||
bool queries_disabled, render_condition_active;
|
||||
struct {
|
||||
|
|
|
|||
|
|
@ -149,7 +149,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)
|
||||
if (!psurf || ctx->disable_color_writes)
|
||||
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,24 +300,26 @@ zink_get_framebuffer(struct zink_context *ctx)
|
|||
unsigned num_resolves = 0;
|
||||
|
||||
struct zink_framebuffer_state state = {0};
|
||||
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
|
||||
struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
|
||||
if (psurf) {
|
||||
struct zink_surface *surf = zink_csurface(psurf);
|
||||
struct zink_surface *transient = zink_transient_surface(psurf);
|
||||
if (transient) {
|
||||
state.attachments[i] = transient->image_view;
|
||||
state.attachments[cresolve_offset + i] = surf->image_view;
|
||||
attachments[cresolve_offset + i] = psurf;
|
||||
psurf = &transient->base;
|
||||
num_resolves++;
|
||||
if (!ctx->disable_color_writes) {
|
||||
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
|
||||
struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
|
||||
if (psurf) {
|
||||
struct zink_surface *surf = zink_csurface(psurf);
|
||||
struct zink_surface *transient = zink_transient_surface(psurf);
|
||||
if (transient) {
|
||||
state.attachments[i] = transient->image_view;
|
||||
state.attachments[cresolve_offset + i] = surf->image_view;
|
||||
attachments[cresolve_offset + i] = psurf;
|
||||
psurf = &transient->base;
|
||||
num_resolves++;
|
||||
} else {
|
||||
state.attachments[i] = surf->image_view;
|
||||
}
|
||||
} else {
|
||||
state.attachments[i] = surf->image_view;
|
||||
state.attachments[i] = VK_NULL_HANDLE;
|
||||
}
|
||||
} else {
|
||||
state.attachments[i] = VK_NULL_HANDLE;
|
||||
attachments[i] = psurf;
|
||||
}
|
||||
attachments[i] = psurf;
|
||||
}
|
||||
|
||||
state.num_attachments = ctx->fb_state.nr_cbufs;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue