zink: handle streamout buffer rebinds
this really just means to nuke the counter buffer, and this can be done by using a special bind_history bit that can be unset when the buffer has been rebound Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9546>
This commit is contained in:
parent
a00f10207c
commit
cfa361e6cd
|
@ -2116,6 +2116,8 @@ zink_create_stream_output_target(struct pipe_context *pctx,
|
|||
t->base.buffer_offset = buffer_offset;
|
||||
t->base.buffer_size = buffer_size;
|
||||
|
||||
zink_resource(t->base.buffer)->bind_history |= ZINK_RESOURCE_USAGE_STREAMOUT;
|
||||
|
||||
return &t->base;
|
||||
}
|
||||
|
||||
|
@ -2171,6 +2173,11 @@ zink_resource_rebind(struct zink_context *ctx, struct zink_resource *res)
|
|||
{
|
||||
assert(res->base.target == PIPE_BUFFER);
|
||||
|
||||
if (res->bind_history & ZINK_RESOURCE_USAGE_STREAMOUT)
|
||||
ctx->dirty_so_targets = true;
|
||||
/* force counter buffer reset */
|
||||
res->bind_history &= ~ZINK_RESOURCE_USAGE_STREAMOUT;
|
||||
|
||||
for (unsigned shader = 0; shader < PIPE_SHADER_TYPES; shader++) {
|
||||
if (!(res->bind_stages & (1 << shader)))
|
||||
continue;
|
||||
|
|
|
@ -141,12 +141,16 @@ zink_emit_stream_output_targets(struct pipe_context *pctx)
|
|||
continue;
|
||||
}
|
||||
struct zink_resource *res = zink_resource(t->base.buffer);
|
||||
if (!(res->bind_history & ZINK_RESOURCE_USAGE_STREAMOUT))
|
||||
/* resource has been rebound */
|
||||
t->counter_buffer_valid = false;
|
||||
buffers[i] = res->obj->buffer;
|
||||
zink_resource_buffer_barrier(ctx, NULL, zink_resource(t->base.buffer),
|
||||
VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT, VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT);
|
||||
zink_batch_reference_resource_rw(batch, res, true);
|
||||
buffer_offsets[i] = t->base.buffer_offset;
|
||||
buffer_sizes[i] = t->base.buffer_size;
|
||||
res->bind_history |= ZINK_RESOURCE_USAGE_STREAMOUT;
|
||||
util_range_add(t->base.buffer, &res->valid_buffer_range, t->base.buffer_offset,
|
||||
t->base.buffer_offset + t->base.buffer_size);
|
||||
}
|
||||
|
|
|
@ -586,6 +586,11 @@ zink_resource_invalidate(struct pipe_context *pctx, struct pipe_resource *pres)
|
|||
if (res->valid_buffer_range.start > res->valid_buffer_range.end)
|
||||
return;
|
||||
|
||||
if (res->bind_history & ZINK_RESOURCE_USAGE_STREAMOUT)
|
||||
ctx->dirty_so_targets = true;
|
||||
/* force counter buffer reset */
|
||||
res->bind_history &= ~ZINK_RESOURCE_USAGE_STREAMOUT;
|
||||
|
||||
util_range_set_empty(&res->valid_buffer_range);
|
||||
if (!zink_get_resource_usage(res))
|
||||
return;
|
||||
|
|
|
@ -29,6 +29,8 @@ struct sw_displaytarget;
|
|||
struct zink_batch;
|
||||
struct zink_context;
|
||||
|
||||
#define ZINK_RESOURCE_USAGE_STREAMOUT (1 << 10) //much greater than ZINK_DESCRIPTOR_TYPES
|
||||
|
||||
#include "util/u_transfer.h"
|
||||
#include "util/u_range.h"
|
||||
#include "util/u_dynarray.h"
|
||||
|
|
Loading…
Reference in New Issue