aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-28 13:55:41 +0100
committermarha <marha@users.sourceforge.net>2012-01-28 13:55:41 +0100
commit1aee8dafb5391e093f3a111f906ab0d8b6775510 (patch)
tree3fd4cc1783510fb6ce17c4c42b4d012014008e5b /mesalib/src/mesa
parentc6a1477b0092762299491d79b3a8cb094c6456da (diff)
downloadvcxsrv-1aee8dafb5391e093f3a111f906ab0d8b6775510.tar.gz
vcxsrv-1aee8dafb5391e093f3a111f906ab0d8b6775510.tar.bz2
vcxsrv-1aee8dafb5391e093f3a111f906ab0d8b6775510.zip
mesa xserver git update 28 jan 2012
Diffstat (limited to 'mesalib/src/mesa')
-rw-r--r--mesalib/src/mesa/drivers/dri/Makefile.am2
-rw-r--r--mesalib/src/mesa/drivers/dri/common/Makefile.am37
-rw-r--r--mesalib/src/mesa/main/bufferobj.c27
-rw-r--r--mesalib/src/mesa/main/dlist.c21
-rw-r--r--mesalib/src/mesa/main/format_unpack.c321
-rw-r--r--mesalib/src/mesa/main/formats.c196
-rw-r--r--mesalib/src/mesa/main/formats.h3
-rw-r--r--mesalib/src/mesa/main/pack.c61
-rw-r--r--mesalib/src/mesa/main/readpix.c9
-rw-r--r--mesalib/src/mesa/main/texgetimage.c9
-rw-r--r--mesalib/src/mesa/main/texstore.c181
-rw-r--r--mesalib/src/mesa/swrast/s_aaline.c2
-rw-r--r--mesalib/src/mesa/swrast/s_aalinetemp.h2
-rw-r--r--mesalib/src/mesa/swrast/s_aatriangle.c2
-rw-r--r--mesalib/src/mesa/swrast/s_context.c25
-rw-r--r--mesalib/src/mesa/swrast/s_context.h1
-rw-r--r--mesalib/src/mesa/swrast/s_drawpix.c3
-rw-r--r--mesalib/src/mesa/swrast/s_fragprog.c12
-rw-r--r--mesalib/src/mesa/swrast/s_fragprog.h82
-rw-r--r--mesalib/src/mesa/swrast/s_lines.c536
-rw-r--r--mesalib/src/mesa/swrast/s_span.c42
-rw-r--r--mesalib/src/mesa/swrast/s_triangle.c4
22 files changed, 988 insertions, 590 deletions
diff --git a/mesalib/src/mesa/drivers/dri/Makefile.am b/mesalib/src/mesa/drivers/dri/Makefile.am
index 3722082eb..8b9358221 100644
--- a/mesalib/src/mesa/drivers/dri/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS=
+SUBDIRS = common
if HAVE_I915_DRI
SUBDIRS+=i915
diff --git a/mesalib/src/mesa/drivers/dri/common/Makefile.am b/mesalib/src/mesa/drivers/dri/common/Makefile.am
new file mode 100644
index 000000000..4b43f4409
--- /dev/null
+++ b/mesalib/src/mesa/drivers/dri/common/Makefile.am
@@ -0,0 +1,37 @@
+# Copyright © 2012 Intel Corporation
+#
+# 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, sublicense,
+# 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 NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS 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.
+
+AM_CFLAGS = \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src/ \
+ -I$(top_srcdir)/src/mapi \
+ -I$(top_srcdir)/src/mesa/ \
+ $(DEFINES) \
+ $(ASM_FLAGS) \
+ $(API_DEFINES) \
+ $(LIBDRM_CFLAGS)
+
+noinst_LTLIBRARIES = libdricommon.la
+
+libdricommon_la_SOURCES = \
+ utils.c \
+ dri_util.c \
+ xmlconfig.c
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index 5b6db78d8..85ad9b55c 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -520,17 +520,29 @@ _mesa_copy_buffer_subdata(struct gl_context *ctx,
GLintptr readOffset, GLintptr writeOffset,
GLsizeiptr size)
{
- void *srcPtr, *dstPtr;
+ GLubyte *srcPtr, *dstPtr;
/* the buffers should not be mapped */
assert(!_mesa_bufferobj_mapped(src));
assert(!_mesa_bufferobj_mapped(dst));
- srcPtr = ctx->Driver.MapBufferRange(ctx, readOffset, size,
- GL_MAP_READ_BIT, src);
- dstPtr = ctx->Driver.MapBufferRange(ctx, writeOffset, size,
- (GL_MAP_WRITE_BIT |
- GL_MAP_INVALIDATE_RANGE_BIT), dst);
+ if (src == dst) {
+ srcPtr = dstPtr = ctx->Driver.MapBufferRange(ctx, 0, src->Size,
+ GL_MAP_READ_BIT |
+ GL_MAP_WRITE_BIT, src);
+
+ if (!srcPtr)
+ return;
+
+ srcPtr += readOffset;
+ dstPtr += writeOffset;
+ } else {
+ srcPtr = ctx->Driver.MapBufferRange(ctx, readOffset, size,
+ GL_MAP_READ_BIT, src);
+ dstPtr = ctx->Driver.MapBufferRange(ctx, writeOffset, size,
+ (GL_MAP_WRITE_BIT |
+ GL_MAP_INVALIDATE_RANGE_BIT), dst);
+ }
/* Note: the src and dst regions will never overlap. Trying to do so
* would generate GL_INVALID_VALUE earlier.
@@ -539,7 +551,8 @@ _mesa_copy_buffer_subdata(struct gl_context *ctx,
memcpy(dstPtr, srcPtr, size);
ctx->Driver.UnmapBuffer(ctx, src);
- ctx->Driver.UnmapBuffer(ctx, dst);
+ if (dst != src)
+ ctx->Driver.UnmapBuffer(ctx, dst);
}
diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c
index 95b8211b2..677debffc 100644
--- a/mesalib/src/mesa/main/dlist.c
+++ b/mesalib/src/mesa/main/dlist.c
@@ -46,6 +46,9 @@
#include "dlist.h"
#include "enums.h"
#include "eval.h"
+#if FEATURE_EXT_framebuffer_object
+#include "fbobject.h"
+#endif
#include "framebuffer.h"
#include "glapi/glapi.h"
#include "hash.h"
@@ -10112,6 +10115,24 @@ _mesa_create_save_table(void)
SET_GenVertexArraysAPPLE(table, _mesa_GenVertexArraysAPPLE);
SET_IsVertexArrayAPPLE(table, _mesa_IsVertexArrayAPPLE);
+ /* 310. GL_EXT_framebuffer_object */
+ SET_GenFramebuffersEXT(table, _mesa_GenFramebuffersEXT);
+ SET_BindFramebufferEXT(table, _mesa_BindFramebufferEXT);
+ SET_DeleteFramebuffersEXT(table, _mesa_DeleteFramebuffersEXT);
+ SET_CheckFramebufferStatusEXT(table, _mesa_CheckFramebufferStatusEXT);
+ SET_GenRenderbuffersEXT(table, _mesa_GenRenderbuffersEXT);
+ SET_BindRenderbufferEXT(table, _mesa_BindRenderbufferEXT);
+ SET_DeleteRenderbuffersEXT(table, _mesa_DeleteRenderbuffersEXT);
+ SET_RenderbufferStorageEXT(table, _mesa_RenderbufferStorageEXT);
+ SET_FramebufferTexture1DEXT(table, _mesa_FramebufferTexture1DEXT);
+ SET_FramebufferTexture2DEXT(table, _mesa_FramebufferTexture2DEXT);
+ SET_FramebufferTexture3DEXT(table, _mesa_FramebufferTexture3DEXT);
+ SET_FramebufferRenderbufferEXT(table, _mesa_FramebufferRenderbufferEXT);
+ SET_GenerateMipmapEXT(table, _mesa_GenerateMipmapEXT);
+
+ /* 317. GL_EXT_framebuffer_multisample */
+ SET_RenderbufferStorageMultisample(table, _mesa_RenderbufferStorageMultisample);
+
/* GL_ARB_vertex_array_object */
SET_BindVertexArray(table, _mesa_BindVertexArray);
SET_GenVertexArrays(table, _mesa_GenVertexArrays);
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index ff98c69cd..a2d889116 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -2210,6 +2210,58 @@ unpack_int_rgba_RG_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
}
static void
+unpack_int_rgba_RG_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i * 2 + 0];
+ dst[i][1] = src[i * 2 + 1];
+ dst[i][2] = 0;
+ dst[i][3] = 1;
+ }
+}
+
+static void
+unpack_int_rgba_RG_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i * 2 + 0];
+ dst[i][1] = src[i * 2 + 1];
+ dst[i][2] = 0;
+ dst[i][3] = 1;
+ }
+}
+
+static void
+unpack_int_rgba_RG_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i * 2 + 0];
+ dst[i][1] = src[i * 2 + 1];
+ dst[i][2] = 0;
+ dst[i][3] = 1;
+ }
+}
+
+static void
+unpack_int_rgba_RG_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i * 2 + 0];
+ dst[i][1] = src[i * 2 + 1];
+ dst[i][2] = 0;
+ dst[i][3] = 1;
+ }
+}
+
+static void
unpack_int_rgba_R_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
{
unsigned int i;
@@ -2223,6 +2275,113 @@ unpack_int_rgba_R_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
}
static void
+unpack_int_rgba_R_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i];
+ dst[i][1] = 0;
+ dst[i][2] = 0;
+ dst[i][3] = 1;
+ }
+}
+
+static void
+unpack_int_rgba_R_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i];
+ dst[i][1] = 0;
+ dst[i][2] = 0;
+ dst[i][3] = 1;
+ }
+}
+
+static void
+unpack_int_rgba_R_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i];
+ dst[i][1] = 0;
+ dst[i][2] = 0;
+ dst[i][3] = 1;
+ }
+}
+
+static void
+unpack_int_rgba_R_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = src[i];
+ dst[i][1] = 0;
+ dst[i][2] = 0;
+ dst[i][3] = 1;
+ }
+}
+
+static void
+unpack_int_rgba_ALPHA_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = 0;
+ dst[i][3] = src[i];
+ }
+}
+
+static void
+unpack_int_rgba_ALPHA_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = 0;
+ dst[i][3] = src[i];
+ }
+}
+
+static void
+unpack_int_rgba_ALPHA_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = 0;
+ dst[i][3] = src[i];
+ }
+}
+
+static void
+unpack_int_rgba_ALPHA_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = 0;
+ dst[i][3] = src[i];
+ }
+}
+
+static void
+unpack_int_rgba_ALPHA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = 0;
+ dst[i][3] = src[i];
+ }
+}
+
+static void
unpack_int_rgba_LUMINANCE_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
{
unsigned int i;
@@ -2245,6 +2404,50 @@ unpack_int_rgba_LUMINANCE_ALPHA_UINT32(const GLuint *src, GLuint dst[][4], GLuin
}
static void
+unpack_int_rgba_LUMINANCE_ALPHA_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0];
+ dst[i][3] = src[i * 2 + 1];
+ }
+}
+
+static void
+unpack_int_rgba_LUMINANCE_ALPHA_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0];
+ dst[i][3] = src[i * 2 + 1];
+ }
+}
+
+static void
+unpack_int_rgba_LUMINANCE_ALPHA_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0];
+ dst[i][3] = src[i * 2 + 1];
+ }
+}
+
+static void
+unpack_int_rgba_LUMINANCE_ALPHA_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = src[i * 2 + 0];
+ dst[i][3] = src[i * 2 + 1];
+ }
+}
+
+static void
unpack_int_rgba_INTENSITY_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
{
unsigned int i;
@@ -2255,6 +2458,46 @@ unpack_int_rgba_INTENSITY_UINT32(const GLuint *src, GLuint dst[][4], GLuint n)
}
static void
+unpack_int_rgba_INTENSITY_UINT16(const GLushort *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i];
+ }
+}
+
+static void
+unpack_int_rgba_INTENSITY_INT16(const GLshort *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i];
+ }
+}
+
+static void
+unpack_int_rgba_INTENSITY_UINT8(const GLubyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i];
+ }
+}
+
+static void
+unpack_int_rgba_INTENSITY_INT8(const GLbyte *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ dst[i][0] = dst[i][1] = dst[i][2] = dst[i][3] = src[i];
+ }
+}
+
+static void
unpack_int_rgba_ARGB2101010_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
{
unsigned int i;
@@ -2318,24 +2561,102 @@ _mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
case MESA_FORMAT_RG_INT32:
unpack_int_rgba_RG_UINT32(src, dst, n);
break;
+
+ case MESA_FORMAT_RG_UINT16:
+ unpack_int_rgba_RG_UINT16(src, dst, n);
+ break;
+ case MESA_FORMAT_RG_INT16:
+ unpack_int_rgba_RG_INT16(src, dst, n);
+ break;
+
+ case MESA_FORMAT_RG_UINT8:
+ unpack_int_rgba_RG_UINT8(src, dst, n);
+ break;
+ case MESA_FORMAT_RG_INT8:
+ unpack_int_rgba_RG_INT8(src, dst, n);
+ break;
+
case MESA_FORMAT_R_UINT32:
case MESA_FORMAT_R_INT32:
unpack_int_rgba_R_UINT32(src, dst, n);
break;
+ case MESA_FORMAT_R_UINT16:
+ unpack_int_rgba_R_UINT16(src, dst, n);
+ break;
+ case MESA_FORMAT_R_INT16:
+ unpack_int_rgba_R_INT16(src, dst, n);
+ break;
+
+ case MESA_FORMAT_R_UINT8:
+ unpack_int_rgba_R_UINT8(src, dst, n);
+ break;
+ case MESA_FORMAT_R_INT8:
+ unpack_int_rgba_R_INT8(src, dst, n);
+ break;
+
+ case MESA_FORMAT_ALPHA_UINT32:
+ case MESA_FORMAT_ALPHA_INT32:
+ unpack_int_rgba_ALPHA_UINT32(src, dst, n);
+ break;
+
+ case MESA_FORMAT_ALPHA_UINT16:
+ unpack_int_rgba_ALPHA_UINT16(src, dst, n);
+ break;
+ case MESA_FORMAT_ALPHA_INT16:
+ unpack_int_rgba_ALPHA_INT16(src, dst, n);
+ break;
+
+ case MESA_FORMAT_ALPHA_UINT8:
+ unpack_int_rgba_ALPHA_UINT8(src, dst, n);
+ break;
+ case MESA_FORMAT_ALPHA_INT8:
+ unpack_int_rgba_ALPHA_INT8(src, dst, n);
+ break;
+
case MESA_FORMAT_LUMINANCE_UINT32:
case MESA_FORMAT_LUMINANCE_INT32:
unpack_int_rgba_LUMINANCE_UINT32(src, dst, n);
break;
+
case MESA_FORMAT_LUMINANCE_ALPHA_UINT32:
case MESA_FORMAT_LUMINANCE_ALPHA_INT32:
unpack_int_rgba_LUMINANCE_ALPHA_UINT32(src, dst, n);
break;
+
+ case MESA_FORMAT_LUMINANCE_ALPHA_UINT16:
+ unpack_int_rgba_LUMINANCE_ALPHA_UINT16(src, dst, n);
+ break;
+ case MESA_FORMAT_LUMINANCE_ALPHA_INT16:
+ unpack_int_rgba_LUMINANCE_ALPHA_INT16(src, dst, n);
+ break;
+
+ case MESA_FORMAT_LUMINANCE_ALPHA_UINT8:
+ unpack_int_rgba_LUMINANCE_ALPHA_UINT8(src, dst, n);
+ break;
+ case MESA_FORMAT_LUMINANCE_ALPHA_INT8:
+ unpack_int_rgba_LUMINANCE_ALPHA_INT8(src, dst, n);
+ break;
+
case MESA_FORMAT_INTENSITY_UINT32:
case MESA_FORMAT_INTENSITY_INT32:
unpack_int_rgba_INTENSITY_UINT32(src, dst, n);
break;
+ case MESA_FORMAT_INTENSITY_UINT16:
+ unpack_int_rgba_INTENSITY_UINT16(src, dst, n);
+ break;
+ case MESA_FORMAT_INTENSITY_INT16:
+ unpack_int_rgba_INTENSITY_INT16(src, dst, n);
+ break;
+
+ case MESA_FORMAT_INTENSITY_UINT8:
+ unpack_int_rgba_INTENSITY_UINT8(src, dst, n);
+ break;
+ case MESA_FORMAT_INTENSITY_INT8:
+ unpack_int_rgba_INTENSITY_INT8(src, dst, n);
+ break;
+
case MESA_FORMAT_ARGB2101010_UINT:
unpack_int_rgba_ARGB2101010_UINT(src, dst, n);
break;
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index 96317dbf4..cecb70c01 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -2516,14 +2516,16 @@ _mesa_format_to_type_and_comps(gl_format format,
/**
* Check if a gl_format exactly matches a GL formaat/type combination
* such that we can use memcpy() from one to the other.
- *
- * Note: this matching assumes that GL_PACK/UNPACK_SWAP_BYTES is unset.
- *
+ * \param gl_format a MESA_FORMAT_x value
+ * \param format the user-specified image format
+ * \param type the user-specified image datatype
+ * \param swapBytes typically the current pixel pack/unpack byteswap state
* \return GL_TRUE if the formats match, GL_FALSE otherwise.
*/
GLboolean
_mesa_format_matches_format_and_type(gl_format gl_format,
- GLenum format, GLenum type)
+ GLenum format, GLenum type,
+ GLboolean swapBytes)
{
const GLboolean littleEndian = _mesa_little_endian();
@@ -2543,21 +2545,77 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
return GL_FALSE;
case MESA_FORMAT_RGBA8888:
- return ((format == GL_RGBA && (type == GL_UNSIGNED_INT_8_8_8_8 ||
- (type == GL_UNSIGNED_BYTE && !littleEndian))) ||
- (format == GL_ABGR_EXT && (type == GL_UNSIGNED_INT_8_8_8_8_REV ||
- (type == GL_UNSIGNED_BYTE && littleEndian))));
+ if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8 && !swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV && swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !littleEndian)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8_REV
+ && !swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8
+ && swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_UNSIGNED_BYTE && littleEndian)
+ return GL_TRUE;
+
+ return GL_FALSE;
case MESA_FORMAT_RGBA8888_REV:
- return ((format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV));
+ if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8_REV &&
+ !swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_INT_8_8_8_8 && swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && littleEndian)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8 &&
+ !swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_8_8_8_8_REV &&
+ swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_UNSIGNED_BYTE && !littleEndian)
+ return GL_TRUE;
+
+ return GL_FALSE;
case MESA_FORMAT_ARGB8888:
- return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8_REV ||
- (type == GL_UNSIGNED_BYTE && littleEndian))));
+ if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV &&
+ !swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8 && swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_BGRA && type == GL_UNSIGNED_BYTE && littleEndian)
+ return GL_TRUE;
+
+ return GL_FALSE;
case MESA_FORMAT_ARGB8888_REV:
- return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8 ||
- (type == GL_UNSIGNED_BYTE && !littleEndian))));
+ if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8 && !swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV &&
+ swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_BGRA && type == GL_UNSIGNED_BYTE && !littleEndian)
+ return GL_TRUE;
+
+ return GL_FALSE;
case MESA_FORMAT_RGBX8888:
case MESA_FORMAT_RGBX8888_REV:
@@ -2568,13 +2626,14 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
return GL_FALSE;
case MESA_FORMAT_RGB888:
- return format == GL_RGB && type == GL_UNSIGNED_BYTE && littleEndian;
+ return format == GL_BGR && type == GL_UNSIGNED_BYTE && littleEndian;
case MESA_FORMAT_BGR888:
- return GL_FALSE;
+ return format == GL_RGB && type == GL_UNSIGNED_BYTE && littleEndian;
case MESA_FORMAT_RGB565:
- return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5;
+ return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 && !swapBytes;
+
case MESA_FORMAT_RGB565_REV:
/* Some of the 16-bit MESA_FORMATs that would seem to correspond to
* GL_UNSIGNED_SHORT_* are byte-swapped instead of channel-reversed,
@@ -2583,15 +2642,20 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
return GL_FALSE;
case MESA_FORMAT_ARGB4444:
- return format == GL_BGRA && type == GL_UNSIGNED_SHORT_4_4_4_4_REV;
+ return format == GL_BGRA && type == GL_UNSIGNED_SHORT_4_4_4_4_REV &&
+ !swapBytes;
+
case MESA_FORMAT_ARGB4444_REV:
return GL_FALSE;
case MESA_FORMAT_RGBA5551:
- return format == GL_RGBA && type == GL_UNSIGNED_SHORT_5_5_5_1;
+ return format == GL_RGBA && type == GL_UNSIGNED_SHORT_5_5_5_1 &&
+ !swapBytes;
case MESA_FORMAT_ARGB1555:
- return format == GL_BGRA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV;
+ return format == GL_BGRA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV &&
+ !swapBytes;
+
case MESA_FORMAT_ARGB1555_REV:
return GL_FALSE;
@@ -2603,7 +2667,7 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
return GL_FALSE;
case MESA_FORMAT_AL1616:
- return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian;
+ return format == GL_LUMINANCE_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian && !swapBytes;
case MESA_FORMAT_AL1616_REV:
return GL_FALSE;
@@ -2613,15 +2677,18 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
case MESA_FORMAT_A8:
return format == GL_ALPHA && type == GL_UNSIGNED_BYTE;
case MESA_FORMAT_A16:
- return format == GL_ALPHA && type == GL_UNSIGNED_SHORT && littleEndian;
+ return format == GL_ALPHA && type == GL_UNSIGNED_SHORT &&
+ littleEndian && !swapBytes;
case MESA_FORMAT_L8:
return format == GL_LUMINANCE && type == GL_UNSIGNED_BYTE;
case MESA_FORMAT_L16:
- return format == GL_LUMINANCE && type == GL_UNSIGNED_SHORT && littleEndian;
+ return format == GL_LUMINANCE && type == GL_UNSIGNED_SHORT &&
+ littleEndian && !swapBytes;
case MESA_FORMAT_I8:
return format == GL_INTENSITY && type == GL_UNSIGNED_BYTE;
case MESA_FORMAT_I16:
- return format == GL_INTENSITY && type == GL_UNSIGNED_SHORT && littleEndian;
+ return format == GL_INTENSITY && type == GL_UNSIGNED_SHORT &&
+ littleEndian && !swapBytes;
case MESA_FORMAT_YCBCR:
case MESA_FORMAT_YCBCR_REV:
@@ -2635,32 +2702,38 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
return GL_FALSE;
case MESA_FORMAT_R16:
- return format == GL_RED && type == GL_UNSIGNED_SHORT && littleEndian;
+ return format == GL_RED && type == GL_UNSIGNED_SHORT && littleEndian &&
+ !swapBytes;
case MESA_FORMAT_RG1616:
- return format == GL_RG && type == GL_UNSIGNED_SHORT && littleEndian;
+ return format == GL_RG && type == GL_UNSIGNED_SHORT && littleEndian &&
+ !swapBytes;
case MESA_FORMAT_RG1616_REV:
return GL_FALSE;
case MESA_FORMAT_ARGB2101010:
- return format == GL_BGRA && type == GL_UNSIGNED_INT_2_10_10_10_REV;
+ return format == GL_BGRA && type == GL_UNSIGNED_INT_2_10_10_10_REV &&
+ !swapBytes;
case MESA_FORMAT_Z24_S8:
- return format == GL_DEPTH_STENCIL && type == GL_UNSIGNED_INT_24_8;
+ return format == GL_DEPTH_STENCIL && type == GL_UNSIGNED_INT_24_8 &&
+ !swapBytes;
case MESA_FORMAT_Z24_X8:
case MESA_FORMAT_S8_Z24:
return GL_FALSE;
case MESA_FORMAT_Z16:
- return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_SHORT;
+ return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_SHORT &&
+ !swapBytes;
case MESA_FORMAT_X8_Z24:
return GL_FALSE;
case MESA_FORMAT_Z32:
- return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_INT;
+ return format == GL_DEPTH_COMPONENT && type == GL_UNSIGNED_INT &&
+ !swapBytes;
case MESA_FORMAT_S8:
- return GL_FALSE;
+ return format == GL_STENCIL_INDEX && type == GL_UNSIGNED_BYTE;
case MESA_FORMAT_SRGB8:
case MESA_FORMAT_SRGBA8:
@@ -2682,44 +2755,44 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
return GL_FALSE;
case MESA_FORMAT_RGBA_FLOAT32:
- return format == GL_RGBA && type == GL_FLOAT;
+ return format == GL_RGBA && type == GL_FLOAT && !swapBytes;
case MESA_FORMAT_RGBA_FLOAT16:
- return format == GL_RGBA && type == GL_HALF_FLOAT;
+ return format == GL_RGBA && type == GL_HALF_FLOAT && !swapBytes;
case MESA_FORMAT_RGB_FLOAT32:
- return format == GL_RGB && type == GL_FLOAT;
+ return format == GL_RGB && type == GL_FLOAT && !swapBytes;
case MESA_FORMAT_RGB_FLOAT16:
- return format == GL_RGB && type == GL_HALF_FLOAT;
+ return format == GL_RGB && type == GL_HALF_FLOAT && !swapBytes;
case MESA_FORMAT_ALPHA_FLOAT32:
- return format == GL_ALPHA && type == GL_FLOAT;
+ return format == GL_ALPHA && type == GL_FLOAT && !swapBytes;
case MESA_FORMAT_ALPHA_FLOAT16:
- return format == GL_ALPHA && type == GL_HALF_FLOAT;
+ return format == GL_ALPHA && type == GL_HALF_FLOAT && !swapBytes;
case MESA_FORMAT_LUMINANCE_FLOAT32:
- return format == GL_LUMINANCE && type == GL_FLOAT;
+ return format == GL_LUMINANCE && type == GL_FLOAT && !swapBytes;
case MESA_FORMAT_LUMINANCE_FLOAT16:
- return format == GL_LUMINANCE && type == GL_HALF_FLOAT;
+ return format == GL_LUMINANCE && type == GL_HALF_FLOAT && !swapBytes;
case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
- return format == GL_LUMINANCE_ALPHA && type == GL_FLOAT;
+ return format == GL_LUMINANCE_ALPHA && type == GL_FLOAT && !swapBytes;
case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
- return format == GL_LUMINANCE_ALPHA && type == GL_HALF_FLOAT;
+ return format == GL_LUMINANCE_ALPHA && type == GL_HALF_FLOAT && !swapBytes;
case MESA_FORMAT_INTENSITY_FLOAT32:
- return format == GL_INTENSITY && type == GL_FLOAT;
+ return format == GL_INTENSITY && type == GL_FLOAT && !swapBytes;
case MESA_FORMAT_INTENSITY_FLOAT16:
- return format == GL_INTENSITY && type == GL_HALF_FLOAT;
+ return format == GL_INTENSITY && type == GL_HALF_FLOAT && !swapBytes;
case MESA_FORMAT_R_FLOAT32:
- return format == GL_RED && type == GL_FLOAT;
+ return format == GL_RED && type == GL_FLOAT && !swapBytes;
case MESA_FORMAT_R_FLOAT16:
- return format == GL_RED && type == GL_HALF_FLOAT;
+ return format == GL_RED && type == GL_HALF_FLOAT && !swapBytes;
case MESA_FORMAT_RG_FLOAT32:
- return format == GL_RG && type == GL_FLOAT;
+ return format == GL_RG && type == GL_FLOAT && !swapBytes;
case MESA_FORMAT_RG_FLOAT16:
- return format == GL_RG && type == GL_HALF_FLOAT;
+ return format == GL_RG && type == GL_HALF_FLOAT && !swapBytes;
/* FINISHME: What do we want to do for GL_EXT_texture_integer? */
case MESA_FORMAT_ALPHA_UINT8:
@@ -2786,8 +2859,26 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
case MESA_FORMAT_SIGNED_R8:
case MESA_FORMAT_SIGNED_RG88_REV:
case MESA_FORMAT_SIGNED_RGBX8888:
+ return GL_FALSE;
+
case MESA_FORMAT_SIGNED_RGBA8888:
+ if (format == GL_RGBA && type == GL_BYTE && !littleEndian)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_BYTE && littleEndian)
+ return GL_TRUE;
+
+ return GL_FALSE;
+
case MESA_FORMAT_SIGNED_RGBA8888_REV:
+ if (format == GL_RGBA && type == GL_BYTE && littleEndian)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_BYTE && !littleEndian)
+ return GL_TRUE;
+
+ return GL_FALSE;
+
case MESA_FORMAT_SIGNED_R16:
case MESA_FORMAT_SIGNED_GR1616:
case MESA_FORMAT_SIGNED_RGB_16:
@@ -2823,15 +2914,20 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
return GL_FALSE;
case MESA_FORMAT_ARGB2101010_UINT:
- return GL_FALSE;
+ return (format == GL_BGRA_INTEGER_EXT &&
+ type == GL_UNSIGNED_INT_2_10_10_10_REV &&
+ !swapBytes);
case MESA_FORMAT_RGB9_E5_FLOAT:
- return format == GL_RGB && type == GL_UNSIGNED_INT_5_9_9_9_REV;
+ return format == GL_RGB && type == GL_UNSIGNED_INT_5_9_9_9_REV &&
+ !swapBytes;
+
case MESA_FORMAT_R11_G11_B10_FLOAT:
- return format == GL_RGB && type == GL_UNSIGNED_INT_10F_11F_11F_REV;
+ return format == GL_RGB && type == GL_UNSIGNED_INT_10F_11F_11F_REV &&
+ !swapBytes;
case MESA_FORMAT_Z32_FLOAT:
- return format == GL_DEPTH_COMPONENT && type == GL_FLOAT;
+ return format == GL_DEPTH_COMPONENT && type == GL_FLOAT && !swapBytes;
case MESA_FORMAT_Z32_FLOAT_X24S8:
return GL_FALSE;
diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h
index 960934338..3a694a813 100644
--- a/mesalib/src/mesa/main/formats.h
+++ b/mesalib/src/mesa/main/formats.h
@@ -343,7 +343,8 @@ _mesa_format_num_components(gl_format format);
GLboolean
_mesa_format_matches_format_and_type(gl_format gl_format,
- GLenum format, GLenum type);
+ GLenum format, GLenum type,
+ GLboolean swapBytes);
#ifdef __cplusplus
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index f874ab21a..d07e2aaa8 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -462,7 +462,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef FN_NAME
#define DST_TYPE GLushort
-#define SRC_CONVERT(x) (x)
+#define SRC_CONVERT(x) MIN2(x, 0xffff)
#define FN_NAME pack_ushort_from_uint_rgba
#include "pack_tmp.h"
#undef DST_TYPE
@@ -470,7 +470,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef FN_NAME
#define DST_TYPE GLshort
-#define SRC_CONVERT(x) (x)
+#define SRC_CONVERT(x) CLAMP((int)x, -32768, 32767)
#define FN_NAME pack_short_from_uint_rgba
#include "pack_tmp.h"
#undef DST_TYPE
@@ -478,7 +478,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef FN_NAME
#define DST_TYPE GLubyte
-#define SRC_CONVERT(x) (x)
+#define SRC_CONVERT(x) MIN2(x, 0xff)
#define FN_NAME pack_ubyte_from_uint_rgba
#include "pack_tmp.h"
#undef DST_TYPE
@@ -486,7 +486,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max)
#undef FN_NAME
#define DST_TYPE GLbyte
-#define SRC_CONVERT(x) (x)
+#define SRC_CONVERT(x) CLAMP((int)x, -128, 127)
#define FN_NAME pack_byte_from_uint_rgba
#include "pack_tmp.h"
#undef DST_TYPE
@@ -2020,14 +2020,10 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4],
if (dstPacking->SwapBytes) {
GLint swapSize = _mesa_sizeof_packed_type(dstType);
if (swapSize == 2) {
- if (dstPacking->SwapBytes) {
- _mesa_swap2((GLushort *) dstAddr, n * comps);
- }
+ _mesa_swap2((GLushort *) dstAddr, n * comps);
}
else if (swapSize == 4) {
- if (dstPacking->SwapBytes) {
- _mesa_swap4((GLuint *) dstAddr, n * comps);
- }
+ _mesa_swap4((GLuint *) dstAddr, n * comps);
}
}
@@ -3008,27 +3004,6 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4],
static inline GLuint
-clamp_byte_to_uint(GLbyte b)
-{
- return b < 0 ? 0 : b;
-}
-
-
-static inline GLuint
-clamp_short_to_uint(GLshort s)
-{
- return s < 0 ? 0 : s;
-}
-
-
-static inline GLuint
-clamp_int_to_uint(GLint i)
-{
- return i < 0 ? 0 : i;
-}
-
-
-static inline GLuint
clamp_float_to_uint(GLfloat f)
{
return f < 0.0F ? 0 : IROUND(f);
@@ -3150,10 +3125,10 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
PROCESS(aSrc, ACOMP, 1, GLubyte, (GLuint));
break;
case GL_BYTE:
- PROCESS(rSrc, RCOMP, 0, GLbyte, clamp_byte_to_uint);
- PROCESS(gSrc, GCOMP, 0, GLbyte, clamp_byte_to_uint);
- PROCESS(bSrc, BCOMP, 0, GLbyte, clamp_byte_to_uint);
- PROCESS(aSrc, ACOMP, 1, GLbyte, clamp_byte_to_uint);
+ PROCESS(rSrc, RCOMP, 0, GLbyte, (GLuint));
+ PROCESS(gSrc, GCOMP, 0, GLbyte, (GLuint));
+ PROCESS(bSrc, BCOMP, 0, GLbyte, (GLuint));
+ PROCESS(aSrc, ACOMP, 1, GLbyte, (GLuint));
break;
case GL_UNSIGNED_SHORT:
PROCESS(rSrc, RCOMP, 0, GLushort, (GLuint));
@@ -3162,10 +3137,10 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
PROCESS(aSrc, ACOMP, 1, GLushort, (GLuint));
break;
case GL_SHORT:
- PROCESS(rSrc, RCOMP, 0, GLshort, clamp_short_to_uint);
- PROCESS(gSrc, GCOMP, 0, GLshort, clamp_short_to_uint);
- PROCESS(bSrc, BCOMP, 0, GLshort, clamp_short_to_uint);
- PROCESS(aSrc, ACOMP, 1, GLshort, clamp_short_to_uint);
+ PROCESS(rSrc, RCOMP, 0, GLshort, (GLuint));
+ PROCESS(gSrc, GCOMP, 0, GLshort, (GLuint));
+ PROCESS(bSrc, BCOMP, 0, GLshort, (GLuint));
+ PROCESS(aSrc, ACOMP, 1, GLshort, (GLuint));
break;
case GL_UNSIGNED_INT:
PROCESS(rSrc, RCOMP, 0, GLuint, (GLuint));
@@ -3174,10 +3149,10 @@ extract_uint_rgba(GLuint n, GLuint rgba[][4],
PROCESS(aSrc, ACOMP, 1, GLuint, (GLuint));
break;
case GL_INT:
- PROCESS(rSrc, RCOMP, 0, GLint, clamp_int_to_uint);
- PROCESS(gSrc, GCOMP, 0, GLint, clamp_int_to_uint);
- PROCESS(bSrc, BCOMP, 0, GLint, clamp_int_to_uint);
- PROCESS(aSrc, ACOMP, 1, GLint, clamp_int_to_uint);
+ PROCESS(rSrc, RCOMP, 0, GLint, (GLuint));
+ PROCESS(gSrc, GCOMP, 0, GLint, (GLuint));
+ PROCESS(bSrc, BCOMP, 0, GLint, (GLuint));
+ PROCESS(aSrc, ACOMP, 1, GLint, (GLuint));
break;
case GL_FLOAT:
PROCESS(rSrc, RCOMP, 0, GLfloat, clamp_float_to_uint);
diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c
index c1489d211..908a55e70 100644
--- a/mesalib/src/mesa/main/readpix.c
+++ b/mesalib/src/mesa/main/readpix.c
@@ -209,15 +209,10 @@ fast_read_rgba_pixels_memcpy( struct gl_context *ctx,
GLubyte *dst, *map;
int dstStride, stride, j, texelBytes;
- if (!_mesa_format_matches_format_and_type(rb->Format, format, type))
+ if (!_mesa_format_matches_format_and_type(rb->Format, format, type,
+ ctx->Pack.SwapBytes))
return GL_FALSE;
- /* check for things we can't handle here */
- if (packing->SwapBytes ||
- packing->LsbFirst) {
- return GL_FALSE;
- }
-
dstStride = _mesa_image_row_stride(packing, width, format, type);
dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height,
format, type, 0, 0);
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index 818deb8e4..42495c8c7 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -462,6 +462,15 @@ get_tex_rgba(struct gl_context *ctx, GLuint dimensions,
transferOps |= IMAGE_CLAMP_BIT;
}
}
+ /* This applies to RGB, RGBA textures. if the format is either LUMINANCE
+ * or LUMINANCE ALPHA, luminance (L) is computed as L=R+G+B .we need to
+ * clamp the sum to [0,1].
+ */
+ else if ((format == GL_LUMINANCE ||
+ format == GL_LUMINANCE_ALPHA) &&
+ dataType == GL_UNSIGNED_NORMALIZED) {
+ transferOps |= IMAGE_CLAMP_BIT;
+ }
if (_mesa_is_format_compressed(texImage->TexFormat)) {
get_tex_rgba_compressed(ctx, dimensions, format, type,
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 600dab302..827fcb788 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -1139,11 +1139,9 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS)
ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_RGB565 &&
baseInternalFormat == GL_RGB &&
- srcFormat == GL_RGB &&
- srcType == GL_UNSIGNED_SHORT_5_6_5) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -1243,30 +1241,9 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- (dstFormat == MESA_FORMAT_RGBA8888 ||
- dstFormat == MESA_FORMAT_RGBX8888) &&
baseInternalFormat == GL_RGBA &&
- ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
- (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- (dstFormat == MESA_FORMAT_RGBA8888_REV ||
- dstFormat == MESA_FORMAT_RGBX8888_REV) &&
- baseInternalFormat == GL_RGBA &&
- ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
- (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -1367,28 +1344,9 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- (dstFormat == MESA_FORMAT_ARGB8888 ||
- dstFormat == MESA_FORMAT_XRGB8888) &&
- baseInternalFormat == GL_RGBA &&
- srcFormat == GL_BGRA &&
- ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
- srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
- /* simple memcpy path (little endian) */
- memcpy_texture(ctx, dims,
- dstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- (dstFormat == MESA_FORMAT_ARGB8888_REV ||
- dstFormat == MESA_FORMAT_XRGB8888_REV) &&
baseInternalFormat == GL_RGBA &&
- srcFormat == GL_BGRA &&
- ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
- srcType == GL_UNSIGNED_INT_8_8_8_8)) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path (big endian) */
memcpy_texture(ctx, dims,
dstFormat,
@@ -1553,18 +1511,15 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_rgb888(TEXSTORE_PARAMS)
{
- const GLboolean littleEndian = _mesa_little_endian();
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_RGB888);
ASSERT(_mesa_get_format_bytes(dstFormat) == 3);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
baseInternalFormat == GL_RGB &&
- srcFormat == GL_BGR &&
- srcType == GL_UNSIGNED_BYTE &&
- littleEndian) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -1670,18 +1625,15 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_bgr888(TEXSTORE_PARAMS)
{
- const GLboolean littleEndian = _mesa_little_endian();
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_BGR888);
ASSERT(_mesa_get_format_bytes(dstFormat) == 3);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
baseInternalFormat == GL_RGB &&
- srcFormat == GL_RGB &&
- srcType == GL_UNSIGNED_BYTE &&
- littleEndian) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -1775,11 +1727,9 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS)
ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_ARGB4444 &&
baseInternalFormat == GL_RGBA &&
- srcFormat == GL_BGRA &&
- srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -1838,11 +1788,9 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS)
ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_RGBA5551 &&
baseInternalFormat == GL_RGBA &&
- srcFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_SHORT_5_5_5_1) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -1891,11 +1839,9 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS)
ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_ARGB1555 &&
baseInternalFormat == GL_RGBA &&
- srcFormat == GL_BGRA &&
- srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -1955,11 +1901,9 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS)
ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_ARGB2101010 &&
- srcFormat == GL_BGRA &&
- srcType == GL_UNSIGNED_INT_2_10_10_10_REV &&
- baseInternalFormat == GL_RGBA) {
+ baseInternalFormat == GL_RGBA &&
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -2458,9 +2402,9 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS)
ASSERT(_mesa_get_format_bytes(dstFormat) == 1);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
baseInternalFormat == GL_RGB &&
- srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -2990,7 +2934,6 @@ _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
{
- const GLboolean littleEndian = _mesa_little_endian();
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBA8888 ||
@@ -2998,11 +2941,9 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_SIGNED_RGBA8888 &&
baseInternalFormat == GL_RGBA &&
- ((srcFormat == GL_RGBA && srcType == GL_BYTE && !littleEndian) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -3010,19 +2951,6 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_SIGNED_RGBA8888_REV &&
- baseInternalFormat == GL_RGBA &&
- ((srcFormat == GL_RGBA && srcType == GL_BYTE && littleEndian) ||
- (srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) {
- /* simple memcpy path */
- memcpy_texture(ctx, dims,
- dstFormat,
- dstRowStride, dstSlices,
- srcWidth, srcHeight, srcDepth, srcFormat, srcType,
- srcAddr, srcPacking);
- }
else {
/* general path */
const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
@@ -3465,13 +3393,14 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS)
}
else {
/* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking, 0x0);
- const GLfloat *src = tempImage;
+ const GLuint *tempImage = make_temp_uint_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType,
+ srcAddr,
+ srcPacking);
+ const GLuint *src = tempImage;
GLint img, row;
if (!tempImage)
return GL_FALSE;
@@ -3534,13 +3463,14 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS)
}
else {
/* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking, 0x0);
- const GLfloat *src = tempImage;
+ const GLuint *tempImage = make_temp_uint_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType,
+ srcAddr,
+ srcPacking);
+ const GLuint *src = tempImage;
GLint img, row;
if (!tempImage)
return GL_FALSE;
@@ -3603,13 +3533,14 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS)
}
else {
/* general path */
- const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
- baseInternalFormat,
- baseFormat,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType, srcAddr,
- srcPacking, 0x0);
- const GLfloat *src = tempImage;
+ const GLuint *tempImage = make_temp_uint_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType,
+ srcAddr,
+ srcPacking);
+ const GLuint *src = tempImage;
GLint img, row;
if (!tempImage)
return GL_FALSE;
@@ -3959,9 +3890,8 @@ _mesa_texstore_rgb9_e5(TEXSTORE_PARAMS)
ASSERT(baseInternalFormat == GL_RGB);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- srcFormat == GL_RGB &&
- srcType == GL_UNSIGNED_INT_5_9_9_9_REV) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -4008,9 +3938,8 @@ _mesa_texstore_r11_g11_b10f(TEXSTORE_PARAMS)
ASSERT(baseInternalFormat == GL_RGB);
if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- srcFormat == GL_RGB &&
- srcType == GL_UNSIGNED_INT_10F_11F_11F_REV) {
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
@@ -4119,11 +4048,9 @@ _mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS)
ASSERT(dstFormat == MESA_FORMAT_ARGB2101010_UINT);
ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
- if (!srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_ARGB2101010_UINT &&
- srcFormat == GL_BGRA_INTEGER_EXT &&
- srcType == GL_UNSIGNED_INT_2_10_10_10_REV &&
- baseInternalFormat == GL_RGBA) {
+ if (baseInternalFormat == GL_RGBA &&
+ _mesa_format_matches_format_and_type(dstFormat, srcFormat, srcType,
+ srcPacking->SwapBytes)) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat,
diff --git a/mesalib/src/mesa/swrast/s_aaline.c b/mesalib/src/mesa/swrast/s_aaline.c
index d4b1805d9..d36d87697 100644
--- a/mesalib/src/mesa/swrast/s_aaline.c
+++ b/mesalib/src/mesa/swrast/s_aaline.c
@@ -479,7 +479,7 @@ _swrast_choose_aa_line_function(struct gl_context *ctx)
ASSERT(ctx->Line.SmoothFlag);
if (ctx->Texture._EnabledCoordUnits != 0
- || ctx->FragmentProgram._Current
+ || _swrast_use_fragment_program(ctx)
|| (ctx->Light.Enabled &&
ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
|| ctx->Fog.ColorSumEnabled
diff --git a/mesalib/src/mesa/swrast/s_aalinetemp.h b/mesalib/src/mesa/swrast/s_aalinetemp.h
index 376ef32d0..ba9f8abb9 100644
--- a/mesalib/src/mesa/swrast/s_aalinetemp.h
+++ b/mesalib/src/mesa/swrast/s_aalinetemp.h
@@ -67,7 +67,7 @@ NAME(plot)(struct gl_context *ctx, struct LineInfo *line, int ix, int iy)
ATTRIB_LOOP_BEGIN
GLfloat (*attribArray)[4] = line->span.array->attribs[attr];
if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0
- && !ctx->FragmentProgram._Current) {
+ && !_swrast_use_fragment_program(ctx)) {
/* texcoord w/ divide by Q */
const GLuint unit = attr - FRAG_ATTRIB_TEX0;
const GLfloat invQ = solve_plane_recip(fx, fy, line->attrPlane[attr][3]);
diff --git a/mesalib/src/mesa/swrast/s_aatriangle.c b/mesalib/src/mesa/swrast/s_aatriangle.c
index c68fdf63b..b59177fa7 100644
--- a/mesalib/src/mesa/swrast/s_aatriangle.c
+++ b/mesalib/src/mesa/swrast/s_aatriangle.c
@@ -299,7 +299,7 @@ _swrast_set_aa_triangle_function(struct gl_context *ctx)
ASSERT(ctx->Polygon.SmoothFlag);
if (ctx->Texture._EnabledCoordUnits != 0
- || ctx->FragmentProgram._Current
+ || _swrast_use_fragment_program(ctx)
|| swrast->_FogEnabled
|| _mesa_need_secondary_color(ctx)) {
SWRAST_CONTEXT(ctx)->Triangle = general_aa_tri;
diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c
index 14cb9b180..cc304d70c 100644
--- a/mesalib/src/mesa/swrast/s_context.c
+++ b/mesalib/src/mesa/swrast/s_context.c
@@ -105,7 +105,7 @@ _swrast_update_rasterflags( struct gl_context *ctx )
}
- if (ctx->FragmentProgram._Current) {
+ if (_swrast_use_fragment_program(ctx)) {
rasterMask |= FRAGPROG_BIT;
}
@@ -170,7 +170,7 @@ _swrast_update_fog_hint( struct gl_context *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
swrast->_PreferPixelFog = (!swrast->AllowVertexFog ||
- ctx->FragmentProgram._Current ||
+ _swrast_use_fragment_program(ctx) ||
(ctx->Hint.Fog == GL_NICEST &&
swrast->AllowPixelFog));
}
@@ -220,13 +220,14 @@ _swrast_update_deferred_texture(struct gl_context *ctx)
swrast->_DeferredTexture = GL_FALSE;
}
else {
+ GLboolean use_fprog = _swrast_use_fragment_program(ctx);
const struct gl_fragment_program *fprog
= ctx->FragmentProgram._Current;
- if (fprog && (fprog->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH))) {
+ if (use_fprog && (fprog->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH))) {
/* Z comes from fragment program/shader */
swrast->_DeferredTexture = GL_FALSE;
}
- else if (fprog && fprog->UsesKill) {
+ else if (use_fprog && fprog->UsesKill) {
swrast->_DeferredTexture = GL_FALSE;
}
else if (ctx->Query.CurrentOcclusionObject) {
@@ -254,7 +255,8 @@ _swrast_update_fog_state( struct gl_context *ctx )
(fp->Base.Target == GL_FRAGMENT_PROGRAM_NV));
/* determine if fog is needed, and if so, which fog mode */
- swrast->_FogEnabled = (fp == NULL && ctx->Fog.Enabled);
+ swrast->_FogEnabled = (!_swrast_use_fragment_program(ctx) &&
+ ctx->Fog.Enabled);
}
@@ -265,10 +267,11 @@ _swrast_update_fog_state( struct gl_context *ctx )
static void
_swrast_update_fragment_program(struct gl_context *ctx, GLbitfield newState)
{
- const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
- if (fp) {
- _mesa_load_state_parameters(ctx, fp->Base.Parameters);
- }
+ if (!_swrast_use_fragment_program(ctx))
+ return;
+
+ _mesa_load_state_parameters(ctx,
+ ctx->FragmentProgram._Current->Base.Parameters);
}
@@ -286,7 +289,7 @@ _swrast_update_specular_vertex_add(struct gl_context *ctx)
swrast->SpecularVertexAdd = (separateSpecular
&& ctx->Texture._EnabledUnits == 0x0
- && !ctx->FragmentProgram._Current
+ && !_swrast_use_fragment_program(ctx)
&& !ctx->ATIFragmentShader._Enabled);
}
@@ -497,7 +500,7 @@ _swrast_update_active_attribs(struct gl_context *ctx)
/*
* Compute _ActiveAttribsMask = which fragment attributes are needed.
*/
- if (ctx->FragmentProgram._Current) {
+ if (_swrast_use_fragment_program(ctx)) {
/* fragment program/shader */
attribsMask = ctx->FragmentProgram._Current->Base.InputsRead;
attribsMask &= ~FRAG_BIT_WPOS; /* WPOS is always handled specially */
diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h
index ae239a9a8..363bdf03a 100644
--- a/mesalib/src/mesa/swrast/s_context.h
+++ b/mesalib/src/mesa/swrast/s_context.h
@@ -47,6 +47,7 @@
#include "main/mtypes.h"
#include "program/prog_execute.h"
#include "swrast.h"
+#include "s_fragprog.h"
#include "s_span.h"
diff --git a/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c
index c5466ddbd..c19808bd4 100644
--- a/mesalib/src/mesa/swrast/s_drawpix.c
+++ b/mesalib/src/mesa/swrast/s_drawpix.c
@@ -239,7 +239,8 @@ fast_draw_rgba_pixels(struct gl_context *ctx, GLint x, GLint y,
return GL_TRUE;
}
- if (_mesa_format_matches_format_and_type(rb->Format, format, type)) {
+ if (_mesa_format_matches_format_and_type(rb->Format, format, type,
+ ctx->Unpack.SwapBytes)) {
fast_draw_generic_pixels(ctx, rb, x, y, width, height,
format, type, &unpack, pixels);
return GL_TRUE;
diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c
index 1caa0ebc2..cd20d8e36 100644
--- a/mesalib/src/mesa/swrast/s_fragprog.c
+++ b/mesalib/src/mesa/swrast/s_fragprog.c
@@ -30,6 +30,18 @@
#include "s_fragprog.h"
#include "s_span.h"
+/**
+ * \brief Should swrast use a fragment program?
+ *
+ * \return true if the current fragment program exists and is not the fixed
+ * function fragment program
+ */
+GLboolean
+_swrast_use_fragment_program(struct gl_context *ctx)
+{
+ struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
+ return fp && fp != ctx->FragmentProgram._TexEnvProgram;
+}
/**
* Apply texture object's swizzle (X/Y/Z/W/0/1) to incoming 'texel'
diff --git a/mesalib/src/mesa/swrast/s_fragprog.h b/mesalib/src/mesa/swrast/s_fragprog.h
index bd5fe6877..ac1f5ff4c 100644
--- a/mesalib/src/mesa/swrast/s_fragprog.h
+++ b/mesalib/src/mesa/swrast/s_fragprog.h
@@ -1,40 +1,42 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5.3
- *
- * Copyright (C) 1999-2006 Brian Paul 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, sublicense,
- * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL 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 S_FRAGPROG_H
-#define S_FRAGPROG_H
-
-
-#include "s_span.h"
-
-struct gl_context;
-
-
-extern void
-_swrast_exec_fragment_program(struct gl_context *ctx, SWspan *span);
-
-
-#endif /* S_FRAGPROG_H */
-
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5.3
+ *
+ * Copyright (C) 1999-2006 Brian Paul 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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 S_FRAGPROG_H
+#define S_FRAGPROG_H
+
+
+#include "s_span.h"
+
+struct gl_context;
+
+GLboolean
+_swrast_use_fragment_program(struct gl_context *ctx);
+
+extern void
+_swrast_exec_fragment_program(struct gl_context *ctx, SWspan *span);
+
+
+#endif /* S_FRAGPROG_H */
+
diff --git a/mesalib/src/mesa/swrast/s_lines.c b/mesalib/src/mesa/swrast/s_lines.c
index aba403308..ee997b08a 100644
--- a/mesalib/src/mesa/swrast/s_lines.c
+++ b/mesalib/src/mesa/swrast/s_lines.c
@@ -1,268 +1,268 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2007 Brian Paul 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, sublicense,
- * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL 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.
- */
-
-
-#include "main/glheader.h"
-#include "main/context.h"
-#include "main/colormac.h"
-#include "main/macros.h"
-#include "s_aaline.h"
-#include "s_context.h"
-#include "s_feedback.h"
-#include "s_lines.h"
-#include "s_span.h"
-
-
-/*
- * Init the mask[] array to implement a line stipple.
- */
-static void
-compute_stipple_mask( struct gl_context *ctx, GLuint len, GLubyte mask[] )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLuint i;
-
- for (i = 0; i < len; i++) {
- GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf;
- if ((1 << bit) & ctx->Line.StipplePattern) {
- mask[i] = GL_TRUE;
- }
- else {
- mask[i] = GL_FALSE;
- }
- swrast->StippleCounter++;
- }
-}
-
-
-/*
- * To draw a wide line we can simply redraw the span N times, side by side.
- */
-static void
-draw_wide_line( struct gl_context *ctx, SWspan *span, GLboolean xMajor )
-{
- const GLint width = (GLint) CLAMP(ctx->Line.Width,
- ctx->Const.MinLineWidth,
- ctx->Const.MaxLineWidth);
- GLint start;
-
- ASSERT(span->end < MAX_WIDTH);
-
- if (width & 1)
- start = width / 2;
- else
- start = width / 2 - 1;
-
- if (xMajor) {
- GLint *y = span->array->y;
- GLuint i;
- GLint w;
- for (w = 0; w < width; w++) {
- if (w == 0) {
- for (i = 0; i < span->end; i++)
- y[i] -= start;
- }
- else {
- for (i = 0; i < span->end; i++)
- y[i]++;
- }
- _swrast_write_rgba_span(ctx, span);
- }
- }
- else {
- GLint *x = span->array->x;
- GLuint i;
- GLint w;
- for (w = 0; w < width; w++) {
- if (w == 0) {
- for (i = 0; i < span->end; i++)
- x[i] -= start;
- }
- else {
- for (i = 0; i < span->end; i++)
- x[i]++;
- }
- _swrast_write_rgba_span(ctx, span);
- }
- }
-}
-
-
-
-/**********************************************************************/
-/***** Rasterization *****/
-/**********************************************************************/
-
-/* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/
-#define NAME simple_no_z_rgba_line
-#define INTERP_RGBA
-#define RENDER_SPAN(span) _swrast_write_rgba_span(ctx, &span);
-#include "s_linetemp.h"
-
-
-/* Z, fog, wide, stipple RGBA line */
-#define NAME rgba_line
-#define INTERP_RGBA
-#define INTERP_Z
-#define RENDER_SPAN(span) \
- if (ctx->Line.StippleFlag) { \
- span.arrayMask |= SPAN_MASK; \
- compute_stipple_mask(ctx, span.end, span.array->mask); \
- } \
- if (ctx->Line.Width > 1.0) { \
- draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
- } \
- else { \
- _swrast_write_rgba_span(ctx, &span); \
- }
-#include "s_linetemp.h"
-
-
-/* General-purpose line (any/all features). */
-#define NAME general_line
-#define INTERP_RGBA
-#define INTERP_Z
-#define INTERP_ATTRIBS
-#define RENDER_SPAN(span) \
- if (ctx->Line.StippleFlag) { \
- span.arrayMask |= SPAN_MASK; \
- compute_stipple_mask(ctx, span.end, span.array->mask); \
- } \
- if (ctx->Line.Width > 1.0) { \
- draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
- } \
- else { \
- _swrast_write_rgba_span(ctx, &span); \
- }
-#include "s_linetemp.h"
-
-
-
-void
-_swrast_add_spec_terms_line(struct gl_context *ctx,
- const SWvertex *v0, const SWvertex *v1)
-{
- SWvertex *ncv0 = (SWvertex *)v0;
- SWvertex *ncv1 = (SWvertex *)v1;
- GLfloat rSum, gSum, bSum;
- GLchan cSave[2][4];
-
- /* save original colors */
- COPY_CHAN4(cSave[0], ncv0->color);
- COPY_CHAN4(cSave[1], ncv1->color);
- /* sum v0 */
- rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0];
- gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1];
- bSum = CHAN_TO_FLOAT(ncv0->color[2]) + ncv0->attrib[FRAG_ATTRIB_COL1][2];
- UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[0], rSum);
- UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[1], gSum);
- UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[2], bSum);
- /* sum v1 */
- rSum = CHAN_TO_FLOAT(ncv1->color[0]) + ncv1->attrib[FRAG_ATTRIB_COL1][0];
- gSum = CHAN_TO_FLOAT(ncv1->color[1]) + ncv1->attrib[FRAG_ATTRIB_COL1][1];
- bSum = CHAN_TO_FLOAT(ncv1->color[2]) + ncv1->attrib[FRAG_ATTRIB_COL1][2];
- UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[0], rSum);
- UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[1], gSum);
- UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[2], bSum);
- /* draw */
- SWRAST_CONTEXT(ctx)->SpecLine( ctx, ncv0, ncv1 );
- /* restore original colors */
- COPY_CHAN4( ncv0->attrib[FRAG_ATTRIB_COL0], cSave[0] );
- COPY_CHAN4( ncv1->attrib[FRAG_ATTRIB_COL0], cSave[1] );
-}
-
-
-
-#ifdef DEBUG
-
-/* record the current line function name */
-static const char *lineFuncName = NULL;
-
-#define USE(lineFunc) \
-do { \
- lineFuncName = #lineFunc; \
- /*printf("%s\n", lineFuncName);*/ \
- swrast->Line = lineFunc; \
-} while (0)
-
-#else
-
-#define USE(lineFunc) swrast->Line = lineFunc
-
-#endif
-
-
-
-/**
- * Determine which line drawing function to use given the current
- * rendering context.
- *
- * Please update the summary flag _SWRAST_NEW_LINE if you add or remove
- * tests to this code.
- */
-void
-_swrast_choose_line( struct gl_context *ctx )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLboolean specular = (ctx->Fog.ColorSumEnabled ||
- (ctx->Light.Enabled &&
- ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR));
-
- if (ctx->RenderMode == GL_RENDER) {
- if (ctx->Line.SmoothFlag) {
- /* antialiased lines */
- _swrast_choose_aa_line_function(ctx);
- ASSERT(swrast->Line);
- }
- else if (ctx->Texture._EnabledCoordUnits
- || ctx->FragmentProgram._Current
- || swrast->_FogEnabled
- || specular) {
- USE(general_line);
- }
- else if (ctx->Depth.Test
- || ctx->Line.Width != 1.0
- || ctx->Line.StippleFlag) {
- /* no texture, but Z, fog, width>1, stipple, etc. */
-#if CHAN_BITS == 32
- USE(general_line);
-#else
- USE(rgba_line);
-#endif
- }
- else {
- ASSERT(!ctx->Depth.Test);
- ASSERT(ctx->Line.Width == 1.0);
- /* simple lines */
- USE(simple_no_z_rgba_line);
- }
- }
- else if (ctx->RenderMode == GL_FEEDBACK) {
- USE(_swrast_feedback_line);
- }
- else {
- ASSERT(ctx->RenderMode == GL_SELECT);
- USE(_swrast_select_line);
- }
-}
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.1
+ *
+ * Copyright (C) 1999-2007 Brian Paul 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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.
+ */
+
+
+#include "main/glheader.h"
+#include "main/context.h"
+#include "main/colormac.h"
+#include "main/macros.h"
+#include "s_aaline.h"
+#include "s_context.h"
+#include "s_feedback.h"
+#include "s_lines.h"
+#include "s_span.h"
+
+
+/*
+ * Init the mask[] array to implement a line stipple.
+ */
+static void
+compute_stipple_mask( struct gl_context *ctx, GLuint len, GLubyte mask[] )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint i;
+
+ for (i = 0; i < len; i++) {
+ GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf;
+ if ((1 << bit) & ctx->Line.StipplePattern) {
+ mask[i] = GL_TRUE;
+ }
+ else {
+ mask[i] = GL_FALSE;
+ }
+ swrast->StippleCounter++;
+ }
+}
+
+
+/*
+ * To draw a wide line we can simply redraw the span N times, side by side.
+ */
+static void
+draw_wide_line( struct gl_context *ctx, SWspan *span, GLboolean xMajor )
+{
+ const GLint width = (GLint) CLAMP(ctx->Line.Width,
+ ctx->Const.MinLineWidth,
+ ctx->Const.MaxLineWidth);
+ GLint start;
+
+ ASSERT(span->end < MAX_WIDTH);
+
+ if (width & 1)
+ start = width / 2;
+ else
+ start = width / 2 - 1;
+
+ if (xMajor) {
+ GLint *y = span->array->y;
+ GLuint i;
+ GLint w;
+ for (w = 0; w < width; w++) {
+ if (w == 0) {
+ for (i = 0; i < span->end; i++)
+ y[i] -= start;
+ }
+ else {
+ for (i = 0; i < span->end; i++)
+ y[i]++;
+ }
+ _swrast_write_rgba_span(ctx, span);
+ }
+ }
+ else {
+ GLint *x = span->array->x;
+ GLuint i;
+ GLint w;
+ for (w = 0; w < width; w++) {
+ if (w == 0) {
+ for (i = 0; i < span->end; i++)
+ x[i] -= start;
+ }
+ else {
+ for (i = 0; i < span->end; i++)
+ x[i]++;
+ }
+ _swrast_write_rgba_span(ctx, span);
+ }
+ }
+}
+
+
+
+/**********************************************************************/
+/***** Rasterization *****/
+/**********************************************************************/
+
+/* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/
+#define NAME simple_no_z_rgba_line
+#define INTERP_RGBA
+#define RENDER_SPAN(span) _swrast_write_rgba_span(ctx, &span);
+#include "s_linetemp.h"
+
+
+/* Z, fog, wide, stipple RGBA line */
+#define NAME rgba_line
+#define INTERP_RGBA
+#define INTERP_Z
+#define RENDER_SPAN(span) \
+ if (ctx->Line.StippleFlag) { \
+ span.arrayMask |= SPAN_MASK; \
+ compute_stipple_mask(ctx, span.end, span.array->mask); \
+ } \
+ if (ctx->Line.Width > 1.0) { \
+ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
+ } \
+ else { \
+ _swrast_write_rgba_span(ctx, &span); \
+ }
+#include "s_linetemp.h"
+
+
+/* General-purpose line (any/all features). */
+#define NAME general_line
+#define INTERP_RGBA
+#define INTERP_Z
+#define INTERP_ATTRIBS
+#define RENDER_SPAN(span) \
+ if (ctx->Line.StippleFlag) { \
+ span.arrayMask |= SPAN_MASK; \
+ compute_stipple_mask(ctx, span.end, span.array->mask); \
+ } \
+ if (ctx->Line.Width > 1.0) { \
+ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
+ } \
+ else { \
+ _swrast_write_rgba_span(ctx, &span); \
+ }
+#include "s_linetemp.h"
+
+
+
+void
+_swrast_add_spec_terms_line(struct gl_context *ctx,
+ const SWvertex *v0, const SWvertex *v1)
+{
+ SWvertex *ncv0 = (SWvertex *)v0;
+ SWvertex *ncv1 = (SWvertex *)v1;
+ GLfloat rSum, gSum, bSum;
+ GLchan cSave[2][4];
+
+ /* save original colors */
+ COPY_CHAN4(cSave[0], ncv0->color);
+ COPY_CHAN4(cSave[1], ncv1->color);
+ /* sum v0 */
+ rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0];
+ gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1];
+ bSum = CHAN_TO_FLOAT(ncv0->color[2]) + ncv0->attrib[FRAG_ATTRIB_COL1][2];
+ UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[0], rSum);
+ UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[1], gSum);
+ UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[2], bSum);
+ /* sum v1 */
+ rSum = CHAN_TO_FLOAT(ncv1->color[0]) + ncv1->attrib[FRAG_ATTRIB_COL1][0];
+ gSum = CHAN_TO_FLOAT(ncv1->color[1]) + ncv1->attrib[FRAG_ATTRIB_COL1][1];
+ bSum = CHAN_TO_FLOAT(ncv1->color[2]) + ncv1->attrib[FRAG_ATTRIB_COL1][2];
+ UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[0], rSum);
+ UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[1], gSum);
+ UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[2], bSum);
+ /* draw */
+ SWRAST_CONTEXT(ctx)->SpecLine( ctx, ncv0, ncv1 );
+ /* restore original colors */
+ COPY_CHAN4( ncv0->attrib[FRAG_ATTRIB_COL0], cSave[0] );
+ COPY_CHAN4( ncv1->attrib[FRAG_ATTRIB_COL0], cSave[1] );
+}
+
+
+
+#ifdef DEBUG
+
+/* record the current line function name */
+static const char *lineFuncName = NULL;
+
+#define USE(lineFunc) \
+do { \
+ lineFuncName = #lineFunc; \
+ /*printf("%s\n", lineFuncName);*/ \
+ swrast->Line = lineFunc; \
+} while (0)
+
+#else
+
+#define USE(lineFunc) swrast->Line = lineFunc
+
+#endif
+
+
+
+/**
+ * Determine which line drawing function to use given the current
+ * rendering context.
+ *
+ * Please update the summary flag _SWRAST_NEW_LINE if you add or remove
+ * tests to this code.
+ */
+void
+_swrast_choose_line( struct gl_context *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLboolean specular = (ctx->Fog.ColorSumEnabled ||
+ (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR));
+
+ if (ctx->RenderMode == GL_RENDER) {
+ if (ctx->Line.SmoothFlag) {
+ /* antialiased lines */
+ _swrast_choose_aa_line_function(ctx);
+ ASSERT(swrast->Line);
+ }
+ else if (ctx->Texture._EnabledCoordUnits
+ || _swrast_use_fragment_program(ctx)
+ || swrast->_FogEnabled
+ || specular) {
+ USE(general_line);
+ }
+ else if (ctx->Depth.Test
+ || ctx->Line.Width != 1.0
+ || ctx->Line.StippleFlag) {
+ /* no texture, but Z, fog, width>1, stipple, etc. */
+#if CHAN_BITS == 32
+ USE(general_line);
+#else
+ USE(rgba_line);
+#endif
+ }
+ else {
+ ASSERT(!ctx->Depth.Test);
+ ASSERT(ctx->Line.Width == 1.0);
+ /* simple lines */
+ USE(simple_no_z_rgba_line);
+ }
+ }
+ else if (ctx->RenderMode == GL_FEEDBACK) {
+ USE(_swrast_feedback_line);
+ }
+ else {
+ ASSERT(ctx->RenderMode == GL_SELECT);
+ USE(_swrast_select_line);
+ }
+}
diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c
index 7ab60b1e5..28f2f3d3f 100644
--- a/mesalib/src/mesa/swrast/s_span.c
+++ b/mesalib/src/mesa/swrast/s_span.c
@@ -139,7 +139,8 @@ _swrast_span_default_attribs(struct gl_context *ctx, SWspan *span)
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
const GLuint attr = FRAG_ATTRIB_TEX0 + i;
const GLfloat *tc = ctx->Current.RasterTexCoords[i];
- if (ctx->FragmentProgram._Current || ctx->ATIFragmentShader._Enabled) {
+ if (_swrast_use_fragment_program(ctx) ||
+ ctx->ATIFragmentShader._Enabled) {
COPY_4V(span->attrStart[attr], tc);
}
else if (tc[3] > 0.0F) {
@@ -498,7 +499,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
swrast_texture_image_const(img);
needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter)
- || ctx->FragmentProgram._Current;
+ || _swrast_use_fragment_program(ctx);
/* LOD is calculated directly in the ansiotropic filter, we can
* skip the normal lambda function as the result is ignored.
*/
@@ -518,7 +519,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
if (needLambda) {
GLuint i;
- if (ctx->FragmentProgram._Current
+ if (_swrast_use_fragment_program(ctx)
|| ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
@@ -559,7 +560,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
}
else {
GLuint i;
- if (ctx->FragmentProgram._Current ||
+ if (_swrast_use_fragment_program(ctx) ||
ctx->ATIFragmentShader._Enabled) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3];
@@ -833,7 +834,7 @@ add_specular(struct gl_context *ctx, SWspan *span)
GLfloat (*col1)[4] = span->array->attribs[FRAG_ATTRIB_COL1];
GLuint i;
- ASSERT(!ctx->FragmentProgram._Current);
+ ASSERT(!_swrast_use_fragment_program(ctx));
ASSERT(span->arrayMask & SPAN_RGBA);
ASSERT(swrast->_ActiveAttribMask & FRAG_BIT_COL1);
(void) swrast; /* silence warning */
@@ -971,25 +972,7 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output)
static inline void
shade_texture_span(struct gl_context *ctx, SWspan *span)
{
- /* This is a hack to work around drivers such as i965 that:
- *
- * - Set _MaintainTexEnvProgram to generate GLSL IR for
- * fixed-function fragment processing.
- * - Don't call _mesa_ir_link_shader to generate Mesa IR from
- * the GLSL IR.
- * - May use swrast to handle glDrawPixels.
- *
- * Since _mesa_ir_link_shader is never called, there is no Mesa IR
- * to execute. Instead do regular fixed-function processing.
- *
- * It is also worth noting that the software fixed-function path is
- * much faster than the software shader path.
- */
- const bool use_fragment_program =
- ctx->FragmentProgram._Current
- && ctx->FragmentProgram._Current != ctx->FragmentProgram._TexEnvProgram;
-
- if (use_fragment_program ||
+ if (_swrast_use_fragment_program(ctx) ||
ctx->ATIFragmentShader._Enabled) {
/* programmable shading */
if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) {
@@ -1018,7 +1001,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span)
interpolate_wpos(ctx, span);
/* Run fragment program/shader now */
- if (use_fragment_program) {
+ if (_swrast_use_fragment_program(ctx)) {
_swrast_exec_fragment_program(ctx, span);
}
else {
@@ -1052,8 +1035,8 @@ put_values(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLuint count, const GLint x[], const GLint y[],
const void *values, const GLubyte *mask)
{
- gl_pack_ubyte_rgba_func pack_ubyte;
- gl_pack_float_rgba_func pack_float;
+ gl_pack_ubyte_rgba_func pack_ubyte = NULL;
+ gl_pack_float_rgba_func pack_float = NULL;
GLuint i;
if (datatype == GL_UNSIGNED_BYTE)
@@ -1151,7 +1134,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
const GLbitfield64 origArrayAttribs = span->arrayAttribs;
const GLenum origChanType = span->array->ChanType;
void * const origRgba = span->array->rgba;
- const GLboolean shader = (ctx->FragmentProgram._Current
+ const GLboolean shader = (_swrast_use_fragment_program(ctx)
|| ctx->ATIFragmentShader._Enabled);
const GLboolean shaderOrTexture = shader || ctx->Texture._EnabledCoordUnits;
struct gl_framebuffer *fb = ctx->DrawBuffer;
@@ -1326,7 +1309,8 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
const GLuint numBuffers = fb->_NumColorDrawBuffers;
const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
const GLboolean multiFragOutputs =
- (fp && fp->Base.OutputsWritten >= (1 << FRAG_RESULT_DATA0));
+ _swrast_use_fragment_program(ctx)
+ && fp->Base.OutputsWritten >= (1 << FRAG_RESULT_DATA0);
GLuint buf;
for (buf = 0; buf < numBuffers; buf++) {
diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c
index 124aa5f8e..ddb4792f7 100644
--- a/mesalib/src/mesa/swrast/s_triangle.c
+++ b/mesalib/src/mesa/swrast/s_triangle.c
@@ -1038,7 +1038,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
* needs to be interpolated.
*/
if (ctx->Texture._EnabledCoordUnits ||
- ctx->FragmentProgram._Current ||
+ _swrast_use_fragment_program(ctx) ||
ctx->ATIFragmentShader._Enabled ||
_mesa_need_secondary_color(ctx) ||
swrast->_FogEnabled) {
@@ -1060,7 +1060,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
/* First see if we can use an optimized 2-D texture function */
if (ctx->Texture._EnabledCoordUnits == 0x1
- && !ctx->FragmentProgram._Current
+ && !_swrast_use_fragment_program(ctx)
&& !ctx->ATIFragmentShader._Enabled
&& ctx->Texture._EnabledUnits == 0x1
&& ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT