#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_blitter.h"
+#include "util/u_upload_mgr.h"
#include "indices/u_primconvert.h"
#include "pipe/p_screen.h"
if (vc4->primconvert)
util_primconvert_destroy(vc4->primconvert);
+ if (vc4->uploader)
+ u_upload_destroy(vc4->uploader);
+
util_slab_destroy(&vc4->transfer_pool);
pipe_surface_reference(&vc4->framebuffer.cbufs[0], NULL);
if (!vc4->primconvert)
goto fail;
+ vc4->uploader = u_upload_create(pctx, 16 * 1024, 4,
+ PIPE_BIND_INDEX_BUFFER);
+
vc4_debug |= saved_shaderdb_flag;
return &vc4->base;
/** Seqno of the last CL flush's job. */
uint64_t last_emit_seqno;
+ struct u_upload_mgr *uploader;
+
/** @{ Current pipeline state objects */
struct pipe_scissor_state scissor;
struct pipe_blend_state *blend;
* definitions, up to but not including QUADS.
*/
if (info->indexed) {
- struct vc4_resource *rsc = vc4_resource(vc4->indexbuf.buffer);
uint32_t offset = vc4->indexbuf.offset;
uint32_t index_size = vc4->indexbuf.index_size;
- if (rsc->shadow_parent) {
- vc4_update_shadow_index_buffer(pctx, &vc4->indexbuf);
- offset = 0;
+ struct pipe_resource *prsc;
+ if (vc4->indexbuf.index_size == 4) {
+ prsc = vc4_get_shadow_index_buffer(pctx, &vc4->indexbuf,
+ info->count, &offset);
+ index_size = 2;
+ } else {
+ prsc = vc4->indexbuf.buffer;
}
+ struct vc4_resource *rsc = vc4_resource(prsc);
cl_start_reloc(&vc4->bcl, 1);
cl_u8(&vc4->bcl, VC4_PACKET_GL_INDEXED_PRIMITIVE);
cl_u32(&vc4->bcl, info->count);
cl_reloc(vc4, &vc4->bcl, rsc->bo, offset);
cl_u32(&vc4->bcl, max_index);
+
+ if (vc4->indexbuf.index_size == 4)
+ pipe_resource_reference(&prsc, NULL);
} else {
cl_u8(&vc4->bcl, VC4_PACKET_GL_ARRAY_PRIMITIVE);
cl_u8(&vc4->bcl, info->mode);
#include "util/u_format.h"
#include "util/u_inlines.h"
#include "util/u_surface.h"
+#include "util/u_upload_mgr.h"
#include "vc4_screen.h"
#include "vc4_context.h"
* was in user memory, it would be nice to not have uploaded it to a VBO
* before translating.
*/
-void
-vc4_update_shadow_index_buffer(struct pipe_context *pctx,
- const struct pipe_index_buffer *ib)
+struct pipe_resource *
+vc4_get_shadow_index_buffer(struct pipe_context *pctx,
+ const struct pipe_index_buffer *ib,
+ uint32_t count,
+ uint32_t *shadow_offset)
{
- struct vc4_resource *shadow = vc4_resource(ib->buffer);
- struct vc4_resource *orig = vc4_resource(shadow->shadow_parent);
- uint32_t count = shadow->base.b.width0 / 2;
-
- if (shadow->writes == orig->writes)
- return;
-
+ struct vc4_context *vc4 = vc4_context(pctx);
+ struct vc4_resource *orig = vc4_resource(ib->buffer);
perf_debug("Fallback conversion for %d uint indices\n", count);
+ void *data;
+ struct pipe_resource *shadow_rsc = NULL;
+ u_upload_alloc(vc4->uploader, 0, count * 2,
+ shadow_offset, &shadow_rsc, &data);
+ uint16_t *dst = data;
+
struct pipe_transfer *src_transfer;
uint32_t *src = pipe_buffer_map_range(pctx, &orig->base.b,
ib->offset,
count * 4,
PIPE_TRANSFER_READ, &src_transfer);
- struct pipe_transfer *dst_transfer;
- uint16_t *dst = pipe_buffer_map_range(pctx, &shadow->base.b,
- 0,
- count * 2,
- PIPE_TRANSFER_WRITE, &dst_transfer);
-
for (int i = 0; i < count; i++) {
uint32_t src_index = src[i];
assert(src_index <= 0xffff);
dst[i] = src_index;
}
- pctx->transfer_unmap(pctx, dst_transfer);
pctx->transfer_unmap(pctx, src_transfer);
- shadow->writes = orig->writes;
+ return shadow_rsc;
}
void
const struct pipe_resource *tmpl);
void vc4_update_shadow_baselevel_texture(struct pipe_context *pctx,
struct pipe_sampler_view *view);
-void vc4_update_shadow_index_buffer(struct pipe_context *pctx,
- const struct pipe_index_buffer *ib);
+struct pipe_resource *vc4_get_shadow_index_buffer(struct pipe_context *pctx,
+ const struct pipe_index_buffer *ib,
+ uint32_t count,
+ uint32_t *offset);
void vc4_dump_surface(struct pipe_surface *psurf);
#endif /* VC4_RESOURCE_H */
if (ib) {
assert(!ib->user_buffer);
-
- if (ib->index_size == 4) {
- struct pipe_resource tmpl = *ib->buffer;
- assert(tmpl.format == PIPE_FORMAT_R8_UNORM);
- assert(tmpl.height0 == 1);
- tmpl.width0 = (tmpl.width0 - ib->offset) / 2;
- struct pipe_resource *pshadow =
- vc4_resource_create(&vc4->screen->base, &tmpl);
- struct vc4_resource *shadow = vc4_resource(pshadow);
- pipe_resource_reference(&shadow->shadow_parent, ib->buffer);
-
- pipe_resource_reference(&vc4->indexbuf.buffer, NULL);
- vc4->indexbuf.buffer = pshadow;
- vc4->indexbuf.index_size = 2;
- } else {
- pipe_resource_reference(&vc4->indexbuf.buffer, ib->buffer);
- vc4->indexbuf.index_size = ib->index_size;
- }
+ pipe_resource_reference(&vc4->indexbuf.buffer, ib->buffer);
+ vc4->indexbuf.index_size = ib->index_size;
vc4->indexbuf.offset = ib->offset;
} else {
pipe_resource_reference(&vc4->indexbuf.buffer, NULL);