mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 07:18:17 +02:00
initial copytexsubimage code, untested
This commit is contained in:
parent
fdb3acf016
commit
79de983b6f
11 changed files with 416 additions and 36 deletions
|
|
@ -11,6 +11,7 @@ DRIVER_SOURCES = \
|
|||
i915_tex_layout.c \
|
||||
intel_tex_image.c \
|
||||
intel_tex_subimage.c \
|
||||
intel_tex_copy.c \
|
||||
intel_tex_validate.c \
|
||||
intel_tex_format.c \
|
||||
intel_tex.c \
|
||||
|
|
|
|||
|
|
@ -150,6 +150,11 @@ GLboolean i915_miptree_layout( struct intel_mipmap_tree *mt )
|
|||
break;
|
||||
}
|
||||
}
|
||||
_mesa_printf("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
|
||||
mt->pitch,
|
||||
mt->total_height,
|
||||
mt->cpp,
|
||||
mt->pitch * mt->total_height * mt->cpp );
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
|
@ -324,6 +329,12 @@ GLboolean i945_miptree_layout( struct intel_mipmap_tree *mt )
|
|||
break;
|
||||
}
|
||||
}
|
||||
_mesa_printf("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
|
||||
mt->pitch,
|
||||
mt->total_height,
|
||||
mt->cpp,
|
||||
mt->pitch * mt->total_height * mt->cpp );
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -259,13 +259,14 @@ static GLboolean i915_update_tex_unit( GLcontext *ctx,
|
|||
memcpy(i915->state.Tex[unit], state, sizeof(state));
|
||||
}
|
||||
|
||||
_mesa_printf("state[I915_TEXREG_SS2] = 0x%x\n", state[I915_TEXREG_SS2]);
|
||||
_mesa_printf("state[I915_TEXREG_SS3] = 0x%x\n", state[I915_TEXREG_SS3]);
|
||||
_mesa_printf("state[I915_TEXREG_SS4] = 0x%x\n", state[I915_TEXREG_SS4]);
|
||||
|
||||
_mesa_printf("state[I915_TEXREG_MS2] = 0x%x\n", state[I915_TEXREG_MS2]);
|
||||
_mesa_printf("state[I915_TEXREG_MS3] = 0x%x\n", state[I915_TEXREG_MS3]);
|
||||
_mesa_printf("state[I915_TEXREG_MS4] = 0x%x\n", state[I915_TEXREG_MS4]);
|
||||
if (INTEL_DEBUG & DEBUG_TEXTURE) {
|
||||
_mesa_printf("state[I915_TEXREG_SS2] = 0x%x\n", state[I915_TEXREG_SS2]);
|
||||
_mesa_printf("state[I915_TEXREG_SS3] = 0x%x\n", state[I915_TEXREG_SS3]);
|
||||
_mesa_printf("state[I915_TEXREG_SS4] = 0x%x\n", state[I915_TEXREG_SS4]);
|
||||
_mesa_printf("state[I915_TEXREG_MS2] = 0x%x\n", state[I915_TEXREG_MS2]);
|
||||
_mesa_printf("state[I915_TEXREG_MS3] = 0x%x\n", state[I915_TEXREG_MS3]);
|
||||
_mesa_printf("state[I915_TEXREG_MS4] = 0x%x\n", state[I915_TEXREG_MS4]);
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ const struct dri_extension card_extensions[] =
|
|||
{ "GL_NV_blend_square", NULL },
|
||||
{ "GL_NV_vertex_program", GL_NV_vertex_program_functions },
|
||||
{ "GL_NV_vertex_program1_1", NULL },
|
||||
{ "GL_SGIS_generate_mipmap", NULL },
|
||||
/* { "GL_SGIS_generate_mipmap", NULL }, */
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
@ -368,7 +368,12 @@ GLboolean intelInitContext( intelContextPtr intel,
|
|||
|
||||
_math_matrix_ctr (&intel->ViewportMatrix);
|
||||
|
||||
driInitExtensions( ctx, card_extensions, GL_TRUE );
|
||||
/* Disable imaging extension until convolution is working in
|
||||
* teximage paths:
|
||||
*/
|
||||
driInitExtensions( ctx, card_extensions,
|
||||
/* GL_TRUE, */
|
||||
GL_FALSE);
|
||||
|
||||
if (intel->ctx.Mesa_DXTn) {
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
|
||||
|
|
|
|||
|
|
@ -533,8 +533,21 @@ extern void intel_dump_batchbuffer( long offset,
|
|||
*/
|
||||
extern void intelInitPixelFuncs( struct dd_function_table *functions );
|
||||
|
||||
GLboolean intel_check_color_per_fragment_ops( const GLcontext *ctx );
|
||||
|
||||
/* Inline conversion functions. These are better-typed than the macros used previously:
|
||||
GLboolean intel_clip_to_framebuffer( GLcontext *ctx,
|
||||
const GLframebuffer *buffer,
|
||||
GLint *x, GLint *y,
|
||||
GLsizei *width, GLsizei *height );
|
||||
|
||||
struct intel_region *intel_readbuf_region( struct intel_context *intel );
|
||||
struct intel_region *intel_drawbuf_region( struct intel_context *intel );
|
||||
|
||||
|
||||
|
||||
/*======================================================================
|
||||
* Inline conversion functions.
|
||||
* These are better-typed than the macros used previously:
|
||||
*/
|
||||
static inline struct intel_context *intel_context( GLcontext *ctx )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -72,8 +72,7 @@ check_color( GLcontext *ctx, GLenum type, GLenum format,
|
|||
return GL_FALSE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
check_color_per_fragment_ops( const GLcontext *ctx )
|
||||
GLboolean intel_check_color_per_fragment_ops( const GLcontext *ctx )
|
||||
{
|
||||
return !(ctx->Color.AlphaEnabled ||
|
||||
ctx->Depth.Test ||
|
||||
|
|
@ -90,11 +89,10 @@ check_color_per_fragment_ops( const GLcontext *ctx )
|
|||
|
||||
|
||||
|
||||
static GLboolean
|
||||
clip_pixelrect( GLcontext *ctx,
|
||||
const GLframebuffer *buffer,
|
||||
GLint *x, GLint *y,
|
||||
GLsizei *width, GLsizei *height )
|
||||
GLboolean intel_clip_to_framebuffer( GLcontext *ctx,
|
||||
const GLframebuffer *buffer,
|
||||
GLint *x, GLint *y,
|
||||
GLsizei *width, GLsizei *height )
|
||||
{
|
||||
/* left clipping */
|
||||
if (*x < buffer->_Xmin) {
|
||||
|
|
@ -122,9 +120,6 @@ clip_pixelrect( GLcontext *ctx,
|
|||
if (*height <= 0)
|
||||
return GL_FALSE;
|
||||
|
||||
/* *size = ((*y + *height - 1) * intel->intelScreen->front.pitch + */
|
||||
/* (*x + *width - 1) * intel->intelScreen->cpp); */
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +184,7 @@ intelTryReadPixels( GLcontext *ctx,
|
|||
drm_clip_rect_t *box = dPriv->pClipRects;
|
||||
int i;
|
||||
|
||||
if (!clip_pixelrect(ctx, ctx->ReadBuffer, &x, &y, &width, &height)) {
|
||||
if (!intel_clip_to_framebuffer(ctx, ctx->ReadBuffer, &x, &y, &width, &height)) {
|
||||
UNLOCK_HARDWARE( intel );
|
||||
if (INTEL_DEBUG & DEBUG_PIXEL)
|
||||
fprintf(stderr, "%s totally clipped -- nothing to do\n",
|
||||
|
|
@ -278,7 +273,7 @@ static void do_draw_pix( GLcontext *ctx,
|
|||
{
|
||||
y -= height; /* cope with pixel zoom */
|
||||
|
||||
if (!clip_pixelrect(ctx, ctx->DrawBuffer,
|
||||
if (!intel_clip_to_framebuffer(ctx, ctx->DrawBuffer,
|
||||
&x, &y, &width, &height)) {
|
||||
UNLOCK_HARDWARE( intel );
|
||||
return;
|
||||
|
|
@ -414,7 +409,7 @@ intelDrawPixels( GLcontext *ctx,
|
|||
}
|
||||
|
||||
|
||||
static struct intel_region *intel_drawbuf_region( struct intel_context *intel )
|
||||
struct intel_region *intel_drawbuf_region( struct intel_context *intel )
|
||||
{
|
||||
switch (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0]) {
|
||||
case BUFFER_BIT_FRONT_LEFT:
|
||||
|
|
@ -429,7 +424,7 @@ static struct intel_region *intel_drawbuf_region( struct intel_context *intel )
|
|||
}
|
||||
}
|
||||
|
||||
static struct intel_region *intel_readbuf_region( struct intel_context *intel )
|
||||
struct intel_region *intel_readbuf_region( struct intel_context *intel )
|
||||
{
|
||||
GLcontext *ctx = &intel->ctx;
|
||||
|
||||
|
|
@ -527,7 +522,7 @@ static GLboolean intelTryCopyPixels( GLcontext *ctx,
|
|||
if (!ctx->DrawBuffer)
|
||||
goto out;
|
||||
|
||||
if (!clip_pixelrect(ctx, ctx->DrawBuffer, &dstx, &dsty, &width, &height))
|
||||
if (!intel_clip_to_framebuffer(ctx, ctx->DrawBuffer, &dstx, &dsty, &width, &height))
|
||||
goto out;
|
||||
|
||||
/* Update source for clipped dest. Need to also clip the source rect.
|
||||
|
|
@ -535,7 +530,7 @@ static GLboolean intelTryCopyPixels( GLcontext *ctx,
|
|||
srcx = dstx + delta_x;
|
||||
srcy = dsty + delta_y;
|
||||
|
||||
if (!clip_pixelrect(ctx, ctx->DrawBuffer, &srcx, &srcy, &width, &height))
|
||||
if (!intel_clip_to_framebuffer(ctx, ctx->DrawBuffer, &srcx, &srcy, &width, &height))
|
||||
goto out;
|
||||
|
||||
/* Update dest for clipped source:
|
||||
|
|
|
|||
|
|
@ -79,6 +79,25 @@ void intelTexSubImage1D(GLcontext *ctx,
|
|||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage);
|
||||
|
||||
void intelCopyTexImage1D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLenum internalFormat,
|
||||
GLint x, GLint y, GLsizei width,
|
||||
GLint border );
|
||||
|
||||
void intelCopyTexImage2D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLenum internalFormat,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLint border );
|
||||
|
||||
void intelCopyTexSubImage1D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint xoffset,
|
||||
GLint x, GLint y, GLsizei width );
|
||||
|
||||
void intelCopyTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height );
|
||||
|
||||
|
||||
GLuint intel_validate_mipmap_tree( struct intel_context *intel,
|
||||
struct intel_texture_object *intelObj );
|
||||
|
||||
|
|
|
|||
283
src/mesa/drivers/dri/i915/intel_tex_copy.c
Normal file
283
src/mesa/drivers/dri/i915/intel_tex_copy.c
Normal file
|
|
@ -0,0 +1,283 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "mtypes.h"
|
||||
#include "enums.h"
|
||||
#include "teximage.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#include "intel_screen.h"
|
||||
#include "intel_context.h"
|
||||
#include "intel_batchbuffer.h"
|
||||
#include "intel_mipmap_tree.h"
|
||||
#include "intel_regions.h"
|
||||
#include "intel_tex.h"
|
||||
#include "bufmgr.h"
|
||||
|
||||
/* Do the best we can using the blitter. A future project is to use
|
||||
* the texture engine and fragment programs for these copies.
|
||||
*/
|
||||
|
||||
static struct intel_region *get_teximage_source( struct intel_context *intel,
|
||||
GLenum internalFormat )
|
||||
{
|
||||
switch (internalFormat) {
|
||||
case GL_DEPTH_COMPONENT:
|
||||
case GL_DEPTH_COMPONENT16_ARB:
|
||||
if (intel->intelScreen->cpp == 2)
|
||||
return intel->depth_region;
|
||||
return NULL;
|
||||
case GL_DEPTH24_STENCIL8_EXT:
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
if (intel->intelScreen->cpp == 4)
|
||||
return intel->depth_region;
|
||||
return NULL;
|
||||
case GL_RGBA:
|
||||
return intel_readbuf_region( intel );
|
||||
case GL_RGB:
|
||||
if (intel->intelScreen->cpp == 2)
|
||||
return intel_readbuf_region( intel );
|
||||
return NULL;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GLboolean do_copy_texsubimage( struct intel_context *intel,
|
||||
struct intel_texture_image *intelImage,
|
||||
GLenum internalFormat,
|
||||
GLint dstx, GLint dsty,
|
||||
GLint x, GLint y,
|
||||
GLsizei width, GLsizei height )
|
||||
{
|
||||
GLcontext *ctx = &intel->ctx;
|
||||
struct intel_region *src = get_teximage_source(intel, internalFormat);
|
||||
GLuint ret = GL_TRUE;
|
||||
|
||||
if (!intelImage->mt)
|
||||
return GL_FALSE;
|
||||
|
||||
if (!intel_check_color_per_fragment_ops( ctx ))
|
||||
return GL_FALSE;
|
||||
|
||||
|
||||
LOCK_HARDWARE(intel);
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = intel->driDrawable;
|
||||
struct bm_buffer_list *list = bmNewBufferList();
|
||||
GLuint image_offset = intel_miptree_image_offset(intelImage->mt,
|
||||
intelImage->face,
|
||||
intelImage->level);
|
||||
GLuint dst_offset = 0;
|
||||
GLuint src_offset = 0;
|
||||
GLint orig_x = x;
|
||||
GLint orig_y = y;
|
||||
|
||||
if (!intel_clip_to_framebuffer(ctx, ctx->DrawBuffer, &x, &y, &width, &height)) {
|
||||
ret = GL_TRUE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Update dst for clipped src. Need to also clip the source rect.
|
||||
*/
|
||||
dstx = x - orig_x;
|
||||
dsty = y - orig_y;
|
||||
|
||||
y = dPriv->h - y - height; /* convert from gl to hardware coords */
|
||||
x += dPriv->x;
|
||||
y += dPriv->y;
|
||||
|
||||
|
||||
bmAddBuffer(list, intelImage->mt->region->buffer, BM_WRITE, NULL, &dst_offset);
|
||||
bmAddBuffer(list, src->buffer, BM_READ, NULL, &src_offset);
|
||||
if (!bmValidateBufferList(intel->bm, list, BM_MEM_AGP)) {
|
||||
ret = GL_FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
intelEmitCopyBlitLocked( intel,
|
||||
intelImage->mt->cpp,
|
||||
src->pitch, src_offset,
|
||||
intelImage->mt->pitch,
|
||||
dst_offset + image_offset,
|
||||
x, y,
|
||||
dstx, dsty,
|
||||
width, height );
|
||||
|
||||
intelFlushBatchLocked( intel, GL_TRUE, GL_FALSE, GL_FALSE);
|
||||
bmFenceBufferList(intel->bm, list);
|
||||
|
||||
out:
|
||||
bmFreeBufferList(list);
|
||||
}
|
||||
|
||||
|
||||
UNLOCK_HARDWARE(intel);
|
||||
if (!ret)
|
||||
return GL_FALSE;
|
||||
|
||||
#if 0
|
||||
/* GL_SGIS_generate_mipmap -- this can be accelerated now.
|
||||
*/
|
||||
if (level == texObj->BaseLevel &&
|
||||
texObj->GenerateMipmap) {
|
||||
intel_generate_mipmap(ctx, target,
|
||||
&ctx->Texture.Unit[ctx->Texture.CurrentUnit],
|
||||
texObj);
|
||||
}
|
||||
#endif
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void intelCopyTexImage1D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLenum internalFormat,
|
||||
GLint x, GLint y, GLsizei width,
|
||||
GLint border )
|
||||
{
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||
struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target);
|
||||
struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
|
||||
|
||||
if (border)
|
||||
goto fail;
|
||||
|
||||
/* Setup or redefine the texture object, mipmap tree and texture
|
||||
* image. Don't populate yet.
|
||||
*/
|
||||
ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
|
||||
width, border,
|
||||
GL_RGBA, CHAN_TYPE, NULL,
|
||||
&ctx->DefaultPacking, texObj, texImage);
|
||||
|
||||
|
||||
|
||||
if (!texImage)
|
||||
goto fail;
|
||||
|
||||
if (!do_copy_texsubimage(intel_context(ctx),
|
||||
intel_texture_image(texImage),
|
||||
internalFormat,
|
||||
0, 0,
|
||||
x, y,
|
||||
width, 1))
|
||||
goto fail;
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
_swrast_copy_teximage1d( ctx, target, level, internalFormat, x, y,
|
||||
width, border );
|
||||
}
|
||||
|
||||
void intelCopyTexImage2D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLenum internalFormat,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLint border )
|
||||
{
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||
struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target);
|
||||
struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
|
||||
|
||||
if (border)
|
||||
goto fail;
|
||||
|
||||
/* Setup or redefine the texture object, mipmap tree and texture
|
||||
* image. Don't populate yet.
|
||||
*/
|
||||
ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
|
||||
width, height, border,
|
||||
GL_RGBA, CHAN_TYPE, NULL,
|
||||
&ctx->DefaultPacking, texObj, texImage);
|
||||
|
||||
|
||||
if (!do_copy_texsubimage(intel_context(ctx),
|
||||
intel_texture_image(texImage),
|
||||
internalFormat,
|
||||
0, 0,
|
||||
x, y,
|
||||
width, height))
|
||||
goto fail;
|
||||
|
||||
return;
|
||||
|
||||
fail:
|
||||
_swrast_copy_teximage2d( ctx, target, level, internalFormat, x, y,
|
||||
width, height, border );
|
||||
}
|
||||
|
||||
|
||||
void intelCopyTexSubImage1D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint xoffset,
|
||||
GLint x, GLint y, GLsizei width )
|
||||
{
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||
struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
|
||||
GLenum internalFormat = texImage->InternalFormat;
|
||||
|
||||
/* Need to check texture is compatible with source format.
|
||||
*/
|
||||
|
||||
if (!do_copy_texsubimage(intel_context(ctx),
|
||||
intel_texture_image(texImage),
|
||||
internalFormat,
|
||||
xoffset, 0,
|
||||
x, y, width, 1)) {
|
||||
_swrast_copy_texsubimage1d( ctx, target, level,
|
||||
xoffset, x, y, width );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void intelCopyTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height )
|
||||
{
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
|
||||
struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
|
||||
GLenum internalFormat = texImage->InternalFormat;
|
||||
|
||||
|
||||
/* Need to check texture is compatible with source format.
|
||||
*/
|
||||
|
||||
if (!do_copy_texsubimage(intel_context(ctx),
|
||||
intel_texture_image(texImage),
|
||||
internalFormat,
|
||||
xoffset, yoffset,
|
||||
x, y, width, height)) {
|
||||
_swrast_copy_texsubimage2d( ctx, target, level,
|
||||
xoffset, yoffset,
|
||||
x, y, width, height );
|
||||
}
|
||||
}
|
||||
|
|
@ -7,13 +7,16 @@
|
|||
* hardware. However, there is still a need to map the formats onto
|
||||
* hardware descriptors.
|
||||
*/
|
||||
/* Note that the i915 can actually support many more formats than
|
||||
* these if we take the step of simply swizzling the colors
|
||||
* immediately after sampling...
|
||||
*/
|
||||
const struct gl_texture_format *
|
||||
intelChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
|
||||
GLenum format, GLenum type )
|
||||
{
|
||||
intelContextPtr intel = INTEL_CONTEXT( ctx );
|
||||
const GLboolean do32bpt = ( intel->intelScreen->cpp == 4 &&
|
||||
intel->intelScreen->tex.size > 4*1024*1024);
|
||||
const GLboolean do32bpt = (intel->intelScreen->cpp == 4);
|
||||
|
||||
switch ( internalFormat ) {
|
||||
case 4:
|
||||
|
|
@ -57,7 +60,7 @@ intelChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
|
|||
case GL_RGB10:
|
||||
case GL_RGB12:
|
||||
case GL_RGB16:
|
||||
return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
|
||||
return &_mesa_texformat_argb8888;
|
||||
|
||||
case GL_RGB5:
|
||||
case GL_RGB4:
|
||||
|
|
|
|||
|
|
@ -215,17 +215,24 @@ static void intelTexImage(GLcontext *ctx,
|
|||
free(texImage->Data);
|
||||
}
|
||||
|
||||
pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
|
||||
format, type,
|
||||
pixels, packing, "glTexImage");
|
||||
if (!pixels)
|
||||
return;
|
||||
/* XXX: If this is the only texture image in the tree, could call
|
||||
* bmBufferData with NULL data to free the old block and avoid
|
||||
* waiting on any outstanding fences.
|
||||
*
|
||||
* XXX: Better to do this internally to intel_mipmap_tree.c,
|
||||
* somehow?
|
||||
*/
|
||||
if (intelObj->mt &&
|
||||
intelObj->mt->first_level == level &&
|
||||
intelObj->mt->last_level == level &&
|
||||
intelObj->mt->target != GL_TEXTURE_CUBE_MAP_ARB) {
|
||||
}
|
||||
|
||||
|
||||
if (!intelObj->mt) {
|
||||
guess_and_alloc_mipmap_tree(intel, intelObj, intelImage);
|
||||
}
|
||||
|
||||
LOCK_HARDWARE(intel);
|
||||
|
||||
|
||||
if (intelObj->mt &&
|
||||
intelObj->mt != intelImage->mt &&
|
||||
|
|
@ -237,6 +244,22 @@ static void intelTexImage(GLcontext *ctx,
|
|||
|
||||
intelImage->mt = intel_miptree_reference(intelObj->mt);
|
||||
}
|
||||
|
||||
|
||||
/* intelCopyTexImage calls this function with pixels == NULL, with
|
||||
* the expectation that the mipmap tree will be set up but nothing
|
||||
* more will be done. This is where those calls return:
|
||||
*/
|
||||
pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
|
||||
format, type,
|
||||
pixels, packing, "glTexImage");
|
||||
if (!pixels)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
LOCK_HARDWARE(intel);
|
||||
|
||||
if (intelImage->mt) {
|
||||
texImage->Data = intel_miptree_image_map(intel,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,30 @@
|
|||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "mtypes.h"
|
||||
#include "texobj.h"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue