aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-02-22 09:28:23 +0100
committermarha <marha@users.sourceforge.net>2012-02-22 09:28:23 +0100
commitecc59cb52ffe4a84fddae997bba64adad35d5e93 (patch)
tree233c2cf0ea65dcf0b671f28e14b1fb083dac87e3 /mesalib/src/mesa/state_tracker
parentd19dd4c9cf37b7b691552c4f4dd873471e31ca68 (diff)
parent6baac61e6ca9cd314e689dfe7f84771aad08c66e (diff)
downloadvcxsrv-ecc59cb52ffe4a84fddae997bba64adad35d5e93.tar.gz
vcxsrv-ecc59cb52ffe4a84fddae997bba64adad35d5e93.tar.bz2
vcxsrv-ecc59cb52ffe4a84fddae997bba64adad35d5e93.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_sampler.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_texture.c7
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c57
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c64
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.h2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c77
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.h106
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c18
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.h3
-rw-r--r--mesalib/src/mesa/state_tracker/st_gen_mipmap.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.h31
13 files changed, 119 insertions, 273 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
index ee69fc390..dc0c789c5 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
@@ -35,6 +35,7 @@
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/samplerobj.h"
+#include "main/texobj.h"
#include "st_context.h"
#include "st_cb_texture.h"
@@ -132,7 +133,7 @@ convert_sampler(struct st_context *st,
texobj = ctx->Texture.Unit[texUnit]._Current;
if (!texobj) {
- texobj = st_get_default_texture(st);
+ texobj = _mesa_get_fallback_texture(ctx, TEXTURE_2D_INDEX);
}
msamp = _mesa_get_samplerobj(ctx, texUnit);
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index e8941da8d..f27a320a5 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -35,6 +35,7 @@
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/samplerobj.h"
+#include "main/texobj.h"
#include "program/prog_instruction.h"
#include "st_context.h"
@@ -137,7 +138,7 @@ check_sampler_swizzle(struct pipe_sampler_view *sv,
}
-static INLINE struct pipe_sampler_view *
+static struct pipe_sampler_view *
st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
struct st_texture_object *stObj,
const struct gl_sampler_object *samp,
@@ -164,7 +165,7 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
}
-static INLINE struct pipe_sampler_view *
+static struct pipe_sampler_view *
st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
struct pipe_context *pipe,
const struct gl_sampler_object *samp,
@@ -201,7 +202,7 @@ update_single_texture(struct st_context *st,
texObj = ctx->Texture.Unit[texUnit]._Current;
if (!texObj) {
- texObj = st_get_default_texture(st);
+ texObj = _mesa_get_fallback_texture(ctx, TEXTURE_2D_INDEX);
samp = &texObj->Sampler;
}
stObj = st_texture_object(texObj);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index a8365a708..193583372 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -388,10 +388,7 @@ check_clear_depth_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuff
GLboolean maskStencil
= (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
- assert(rb->Format == MESA_FORMAT_S8 ||
- rb->Format == MESA_FORMAT_Z24_S8 ||
- rb->Format == MESA_FORMAT_S8_Z24 ||
- rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ assert(_mesa_get_format_bits(rb->Format, GL_STENCIL_BITS) > 0);
if (ctx->Scissor.Enabled &&
(ctx->Scissor.X != 0 ||
@@ -444,10 +441,7 @@ check_clear_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb
const GLboolean maskStencil
= (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
- assert(rb->Format == MESA_FORMAT_S8 ||
- rb->Format == MESA_FORMAT_Z24_S8 ||
- rb->Format == MESA_FORMAT_S8_Z24 ||
- rb->Format == MESA_FORMAT_Z32_FLOAT_X24S8);
+ assert(_mesa_get_format_bits(rb->Format, GL_STENCIL_BITS) > 0);
if (maskStencil)
return GL_TRUE;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 386eed290..de4c189a8 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -33,6 +33,7 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/bufferobj.h"
+#include "main/format_pack.h"
#include "main/macros.h"
#include "main/mfeatures.h"
#include "main/mtypes.h"
@@ -842,12 +843,14 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
y = ctx->DrawBuffer->Height - y - height;
}
- if(format != GL_DEPTH_STENCIL &&
- util_format_get_component_bits(strb->format,
- UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
+ if (format == GL_STENCIL_INDEX &&
+ _mesa_is_format_packed_depth_stencil(strb->Base.Format)) {
+ /* writing stencil to a combined depth+stencil buffer */
usage = PIPE_TRANSFER_READ_WRITE;
- else
+ }
+ else {
usage = PIPE_TRANSFER_WRITE;
+ }
pt = pipe_get_transfer(pipe, strb->texture,
strb->rtt_level, strb->rtt_face + strb->rtt_slice,
@@ -1209,8 +1212,7 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
}
}
- if (util_format_get_component_bits(rbDraw->format,
- UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
+ if (_mesa_is_format_packed_depth_stencil(rbDraw->Base.Format))
usage = PIPE_TRANSFER_READ_WRITE;
else
usage = PIPE_TRANSFER_WRITE;
@@ -1248,48 +1250,7 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
dst = drawMap + y * ptDraw->stride;
src = buffer + i * width;
- switch (ptDraw->resource->format) {
- case PIPE_FORMAT_Z24_UNORM_S8_UINT:
- {
- uint *dst4 = (uint *) dst;
- int j;
- assert(usage == PIPE_TRANSFER_READ_WRITE);
- for (j = 0; j < width; j++) {
- *dst4 = (*dst4 & 0xffffff) | (src[j] << 24);
- dst4++;
- }
- }
- break;
- case PIPE_FORMAT_S8_UINT_Z24_UNORM:
- {
- uint *dst4 = (uint *) dst;
- int j;
- assert(usage == PIPE_TRANSFER_READ_WRITE);
- for (j = 0; j < width; j++) {
- *dst4 = (*dst4 & 0xffffff00) | (src[j] & 0xff);
- dst4++;
- }
- }
- break;
- case PIPE_FORMAT_S8_UINT:
- assert(usage == PIPE_TRANSFER_WRITE);
- memcpy(dst, src, width);
- break;
- case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
- {
- uint *dst4 = (uint *) dst;
- int j;
- dst4++;
- assert(usage == PIPE_TRANSFER_READ_WRITE);
- for (j = 0; j < width; j++) {
- *dst4 = src[j] & 0xff;
- dst4 += 2;
- }
- }
- break;
- default:
- assert(0);
- }
+ _mesa_pack_ubyte_stencil_row(rbDraw->Base.Format, width, src, dst);
}
free(buffer);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index 1cbc0d606..300c3f0eb 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -97,7 +97,6 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
strb->Base.Height = height;
strb->Base.Format = st_pipe_format_to_mesa_format(format);
strb->Base._BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
- strb->format = format;
strb->defined = GL_FALSE; /* undefined contents now */
@@ -106,10 +105,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
free(strb->data);
- assert(strb->format != PIPE_FORMAT_NONE);
-
- strb->stride = util_format_get_stride(strb->format, width);
- size = util_format_get_2d_size(strb->format, strb->stride, height);
+ size = _mesa_format_image_size(strb->Base.Format, width, height, 1);
strb->data = malloc(size);
@@ -142,7 +138,12 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
if (util_format_is_depth_or_stencil(format)) {
template.bind = PIPE_BIND_DEPTH_STENCIL;
}
+ else if (strb->Base.Name != 0) {
+ /* this is a user-created renderbuffer */
+ template.bind = PIPE_BIND_RENDER_TARGET;
+ }
else {
+ /* this is a window-system buffer */
template.bind = (PIPE_BIND_DISPLAY_TARGET |
PIPE_BIND_RENDER_TARGET);
}
@@ -152,7 +153,6 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
if (!strb->texture)
return FALSE;
- memset(&surf_tmpl, 0, sizeof(surf_tmpl));
u_surface_default_template(&surf_tmpl, strb->texture, template.bind);
strb->surface = pipe->create_surface(pipe,
strb->texture,
@@ -203,10 +203,10 @@ st_new_renderbuffer(struct gl_context *ctx, GLuint name)
{
struct st_renderbuffer *strb = ST_CALLOC_STRUCT(st_renderbuffer);
if (strb) {
+ assert(name != 0);
_mesa_init_renderbuffer(&strb->Base, name);
strb->Base.Delete = st_renderbuffer_delete;
strb->Base.AllocStorage = st_renderbuffer_alloc_storage;
- strb->format = PIPE_FORMAT_NONE;
return &strb->Base;
}
return NULL;
@@ -233,7 +233,6 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
strb->Base.NumSamples = samples;
strb->Base.Format = st_pipe_format_to_mesa_format(format);
strb->Base._BaseFormat = _mesa_get_format_base_format(strb->Base.Format);
- strb->format = format;
strb->software = sw;
switch (format) {
@@ -297,8 +296,6 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
}
-
-
/**
* Called via ctx->Driver.BindFramebufferEXT().
*/
@@ -306,20 +303,7 @@ static void
st_bind_framebuffer(struct gl_context *ctx, GLenum target,
struct gl_framebuffer *fb, struct gl_framebuffer *fbread)
{
-
-}
-
-/**
- * Called by ctx->Driver.FramebufferRenderbuffer
- */
-static void
-st_framebuffer_renderbuffer(struct gl_context *ctx,
- struct gl_framebuffer *fb,
- GLenum attachment,
- struct gl_renderbuffer *rb)
-{
- /* XXX no need for derivation? */
- _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+ /* no-op */
}
@@ -380,9 +364,6 @@ st_render_texture(struct gl_context *ctx,
rb->Height = texImage->Height2;
rb->_BaseFormat = texImage->_BaseFormat;
rb->InternalFormat = texImage->InternalFormat;
- /*printf("***** render to texture level %d: %d x %d\n", att->TextureLevel, rb->Width, rb->Height);*/
-
- /*printf("***** pipe texture %d x %d\n", pt->width0, pt->height0);*/
pipe_resource_reference( &strb->texture, pt );
@@ -392,7 +373,8 @@ st_render_texture(struct gl_context *ctx,
/* new surface for rendering into the texture */
memset(&surf_tmpl, 0, sizeof(surf_tmpl));
- surf_tmpl.format = ctx->Color.sRGBEnabled ? strb->texture->format : util_format_linear(strb->texture->format);
+ surf_tmpl.format = ctx->Color.sRGBEnabled
+ ? strb->texture->format : util_format_linear(strb->texture->format);
surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
surf_tmpl.u.tex.level = strb->rtt_level;
surf_tmpl.u.tex.first_layer = strb->rtt_face + strb->rtt_slice;
@@ -401,15 +383,8 @@ st_render_texture(struct gl_context *ctx,
strb->texture,
&surf_tmpl);
- strb->format = pt->format;
-
strb->Base.Format = st_pipe_format_to_mesa_format(pt->format);
- /*
- printf("RENDER TO TEXTURE obj=%p pt=%p surf=%p %d x %d\n",
- att->Texture, pt, strb->surface, rb->Width, rb->Height);
- */
-
/* Invalidate buffer state so that the pipe's framebuffer state
* gets updated.
* That's where the new renderbuffer (which we just created) gets
@@ -433,10 +408,6 @@ st_finish_render_texture(struct gl_context *ctx,
strb->rtt = NULL;
- /*
- printf("FINISH RENDER TO TEXTURE surf=%p\n", strb->surface);
- */
-
/* restore previous framebuffer state */
st_invalidate_state(ctx, _NEW_BUFFERS);
}
@@ -647,12 +618,12 @@ st_MapRenderbuffer(struct gl_context *ctx,
if (strb->software) {
/* software-allocated renderbuffer (probably an accum buffer) */
- GLubyte *map = (GLubyte *) strb->data;
if (strb->data) {
- map += strb->stride * y;
- map += util_format_get_blocksize(strb->format) * x;
- *mapOut = map;
- *rowStrideOut = strb->stride;
+ GLint bpp = _mesa_get_format_bytes(strb->Base.Format);
+ GLint stride = _mesa_format_row_stride(strb->Base.Format,
+ strb->Base.Width);
+ *mapOut = (GLubyte *) strb->data + y * stride + x * bpp;
+ *rowStrideOut = stride;
}
else {
*mapOut = NULL;
@@ -730,14 +701,11 @@ void st_init_fbo_functions(struct dd_function_table *functions)
functions->NewFramebuffer = st_new_framebuffer;
functions->NewRenderbuffer = st_new_renderbuffer;
functions->BindFramebuffer = st_bind_framebuffer;
- functions->FramebufferRenderbuffer = st_framebuffer_renderbuffer;
+ functions->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
functions->RenderTexture = st_render_texture;
functions->FinishRenderTexture = st_finish_render_texture;
functions->ValidateFramebuffer = st_validate_framebuffer;
#endif
- /* no longer needed by core Mesa, drivers handle resizes...
- functions->ResizeBuffers = st_resize_buffers;
- */
functions->DrawBuffers = st_DrawBuffers;
functions->ReadBuffer = st_ReadBuffer;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.h b/mesalib/src/mesa/state_tracker/st_cb_fbo.h
index 1be017314..506fd06d6 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.h
@@ -48,7 +48,6 @@ struct st_renderbuffer
struct gl_renderbuffer Base;
struct pipe_resource *texture;
struct pipe_surface *surface; /* temporary view into texture */
- enum pipe_format format; /** preferred format, or PIPE_FORMAT_NONE */
GLboolean defined; /**< defined contents? */
struct pipe_transfer *transfer; /**< only used when mapping the resource */
@@ -57,7 +56,6 @@ struct st_renderbuffer
* Used only when hardware accumulation buffers are not supported.
*/
boolean software;
- size_t stride;
void *data;
struct st_texture_object *rtt; /**< GL render to texture's texture */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index 5cd9a4c94..74ae2d11d 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -609,8 +609,7 @@ decompress_with_blit(struct gl_context * ctx,
struct pipe_context *pipe = st->pipe;
struct st_texture_image *stImage = st_texture_image(texImage);
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
- struct pipe_sampler_view *src_view =
- st_get_texture_sampler_view(stObj, pipe);
+ struct pipe_sampler_view *src_view;
const GLuint width = texImage->Width;
const GLuint height = texImage->Height;
struct pipe_surface *dst_surface;
@@ -632,8 +631,21 @@ decompress_with_blit(struct gl_context * ctx,
pipe->render_condition(pipe, NULL, 0);
}
- /* Choose the source mipmap level */
- src_view->u.tex.first_level = src_view->u.tex.last_level = texImage->Level;
+ /* Create sampler view that limits fetches to the source mipmap level */
+ {
+ struct pipe_sampler_view sv_temp;
+
+ u_sampler_view_default_template(&sv_temp, stObj->pt, stObj->pt->format);
+
+ sv_temp.u.tex.first_level =
+ sv_temp.u.tex.last_level = texImage->Level;
+
+ src_view = pipe->create_sampler_view(pipe, stObj->pt, &sv_temp);
+ if (!src_view) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
+ return;
+ }
+ }
/* blit/render/decompress */
util_blit_pixels_tex(st->blit,
@@ -661,7 +673,9 @@ decompress_with_blit(struct gl_context * ctx,
pixels = _mesa_map_pbo_dest(ctx, &ctx->Pack, pixels);
/* copy/pack data into user buffer */
- if (st_equal_formats(stImage->pt->format, format, type)) {
+ if (_mesa_format_matches_format_and_type(stImage->base.TexFormat,
+ format, type,
+ ctx->Pack.SwapBytes)) {
/* memcpy */
const uint bytesPerRow = width * util_format_get_blocksize(stImage->pt->format);
ubyte *map = pipe_transfer_map(pipe, tex_xfer);
@@ -702,6 +716,8 @@ decompress_with_blit(struct gl_context * ctx,
/* destroy the temp / dest surface */
util_destroy_rgba_surface(dst_texture, dst_surface);
+
+ pipe_sampler_view_reference(&src_view, NULL);
}
@@ -1337,57 +1353,6 @@ st_finalize_texture(struct gl_context *ctx,
/**
- * Returns pointer to a default/dummy texture.
- * This is typically used when the current shader has tex/sample instructions
- * but the user has not provided a (any) texture(s).
- */
-struct gl_texture_object *
-st_get_default_texture(struct st_context *st)
-{
- if (!st->default_texture) {
- static const GLenum target = GL_TEXTURE_2D;
- GLubyte pixels[16][16][4];
- struct gl_texture_object *texObj;
- struct gl_texture_image *texImg;
- GLuint i, j;
-
- /* The ARB_fragment_program spec says (0,0,0,1) should be returned
- * when attempting to sample incomplete textures.
- */
- for (i = 0; i < 16; i++) {
- for (j = 0; j < 16; j++) {
- pixels[i][j][0] = 0;
- pixels[i][j][1] = 0;
- pixels[i][j][2] = 0;
- pixels[i][j][3] = 255;
- }
- }
-
- texObj = st->ctx->Driver.NewTextureObject(st->ctx, 0, target);
-
- texImg = _mesa_get_tex_image(st->ctx, texObj, target, 0);
-
- _mesa_init_teximage_fields(st->ctx, texImg,
- 16, 16, 1, 0, /* w, h, d, border */
- GL_RGBA, MESA_FORMAT_RGBA8888);
-
- _mesa_store_teximage2d(st->ctx, texImg,
- GL_RGBA, /* level, intformat */
- 16, 16, 1, /* w, h, d, border */
- GL_RGBA, GL_UNSIGNED_BYTE, pixels,
- &st->ctx->DefaultPacking);
-
- texObj->Sampler.MinFilter = GL_NEAREST;
- texObj->Sampler.MagFilter = GL_NEAREST;
- texObj->_Complete = GL_TRUE;
-
- st->default_texture = texObj;
- }
- return st->default_texture;
-}
-
-
-/**
* Called via ctx->Driver.AllocTextureStorage() to allocate texture memory
* for a whole mipmap stack.
*/
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.h b/mesalib/src/mesa/state_tracker/st_cb_texture.h
index 81671b074..27956bcc2 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.h
@@ -1,55 +1,51 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#ifndef ST_CB_TEXTURE_H
-#define ST_CB_TEXTURE_H
-
-
-#include "main/glheader.h"
-
-struct dd_function_table;
-struct gl_context;
-struct gl_texture_object;
-struct pipe_context;
-struct st_context;
-
-extern GLboolean
-st_finalize_texture(struct gl_context *ctx,
- struct pipe_context *pipe,
- struct gl_texture_object *tObj);
-
-
-extern struct gl_texture_object *
-st_get_default_texture(struct st_context *st);
-
-
-extern void
-st_init_texture_functions(struct dd_function_table *functions);
-
-
-#endif /* ST_CB_TEXTURE_H */
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef ST_CB_TEXTURE_H
+#define ST_CB_TEXTURE_H
+
+
+#include "main/glheader.h"
+
+struct dd_function_table;
+struct gl_context;
+struct gl_texture_object;
+struct pipe_context;
+struct st_context;
+
+extern GLboolean
+st_finalize_texture(struct gl_context *ctx,
+ struct pipe_context *pipe,
+ struct gl_texture_object *tObj);
+
+
+extern void
+st_init_texture_functions(struct dd_function_table *functions);
+
+
+#endif /* ST_CB_TEXTURE_H */
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index 2fdbcd773..4265d14b4 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -1639,24 +1639,6 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLint internalFormat,
format, type, want_renderable);
}
-/**
- * Test if a gallium format is equivalent to a GL format/type.
- */
-GLboolean
-st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type)
-{
- switch (pFormat) {
- case PIPE_FORMAT_A8B8G8R8_UNORM:
- return format == GL_RGBA && type == GL_UNSIGNED_BYTE;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- return format == GL_BGRA && type == GL_UNSIGNED_BYTE;
- case PIPE_FORMAT_B5G6R5_UNORM:
- return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5;
- /* XXX more combos... */
- default:
- return GL_FALSE;
- }
-}
GLboolean
st_sampler_compat_formats(enum pipe_format format1, enum pipe_format format2)
diff --git a/mesalib/src/mesa/state_tracker/st_format.h b/mesalib/src/mesa/state_tracker/st_format.h
index 1dea0d9a5..7cf92eb41 100644
--- a/mesalib/src/mesa/state_tracker/st_format.h
+++ b/mesalib/src/mesa/state_tracker/st_format.h
@@ -67,9 +67,6 @@ st_ChooseTextureFormat(struct gl_context * ctx, GLint internalFormat,
GLenum format, GLenum type);
-extern GLboolean
-st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type);
-
/* can we use a sampler view to translate these formats
only used to make TFP so far */
extern GLboolean
diff --git a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
index d817a9c2b..d3496642f 100644
--- a/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/mesalib/src/mesa/state_tracker/st_gen_mipmap.c
@@ -75,10 +75,9 @@ st_render_mipmap(struct st_context *st,
{
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_sampler_view *psv = st_get_texture_sampler_view(stObj, pipe);
+ struct pipe_sampler_view *psv;
const uint face = _mesa_tex_target_to_face(target);
- assert(psv->texture == stObj->pt);
#if 0
assert(target != GL_TEXTURE_3D); /* implemented but untested */
#endif
@@ -86,11 +85,14 @@ st_render_mipmap(struct st_context *st,
/* check if we can render in the texture's format */
/* XXX should probably kill this and always use util_gen_mipmap
since this implements a sw fallback as well */
- if (!screen->is_format_supported(screen, psv->format, psv->texture->target,
+ if (!screen->is_format_supported(screen, stObj->pt->format,
+ stObj->pt->target,
0, PIPE_BIND_RENDER_TARGET)) {
return FALSE;
}
+ psv = st_create_texture_sampler_view(pipe, stObj->pt);
+
/* Disable conditional rendering. */
if (st->render_condition) {
pipe->render_condition(pipe, NULL, 0);
@@ -103,6 +105,8 @@ st_render_mipmap(struct st_context *st,
pipe->render_condition(pipe, st->render_condition, st->condition_mode);
}
+ pipe_sampler_view_reference(&psv, NULL);
+
return TRUE;
}
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index 7efc17305..d54b7ed62 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -805,9 +805,7 @@ st_manager_get_egl_image_surface(struct st_context *st,
if (!smapi->get_egl_image(smapi, eglimg, &stimg))
return NULL;
- memset(&surf_tmpl, 0, sizeof(surf_tmpl));
- surf_tmpl.format = stimg.texture->format;
- surf_tmpl.usage = usage;
+ u_surface_default_template(&surf_tmpl, stimg.texture, usage);
surf_tmpl.u.tex.level = stimg.level;
surf_tmpl.u.tex.first_layer = stimg.layer;
surf_tmpl.u.tex.last_layer = stimg.layer;
diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h
index 3d2a6369c..62e975bb4 100644
--- a/mesalib/src/mesa/state_tracker/st_texture.h
+++ b/mesalib/src/mesa/state_tracker/st_texture.h
@@ -45,7 +45,7 @@ struct st_texture_image
{
struct gl_texture_image base;
- /** Used to store texture data that doesn't fit in the patent
+ /** Used to store texture data that doesn't fit in the parent
* object's mipmap buffer.
*/
GLubyte *TexData;
@@ -123,18 +123,6 @@ st_get_stobj_resource(struct st_texture_object *stObj)
static INLINE struct pipe_sampler_view *
-st_create_texture_sampler_view(struct pipe_context *pipe,
- struct pipe_resource *texture)
-{
- struct pipe_sampler_view templ;
-
- u_sampler_view_default_template(&templ, texture, texture->format);
-
- return pipe->create_sampler_view(pipe, texture, &templ);
-}
-
-
-static INLINE struct pipe_sampler_view *
st_create_texture_sampler_view_format(struct pipe_context *pipe,
struct pipe_resource *texture,
enum pipe_format format)
@@ -146,23 +134,16 @@ st_create_texture_sampler_view_format(struct pipe_context *pipe,
return pipe->create_sampler_view(pipe, texture, &templ);
}
-
static INLINE struct pipe_sampler_view *
-st_get_texture_sampler_view(struct st_texture_object *stObj,
- struct pipe_context *pipe)
+st_create_texture_sampler_view(struct pipe_context *pipe,
+ struct pipe_resource *texture)
{
- if (!stObj || !stObj->pt) {
- return NULL;
- }
-
- if (!stObj->sampler_view) {
- stObj->sampler_view = st_create_texture_sampler_view(pipe, stObj->pt);
- }
-
- return stObj->sampler_view;
+ return st_create_texture_sampler_view_format(pipe, texture,
+ texture->format);
}
+
extern struct pipe_resource *
st_texture_create(struct st_context *st,
enum pipe_texture_target target,