aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2015-02-22 21:39:56 +0100
committermarha <marha@users.sourceforge.net>2015-02-22 21:39:56 +0100
commit462f18c7b25fe3e467f837647d07ab0a78aa8d2b (patch)
treefc8013c0a1bac05a1945846c1697e973f4c35013 /mesalib/src/mesa/swrast
parent36f711ee12b6dd5184198abed3aa551efb585587 (diff)
downloadvcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.tar.gz
vcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.tar.bz2
vcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.zip
Merged origin/release (checked in because wanted to merge new stuff)
Diffstat (limited to 'mesalib/src/mesa/swrast')
-rw-r--r--mesalib/src/mesa/swrast/s_aaline.c1
-rw-r--r--mesalib/src/mesa/swrast/s_aalinetemp.h3
-rw-r--r--mesalib/src/mesa/swrast/s_blit.c43
-rw-r--r--mesalib/src/mesa/swrast/s_copypix.c25
-rw-r--r--mesalib/src/mesa/swrast/s_drawpix.c41
-rw-r--r--mesalib/src/mesa/swrast/s_fragprog.c4
-rw-r--r--mesalib/src/mesa/swrast/s_span.c28
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch.c11
-rw-r--r--mesalib/src/mesa/swrast/s_texfetch_tmp.h1359
-rw-r--r--mesalib/src/mesa/swrast/s_texfilter.c121
-rw-r--r--mesalib/src/mesa/swrast/s_triangle.c11
-rw-r--r--mesalib/src/mesa/swrast/swrast.h18
12 files changed, 302 insertions, 1363 deletions
diff --git a/mesalib/src/mesa/swrast/s_aaline.c b/mesalib/src/mesa/swrast/s_aaline.c
index b4e05ff80..6aea9d545 100644
--- a/mesalib/src/mesa/swrast/s_aaline.c
+++ b/mesalib/src/mesa/swrast/s_aaline.c
@@ -27,6 +27,7 @@
#include "main/imports.h"
#include "main/macros.h"
#include "main/mtypes.h"
+#include "main/teximage.h"
#include "swrast/s_aaline.h"
#include "swrast/s_context.h"
#include "swrast/s_span.h"
diff --git a/mesalib/src/mesa/swrast/s_aalinetemp.h b/mesalib/src/mesa/swrast/s_aalinetemp.h
index 670b663bd..f1d078fd8 100644
--- a/mesalib/src/mesa/swrast/s_aalinetemp.h
+++ b/mesalib/src/mesa/swrast/s_aalinetemp.h
@@ -179,7 +179,8 @@ NAME(line)(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1)
if (attr >= VARYING_SLOT_TEX0 && attr < VARYING_SLOT_VAR0) {
const GLuint u = attr - VARYING_SLOT_TEX0;
const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current;
- const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel];
+ const struct gl_texture_image *texImage =
+ _mesa_base_tex_image(obj);
line.texWidth[attr] = (GLfloat) texImage->Width;
line.texHeight[attr] = (GLfloat) texImage->Height;
}
diff --git a/mesalib/src/mesa/swrast/s_blit.c b/mesalib/src/mesa/swrast/s_blit.c
index e3b45f146..16e5b8c1c 100644
--- a/mesalib/src/mesa/swrast/s_blit.c
+++ b/mesalib/src/mesa/swrast/s_blit.c
@@ -107,14 +107,14 @@ RESAMPLE(resample_row_16, GLuint, 4)
*/
static void
blit_nearest(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield buffer)
{
struct gl_renderbuffer *readRb, *drawRb = NULL;
struct gl_renderbuffer_attachment *readAtt = NULL, *drawAtt = NULL;
- struct gl_framebuffer *readFb = ctx->ReadBuffer;
- struct gl_framebuffer *drawFb = ctx->DrawBuffer;
GLuint numDrawBuffers = 0;
GLuint i;
@@ -508,11 +508,11 @@ resample_linear_row_float(GLint srcWidth, GLint dstWidth,
*/
static void
blit_linear(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1)
{
- struct gl_framebuffer *drawFb = ctx->DrawBuffer;
- struct gl_framebuffer *readFb = ctx->ReadBuffer;
struct gl_renderbuffer *readRb = readFb->_ColorReadBuffer;
struct gl_renderbuffer_attachment *readAtt =
&readFb->Attachment[readFb->_ColorReadBufferIndex];
@@ -733,6 +733,8 @@ fail_no_memory:
*/
void
_swrast_BlitFramebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter)
@@ -756,7 +758,7 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
if (!_mesa_check_conditional_render(ctx))
return; /* Do not blit */
- if (!_mesa_clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1,
+ if (!_mesa_clip_blit(ctx, readFb, drawFb, &srcX0, &srcY0, &srcX1, &srcY1,
&dstX0, &dstY0, &dstX1, &dstY1)) {
return;
}
@@ -775,33 +777,34 @@ _swrast_BlitFramebuffer(struct gl_context *ctx,
dstY0 < dstY1) {
for (i = 0; i < 3; i++) {
if (mask & buffers[i]) {
- if (swrast_fast_copy_pixels(ctx,
- srcX0, srcY0,
- srcX1 - srcX0, srcY1 - srcY0,
- dstX0, dstY0,
- buffer_enums[i])) {
- mask &= ~buffers[i];
- }
- }
+ if (swrast_fast_copy_pixels(ctx,
+ readFb, drawFb,
+ srcX0, srcY0,
+ srcX1 - srcX0, srcY1 - srcY0,
+ dstX0, dstY0,
+ buffer_enums[i])) {
+ mask &= ~buffers[i];
+ }
+ }
}
if (!mask)
- return;
+ return;
}
if (filter == GL_NEAREST) {
for (i = 0; i < 3; i++) {
- if (mask & buffers[i]) {
- blit_nearest(ctx, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, buffers[i]);
- }
+ if (mask & buffers[i]) {
+ blit_nearest(ctx, readFb, drawFb, srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1, buffers[i]);
+ }
}
}
else {
ASSERT(filter == GL_LINEAR);
if (mask & GL_COLOR_BUFFER_BIT) { /* depth/stencil not allowed */
- blit_linear(ctx, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1);
+ blit_linear(ctx, readFb, drawFb, srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1);
}
}
diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c
index d00173476..e21c69dbc 100644
--- a/mesalib/src/mesa/swrast/s_copypix.c
+++ b/mesalib/src/mesa/swrast/s_copypix.c
@@ -442,11 +442,11 @@ end:
*/
GLboolean
swrast_fast_copy_pixels(struct gl_context *ctx,
- GLint srcX, GLint srcY, GLsizei width, GLsizei height,
- GLint dstX, GLint dstY, GLenum type)
+ struct gl_framebuffer *srcFb,
+ struct gl_framebuffer *dstFb,
+ GLint srcX, GLint srcY, GLsizei width, GLsizei height,
+ GLint dstX, GLint dstY, GLenum type)
{
- struct gl_framebuffer *srcFb = ctx->ReadBuffer;
- struct gl_framebuffer *dstFb = ctx->DrawBuffer;
struct gl_renderbuffer *srcRb, *dstRb;
GLint row;
GLuint pixelBytes, widthInBytes;
@@ -620,9 +620,9 @@ map_readbuffer(struct gl_context *ctx, GLenum type)
* By time we get here, all parameters will have been error-checked.
*/
void
-_swrast_CopyPixels( struct gl_context *ctx,
- GLint srcx, GLint srcy, GLsizei width, GLsizei height,
- GLint destx, GLint desty, GLenum type )
+_swrast_CopyPixels(struct gl_context *ctx,
+ GLint srcx, GLint srcy, GLsizei width, GLsizei height,
+ GLint destx, GLint desty, GLenum type)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
struct gl_renderbuffer *rb;
@@ -634,11 +634,12 @@ _swrast_CopyPixels( struct gl_context *ctx,
_swrast_validate_derived( ctx );
if (!(SWRAST_CONTEXT(ctx)->_RasterMask != 0x0 ||
- ctx->Pixel.ZoomX != 1.0F ||
- ctx->Pixel.ZoomY != 1.0F ||
- ctx->_ImageTransferState) &&
- swrast_fast_copy_pixels(ctx, srcx, srcy, width, height, destx, desty,
- type)) {
+ ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != 1.0F ||
+ ctx->_ImageTransferState) &&
+ swrast_fast_copy_pixels(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
+ srcx, srcy, width, height, destx, desty,
+ type)) {
/* all done */
return;
}
diff --git a/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c
index f7926e426..c99251904 100644
--- a/mesalib/src/mesa/swrast/s_drawpix.c
+++ b/mesalib/src/mesa/swrast/s_drawpix.c
@@ -29,6 +29,8 @@
#include "main/condrender.h"
#include "main/context.h"
#include "main/format_pack.h"
+#include "main/format_utils.h"
+#include "main/glformats.h"
#include "main/image.h"
#include "main/imports.h"
#include "main/macros.h"
@@ -414,7 +416,6 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
{
const GLint imgX = x, imgY = y;
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
- GLfloat *convImage = NULL;
GLbitfield transferOps = ctx->_ImageTransferState;
SWspan span;
@@ -452,6 +453,28 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
GLint skipPixels = 0;
/* use span array for temp color storage */
GLfloat *rgba = (GLfloat *) span.array->attribs[VARYING_SLOT_COL0];
+ void *tempImage = NULL;
+
+ if (unpack->SwapBytes) {
+ /* We have to handle byte-swapping scenarios before calling
+ * _mesa_format_convert
+ */
+ GLint swapSize = _mesa_sizeof_packed_type(type);
+ if (swapSize == 2 || swapSize == 4) {
+ int components = _mesa_components_in_format(format);
+ int elementCount = width * height * components;
+ tempImage = malloc(elementCount * swapSize);
+ if (!tempImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
+ return;
+ }
+ if (swapSize == 2)
+ _mesa_swap2_copy(tempImage, (GLushort *) pixels, elementCount);
+ else
+ _mesa_swap4_copy(tempImage, (GLuint *) pixels, elementCount);
+ pixels = tempImage;
+ }
+ }
/* if the span is wider than SWRAST_MAX_WIDTH we have to do it in chunks */
while (skipPixels < width) {
@@ -462,11 +485,15 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
type, 0, skipPixels);
GLint row;
+ /* get image row as float/RGBA */
+ uint32_t srcMesaFormat = _mesa_format_from_format_and_type(format, type);
for (row = 0; row < height; row++) {
- /* get image row as float/RGBA */
- _mesa_unpack_color_span_float(ctx, spanWidth, GL_RGBA, rgba,
- format, type, source, unpack,
- transferOps);
+ int dstRowStride = 4 * width * sizeof(float);
+ _mesa_format_convert(rgba, RGBA32_FLOAT, dstRowStride,
+ (void*)source, srcMesaFormat, srcStride,
+ spanWidth, 1, NULL);
+ if (transferOps)
+ _mesa_apply_rgba_transfer_ops(ctx, transferOps, spanWidth, (GLfloat (*)[4])rgba);
/* Set these for each row since the _swrast_write_* functions
* may change them while clipping/rendering.
*/
@@ -491,9 +518,9 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
/* XXX this is ugly/temporary, to undo above change */
span.array->ChanType = CHAN_TYPE;
- }
- free(convImage);
+ free(tempImage);
+ }
swrast_render_finish(ctx);
}
diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c
index 21699f3ea..1d7c33619 100644
--- a/mesalib/src/mesa/swrast/s_fragprog.c
+++ b/mesalib/src/mesa/swrast/s_fragprog.c
@@ -25,6 +25,7 @@
#include "main/glheader.h"
#include "main/colormac.h"
#include "main/samplerobj.h"
+#include "main/teximage.h"
#include "program/prog_instruction.h"
#include "s_context.h"
@@ -116,8 +117,7 @@ fetch_texel_deriv( struct gl_context *ctx, const GLfloat texcoord[4],
const struct gl_texture_object *texObj = texUnit->_Current;
if (texObj) {
- const struct gl_texture_image *texImg =
- texObj->Image[0][texObj->BaseLevel];
+ const struct gl_texture_image *texImg = _mesa_base_tex_image(texObj);
const struct swrast_texture_image *swImg =
swrast_texture_image_const(texImg);
const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, unit);
diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c
index 10aa33c6f..321959df9 100644
--- a/mesalib/src/mesa/swrast/s_span.c
+++ b/mesalib/src/mesa/swrast/s_span.c
@@ -39,6 +39,7 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/samplerobj.h"
+#include "main/teximage.h"
#include "s_atifragshader.h"
#include "s_alpha.h"
@@ -495,7 +496,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
GLfloat q = span->attrStart[attr][3] + span->leftClip * dqdx;
if (obj) {
- const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
+ const struct gl_texture_image *img = _mesa_base_tex_image(obj);
const struct swrast_texture_image *swImg =
swrast_texture_image_const(img);
const struct gl_sampler_object *samp = _mesa_get_samplerobj(ctx, u);
@@ -932,19 +933,19 @@ clamp_colors(SWspan *span)
* \param output which fragment program color output is being processed
*/
static inline void
-convert_color_type(SWspan *span, GLenum newType, GLuint output)
+convert_color_type(SWspan *span, GLenum srcType, GLenum newType, GLuint output)
{
GLvoid *src, *dst;
- if (output > 0 || span->array->ChanType == GL_FLOAT) {
+ if (output > 0 || srcType == GL_FLOAT) {
src = span->array->attribs[VARYING_SLOT_COL0 + output];
span->array->ChanType = GL_FLOAT;
}
- else if (span->array->ChanType == GL_UNSIGNED_BYTE) {
+ else if (srcType == GL_UNSIGNED_BYTE) {
src = span->array->rgba8;
}
else {
- ASSERT(span->array->ChanType == GL_UNSIGNED_SHORT);
+ ASSERT(srcType == GL_UNSIGNED_SHORT);
src = span->array->rgba16;
}
@@ -978,7 +979,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span)
ctx->ATIFragmentShader._Enabled) {
/* programmable shading */
if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) {
- convert_color_type(span, GL_FLOAT, 0);
+ convert_color_type(span, span->array->ChanType, GL_FLOAT, 0);
}
else {
span->array->rgba = (void *) span->array->attribs[VARYING_SLOT_COL0];
@@ -1313,6 +1314,8 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
const GLboolean multiFragOutputs =
_swrast_use_fragment_program(ctx)
&& fp->Base.OutputsWritten >= (1 << FRAG_RESULT_DATA0);
+ /* Save srcColorType because convert_color_type() can change it */
+ const GLenum srcColorType = span->array->ChanType;
GLuint buf;
for (buf = 0; buf < numBuffers; buf++) {
@@ -1324,17 +1327,18 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
/* re-use one of the attribute array buffers for rgbaSave */
GLchan (*rgbaSave)[4] = (GLchan (*)[4]) span->array->attribs[0];
struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
- GLenum colorType = srb->ColorType;
+ const GLenum dstColorType = srb->ColorType;
- assert(colorType == GL_UNSIGNED_BYTE ||
- colorType == GL_FLOAT);
+ assert(dstColorType == GL_UNSIGNED_BYTE ||
+ dstColorType == GL_FLOAT);
/* set span->array->rgba to colors for renderbuffer's datatype */
- if (span->array->ChanType != colorType) {
- convert_color_type(span, colorType, 0);
+ if (srcColorType != dstColorType) {
+ convert_color_type(span, srcColorType, dstColorType,
+ multiFragOutputs ? buf : 0);
}
else {
- if (span->array->ChanType == GL_UNSIGNED_BYTE) {
+ if (srcColorType == GL_UNSIGNED_BYTE) {
span->array->rgba = span->array->rgba8;
}
else {
diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c
index 0f6da919d..9629024b9 100644
--- a/mesalib/src/mesa/swrast/s_texfetch.c
+++ b/mesalib/src/mesa/swrast/s_texfetch.c
@@ -166,6 +166,8 @@ texfetch_funcs[] =
FETCH_FUNCS(B10G10R10A2_UNORM),
FETCH_NULL(B10G10R10X2_UNORM),
FETCH_FUNCS(R10G10B10A2_UNORM),
+ FETCH_NULL(R10G10B10X2_UNORM),
+
FETCH_FUNCS(S8_UINT_Z24_UNORM),
{
MESA_FORMAT_X8_UINT_Z24_UNORM,
@@ -180,6 +182,13 @@ texfetch_funcs[] =
fetch_texel_2d_Z24_UNORM_S8_UINT,
fetch_texel_3d_Z24_UNORM_S8_UINT
},
+ FETCH_NULL(R3G3B2_UNORM),
+ FETCH_NULL(A4B4G4R4_UNORM),
+ FETCH_NULL(R4G4B4A4_UNORM),
+ FETCH_NULL(R5G5B5A1_UNORM),
+ FETCH_NULL(A2B10G10R10_UNORM),
+ FETCH_NULL(A2R10G10B10_UNORM),
+
FETCH_FUNCS(YCBCR),
FETCH_FUNCS(YCBCR_REV),
@@ -276,6 +285,8 @@ texfetch_funcs[] =
/* Packed signed/unsigned non-normalized integer formats */
FETCH_NULL(B10G10R10A2_UINT),
FETCH_NULL(R10G10B10A2_UINT),
+ FETCH_NULL(A2B10G10R10_UINT),
+ FETCH_NULL(A2R10G10B10_UINT),
/* Array signed/unsigned non-normalized integer formats */
FETCH_NULL(A_UINT8),
diff --git a/mesalib/src/mesa/swrast/s_texfetch_tmp.h b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
index 7ff30f6b4..45bd83950 100644
--- a/mesalib/src/mesa/swrast/s_texfetch_tmp.h
+++ b/mesalib/src/mesa/swrast/s_texfetch_tmp.h
@@ -39,6 +39,7 @@
* \author Brian Paul
*/
+#include <format_unpack.h>
#if DIM == 1
@@ -68,1244 +69,128 @@
#error illegal number of texture dimensions
#endif
-
-static void
-FETCH(Z_UNORM32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[0] = src[0] * (1.0F / 0xffffffff);
-}
-
-
-static void
-FETCH(Z_UNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[0] = src[0] * (1.0F / 65535.0F);
-}
-
-
-static void
-FETCH(RGBA_FLOAT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
- texel[RCOMP] = src[0];
- texel[GCOMP] = src[1];
- texel[BCOMP] = src[2];
- texel[ACOMP] = src[3];
-}
-
-
-static void
-FETCH(RGBA_FLOAT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
- texel[RCOMP] = _mesa_half_to_float(src[0]);
- texel[GCOMP] = _mesa_half_to_float(src[1]);
- texel[BCOMP] = _mesa_half_to_float(src[2]);
- texel[ACOMP] = _mesa_half_to_float(src[3]);
-}
-
-
-static void
-FETCH(RGB_FLOAT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 3);
- texel[RCOMP] = src[0];
- texel[GCOMP] = src[1];
- texel[BCOMP] = src[2];
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(RGB_FLOAT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 3);
- texel[RCOMP] = _mesa_half_to_float(src[0]);
- texel[GCOMP] = _mesa_half_to_float(src[1]);
- texel[BCOMP] = _mesa_half_to_float(src[2]);
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(A_FLOAT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = src[0];
-}
-
-
-static void
-FETCH(A_FLOAT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = _mesa_half_to_float(src[0]);
-}
-
-
-static void
-FETCH(L_FLOAT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = src[0];
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(L_FLOAT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = _mesa_half_to_float(src[0]);
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(LA_FLOAT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = src[0];
- texel[ACOMP] = src[1];
-}
-
-
-static void
-FETCH(LA_FLOAT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = _mesa_half_to_float(src[0]);
- texel[ACOMP] = _mesa_half_to_float(src[1]);
-}
-
-
-static void
-FETCH(I_FLOAT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = src[0];
-}
-
-
-static void
-FETCH(I_FLOAT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = _mesa_half_to_float(src[0]);
-}
-
-
-static void
-FETCH(R_FLOAT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 1);
- texel[RCOMP] = src[0];
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(R_FLOAT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 1);
- texel[RCOMP] = _mesa_half_to_float(src[0]);
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(RG_FLOAT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
- texel[RCOMP] = src[0];
- texel[GCOMP] = src[1];
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(RG_FLOAT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLhalfARB *src = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 2);
- texel[RCOMP] = _mesa_half_to_float(src[0]);
- texel[GCOMP] = _mesa_half_to_float(src[1]);
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(A8B8G8R8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
-}
-
-
-static void
-FETCH(R8G8B8A8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
-}
-
-
-static void
-FETCH(B8G8R8A8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
-}
-
-
-static void
-FETCH(A8R8G8B8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
-}
-
-
-static void
-FETCH(X8B8G8R8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[ACOMP] = 1.0f;
-}
-
-
-static void
-FETCH(R8G8B8X8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[ACOMP] = 1.0f;
-}
-
-
-static void
-FETCH(B8G8R8X8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
- texel[ACOMP] = 1.0f;
-}
-
-
-static void
-FETCH(X8R8G8B8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
- texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
- texel[ACOMP] = 1.0f;
-}
-
-
-static void
-FETCH(BGR_UNORM8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
- texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
- texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(RGB_UNORM8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
- texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
- texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(B5G6R5_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = *src;
- texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
- texel[GCOMP] = ((s >> 5 ) & 0x3f) * (1.0F / 63.0F);
- texel[BCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F);
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(R5G6B5_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
- texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
- texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) );
- texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(B4G4R4A4_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = *src;
- texel[RCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F);
- texel[GCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
- texel[BCOMP] = ((s ) & 0xf) * (1.0F / 15.0F);
- texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
-}
-
-
-static void
-FETCH(A4R4G4B4_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
- texel[GCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F);
- texel[BCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
- texel[ACOMP] = ((s ) & 0xf) * (1.0F / 15.0F);
-}
-
-
-static void
-FETCH(A1B5G5R5_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = *src;
- texel[RCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F);
- texel[GCOMP] = ((s >> 6) & 0x1f) * (1.0F / 31.0F);
- texel[BCOMP] = ((s >> 1) & 0x1f) * (1.0F / 31.0F);
- texel[ACOMP] = ((s ) & 0x01) * 1.0F;
-}
-
-
-static void
-FETCH(B5G5R5A1_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = *src;
- texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F);
- texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F);
- texel[BCOMP] = ((s >> 0) & 0x1f) * (1.0F / 31.0F);
- texel[ACOMP] = ((s >> 15) & 0x01) * 1.0F;
-}
-
-
-static void
-FETCH(A1R5G5B5_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */
- texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 7) & 0xf8) | ((s >> 12) & 0x7) );
- texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 2) & 0xf8) | ((s >> 7) & 0x7) );
- texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
- texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 );
-}
-
-
-static void
-FETCH(B10G10R10A2_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- const GLuint s = *src;
- texel[RCOMP] = ((s >> 20) & 0x3ff) * (1.0F / 1023.0F);
- texel[GCOMP] = ((s >> 10) & 0x3ff) * (1.0F / 1023.0F);
- texel[BCOMP] = ((s >> 0) & 0x3ff) * (1.0F / 1023.0F);
- texel[ACOMP] = ((s >> 30) & 0x03) * (1.0F / 3.0F);
-}
-
-
-static void
-FETCH(R10G10B10A2_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- const GLuint s = *src;
- texel[RCOMP] = ((s >> 0) & 0x3ff) * (1.0F / 1023.0F);
- texel[GCOMP] = ((s >> 10) & 0x3ff) * (1.0F / 1023.0F);
- texel[BCOMP] = ((s >> 20) & 0x3ff) * (1.0F / 1023.0F);
- texel[ACOMP] = ((s >> 30) & 0x03) * (1.0F / 3.0F);
-}
-
-
-static void
-FETCH(R8G8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( s & 0xff );
- texel[GCOMP] = UBYTE_TO_FLOAT( s >> 8 );
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-
-static void
-FETCH(G8R8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT( s >> 8 );
- texel[GCOMP] = UBYTE_TO_FLOAT( s & 0xff );
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-
-static void
-FETCH(L4A4_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = (s & 0xf) * (1.0F / 15.0F);
- texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
-}
-
-
-static void
-FETCH(L8A8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 );
-}
-
-
-static void
-FETCH(R_UNORM8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte s = *TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] = UBYTE_TO_FLOAT(s);
- texel[GCOMP] = 0.0;
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-
-static void
-FETCH(R_UNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] = USHORT_TO_FLOAT(s);
- texel[GCOMP] = 0.0;
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-
-static void
-FETCH(A8L8_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 );
- texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff );
-}
-
-
-static void
-FETCH(R16G16_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = USHORT_TO_FLOAT( s & 0xffff );
- texel[GCOMP] = USHORT_TO_FLOAT( s >> 16 );
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-
-static void
-FETCH(G16R16_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = USHORT_TO_FLOAT( s >> 16 );
- texel[GCOMP] = USHORT_TO_FLOAT( s & 0xffff );
- texel[BCOMP] = 0.0;
- texel[ACOMP] = 1.0;
-}
-
-
-static void
-FETCH(L16A16_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff );
- texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 );
-}
-
-
-static void
-FETCH(A16L16_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = USHORT_TO_FLOAT( s >> 16 );
- texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff );
-}
-
-
-static void
-FETCH(B2G3R3_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- const GLubyte s = *src;
- texel[RCOMP] = ((s >> 5) & 0x7) * (1.0F / 7.0F);
- texel[GCOMP] = ((s >> 2) & 0x7) * (1.0F / 7.0F);
- texel[BCOMP] = ((s ) & 0x3) * (1.0F / 3.0F);
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(A_UNORM8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
-}
-
-
-static void
-FETCH(A_UNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
-}
-
-
-static void
-FETCH(L_UNORM8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(L_UNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = USHORT_TO_FLOAT( src[0] );
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(I_UNORM8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
-}
-
-
-static void
-FETCH(I_UNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
-}
-
-
-static void
-FETCH(BGR_SRGB8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 3);
- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(src[2]);
- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(src[1]);
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(src[0]);
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(A8B8G8R8_SRGB)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 24) );
- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); /* linear! */
-}
-
-
-static void
-FETCH(B8G8R8A8_SRGB)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s ) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
-}
-
-
-static void
-FETCH(A8R8G8B8_SRGB)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 24) );
- texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); /* linear! */
-}
-
-
-static void
-FETCH(R8G8B8A8_SRGB)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s ) & 0xff );
- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
- texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
-}
-
-
-static void
-FETCH(R8G8B8X8_SRGB)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s ) & 0xff );
- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
- texel[ACOMP] = 1.0f;
-}
-
-
-static void
-FETCH(X8B8G8R8_SRGB)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 24) );
- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 16) & 0xff );
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float( (s >> 8) & 0xff );
- texel[ACOMP] = 1.0f;
-}
-
-
-static void
-FETCH(L_SRGB8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(src[0]);
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(L8A8_SRGB)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(s & 0xff);
- texel[ACOMP] = UBYTE_TO_FLOAT(s >> 8); /* linear */
-}
-
-
-static void
-FETCH(A8L8_SRGB)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 2);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(s >> 8);
- texel[ACOMP] = UBYTE_TO_FLOAT(s & 0xff); /* linear */
-}
-
-
-static void
-FETCH(RGBA_SINT8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLbyte *src = TEXEL_ADDR(GLbyte, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-
-static void
-FETCH(RGBA_SINT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort *src = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-
-static void
-FETCH(RGBA_SINT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLint *src = TEXEL_ADDR(GLint, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-
-static void
-FETCH(RGBA_UINT8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-
-static void
-FETCH(RGBA_UINT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-
-static void
-FETCH(RGBA_UINT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 4);
- texel[RCOMP] = (GLfloat) src[0];
- texel[GCOMP] = (GLfloat) src[1];
- texel[BCOMP] = (GLfloat) src[2];
- texel[ACOMP] = (GLfloat) src[3];
-}
-
-
-static void
-FETCH(R_SNORM8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( s );
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(A_SNORM8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- texel[RCOMP] = 0.0F;
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
-}
-
-
-static void
-FETCH(L_SNORM8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( s );
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(I_SNORM8)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( s );
-}
-
-
-static void
-FETCH(R8G8_SNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
- texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(L8A8_SNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
-}
-
-
-static void
-FETCH(A8L8_SNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
-}
-
-
-static void
-FETCH(X8B8G8R8_SNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
- texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
- texel[ACOMP] = 1.0f;
-}
-
-
-static void
-FETCH(A8B8G8R8_SNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
- texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) );
-}
-
-
-static void
-FETCH(R8G8B8A8_SNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s ) );
- texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
- texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
- texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
-}
-
-
-static void
-FETCH(R_SNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] = SHORT_TO_FLOAT_TEX( s );
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(A_SNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] = 0.0F;
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
-}
-
-
-static void
-FETCH(L_SNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = SHORT_TO_FLOAT_TEX( s );
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(I_SNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] =
- texel[ACOMP] = SHORT_TO_FLOAT_TEX( s );
-}
-
-
-static void
-FETCH(R16G16_SNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
- texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
- texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(LA_SNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
- texel[RCOMP] =
- texel[GCOMP] =
- texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
- texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[1] );
-}
-
-
-static void
-
-FETCH(RGB_SNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
- texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
- texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
- texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] );
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(RGBA_SNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
- texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
- texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
- texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] );
- texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] );
-}
-
-
-static void
-FETCH(RGBA_UNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
- texel[RCOMP] = USHORT_TO_FLOAT( s[0] );
- texel[GCOMP] = USHORT_TO_FLOAT( s[1] );
- texel[BCOMP] = USHORT_TO_FLOAT( s[2] );
- texel[ACOMP] = USHORT_TO_FLOAT( s[3] );
-}
-
-
-static void
-FETCH(RGBX_UNORM16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
- texel[RCOMP] = USHORT_TO_FLOAT(s[0]);
- texel[GCOMP] = USHORT_TO_FLOAT(s[1]);
- texel[BCOMP] = USHORT_TO_FLOAT(s[2]);
- texel[ACOMP] = 1.0f;
-}
-
-
-static void
-FETCH(RGBX_FLOAT16)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLhalfARB *s = TEXEL_ADDR(GLhalfARB, texImage, i, j, k, 4);
- texel[RCOMP] = _mesa_half_to_float(s[0]);
- texel[GCOMP] = _mesa_half_to_float(s[1]);
- texel[BCOMP] = _mesa_half_to_float(s[2]);
- texel[ACOMP] = 1.0f;
-}
-
-
-static void
-FETCH(RGBX_FLOAT32)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLfloat *s = TEXEL_ADDR(GLfloat, texImage, i, j, k, 4);
- texel[RCOMP] = s[0];
- texel[GCOMP] = s[1];
- texel[BCOMP] = s[2];
- texel[ACOMP] = 1.0f;
-}
-
-
-/**
- * Fetch texel from 1D, 2D or 3D ycbcr texture, returning RGBA.
- */
-static void
-FETCH(YCBCR)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
- const GLushort *src1 = src0 + 1; /* odd */
- const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */
- const GLubyte cb = *src0 & 0xff; /* chroma U */
- const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */
- const GLubyte cr = *src1 & 0xff; /* chroma V */
- const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
- GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
- GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
- GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
- r *= (1.0F / 255.0F);
- g *= (1.0F / 255.0F);
- b *= (1.0F / 255.0F);
- texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
- texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
- texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
- texel[ACOMP] = 1.0F;
-}
-
-
-/**
- * Fetch texel from 1D, 2D or 3D ycbcr texture, returning RGBA.
- */
-static void
-FETCH(YCBCR_REV)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
- const GLushort *src1 = src0 + 1; /* odd */
- const GLubyte y0 = *src0 & 0xff; /* luminance */
- const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
- const GLubyte y1 = *src1 & 0xff; /* luminance */
- const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */
- const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
- GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
- GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
- GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
- r *= (1.0F / 255.0F);
- g *= (1.0F / 255.0F);
- b *= (1.0F / 255.0F);
- texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
- texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
- texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(S8_UINT_Z24_UNORM)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- /* only return Z, not stencil data */
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
- texel[0] = (GLfloat) (((*src) >> 8) * scale);
- ASSERT(texImage->Base.TexFormat == MESA_FORMAT_S8_UINT_Z24_UNORM ||
- texImage->Base.TexFormat == MESA_FORMAT_X8_UINT_Z24_UNORM);
- ASSERT(texel[0] >= 0.0F);
- ASSERT(texel[0] <= 1.0F);
-}
-
-
-static void
-FETCH(Z24_UNORM_S8_UINT)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- /* only return Z, not stencil data */
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
- texel[0] = (GLfloat) (((*src) & 0x00ffffff) * scale);
- ASSERT(texImage->Base.TexFormat == MESA_FORMAT_Z24_UNORM_S8_UINT ||
- texImage->Base.TexFormat == MESA_FORMAT_Z24_UNORM_X8_UINT);
- ASSERT(texel[0] >= 0.0F);
- ASSERT(texel[0] <= 1.0F);
-}
-
-
-static void
-FETCH(R9G9B9E5_FLOAT)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- rgb9e5_to_float3(*src, texel);
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(R11G11B10_FLOAT)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- r11g11b10f_to_float3(*src, texel);
- texel[ACOMP] = 1.0F;
-}
-
-
-static void
-FETCH(Z32_FLOAT_S8X24_UINT)(const struct swrast_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel)
-{
- const GLfloat *src = TEXEL_ADDR(GLfloat, texImage, i, j, k, 2);
- texel[RCOMP] = src[0];
- texel[GCOMP] = 0.0F;
- texel[BCOMP] = 0.0F;
- texel[ACOMP] = 1.0F;
-}
-
-
+#define FETCH_Z(x, type, size) \
+ static void \
+ FETCH(x) (const struct swrast_texture_image *texImage, \
+ GLint i, GLint j, GLint k, GLfloat *texel) \
+ { \
+ const type *src = TEXEL_ADDR(type, texImage, i, j, k, size); \
+ _mesa_unpack_float_z_row(MESA_FORMAT_##x, 1, src, texel); \
+ }
+
+#define FETCH_RGBA(x, type, size) \
+ static void \
+ FETCH(x) (const struct swrast_texture_image *texImage, \
+ GLint i, GLint j, GLint k, GLfloat *texel) \
+ { \
+ const type *src = TEXEL_ADDR(type, texImage, i, j, k, size); \
+ _mesa_unpack_rgba_row(MESA_FORMAT_##x, 1, src, (GLvoid *)texel); \
+ }
+
+FETCH_Z(Z_UNORM32, GLuint, 1)
+FETCH_Z(Z_UNORM16, GLushort, 1)
+FETCH_Z(S8_UINT_Z24_UNORM, GLuint, 1) /* only return Z, not stencil data */
+FETCH_Z(Z24_UNORM_S8_UINT, GLuint, 1) /* only return Z, not stencil data */
+FETCH_Z(Z32_FLOAT_S8X24_UINT, GLfloat, 2)
+
+FETCH_RGBA(RGBA_FLOAT32, GLfloat, 4)
+FETCH_RGBA(RGBA_FLOAT16, GLhalfARB, 4)
+FETCH_RGBA(RGB_FLOAT32, GLfloat, 3)
+FETCH_RGBA(RGB_FLOAT16, GLhalfARB, 3)
+FETCH_RGBA(A_FLOAT32, GLfloat, 1)
+FETCH_RGBA(A_FLOAT16, GLhalfARB, 1)
+FETCH_RGBA(L_FLOAT32, GLfloat, 1)
+FETCH_RGBA(L_FLOAT16, GLhalfARB, 1)
+FETCH_RGBA(LA_FLOAT32, GLfloat, 2)
+FETCH_RGBA(LA_FLOAT16, GLhalfARB, 2)
+FETCH_RGBA(I_FLOAT32, GLfloat, 1)
+FETCH_RGBA(I_FLOAT16, GLhalfARB, 1)
+FETCH_RGBA(R_FLOAT32, GLfloat, 1)
+FETCH_RGBA(R_FLOAT16, GLhalfARB, 1)
+FETCH_RGBA(RG_FLOAT32, GLfloat, 2)
+FETCH_RGBA(RG_FLOAT16, GLhalfARB, 2)
+FETCH_RGBA(A8B8G8R8_UNORM, GLuint, 1)
+FETCH_RGBA(R8G8B8A8_UNORM, GLuint, 1)
+FETCH_RGBA(B8G8R8A8_UNORM, GLuint, 1)
+FETCH_RGBA(A8R8G8B8_UNORM, GLuint, 1)
+FETCH_RGBA(X8B8G8R8_UNORM, GLuint, 1)
+FETCH_RGBA(R8G8B8X8_UNORM, GLuint, 1)
+FETCH_RGBA(B8G8R8X8_UNORM, GLuint, 1)
+FETCH_RGBA(X8R8G8B8_UNORM, GLuint, 1)
+FETCH_RGBA(BGR_UNORM8, GLubyte, 3)
+FETCH_RGBA(RGB_UNORM8, GLubyte, 3)
+FETCH_RGBA(B5G6R5_UNORM, GLushort, 1)
+FETCH_RGBA(R5G6B5_UNORM, GLushort, 1)
+FETCH_RGBA(B4G4R4A4_UNORM, GLushort, 1)
+FETCH_RGBA(A4R4G4B4_UNORM, GLushort, 1)
+FETCH_RGBA(A1B5G5R5_UNORM, GLushort, 1)
+FETCH_RGBA(B5G5R5A1_UNORM, GLushort, 1)
+FETCH_RGBA(A1R5G5B5_UNORM, GLushort, 1)
+FETCH_RGBA(B10G10R10A2_UNORM, GLuint, 1)
+FETCH_RGBA(R10G10B10A2_UNORM, GLuint, 1)
+FETCH_RGBA(R8G8_UNORM, GLushort, 1)
+FETCH_RGBA(G8R8_UNORM, GLushort, 1)
+FETCH_RGBA(L4A4_UNORM, GLubyte, 1)
+FETCH_RGBA(L8A8_UNORM, GLushort, 1)
+FETCH_RGBA(R_UNORM8, GLubyte, 1)
+FETCH_RGBA(R_UNORM16, GLushort, 1)
+FETCH_RGBA(A8L8_UNORM, GLushort, 1)
+FETCH_RGBA(R16G16_UNORM, GLuint, 1)
+FETCH_RGBA(G16R16_UNORM, GLuint, 1)
+FETCH_RGBA(L16A16_UNORM, GLuint, 1)
+FETCH_RGBA(A16L16_UNORM, GLuint, 1)
+FETCH_RGBA(B2G3R3_UNORM, GLubyte, 1)
+FETCH_RGBA(A_UNORM8, GLubyte, 1)
+FETCH_RGBA(A_UNORM16, GLushort, 1)
+FETCH_RGBA(L_UNORM8, GLubyte, 1)
+FETCH_RGBA(L_UNORM16, GLushort, 1)
+FETCH_RGBA(I_UNORM8, GLubyte, 1)
+FETCH_RGBA(I_UNORM16, GLushort, 1)
+FETCH_RGBA(BGR_SRGB8, GLubyte, 3)
+FETCH_RGBA(A8B8G8R8_SRGB, GLuint, 1)
+FETCH_RGBA(B8G8R8A8_SRGB, GLuint, 1)
+FETCH_RGBA(A8R8G8B8_SRGB, GLuint, 1)
+FETCH_RGBA(R8G8B8A8_SRGB, GLuint, 1)
+FETCH_RGBA(R8G8B8X8_SRGB, GLuint, 1)
+FETCH_RGBA(X8B8G8R8_SRGB, GLuint, 1)
+FETCH_RGBA(L_SRGB8, GLubyte, 1)
+FETCH_RGBA(L8A8_SRGB, GLushort, 1)
+FETCH_RGBA(A8L8_SRGB, GLushort, 2)
+FETCH_RGBA(RGBA_SINT8, GLbyte, 4)
+FETCH_RGBA(RGBA_SINT16, GLshort, 4)
+FETCH_RGBA(RGBA_SINT32, GLint, 4)
+FETCH_RGBA(RGBA_UINT8, GLubyte, 4)
+FETCH_RGBA(RGBA_UINT16, GLushort, 4)
+FETCH_RGBA(RGBA_UINT32, GLuint, 4)
+FETCH_RGBA(R_SNORM8, GLbyte, 1)
+FETCH_RGBA(A_SNORM8, GLbyte, 1)
+FETCH_RGBA(L_SNORM8, GLbyte, 1)
+FETCH_RGBA(I_SNORM8, GLbyte, 1)
+FETCH_RGBA(R8G8_SNORM, GLshort, 1)
+FETCH_RGBA(L8A8_SNORM, GLshort, 1)
+FETCH_RGBA(A8L8_SNORM, GLshort, 1)
+FETCH_RGBA(X8B8G8R8_SNORM, GLint, 1)
+FETCH_RGBA(A8B8G8R8_SNORM, GLint, 1)
+FETCH_RGBA(R8G8B8A8_SNORM, GLint, 1)
+FETCH_RGBA(R_SNORM16, GLshort, 1)
+FETCH_RGBA(A_SNORM16, GLshort, 1)
+FETCH_RGBA(L_SNORM16, GLshort, 1)
+FETCH_RGBA(I_SNORM16, GLshort, 1)
+FETCH_RGBA(R16G16_SNORM, GLshort, 2)
+FETCH_RGBA(LA_SNORM16, GLshort, 2)
+FETCH_RGBA(RGB_SNORM16, GLshort, 3)
+FETCH_RGBA(RGBA_SNORM16, GLshort, 4)
+FETCH_RGBA(RGBA_UNORM16, GLushort, 4)
+FETCH_RGBA(RGBX_UNORM16, GLushort, 4)
+FETCH_RGBA(RGBX_FLOAT16, GLhalfARB, 4)
+FETCH_RGBA(RGBX_FLOAT32, GLfloat, 4)
+FETCH_RGBA(YCBCR, GLushort, 1) /* Fetch texel from 1D, 2D or 3D ycbcr texture, returning RGBA. */
+FETCH_RGBA(YCBCR_REV, GLushort, 1) /* Fetch texel from 1D, 2D or 3D ycbcr texture, returning RGBA. */
+FETCH_RGBA(R9G9B9E5_FLOAT, GLuint, 1)
+FETCH_RGBA(R11G11B10_FLOAT, GLuint, 1)
#undef TEXEL_ADDR
#undef DIM
#undef FETCH
+#undef FETCH_Z
+#undef FETCH_RGBA
diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c
index 65cf52e21..fa79fdc5b 100644
--- a/mesalib/src/mesa/swrast/s_texfilter.c
+++ b/mesalib/src/mesa/swrast/s_texfilter.c
@@ -27,8 +27,9 @@
#include "main/context.h"
#include "main/colormac.h"
#include "main/imports.h"
-#include "main/texobj.h"
#include "main/samplerobj.h"
+#include "main/teximage.h"
+#include "main/texobj.h"
#include "s_context.h"
#include "s_texfilter.h"
@@ -73,7 +74,7 @@ lerp_2d(GLfloat a, GLfloat b,
* Do 3D/trilinear interpolation of float values.
* \sa lerp_2d
*/
-static inline GLfloat
+static GLfloat
lerp_3d(GLfloat a, GLfloat b, GLfloat c,
GLfloat v000, GLfloat v100, GLfloat v010, GLfloat v110,
GLfloat v001, GLfloat v101, GLfloat v011, GLfloat v111)
@@ -91,7 +92,7 @@ lerp_3d(GLfloat a, GLfloat b, GLfloat c,
/**
* Do linear interpolation of colors.
*/
-static inline void
+static void
lerp_rgba(GLfloat result[4], GLfloat t, const GLfloat a[4], const GLfloat b[4])
{
result[0] = LERP(t, a[0], b[0]);
@@ -104,7 +105,7 @@ lerp_rgba(GLfloat result[4], GLfloat t, const GLfloat a[4], const GLfloat b[4])
/**
* Do bilinear interpolation of colors.
*/
-static inline void
+static void
lerp_rgba_2d(GLfloat result[4], GLfloat a, GLfloat b,
const GLfloat t00[4], const GLfloat t10[4],
const GLfloat t01[4], const GLfloat t11[4])
@@ -119,7 +120,7 @@ lerp_rgba_2d(GLfloat result[4], GLfloat a, GLfloat b,
/**
* Do trilinear interpolation of colors.
*/
-static inline void
+static void
lerp_rgba_3d(GLfloat result[4], GLfloat a, GLfloat b, GLfloat c,
const GLfloat t000[4], const GLfloat t100[4],
const GLfloat t010[4], const GLfloat t110[4],
@@ -155,7 +156,7 @@ lerp_rgba_3d(GLfloat result[4], GLfloat a, GLfloat b, GLfloat c,
* i0, i1 = returns two nearest texel indexes
* weight = returns blend factor between texels
*/
-static inline void
+static void
linear_texel_locations(GLenum wrapMode,
const struct gl_texture_image *img,
GLint size, GLfloat s,
@@ -285,7 +286,7 @@ linear_texel_locations(GLenum wrapMode,
/**
* Used to compute texel location for nearest sampling.
*/
-static inline GLint
+static GLint
nearest_texel_location(GLenum wrapMode,
const struct gl_texture_image *img,
GLint size, GLfloat s)
@@ -410,7 +411,7 @@ nearest_texel_location(GLenum wrapMode,
/* Power of two image sizes only */
-static inline void
+static void
linear_repeat_texel_location(GLuint size, GLfloat s,
GLint *i0, GLint *i1, GLfloat *weight)
{
@@ -424,7 +425,7 @@ linear_repeat_texel_location(GLuint size, GLfloat s,
/**
* Do clamp/wrap for a texture rectangle coord, GL_NEAREST filter mode.
*/
-static inline GLint
+static GLint
clamp_rect_coord_nearest(GLenum wrapMode, GLfloat coord, GLint max)
{
switch (wrapMode) {
@@ -444,7 +445,7 @@ clamp_rect_coord_nearest(GLenum wrapMode, GLfloat coord, GLint max)
/**
* As above, but GL_LINEAR filtering.
*/
-static inline void
+static void
clamp_rect_coord_linear(GLenum wrapMode, GLfloat coord, GLint max,
GLint *i0out, GLint *i1out, GLfloat *weight)
{
@@ -486,7 +487,7 @@ clamp_rect_coord_linear(GLenum wrapMode, GLfloat coord, GLint max,
/**
* Compute slice/image to use for 1D or 2D array texture.
*/
-static inline GLint
+static GLint
tex_array_slice(GLfloat coord, GLsizei size)
{
GLint slice = IFLOOR(coord + 0.5f);
@@ -499,7 +500,7 @@ tex_array_slice(GLfloat coord, GLsizei size)
* Compute nearest integer texcoords for given texobj and coordinate.
* NOTE: only used for depth texture sampling.
*/
-static inline void
+static void
nearest_texcoord(const struct gl_sampler_object *samp,
const struct gl_texture_object *texObj,
GLuint level,
@@ -548,7 +549,7 @@ nearest_texcoord(const struct gl_sampler_object *samp,
* Compute linear integer texcoords for given texobj and coordinate.
* NOTE: only used for depth texture sampling.
*/
-static inline void
+static void
linear_texcoord(const struct gl_sampler_object *samp,
const struct gl_texture_object *texObj,
GLuint level,
@@ -607,7 +608,7 @@ linear_texcoord(const struct gl_sampler_object *samp,
* For linear interpolation between mipmap levels N and N+1, this function
* computes N.
*/
-static inline GLint
+static GLint
linear_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda)
{
if (lambda < 0.0F)
@@ -622,7 +623,7 @@ linear_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda)
/**
* Compute the nearest mipmap level to take texels from.
*/
-static inline GLint
+static GLint
nearest_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda)
{
GLfloat l;
@@ -658,7 +659,7 @@ nearest_mipmap_level(const struct gl_texture_object *tObj, GLfloat lambda)
* will be minified, magnified, or split between the two. This function
* determines the subranges in [0, n-1] that are to be minified or magnified.
*/
-static inline void
+static void
compute_min_mag_ranges(const struct gl_sampler_object *samp,
GLuint n, const GLfloat lambda[],
GLuint *minStart, GLuint *minEnd,
@@ -767,7 +768,7 @@ compute_min_mag_ranges(const struct gl_sampler_object *samp,
* the base texture format. Ex: if the texture base format it GL_ALPHA,
* we return (0,0,0,BorderAlpha).
*/
-static inline void
+static void
get_border_color(const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
GLfloat rgba[4])
@@ -804,7 +805,7 @@ get_border_color(const struct gl_sampler_object *samp,
/**
* Put z into texel according to GL_DEPTH_MODE.
*/
-static inline void
+static void
apply_depth_mode(GLenum depthMode, GLfloat z, GLfloat texel[4])
{
switch (depthMode) {
@@ -832,7 +833,7 @@ apply_depth_mode(GLenum depthMode, GLfloat z, GLfloat texel[4])
static GLboolean
is_depth_texture(const struct gl_texture_object *tObj)
{
- GLenum format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat;
+ GLenum format = _mesa_texture_base_format(tObj);
return format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT;
}
@@ -844,7 +845,7 @@ is_depth_texture(const struct gl_texture_object *tObj)
/**
* Return the texture sample for coordinate (s) using GL_NEAREST filter.
*/
-static inline void
+static void
sample_1d_nearest(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
@@ -869,7 +870,7 @@ sample_1d_nearest(struct gl_context *ctx,
/**
* Return the texture sample for coordinate (s) using GL_LINEAR filter.
*/
-static inline void
+static void
sample_1d_linear(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
@@ -1004,7 +1005,7 @@ sample_nearest_1d( struct gl_context *ctx,
GLfloat rgba[][4] )
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_1d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
@@ -1021,7 +1022,7 @@ sample_linear_1d( struct gl_context *ctx,
GLfloat rgba[][4] )
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_1d_linear(ctx, samp, image, texcoords[i], rgba[i]);
@@ -1051,12 +1052,12 @@ sample_lambda_1d( struct gl_context *ctx,
switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_1d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_1d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
@@ -1086,12 +1087,12 @@ sample_lambda_1d( struct gl_context *ctx,
switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_1d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_1d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
default:
@@ -1110,7 +1111,7 @@ sample_lambda_1d( struct gl_context *ctx,
/**
* Return the texture sample for coordinate (s,t) using GL_NEAREST filter.
*/
-static inline void
+static void
sample_2d_nearest(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
@@ -1144,7 +1145,7 @@ sample_2d_nearest(struct gl_context *ctx,
* Return the texture sample for coordinate (s,t) using GL_LINEAR filter.
* New sampling code contributed by Lynn Quam <quam@ai.sri.com>.
*/
-static inline void
+static void
sample_2d_linear(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
@@ -1209,7 +1210,7 @@ sample_2d_linear(struct gl_context *ctx,
* As above, but we know WRAP_S == REPEAT and WRAP_T == REPEAT.
* We don't have to worry about the texture border.
*/
-static inline void
+static void
sample_2d_linear_repeat(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
@@ -1364,7 +1365,7 @@ sample_nearest_2d(struct gl_context *ctx,
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_2d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
@@ -1381,7 +1382,7 @@ sample_linear_2d(struct gl_context *ctx,
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg = swrast_texture_image_const(image);
(void) lambda;
if (samp->WrapS == GL_REPEAT &&
@@ -1415,7 +1416,7 @@ opt_sample_rgb_2d(struct gl_context *ctx,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
{
- const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *img = _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLfloat width = (GLfloat) img->Width;
const GLfloat height = (GLfloat) img->Height;
@@ -1460,7 +1461,7 @@ opt_sample_rgba_2d(struct gl_context *ctx,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
{
- const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *img = _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg = swrast_texture_image_const(img);
const GLfloat width = (GLfloat) img->Width;
const GLfloat height = (GLfloat) img->Height;
@@ -1498,7 +1499,7 @@ sample_lambda_2d(struct gl_context *ctx,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda[], GLfloat rgba[][4])
{
- const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *tImg = _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg);
GLuint minStart, minEnd; /* texels with minification */
GLuint magStart, magEnd; /* texels with magnification */
@@ -1653,7 +1654,7 @@ sample_2d_ewa(struct gl_context *ctx,
GLfloat scaling = 1.0f / (1 << level);
const struct gl_texture_image *img = tObj->Image[0][level];
const struct gl_texture_image *mostDetailedImage =
- tObj->Image[0][tObj->BaseLevel];
+ _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg =
swrast_texture_image_const(mostDetailedImage);
GLfloat tex_u = -0.5f + texcoord[0] * swImg->WidthScale * scaling;
@@ -1830,7 +1831,7 @@ sample_2d_footprint(struct gl_context *ctx,
* Returns the index of the specified texture object in the
* gl_context texture unit array.
*/
-static inline GLuint
+static GLuint
texture_unit_index(const struct gl_context *ctx,
const struct gl_texture_object *tObj)
{
@@ -1865,7 +1866,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
GLuint n, const GLfloat texcoords[][4],
const GLfloat lambda_iso[], GLfloat rgba[][4])
{
- const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *tImg = _mesa_base_tex_image(tObj);
const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg);
const GLfloat maxEccentricity =
samp->MaxAnisotropy * samp->MaxAnisotropy;
@@ -2012,7 +2013,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
/**
* Return the texture sample for coordinate (s,t,r) using GL_NEAREST filter.
*/
-static inline void
+static void
sample_3d_nearest(struct gl_context *ctx,
const struct gl_sampler_object *samp,
const struct gl_texture_image *img,
@@ -2232,7 +2233,7 @@ sample_nearest_3d(struct gl_context *ctx,
GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_3d_nearest(ctx, samp, image, texcoords[i], rgba[i]);
@@ -2249,7 +2250,7 @@ sample_linear_3d(struct gl_context *ctx,
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_3d_linear(ctx, samp, image, texcoords[i], rgba[i]);
@@ -2279,12 +2280,12 @@ sample_lambda_3d(struct gl_context *ctx,
switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_3d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_3d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
@@ -2314,12 +2315,12 @@ sample_lambda_3d(struct gl_context *ctx,
switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_3d_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_3d_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_3d_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
default:
@@ -3020,7 +3021,7 @@ sample_nearest_2d_array(struct gl_context *ctx,
GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_2d_array_nearest(ctx, samp, image, texcoords[i], rgba[i]);
@@ -3038,7 +3039,7 @@ sample_linear_2d_array(struct gl_context *ctx,
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_2d_array_linear(ctx, samp, image, texcoords[i], rgba[i]);
@@ -3068,12 +3069,12 @@ sample_lambda_2d_array(struct gl_context *ctx,
switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_2d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_2d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
@@ -3111,12 +3112,12 @@ sample_lambda_2d_array(struct gl_context *ctx,
switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_2d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_2d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_2d_array_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
default:
@@ -3311,7 +3312,7 @@ sample_nearest_1d_array(struct gl_context *ctx,
GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_1d_array_nearest(ctx, samp, image, texcoords[i], rgba[i]);
@@ -3328,7 +3329,7 @@ sample_linear_1d_array(struct gl_context *ctx,
const GLfloat lambda[], GLfloat rgba[][4])
{
GLuint i;
- struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ const struct gl_texture_image *image = _mesa_base_tex_image(tObj);
(void) lambda;
for (i = 0; i < n; i++) {
sample_1d_array_linear(ctx, samp, image, texcoords[i], rgba[i]);
@@ -3358,12 +3359,12 @@ sample_lambda_1d_array(struct gl_context *ctx,
switch (samp->MinFilter) {
case GL_NEAREST:
for (i = minStart; i < minEnd; i++)
- sample_1d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = minStart; i < minEnd; i++)
- sample_1d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_NEAREST_MIPMAP_NEAREST:
@@ -3397,12 +3398,12 @@ sample_lambda_1d_array(struct gl_context *ctx,
switch (samp->MagFilter) {
case GL_NEAREST:
for (i = magStart; i < magEnd; i++)
- sample_1d_array_nearest(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_nearest(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
case GL_LINEAR:
for (i = magStart; i < magEnd; i++)
- sample_1d_array_linear(ctx, samp, tObj->Image[0][tObj->BaseLevel],
+ sample_1d_array_linear(ctx, samp, _mesa_base_tex_image(tObj),
texcoords[i], rgba[i]);
break;
default:
@@ -3416,7 +3417,7 @@ sample_lambda_1d_array(struct gl_context *ctx,
/**
* Compare texcoord against depth sample. Return 1.0 or 0.0 value.
*/
-static inline GLfloat
+static GLfloat
shadow_compare(GLenum function, GLfloat coord, GLfloat depthSample)
{
switch (function) {
@@ -3448,7 +3449,7 @@ shadow_compare(GLenum function, GLfloat coord, GLfloat depthSample)
/**
* Compare texcoord against four depth samples.
*/
-static inline GLfloat
+static GLfloat
shadow_compare4(GLenum function, GLfloat coord,
GLfloat depth00, GLfloat depth01,
GLfloat depth10, GLfloat depth11,
@@ -3749,7 +3750,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
}
else {
/* check for a few optimized cases */
- const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
+ const struct gl_texture_image *img = _mesa_base_tex_image(t);
const struct swrast_texture_image *swImg =
swrast_texture_image_const(img);
texture_sample_func func;
diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c
index 164906643..1d8e31c2e 100644
--- a/mesalib/src/mesa/swrast/s_triangle.c
+++ b/mesalib/src/mesa/swrast/s_triangle.c
@@ -37,6 +37,7 @@
#include "main/mtypes.h"
#include "main/state.h"
#include "main/samplerobj.h"
+#include "main/teximage.h"
#include "program/prog_instruction.h"
#include "s_aatriangle.h"
@@ -127,7 +128,7 @@ _swrast_culltriangle( struct gl_context *ctx,
const struct gl_texture_object *obj = \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
- obj->Image[0][obj->BaseLevel]; \
+ _mesa_base_tex_image(obj); \
const struct swrast_texture_image *swImg = \
swrast_texture_image_const(texImg); \
const GLfloat twidth = (GLfloat) texImg->Width; \
@@ -185,7 +186,7 @@ _swrast_culltriangle( struct gl_context *ctx,
const struct gl_texture_object *obj = \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
- obj->Image[0][obj->BaseLevel]; \
+ _mesa_base_tex_image(obj); \
const struct swrast_texture_image *swImg = \
swrast_texture_image_const(texImg); \
const GLfloat twidth = (GLfloat) texImg->Width; \
@@ -542,7 +543,7 @@ affine_span(struct gl_context *ctx, SWspan *span,
const struct gl_texture_object *obj = \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
- obj->Image[0][obj->BaseLevel]; \
+ _mesa_base_tex_image(obj); \
const struct swrast_texture_image *swImg = \
swrast_texture_image_const(texImg); \
const GLfloat twidth = (GLfloat) texImg->Width; \
@@ -811,7 +812,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span,
const struct gl_texture_object *obj = \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
- obj->Image[0][obj->BaseLevel]; \
+ _mesa_base_tex_image(obj); \
const struct swrast_texture_image *swImg = \
swrast_texture_image_const(texImg); \
info.texture = (const GLchan *) swImg->ImageSlices[0]; \
@@ -1059,7 +1060,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
else
samp = NULL;
- texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL;
+ texImg = texObj2D ? _mesa_base_tex_image(texObj2D) : NULL;
swImg = swrast_texture_image_const(texImg);
format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE;
diff --git a/mesalib/src/mesa/swrast/swrast.h b/mesalib/src/mesa/swrast/swrast.h
index ac3dbe304..a89dc6cda 100644
--- a/mesalib/src/mesa/swrast/swrast.h
+++ b/mesalib/src/mesa/swrast/swrast.h
@@ -132,16 +132,18 @@ _swrast_Bitmap( struct gl_context *ctx,
const GLubyte *bitmap );
extern void
-_swrast_CopyPixels( struct gl_context *ctx,
- GLint srcx, GLint srcy,
- GLint destx, GLint desty,
- GLsizei width, GLsizei height,
- GLenum type );
+_swrast_CopyPixels(struct gl_context *ctx,
+ GLint srcx, GLint srcy,
+ GLint destx, GLint desty,
+ GLsizei width, GLsizei height,
+ GLenum type);
extern GLboolean
swrast_fast_copy_pixels(struct gl_context *ctx,
- GLint srcX, GLint srcY, GLsizei width, GLsizei height,
- GLint dstX, GLint dstY, GLenum type);
+ struct gl_framebuffer *srcFb,
+ struct gl_framebuffer *dstFb,
+ GLint srcX, GLint srcY, GLsizei width, GLsizei height,
+ GLint dstX, GLint dstY, GLenum type);
extern void
_swrast_DrawPixels( struct gl_context *ctx,
@@ -153,6 +155,8 @@ _swrast_DrawPixels( struct gl_context *ctx,
extern void
_swrast_BlitFramebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);