struct pipe_resource *old_tex = *ptr;
if (pipe_reference_described(&(*ptr)->reference, &tex->reference,
- (debug_reference_descriptor)debug_describe_resource))
- old_tex->screen->resource_destroy(old_tex->screen, old_tex);
+ (debug_reference_descriptor)debug_describe_resource)) {
+ /* Avoid recursion, which would prevent inlining this function */
+ do {
+ struct pipe_resource *next = old_tex->next;
+
+ old_tex->screen->resource_destroy(old_tex->screen, old_tex);
+ old_tex = next;
+ } while (pipe_reference_described(&old_tex->reference, NULL,
+ (debug_reference_descriptor)debug_describe_resource));
+ }
*ptr = tex;
}
*ptr = target;
}
+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)
unsigned size,
const void *data)
{
- struct pipe_box box;
- unsigned access = PIPE_TRANSFER_WRITE;
-
- if (offset == 0 && size == buf->width0) {
- access |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
- } else {
- access |= PIPE_TRANSFER_DISCARD_RANGE;
- }
-
- u_box_1d(offset, size, &box);
-
- pipe->transfer_inline_write( pipe,
- buf,
- 0,
- access,
- &box,
- data,
- size,
- 0);
+ /* Don't set any other usage bits. Drivers should derive them. */
+ pipe->buffer_subdata(pipe, buf, PIPE_TRANSFER_WRITE, offset, size, data);
}
/**
unsigned offset, unsigned size,
const void *data)
{
- struct pipe_box box;
-
- u_box_1d(offset, size, &box);
-
- pipe->transfer_inline_write(pipe,
- buf,
- 0,
- (PIPE_TRANSFER_WRITE |
- PIPE_TRANSFER_UNSYNCHRONIZED),
- &box,
- data,
- 0, 0);
+ pipe->buffer_subdata(pipe, buf,
+ (PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_UNSYNCHRONIZED),
+ offset, size, data);
}
}
static inline void
-pipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
+pipe_set_constant_buffer(struct pipe_context *pipe,
+ enum pipe_shader_type shader, uint index,
struct pipe_resource *buf)
{
if (buf) {
{
switch (type) {
case PIPE_QUERY_OCCLUSION_PREDICATE:
+ case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
+ case PIPE_QUERY_SO_OVERFLOW_ANY_PREDICATE:
case PIPE_QUERY_GPU_FINISHED:
result->b = FALSE;
break;
}
/** Convert PIPE_TEXTURE_x to TGSI_TEXTURE_x */
-static inline unsigned
+static inline enum tgsi_texture_type
util_pipe_tex_to_tgsi_tex(enum pipe_texture_target pipe_tex_target,
unsigned nr_samples)
{
util_copy_image_view(struct pipe_image_view *dst,
const struct pipe_image_view *src)
{
- pipe_resource_reference(&dst->resource, src->resource);
- dst->format = src->format;
- dst->access = src->access;
- dst->u = src->u;
+ if (src) {
+ pipe_resource_reference(&dst->resource, src->resource);
+ dst->format = src->format;
+ dst->access = src->access;
+ dst->u = src->u;
+ } else {
+ pipe_resource_reference(&dst->resource, NULL);
+ dst->format = PIPE_FORMAT_NONE;
+ dst->access = 0;
+ memset(&dst->u, 0, sizeof(dst->u));
+ }
}
static inline unsigned