summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_pixeltransfer.c12
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c2
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c12
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c29
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c62
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c163
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c5
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c84
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c6
-rw-r--r--src/mesa/state_tracker/st_texture.c42
-rw-r--r--src/mesa/state_tracker/st_texture.h9
11 files changed, 246 insertions, 180 deletions
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index 999c148449..e500ac8684 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -126,7 +126,8 @@ create_color_map_texture(GLcontext *ctx)
/* create texture for color map/table */
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0,
- texSize, texSize, 1, 0);
+ texSize, texSize, 1, 0,
+ PIPE_TEXTURE_USAGE_SAMPLER);
return pt;
}
@@ -148,8 +149,10 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
uint *dest;
uint i, j;
- surface = screen->get_tex_surface(screen, pt, 0, 0, 0);
- dest = (uint *) pipe_surface_map(surface);
+ surface = screen->get_tex_surface(screen, pt, 0, 0, 0,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ dest = (uint *) screen->surface_map(screen, surface,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
/* Pack four 1D maps into a 2D texture:
* R map is placed horizontally, indexed by S, in channel 0
@@ -168,9 +171,8 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
}
}
- pipe_surface_unmap(surface);
+ screen->surface_unmap(screen, surface);
pipe_surface_reference(&surface, NULL);
- pipe->texture_update(pipe, pt, 0, 0x1);
}
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 10283d31a1..4ce7c41e90 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -150,7 +150,7 @@ update_samplers(struct st_context *st)
sampler->normalized_coords = 1;
sampler->lod_bias = st->ctx->Texture.Unit[su].LodBias;
- sampler->min_lod = MAX2(0.0f, texobj->MinLod);
+ sampler->min_lod = MAX2(0.0f, texobj->MinLod - texobj->BaseLevel);
sampler->max_lod = MIN2(texobj->MaxLevel - texobj->BaseLevel,
texobj->MaxLod);
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 1636bed91a..e4ef3e16b7 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -106,13 +106,15 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{
struct st_renderbuffer *acc_strb = st_renderbuffer(rb);
struct pipe_surface *acc_ps = acc_strb->surface;
+ struct pipe_screen *screen = ctx->st->pipe->screen;
const GLint xpos = ctx->DrawBuffer->_Xmin;
const GLint ypos = ctx->DrawBuffer->_Ymin;
const GLint width = ctx->DrawBuffer->_Xmax - xpos;
const GLint height = ctx->DrawBuffer->_Ymax - ypos;
GLvoid *map;
- map = pipe_surface_map(acc_ps);
+ map = screen->surface_map(screen, acc_ps,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
/* note acc_strb->format might not equal acc_ps->format */
switch (acc_strb->format) {
@@ -140,7 +142,7 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
_mesa_problem(ctx, "unexpected format in st_clear_accum_buffer()");
}
- pipe_surface_unmap(acc_ps);
+ screen->surface_unmap(screen, acc_ps);
}
@@ -150,10 +152,12 @@ accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias,
GLint xpos, GLint ypos, GLint width, GLint height,
struct st_renderbuffer *acc_strb)
{
+ struct pipe_screen *screen = ctx->st->pipe->screen;
struct pipe_surface *acc_ps = acc_strb->surface;
GLvoid *map;
- map = pipe_surface_map(acc_ps);
+ map = screen->surface_map(screen, acc_ps,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
/* note acc_strb->format might not equal acc_ps->format */
switch (acc_strb->format) {
@@ -174,7 +178,7 @@ accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias,
_mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
}
- pipe_surface_unmap(acc_ps);
+ screen->surface_unmap(screen, acc_ps);
}
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index ce8fefe703..f816e59104 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -321,16 +321,18 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
* Create texture to hold bitmap pattern.
*/
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, ctx->st->bitmap.tex_format,
- 0, width, height, 1, 0);
+ 0, width, height, 1, 0,
+ PIPE_TEXTURE_USAGE_SAMPLER);
if (!pt) {
_mesa_unmap_bitmap_pbo(ctx, unpack);
return NULL;
}
- surface = screen->get_tex_surface(screen, pt, 0, 0, 0);
+ surface = screen->get_tex_surface(screen, pt, 0, 0, 0,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
/* map texture surface */
- dest = pipe_surface_map(surface);
+ dest = screen->surface_map(screen, surface, PIPE_BUFFER_USAGE_CPU_WRITE);
/* Put image into texture surface */
memset(dest, 0xff, height * surface->pitch);
@@ -340,9 +342,8 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
_mesa_unmap_bitmap_pbo(ctx, unpack);
/* Release surface */
- pipe_surface_unmap(surface);
+ screen->surface_unmap(screen, surface);
pipe_surface_reference(&surface, NULL);
- pipe->texture_update(pipe, pt, 0, 0x1);
return pt;
}
@@ -539,13 +540,16 @@ 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, 0);
+ 1, 0,
+ PIPE_TEXTURE_USAGE_SAMPLER);
/* Map the texture surface.
* Subsequent glBitmap calls will write into the texture image.
*/
- cache->surf = screen->get_tex_surface(screen, cache->texture, 0, 0, 0);
- cache->buffer = pipe_surface_map(cache->surf);
+ cache->surf = screen->get_tex_surface(screen, cache->texture, 0, 0, 0,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ cache->buffer = screen->surface_map(screen, cache->surf,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
/* init image to all 0xff */
memset(cache->buffer, 0xff, BITMAP_CACHE_WIDTH * BITMAP_CACHE_HEIGHT);
@@ -562,6 +566,7 @@ st_flush_bitmap_cache(struct st_context *st)
if (st->ctx->DrawBuffer) {
struct bitmap_cache *cache = st->bitmap.cache;
struct pipe_context *pipe = st->pipe;
+ struct pipe_screen *screen = pipe->screen;
assert(cache->xmin <= cache->xmax);
/*
@@ -574,12 +579,18 @@ st_flush_bitmap_cache(struct st_context *st)
/* The texture surface has been mapped until now.
* So unmap and release the texture surface before drawing.
*/
+#if 0
pipe_surface_unmap(cache->surf);
pipe_surface_reference(&cache->surf, NULL);
+#else
+ screen->surface_unmap(screen, cache->surf);
+ screen->tex_surface_release(screen, &cache->surf);
+#endif
+#if 0
/* XXX is this needed? */
pipe->texture_update(pipe, cache->texture, 0, 0x1);
-
+#endif
draw_bitmap_quad(st->ctx,
cache->xpos,
cache->ypos,
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 65bfd6cfcc..8c775ad886 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -346,7 +346,8 @@ make_texture(struct st_context *st,
return NULL;
pt = st_texture_create(st, PIPE_TEXTURE_2D, pipeFormat, 0, width, height,
- 1, 0);
+ 1, 0,
+ PIPE_TEXTURE_USAGE_SAMPLER);
if (!pt) {
_mesa_unmap_drawpix_pbo(ctx, unpack);
return NULL;
@@ -362,10 +363,12 @@ make_texture(struct st_context *st,
/* we'll do pixel transfer in a fragment shader */
ctx->_ImageTransferState = 0x0;
- surface = screen->get_tex_surface(screen, pt, 0, 0, 0);
+ surface = screen->get_tex_surface(screen, pt, 0, 0, 0,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
/* map texture surface */
- dest = pipe_surface_map(surface);
+ dest = screen->surface_map(screen, surface,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
/* Put image into texture surface.
* Note that the image is actually going to be upside down in
@@ -384,9 +387,8 @@ make_texture(struct st_context *st,
unpack);
/* unmap */
- pipe_surface_unmap(surface);
+ screen->surface_unmap(screen, surface);
pipe_surface_reference(&surface, NULL);
- pipe->texture_update(pipe, pt, 0, 0x1);
assert(success);
@@ -731,6 +733,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
{
struct st_context *st = ctx->st;
struct pipe_context *pipe = st->pipe;
+ struct pipe_screen *screen = pipe->screen;
struct pipe_surface *ps = st->state.framebuffer.zsbuf;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
GLint skipPixels;
@@ -739,7 +742,8 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
/* map the stencil buffer */
- stmap = pipe_surface_map(ps);
+ stmap = screen->surface_map(screen, ps,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
/* if width > MAX_WIDTH, have to process image in chunks */
skipPixels = 0;
@@ -796,7 +800,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
}
/* unmap the stencil buffer */
- pipe_surface_unmap(ps);
+ screen->surface_unmap(screen, ps);
}
@@ -869,6 +873,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint dstx, GLint dsty)
{
struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer);
+ struct pipe_screen *screen = ctx->st->pipe->screen;
struct pipe_surface *psDraw = rbDraw->surface;
ubyte *drawMap;
ubyte *buffer;
@@ -885,7 +890,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
&ctx->DefaultPacking, buffer);
/* map the stencil buffer */
- drawMap = pipe_surface_map(psDraw);
+ drawMap = screen->surface_map(screen, psDraw, PIPE_BUFFER_USAGE_CPU_WRITE);
/* draw */
/* XXX PixelZoom not handled yet */
@@ -925,7 +930,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
free(buffer);
/* unmap the stencil buffer */
- pipe_surface_unmap(psDraw);
+ screen->surface_unmap(screen, psDraw);
}
@@ -990,17 +995,19 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, texFormat, 0,
- width, height, 1, 0);
+ width, height, 1, 0,
+ PIPE_TEXTURE_USAGE_SAMPLER);
if (!pt)
return;
- psTex = screen->get_tex_surface(screen, pt, 0, 0, 0);
-
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
srcy = ctx->DrawBuffer->Height - srcy - height;
}
if (srcFormat == texFormat) {
+ psTex = screen->get_tex_surface(screen, pt, 0, 0, 0,
+ PIPE_BUFFER_USAGE_GPU_WRITE );
+
/* copy source framebuffer surface into mipmap/texture */
pipe->surface_copy(pipe,
FALSE,
@@ -1009,21 +1016,26 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
psRead,
srcx, srcy, width, height);
}
- else if (type == GL_COLOR) {
- /* alternate path using get/put_tile() */
- GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+ else {
+ psTex = screen->get_tex_surface(screen, pt, 0, 0, 0,
+ PIPE_BUFFER_USAGE_CPU_WRITE );
- pipe_get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf);
- pipe_put_tile_rgba(pipe, psTex, 0, 0, width, height, buf);
+ if (type == GL_COLOR) {
+ /* alternate path using get/put_tile() */
+ GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- free(buf);
- }
- else {
- /* GL_DEPTH */
- GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint));
- pipe_get_tile_z(pipe, psRead, srcx, srcy, width, height, buf);
- pipe_put_tile_z(pipe, psTex, 0, 0, width, height, buf);
- free(buf);
+ pipe_get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf);
+ pipe_put_tile_rgba(pipe, psTex, 0, 0, width, height, buf);
+
+ free(buf);
+ }
+ else {
+ /* GL_DEPTH */
+ GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint));
+ pipe_get_tile_z(pipe, psRead, srcx, srcy, width, height, buf);
+ pipe_put_tile_z(pipe, psTex, 0, 0, width, height, buf);
+ free(buf);
+ }
}
/* draw textured quad */
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index fc8a5ea7f6..1fa82b07e6 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -77,6 +77,11 @@ init_renderbuffer_bits(struct st_renderbuffer *strb,
return info.size;
}
+static INLINE GLboolean pf_is_depth_stencil( enum pipe_format format )
+{
+ return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
+ pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0;
+}
/**
* gl_renderbuffer::AllocStorage()
@@ -90,80 +95,94 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
{
struct pipe_context *pipe = ctx->st->pipe;
struct st_renderbuffer *strb = st_renderbuffer(rb);
- enum pipe_format pipeFormat;
- GLbitfield flags = 0x0; /* XXX needed? */
- int ret;
-
- if (!strb->surface) {
- /* first time surface creation */
- strb->surface = pipe->winsys->surface_alloc(pipe->winsys);
- assert(strb->surface);
- assert(strb->surface->refcount);
- assert(strb->surface->winsys);
- if (!strb->surface)
- return GL_FALSE;
+ struct pipe_texture template, *texture;
+ unsigned surface_usage;
+
+ /* Free the old surface (and texture if we hold the last
+ * reference):
+ */
+ pipe_surface_reference( &strb->surface, NULL );
+
+ memset(&template, 0, sizeof(template));
+
+ if (strb->format != PIPE_FORMAT_NONE) {
+ template.format = strb->format;
}
- else if (strb->surface->buffer) {
- /* release/discard the old surface buffer */
- pipe_reference_buffer(pipe, &strb->surface->buffer, NULL);
+ else {
+ template.format = st_choose_renderbuffer_format(pipe, internalFormat);
}
- /* Determine surface format here */
- if (strb->format != PIPE_FORMAT_NONE) {
- assert(strb->format != 0);
- /* we'll hit this for front/back color bufs */
- pipeFormat = strb->format;
+ strb->Base.Width = width;
+ strb->Base.Height = height;
+ init_renderbuffer_bits(strb, template.format);
+
+ template.target = PIPE_TEXTURE_2D;
+ template.compressed = 0;
+ template.cpp = pf_get_size(template.format);
+ template.width[0] = width;
+ template.height[0] = height;
+ template.depth[0] = 1;
+ template.last_level = 0;
+
+ if (pf_is_depth_stencil(template.format)) {
+ template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
}
else {
- pipeFormat = st_choose_renderbuffer_format(pipe, internalFormat);
+ template.tex_usage = (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+ PIPE_TEXTURE_USAGE_RENDER_TARGET);
}
- init_renderbuffer_bits(strb, pipeFormat);
-
- ret = pipe->winsys->surface_alloc_storage(pipe->winsys,
- strb->surface,
- width,
- height,
- pipeFormat,
- flags);
- if (ret || !strb->surface->buffer) {
- if (pipeFormat == DEFAULT_ACCUM_PIPE_FORMAT) {
- /* Accum buffer. Try a different surface format. Since accum
- * buffers are s/w only for now, the surface pixel format doesn't
- * really matter, only that the buffer is large enough.
- */
- int sz, mult;
- enum pipe_format accum_format;
-
- /* allocate a buffer of (typically) double height to get 64bpp */
- accum_format = st_choose_renderbuffer_format(pipe, GL_RGBA);
- sz = pf_get_size(accum_format);
- mult = pf_get_size(DEFAULT_ACCUM_PIPE_FORMAT) / sz;
-
- ret = pipe->winsys->surface_alloc_storage(pipe->winsys,
- strb->surface,
- width, height * mult,
- accum_format, flags);
- if (ret)
- return GL_FALSE; /* we've _really_ failed */
-
- }
- else {
- return GL_FALSE; /* out of memory, try s/w buffer? */
- }
+
+ /* Probably need dedicated flags for surface usage too:
+ */
+ surface_usage = (PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE |
+ PIPE_BUFFER_USAGE_CPU_READ |
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+
+ texture = pipe->screen->texture_create( pipe->screen,
+ &template );
+
+ /* Special path for accum buffers.
+ *
+ * Try a different surface format. Since accum buffers are s/w
+ * only for now, the surface pixel format doesn't really matter,
+ * only that the buffer is large enough.
+ */
+ if (!texture && template.format == DEFAULT_ACCUM_PIPE_FORMAT)
+ {
+ /* Actually, just setting this usage value should be sufficient
+ * to tell the driver to go ahead and allocate the buffer, even
+ * if HW doesn't support the format.
+ */
+ template.tex_usage = 0;
+ surface_usage = (PIPE_BUFFER_USAGE_CPU_READ |
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+
+ texture = pipe->screen->texture_create( pipe->screen,
+ &template );
+
}
- ASSERT(strb->surface->buffer);
- ASSERT(strb->surface->format);
- ASSERT(strb->surface->cpp);
- ASSERT(strb->surface->width == width);
- /*ASSERT(strb->surface->height == height);*/
- ASSERT(strb->surface->pitch);
+ if (!texture)
+ return FALSE;
- strb->Base.Width = width;
- strb->Base.Height = height;
+ strb->surface = pipe->screen->get_tex_surface( pipe->screen,
+ texture,
+ 0, 0, 0,
+ surface_usage );
+
+ pipe_texture_reference( &texture, NULL );
- return GL_TRUE;
+ assert(strb->surface->buffer);
+ assert(strb->surface->format);
+ assert(strb->surface->cpp);
+ assert(strb->surface->width == width);
+ assert(strb->surface->height == height);
+ assert(strb->surface->pitch);
+
+
+ return strb->surface != NULL;
}
@@ -175,10 +194,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
{
struct st_renderbuffer *strb = st_renderbuffer(rb);
ASSERT(strb);
- if (strb->surface) {
- struct pipe_winsys *ws = strb->surface->winsys;
- ws->surface_release(ws, &strb->surface);
- }
+ pipe_surface_reference(&strb->surface, NULL);
free(strb);
}
@@ -368,7 +384,11 @@ st_render_texture(GLcontext *ctx,
strb->surface = screen->get_tex_surface(screen, pt,
att->CubeMapFace,
att->TextureLevel,
- att->Zoffset);
+ att->Zoffset,
+ PIPE_BUFFER_USAGE_CPU_READ |
+ PIPE_BUFFER_USAGE_CPU_WRITE |
+ PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE);
assert(strb->surface);
assert(screen->is_format_supported(screen, strb->surface->format, PIPE_TEXTURE));
assert(screen->is_format_supported(screen, strb->surface->format, PIPE_SURFACE));
@@ -396,22 +416,19 @@ static void
st_finish_render_texture(GLcontext *ctx,
struct gl_renderbuffer_attachment *att)
{
+ struct pipe_screen *screen = ctx->st->pipe->screen;
struct st_renderbuffer *strb = st_renderbuffer(att->Renderbuffer);
assert(strb);
ctx->st->pipe->flush(ctx->st->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
- ctx->st->pipe->texture_update(ctx->st->pipe,
- st_get_texobj_texture(att->Texture),
- att->CubeMapFace, 1 << att->TextureLevel);
+ screen->tex_surface_release( screen, &strb->surface );
/*
printf("FINISH RENDER TO TEXTURE surf=%p\n", strb->surface);
*/
- pipe_surface_reference(&strb->surface, NULL);
-
_mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
/* restore previous framebuffer state */
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index ddbe36106c..e242195e7a 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -61,13 +61,14 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
GLvoid *pixels)
{
struct gl_framebuffer *fb = ctx->ReadBuffer;
+ struct pipe_screen *screen = ctx->st->pipe->screen;
struct st_renderbuffer *strb = st_renderbuffer(fb->_StencilBuffer);
struct pipe_surface *ps = strb->surface;
ubyte *stmap;
GLint j;
/* map the stencil buffer */
- stmap = pipe_surface_map(ps);
+ stmap = screen->surface_map(screen, ps, PIPE_BUFFER_USAGE_CPU_READ);
/* width should never be > MAX_WIDTH since we did clipping earlier */
ASSERT(width <= MAX_WIDTH);
@@ -124,7 +125,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
/* unmap the stencil buffer */
- pipe_surface_unmap(ps);
+ screen->surface_unmap(screen, ps);
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 02ef961e4d..c877e4382d 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -333,7 +333,9 @@ guess_and_alloc_texture(struct st_context *st,
width,
height,
depth,
- comp_byte);
+ comp_byte,
+ ( PIPE_TEXTURE_USAGE_RENDER_TARGET |
+ PIPE_TEXTURE_USAGE_SAMPLER ));
DBG("%s - success\n", __FUNCTION__);
}
@@ -478,7 +480,6 @@ st_TexImage(GLcontext * ctx,
struct gl_texture_image *texImage,
GLsizei imageSize, int compressed)
{
- struct pipe_context *pipe = ctx->st->pipe;
struct st_texture_object *stObj = st_texture_object(texObj);
struct st_texture_image *stImage = st_texture_image(texImage);
GLint postConvWidth, postConvHeight;
@@ -637,7 +638,8 @@ st_TexImage(GLcontext * ctx,
return;
if (stImage->pt) {
- texImage->Data = st_texture_image_map(ctx->st, stImage, 0);
+ texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
}
else {
@@ -686,8 +688,9 @@ st_TexImage(GLcontext * ctx,
}
if (stImage->pt && i < depth) {
- st_texture_image_unmap(stImage);
- texImage->Data = st_texture_image_map(ctx->st, stImage, i);
+ st_texture_image_unmap(ctx->st, stImage);
+ texImage->Data = st_texture_image_map(ctx->st, stImage, i,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
src += srcImageStride;
}
}
@@ -696,13 +699,10 @@ st_TexImage(GLcontext * ctx,
_mesa_unmap_teximage_pbo(ctx, unpack);
if (stImage->pt) {
- st_texture_image_unmap(stImage);
+ st_texture_image_unmap(ctx->st, stImage);
texImage->Data = NULL;
}
- if (stObj->pt)
- pipe->texture_update(pipe, stObj->pt, stImage->face, (1 << level));
-
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
ctx->Driver.GenerateMipmap(ctx, target, texObj);
}
@@ -795,7 +795,8 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
/* Image is stored in hardware format in a buffer managed by the
* kernel. Need to explicitly map and unmap it.
*/
- texImage->Data = st_texture_image_map(ctx->st, stImage, 0);
+ texImage->Data = st_texture_image_map(ctx->st, stImage, 0,
+ PIPE_BUFFER_USAGE_CPU_READ);
texImage->RowStride = stImage->surface->pitch;
}
else {
@@ -825,8 +826,9 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
}
if (stImage->pt && i < depth) {
- st_texture_image_unmap(stImage);
- texImage->Data = st_texture_image_map(ctx->st, stImage, i);
+ st_texture_image_unmap(ctx->st, stImage);
+ texImage->Data = st_texture_image_map(ctx->st, stImage, i,
+ PIPE_BUFFER_USAGE_CPU_READ);
dest += dstImageStride;
}
}
@@ -835,7 +837,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
/* Unmap */
if (stImage->pt) {
- st_texture_image_unmap(stImage);
+ st_texture_image_unmap(ctx->st, stImage);
texImage->Data = NULL;
}
}
@@ -876,8 +878,6 @@ st_TexSubimage(GLcontext * ctx,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- struct pipe_context *pipe = ctx->st->pipe;
- struct st_texture_object *stObj = st_texture_object(texObj);
struct st_texture_image *stImage = st_texture_image(texImage);
GLuint dstRowStride;
GLuint srcImageStride = _mesa_image_image_stride(packing, width, height,
@@ -899,7 +899,8 @@ st_TexSubimage(GLcontext * ctx,
* from uploading the buffer under us.
*/
if (stImage->pt) {
- texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset);
+ texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
dstRowStride = stImage->surface->pitch * stImage->surface->cpp;
}
@@ -924,8 +925,9 @@ st_TexSubimage(GLcontext * ctx,
if (stImage->pt && i < depth) {
/* map next slice of 3D texture */
- st_texture_image_unmap(stImage);
- texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset + i);
+ st_texture_image_unmap(ctx->st, stImage);
+ texImage->Data = st_texture_image_map(ctx->st, stImage, zoffset + i,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
src += srcImageStride;
}
}
@@ -937,11 +939,9 @@ st_TexSubimage(GLcontext * ctx,
_mesa_unmap_teximage_pbo(ctx, packing);
if (stImage->pt) {
- st_texture_image_unmap(stImage);
+ st_texture_image_unmap(ctx->st, stImage);
texImage->Data = NULL;
}
-
- pipe->texture_update(pipe, stObj->pt, stImage->face, (1 << level));
}
@@ -1060,7 +1060,8 @@ fallback_copy_texsubimage(GLcontext *ctx,
src_surf = strb->surface;
- dest_surf = screen->get_tex_surface(screen, pt, face, level, destZ);
+ dest_surf = screen->get_tex_surface(screen, pt, face, level, destZ,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
assert(width <= MAX_WIDTH);
@@ -1121,7 +1122,6 @@ do_copy_texsubimage(GLcontext *ctx,
struct gl_texture_image *texImage =
_mesa_select_tex_image(ctx, texObj, target, level);
struct st_texture_image *stImage = st_texture_image(texImage);
- struct st_texture_object *stObj = st_texture_object(texObj);
GLenum baseFormat = texImage->InternalFormat;
struct gl_framebuffer *fb = ctx->ReadBuffer;
struct st_renderbuffer *strb;
@@ -1159,7 +1159,8 @@ do_copy_texsubimage(GLcontext *ctx,
dest_format = stImage->pt->format;
dest_surface = screen->get_tex_surface(screen, stImage->pt, stImage->face,
- stImage->level, destZ);
+ stImage->level, destZ,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
if (ctx->_ImageTransferState == 0x0 &&
strb->surface->buffer &&
@@ -1225,8 +1226,6 @@ do_copy_texsubimage(GLcontext *ctx,
pipe_surface_reference(&dest_surface, NULL);
- pipe->texture_update(pipe, stObj->pt, stImage->face, (1 << level));
-
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
ctx->Driver.GenerateMipmap(ctx, target, texObj);
}
@@ -1366,7 +1365,7 @@ calculate_first_last_level(struct st_texture_object *stObj)
}
else {
firstLevel = 0;
- lastLevel = MIN2(tObj->MaxLevel, tObj->Image[0][0]->WidthLog2);
+ lastLevel = MIN2(tObj->MaxLevel, tObj->Image[0][tObj->BaseLevel]->WidthLog2);
}
break;
case GL_TEXTURE_RECTANGLE_NV:
@@ -1474,19 +1473,17 @@ st_finalize_texture(GLcontext *ctx,
/* If we already have a gallium texture, check that it matches the texture
* object's format, target, size, num_levels, etc.
*/
- if (stObj->pt) {
- const enum pipe_format fmt =
- st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat);
- if (stObj->pt->target != gl_target_to_pipe(stObj->base.Target) ||
- stObj->pt->format != fmt ||
- stObj->pt->last_level < stObj->lastLevel ||
- stObj->pt->width[0] != firstImage->base.Width2 ||
- stObj->pt->height[0] != firstImage->base.Height2 ||
- stObj->pt->depth[0] != firstImage->base.Depth2 ||
- stObj->pt->cpp != cpp ||
- stObj->pt->compressed != firstImage->base.IsCompressed) {
- pipe_texture_release(&stObj->pt);
- }
+ if (stObj->pt &&
+ (stObj->pt->target != gl_target_to_pipe(stObj->base.Target) ||
+ stObj->pt->format !=
+ st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat) ||
+ stObj->pt->last_level < stObj->lastLevel ||
+ stObj->pt->cpp != cpp ||
+ stObj->pt->width[0] != firstImage->base.Width2 ||
+ stObj->pt->height[0] != firstImage->base.Height2 ||
+ stObj->pt->depth[0] != firstImage->base.Depth2 ||
+ stObj->pt->compressed != firstImage->base.IsCompressed)) {
+ pipe_texture_release(&stObj->pt);
}
/* May need to create a new gallium texture:
@@ -1499,7 +1496,11 @@ st_finalize_texture(GLcontext *ctx,
firstImage->base.Width2,
firstImage->base.Height2,
firstImage->base.Depth2,
- comp_byte);
+ comp_byte,
+
+ ( PIPE_TEXTURE_USAGE_RENDER_TARGET |
+ PIPE_TEXTURE_USAGE_SAMPLER ));
+
if (!stObj->pt) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
return GL_FALSE;
@@ -1519,7 +1520,6 @@ st_finalize_texture(GLcontext *ctx,
if (stImage && stObj->pt != stImage->pt) {
copy_image_data_to_texture(ctx->st, stObj, level, stImage);
*needFlush = GL_TRUE;
- pipe->texture_update(pipe, stObj->pt, face, (1 << level));
}
}
}
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 1a0e19c2f9..cfacfdd04c 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -123,8 +123,10 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
const ubyte *srcData;
ubyte *dstData;
- srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice);
- dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice);
+ srcSurf = screen->get_tex_surface(screen, pt, face, srcLevel, zslice,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ dstSurf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
srcData = (ubyte *) pipe_buffer_map(pipe, srcSurf->buffer,
PIPE_BUFFER_USAGE_CPU_READ)
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index f68bef1207..2b3742d4e5 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -75,7 +75,8 @@ st_texture_create(struct st_context *st,
GLuint width0,
GLuint height0,
GLuint depth0,
- GLuint compress_byte)
+ GLuint compress_byte,
+ GLuint usage )
{
struct pipe_texture pt, *newtex;
struct pipe_screen *screen = st->pipe->screen;
@@ -98,6 +99,7 @@ st_texture_create(struct st_context *st,
pt.depth[0] = depth0;
pt.compressed = compress_byte ? 1 : 0;
pt.cpp = pt.compressed ? compress_byte : st_sizeof_format(format);
+ pt.tex_usage = usage;
newtex = screen->texture_create(screen, &pt);
@@ -184,25 +186,30 @@ st_texture_image_offset(const struct pipe_texture * pt,
*/
GLubyte *
st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
- GLuint zoffset)
+ GLuint zoffset,
+ GLuint flags )
{
struct pipe_screen *screen = st->pipe->screen;
struct pipe_texture *pt = stImage->pt;
DBG("%s \n", __FUNCTION__);
stImage->surface = screen->get_tex_surface(screen, pt, stImage->face,
- stImage->level, zoffset);
+ stImage->level, zoffset,
+ flags);
- return pipe_surface_map(stImage->surface);
+ return screen->surface_map(screen, stImage->surface, flags);
}
void
-st_texture_image_unmap(struct st_texture_image *stImage)
+st_texture_image_unmap(struct st_context *st,
+ struct st_texture_image *stImage)
{
+ struct pipe_screen *screen = st->pipe->screen;
+
DBG("%s\n", __FUNCTION__);
- pipe_surface_unmap(stImage->surface);
+ screen->surface_unmap(screen, stImage->surface);
pipe_surface_reference(&stImage->surface, NULL);
}
@@ -224,12 +231,15 @@ st_surface_data(struct pipe_context *pipe,
const void *src, unsigned src_pitch,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- pipe_copy_rect(pipe_surface_map(dst),
+ struct pipe_screen *screen = pipe->screen;
+ void *map = screen->surface_map(screen, dst, PIPE_BUFFER_USAGE_CPU_WRITE);
+
+ pipe_copy_rect(map,
dst->cpp,
dst->pitch,
dstx, dsty, width, height, src, src_pitch, srcx, srcy);
- pipe_surface_unmap(dst);
+ screen->surface_unmap(screen, dst);
}
@@ -256,7 +266,8 @@ st_texture_image_data(struct pipe_context *pipe,
if(dst->compressed)
height /= 4;
- dst_surface = screen->get_tex_surface(screen, dst, face, level, i);
+ dst_surface = screen->get_tex_surface(screen, dst, face, level, i,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
st_surface_data(pipe, dst_surface,
0, 0, /* dstx, dsty */
@@ -265,7 +276,7 @@ st_texture_image_data(struct pipe_context *pipe,
0, 0, /* source x, y */
dst->width[level], height); /* width, height */
- pipe_surface_reference(&dst_surface, NULL);
+ screen->tex_surface_release(screen, &dst_surface);
srcUB += src_image_pitch * dst->cpp;
}
@@ -304,8 +315,11 @@ st_texture_image_copy(struct pipe_context *pipe,
assert(src->width[srcLevel] == width);
assert(src->height[srcLevel] == height);
- dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i);
- src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i);
+ dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i,
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+
+ src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
+ PIPE_BUFFER_USAGE_GPU_READ);
pipe->surface_copy(pipe,
FALSE,
@@ -315,7 +329,7 @@ st_texture_image_copy(struct pipe_context *pipe,
0, 0, /* srcX, Y */
width, copyHeight);
- pipe_surface_reference(&dst_surface, NULL);
- pipe_surface_reference(&src_surface, NULL);
+ screen->tex_surface_release(screen, &src_surface);
+ screen->tex_surface_release(screen, &dst_surface);
}
}
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index b05762113c..55d1a367b5 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -103,7 +103,8 @@ st_texture_create(struct st_context *st,
GLuint width0,
GLuint height0,
GLuint depth0,
- GLuint compress_byte);
+ GLuint compress_byte,
+ GLuint tex_usage );
/* Check if an image fits into an existing texture object.
@@ -119,10 +120,12 @@ st_texture_match_image(const struct pipe_texture *pt,
extern GLubyte *
st_texture_image_map(struct st_context *st,
struct st_texture_image *stImage,
- GLuint zoffset);
+ GLuint zoffset,
+ GLuint flags);
extern void
-st_texture_image_unmap(struct st_texture_image *stImage);
+st_texture_image_unmap(struct st_context *st,
+ struct st_texture_image *stImage);
/* Return pointers to each 2d slice within an image. Indexed by depth