mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 05:08:08 +02:00
zink: break out region overlap testing function into helper
this is useful for a lot of copying operations Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9206>
This commit is contained in:
parent
48716b1431
commit
787412b7eb
3 changed files with 24 additions and 17 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
#include "zink_screen.h"
|
#include "zink_screen.h"
|
||||||
|
|
||||||
#include "util/u_blitter.h"
|
#include "util/u_blitter.h"
|
||||||
|
#include "util/u_rect.h"
|
||||||
#include "util/u_surface.h"
|
#include "util/u_surface.h"
|
||||||
#include "util/format/u_format.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]);
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
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 *
|
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)
|
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) {
|
if (scissor_state) {
|
||||||
struct u_rect scissor = {scissor_state->minx, scissor_state->maxx, scissor_state->miny, scissor_state->maxy};
|
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 zink_resource *res = zink_resource(pres);
|
||||||
struct pipe_screen *pscreen = pctx->screen;
|
struct pipe_screen *pscreen = pctx->screen;
|
||||||
struct u_rect region = {box->x, box->x + box->width, box->y, box->y + box->height};
|
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 zink_batch *batch = zink_curr_batch(ctx);
|
||||||
struct pipe_surface *surf = NULL;
|
struct pipe_surface *surf = NULL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
struct blitter_context;
|
struct blitter_context;
|
||||||
struct primconvert_context;
|
struct primconvert_context;
|
||||||
struct list_head;
|
struct list_head;
|
||||||
|
struct u_rect;
|
||||||
|
|
||||||
struct zink_blend_state;
|
struct zink_blend_state;
|
||||||
struct zink_depth_stencil_alpha_state;
|
struct zink_depth_stencil_alpha_state;
|
||||||
|
|
@ -280,6 +281,9 @@ void
|
||||||
zink_blit(struct pipe_context *pctx,
|
zink_blit(struct pipe_context *pctx,
|
||||||
const struct pipe_blit_info *info);
|
const struct pipe_blit_info *info);
|
||||||
|
|
||||||
|
bool
|
||||||
|
zink_blit_region_fills(struct u_rect region, unsigned width, unsigned height);
|
||||||
|
|
||||||
void
|
void
|
||||||
zink_clear(struct pipe_context *pctx,
|
zink_clear(struct pipe_context *pctx,
|
||||||
unsigned buffers,
|
unsigned buffers,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue