X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Futil%2Fu_inlines.h;h=79f62c322666f95ccd4cc49396eb3f5c0f657fc0;hb=1b592d30c51696eeeadca7a55b603c543dfdc3cf;hp=90821b29de20f7027a405cb319aaf2d8791e51a2;hpb=9d881cc0ac8f08f839dd86f6aeaf6c7bca97ccb1;p=mesa.git diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 90821b29de2..79f62c32266 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -136,8 +136,16 @@ pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex) 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; } @@ -185,6 +193,25 @@ pipe_so_target_reference(struct pipe_stream_output_target **ptr, *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) @@ -339,25 +366,8 @@ pipe_buffer_write(struct pipe_context *pipe, 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); } /** @@ -372,18 +382,10 @@ pipe_buffer_write_nooverlap(struct pipe_context *pipe, 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); } @@ -481,7 +483,8 @@ pipe_transfer_unmap( struct pipe_context *context, } 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) { @@ -533,7 +536,9 @@ util_query_clear_result(union pipe_query_result *result, unsigned type) { 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; @@ -559,7 +564,7 @@ util_query_clear_result(union pipe_query_result *result, unsigned type) } /** 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) { @@ -626,10 +631,17 @@ static inline void 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