struct pipe_resource *old_tex = *ptr;
if (pipe_reference_described(&(*ptr)->reference, &tex->reference,
- (debug_reference_descriptor)debug_describe_resource))
+ (debug_reference_descriptor)debug_describe_resource)) {
+ pipe_resource_reference(&old_tex->next, NULL);
old_tex->screen->resource_destroy(old_tex->screen, old_tex);
+ }
*ptr = tex;
}
/**
* Create a new resource.
* \param bind bitmask of PIPE_BIND_x flags
- * \param usage bitmask of PIPE_USAGE_x flags
+ * \param usage a PIPE_USAGE_x value
*/
static inline struct pipe_resource *
pipe_buffer_create( struct pipe_screen *screen,
unsigned bind,
- unsigned usage,
+ enum pipe_resource_usage usage,
unsigned size )
{
struct pipe_resource buffer;
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 struct pipe_resource *
pipe_buffer_create_with_data(struct pipe_context *pipe,
unsigned bind,
- unsigned usage,
+ enum pipe_resource_usage usage,
unsigned size,
const void *ptr)
{
}
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) {
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
}
}
-static inline unsigned
-util_pipe_shader_from_tgsi_processor(unsigned processor)
-{
- switch (processor) {
- case TGSI_PROCESSOR_VERTEX:
- return PIPE_SHADER_VERTEX;
- case TGSI_PROCESSOR_TESS_CTRL:
- return PIPE_SHADER_TESS_CTRL;
- case TGSI_PROCESSOR_TESS_EVAL:
- return PIPE_SHADER_TESS_EVAL;
- case TGSI_PROCESSOR_GEOMETRY:
- return PIPE_SHADER_GEOMETRY;
- case TGSI_PROCESSOR_FRAGMENT:
- return PIPE_SHADER_FRAGMENT;
- case TGSI_PROCESSOR_COMPUTE:
- return PIPE_SHADER_COMPUTE;
- default:
- assert(0);
- return PIPE_SHADER_VERTEX;
- }
+static inline bool
+util_texrange_covers_whole_level(const struct pipe_resource *tex,
+ unsigned level, unsigned x, unsigned y,
+ unsigned z, unsigned width,
+ unsigned height, unsigned depth)
+{
+ return x == 0 && y == 0 && z == 0 &&
+ width == u_minify(tex->width0, level) &&
+ height == u_minify(tex->height0, level) &&
+ depth == util_max_layer(tex, level) + 1;
}
#ifdef __cplusplus