diff options
Diffstat (limited to 'src/gallium/auxiliary')
20 files changed, 144 insertions, 130 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 3d3c44cf81a..68f7b9e7bfe 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -408,8 +408,8 @@ void cso_destroy_context( struct cso_context *ctx ) util_unreference_framebuffer_state(&ctx->fb); util_unreference_framebuffer_state(&ctx->fb_saved); - pipe_resource_reference(&ctx->aux_vertex_buffer_current.buffer, NULL); - pipe_resource_reference(&ctx->aux_vertex_buffer_saved.buffer, NULL); + pipe_vertex_buffer_unreference(&ctx->aux_vertex_buffer_current); + pipe_vertex_buffer_unreference(&ctx->aux_vertex_buffer_saved); for (i = 0; i < PIPE_SHADER_TYPES; i++) { pipe_resource_reference(&ctx->aux_constbuf_current[i].buffer, NULL); @@ -1150,15 +1150,9 @@ void cso_set_vertex_buffers(struct cso_context *ctx, const struct pipe_vertex_buffer *vb = buffers + (ctx->aux_vertex_buffer_index - start_slot); - pipe_resource_reference(&ctx->aux_vertex_buffer_current.buffer, - vb->buffer); - memcpy(&ctx->aux_vertex_buffer_current, vb, - sizeof(struct pipe_vertex_buffer)); - } - else { - pipe_resource_reference(&ctx->aux_vertex_buffer_current.buffer, - NULL); - ctx->aux_vertex_buffer_current.user_buffer = NULL; + pipe_vertex_buffer_reference(&ctx->aux_vertex_buffer_current, vb); + } else { + pipe_vertex_buffer_unreference(&ctx->aux_vertex_buffer_current); } } @@ -1175,10 +1169,8 @@ cso_save_aux_vertex_buffer_slot(struct cso_context *ctx) return; } - pipe_resource_reference(&ctx->aux_vertex_buffer_saved.buffer, - ctx->aux_vertex_buffer_current.buffer); - memcpy(&ctx->aux_vertex_buffer_saved, &ctx->aux_vertex_buffer_current, - sizeof(struct pipe_vertex_buffer)); + pipe_vertex_buffer_reference(&ctx->aux_vertex_buffer_saved, + &ctx->aux_vertex_buffer_current); } static void @@ -1193,7 +1185,7 @@ cso_restore_aux_vertex_buffer_slot(struct cso_context *ctx) cso_set_vertex_buffers(ctx, ctx->aux_vertex_buffer_index, 1, &ctx->aux_vertex_buffer_saved); - pipe_resource_reference(&ctx->aux_vertex_buffer_saved.buffer, NULL); + pipe_vertex_buffer_unreference(&ctx->aux_vertex_buffer_saved); } unsigned cso_get_aux_vertex_buffer_slot(struct cso_context *ctx) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 8f1189a6bda..0eee0751069 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -206,9 +206,8 @@ void draw_destroy( struct draw_context *draw ) } } - for (i = 0; i < draw->pt.nr_vertex_buffers; i++) { - pipe_resource_reference(&draw->pt.vertex_buffer[i].buffer, NULL); - } + for (i = 0; i < draw->pt.nr_vertex_buffers; i++) + pipe_vertex_buffer_unreference(&draw->pt.vertex_buffer[i]); /* Not so fast -- we're just borrowing this at the moment. * diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index bb08f665064..203572010fc 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -352,9 +352,9 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm, LLVMTypeRef elem_types[4]; LLVMTypeRef vb_type; - elem_types[0] = - elem_types[1] = LLVMInt32TypeInContext(gallivm->context); - elem_types[2] = + elem_types[0] = LLVMInt16TypeInContext(gallivm->context); + elem_types[1] = LLVMInt8TypeInContext(gallivm->context); + elem_types[2] = LLVMInt32TypeInContext(gallivm->context); elem_types[3] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); vb_type = LLVMStructTypeInContext(gallivm->context, elem_types, @@ -363,8 +363,12 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm, (void) target; /* silence unused var warning for non-debug build */ LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride, target, vb_type, 0); - LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, buffer_offset, + LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, is_user_buffer, target, vb_type, 1); + LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, buffer_offset, + target, vb_type, 2); + LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, buffer.resource, + target, vb_type, 3); LP_CHECK_STRUCT_SIZE(struct pipe_vertex_buffer, target, vb_type); @@ -1699,6 +1703,8 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant) vbuffer_ptr = LLVMBuildGEP(builder, vbuffers_ptr, &vb_index, 1, ""); vb_info = LLVMBuildGEP(builder, vb_ptr, &vb_index, 1, ""); vb_stride[j] = draw_jit_vbuffer_stride(gallivm, vb_info); + vb_stride[j] = LLVMBuildZExt(gallivm->builder, vb_stride[j], + LLVMInt32TypeInContext(context), ""); vb_buffer_offset = draw_jit_vbuffer_offset(gallivm, vb_info); map_ptr[j] = draw_jit_dvbuffer_map(gallivm, vbuffer_ptr); buffer_size = draw_jit_dvbuffer_size(gallivm, vbuffer_ptr); diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index 57c9e72c04c..a968be01f81 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -172,7 +172,7 @@ enum { lp_build_struct_get(_gallivm, _ptr, 0, "stride") #define draw_jit_vbuffer_offset(_gallivm, _ptr) \ - lp_build_struct_get(_gallivm, _ptr, 1, "buffer_offset") + lp_build_struct_get(_gallivm, _ptr, 2, "buffer_offset") enum { DRAW_JIT_DVBUFFER_MAP = 0, diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index f492c81fe6d..9dd2fbf17e5 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -579,15 +579,15 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) hud->whitelines.buffer_size + hud->text.buffer_size + hud->color_prims.buffer_size, - 16, &hud->bg.vbuf.buffer_offset, &hud->bg.vbuf.buffer, + 16, &hud->bg.vbuf.buffer_offset, &hud->bg.vbuf.buffer.resource, (void**)&hud->bg.vertices); if (!hud->bg.vertices) { goto out; } - pipe_resource_reference(&hud->whitelines.vbuf.buffer, hud->bg.vbuf.buffer); - pipe_resource_reference(&hud->text.vbuf.buffer, hud->bg.vbuf.buffer); - pipe_resource_reference(&hud->color_prims.vbuf.buffer, hud->bg.vbuf.buffer); + pipe_resource_reference(&hud->whitelines.vbuf.buffer.resource, hud->bg.vbuf.buffer.resource); + pipe_resource_reference(&hud->text.vbuf.buffer.resource, hud->bg.vbuf.buffer.resource); + pipe_resource_reference(&hud->color_prims.vbuf.buffer.resource, hud->bg.vbuf.buffer.resource); hud->whitelines.vbuf.buffer_offset = hud->bg.vbuf.buffer_offset + hud->bg.buffer_size; @@ -654,7 +654,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) &hud->bg.vbuf); cso_draw_arrays(cso, PIPE_PRIM_QUADS, 0, hud->bg.num_vertices); } - pipe_resource_reference(&hud->bg.vbuf.buffer, NULL); + pipe_resource_reference(&hud->bg.vbuf.buffer.resource, NULL); /* draw accumulated vertices for white lines */ cso_set_blend(cso, &hud->no_blend); @@ -675,7 +675,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) cso_set_fragment_shader_handle(hud->cso, hud->fs_color); cso_draw_arrays(cso, PIPE_PRIM_LINES, 0, hud->whitelines.num_vertices); } - pipe_resource_reference(&hud->whitelines.vbuf.buffer, NULL); + pipe_resource_reference(&hud->whitelines.vbuf.buffer.resource, NULL); /* draw accumulated vertices for text */ cso_set_blend(cso, &hud->alpha_blend); @@ -685,7 +685,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) cso_set_fragment_shader_handle(hud->cso, hud->fs_text); cso_draw_arrays(cso, PIPE_PRIM_QUADS, 0, hud->text.num_vertices); } - pipe_resource_reference(&hud->text.vbuf.buffer, NULL); + pipe_resource_reference(&hud->text.vbuf.buffer.resource, NULL); /* draw the rest */ cso_set_rasterizer(cso, &hud->rasterizer_aa_lines); diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 447d8d2281f..13fa9651392 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -539,7 +539,7 @@ void util_blitter_restore_vertex_states(struct blitter_context *blitter) /* Vertex buffer. */ pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, &ctx->base.saved_vertex_buffer); - pipe_resource_reference(&ctx->base.saved_vertex_buffer.buffer, NULL); + pipe_vertex_buffer_unreference(&ctx->base.saved_vertex_buffer); /* Vertex elements. */ pipe->bind_vertex_elements_state(pipe, ctx->base.saved_velem_state); @@ -1209,15 +1209,15 @@ static void blitter_draw(struct blitter_context_priv *ctx, vb.stride = 8 * sizeof(float); u_upload_data(pipe->stream_uploader, 0, sizeof(ctx->vertices), 4, ctx->vertices, - &vb.buffer_offset, &vb.buffer); - if (!vb.buffer) + &vb.buffer_offset, &vb.buffer.resource); + if (!vb.buffer.resource) return; u_upload_unmap(pipe->stream_uploader); pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, &vb); util_draw_arrays_instanced(pipe, PIPE_PRIM_TRIANGLE_FAN, 0, 4, 0, num_instances); - pipe_resource_reference(&vb.buffer, NULL); + pipe_resource_reference(&vb.buffer.resource, NULL); } void util_blitter_draw_rectangle(struct blitter_context *blitter, @@ -2199,7 +2199,8 @@ void util_blitter_copy_buffer(struct blitter_context *blitter, blitter_check_saved_vertex_states(ctx); blitter_disable_render_cond(ctx); - vb.buffer = src; + vb.is_user_buffer = false; + vb.buffer.resource = src; vb.buffer_offset = srcx; vb.stride = 4; @@ -2259,8 +2260,8 @@ void util_blitter_clear_buffer(struct blitter_context *blitter, } u_upload_data(pipe->stream_uploader, 0, num_channels*4, 4, clear_value, - &vb.buffer_offset, &vb.buffer); - if (!vb.buffer) + &vb.buffer_offset, &vb.buffer.resource); + if (!vb.buffer.resource) goto out; vb.stride = 0; @@ -2291,7 +2292,7 @@ out: util_blitter_restore_render_cond(blitter); util_blitter_unset_running_flag(blitter); pipe_so_target_reference(&so_target, NULL); - pipe_resource_reference(&vb.buffer, NULL); + pipe_resource_reference(&vb.buffer.resource, NULL); } /* probably radeon specific */ diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index f47c3dd07e9..fd4fe7a233a 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -503,10 +503,8 @@ static inline void util_blitter_save_vertex_buffer_slot(struct blitter_context *blitter, struct pipe_vertex_buffer *vertex_buffers) { - pipe_resource_reference(&blitter->saved_vertex_buffer.buffer, - vertex_buffers[blitter->vb_slot].buffer); - memcpy(&blitter->saved_vertex_buffer, &vertex_buffers[blitter->vb_slot], - sizeof(struct pipe_vertex_buffer)); + pipe_vertex_buffer_reference(&blitter->saved_vertex_buffer, + &vertex_buffers[blitter->vb_slot]); } static inline void diff --git a/src/gallium/auxiliary/util/u_draw.c b/src/gallium/auxiliary/util/u_draw.c index b9f8fcd3c2a..ca786489786 100644 --- a/src/gallium/auxiliary/util/u_draw.c +++ b/src/gallium/auxiliary/util/u_draw.c @@ -62,13 +62,13 @@ util_draw_max_index( const struct util_format_description *format_desc; unsigned format_size; - if (!buffer->buffer) { + if (buffer->is_user_buffer || !buffer->buffer.resource) { continue; } - assert(buffer->buffer->height0 == 1); - assert(buffer->buffer->depth0 == 1); - buffer_size = buffer->buffer->width0; + assert(buffer->buffer.resource->height0 == 1); + assert(buffer->buffer.resource->depth0 == 1); + buffer_size = buffer->buffer.resource->width0; format_desc = util_format_description(element->src_format); assert(format_desc->block.width == 1); diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c index ce3fa41d9b0..fe9558e6c90 100644 --- a/src/gallium/auxiliary/util/u_draw_quad.c +++ b/src/gallium/auxiliary/util/u_draw_quad.c @@ -54,7 +54,7 @@ util_draw_vertex_buffer(struct pipe_context *pipe, /* tell pipe about the vertex buffer */ memset(&vbuffer, 0, sizeof(vbuffer)); - vbuffer.buffer = vbuf; + vbuffer.buffer.resource = vbuf; vbuffer.stride = num_attribs * 4 * sizeof(float); /* vertex size */ vbuffer.buffer_offset = offset; @@ -82,7 +82,8 @@ util_draw_user_vertex_buffer(struct cso_context *cso, void *buffer, assert(num_attribs <= PIPE_MAX_ATTRIBS); - vbuffer.user_buffer = buffer; + vbuffer.is_user_buffer = true; + vbuffer.buffer.user = buffer; vbuffer.stride = num_attribs * 4 * sizeof(float); /* vertex size */ /* note: vertex elements already set by caller */ diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c index bf27a4e0eea..b9e6b522589 100644 --- a/src/gallium/auxiliary/util/u_dump_state.c +++ b/src/gallium/auxiliary/util/u_dump_state.c @@ -863,9 +863,9 @@ util_dump_vertex_buffer(FILE *stream, const struct pipe_vertex_buffer *state) util_dump_struct_begin(stream, "pipe_vertex_buffer"); util_dump_member(stream, uint, state, stride); + util_dump_member(stream, bool, state, is_user_buffer); util_dump_member(stream, uint, state, buffer_offset); - util_dump_member(stream, ptr, state, buffer); - util_dump_member(stream, ptr, state, user_buffer); + util_dump_member(stream, ptr, state, buffer.resource); util_dump_struct_end(stream); } diff --git a/src/gallium/auxiliary/util/u_helpers.c b/src/gallium/auxiliary/util/u_helpers.c index 5b46fa1351f..f91cb0c158d 100644 --- a/src/gallium/auxiliary/util/u_helpers.c +++ b/src/gallium/auxiliary/util/u_helpers.c @@ -51,10 +51,13 @@ void util_set_vertex_buffers_mask(struct pipe_vertex_buffer *dst, if (src) { for (i = 0; i < count; i++) { - if (src[i].buffer || src[i].user_buffer) { + if (src[i].buffer.resource) bitmask |= 1 << i; - } - pipe_resource_reference(&dst[i].buffer, src[i].buffer); + + pipe_vertex_buffer_unreference(&dst[i]); + + if (!src[i].is_user_buffer) + pipe_resource_reference(&dst[i].buffer.resource, src[i].buffer.resource); } /* Copy over the other members of pipe_vertex_buffer. */ @@ -65,10 +68,8 @@ void util_set_vertex_buffers_mask(struct pipe_vertex_buffer *dst, } else { /* Unreference the buffers. */ - for (i = 0; i < count; i++) { - pipe_resource_reference(&dst[i].buffer, NULL); - dst[i].user_buffer = NULL; - } + for (i = 0; i < count; i++) + pipe_vertex_buffer_unreference(&dst[i]); *enabled_buffers &= ~(((1ull << count) - 1) << start_slot); } @@ -87,7 +88,7 @@ void util_set_vertex_buffers_count(struct pipe_vertex_buffer *dst, uint32_t enabled_buffers = 0; for (i = 0; i < *dst_count; i++) { - if (dst[i].buffer || dst[i].user_buffer) + if (dst[i].buffer.resource) enabled_buffers |= (1ull << i); } diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 6bc5e6660f9..6a3d5043cf2 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -188,6 +188,25 @@ pipe_so_target_reference(struct pipe_stream_output_target **ptr, } static inline void +pipe_vertex_buffer_unreference(struct pipe_vertex_buffer *dst) +{ + if (dst->is_user_buffer) + dst->buffer.user = NULL; + else + pipe_resource_reference(&dst->buffer.resource, NULL); +} + +static inline void +pipe_vertex_buffer_reference(struct pipe_vertex_buffer *dst, + const struct pipe_vertex_buffer *src) +{ + pipe_vertex_buffer_unreference(dst); + if (!src->is_user_buffer) + pipe_resource_reference(&dst->buffer.resource, src->buffer.resource); + memcpy(dst, src, sizeof(*src)); +} + +static inline void pipe_surface_reset(struct pipe_context *ctx, struct pipe_surface* ps, struct pipe_resource *pt, unsigned level, unsigned layer) { diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c index f040f4a882d..62b88acca58 100644 --- a/src/gallium/auxiliary/util/u_vbuf.c +++ b/src/gallium/auxiliary/util/u_vbuf.c @@ -377,13 +377,12 @@ void u_vbuf_destroy(struct u_vbuf *mgr) mgr->pipe->set_vertex_buffers(mgr->pipe, 0, num_vb, NULL); - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - pipe_resource_reference(&mgr->vertex_buffer[i].buffer, NULL); - } - for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { - pipe_resource_reference(&mgr->real_vertex_buffer[i].buffer, NULL); - } - pipe_resource_reference(&mgr->aux_vertex_buffer_saved.buffer, NULL); + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) + pipe_vertex_buffer_unreference(&mgr->vertex_buffer[i]); + for (i = 0; i < PIPE_MAX_ATTRIBS; i++) + pipe_vertex_buffer_unreference(&mgr->real_vertex_buffer[i]); + + pipe_vertex_buffer_unreference(&mgr->aux_vertex_buffer_saved); translate_cache_destroy(mgr->translate_cache); cso_cache_delete(mgr->cso_cache); @@ -417,17 +416,17 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key, vb = &mgr->vertex_buffer[i]; offset = vb->buffer_offset + vb->stride * start_vertex; - if (vb->user_buffer) { - map = (uint8_t*)vb->user_buffer + offset; + if (vb->is_user_buffer) { + map = (uint8_t*)vb->buffer.user + offset; } else { unsigned size = vb->stride ? num_vertices * vb->stride : sizeof(double)*4; - if (offset+size > vb->buffer->width0) { - size = vb->buffer->width0 - offset; + if (offset+size > vb->buffer.resource->width0) { + size = vb->buffer.resource->width0 - offset; } - map = pipe_buffer_map_range(mgr->pipe, vb->buffer, offset, size, + map = pipe_buffer_map_range(mgr->pipe, vb->buffer.resource, offset, size, PIPE_TRANSFER_READ, &vb_transfer[i]); } @@ -510,8 +509,8 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key, /* Move the buffer reference. */ pipe_resource_reference( - &mgr->real_vertex_buffer[out_vb].buffer, NULL); - mgr->real_vertex_buffer[out_vb].buffer = out_buffer; + &mgr->real_vertex_buffer[out_vb].buffer.resource, NULL); + mgr->real_vertex_buffer[out_vb].buffer.resource = out_buffer; return PIPE_OK; } @@ -721,7 +720,7 @@ static void u_vbuf_translate_end(struct u_vbuf *mgr) for (i = 0; i < VB_NUM; i++) { unsigned vb = mgr->fallback_vbs[i]; if (vb != ~0u) { - pipe_resource_reference(&mgr->real_vertex_buffer[vb].buffer, NULL); + pipe_resource_reference(&mgr->real_vertex_buffer[vb].buffer.resource, NULL); mgr->fallback_vbs[i] = ~0; /* This will cause the buffer to be unbound in the driver later. */ @@ -830,8 +829,8 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr, for (i = 0; i < count; i++) { unsigned dst_index = start_slot + i; - pipe_resource_reference(&mgr->vertex_buffer[dst_index].buffer, NULL); - pipe_resource_reference(&mgr->real_vertex_buffer[dst_index].buffer, + pipe_vertex_buffer_unreference(&mgr->vertex_buffer[dst_index]); + pipe_resource_reference(&mgr->real_vertex_buffer[dst_index].buffer.resource, NULL); } @@ -845,18 +844,13 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr, struct pipe_vertex_buffer *orig_vb = &mgr->vertex_buffer[dst_index]; struct pipe_vertex_buffer *real_vb = &mgr->real_vertex_buffer[dst_index]; - if (!vb->buffer && !vb->user_buffer) { - pipe_resource_reference(&orig_vb->buffer, NULL); - pipe_resource_reference(&real_vb->buffer, NULL); - real_vb->user_buffer = NULL; + if (!vb->buffer.resource) { + pipe_vertex_buffer_unreference(orig_vb); + pipe_vertex_buffer_unreference(real_vb); continue; } - pipe_resource_reference(&orig_vb->buffer, vb->buffer); - orig_vb->user_buffer = vb->user_buffer; - - real_vb->buffer_offset = orig_vb->buffer_offset = vb->buffer_offset; - real_vb->stride = orig_vb->stride = vb->stride; + pipe_vertex_buffer_reference(orig_vb, vb); if (vb->stride) { nonzero_stride_vb_mask |= 1 << dst_index; @@ -866,18 +860,23 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr, if ((!mgr->caps.buffer_offset_unaligned && vb->buffer_offset % 4 != 0) || (!mgr->caps.buffer_stride_unaligned && vb->stride % 4 != 0)) { incompatible_vb_mask |= 1 << dst_index; - pipe_resource_reference(&real_vb->buffer, NULL); + real_vb->buffer_offset = vb->buffer_offset; + real_vb->stride = vb->stride; + pipe_vertex_buffer_unreference(real_vb); + real_vb->is_user_buffer = false; continue; } - if (!mgr->caps.user_vertex_buffers && vb->user_buffer) { + if (!mgr->caps.user_vertex_buffers && vb->is_user_buffer) { user_vb_mask |= 1 << dst_index; - pipe_resource_reference(&real_vb->buffer, NULL); + real_vb->buffer_offset = vb->buffer_offset; + real_vb->stride = vb->stride; + pipe_vertex_buffer_unreference(real_vb); + real_vb->is_user_buffer = false; continue; } - pipe_resource_reference(&real_vb->buffer, vb->buffer); - real_vb->user_buffer = vb->user_buffer; + pipe_vertex_buffer_reference(real_vb, vb); } mgr->user_vb_mask |= user_vb_mask; @@ -933,7 +932,7 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr, continue; } - if (!vb->user_buffer) { + if (!vb->is_user_buffer) { continue; } @@ -983,11 +982,11 @@ u_vbuf_upload_buffers(struct u_vbuf *mgr, assert(start < end); real_vb = &mgr->real_vertex_buffer[i]; - ptr = mgr->vertex_buffer[i].user_buffer; + ptr = mgr->vertex_buffer[i].buffer.user; - u_upload_data(mgr->pipe->stream_uploader, start, end - start, 4, ptr + start, - &real_vb->buffer_offset, &real_vb->buffer); - if (!real_vb->buffer) + u_upload_data(mgr->pipe->stream_uploader, start, end - start, 4, + ptr + start, &real_vb->buffer_offset, &real_vb->buffer.resource); + if (!real_vb->buffer.resource) return PIPE_ERROR_OUT_OF_MEMORY; real_vb->buffer_offset -= start; @@ -1320,16 +1319,13 @@ void u_vbuf_restore_vertex_elements(struct u_vbuf *mgr) void u_vbuf_save_aux_vertex_buffer_slot(struct u_vbuf *mgr) { - struct pipe_vertex_buffer *vb = - &mgr->vertex_buffer[mgr->aux_vertex_buffer_slot]; - - pipe_resource_reference(&mgr->aux_vertex_buffer_saved.buffer, vb->buffer); - memcpy(&mgr->aux_vertex_buffer_saved, vb, sizeof(*vb)); + pipe_vertex_buffer_reference(&mgr->aux_vertex_buffer_saved, + &mgr->vertex_buffer[mgr->aux_vertex_buffer_slot]); } void u_vbuf_restore_aux_vertex_buffer_slot(struct u_vbuf *mgr) { u_vbuf_set_vertex_buffers(mgr, mgr->aux_vertex_buffer_slot, 1, &mgr->aux_vertex_buffer_saved); - pipe_resource_reference(&mgr->aux_vertex_buffer_saved.buffer, NULL); + pipe_vertex_buffer_unreference(&mgr->aux_vertex_buffer_saved); } diff --git a/src/gallium/auxiliary/vl/vl_bicubic_filter.c b/src/gallium/auxiliary/vl/vl_bicubic_filter.c index efd8a1c7aec..a3dc6c8c5cf 100644 --- a/src/gallium/auxiliary/vl/vl_bicubic_filter.c +++ b/src/gallium/auxiliary/vl/vl_bicubic_filter.c @@ -295,7 +295,7 @@ vl_bicubic_filter_init(struct vl_bicubic_filter *filter, struct pipe_context *pi goto error_sampler; filter->quad = vl_vb_upload_quads(pipe); - if(!filter->quad.buffer) + if(!filter->quad.buffer.resource) goto error_quad; memset(&ve, 0, sizeof(ve)); @@ -349,7 +349,7 @@ error_vs: pipe->delete_vertex_elements_state(pipe, filter->ves); error_ves: - pipe_resource_reference(&filter->quad.buffer, NULL); + pipe_resource_reference(&filter->quad.buffer.resource, NULL); error_quad: pipe->delete_sampler_state(pipe, filter->sampler); @@ -373,7 +373,7 @@ vl_bicubic_filter_cleanup(struct vl_bicubic_filter *filter) filter->pipe->delete_blend_state(filter->pipe, filter->blend); filter->pipe->delete_rasterizer_state(filter->pipe, filter->rs_state); filter->pipe->delete_vertex_elements_state(filter->pipe, filter->ves); - pipe_resource_reference(&filter->quad.buffer, NULL); + pipe_resource_reference(&filter->quad.buffer.resource, NULL); filter->pipe->delete_vs_state(filter->pipe, filter->vs); filter->pipe->delete_fs_state(filter->pipe, filter->fs); diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index 693d685cd0b..a79bf112646 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -605,7 +605,8 @@ init_buffers(struct vl_compositor *c) */ c->vertex_buf.stride = sizeof(struct vertex2f) + sizeof(struct vertex4f) * 2; c->vertex_buf.buffer_offset = 0; - c->vertex_buf.buffer = NULL; + c->vertex_buf.buffer.resource = NULL; + c->vertex_buf.is_user_buffer = false; vertex_elems[0].src_offset = 0; vertex_elems[0].instance_divisor = 0; @@ -630,7 +631,7 @@ cleanup_buffers(struct vl_compositor *c) assert(c); c->pipe->delete_vertex_elements_state(c->pipe, c->vertex_elems_state); - pipe_resource_reference(&c->vertex_buf.buffer, NULL); + pipe_resource_reference(&c->vertex_buf.buffer.resource, NULL); } static inline struct u_rect @@ -812,7 +813,7 @@ gen_vertex_data(struct vl_compositor *c, struct vl_compositor_state *s, struct u u_upload_alloc(c->pipe->stream_uploader, 0, c->vertex_buf.stride * VL_COMPOSITOR_MAX_LAYERS * 4, /* size */ 4, /* alignment */ - &c->vertex_buf.buffer_offset, &c->vertex_buf.buffer, + &c->vertex_buf.buffer_offset, &c->vertex_buf.buffer.resource, (void**)&vb); for (i = 0; i < VL_COMPOSITOR_MAX_LAYERS; i++) { diff --git a/src/gallium/auxiliary/vl/vl_deint_filter.c b/src/gallium/auxiliary/vl/vl_deint_filter.c index 2eec5cbcd32..d2c48bda7f9 100644 --- a/src/gallium/auxiliary/vl/vl_deint_filter.c +++ b/src/gallium/auxiliary/vl/vl_deint_filter.c @@ -308,7 +308,7 @@ vl_deint_filter_init(struct vl_deint_filter *filter, struct pipe_context *pipe, goto error_sampler; filter->quad = vl_vb_upload_quads(pipe); - if(!filter->quad.buffer) + if(!filter->quad.buffer.resource) goto error_quad; memset(&ve, 0, sizeof(ve)); @@ -361,7 +361,7 @@ error_vs: pipe->delete_vertex_elements_state(pipe, filter->ves); error_ves: - pipe_resource_reference(&filter->quad.buffer, NULL); + pipe_resource_reference(&filter->quad.buffer.resource, NULL); error_quad: pipe->delete_sampler_state(pipe, filter->sampler); @@ -396,7 +396,7 @@ vl_deint_filter_cleanup(struct vl_deint_filter *filter) filter->pipe->delete_blend_state(filter->pipe, filter->blend[2]); filter->pipe->delete_rasterizer_state(filter->pipe, filter->rs_state); filter->pipe->delete_vertex_elements_state(filter->pipe, filter->ves); - pipe_resource_reference(&filter->quad.buffer, NULL); + pipe_resource_reference(&filter->quad.buffer.resource, NULL); filter->pipe->delete_vs_state(filter->pipe, filter->vs); filter->pipe->delete_fs_state(filter->pipe, filter->fs_copy_top); diff --git a/src/gallium/auxiliary/vl/vl_matrix_filter.c b/src/gallium/auxiliary/vl/vl_matrix_filter.c index b498d1f1db2..1dacc7c6025 100644 --- a/src/gallium/auxiliary/vl/vl_matrix_filter.c +++ b/src/gallium/auxiliary/vl/vl_matrix_filter.c @@ -184,7 +184,7 @@ vl_matrix_filter_init(struct vl_matrix_filter *filter, struct pipe_context *pipe goto error_sampler; filter->quad = vl_vb_upload_quads(pipe); - if(!filter->quad.buffer) + if(!filter->quad.buffer.resource) goto error_quad; memset(&ve, 0, sizeof(ve)); @@ -233,7 +233,7 @@ error_offsets: pipe->delete_vertex_elements_state(pipe, filter->ves); error_ves: - pipe_resource_reference(&filter->quad.buffer, NULL); + pipe_resource_reference(&filter->quad.buffer.resource, NULL); error_quad: pipe->delete_sampler_state(pipe, filter->sampler); @@ -257,7 +257,7 @@ vl_matrix_filter_cleanup(struct vl_matrix_filter *filter) filter->pipe->delete_blend_state(filter->pipe, filter->blend); filter->pipe->delete_rasterizer_state(filter->pipe, filter->rs_state); filter->pipe->delete_vertex_elements_state(filter->pipe, filter->ves); - pipe_resource_reference(&filter->quad.buffer, NULL); + pipe_resource_reference(&filter->quad.buffer.resource, NULL); filter->pipe->delete_vs_state(filter->pipe, filter->vs); filter->pipe->delete_fs_state(filter->pipe, filter->fs); diff --git a/src/gallium/auxiliary/vl/vl_median_filter.c b/src/gallium/auxiliary/vl/vl_median_filter.c index 0183b875871..273afaf2fb2 100644 --- a/src/gallium/auxiliary/vl/vl_median_filter.c +++ b/src/gallium/auxiliary/vl/vl_median_filter.c @@ -295,7 +295,7 @@ vl_median_filter_init(struct vl_median_filter *filter, struct pipe_context *pipe goto error_sampler; filter->quad = vl_vb_upload_quads(pipe); - if(!filter->quad.buffer) + if(!filter->quad.buffer.resource) goto error_quad; memset(&ve, 0, sizeof(ve)); @@ -337,7 +337,7 @@ error_offsets: pipe->delete_vertex_elements_state(pipe, filter->ves); error_ves: - pipe_resource_reference(&filter->quad.buffer, NULL); + pipe_resource_reference(&filter->quad.buffer.resource, NULL); error_quad: pipe->delete_sampler_state(pipe, filter->sampler); @@ -361,7 +361,7 @@ vl_median_filter_cleanup(struct vl_median_filter *filter) filter->pipe->delete_blend_state(filter->pipe, filter->blend); filter->pipe->delete_rasterizer_state(filter->pipe, filter->rs_state); filter->pipe->delete_vertex_elements_state(filter->pipe, filter->ves); - pipe_resource_reference(&filter->quad.buffer, NULL); + pipe_resource_reference(&filter->quad.buffer.resource, NULL); filter->pipe->delete_vs_state(filter->pipe, filter->vs); filter->pipe->delete_fs_state(filter->pipe, filter->fs); diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index db62b44f563..8a2dae34e35 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -509,8 +509,8 @@ vl_mpeg12_destroy(struct pipe_video_codec *decoder) dec->context->delete_vertex_elements_state(dec->context, dec->ves_ycbcr); dec->context->delete_vertex_elements_state(dec->context, dec->ves_mv); - pipe_resource_reference(&dec->quads.buffer, NULL); - pipe_resource_reference(&dec->pos.buffer, NULL); + pipe_resource_reference(&dec->quads.buffer.resource, NULL); + pipe_resource_reference(&dec->pos.buffer.resource, NULL); pipe_sampler_view_reference(&dec->zscan_linear, NULL); pipe_sampler_view_reference(&dec->zscan_normal, NULL); diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.c b/src/gallium/auxiliary/vl/vl_vertex_buffers.c index 17212278f1a..45a9badce21 100644 --- a/src/gallium/auxiliary/vl/vl_vertex_buffers.c +++ b/src/gallium/auxiliary/vl/vl_vertex_buffers.c @@ -49,23 +49,23 @@ vl_vb_upload_quads(struct pipe_context *pipe) /* create buffer */ quad.stride = sizeof(struct vertex2f); quad.buffer_offset = 0; - quad.buffer = pipe_buffer_create + quad.buffer.resource = pipe_buffer_create ( pipe->screen, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_DEFAULT, sizeof(struct vertex2f) * 4 ); - quad.user_buffer = NULL; + quad.is_user_buffer = false; - if(!quad.buffer) + if(!quad.buffer.resource) return quad; /* and fill it */ v = pipe_buffer_map ( pipe, - quad.buffer, + quad.buffer.resource, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &buf_transfer ); @@ -94,23 +94,23 @@ vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height) /* create buffer */ pos.stride = sizeof(struct vertex2s); pos.buffer_offset = 0; - pos.buffer = pipe_buffer_create + pos.buffer.resource = pipe_buffer_create ( pipe->screen, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_DEFAULT, sizeof(struct vertex2s) * width * height ); - pos.user_buffer = NULL; + pos.is_user_buffer = false; - if(!pos.buffer) + if(!pos.buffer.resource) return pos; /* and fill it */ v = pipe_buffer_map ( pipe, - pos.buffer, + pos.buffer.resource, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &buf_transfer ); @@ -268,8 +268,8 @@ vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component) buf.stride = sizeof(struct vl_ycbcr_block); buf.buffer_offset = 0; - buf.buffer = buffer->ycbcr[component].resource; - buf.user_buffer = NULL; + buf.buffer.resource = buffer->ycbcr[component].resource; + buf.is_user_buffer = false; return buf; } @@ -283,8 +283,8 @@ vl_vb_get_mv(struct vl_vertex_buffer *buffer, int motionvector) buf.stride = sizeof(struct vl_motionvector); buf.buffer_offset = 0; - buf.buffer = buffer->mv[motionvector].resource; - buf.user_buffer = NULL; + buf.buffer.resource = buffer->mv[motionvector].resource; + buf.is_user_buffer = false; return buf; } |