diff --git a/src/gallium/drivers/zink/zink_blit.c b/src/gallium/drivers/zink/zink_blit.c index 6b1f7234ba5..20fa51987d8 100644 --- a/src/gallium/drivers/zink/zink_blit.c +++ b/src/gallium/drivers/zink/zink_blit.c @@ -4,6 +4,7 @@ #include "zink_screen.h" #include "util/u_blitter.h" +#include "util/u_rect.h" #include "util/u_surface.h" #include "util/format/u_format.h" @@ -260,3 +261,20 @@ zink_blit_begin(struct zink_context *ctx, enum zink_blit_flags flags) ctx->sampler_views[PIPE_SHADER_FRAGMENT]); } } + +bool +zink_blit_region_fills(struct u_rect region, unsigned width, unsigned height) +{ + struct u_rect intersect = {0, width, 0, height}; + + if (!u_rect_test_intersection(®ion, &intersect)) + /* is this even a thing? */ + return false; + + u_rect_find_intersection(®ion, &intersect); + if (intersect.x0 != 0 || intersect.y0 != 0 || + intersect.x1 != width || intersect.y1 != height) + return false; + + return false; +} diff --git a/src/gallium/drivers/zink/zink_clear.c b/src/gallium/drivers/zink/zink_clear.c index 437e75b2e13..3e2436f45b6 100644 --- a/src/gallium/drivers/zink/zink_clear.c +++ b/src/gallium/drivers/zink/zink_clear.c @@ -162,22 +162,7 @@ clear_zs_no_rp(struct zink_context *ctx, struct zink_resource *res, VkImageAspec vkCmdClearDepthStencilImage(batch->cmdbuf, res->image, res->layout, &zs_value, 1, &range); } -static bool -clear_needs_rp(unsigned width, unsigned height, struct u_rect *region) -{ - struct u_rect intersect = {0, width, 0, height}; - if (!u_rect_test_intersection(region, &intersect)) - /* is this even a thing? */ - return true; - - u_rect_find_intersection(region, &intersect); - if (intersect.x0 != 0 || intersect.y0 != 0 || - intersect.x1 != width || intersect.y1 != height) - return true; - - return false; -} static struct zink_framebuffer_clear_data * get_clear_data(struct zink_context *ctx, struct zink_framebuffer_clear *fb_clear, const struct pipe_scissor_state *scissor_state) @@ -212,7 +197,7 @@ zink_clear(struct pipe_context *pctx, if (scissor_state) { struct u_rect scissor = {scissor_state->minx, scissor_state->maxx, scissor_state->miny, scissor_state->maxy}; - needs_rp = clear_needs_rp(fb->width, fb->height, &scissor); + needs_rp = !zink_blit_region_fills(scissor, fb->width, fb->height); } @@ -373,7 +358,7 @@ zink_clear_texture(struct pipe_context *pctx, struct zink_resource *res = zink_resource(pres); struct pipe_screen *pscreen = pctx->screen; struct u_rect region = {box->x, box->x + box->width, box->y, box->y + box->height}; - bool needs_rp = clear_needs_rp(pres->width0, pres->height0, ®ion) || ctx->render_condition_active; + bool needs_rp = !zink_blit_region_fills(region, pres->width0, pres->height0) || ctx->render_condition_active; struct zink_batch *batch = zink_curr_batch(ctx); struct pipe_surface *surf = NULL; diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h index e83d5434d9f..7f7deb8b0ce 100644 --- a/src/gallium/drivers/zink/zink_context.h +++ b/src/gallium/drivers/zink/zink_context.h @@ -38,6 +38,7 @@ struct blitter_context; struct primconvert_context; struct list_head; +struct u_rect; struct zink_blend_state; struct zink_depth_stencil_alpha_state; @@ -280,6 +281,9 @@ void zink_blit(struct pipe_context *pctx, const struct pipe_blit_info *info); +bool +zink_blit_region_fills(struct u_rect region, unsigned width, unsigned height); + void zink_clear(struct pipe_context *pctx, unsigned buffers,