diff options
Diffstat (limited to 'src/mesa/state_tracker')
28 files changed, 426 insertions, 380 deletions
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index d975cd66f7d..5ac81bd4ee2 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -57,7 +57,7 @@ void st_upload_constants( struct st_context *st, unsigned shader_type) { struct pipe_context *pipe = st->pipe; - struct pipe_buffer **cbuf = &st->state.constants[shader_type]; + struct pipe_resource **cbuf = &st->state.constants[shader_type]; assert(shader_type == PIPE_SHADER_VERTEX || shader_type == PIPE_SHADER_FRAGMENT); @@ -71,10 +71,10 @@ void st_upload_constants( struct st_context *st, /* We always need to get a new buffer, to keep the drivers simple and * avoid gratuitous rendering synchronization. */ - pipe_buffer_reference(cbuf, NULL ); - *cbuf = pipe_buffer_create(pipe->screen, 16, - PIPE_BUFFER_USAGE_CONSTANT, - paramBytes ); + pipe_resource_reference(cbuf, NULL ); + *cbuf = pipe_buffer_create(pipe->screen, + PIPE_BIND_CONSTANT_BUFFER, + paramBytes ); if (ST_DEBUG & DEBUG_CONSTANTS) { debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n", diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 79ad70909a9..d33ddc83f64 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -45,7 +45,7 @@ /** * When doing GL render to texture, we have to be sure that finalize_texture() - * didn't yank out the pipe_texture that we earlier created a surface for. + * didn't yank out the pipe_resource that we earlier created a surface for. * Check for that here and create a new surface if needed. */ static void @@ -53,29 +53,30 @@ update_renderbuffer_surface(struct st_context *st, struct st_renderbuffer *strb) { struct pipe_screen *screen = st->pipe->screen; - struct pipe_texture *texture = strb->rtt->pt; + struct pipe_resource *resource = strb->rtt->pt; int rtt_width = strb->Base.Width; int rtt_height = strb->Base.Height; if (!strb->surface || - strb->surface->texture != texture || + strb->surface->texture != resource || strb->surface->width != rtt_width || strb->surface->height != rtt_height) { GLuint level; /* find matching mipmap level size */ - for (level = 0; level <= texture->last_level; level++) { - if (u_minify(texture->width0, level) == rtt_width && - u_minify(texture->height0, level) == rtt_height) { + for (level = 0; level <= resource->last_level; level++) { + if (u_minify(resource->width0, level) == rtt_width && + u_minify(resource->height0, level) == rtt_height) { pipe_surface_reference(&strb->surface, NULL); strb->surface = screen->get_tex_surface(screen, - texture, - strb->rtt_face, - level, - strb->rtt_slice, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); + resource, + strb->rtt_face, + level, + strb->rtt_slice, + PIPE_BIND_RENDER_TARGET | + PIPE_BIND_BLIT_SOURCE | + PIPE_BIND_BLIT_DESTINATION ); #if 0 printf("-- alloc new surface %d x %d into tex %p\n", strb->surface->width, strb->surface->height, diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index 03e33361448..4aac5bd97fe 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -112,21 +112,21 @@ make_state_key(GLcontext *ctx, struct state_key *key) } -static struct pipe_texture * +static struct pipe_resource * create_color_map_texture(GLcontext *ctx) { struct pipe_context *pipe = ctx->st->pipe; - struct pipe_texture *pt; + struct pipe_resource *pt; enum pipe_format format; const uint texSize = 256; /* simple, and usually perfect */ /* find an RGBA texture format */ format = st_choose_format(pipe->screen, GL_RGBA, - PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER); + PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); /* create texture for color map/table */ pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0, - texSize, texSize, 1, PIPE_TEXTURE_USAGE_SAMPLER); + texSize, texSize, 1, PIPE_BIND_SAMPLER_VIEW); return pt; } @@ -135,7 +135,7 @@ create_color_map_texture(GLcontext *ctx) * Update the pixelmap texture with the contents of the R/G/B/A pixel maps. */ static void -load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt) +load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt) { struct pipe_context *pipe = ctx->st->pipe; struct pipe_transfer *transfer; @@ -150,7 +150,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt) transfer = st_cond_flush_get_tex_transfer(st_context(ctx), pt, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, texSize, texSize); - dest = (uint *) pipe->transfer_map(pipe, transfer); + dest = (uint *) pipe_transfer_map(pipe, transfer); /* Pack four 1D maps into a 2D texture: * R map is placed horizontally, indexed by S, in channel 0 @@ -171,8 +171,8 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt) } } - pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(pipe, transfer); + pipe_transfer_unmap(pipe, transfer); + pipe->transfer_destroy(pipe, transfer); } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 01aba3e3dd4..a693141921f 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -137,7 +137,8 @@ accum_accum(struct st_context *st, GLfloat value, if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); - color_trans = st_cond_flush_get_tex_transfer(st, color_strb->texture, + color_trans = st_cond_flush_get_tex_transfer(st, + color_strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, xpos, ypos, width, height); @@ -165,7 +166,7 @@ accum_accum(struct st_context *st, GLfloat value, } free(buf); - pipe->tex_transfer_destroy(pipe, color_trans); + pipe->transfer_destroy(pipe, color_trans); } @@ -213,7 +214,7 @@ accum_load(struct st_context *st, GLfloat value, } free(buf); - pipe->tex_transfer_destroy(pipe, color_trans); + pipe->transfer_destroy(pipe, color_trans); } @@ -280,7 +281,7 @@ accum_return(GLcontext *ctx, GLfloat value, pipe_put_tile_rgba(pipe, color_trans, 0, 0, width, height, buf); free(buf); - pipe->tex_transfer_destroy(pipe, color_trans); + pipe->transfer_destroy(pipe, color_trans); } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 9a0446bb710..074fc277110 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -92,7 +92,7 @@ struct bitmap_cache /** Bitmap's Z position */ GLfloat zpos; - struct pipe_texture *texture; + struct pipe_resource *texture; struct pipe_transfer *trans; GLboolean empty; @@ -253,7 +253,7 @@ unpack_bitmap(struct st_context *st, /** * Create a texture which represents a bitmap image. */ -static struct pipe_texture * +static struct pipe_resource * make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap) @@ -261,7 +261,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, struct pipe_context *pipe = ctx->st->pipe; struct pipe_transfer *transfer; ubyte *dest; - struct pipe_texture *pt; + struct pipe_resource *pt; /* PBO source... */ bitmap = _mesa_map_pbo_source(ctx, unpack, bitmap); @@ -274,7 +274,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, */ pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, ctx->st->bitmap.tex_format, 0, width, height, 1, - PIPE_TEXTURE_USAGE_SAMPLER); + PIPE_BIND_SAMPLER_VIEW); if (!pt) { _mesa_unmap_pbo_source(ctx, unpack); return NULL; @@ -284,7 +284,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, PIPE_TRANSFER_WRITE, 0, 0, width, height); - dest = pipe->transfer_map(pipe, transfer); + dest = pipe_transfer_map(pipe, transfer); /* Put image into texture transfer */ memset(dest, 0xff, height * transfer->stride); @@ -294,8 +294,8 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, _mesa_unmap_pbo_source(ctx, unpack); /* Release transfer */ - pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(pipe, transfer); + pipe_transfer_unmap(pipe, transfer); + pipe->transfer_destroy(pipe, transfer); return pt; } @@ -334,13 +334,13 @@ setup_bitmap_vertex_data(struct st_context *st, GLuint i; if (st->bitmap.vbuf_slot >= max_slots) { - pipe_buffer_reference(&st->bitmap.vbuf, NULL); + pipe_resource_reference(&st->bitmap.vbuf, NULL); st->bitmap.vbuf_slot = 0; } if (!st->bitmap.vbuf) { - st->bitmap.vbuf = pipe_buffer_create(pipe->screen, 32, - PIPE_BUFFER_USAGE_VERTEX, + st->bitmap.vbuf = pipe_buffer_create(pipe->screen, + PIPE_BIND_VERTEX_BUFFER, max_slots * sizeof(st->bitmap.vertices)); } @@ -530,7 +530,7 @@ reset_cache(struct st_context *st) cache->ymax = -1000000; if (cache->trans) { - pipe->tex_transfer_destroy(pipe, cache->trans); + pipe->transfer_destroy(pipe, cache->trans); cache->trans = NULL; } @@ -540,7 +540,8 @@ reset_cache(struct st_context *st) cache->texture = st_texture_create(st, PIPE_TEXTURE_2D, st->bitmap.tex_format, 0, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, - 1, PIPE_TEXTURE_USAGE_SAMPLER); + 1, + PIPE_BIND_SAMPLER_VIEW); } @@ -580,7 +581,7 @@ create_cache_trans(struct st_context *st) PIPE_TRANSFER_WRITE, 0, 0, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT); - cache->buffer = pipe->transfer_map(pipe, cache->trans); + cache->buffer = pipe_transfer_map(pipe, cache->trans); /* init image to all 0xff */ memset(cache->buffer, 0xff, cache->trans->stride * BITMAP_CACHE_HEIGHT); @@ -614,10 +615,10 @@ st_flush_bitmap_cache(struct st_context *st) if (cache->trans) { if (0) print_cache(cache); - pipe->transfer_unmap(pipe, cache->trans); + pipe_transfer_unmap(pipe, cache->trans); cache->buffer = NULL; - pipe->tex_transfer_destroy(pipe, cache->trans); + pipe->transfer_destroy(pipe, cache->trans); cache->trans = NULL; } @@ -636,7 +637,7 @@ st_flush_bitmap_cache(struct st_context *st) } /* release/free the texture */ - pipe_texture_reference(&cache->texture, NULL); + pipe_resource_reference(&cache->texture, NULL); reset_cache(st); } @@ -652,7 +653,7 @@ st_flush_bitmap( struct st_context *st ) /* Release vertex buffer to avoid synchronous rendering if we were * to map it in the next frame. */ - pipe_buffer_reference(&st->bitmap.vbuf, NULL); + pipe_resource_reference(&st->bitmap.vbuf, NULL); st->bitmap.vbuf_slot = 0; } @@ -732,7 +733,7 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap ) { struct st_context *st = ctx->st; - struct pipe_texture *pt; + struct pipe_resource *pt; if (width == 0 || height == 0) return; @@ -768,7 +769,7 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } /* release/free the texture */ - pipe_texture_reference(&pt, NULL); + pipe_resource_reference(&pt, NULL); } } @@ -805,15 +806,15 @@ st_init_bitmap(struct st_context *st) /* find a usable texture format */ if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0)) { + PIPE_BIND_SAMPLER_VIEW, 0)) { st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM; } else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0)) { + PIPE_BIND_SAMPLER_VIEW, 0)) { st->bitmap.tex_format = PIPE_FORMAT_A8_UNORM; } else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0)) { + PIPE_BIND_SAMPLER_VIEW, 0)) { st->bitmap.tex_format = PIPE_FORMAT_L8_UNORM; } else { @@ -843,16 +844,16 @@ st_destroy_bitmap(struct st_context *st) } if (st->bitmap.vbuf) { - pipe_buffer_reference(&st->bitmap.vbuf, NULL); + pipe_resource_reference(&st->bitmap.vbuf, NULL); st->bitmap.vbuf = NULL; } if (cache) { if (cache->trans) { - pipe->transfer_unmap(pipe, cache->trans); - pipe->tex_transfer_destroy(pipe, cache->trans); + pipe_transfer_unmap(pipe, cache->trans); + pipe->transfer_destroy(pipe, cache->trans); } - pipe_texture_reference(&st->bitmap.cache->texture, NULL); + pipe_resource_reference(&st->bitmap.cache->texture, NULL); free(st->bitmap.cache); st->bitmap.cache = NULL; } diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index 06b0a18fd22..0498080ccfc 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -128,7 +128,7 @@ st_BlitFramebuffer(GLcontext *ctx, srcAtt->CubeMapFace, srcAtt->TextureLevel, srcAtt->Zoffset, - PIPE_BUFFER_USAGE_GPU_READ); + PIPE_BIND_BLIT_SOURCE); if(!srcSurf) return; diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index b55a085cc7c..f24145844b9 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -76,9 +76,10 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj) struct st_buffer_object *st_obj = st_buffer_object(obj); assert(obj->RefCount == 0); + assert(st_obj->transfer == NULL); if (st_obj->buffer) - pipe_buffer_reference(&st_obj->buffer, NULL); + pipe_resource_reference(&st_obj->buffer, NULL); free(st_obj); } @@ -116,8 +117,15 @@ st_bufferobj_subdata(GLcontext *ctx, if (!data) return; - st_cond_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer, - offset, size, data); + /* Now that transfers are per-context, we don't have to figure out + * flushing here. Usually drivers won't need to flush in this case + * even if the buffer is currently referenced by hardware - they + * just queue the upload as dma rather than mapping the underlying + * buffer directly. + */ + pipe_buffer_write(st_context(ctx)->pipe, + st_obj->buffer, + offset, size, data); } @@ -141,8 +149,8 @@ st_bufferobj_get_subdata(GLcontext *ctx, if (!size) return; - st_cond_flush_pipe_buffer_read(st_context(ctx), st_obj->buffer, - offset, size, data); + pipe_buffer_read(st_context(ctx)->pipe, st_obj->buffer, + offset, size, data); } @@ -172,22 +180,24 @@ st_bufferobj_data(GLcontext *ctx, switch(target) { case GL_PIXEL_PACK_BUFFER_ARB: case GL_PIXEL_UNPACK_BUFFER_ARB: - buffer_usage = PIPE_BUFFER_USAGE_PIXEL; + buffer_usage = (PIPE_BIND_RENDER_TARGET | + PIPE_BIND_BLIT_SOURCE | + PIPE_BIND_BLIT_DESTINATION); break; case GL_ARRAY_BUFFER_ARB: - buffer_usage = PIPE_BUFFER_USAGE_VERTEX; + buffer_usage = PIPE_BIND_VERTEX_BUFFER; break; case GL_ELEMENT_ARRAY_BUFFER_ARB: - buffer_usage = PIPE_BUFFER_USAGE_INDEX; + buffer_usage = PIPE_BIND_INDEX_BUFFER; break; default: buffer_usage = 0; } - pipe_buffer_reference( &st_obj->buffer, NULL ); + pipe_resource_reference( &st_obj->buffer, NULL ); if (size != 0) { - st_obj->buffer = pipe_buffer_create(pipe->screen, 32, buffer_usage, size); + st_obj->buffer = pipe_buffer_create(pipe->screen, buffer_usage, size); if (!st_obj->buffer) { return GL_FALSE; @@ -215,21 +225,22 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access, switch (access) { case GL_WRITE_ONLY: - flags = PIPE_BUFFER_USAGE_CPU_WRITE; + flags = PIPE_TRANSFER_WRITE; break; case GL_READ_ONLY: - flags = PIPE_BUFFER_USAGE_CPU_READ; + flags = PIPE_TRANSFER_READ; break; case GL_READ_WRITE: - /* fall-through */ default: - flags = PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE; + flags = PIPE_TRANSFER_READ_WRITE; break; } - obj->Pointer = st_cond_flush_pipe_buffer_map(st_context(ctx), - st_obj->buffer, - flags); + obj->Pointer = pipe_buffer_map(st_context(ctx)->pipe, + st_obj->buffer, + flags, + &st_obj->transfer); + if (obj->Pointer) { obj->Offset = 0; obj->Length = obj->Size; @@ -255,25 +266,25 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target, { struct pipe_context *pipe = st_context(ctx)->pipe; struct st_buffer_object *st_obj = st_buffer_object(obj); - uint flags = 0x0; + enum pipe_transfer_usage flags = 0x0; if (access & GL_MAP_WRITE_BIT) - flags |= PIPE_BUFFER_USAGE_CPU_WRITE; + flags |= PIPE_TRANSFER_WRITE; if (access & GL_MAP_READ_BIT) - flags |= PIPE_BUFFER_USAGE_CPU_READ; + flags |= PIPE_TRANSFER_READ; if (access & GL_MAP_FLUSH_EXPLICIT_BIT) - flags |= PIPE_BUFFER_USAGE_FLUSH_EXPLICIT; + flags |= PIPE_TRANSFER_FLUSH_EXPLICIT; if (access & GL_MAP_UNSYNCHRONIZED_BIT) - flags |= PIPE_BUFFER_USAGE_UNSYNCHRONIZED; + flags |= PIPE_TRANSFER_UNSYNCHRONIZED; /* ... other flags ... */ if (access & MESA_MAP_NOWAIT_BIT) - flags |= PIPE_BUFFER_USAGE_DONTBLOCK; + flags |= PIPE_TRANSFER_DONTBLOCK; assert(offset >= 0); assert(length >= 0); @@ -288,7 +299,11 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target, obj->Pointer = &st_bufferobj_zero_length_range; } else { - obj->Pointer = pipe_buffer_map_range(pipe->screen, st_obj->buffer, offset, length, flags); + obj->Pointer = pipe_buffer_map_range(pipe, + st_obj->buffer, + offset, length, + flags, + &st_obj->transfer); if (obj->Pointer) { obj->Pointer = (ubyte *) obj->Pointer + offset; } @@ -316,11 +331,12 @@ st_bufferobj_flush_mapped_range(GLcontext *ctx, GLenum target, assert(offset >= 0); assert(length >= 0); assert(offset + length <= obj->Length); + assert(obj->Pointer); if (!length) return; - pipe_buffer_flush_mapped_range(pipe->screen, st_obj->buffer, + pipe_buffer_flush_mapped_range(pipe, st_obj->transfer, obj->Offset + offset, length); } @@ -334,9 +350,10 @@ st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj) struct pipe_context *pipe = st_context(ctx)->pipe; struct st_buffer_object *st_obj = st_buffer_object(obj); - if(obj->Length) - pipe_buffer_unmap(pipe->screen, st_obj->buffer); + if (obj->Length) + pipe_buffer_unmap(pipe, st_obj->buffer, st_obj->transfer); + st_obj->transfer = NULL; obj->Pointer = NULL; obj->Offset = 0; obj->Length = 0; @@ -357,6 +374,8 @@ st_copy_buffer_subdata(GLcontext *ctx, struct pipe_context *pipe = st_context(ctx)->pipe; struct st_buffer_object *srcObj = st_buffer_object(src); struct st_buffer_object *dstObj = st_buffer_object(dst); + struct pipe_transfer *src_transfer; + struct pipe_transfer *dst_transfer; ubyte *srcPtr, *dstPtr; if(!size) @@ -366,21 +385,36 @@ st_copy_buffer_subdata(GLcontext *ctx, assert(!src->Pointer); assert(!dst->Pointer); - srcPtr = (ubyte *) pipe_buffer_map_range(pipe->screen, + srcPtr = (ubyte *) pipe_buffer_map_range(pipe, srcObj->buffer, readOffset, size, - PIPE_BUFFER_USAGE_CPU_READ); + PIPE_TRANSFER_READ, + &src_transfer); - dstPtr = (ubyte *) pipe_buffer_map_range(pipe->screen, + dstPtr = (ubyte *) pipe_buffer_map_range(pipe, dstObj->buffer, writeOffset, size, - PIPE_BUFFER_USAGE_CPU_WRITE); + PIPE_TRANSFER_WRITE, + &dst_transfer); if (srcPtr && dstPtr) memcpy(dstPtr + writeOffset, srcPtr + readOffset, size); - pipe_buffer_unmap(pipe->screen, srcObj->buffer); - pipe_buffer_unmap(pipe->screen, dstObj->buffer); + pipe_buffer_unmap(pipe, srcObj->buffer, src_transfer); + pipe_buffer_unmap(pipe, dstObj->buffer, dst_transfer); +} + + +/* TODO: if buffer wasn't created with appropriate usage flags, need + * to recreate it now and copy contents -- or possibly create a + * gallium entrypoint to extend the usage flags and let the driver + * decide if a copy is necessary. + */ +void +st_bufferobj_validate_usage(struct st_context *st, + struct st_buffer_object *obj, + unsigned usage) +{ } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.h b/src/mesa/state_tracker/st_cb_bufferobjects.h index fda6d05dd34..955673ceb66 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.h +++ b/src/mesa/state_tracker/st_cb_bufferobjects.h @@ -30,7 +30,7 @@ struct st_context; struct gl_buffer_object; -struct pipe_buffer; +struct pipe_resource; /** * State_tracker vertex/pixel buffer object, derived from Mesa's @@ -39,7 +39,8 @@ struct pipe_buffer; struct st_buffer_object { struct gl_buffer_object Base; - struct pipe_buffer *buffer; + struct pipe_resource *buffer; /* GPU storage */ + struct pipe_transfer *transfer; /* In-progress map information */ }; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 6007c767182..eb9ba0557d3 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -99,7 +99,7 @@ st_destroy_clear(struct st_context *st) st->clear.vs = NULL; } if (st->clear.vbuf) { - pipe_buffer_reference(&st->clear.vbuf, NULL); + pipe_resource_reference(&st->clear.vbuf, NULL); st->clear.vbuf = NULL; } } @@ -131,13 +131,13 @@ draw_quad(GLcontext *ctx, GLuint i; if (st->clear.vbuf_slot >= max_slots) { - pipe_buffer_reference(&st->clear.vbuf, NULL); + pipe_resource_reference(&st->clear.vbuf, NULL); st->clear.vbuf_slot = 0; } if (!st->clear.vbuf) { - st->clear.vbuf = pipe_buffer_create(pipe->screen, 32, - PIPE_BUFFER_USAGE_VERTEX, + st->clear.vbuf = pipe_buffer_create(pipe->screen, + PIPE_BIND_VERTEX_BUFFER, max_slots * sizeof(st->clear.vertices)); } @@ -435,7 +435,7 @@ st_flush_clear(struct st_context *st) /* Release vertex buffer to avoid synchronous rendering if we were * to map it in the next frame. */ - pipe_buffer_reference(&st->clear.vbuf, NULL); + pipe_resource_reference(&st->clear.vbuf, NULL); st->clear.vbuf_slot = 0; } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 93b95a534c7..955e371398d 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -296,13 +296,13 @@ base_format(GLenum format) * If width, height are not POT and the driver only handles POT textures, * allocate the next larger size of texture that is POT. */ -static struct pipe_texture * +static struct pipe_resource * alloc_texture(struct st_context *st, GLsizei width, GLsizei height, enum pipe_format texFormat) { struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_texture *pt; + struct pipe_resource *pt; int ptw, pth; ptw = width; @@ -330,7 +330,7 @@ alloc_texture(struct st_context *st, GLsizei width, GLsizei height, } pt = st_texture_create(st, PIPE_TEXTURE_2D, texFormat, 0, - ptw, pth, 1, PIPE_TEXTURE_USAGE_SAMPLER); + ptw, pth, 1, PIPE_BIND_SAMPLER_VIEW); return pt; } @@ -340,7 +340,7 @@ alloc_texture(struct st_context *st, GLsizei width, GLsizei height, * Make texture containing an image for glDrawPixels image. * If 'pixels' is NULL, leave the texture image data undefined. */ -static struct pipe_texture * +static struct pipe_resource * make_texture(struct st_context *st, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, @@ -349,7 +349,7 @@ make_texture(struct st_context *st, GLcontext *ctx = st->ctx; struct pipe_context *pipe = st->pipe; gl_format mformat; - struct pipe_texture *pt; + struct pipe_resource *pt; enum pipe_format pipeFormat; GLuint cpp; GLenum baseFormat; @@ -389,7 +389,7 @@ make_texture(struct st_context *st, width, height); /* map texture transfer */ - dest = pipe->transfer_map(pipe, transfer); + dest = pipe_transfer_map(pipe, transfer); /* Put image into texture transfer. @@ -409,8 +409,8 @@ make_texture(struct st_context *st, unpack); /* unmap */ - pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(pipe, transfer); + pipe_transfer_unmap(pipe, transfer); + pipe->transfer_destroy(pipe, transfer); assert(success); @@ -502,10 +502,11 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, } { - struct pipe_buffer *buf; + struct pipe_resource *buf; /* allocate/load buffer object with vertex data */ - buf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX, + buf = pipe_buffer_create(pipe->screen, + PIPE_BIND_VERTEX_BUFFER, sizeof(verts)); st_no_flush_pipe_buffer_write(st, buf, 0, sizeof(verts), verts); @@ -513,7 +514,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, PIPE_PRIM_QUADS, 4, /* verts */ 3); /* attribs/vert */ - pipe_buffer_reference(&buf, NULL); + pipe_resource_reference(&buf, NULL); } } @@ -688,7 +689,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, usage, x, y, width, height); - stmap = pipe->transfer_map(pipe, pt); + stmap = pipe_transfer_map(pipe, pt); pixels = _mesa_map_pbo_source(ctx, &clippedUnpack, pixels); assert(pixels); @@ -733,7 +734,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } /* now pack the stencil (and Z) values in the dest format */ - switch (pt->texture->format) { + switch (pt->resource->format) { case PIPE_FORMAT_S8_USCALED: { ubyte *dest = stmap + spanY * pt->stride + spanX; @@ -788,8 +789,8 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, _mesa_unmap_pbo_source(ctx, &clippedUnpack); /* unmap the stencil buffer */ - pipe->transfer_unmap(pipe, pt); - pipe->tex_transfer_destroy(pipe, pt); + pipe_transfer_unmap(pipe, pt); + pipe->transfer_destroy(pipe, pt); } @@ -830,7 +831,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, /* draw with textured quad */ { - struct pipe_texture *pt + struct pipe_resource *pt = make_texture(st, width, height, format, type, unpack, pixels); if (pt) { struct pipe_sampler_view *sv = st_sampler_view_from_texture(st->pipe, pt); @@ -844,7 +845,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, color, GL_FALSE); pipe_sampler_view_reference(&sv, NULL); } - pipe_texture_reference(&pt, NULL); + pipe_resource_reference(&pt, NULL); } } } @@ -889,11 +890,11 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, usage, dstx, dsty, width, height); - assert(util_format_get_blockwidth(ptDraw->texture->format) == 1); - assert(util_format_get_blockheight(ptDraw->texture->format) == 1); + assert(util_format_get_blockwidth(ptDraw->resource->format) == 1); + assert(util_format_get_blockheight(ptDraw->resource->format) == 1); /* map the stencil buffer */ - drawMap = pipe->transfer_map(pipe, ptDraw); + drawMap = pipe_transfer_map(pipe, ptDraw); /* draw */ /* XXX PixelZoom not handled yet */ @@ -911,7 +912,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, dst = drawMap + y * ptDraw->stride; src = buffer + i * width; - switch (ptDraw->texture->format) { + switch (ptDraw->resource->format) { case PIPE_FORMAT_Z24_UNORM_S8_USCALED: { uint *dst4 = (uint *) dst; @@ -946,8 +947,8 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, free(buffer); /* unmap the stencil buffer */ - pipe->transfer_unmap(pipe, ptDraw); - pipe->tex_transfer_destroy(pipe, ptDraw); + pipe_transfer_unmap(pipe, ptDraw); + pipe->transfer_destroy(pipe, ptDraw); } @@ -961,7 +962,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, struct pipe_screen *screen = pipe->screen; struct st_renderbuffer *rbRead; void *driver_vp, *driver_fp; - struct pipe_texture *pt; + struct pipe_resource *pt; struct pipe_sampler_view *sv; GLfloat *color; enum pipe_format srcFormat, texFormat; @@ -996,7 +997,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, srcFormat = rbRead->texture->format; if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0)) { + PIPE_BIND_SAMPLER_VIEW, 0)) { texFormat = srcFormat; } else { @@ -1004,13 +1005,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, if (type == GL_DEPTH) { texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL); + PIPE_BIND_DEPTH_STENCIL); assert(texFormat != PIPE_FORMAT_NONE); } else { /* default color format */ texFormat = st_choose_format(screen, GL_RGBA, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER); + PIPE_BIND_SAMPLER_VIEW); assert(texFormat != PIPE_FORMAT_NONE); } } @@ -1042,7 +1043,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, sv = st_sampler_view_from_texture(st->pipe, pt); if (!sv) { - pipe_texture_reference(&pt, NULL); + pipe_resource_reference(&pt, NULL); return; } @@ -1052,10 +1053,10 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* copy source framebuffer surface into mipmap/texture */ struct pipe_surface *psRead = screen->get_tex_surface(screen, rbRead->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ); + PIPE_BIND_BLIT_SOURCE); struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_WRITE ); - + PIPE_BIND_RENDER_TARGET | + PIPE_BIND_BLIT_DESTINATION); pipe->surface_copy(pipe, psTex, /* dest surf */ pack.SkipPixels, pack.SkipRows, /* dest pos */ @@ -1109,8 +1110,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, free(buf); } - pipe->tex_transfer_destroy(pipe, ptRead); - pipe->tex_transfer_destroy(pipe, ptTex); + pipe->transfer_destroy(pipe, ptRead); + pipe->transfer_destroy(pipe, ptTex); } /* OK, the texture 'pt' contains the src image/pixels. Now draw a @@ -1123,7 +1124,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, driver_fp, color, invertTex); - pipe_texture_reference(&pt, NULL); + pipe_resource_reference(&pt, NULL); pipe_sampler_view_reference(&sv, NULL); } diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index 934b70dc1a6..3c4fe32090b 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -79,7 +79,7 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx, struct pipe_surface *ps; unsigned usage; - usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE; + usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_BLIT_SOURCE | PIPE_BIND_BLIT_DESTINATION; ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage); if (ps) { strb->Base.Width = ps->width; @@ -90,7 +90,7 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx, strb->Base.InternalFormat = strb->Base._BaseFormat; pipe_surface_reference(&strb->surface, ps); - pipe_texture_reference(&strb->texture, ps->texture); + pipe_resource_reference(&strb->texture, ps->texture); pipe_surface_reference(&ps, NULL); } @@ -128,7 +128,7 @@ st_bind_surface(GLcontext *ctx, GLenum target, stObj->pipe = ctx->st->pipe; /* FIXME create a non-default sampler view from the pipe_surface? */ - pipe_texture_reference(&stImage->pt, ps->texture); + pipe_resource_reference(&stImage->pt, ps->texture); _mesa_dirty_texobj(ctx, texObj, GL_TRUE); } @@ -143,7 +143,7 @@ st_egl_image_target_texture_2d(GLcontext *ctx, GLenum target, struct pipe_surface *ps; unsigned usage; - usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE; + usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_BLIT_DESTINATION | PIPE_BIND_BLIT_SOURCE; ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage); if (ps) { st_bind_surface(ctx, target, texObj, texImage, ps); diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 542ab38a50e..d50970f7e4b 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -96,13 +96,12 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, return strb->data != NULL; } else { - struct pipe_texture template; - unsigned surface_usage; + struct pipe_resource template; /* Free the old surface and texture */ pipe_surface_reference( &strb->surface, NULL ); - pipe_texture_reference( &strb->texture, NULL ); + pipe_resource_reference( &strb->texture, NULL ); pipe_sampler_view_reference(&strb->sampler_view, NULL); /* Setup new texture template. @@ -116,23 +115,14 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, template.last_level = 0; template.nr_samples = rb->NumSamples; if (util_format_is_depth_or_stencil(format)) { - template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; + template.bind = PIPE_BIND_DEPTH_STENCIL; } else { - template.tex_usage = (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | - PIPE_TEXTURE_USAGE_RENDER_TARGET); + template.bind = (PIPE_BIND_DISPLAY_TARGET | + PIPE_BIND_RENDER_TARGET); } - /* Probably need dedicated flags for surface usage too: - */ - surface_usage = (PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); -#if 0 - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE); -#endif - - strb->texture = screen->texture_create(screen, &template); + strb->texture = screen->resource_create(screen, &template); if (!strb->texture) return FALSE; @@ -140,7 +130,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, strb->surface = screen->get_tex_surface(screen, strb->texture, 0, 0, 0, - surface_usage); + template.bind); if (strb->surface) { assert(strb->surface->texture); assert(strb->surface->format); @@ -162,7 +152,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb) struct st_renderbuffer *strb = st_renderbuffer(rb); ASSERT(strb); pipe_surface_reference(&strb->surface, NULL); - pipe_texture_reference(&strb->texture, NULL); + pipe_resource_reference(&strb->texture, NULL); pipe_sampler_view_reference(&strb->sampler_view, NULL); free(strb->data); free(strb); @@ -323,7 +313,7 @@ st_render_texture(GLcontext *ctx, struct pipe_screen *screen = ctx->st->pipe->screen; struct st_renderbuffer *strb; struct gl_renderbuffer *rb; - struct pipe_texture *pt = st_get_texobj_texture(att->Texture); + struct pipe_resource *pt = st_get_texobj_texture(att->Texture); struct st_texture_object *stObj; const struct gl_texture_image *texImage; GLint pt_level; @@ -366,7 +356,7 @@ st_render_texture(GLcontext *ctx, /*printf("***** pipe texture %d x %d\n", pt->width0, pt->height0);*/ - pipe_texture_reference( &strb->texture, pt ); + pipe_resource_reference( &strb->texture, pt ); pipe_surface_reference(&strb->surface, NULL); @@ -380,8 +370,7 @@ st_render_texture(GLcontext *ctx, strb->rtt_face, strb->rtt_level, strb->rtt_slice, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BIND_RENDER_TARGET); strb->format = pt->format; @@ -479,20 +468,20 @@ st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) if (!st_validate_attachment(screen, &fb->Attachment[BUFFER_DEPTH], - PIPE_TEXTURE_USAGE_DEPTH_STENCIL)) { + PIPE_BIND_DEPTH_STENCIL)) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; return; } if (!st_validate_attachment(screen, &fb->Attachment[BUFFER_STENCIL], - PIPE_TEXTURE_USAGE_DEPTH_STENCIL)) { + PIPE_BIND_DEPTH_STENCIL)) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; return; } for (i = 0; i < ctx->Const.MaxColorAttachments; i++) { if (!st_validate_attachment(screen, &fb->Attachment[BUFFER_COLOR0 + i], - PIPE_TEXTURE_USAGE_RENDER_TARGET)) { + PIPE_BIND_RENDER_TARGET)) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; return; } diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h index 7a45a608fe1..5f11a7cd8ab 100644 --- a/src/mesa/state_tracker/st_cb_fbo.h +++ b/src/mesa/state_tracker/st_cb_fbo.h @@ -37,7 +37,7 @@ struct st_renderbuffer { struct gl_renderbuffer Base; - struct pipe_texture *texture; + struct pipe_resource *texture; struct pipe_surface *surface; /* temporary view into texture */ struct pipe_sampler_view *sampler_view; enum pipe_format format; /** preferred format, or PIPE_FORMAT_NONE */ @@ -54,7 +54,7 @@ struct st_renderbuffer int rtt_level, rtt_face, rtt_slice; /** Render to texture state */ - struct pipe_texture *texture_save; + struct pipe_resource *texture_save; struct pipe_surface *surface_save; struct pipe_sampler_view *sampler_view_save; }; diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 10795ee9e4a..3c06221c87d 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -82,7 +82,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, width, height); /* map the stencil buffer */ - stmap = pipe->transfer_map(pipe, pt); + stmap = pipe_transfer_map(pipe, pt); /* width should never be > MAX_WIDTH since we did clipping earlier */ ASSERT(width <= MAX_WIDTH); @@ -102,7 +102,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } /* get stencil (and Z) values */ - switch (pt->texture->format) { + switch (pt->resource->format) { case PIPE_FORMAT_S8_USCALED: { const ubyte *src = stmap + srcY * pt->stride; @@ -162,8 +162,8 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } /* unmap the stencil buffer */ - pipe->transfer_unmap(pipe, pt); - pipe->tex_transfer_destroy(pipe, pt); + pipe_transfer_unmap(pipe, pt); + pipe->transfer_destroy(pipe, pt); } @@ -253,9 +253,9 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, return GL_FALSE; } - map = pipe->transfer_map(pipe, trans); + map = pipe_transfer_map(pipe, trans); if (!map) { - pipe->tex_transfer_destroy(pipe, trans); + pipe->transfer_destroy(pipe, trans); return GL_FALSE; } @@ -317,8 +317,8 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, ; /* nothing */ } - pipe->transfer_unmap(pipe, trans); - pipe->tex_transfer_destroy(pipe, trans); + pipe_transfer_unmap(pipe, trans); + pipe->transfer_destroy(pipe, trans); } return GL_TRUE; @@ -437,8 +437,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width, format, type); - if (trans->texture->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || - trans->texture->format == PIPE_FORMAT_Z24X8_UNORM) { + if (trans->resource->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED || + trans->resource->format == PIPE_FORMAT_Z24X8_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { GLuint ztemp[MAX_WIDTH]; @@ -469,8 +469,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } } - else if (trans->texture->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM || - trans->texture->format == PIPE_FORMAT_X8Z24_UNORM) { + else if (trans->resource->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM || + trans->resource->format == PIPE_FORMAT_X8Z24_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { GLuint ztemp[MAX_WIDTH]; @@ -496,7 +496,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } } - else if (trans->texture->format == PIPE_FORMAT_Z16_UNORM) { + else if (trans->resource->format == PIPE_FORMAT_Z16_UNORM) { for (i = 0; i < height; i++) { GLushort ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; @@ -511,7 +511,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, dst += dstStride; } } - else if (trans->texture->format == PIPE_FORMAT_Z32_UNORM) { + else if (trans->resource->format == PIPE_FORMAT_Z32_UNORM) { for (i = 0; i < height; i++) { GLuint ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; @@ -542,7 +542,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } - pipe->tex_transfer_destroy(pipe, trans); + pipe->transfer_destroy(pipe, trans); _mesa_unmap_pbo_dest(ctx, &clippedPacking); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 390ada5489c..ce112f67957 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -123,7 +123,7 @@ st_DeleteTextureObject(GLcontext *ctx, { struct st_texture_object *stObj = st_texture_object(texObj); if (stObj->pt) - pipe_texture_reference(&stObj->pt, NULL); + pipe_resource_reference(&stObj->pt, NULL); if (stObj->sampler_view) { if (stObj->sampler_view->context != ctx->st->pipe) { /* Take "ownership" of this texture sampler view by setting @@ -148,7 +148,7 @@ st_FreeTextureImageData(GLcontext * ctx, struct gl_texture_image *texImage) DBG("%s\n", __FUNCTION__); if (stImage->pt) { - pipe_texture_reference(&stImage->pt, NULL); + pipe_resource_reference(&stImage->pt, NULL); } if (texImage->Data) { @@ -214,17 +214,17 @@ do_memcpy(void *dest, const void *src, size_t n) static GLuint default_usage(enum pipe_format fmt) { - GLuint usage = PIPE_TEXTURE_USAGE_SAMPLER; + GLuint usage = PIPE_BIND_SAMPLER_VIEW; if (util_format_is_depth_or_stencil(fmt)) - usage |= PIPE_TEXTURE_USAGE_DEPTH_STENCIL; + usage |= PIPE_BIND_DEPTH_STENCIL; else - usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; + usage |= PIPE_BIND_RENDER_TARGET; return usage; } /** - * Allocate a pipe_texture object for the given st_texture_object using + * Allocate a pipe_resource object for the given st_texture_object using * the given st_texture_image to guess the mipmap size/levels. * * [comments...] @@ -387,8 +387,8 @@ compress_with_blit(GLcontext * ctx, struct pipe_context *pipe = ctx->st->pipe; struct pipe_screen *screen = pipe->screen; gl_format mesa_format; - struct pipe_texture templ; - struct pipe_texture *src_tex; + struct pipe_resource templ; + struct pipe_resource *src_tex; struct pipe_sampler_view view_templ; struct pipe_sampler_view *src_view; struct pipe_surface *dst_surface; @@ -403,7 +403,7 @@ compress_with_blit(GLcontext * ctx, /* get destination surface (in the compressed texture) */ dst_surface = screen->get_tex_surface(screen, stImage->pt, stImage->face, stImage->level, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BIND_BLIT_DESTINATION); if (!dst_surface) { /* can't render into this format (or other problem) */ return GL_FALSE; @@ -425,8 +425,9 @@ compress_with_blit(GLcontext * ctx, templ.height0 = height; templ.depth0 = 1; templ.last_level = 0; - templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER; - src_tex = screen->texture_create(screen, &templ); + templ._usage = PIPE_USAGE_DEFAULT; + templ.bind = PIPE_BIND_SAMPLER_VIEW; + src_tex = screen->resource_create(screen, &templ); if (!src_tex) return GL_FALSE; @@ -437,7 +438,7 @@ compress_with_blit(GLcontext * ctx, 0, 0, 0, /* face, level are zero */ PIPE_TRANSFER_WRITE, 0, 0, width, height); /* x, y, w, h */ - map = pipe->transfer_map(pipe, tex_xfer); + map = pipe_transfer_map(pipe, tex_xfer); _mesa_texstore(ctx, 2, GL_RGBA, mesa_format, map, /* dest ptr */ @@ -449,8 +450,8 @@ compress_with_blit(GLcontext * ctx, pixels, /* source data */ unpack); /* source data packing */ - pipe->transfer_unmap(pipe, tex_xfer); - pipe->tex_transfer_destroy(pipe, tex_xfer); + pipe_transfer_unmap(pipe, tex_xfer); + pipe->transfer_destroy(pipe, tex_xfer); /* Create temporary sampler view */ u_sampler_view_default_template(&view_templ, @@ -472,7 +473,7 @@ compress_with_blit(GLcontext * ctx, PIPE_TEX_MIPFILTER_NEAREST); pipe_surface_reference(&dst_surface, NULL); - pipe_texture_reference(&src_tex, NULL); + pipe_resource_reference(&src_tex, NULL); pipe_sampler_view_reference(&src_view, NULL); return GL_TRUE; @@ -560,7 +561,7 @@ st_TexImage(GLcontext * ctx, * Release any old malloced memory. */ if (stImage->pt) { - pipe_texture_reference(&stImage->pt, NULL); + pipe_resource_reference(&stImage->pt, NULL); assert(!texImage->Data); } else if (texImage->Data) { @@ -577,7 +578,7 @@ st_TexImage(GLcontext * ctx, !st_texture_match_image(stObj->pt, &stImage->base, stImage->face, stImage->level)) { DBG("release it\n"); - pipe_texture_reference(&stObj->pt, NULL); + pipe_resource_reference(&stObj->pt, NULL); assert(!stObj->pt); pipe_sampler_view_reference(&stObj->sampler_view, NULL); stObj->teximage_realloc = FALSE; @@ -610,7 +611,7 @@ st_TexImage(GLcontext * ctx, st_texture_match_image(stObj->pt, &stImage->base, stImage->face, stImage->level)) { - pipe_texture_reference(&stImage->pt, stObj->pt); + pipe_resource_reference(&stImage->pt, stObj->pt); assert(stImage->pt); } @@ -644,7 +645,7 @@ st_TexImage(GLcontext * ctx, screen->is_format_supported(screen, stImage->pt->format, stImage->pt->target, - PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) { + PIPE_BIND_RENDER_TARGET, 0)) { if (!pixels) goto done; @@ -842,11 +843,14 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, const GLuint width = texImage->Width; const GLuint height = texImage->Height; struct pipe_surface *dst_surface; - struct pipe_texture *dst_texture; + struct pipe_resource *dst_texture; struct pipe_transfer *tex_xfer; + unsigned bind = (PIPE_BIND_BLIT_DESTINATION | + PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */ + PIPE_BIND_TRANSFER_READ); /* create temp / dest surface */ - if (!util_create_rgba_surface(screen, width, height, + if (!util_create_rgba_surface(screen, width, height, bind, &dst_texture, &dst_surface)) { _mesa_problem(ctx, "util_create_rgba_surface() failed " "in decompress_with_blit()"); @@ -855,7 +859,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, /* blit/render/decompress */ util_blit_pixels_tex(ctx->st->blit, - src_view, /* pipe_texture (src) */ + src_view, /* pipe_resource (src) */ 0, 0, /* src x0, y0 */ width, height, /* src x1, y1 */ dst_surface, /* pipe_surface (dst) */ @@ -876,7 +880,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, if (st_equal_formats(stImage->pt->format, format, type)) { /* memcpy */ const uint bytesPerRow = width * util_format_get_blocksize(stImage->pt->format); - ubyte *map = pipe->transfer_map(pipe, tex_xfer); + ubyte *map = pipe_transfer_map(pipe, tex_xfer); GLuint row; for (row = 0; row < height; row++) { GLvoid *dest = _mesa_image_address2d(&ctx->Pack, pixels, width, @@ -884,7 +888,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, memcpy(dest, map, bytesPerRow); map += tex_xfer->stride; } - pipe->transfer_unmap(pipe, tex_xfer); + pipe_transfer_unmap(pipe, tex_xfer); } else { /* format translation via floats */ @@ -908,7 +912,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, _mesa_unmap_pbo_dest(ctx, &ctx->Pack); - pipe->tex_transfer_destroy(pipe, tex_xfer); + pipe->transfer_destroy(pipe, tex_xfer); /* destroy the temp / dest surface */ util_destroy_rgba_surface(dst_texture, dst_surface); @@ -1069,7 +1073,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level, screen->is_format_supported(screen, stImage->pt->format, stImage->pt->target, - PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) { + PIPE_BIND_RENDER_TARGET, 0)) { if (compress_with_blit(ctx, target, level, xoffset, yoffset, zoffset, width, height, depth, @@ -1392,7 +1396,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, } st_texture_image_unmap(ctx->st, stImage); - pipe->tex_transfer_destroy(pipe, src_trans); + pipe->transfer_destroy(pipe, src_trans); } @@ -1577,7 +1581,7 @@ st_copy_texsubimage(GLcontext *ctx, dest_surface = screen->get_tex_surface(screen, stImage->pt, stImage->face, stImage->level, destZ, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BIND_BLIT_DESTINATION); /* for surface_copy(), y=0=top, always */ pipe->surface_copy(pipe, @@ -1596,11 +1600,11 @@ st_copy_texsubimage(GLcontext *ctx, texBaseFormat != GL_DEPTH_STENCIL && screen->is_format_supported(screen, src_format, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, + PIPE_BIND_SAMPLER_VIEW, 0) && screen->is_format_supported(screen, dest_format, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET, + PIPE_BIND_RENDER_TARGET, 0)) { /* draw textured quad to do the copy */ GLint srcY0, srcY1; @@ -1608,7 +1612,7 @@ st_copy_texsubimage(GLcontext *ctx, dest_surface = screen->get_tex_surface(screen, stImage->pt, stImage->face, stImage->level, destZ, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BIND_BLIT_DESTINATION); if (do_flip) { srcY1 = strb->Base.Height - srcY - height; @@ -1748,7 +1752,7 @@ copy_image_data_to_texture(struct st_context *st, stImage->pt, /* src texture */ stImage->face); - pipe_texture_reference(&stImage->pt, NULL); + pipe_resource_reference(&stImage->pt, NULL); } else if (stImage->base.Data) { /* More straightforward upload. @@ -1770,7 +1774,7 @@ copy_image_data_to_texture(struct st_context *st, stImage->base.Data = NULL; } - pipe_texture_reference(&stImage->pt, stObj->pt); + pipe_resource_reference(&stImage->pt, stObj->pt); } @@ -1816,7 +1820,7 @@ st_finalize_texture(GLcontext *ctx, if (firstImage->pt && firstImage->pt != stObj->pt && firstImage->pt->last_level >= stObj->lastLevel) { - pipe_texture_reference(&stObj->pt, firstImage->pt); + pipe_resource_reference(&stObj->pt, firstImage->pt); pipe_sampler_view_reference(&stObj->sampler_view, NULL); } @@ -1836,7 +1840,7 @@ st_finalize_texture(GLcontext *ctx, stObj->pt->height0 != firstImage->base.Height2 || stObj->pt->depth0 != firstImage->base.Depth2) { - pipe_texture_reference(&stObj->pt, NULL); + pipe_resource_reference(&stObj->pt, NULL); pipe_sampler_view_reference(&stObj->sampler_view, NULL); ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER; } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 83580591fc3..0a1503fc692 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -240,7 +240,7 @@ static void st_destroy_context_priv( struct st_context *st ) for (i = 0; i < Elements(st->state.constants); i++) { if (st->state.constants[i]) { - pipe_buffer_reference(&st->state.constants[i], NULL); + pipe_resource_reference(&st->state.constants[i], NULL); } } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 786beaec08b..f28d5aa3ed3 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -95,7 +95,7 @@ struct st_context struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS]; struct pipe_sampler_state *sampler_list[PIPE_MAX_SAMPLERS]; struct pipe_clip_state clip; - struct pipe_buffer *constants[2]; + struct pipe_resource *constants[2]; struct pipe_framebuffer_state framebuffer; struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; struct pipe_scissor_state scissor; @@ -143,7 +143,7 @@ struct st_context GLuint user_prog_sn; /**< user fragment program serial no. */ struct st_fragment_program *combined_prog; GLuint combined_prog_sn; - struct pipe_texture *pixelmap_texture; + struct pipe_resource *pixelmap_texture; struct pipe_sampler_view *pixelmap_sampler_view; boolean pixelmap_enabled; /**< use the pixelmap texture? */ } pixel_xfer; @@ -155,7 +155,7 @@ struct st_context enum pipe_format tex_format; void *vs; float vertices[4][3][4]; /**< vertex pos + color + texcoord */ - struct pipe_buffer *vbuf; + struct pipe_resource *vbuf; unsigned vbuf_slot; /* next free slot in vbuf */ struct bitmap_cache *cache; } bitmap; @@ -174,7 +174,7 @@ struct st_context void *vs; void *fs; float vertices[4][2][4]; /**< vertex pos + color */ - struct pipe_buffer *vbuf; + struct pipe_resource *vbuf; unsigned vbuf_slot; } clear; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index e0bb1a0af52..0ebc462ced4 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -360,12 +360,13 @@ setup_interleaved_attribs(GLcontext *ctx, offset0 = low; if (userSpace) { vbuffer->buffer = - pipe_user_buffer_create(pipe->screen, (void *) low, high - low); + pipe_user_buffer_create(pipe->screen, (void *) low, high - low, + PIPE_BIND_VERTEX_BUFFER); vbuffer->buffer_offset = 0; } else { vbuffer->buffer = NULL; - pipe_buffer_reference(&vbuffer->buffer, stobj->buffer); + pipe_resource_reference(&vbuffer->buffer, stobj->buffer); vbuffer->buffer_offset = pointer_to_offset(low); } vbuffer->stride = stride; /* in bytes */ @@ -422,7 +423,7 @@ setup_non_interleaved_attribs(GLcontext *ctx, /*printf("stobj %u = %p\n", attr, (void*) stobj);*/ vbuffer[attr].buffer = NULL; - pipe_buffer_reference(&vbuffer[attr].buffer, stobj->buffer); + pipe_resource_reference(&vbuffer[attr].buffer, stobj->buffer); vbuffer[attr].buffer_offset = pointer_to_offset(arrays[mesaAttr]->Ptr); velements[attr].src_offset = 0; } @@ -443,14 +444,19 @@ setup_non_interleaved_attribs(GLcontext *ctx, bytes = arrays[mesaAttr]->Size * _mesa_sizeof_type(arrays[mesaAttr]->Type); } - vbuffer[attr].buffer = pipe_user_buffer_create(pipe->screen, - (void *) arrays[mesaAttr]->Ptr, bytes); + vbuffer[attr].buffer = + pipe_user_buffer_create(pipe->screen, + (void *) arrays[mesaAttr]->Ptr, bytes, + PIPE_BIND_VERTEX_BUFFER); } else { /* no array, use ctx->Current.Attrib[] value */ bytes = sizeof(ctx->Current.Attrib[0]); - vbuffer[attr].buffer = pipe_user_buffer_create(pipe->screen, - (void *) ctx->Current.Attrib[mesaAttr], bytes); + vbuffer[attr].buffer = + pipe_user_buffer_create(pipe->screen, + (void *) ctx->Current.Attrib[mesaAttr], + bytes, + PIPE_BIND_VERTEX_BUFFER); stride = 0; } @@ -618,7 +624,7 @@ st_draw_vbo(GLcontext *ctx, if (ib) { /* indexed primitive */ struct gl_buffer_object *bufobj = ib->obj; - struct pipe_buffer *indexBuf = NULL; + struct pipe_resource *indexBuf = NULL; unsigned indexSize, indexOffset, i; unsigned prim; @@ -641,13 +647,14 @@ st_draw_vbo(GLcontext *ctx, if (bufobj && bufobj->Name) { /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); - pipe_buffer_reference(&indexBuf, stobj->buffer); + pipe_resource_reference(&indexBuf, stobj->buffer); indexOffset = pointer_to_offset(ib->ptr) / indexSize; } else { /* element/indicies are in user space memory */ indexBuf = pipe_user_buffer_create(pipe->screen, (void *) ib->ptr, - ib->count * indexSize); + ib->count * indexSize, + PIPE_BIND_INDEX_BUFFER); indexOffset = 0; } @@ -683,7 +690,7 @@ st_draw_vbo(GLcontext *ctx, } } - pipe_buffer_reference(&indexBuf, NULL); + pipe_resource_reference(&indexBuf, NULL); } else { /* non-indexed */ @@ -706,7 +713,7 @@ st_draw_vbo(GLcontext *ctx, /* unreference buffers (frees wrapped user-space buffer objects) */ for (attr = 0; attr < num_vbuffers; attr++) { - pipe_buffer_reference(&vbuffer[attr].buffer, NULL); + pipe_resource_reference(&vbuffer[attr].buffer, NULL); assert(!vbuffer[attr].buffer); } diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 26a5b3fcd63..b717bd4e3fb 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -104,9 +104,12 @@ st_feedback_draw_vbo(GLcontext *ctx, struct draw_context *draw = st->draw; const struct st_vertex_program *vp; const struct pipe_shader_state *vs; - struct pipe_buffer *index_buffer_handle = 0; + struct pipe_resource *index_buffer_handle = 0; struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS]; struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; + struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS]; + struct pipe_transfer *ib_transfer; + struct pipe_transfer *cb_transfer; GLuint attr, i; ubyte *mapped_constants; @@ -155,7 +158,7 @@ st_feedback_draw_vbo(GLcontext *ctx, assert(stobj->buffer); vbuffers[attr].buffer = NULL; - pipe_buffer_reference(&vbuffers[attr].buffer, stobj->buffer); + pipe_resource_reference(&vbuffers[attr].buffer, stobj->buffer); vbuffers[attr].buffer_offset = pointer_to_offset(arrays[0]->Ptr); velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; } @@ -168,7 +171,8 @@ st_feedback_draw_vbo(GLcontext *ctx, /* wrap user data */ vbuffers[attr].buffer = pipe_user_buffer_create(pipe->screen, (void *) arrays[mesaAttr]->Ptr, - bytes); + bytes, + PIPE_BIND_VERTEX_BUFFER); vbuffers[attr].buffer_offset = 0; velements[attr].src_offset = 0; } @@ -191,8 +195,9 @@ st_feedback_draw_vbo(GLcontext *ctx, #endif /* map the attrib buffer */ - map = pipe_buffer_map(pipe->screen, vbuffers[attr].buffer, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pipe, vbuffers[attr].buffer, + PIPE_TRANSFER_READ, + &vb_transfer[attr]); draw_set_mapped_vertex_buffer(draw, attr, map); } @@ -221,13 +226,14 @@ st_feedback_draw_vbo(GLcontext *ctx, index_buffer_handle = stobj->buffer; - map = pipe_buffer_map(pipe->screen, index_buffer_handle, - PIPE_BUFFER_USAGE_CPU_READ); + map = pipe_buffer_map(pipe, index_buffer_handle, + PIPE_TRANSFER_READ, &ib_transfer); draw_set_mapped_element_buffer(draw, indexSize, map); } else { draw_set_mapped_element_buffer(draw, indexSize, (void *) ib->ptr); + ib_transfer = NULL; } } else { @@ -237,12 +243,13 @@ st_feedback_draw_vbo(GLcontext *ctx, /* map constant buffers */ - mapped_constants = pipe_buffer_map(pipe->screen, + mapped_constants = pipe_buffer_map(pipe, st->state.constants[PIPE_SHADER_VERTEX], - PIPE_BUFFER_USAGE_CPU_READ); + PIPE_TRANSFER_READ, + &cb_transfer); draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX, 0, mapped_constants, - st->state.constants[PIPE_SHADER_VERTEX]->size); + st->state.constants[PIPE_SHADER_VERTEX]->width0); /* draw here */ @@ -252,20 +259,22 @@ st_feedback_draw_vbo(GLcontext *ctx, /* unmap constant buffers */ - pipe_buffer_unmap(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX]); + pipe_buffer_unmap(pipe, st->state.constants[PIPE_SHADER_VERTEX], + cb_transfer); /* * unmap vertex/index buffers */ for (i = 0; i < PIPE_MAX_ATTRIBS; i++) { if (draw->pt.vertex_buffer[i].buffer) { - pipe_buffer_unmap(pipe->screen, draw->pt.vertex_buffer[i].buffer); - pipe_buffer_reference(&draw->pt.vertex_buffer[i].buffer, NULL); + pipe_buffer_unmap(pipe, draw->pt.vertex_buffer[i].buffer, + vb_transfer[i]); + pipe_resource_reference(&draw->pt.vertex_buffer[i].buffer, NULL); draw_set_mapped_vertex_buffer(draw, i, NULL); } } if (index_buffer_handle) { - pipe_buffer_unmap(pipe->screen, index_buffer_handle); + pipe_buffer_unmap(pipe, index_buffer_handle, ib_transfer); draw_set_mapped_element_buffer(draw, 0, NULL); } } diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index affb054866a..1e4b7b88405 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -287,39 +287,39 @@ void st_init_extensions(struct st_context *st) */ if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) && + PIPE_BIND_DEPTH_STENCIL, 0) && screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0)) { + PIPE_BIND_SAMPLER_VIEW, 0)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; } else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) && + PIPE_BIND_DEPTH_STENCIL, 0) && screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0)) { + PIPE_BIND_SAMPLER_VIEW, 0)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; } /* sRGB support */ if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0) || + PIPE_BIND_SAMPLER_VIEW, 0) || screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0)) { + PIPE_BIND_SAMPLER_VIEW, 0)) { ctx->Extensions.EXT_texture_sRGB = GL_TRUE; } /* s3tc support */ if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0) && + PIPE_BIND_SAMPLER_VIEW, 0) && (ctx->Mesa_DXTn || screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))) { + PIPE_BIND_RENDER_TARGET, 0))) { ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; ctx->Extensions.S3_s3tc = GL_TRUE; } @@ -327,10 +327,10 @@ void st_init_extensions(struct st_context *st) /* ycbcr support */ if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0) || + PIPE_BIND_SAMPLER_VIEW, 0) || screen->is_format_supported(screen, PIPE_FORMAT_YUYV, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0)) { + PIPE_BIND_SAMPLER_VIEW, 0)) { ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; } diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index ecc08762bb2..731ec64c139 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -374,7 +374,7 @@ default_deep_rgba_format(struct pipe_screen *screen, if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, target, tex_usage, geom_flags)) { return PIPE_FORMAT_R16G16B16A16_SNORM; } - if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) + if (tex_usage & PIPE_BIND_RENDER_TARGET) return default_rgba_format(screen, target, tex_usage, geom_flags); else return PIPE_FORMAT_NONE; @@ -410,8 +410,8 @@ default_depth_format(struct pipe_screen *screen, * Given an OpenGL internalFormat value for a texture or surface, return * the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match. * \param target one of PIPE_TEXTURE_x - * \param tex_usage either PIPE_TEXTURE_USAGE_RENDER_TARGET - * or PIPE_TEXTURE_USAGE_SAMPLER + * \param tex_usage either PIPE_BIND_RENDER_TARGET + * or PIPE_BIND_SAMPLER_VIEW */ enum pipe_format st_choose_format(struct pipe_screen *screen, GLenum internalFormat, @@ -432,7 +432,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_COMPRESSED_RGB: return default_rgb_format( screen, target, tex_usage, geom_flags ); case GL_RGBA16: - if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) + if (tex_usage & PIPE_BIND_RENDER_TARGET) return default_deep_rgba_format( screen, target, tex_usage, geom_flags ); else return default_rgba_format( screen, target, tex_usage, geom_flags ); @@ -645,9 +645,9 @@ st_choose_renderbuffer_format(struct pipe_screen *screen, { uint usage; if (is_depth_or_stencil_format(internalFormat)) - usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; + usage = PIPE_BIND_DEPTH_STENCIL; else - usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + usage = PIPE_BIND_RENDER_TARGET; return st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D, usage); } @@ -665,7 +665,7 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, (void) type; pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat, - PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER); + PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); if (pFormat == PIPE_FORMAT_NONE) return MESA_FORMAT_NONE; diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index d3c43bbc68a..819b4487ac2 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -196,7 +196,7 @@ st_set_framebuffer_surface(struct st_framebuffer *stfb, /* replace the renderbuffer's surface/texture pointers */ pipe_surface_reference( &strb->surface, surf ); - pipe_texture_reference( &strb->texture, surf->texture ); + pipe_resource_reference( &strb->texture, surf->texture ); pipe_sampler_view_reference(&strb->sampler_view, NULL); if (ctx) { @@ -243,7 +243,7 @@ st_get_framebuffer_surface(struct st_framebuffer *stfb, uint surfIndex, struct p } int -st_get_framebuffer_texture(struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture) +st_get_framebuffer_texture(struct st_framebuffer *stfb, uint surfIndex, struct pipe_resource **texture) { struct st_renderbuffer *strb; diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 030b0a0f065..f0fe31967c3 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -91,7 +91,7 @@ st_render_mipmap(struct st_context *st, /* check if we can render in the texture's format */ if (!screen->is_format_supported(screen, psv->format, psv->texture->target, - PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) { + PIPE_BIND_RENDER_TARGET, 0)) { return FALSE; } @@ -107,7 +107,7 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj) { struct pipe_context *pipe = ctx->st->pipe; - struct pipe_texture *pt = st_get_texobj_texture(texObj); + struct pipe_resource *pt = st_get_texobj_texture(texObj); const uint baseLevel = texObj->BaseLevel; const uint lastLevel = pt->last_level; const uint face = _mesa_tex_target_to_face(target), zslice = 0; @@ -142,11 +142,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, u_minify(pt->width0, dstLevel), u_minify(pt->height0, dstLevel)); - srcData = (ubyte *) pipe->transfer_map(pipe, srcTrans); - dstData = (ubyte *) pipe->transfer_map(pipe, dstTrans); + srcData = (ubyte *) pipe_transfer_map(pipe, srcTrans); + dstData = (ubyte *) pipe_transfer_map(pipe, dstTrans); - srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->texture->format); - dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->texture->format); + srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->resource->format); + dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->resource->format); _mesa_generate_mipmap_level(target, datatype, comps, 0 /*border*/, @@ -161,11 +161,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, dstData, dstStride); /* stride in texels */ - pipe->transfer_unmap(pipe, srcTrans); - pipe->transfer_unmap(pipe, dstTrans); + pipe_transfer_unmap(pipe, srcTrans); + pipe_transfer_unmap(pipe, dstTrans); - pipe->tex_transfer_destroy(pipe, srcTrans); - pipe->tex_transfer_destroy(pipe, dstTrans); + pipe->transfer_destroy(pipe, srcTrans); + pipe->transfer_destroy(pipe, dstTrans); } } @@ -213,7 +213,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, { struct st_context *st = ctx->st; struct st_texture_object *stObj = st_texture_object(texObj); - struct pipe_texture *pt = st_get_texobj_texture(texObj); + struct pipe_resource *pt = st_get_texobj_texture(texObj); const uint baseLevel = texObj->BaseLevel; uint lastLevel; uint dstLevel; @@ -231,7 +231,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, /* The current gallium texture doesn't have space for all the * mipmap levels we need to generate. So allocate a new texture. */ - struct pipe_texture *oldTex = stObj->pt; + struct pipe_resource *oldTex = stObj->pt; GLboolean needFlush; /* create new texture with space for more levels */ @@ -242,7 +242,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, oldTex->width0, oldTex->height0, oldTex->depth0, - oldTex->tex_usage); + oldTex->bind); /* The texture isn't in a "complete" state yet so set the expected * lastLevel here, since it won't get done in st_finalize_texture(). @@ -255,7 +255,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, st_finalize_texture(ctx, st->pipe, texObj, &needFlush); /* release the old tex (will likely be freed too) */ - pipe_texture_reference(&oldTex, NULL); + pipe_resource_reference(&oldTex, NULL); pipe_sampler_view_reference(&stObj->sampler_view, NULL); pt = stObj->pt; @@ -299,6 +299,6 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, dstImage->TexFormat = srcImage->TexFormat; stImage = (struct st_texture_image *) dstImage; - pipe_texture_reference(&stImage->pt, pt); + pipe_resource_reference(&stImage->pt, pt); } } diff --git a/src/mesa/state_tracker/st_inlines.h b/src/mesa/state_tracker/st_inlines.h index 7fcde7b1a96..32584b25c27 100644 --- a/src/mesa/state_tracker/st_inlines.h +++ b/src/mesa/state_tracker/st_inlines.h @@ -37,6 +37,7 @@ #include "pipe/p_screen.h" #include "pipe/p_defines.h" #include "util/u_inlines.h" +#include "util/u_box.h" #include "pipe/p_state.h" #include "st_context.h" @@ -45,7 +46,7 @@ static INLINE struct pipe_transfer * st_cond_flush_get_tex_transfer(struct st_context *st, - struct pipe_texture *pt, + struct pipe_resource *pt, unsigned int face, unsigned int level, unsigned int zslice, @@ -54,15 +55,26 @@ st_cond_flush_get_tex_transfer(struct st_context *st, unsigned int w, unsigned int h) { struct pipe_context *context = st->pipe; + struct pipe_subresource subresource; + struct pipe_box box; + + subresource.face = face; + subresource.level = level; + + u_box_2d_zslice(x, y, zslice, w, h, &box); st_teximage_flush_before_map(st, pt, face, level, usage); - return context->get_tex_transfer(context, pt, face, level, zslice, usage, - x, y, w, h); + + return context->get_transfer(context, + pt, + subresource, + usage, + &box); } static INLINE struct pipe_transfer * st_no_flush_get_tex_transfer(struct st_context *st, - struct pipe_texture *pt, + struct pipe_resource *pt, unsigned int face, unsigned int level, unsigned int zslice, @@ -71,93 +83,76 @@ st_no_flush_get_tex_transfer(struct st_context *st, unsigned int w, unsigned int h) { struct pipe_context *context = st->pipe; - - return context->get_tex_transfer(context, pt, face, level, - zslice, usage, x, y, w, h); -} - -static INLINE void * -st_cond_flush_pipe_buffer_map(struct st_context *st, - struct pipe_buffer *buf, - unsigned int map_flags) -{ - struct pipe_context *pipe = st->pipe; - unsigned int referenced = pipe->is_buffer_referenced(pipe, buf); - - if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) || - (map_flags & PIPE_BUFFER_USAGE_CPU_WRITE))) - st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); - - return pipe_buffer_map(pipe->screen, buf, map_flags); -} - -static INLINE void * -st_no_flush_pipe_buffer_map(struct st_context *st, - struct pipe_buffer *buf, - unsigned int map_flags) -{ - return pipe_buffer_map(st->pipe->screen, buf, map_flags); + struct pipe_box box; + struct pipe_subresource subresource = u_subresource( face, level ); + + u_box_2d_zslice( x, y, zslice, + w, h, + &box ); + + return context->get_transfer(context, + pt, + subresource, + usage, + &box); } static INLINE void st_cond_flush_pipe_buffer_write(struct st_context *st, - struct pipe_buffer *buf, + struct pipe_resource *buf, unsigned int offset, unsigned int size, const void * data) { struct pipe_context *pipe = st->pipe; - if (pipe->is_buffer_referenced(pipe, buf)) - st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); - - pipe_buffer_write(pipe->screen, buf, offset, size, data); + pipe_buffer_write(pipe, buf, offset, size, data); } static INLINE void st_no_flush_pipe_buffer_write(struct st_context *st, - struct pipe_buffer *buf, + struct pipe_resource *buf, unsigned int offset, unsigned int size, const void * data) { - pipe_buffer_write(st->pipe->screen, buf, offset, size, data); + pipe_buffer_write(st->pipe, buf, offset, size, data); } static INLINE void st_no_flush_pipe_buffer_write_nooverlap(struct st_context *st, - struct pipe_buffer *buf, + struct pipe_resource *buf, unsigned int offset, unsigned int size, const void * data) { - pipe_buffer_write_nooverlap(st->pipe->screen, buf, offset, size, data); + pipe_buffer_write_nooverlap(st->pipe, buf, offset, size, data); } static INLINE void st_cond_flush_pipe_buffer_read(struct st_context *st, - struct pipe_buffer *buf, + struct pipe_resource *buf, unsigned int offset, unsigned int size, void * data) { struct pipe_context *pipe = st->pipe; - if (pipe->is_buffer_referenced(pipe, buf) & PIPE_REFERENCED_FOR_WRITE) + if (pipe->is_resource_referenced(pipe, buf, 0, 0) & PIPE_REFERENCED_FOR_WRITE) st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); - pipe_buffer_read(pipe->screen, buf, offset, size, data); + pipe_buffer_read(pipe, buf, offset, size, data); } static INLINE void st_no_flush_pipe_buffer_read(struct st_context *st, - struct pipe_buffer *buf, + struct pipe_resource *buf, unsigned int offset, unsigned int size, void * data) { - pipe_buffer_read(st->pipe->screen, buf, offset, size, data); + pipe_buffer_read(st->pipe, buf, offset, size, data); } #endif diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 4b4c17ca8b9..8a6c8256ff8 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -150,7 +150,7 @@ static void st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st) { struct pipe_screen *screen = st->pipe->screen; - struct pipe_texture *textures[ST_ATTACHMENT_COUNT]; + struct pipe_resource *textures[ST_ATTACHMENT_COUNT]; uint width, height; unsigned i; boolean changed = FALSE; @@ -175,22 +175,22 @@ st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st) idx = attachment_to_buffer_index(stfb->statts[i]); if (idx >= BUFFER_COUNT) { - pipe_texture_reference(&textures[i], NULL); + pipe_resource_reference(&textures[i], NULL); continue; } strb = st_renderbuffer(stfb->Base.Attachment[idx].Renderbuffer); assert(strb); if (strb->texture == textures[i]) { - pipe_texture_reference(&textures[i], NULL); + pipe_resource_reference(&textures[i], NULL); continue; } ps = screen->get_tex_surface(screen, textures[i], 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BIND_RENDER_TARGET); if (ps) { pipe_surface_reference(&strb->surface, ps); - pipe_texture_reference(&strb->texture, ps->texture); + pipe_resource_reference(&strb->texture, ps->texture); /* ownership transfered */ pipe_surface_reference(&ps, NULL); @@ -203,7 +203,7 @@ st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st) height = strb->Base.Height; } - pipe_texture_reference(&textures[i], NULL); + pipe_resource_reference(&textures[i], NULL); } if (changed) { @@ -498,7 +498,7 @@ st_context_flush(struct st_context_iface *stctxi, unsigned flags, static boolean st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target, int level, enum pipe_format internal_format, - struct pipe_texture *tex, boolean mipmap) + struct pipe_resource *tex, boolean mipmap) { struct st_context *st = (struct st_context *) stctxi; GLcontext *ctx = st->ctx; @@ -557,7 +557,7 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target } stObj->pipe = st->pipe; - pipe_texture_reference(&stImage->pt, tex); + pipe_resource_reference(&stImage->pt, tex); _mesa_dirty_texobj(ctx, texObj, GL_TRUE); _mesa_unlock_texture(ctx, texObj); @@ -744,7 +744,7 @@ st_manager_get_egl_image_surface(struct st_context *st, ps = smapi->screen->get_tex_surface(smapi->screen, stimg.texture, stimg.face, stimg.level, stimg.zslice, usage); - pipe_texture_reference(&stimg.texture, NULL); + pipe_resource_reference(&stimg.texture, NULL); return ps; } diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index 4b40d6d0448..18f82132b9f 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -53,7 +53,7 @@ struct st_framebuffer; struct pipe_context; struct pipe_fence_handle; struct pipe_surface; -struct pipe_texture; +struct pipe_resource; PUBLIC @@ -94,7 +94,7 @@ int st_get_framebuffer_surface(struct st_framebuffer *stfb, PUBLIC int st_get_framebuffer_texture(struct st_framebuffer *stfb, - uint surfIndex, struct pipe_texture **texture); + uint surfIndex, struct pipe_resource **texture); PUBLIC void *st_framebuffer_private( struct st_framebuffer *stfb ); diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 5809927852d..a623eed50ac 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -69,12 +69,12 @@ target_to_target(GLenum target) /** - * Allocate a new pipe_texture object + * Allocate a new pipe_resource object * width0, height0, depth0 are the dimensions of the level 0 image * (the highest resolution). last_level indicates how many mipmap levels * to allocate storage for. For non-mipmapped textures, this will be zero. */ -struct pipe_texture * +struct pipe_resource * st_texture_create(struct st_context *st, enum pipe_texture_target target, enum pipe_format format, @@ -82,9 +82,9 @@ st_texture_create(struct st_context *st, GLuint width0, GLuint height0, GLuint depth0, - GLuint usage ) + GLuint bind ) { - struct pipe_texture pt, *newtex; + struct pipe_resource pt, *newtex; struct pipe_screen *screen = st->pipe->screen; assert(target <= PIPE_TEXTURE_CUBE); @@ -95,7 +95,7 @@ st_texture_create(struct st_context *st, assert(format); assert(screen->is_format_supported(screen, format, target, - PIPE_TEXTURE_USAGE_SAMPLER, 0)); + PIPE_BIND_SAMPLER_VIEW, 0)); memset(&pt, 0, sizeof(pt)); pt.target = target; @@ -104,9 +104,11 @@ st_texture_create(struct st_context *st, pt.width0 = width0; pt.height0 = height0; pt.depth0 = depth0; - pt.tex_usage = usage; + pt._usage = PIPE_USAGE_DEFAULT; + pt.bind = bind; + pt.flags = 0; - newtex = screen->texture_create(screen, &pt); + newtex = screen->resource_create(screen, &pt); assert(!newtex || pipe_is_referenced(&newtex->reference)); @@ -118,7 +120,7 @@ st_texture_create(struct st_context *st, * Check if a texture image can be pulled into a unified mipmap texture. */ GLboolean -st_texture_match_image(const struct pipe_texture *pt, +st_texture_match_image(const struct pipe_resource *pt, const struct gl_texture_image *image, GLuint face, GLuint level) { @@ -152,7 +154,7 @@ st_texture_match_image(const struct pipe_texture *pt, * These functions present that view to mesa: */ const GLuint * -st_texture_depth_offsets(struct pipe_texture *pt, GLuint level) +st_texture_depth_offsets(struct pipe_resource *pt, GLuint level) { static const GLuint zero = 0; @@ -168,7 +170,7 @@ st_texture_depth_offsets(struct pipe_texture *pt, GLuint level) * texture memory buffer, in bytes. */ GLuint -st_texture_image_offset(const struct pipe_texture * pt, +st_texture_image_offset(const struct pipe_resource * pt, GLuint face, GLuint level) { if (pt->target == PIPE_TEXTURE_CUBE) @@ -192,7 +194,7 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, GLuint x, GLuint y, GLuint w, GLuint h) { struct pipe_context *pipe = st->pipe; - struct pipe_texture *pt = stImage->pt; + struct pipe_resource *pt = stImage->pt; DBG("%s \n", __FUNCTION__); @@ -201,7 +203,7 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, usage, x, y, w, h); if (stImage->transfer) - return pipe->transfer_map(pipe, stImage->transfer); + return pipe_transfer_map(pipe, stImage->transfer); else return NULL; } @@ -215,9 +217,9 @@ st_texture_image_unmap(struct st_context *st, DBG("%s\n", __FUNCTION__); - pipe->transfer_unmap(pipe, stImage->transfer); + pipe_transfer_unmap(pipe, stImage->transfer); - pipe->tex_transfer_destroy(pipe, stImage->transfer); + pipe->transfer_destroy(pipe, stImage->transfer); } @@ -237,18 +239,18 @@ st_surface_data(struct pipe_context *pipe, const void *src, unsigned src_stride, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { - void *map = pipe->transfer_map(pipe, dst); + void *map = pipe_transfer_map(pipe, dst); - assert(dst->texture); + assert(dst->resource); util_copy_rect(map, - dst->texture->format, + dst->resource->format, dst->stride, dstx, dsty, width, height, src, src_stride, srcx, srcy); - pipe->transfer_unmap(pipe, dst); + pipe_transfer_unmap(pipe, dst); } @@ -256,7 +258,7 @@ st_surface_data(struct pipe_context *pipe, */ void st_texture_image_data(struct st_context *st, - struct pipe_texture *dst, + struct pipe_resource *dst, GLuint face, GLuint level, void *src, @@ -284,7 +286,7 @@ st_texture_image_data(struct st_context *st, u_minify(dst->width0, level), u_minify(dst->height0, level)); /* width, height */ - pipe->tex_transfer_destroy(pipe, dst_transfer); + pipe->transfer_destroy(pipe, dst_transfer); srcUB += src_image_stride; } @@ -295,8 +297,8 @@ st_texture_image_data(struct st_context *st, */ void st_texture_image_copy(struct pipe_context *pipe, - struct pipe_texture *dst, GLuint dstLevel, - struct pipe_texture *src, + struct pipe_resource *dst, GLuint dstLevel, + struct pipe_resource *src, GLuint face) { struct pipe_screen *screen = pipe->screen; @@ -337,10 +339,10 @@ st_texture_image_copy(struct pipe_context *pipe, #endif dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BIND_BLIT_DESTINATION); src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i, - PIPE_BUFFER_USAGE_GPU_READ); + PIPE_BIND_BLIT_SOURCE); pipe->surface_copy(pipe, dst_surface, @@ -416,7 +418,7 @@ st_bind_texture_surface(struct pipe_surface *ps, int target, int level, texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat, GL_RGBA, GL_UNSIGNED_BYTE); _mesa_set_fetch_functions(texImage, 2); - pipe_texture_reference(&stImage->pt, ps->texture); + pipe_resource_reference(&stImage->pt, ps->texture); _mesa_dirty_texobj(ctx, texObj, GL_TRUE); _mesa_unlock_texture(ctx, texObj); @@ -466,7 +468,7 @@ st_unbind_texture_surface(struct pipe_surface *ps, int target, int level) /* Make sure the pipe surface is still bound. The texture object is still * considered surface based even if this is the last bound surface. */ if (stImage->pt == ps->texture) { - pipe_texture_reference(&stImage->pt, NULL); + pipe_resource_reference(&stImage->pt, NULL); _mesa_clear_texture_image(ctx, texImage); _mesa_dirty_texobj(ctx, texObj, GL_TRUE); @@ -517,20 +519,21 @@ st_bind_teximage(struct st_framebuffer *stfb, uint surfIndex, st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); /* save the renderbuffer's surface/texture info */ - pipe_texture_reference(&strb->texture_save, strb->texture); + pipe_resource_reference(&strb->texture_save, strb->texture); pipe_surface_reference(&strb->surface_save, strb->surface); pipe_sampler_view_reference(&strb->sampler_view_save, strb->sampler_view); /* plug in new surface/texture info */ - pipe_texture_reference(&strb->texture, stImage->pt); + pipe_resource_reference(&strb->texture, stImage->pt); /* XXX: Shouldn't we release reference to old surface here? */ strb->surface = screen->get_tex_surface(screen, strb->texture, face, level, slice, - (PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE)); + (PIPE_BIND_RENDER_TARGET | + PIPE_BIND_BLIT_SOURCE | + PIPE_BIND_BLIT_DESTINATION)); pipe_sampler_view_reference(&strb->sampler_view, NULL); @@ -562,11 +565,11 @@ st_release_teximage(struct st_framebuffer *stfb, uint surfIndex, /* free tex surface, restore original */ pipe_surface_reference(&strb->surface, strb->surface_save); - pipe_texture_reference(&strb->texture, strb->texture_save); + pipe_resource_reference(&strb->texture, strb->texture_save); pipe_sampler_view_reference(&strb->sampler_view, strb->sampler_view_save); pipe_surface_reference(&strb->surface_save, NULL); - pipe_texture_reference(&strb->texture_save, NULL); + pipe_resource_reference(&strb->texture_save, NULL); pipe_sampler_view_reference(&strb->sampler_view, NULL); st->dirty.st |= ST_NEW_FRAMEBUFFER; @@ -576,14 +579,14 @@ st_release_teximage(struct st_framebuffer *stfb, uint surfIndex, void st_teximage_flush_before_map(struct st_context *st, - struct pipe_texture *pt, + struct pipe_resource *pt, unsigned int face, unsigned int level, enum pipe_transfer_usage usage) { struct pipe_context *pipe = st->pipe; unsigned referenced = - pipe->is_texture_referenced(pipe, pt, face, level); + pipe->is_resource_referenced(pipe, pt, face, level); if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) || (usage & PIPE_TRANSFER_WRITE))) diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index c62f7f2cc0d..76ea7e6950a 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -35,7 +35,7 @@ #include "main/mtypes.h" struct pipe_context; -struct pipe_texture; +struct pipe_resource; struct st_texture_image @@ -51,7 +51,7 @@ struct st_texture_image * Else if stImage->base.Data != NULL, image is stored there. * Else there is no image data. */ - struct pipe_texture *pt; + struct pipe_resource *pt; struct pipe_transfer *transfer; }; @@ -69,7 +69,7 @@ struct st_texture_object /* On validation any active images held in main memory or in other * textures will be copied to this texture and the old storage freed. */ - struct pipe_texture *pt; + struct pipe_resource *pt; /* Default sampler view attached to this texture object. Created lazily * on first binding. @@ -100,7 +100,7 @@ st_texture_object(struct gl_texture_object *obj) } -static INLINE struct pipe_texture * +static INLINE struct pipe_resource * st_get_texobj_texture(struct gl_texture_object *texObj) { struct st_texture_object *stObj = st_texture_object(texObj); @@ -108,7 +108,7 @@ st_get_texobj_texture(struct gl_texture_object *texObj) } -static INLINE struct pipe_texture * +static INLINE struct pipe_resource * st_get_stobj_texture(struct st_texture_object *stObj) { return stObj ? stObj->pt : NULL; @@ -117,7 +117,7 @@ st_get_stobj_texture(struct st_texture_object *stObj) static INLINE struct pipe_sampler_view * st_sampler_view_from_texture(struct pipe_context *pipe, - struct pipe_texture *texture) + struct pipe_resource *texture) { struct pipe_sampler_view templ; @@ -144,7 +144,7 @@ st_get_stobj_sampler_view(struct st_texture_object *stObj) } -extern struct pipe_texture * +extern struct pipe_resource * st_texture_create(struct st_context *st, enum pipe_texture_target target, enum pipe_format format, @@ -158,7 +158,7 @@ st_texture_create(struct st_context *st, /* Check if an image fits into an existing texture object. */ extern GLboolean -st_texture_match_image(const struct pipe_texture *pt, +st_texture_match_image(const struct pipe_resource *pt, const struct gl_texture_image *image, GLuint face, GLuint level); @@ -182,17 +182,17 @@ st_texture_image_unmap(struct st_context *st, * value. */ extern const GLuint * -st_texture_depth_offsets(struct pipe_texture *pt, GLuint level); +st_texture_depth_offsets(struct pipe_resource *pt, GLuint level); /* Return the linear offset of an image relative to the start of its region. */ extern GLuint -st_texture_image_offset(const struct pipe_texture *pt, +st_texture_image_offset(const struct pipe_resource *pt, GLuint face, GLuint level); extern GLuint -st_texture_texel_offset(const struct pipe_texture * pt, +st_texture_texel_offset(const struct pipe_resource * pt, GLuint face, GLuint level, GLuint col, GLuint row, GLuint img); @@ -201,7 +201,7 @@ st_texture_texel_offset(const struct pipe_texture * pt, */ extern void st_texture_image_data(struct st_context *st, - struct pipe_texture *dst, + struct pipe_resource *dst, GLuint face, GLuint level, void *src, GLuint src_row_pitch, GLuint src_image_pitch); @@ -210,13 +210,13 @@ st_texture_image_data(struct st_context *st, */ extern void st_texture_image_copy(struct pipe_context *pipe, - struct pipe_texture *dst, GLuint dstLevel, - struct pipe_texture *src, + struct pipe_resource *dst, GLuint dstLevel, + struct pipe_resource *src, GLuint face); extern void st_teximage_flush_before_map(struct st_context *st, - struct pipe_texture *pt, + struct pipe_resource *pt, unsigned int face, unsigned int level, enum pipe_transfer_usage usage); |