aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
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
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')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_simple_screen.h180
-rw-r--r--mesalib/src/mapi/glapi/glapi_priv.h10
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c10
-rw-r--r--mesalib/src/mesa/main/attrib.c24
-rw-r--r--mesalib/src/mesa/main/fbobject.c11
-rw-r--r--mesalib/src/mesa/main/format_pack.c36
-rw-r--r--mesalib/src/mesa/main/format_unpack.c20
-rw-r--r--mesalib/src/mesa/main/image.c9
-rw-r--r--mesalib/src/mesa/main/mtypes.h2
-rw-r--r--mesalib/src/mesa/main/shared.c8
-rw-r--r--mesalib/src/mesa/main/teximage.c81
-rw-r--r--mesalib/src/mesa/main/texobj.c126
-rw-r--r--mesalib/src/mesa/main/texobj.h4
-rw-r--r--mesalib/src/mesa/main/texstate.c10
-rw-r--r--mesalib/src/mesa/main/varray.c42
-rw-r--r--mesalib/src/mesa/main/version.h2
-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
-rw-r--r--mesalib/src/mesa/swrast/s_fragprog.c3
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_array.c85
31 files changed, 444 insertions, 611 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_simple_screen.h b/mesalib/src/gallium/auxiliary/util/u_simple_screen.h
deleted file mode 100644
index d81ecee7e..000000000
--- a/mesalib/src/gallium/auxiliary/util/u_simple_screen.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * 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 U_SIMPLE_SCREEN_H
-#define U_SIMPLE_SCREEN_H
-
-#include "pipe/p_format.h"
-
-struct pipe_screen;
-struct pipe_fence_handle;
-struct pipe_surface;
-struct pipe_resource;
-
-/**
- * Gallium3D drivers are (meant to be!) independent of both GL and the
- * window system. The window system provides a buffer manager and a
- * set of additional hooks for things like command buffer submission,
- * etc.
- *
- * There clearly has to be some agreement between the window system
- * driver and the hardware driver about the format of command buffers,
- * etc.
- */
-struct pipe_winsys
-{
- void (*destroy)( struct pipe_winsys *ws );
-
- /** Returns name of this winsys interface */
- const char *(*get_name)( struct pipe_winsys *ws );
-
- /**
- * Do any special operations to ensure frontbuffer contents are
- * displayed, eg copy fake frontbuffer.
- */
- void (*flush_frontbuffer)( struct pipe_winsys *ws,
- struct pipe_resource *resource,
- unsigned level, unsigned layer,
- void *context_private );
-
-
- /**
- * Buffer management. Buffer attributes are mostly fixed over its lifetime.
- *
- * Remember that gallium gets to choose the interface it needs, and the
- * window systems must then implement that interface (rather than the
- * other way around...).
- *
- * usage is a bitmask of PIPE_BIND_*.
- * All possible usages must be present.
- *
- * alignment indicates the client's alignment requirements, eg for
- * SSE instructions.
- */
- struct pipe_resource *(*buffer_create)( struct pipe_winsys *ws,
- unsigned alignment,
- unsigned usage,
- unsigned size );
-
- /**
- * Create a buffer that wraps user-space data.
- *
- * Effectively this schedules a delayed call to buffer_create
- * followed by an upload of the data at *some point in the future*,
- * or perhaps never. Basically the allocate/upload is delayed
- * until the buffer is actually passed to hardware.
- *
- * The intention is to provide a quick way to turn regular data
- * into a buffer, and secondly to avoid a copy operation if that
- * data subsequently turns out to be only accessed by the CPU.
- *
- * Common example is OpenGL vertex buffers that are subsequently
- * processed either by software TNL in the driver or by passing to
- * hardware.
- *
- * XXX: What happens if the delayed call to buffer_create() fails?
- *
- * Note that ptr may be accessed at any time upto the time when the
- * buffer is destroyed, so the data must not be freed before then.
- */
- struct pipe_resource *(*user_buffer_create)(struct pipe_winsys *ws,
- void *ptr,
- unsigned bytes);
-
- /**
- * Allocate storage for a display target surface.
- *
- * Often surfaces which are meant to be blitted to the front screen (i.e.,
- * display targets) must be allocated with special characteristics, memory
- * pools, or obtained directly from the windowing system.
- *
- * This callback is invoked by the pipe_screen when creating a texture marked
- * with the PIPE_BIND_DISPLAY_TARGET flag to get the underlying
- * buffer storage.
- */
- struct pipe_resource *(*surface_buffer_create)(struct pipe_winsys *ws,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride);
-
-
- /**
- * Map the entire data store of a buffer object into the client's address.
- * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
- */
- void *(*buffer_map)( struct pipe_winsys *ws,
- struct pipe_resource *buf,
- unsigned usage );
-
- void (*buffer_unmap)( struct pipe_winsys *ws,
- struct pipe_resource *buf );
-
- void (*buffer_destroy)( struct pipe_resource *buf );
-
-
- /** Set ptr = fence, with reference counting */
- void (*fence_reference)( struct pipe_winsys *ws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence );
-
- /**
- * Checks whether the fence has been signalled.
- * \param flags driver-specific meaning
- * \return zero on success.
- */
- int (*fence_signalled)( struct pipe_winsys *ws,
- struct pipe_fence_handle *fence,
- unsigned flag );
-
- /**
- * Wait for the fence to finish.
- * \param flags driver-specific meaning
- * \return zero on success.
- */
- int (*fence_finish)( struct pipe_winsys *ws,
- struct pipe_fence_handle *fence,
- unsigned flags,
- uint64_t timeout );
-
-};
-
-/**
- * The following function initializes a simple passthrough screen.
- *
- * All the relevant screen function pointers will forwarded to the
- * winsys.
- */
-void u_simple_screen_init(struct pipe_screen *screen);
-
-/**
- * Returns the name of the winsys associated with this screen.
- */
-const char* u_simple_screen_winsys_name(struct pipe_screen *screen);
-
-#endif
diff --git a/mesalib/src/mapi/glapi/glapi_priv.h b/mesalib/src/mapi/glapi/glapi_priv.h
index 3ab553a2b..b6600c5fc 100644
--- a/mesalib/src/mapi/glapi/glapi_priv.h
+++ b/mesalib/src/mapi/glapi/glapi_priv.h
@@ -38,6 +38,16 @@
#include "GL/gl.h"
#include "GL/glext.h"
+/* The define of GL_COVERAGE_SAMPLES_NV in gl2ext.h is guarded by a different
+ * extension (GL_NV_coverage_sample) than in glext.h
+ * (GL_NV_multisample_coverage). Just undefine it to avoid spurious compiler
+ * warnings.
+ */
+#undef GL_COVERAGE_SAMPLES_NV
+
+#include "GLES2/gl2platform.h"
+#include "GLES2/gl2ext.h"
+
#ifndef GL_OES_fixed_point
typedef int GLfixed;
typedef int GLclampx;
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index 0cf1028c4..6c8495ddb 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -3244,7 +3244,7 @@ decompress_texture_image(struct gl_context *ctx,
struct gl_texture_image *texImage,
GLuint slice,
GLenum destFormat, GLenum destType,
- GLvoid *dest, GLint destRowLength)
+ GLvoid *dest)
{
struct decompress_state *decompress = &ctx->Meta->Decompress;
struct gl_texture_object *texObj = texImage->TexObject;
@@ -3274,7 +3274,7 @@ decompress_texture_image(struct gl_context *ctx,
fboDrawSave = ctx->DrawBuffer->Name;
fboReadSave = ctx->ReadBuffer->Name;
- _mesa_meta_begin(ctx, MESA_META_ALL);
+ _mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_PIXEL_STORE);
/* Create/bind FBO/renderbuffer */
if (decompress->FBO == 0) {
@@ -3292,7 +3292,7 @@ decompress_texture_image(struct gl_context *ctx,
}
/* alloc dest surface */
- if (width != decompress->Width || height != decompress->Height) {
+ if (width > decompress->Width || height > decompress->Height) {
_mesa_RenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA,
width, height);
decompress->Width = width;
@@ -3409,7 +3409,6 @@ decompress_texture_image(struct gl_context *ctx,
_mesa_PixelTransferf(GL_BLUE_SCALE, 0.0f);
}
- ctx->Pack.RowLength = destRowLength;
_mesa_ReadPixels(0, 0, width, height, destFormat, destType, dest);
}
@@ -3450,8 +3449,7 @@ _mesa_meta_GetTexImage(struct gl_context *ctx,
const GLuint slice = 0; /* only 2D compressed textures for now */
/* Need to unlock the texture here to prevent deadlock... */
_mesa_unlock_texture(ctx, texObj);
- decompress_texture_image(ctx, texImage, slice, format, type, pixels,
- ctx->Pack.RowLength);
+ decompress_texture_image(ctx, texImage, slice, format, type, pixels);
/* ... and relock it */
_mesa_lock_texture(ctx, texObj);
}
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index 846da35e9..7042312a8 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -122,7 +122,6 @@ struct gl_enable_attrib
GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */
GLboolean SampleAlphaToOne; /* GL_ARB_multisample */
GLboolean SampleCoverage; /* GL_ARB_multisample */
- GLboolean SampleCoverageInvert; /* GL_ARB_multisample */
GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
GLbitfield Texture[MAX_TEXTURE_UNITS];
@@ -314,7 +313,6 @@ _mesa_PushAttrib(GLbitfield mask)
attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage;
attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne;
attr->SampleCoverage = ctx->Multisample.SampleCoverage;
- attr->SampleCoverageInvert = ctx->Multisample.SampleCoverageInvert;
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
attr->Texture[i] = ctx->Texture.Unit[i].Enabled;
attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled;
@@ -608,9 +606,6 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)
TEST_AND_UPDATE(ctx->Multisample.SampleCoverage,
enable->SampleCoverage,
GL_SAMPLE_COVERAGE_ARB);
- TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert,
- enable->SampleCoverageInvert,
- GL_SAMPLE_COVERAGE_INVERT_ARB);
/* GL_ARB_vertex_program, GL_NV_vertex_program */
TEST_AND_UPDATE(ctx->VertexProgram.Enabled,
enable->VertexProgram,
@@ -622,8 +617,6 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)
enable->VertexProgramTwoSide,
GL_VERTEX_PROGRAM_TWO_SIDE_ARB);
-#undef TEST_AND_UPDATE
-
/* texture unit enables */
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
const GLbitfield enabled = enable->Texture[i];
@@ -1275,6 +1268,23 @@ _mesa_PopAttrib(void)
{
const struct gl_multisample_attrib *ms;
ms = (const struct gl_multisample_attrib *) attr->data;
+
+ TEST_AND_UPDATE(ctx->Multisample.Enabled,
+ ms->Enabled,
+ GL_MULTISAMPLE);
+
+ TEST_AND_UPDATE(ctx->Multisample.SampleCoverage,
+ ms->SampleCoverage,
+ GL_SAMPLE_COVERAGE);
+
+ TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage,
+ ms->SampleAlphaToCoverage,
+ GL_SAMPLE_ALPHA_TO_COVERAGE);
+
+ TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne,
+ ms->SampleAlphaToOne,
+ GL_SAMPLE_ALPHA_TO_ONE);
+
_mesa_SampleCoverageARB(ms->SampleCoverageValue,
ms->SampleCoverageInvert);
}
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 987d687b9..6ee062d0b 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -1758,11 +1758,8 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
if (bindDrawBuf) {
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
- /* check if old read/draw buffers were render-to-texture */
- if (!bindReadBuf)
- check_end_texture_render(ctx, oldReadFb);
-
- if (oldDrawFb != oldReadFb)
+ /* check if old framebuffer had any texture attachments */
+ if (oldDrawFb)
check_end_texture_render(ctx, oldDrawFb);
/* check if newly bound framebuffer has any texture attachments */
@@ -2026,7 +2023,7 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
BUFFER_STENCIL);
} else if (attachment == GL_STENCIL_ATTACHMENT &&
texObj == fb->Attachment[BUFFER_DEPTH].Texture) {
- /* As above, but with depth and stencil juxtasposed. */
+ /* As above, but with depth and stencil juxtaposed. */
reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL,
BUFFER_DEPTH);
} else {
@@ -2269,7 +2266,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
ASSERT_OUTSIDE_BEGIN_END(ctx);
- /* The error differs in GL andd GLES. */
+ /* The error differs in GL and GLES. */
err = ctx->API == API_OPENGL ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
buffer = get_framebuffer_target(ctx, target);
diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c
index ea1d95ee9..ff08ac561 100644
--- a/mesalib/src/mesa/main/format_pack.c
+++ b/mesalib/src/mesa/main/format_pack.c
@@ -42,6 +42,14 @@
#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
+/** Helper struct for MESA_FORMAT_Z32_FLOAT_X24S8 */
+struct z32f_x24s8
+{
+ float z;
+ uint32_t x24s8;
+};
+
+
typedef void (*pack_ubyte_rgba_row_func)(GLuint n,
const GLubyte src[][4], void *dst);
@@ -2372,10 +2380,10 @@ _mesa_pack_float_z_row(gl_format format, GLuint n,
break;
case MESA_FORMAT_Z32_FLOAT_X24S8:
{
- GLfloat *d = ((GLfloat *) dst);
+ struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
GLuint i;
for (i = 0; i < n; i++) {
- d[i * 2] = src[i];
+ d[i].z = src[i];
}
}
break;
@@ -2445,13 +2453,13 @@ _mesa_pack_uint_z_row(gl_format format, GLuint n,
break;
case MESA_FORMAT_Z32_FLOAT_X24S8:
{
- GLfloat *d = ((GLfloat *) dst);
+ struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
const GLdouble scale = 1.0 / (GLdouble) 0xffffffff;
GLuint i;
for (i = 0; i < n; i++) {
- d[i * 2] = src[i] * scale;
- assert(d[i * 2] >= 0.0f);
- assert(d[i * 2] <= 1.0f);
+ d[i].z = src[i] * scale;
+ assert(d[i].z >= 0.0f);
+ assert(d[i].z <= 1.0f);
}
}
break;
@@ -2495,10 +2503,10 @@ _mesa_pack_ubyte_stencil_row(gl_format format, GLuint n,
break;
case MESA_FORMAT_Z32_FLOAT_X24S8:
{
- GLuint *d = dst;
+ struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
GLuint i;
for (i = 0; i < n; i++) {
- d[i * 2 + 1] = src[i];
+ d[i].x24s8 = src[i];
}
}
break;
@@ -2530,6 +2538,18 @@ _mesa_pack_uint_24_8_depth_stencil_row(gl_format format, GLuint n,
}
}
break;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ {
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
+ struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
+ GLint i;
+ for (i = 0; i < n; i++) {
+ GLfloat z = (src[i] >> 8) * scale;
+ d[i].z = z;
+ d[i].x24s8 = src[i];
+ }
+ }
+ break;
default:
_mesa_problem(NULL, "bad format %s in _mesa_pack_ubyte_s_row",
_mesa_get_format_name(format));
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index a484979e2..b00e01236 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -29,6 +29,13 @@
#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
+/** Helper struct for MESA_FORMAT_Z32_FLOAT_X24S8 */
+struct z32f_x24s8
+{
+ float z;
+ uint32_t x24s8;
+};
+
/* Expand 1, 2, 3, 4, 5, 6-bit values to fill 8 bits */
@@ -2825,10 +2832,10 @@ unpack_float_z_Z32F(GLuint n, const void *src, GLfloat *dst)
static void
unpack_float_z_Z32X24S8(GLuint n, const void *src, GLfloat *dst)
{
- const GLfloat *s = ((const GLfloat *) src);
+ const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
GLuint i;
for (i = 0; i < n; i++) {
- dst[i] = s[i * 2];
+ dst[i] = s[i].z;
}
}
@@ -2929,11 +2936,6 @@ unpack_uint_z_Z32_FLOAT(const void *src, GLuint *dst, GLuint n)
static void
unpack_uint_z_Z32_FLOAT_X24S8(const void *src, GLuint *dst, GLuint n)
{
- struct z32f_x24s8 {
- float z;
- uint32_t x24s8;
- };
-
const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
GLuint i;
@@ -3015,10 +3017,10 @@ static void
unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src, GLubyte *dst, GLuint n)
{
GLuint i;
- const GLuint *src32 = src;
+ const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
for (i = 0; i < n; i++)
- dst[i] = src32[i * 2 + 1] & 0xff;
+ dst[i] = s[i].x24s8 & 0xff;
}
void
diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c
index 750db9444..b6c2645e9 100644
--- a/mesalib/src/mesa/main/image.c
+++ b/mesalib/src/mesa/main/image.c
@@ -428,6 +428,15 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
}
return GL_NO_ERROR;
+ case GL_UNSIGNED_INT_10F_11F_11F_REV:
+ if (!ctx->Extensions.EXT_packed_float) {
+ return GL_INVALID_ENUM;
+ }
+ if (format != GL_RGB) {
+ return GL_INVALID_OPERATION;
+ }
+ return GL_NO_ERROR;
+
default:
; /* fall-through */
}
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 5ef97c86c..9200f3fc4 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -2483,7 +2483,7 @@ struct gl_shared_state
struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
/** Fallback texture used when a bound texture is incomplete */
- struct gl_texture_object *FallbackTex;
+ struct gl_texture_object *FallbackTex[NUM_TEXTURE_TARGETS];
/**
* \name Thread safety and statechange notification for texture
diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c
index c07ce8238..226947638 100644
--- a/mesalib/src/mesa/main/shared.c
+++ b/mesalib/src/mesa/main/shared.c
@@ -307,9 +307,11 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared)
{
GLuint i;
- /* Free the dummy/fallback texture object */
- if (shared->FallbackTex)
- ctx->Driver.DeleteTexture(ctx, shared->FallbackTex);
+ /* Free the dummy/fallback texture objects */
+ for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
+ if (shared->FallbackTex[i])
+ ctx->Driver.DeleteTexture(ctx, shared->FallbackTex[i]);
+ }
/*
* Free display lists
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index e4eb7f67d..9b6c6c896 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -1083,11 +1083,13 @@ _mesa_init_teximage_fields(struct gl_context *ctx,
GLint border, GLenum internalFormat,
gl_format format)
{
+ GLenum target;
ASSERT(img);
ASSERT(width >= 0);
ASSERT(height >= 0);
ASSERT(depth >= 0);
+ target = img->TexObject->Target;
img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat );
ASSERT(img->_BaseFormat > 0);
img->InternalFormat = internalFormat;
@@ -1099,26 +1101,72 @@ _mesa_init_teximage_fields(struct gl_context *ctx,
img->Width2 = width - 2 * border; /* == 1 << img->WidthLog2; */
img->WidthLog2 = _mesa_logbase2(img->Width2);
- if (height == 1) { /* 1-D texture */
- img->Height2 = 1;
+ switch(target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_BUFFER:
+ case GL_PROXY_TEXTURE_1D:
+ if (height == 0)
+ img->Height2 = 0;
+ else
+ img->Height2 = 1;
img->HeightLog2 = 0;
- }
- else {
+ if (depth == 0)
+ img->Depth2 = 0;
+ else
+ img->Depth2 = 1;
+ img->DepthLog2 = 0;
+ break;
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_PROXY_TEXTURE_1D_ARRAY:
+ img->Height2 = height; /* no border */
+ img->HeightLog2 = 0; /* not used */
+ if (depth == 0)
+ img->Depth2 = 0;
+ else
+ img->Depth2 = 1;
+ img->DepthLog2 = 0;
+ break;
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ case GL_TEXTURE_EXTERNAL_OES:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_RECTANGLE:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */
img->HeightLog2 = _mesa_logbase2(img->Height2);
- }
-
- if (depth == 1) { /* 2-D texture */
- img->Depth2 = 1;
+ if (depth == 0)
+ img->Depth2 = 0;
+ else
+ img->Depth2 = 1;
img->DepthLog2 = 0;
- }
- else {
+ break;
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_PROXY_TEXTURE_2D_ARRAY:
+ img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */
+ img->HeightLog2 = _mesa_logbase2(img->Height2);
+ img->Depth2 = depth; /* no border */
+ img->DepthLog2 = 0; /* not used */
+ break;
+ case GL_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_3D:
+ img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */
+ img->HeightLog2 = _mesa_logbase2(img->Height2);
img->Depth2 = depth - 2 * border; /* == 1 << img->DepthLog2; */
img->DepthLog2 = _mesa_logbase2(img->Depth2);
+ break;
+ default:
+ _mesa_problem(NULL, "invalid target 0x%x in _mesa_init_teximage_fields()",
+ target);
}
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
-
img->TexFormat = format;
}
@@ -1852,6 +1900,17 @@ subtexture_error_check2( struct gl_context *ctx, GLuint dimensions,
}
}
+ if (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_texture_integer) {
+ /* both source and dest must be integer-valued, or neither */
+ if (_mesa_is_format_integer_color(destTex->TexFormat) !=
+ _mesa_is_integer_format(format)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexSubImage%dD(integer/non-integer format mismatch)",
+ dimensions);
+ return GL_TRUE;
+ }
+ }
+
return GL_FALSE;
}
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index 1b61d3a63..590594826 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -759,59 +759,127 @@ _mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj,
/**
- * Return pointer to a default/fallback texture.
- * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1).
- * That's the value a sampler should get when sampling from an
+ * Return pointer to a default/fallback texture of the given type/target.
+ * The texture is an RGBA texture with all texels = (0,0,0,1).
+ * That's the value a GLSL sampler should get when sampling from an
* incomplete texture.
*/
struct gl_texture_object *
-_mesa_get_fallback_texture(struct gl_context *ctx)
+_mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
{
- if (!ctx->Shared->FallbackTex) {
+ if (!ctx->Shared->FallbackTex[tex]) {
/* create fallback texture now */
- static GLubyte texels[8 * 8][4];
+ const GLsizei width = 1, height = 1, depth = 1;
+ GLubyte texel[4];
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
gl_format texFormat;
- GLuint i;
-
- for (i = 0; i < 8 * 8; i++) {
- texels[i][0] =
- texels[i][1] =
- texels[i][2] = 0x0;
- texels[i][3] = 0xff;
+ GLuint dims, face, numFaces = 1;
+ GLenum target;
+
+ texel[0] =
+ texel[1] =
+ texel[2] = 0x0;
+ texel[3] = 0xff;
+
+ switch (tex) {
+ case TEXTURE_2D_ARRAY_INDEX:
+ dims = 3;
+ target = GL_TEXTURE_2D_ARRAY;
+ break;
+ case TEXTURE_1D_ARRAY_INDEX:
+ dims = 2;
+ target = GL_TEXTURE_1D_ARRAY;
+ break;
+ case TEXTURE_CUBE_INDEX:
+ dims = 2;
+ target = GL_TEXTURE_CUBE_MAP;
+ numFaces = 6;
+ break;
+ case TEXTURE_3D_INDEX:
+ dims = 3;
+ target = GL_TEXTURE_3D;
+ break;
+ case TEXTURE_RECT_INDEX:
+ dims = 2;
+ target = GL_TEXTURE_RECTANGLE;
+ break;
+ case TEXTURE_2D_INDEX:
+ dims = 2;
+ target = GL_TEXTURE_2D;
+ break;
+ case TEXTURE_1D_INDEX:
+ dims = 1;
+ target = GL_TEXTURE_1D;
+ break;
+ case TEXTURE_BUFFER_INDEX:
+ case TEXTURE_EXTERNAL_INDEX:
+ default:
+ /* no-op */
+ return NULL;
}
/* create texture object */
- texObj = ctx->Driver.NewTextureObject(ctx, 0, GL_TEXTURE_2D);
+ texObj = ctx->Driver.NewTextureObject(ctx, 0, target);
+ if (!texObj)
+ return NULL;
+
assert(texObj->RefCount == 1);
texObj->Sampler.MinFilter = GL_NEAREST;
texObj->Sampler.MagFilter = GL_NEAREST;
- /* create level[0] texture image */
- texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0);
-
texFormat = ctx->Driver.ChooseTextureFormat(ctx, GL_RGBA, GL_RGBA,
GL_UNSIGNED_BYTE);
- /* init the image fields */
- _mesa_init_teximage_fields(ctx, texImage,
- 8, 8, 1, 0, GL_RGBA, texFormat);
+ /* need a loop here just for cube maps */
+ for (face = 0; face < numFaces; face++) {
+ GLenum faceTarget;
- ASSERT(texImage->TexFormat != MESA_FORMAT_NONE);
-
- /* set image data */
- ctx->Driver.TexImage2D(ctx, texImage, GL_RGBA,
- 8, 8, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, texels,
- &ctx->DefaultPacking);
+ if (target == GL_TEXTURE_CUBE_MAP)
+ faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
+ else
+ faceTarget = target;
+
+ /* initialize level[0] texture image */
+ texImage = _mesa_get_tex_image(ctx, texObj, faceTarget, 0);
+
+ _mesa_init_teximage_fields(ctx, texImage,
+ width,
+ (dims > 1) ? height : 1,
+ (dims > 2) ? depth : 1,
+ 0, /* border */
+ GL_RGBA, texFormat);
+
+ switch (dims) {
+ case 1:
+ ctx->Driver.TexImage1D(ctx, texImage, GL_RGBA,
+ width, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, texel,
+ &ctx->DefaultPacking);
+ break;
+ case 2:
+ ctx->Driver.TexImage2D(ctx, texImage, GL_RGBA,
+ width, height, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, texel,
+ &ctx->DefaultPacking);
+ break;
+ case 3:
+ ctx->Driver.TexImage3D(ctx, texImage, GL_RGBA,
+ width, height, depth, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, texel,
+ &ctx->DefaultPacking);
+ break;
+ default:
+ _mesa_problem(ctx, "bad dims in _mesa_get_fallback_texture()");
+ }
+ }
_mesa_test_texobj_completeness(ctx, texObj);
assert(texObj->_Complete);
- ctx->Shared->FallbackTex = texObj;
+ ctx->Shared->FallbackTex[tex] = texObj;
}
- return ctx->Shared->FallbackTex;
+ return ctx->Shared->FallbackTex[tex];
}
diff --git a/mesalib/src/mesa/main/texobj.h b/mesalib/src/mesa/main/texobj.h
index 9ca7a4c9e..03dfbe304 100644
--- a/mesalib/src/mesa/main/texobj.h
+++ b/mesalib/src/mesa/main/texobj.h
@@ -34,8 +34,8 @@
#include "compiler.h"
#include "glheader.h"
+#include "mtypes.h"
-struct gl_context;
/**
* \name Internal functions
@@ -89,7 +89,7 @@ _mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj,
GLboolean invalidate_state);
extern struct gl_texture_object *
-_mesa_get_fallback_texture(struct gl_context *ctx);
+_mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex);
extern void
_mesa_unlock_context_textures( struct gl_context *ctx );
diff --git a/mesalib/src/mesa/main/texstate.c b/mesalib/src/mesa/main/texstate.c
index cc49916a9..187ec9c36 100644
--- a/mesalib/src/mesa/main/texstate.c
+++ b/mesalib/src/mesa/main/texstate.c
@@ -586,9 +586,15 @@ update_texture_state( struct gl_context *ctx )
* object, but there isn't one (or it's incomplete). Use the
* fallback texture.
*/
- struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx);
- texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX;
+ struct gl_texture_object *texObj;
+ gl_texture_index texTarget;
+
+ assert(_mesa_bitcount(enabledTargets) == 1);
+
+ texTarget = (gl_texture_index) (ffs(enabledTargets) - 1);
+ texObj = _mesa_get_fallback_texture(ctx, texTarget);
_mesa_reference_texobj(&texUnit->_Current, texObj);
+ texUnit->_ReallyEnabled = 1 << texTarget;
}
else {
/* fixed-function: texture unit is really disabled */
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index 77c1d7d9b..39d3a27e0 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -185,6 +185,7 @@ update_array(struct gl_context *ctx,
(type == GL_UNSIGNED_INT_2_10_10_10_REV ||
type == GL_INT_2_10_10_10_REV) && size != 4) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(size=%d)", func, size);
+ return;
}
ASSERT(size <= 4);
@@ -482,6 +483,7 @@ _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
void GLAPIENTRY
_mesa_EnableVertexAttribArrayARB(GLuint index)
{
+ struct gl_array_object *arrayObj;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -491,18 +493,24 @@ _mesa_EnableVertexAttribArrayARB(GLuint index)
return;
}
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ arrayObj = ctx->Array.ArrayObj;
+
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(arrayObj->VertexAttrib));
- FLUSH_VERTICES(ctx, _NEW_ARRAY);
- ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE;
- ctx->Array.ArrayObj->_Enabled |= VERT_BIT_GENERIC(index);
- ctx->Array.NewState |= VERT_BIT_GENERIC(index);
+ if (!arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
+ /* was disabled, now being enabled */
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_TRUE;
+ arrayObj->_Enabled |= VERT_BIT_GENERIC(index);
+ ctx->Array.NewState |= VERT_BIT_GENERIC(index);
+ }
}
void GLAPIENTRY
_mesa_DisableVertexAttribArrayARB(GLuint index)
{
+ struct gl_array_object *arrayObj;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -512,12 +520,17 @@ _mesa_DisableVertexAttribArrayARB(GLuint index)
return;
}
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.ArrayObj->VertexAttrib));
+ arrayObj = ctx->Array.ArrayObj;
+
+ ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(arrayObj->VertexAttrib));
- FLUSH_VERTICES(ctx, _NEW_ARRAY);
- ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE;
- ctx->Array.ArrayObj->_Enabled &= ~VERT_BIT_GENERIC(index);
- ctx->Array.NewState |= VERT_BIT_GENERIC(index);
+ if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
+ /* was enabled, now being disabled */
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE;
+ arrayObj->_Enabled &= ~VERT_BIT_GENERIC(index);
+ ctx->Array.NewState |= VERT_BIT_GENERIC(index);
+ }
}
@@ -1087,11 +1100,12 @@ _mesa_PrimitiveRestartIndex(GLuint index)
return;
}
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
-
- FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
- ctx->Array.RestartIndex = index;
+ if (ctx->Array.RestartIndex != index) {
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ ctx->Array.RestartIndex = index;
+ }
}
diff --git a/mesalib/src/mesa/main/version.h b/mesalib/src/mesa/main/version.h
index 35bf53392..94a9855d9 100644
--- a/mesalib/src/mesa/main/version.h
+++ b/mesalib/src/mesa/main/version.h
@@ -35,7 +35,7 @@ struct gl_context;
#define MESA_MAJOR 8
#define MESA_MINOR 1
#define MESA_PATCH 0
-#define MESA_VERSION_STRING "8.0-devel"
+#define MESA_VERSION_STRING "8.1-devel"
/* To make version comparison easy */
#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
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,
diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c
index cd20d8e36..8d59371c8 100644
--- a/mesalib/src/mesa/swrast/s_fragprog.c
+++ b/mesalib/src/mesa/swrast/s_fragprog.c
@@ -40,7 +40,8 @@ GLboolean
_swrast_use_fragment_program(struct gl_context *ctx)
{
struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
- return fp && fp != ctx->FragmentProgram._TexEnvProgram;
+ return fp && !(fp == ctx->FragmentProgram._TexEnvProgram
+ && fp->Base.NumInstructions == 0);
}
/**
diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c
index d6b4d615c..06e36a677 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_array.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_array.c
@@ -708,6 +708,7 @@ vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count,
* Map GL_ELEMENT_ARRAY_BUFFER and print contents.
* For debugging.
*/
+#if 0
static void
dump_element_buffer(struct gl_context *ctx, GLenum type)
{
@@ -759,6 +760,7 @@ dump_element_buffer(struct gl_context *ctx, GLenum type)
ctx->Driver.UnmapBuffer(ctx, ctx->Array.ArrayObj->ElementArrayBufferObj);
}
+#endif
/**
@@ -857,6 +859,7 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
GLint basevertex)
{
static GLuint warnCount = 0;
+ GLboolean index_bounds_valid = GL_TRUE;
GET_CURRENT_CONTEXT(ctx);
if (MESA_VERBOSE & VERBOSE_DRAW)
@@ -869,6 +872,26 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
type, indices, basevertex ))
return;
+ if ((int) end + basevertex < 0 ||
+ start + basevertex >= ctx->Array.ArrayObj->_MaxElement) {
+ /* The application requested we draw using a range of indices that's
+ * outside the bounds of the current VBO. This is invalid and appears
+ * to give undefined results. The safest thing to do is to simply
+ * ignore the range, in case the application botched their range tracking
+ * but did provide valid indices. Also issue a warning indicating that
+ * the application is broken.
+ */
+ if (warnCount++ < 10) {
+ _mesa_warning(ctx, "glDrawRangeElements(start %u, end %u, "
+ "basevertex %d, count %d, type 0x%x, indices=%p):\n"
+ "\trange is outside VBO bounds (max=%u); ignoring.\n"
+ "\tThis should be fixed in the application.",
+ start, end, basevertex, count, type, indices,
+ ctx->Array.ArrayObj->_MaxElement - 1);
+ }
+ index_bounds_valid = GL_FALSE;
+ }
+
/* NOTE: It's important that 'end' is a reasonable value.
* in _tnl_draw_prims(), we use end to determine how many vertices
* to transform. If it's too large, we can unnecessarily split prims
@@ -885,62 +908,6 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
end = MIN2(end, 0xffff);
}
- if (end >= ctx->Array.ArrayObj->_MaxElement) {
- /* the max element is out of bounds of one or more enabled arrays */
- warnCount++;
-
- if (warnCount < 10) {
- _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, count %d, "
- "type 0x%x, indices=%p)\n"
- "\tend is out of bounds (max=%u) "
- "Element Buffer %u (size %d)\n"
- "\tThis should probably be fixed in the application.",
- start, end, count, type, indices,
- ctx->Array.ArrayObj->_MaxElement - 1,
- ctx->Array.ArrayObj->ElementArrayBufferObj->Name,
- (int) ctx->Array.ArrayObj->ElementArrayBufferObj->Size);
- }
-
- if (0)
- dump_element_buffer(ctx, type);
-
- if (0)
- _mesa_print_arrays(ctx);
-
- /* 'end' was out of bounds, but now let's check the actual array
- * indexes to see if any of them are out of bounds.
- */
- if (0) {
- GLuint max = _mesa_max_buffer_index(ctx, count, type, indices,
- ctx->Array.ArrayObj->ElementArrayBufferObj);
- if (max >= ctx->Array.ArrayObj->_MaxElement) {
- if (warnCount < 10) {
- _mesa_warning(ctx, "glDraw[Range]Elements(start %u, end %u, "
- "count %d, type 0x%x, indices=%p)\n"
- "\tindex=%u is out of bounds (max=%u) "
- "Element Buffer %u (size %d)\n"
- "\tSkipping the glDrawRangeElements() call",
- start, end, count, type, indices, max,
- ctx->Array.ArrayObj->_MaxElement - 1,
- ctx->Array.ArrayObj->ElementArrayBufferObj->Name,
- (int) ctx->Array.ArrayObj->ElementArrayBufferObj->Size);
- }
- }
- /* XXX we could also find the min index and compare to 'start'
- * to see if start is correct. But it's more likely to get the
- * upper bound wrong.
- */
- }
-
- /* Set 'end' to the max possible legal value */
- assert(ctx->Array.ArrayObj->_MaxElement >= 1);
- end = ctx->Array.ArrayObj->_MaxElement - 1;
-
- if (end < start) {
- return;
- }
- }
-
if (0) {
printf("glDraw[Range]Elements{,BaseVertex}"
"(start %u, end %u, type 0x%x, count %d) ElemBuf %u, "
@@ -950,13 +917,17 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode,
basevertex);
}
+ if ((int) start + basevertex < 0 ||
+ end + basevertex >= ctx->Array.ArrayObj->_MaxElement)
+ index_bounds_valid = GL_FALSE;
+
#if 0
check_draw_elements_data(ctx, count, type, indices);
#else
(void) check_draw_elements_data;
#endif
- vbo_validated_drawrangeelements(ctx, mode, GL_TRUE, start, end,
+ vbo_validated_drawrangeelements(ctx, mode, index_bounds_valid, start, end,
count, type, indices, basevertex, 1);
}