diff options
Diffstat (limited to 'src/mesa/drivers/windows/gldirect/dx7/gld_texture_dx7.c')
-rw-r--r-- | src/mesa/drivers/windows/gldirect/dx7/gld_texture_dx7.c | 182 |
1 files changed, 162 insertions, 20 deletions
diff --git a/src/mesa/drivers/windows/gldirect/dx7/gld_texture_dx7.c b/src/mesa/drivers/windows/gldirect/dx7/gld_texture_dx7.c index 6e9de16b8f..bbe673516d 100644 --- a/src/mesa/drivers/windows/gldirect/dx7/gld_texture_dx7.c +++ b/src/mesa/drivers/windows/gldirect/dx7/gld_texture_dx7.c @@ -69,10 +69,10 @@ D3DX_SURFACEFORMAT _gldD3DXFormatFromSurface(IDirectDrawSurface7 *pSurface); static void gld_fetch_1d_texel_X8R8G8B8( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); - GLchan *rgba = (GLchan *) texel; + GLchan *rgba = (GLchan *)texel; rgba[RCOMP] = src[2]; rgba[GCOMP] = src[1]; rgba[BCOMP] = src[0]; @@ -81,9 +81,22 @@ static void gld_fetch_1d_texel_X8R8G8B8( //--------------------------------------------------------------------------- +static void gld_fetch_1d_texel_f_X8R8G8B8( + const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); + texel[RCOMP] = CHAN_TO_FLOAT(src[0]); + texel[GCOMP] = CHAN_TO_FLOAT(src[1]); + texel[BCOMP] = CHAN_TO_FLOAT(src[2]); + texel[ACOMP] = 1.f; +} + +//--------------------------------------------------------------------------- + static void gld_fetch_1d_texel_X1R5G5B5( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); GLchan *rgba = (GLchan *) texel; GLushort s = *src; @@ -95,9 +108,23 @@ static void gld_fetch_1d_texel_X1R5G5B5( //--------------------------------------------------------------------------- +static void gld_fetch_1d_texel_f_X1R5G5B5( + const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + GLushort s = *src; + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 10) & 0xf8) * 255 / 0xf8 ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 5) & 0xf8) * 255 / 0xf8 ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s ) & 0xf8) * 255 / 0xf8 ); + texel[ACOMP] = 1.f; +} + +//--------------------------------------------------------------------------- + static void gld_fetch_1d_texel_X4R4G4B4( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); GLchan *rgba = (GLchan *) texel; GLushort s = *src; @@ -109,6 +136,20 @@ static void gld_fetch_1d_texel_X4R4G4B4( //--------------------------------------------------------------------------- +static void gld_fetch_1d_texel_f_X4R4G4B4( + const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + GLushort s = *src; + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf) * 255 / 0xf ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 4) & 0xf) * 255 / 0xf ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s ) & 0xf) * 255 / 0xf ); + texel[ACOMP] = 1.f; +} + +//--------------------------------------------------------------------------- + #undef CHAN_SRC #undef UBYTE_SRC #undef USHORT_SRC @@ -131,10 +172,10 @@ static void gld_fetch_1d_texel_X4R4G4B4( static void gld_fetch_2d_texel_X8R8G8B8( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); - GLchan *rgba = (GLchan *) texel; + GLchan *rgba = (GLchan *)texel; rgba[RCOMP] = src[2]; rgba[GCOMP] = src[1]; rgba[BCOMP] = src[0]; @@ -143,9 +184,22 @@ static void gld_fetch_2d_texel_X8R8G8B8( //--------------------------------------------------------------------------- +static void gld_fetch_2d_texel_f_X8R8G8B8( + const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); + texel[RCOMP] = CHAN_TO_FLOAT(src[0]); + texel[GCOMP] = CHAN_TO_FLOAT(src[1]); + texel[BCOMP] = CHAN_TO_FLOAT(src[2]); + texel[ACOMP] = 1.f; +} + +//--------------------------------------------------------------------------- + static void gld_fetch_2d_texel_X1R5G5B5( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); GLchan *rgba = (GLchan *) texel; GLushort s = *src; @@ -157,9 +211,23 @@ static void gld_fetch_2d_texel_X1R5G5B5( //--------------------------------------------------------------------------- +static void gld_fetch_2d_texel_f_X1R5G5B5( + const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + GLushort s = *src; + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 10) & 0xf8) * 255 / 0xf8 ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 5) & 0xf8) * 255 / 0xf8 ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s ) & 0xf8) * 255 / 0xf8 ); + texel[ACOMP] = 1.f; +} + +//--------------------------------------------------------------------------- + static void gld_fetch_2d_texel_X4R4G4B4( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); GLchan *rgba = (GLchan *) texel; GLushort s = *src; @@ -171,6 +239,20 @@ static void gld_fetch_2d_texel_X4R4G4B4( //--------------------------------------------------------------------------- +static void gld_fetch_2d_texel_f_X4R4G4B4( + const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + GLushort s = *src; + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf) * 255 / 0xf ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 4) & 0xf) * 255 / 0xf ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s ) & 0xf) * 255 / 0xf ); + texel[ACOMP] = 1.f; +} + +//--------------------------------------------------------------------------- + #undef CHAN_SRC #undef UBYTE_SRC #undef USHORT_SRC @@ -197,10 +279,10 @@ static void gld_fetch_2d_texel_X4R4G4B4( static void gld_fetch_3d_texel_X8R8G8B8( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); - GLchan *rgba = (GLchan *) texel; + GLchan *rgba = (GLchan *)texel; rgba[RCOMP] = src[2]; rgba[GCOMP] = src[1]; rgba[BCOMP] = src[0]; @@ -209,9 +291,22 @@ static void gld_fetch_3d_texel_X8R8G8B8( //--------------------------------------------------------------------------- +static void gld_fetch_3d_texel_f_X8R8G8B8( + const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); + texel[RCOMP] = CHAN_TO_FLOAT(src[0]); + texel[GCOMP] = CHAN_TO_FLOAT(src[1]); + texel[BCOMP] = CHAN_TO_FLOAT(src[2]); + texel[ACOMP] = 1.f; +} + +//--------------------------------------------------------------------------- + static void gld_fetch_3d_texel_X1R5G5B5( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); GLchan *rgba = (GLchan *) texel; GLushort s = *src; @@ -223,9 +318,23 @@ static void gld_fetch_3d_texel_X1R5G5B5( //--------------------------------------------------------------------------- +static void gld_fetch_3d_texel_f_X1R5G5B5( + const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + GLushort s = *src; + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 10) & 0xf8) * 255 / 0xf8 ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 5) & 0xf8) * 255 / 0xf8 ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s ) & 0xf8) * 255 / 0xf8 ); + texel[ACOMP] = 1.f; +} + +//--------------------------------------------------------------------------- + static void gld_fetch_3d_texel_X4R4G4B4( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLvoid *texel ) + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); GLchan *rgba = (GLchan *) texel; GLushort s = *src; @@ -237,6 +346,20 @@ static void gld_fetch_3d_texel_X4R4G4B4( //--------------------------------------------------------------------------- +static void gld_fetch_3d_texel_f_X4R4G4B4( + const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) +{ + const GLushort *src = USHORT_SRC( texImage, i, j, k ); + GLushort s = *src; + texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf) * 255 / 0xf ); + texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 4) & 0xf) * 255 / 0xf ); + texel[BCOMP] = UBYTE_TO_FLOAT( ((s ) & 0xf) * 255 / 0xf ); + texel[ACOMP] = 1.f; +} + +//--------------------------------------------------------------------------- + #undef CHAN_SRC #undef UBYTE_SRC #undef USHORT_SRC @@ -249,6 +372,7 @@ static void gld_fetch_3d_texel_X4R4G4B4( const struct gl_texture_format _gld_texformat_X8R8G8B8 = { MESA_FORMAT_ARGB8888, /* MesaFormat */ GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 8, /* RedBits */ 8, /* GreenBits */ 8, /* BlueBits */ @@ -258,14 +382,19 @@ const struct gl_texture_format _gld_texformat_X8R8G8B8 = { 0, /* IndexBits */ 0, /* DepthBits */ 4, /* TexelBytes */ + _mesa_texstore_argb8888, /* StoreTexImageFunc */ gld_fetch_1d_texel_X8R8G8B8, /* FetchTexel1D */ gld_fetch_2d_texel_X8R8G8B8, /* FetchTexel2D */ gld_fetch_3d_texel_X8R8G8B8, /* FetchTexel3D */ + gld_fetch_1d_texel_f_X8R8G8B8, /* FetchTexel1Df */ + gld_fetch_2d_texel_f_X8R8G8B8, /* FetchTexel2Df */ + gld_fetch_3d_texel_f_X8R8G8B8, /* FetchTexel3Df */ }; const struct gl_texture_format _gld_texformat_X1R5G5B5 = { MESA_FORMAT_ARGB1555, /* MesaFormat */ GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 5, /* RedBits */ 5, /* GreenBits */ 5, /* BlueBits */ @@ -275,14 +404,19 @@ const struct gl_texture_format _gld_texformat_X1R5G5B5 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ + _mesa_texstore_argb1555, /* StoreTexImageFunc */ gld_fetch_1d_texel_X1R5G5B5, /* FetchTexel1D */ gld_fetch_2d_texel_X1R5G5B5, /* FetchTexel2D */ gld_fetch_3d_texel_X1R5G5B5, /* FetchTexel3D */ + gld_fetch_1d_texel_f_X1R5G5B5, /* FetchTexel1Df */ + gld_fetch_2d_texel_f_X1R5G5B5, /* FetchTexel2Df */ + gld_fetch_3d_texel_f_X1R5G5B5, /* FetchTexel3Df */ }; const struct gl_texture_format _gld_texformat_X4R4G4B4 = { MESA_FORMAT_ARGB4444, /* MesaFormat */ GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 4, /* RedBits */ 4, /* GreenBits */ 4, /* BlueBits */ @@ -292,9 +426,13 @@ const struct gl_texture_format _gld_texformat_X4R4G4B4 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ + _mesa_texstore_argb4444, /* StoreTexImageFunc */ gld_fetch_1d_texel_X4R4G4B4, /* FetchTexel1D */ gld_fetch_2d_texel_X4R4G4B4, /* FetchTexel2D */ gld_fetch_3d_texel_X4R4G4B4, /* FetchTexel3D */ + gld_fetch_1d_texel_f_X4R4G4B4, /* FetchTexel1Df */ + gld_fetch_2d_texel_f_X4R4G4B4, /* FetchTexel2Df */ + gld_fetch_3d_texel_f_X4R4G4B4, /* FetchTexel3Df */ }; //--------------------------------------------------------------------------- @@ -887,6 +1025,10 @@ void gld_DrawPixels_DX7( D3DX_SURFACEFORMAT sf; DWORD dwMipmaps; + const struct gl_texture_format *MesaFormat; + + MesaFormat = _mesa_choose_tex_format(ctx, format, format, type); + gldCtx = GLD_GET_CONTEXT(ctx); gld = GLD_GET_DX7_DRIVER(gldCtx); @@ -923,7 +1065,7 @@ void gld_DrawPixels_DX7( } // unpack image, apply transfer ops and store directly in texture - _mesa_transfer_teximage( + MesaFormat->StoreImage( ctx, 2, GL_RGBA, @@ -1070,9 +1212,9 @@ void gld_ReadPixels_DX7( // We need to flip the data. Yuck. // Perhaps Mesa has a span packer we can use in future... for (i=0; i<height; i++) { - BYTE *pDestRow = (BYTE*)_mesa_image_address2d(pack, dest, width, height, format, type, 0, i, 0); + BYTE *pDestRow = (BYTE*)_mesa_image_address(2,pack, dest, width, height, format, type, 0, i, 0); BYTE *pSrcRow = (BYTE*)d3dLockedRect.pBits + (d3dLockedRect.Pitch * (height-i-1)); - _mesa_transfer_teximage( + texImage->TexFormat->StoreImage( ctx, 2, GL_RGBA, // base format @@ -1295,7 +1437,7 @@ void gld_Bitmap_DX7( for (i=0; i<height; i++) { GLubyte byte; pBits = (D3DCOLOR*)((BYTE*)ddsd.lpSurface + (i*ddsd.lPitch)); - src = (const GLubyte *) _mesa_image_address2d( + src = (const GLubyte *) _mesa_image_address(2, &ctx->DefaultPacking, pTempBitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, i, 0); for (j=0; j<(width>>3); j++) { @@ -1527,7 +1669,7 @@ void gld_TexImage2D_DX7( return; } // unpack image, apply transfer ops and store in tempImage - _mesa_transfer_teximage(ctx, 2, texImage->Format, + texImage->TexFormat->StoreImage(ctx, 2, texImage->Format, &_mesa_texformat_argb8888, // dest format tempImage, width, height, 1, 0, 0, 0, @@ -1633,7 +1775,7 @@ void gld_TexImage2D_DX7( } // unpack image, apply transfer ops and store directly in texture - _mesa_transfer_teximage( + texImage->TexFormat->StoreImage( ctx, 2, texImage->Format, @@ -1705,7 +1847,7 @@ void gld_TexSubImage2D( GLcontext *ctx, GLenum target, GLint level, } // unpack image, apply transfer ops and store in tempImage - _mesa_transfer_teximage(ctx, 2, texImage->Format, + texImage->TexFormat->StoreImage(ctx, 2, texImage->Format, &_mesa_texformat_argb8888, // dest format tempImage, width, height, 1, 0, 0, 0, @@ -1802,7 +1944,7 @@ void gld_TexSubImage2D_DX7( GLcontext *ctx, GLenum target, GLint level, } // unpack image, apply transfer ops and store directly in texture - _mesa_transfer_teximage(ctx, 2, texImage->Format, + texImage->TexFormat->StoreImage(ctx, 2, texImage->Format, _gldMesaFormatForD3DFormat(_gldD3DXFormatFromSurface(pSurface)), ddsd.lpSurface, width, height, 1, |