2 /**************************************************************************
4 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
34 #include "intel_context.h"
35 #include "intel_tex.h"
36 #include "intel_mipmap_tree.h"
38 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
41 intelTexSubimage(GLcontext
* ctx
,
43 GLenum target
, GLint level
,
44 GLint xoffset
, GLint yoffset
, GLint zoffset
,
45 GLint width
, GLint height
, GLint depth
,
46 GLenum format
, GLenum type
, const void *pixels
,
47 const struct gl_pixelstore_attrib
*packing
,
48 struct gl_texture_object
*texObj
,
49 struct gl_texture_image
*texImage
)
51 struct intel_context
*intel
= intel_context(ctx
);
52 struct intel_texture_image
*intelImage
= intel_texture_image(texImage
);
55 DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__
,
56 _mesa_lookup_enum_by_nr(target
),
57 level
, xoffset
, yoffset
, width
, height
);
62 _mesa_validate_pbo_teximage(ctx
, dims
, width
, height
, depth
, format
,
63 type
, pixels
, packing
, "glTexSubImage2D");
68 intel_region_idle(intel
->intelScreen
, intelImage
->mt
->region
);
72 /* Map buffer if necessary. Need to lock to prevent other contexts
73 * from uploading the buffer under us.
76 texImage
->Data
= intel_miptree_image_map(intel
,
81 texImage
->ImageOffsets
);
85 if (!texImage
->TexFormat
->StoreImage(ctx
, dims
, texImage
->_BaseFormat
,
88 xoffset
, yoffset
, zoffset
,
90 texImage
->ImageOffsets
,
92 format
, type
, pixels
, packing
)) {
93 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "intelTexSubImage");
97 /* GL_SGIS_generate_mipmap */
98 if (level
== texObj
->BaseLevel
&& texObj
->GenerateMipmap
) {
99 _mesa_generate_mipmap(ctx
, target
,
100 &ctx
->Texture
.Unit
[ctx
->Texture
.CurrentUnit
],
105 _mesa_unmap_teximage_pbo(ctx
, packing
);
107 if (intelImage
->mt
) {
108 intel_miptree_image_unmap(intel
, intelImage
->mt
);
109 texImage
->Data
= NULL
;
112 UNLOCK_HARDWARE(intel
);
120 intelTexSubImage3D(GLcontext
* ctx
,
123 GLint xoffset
, GLint yoffset
, GLint zoffset
,
124 GLsizei width
, GLsizei height
, GLsizei depth
,
125 GLenum format
, GLenum type
,
126 const GLvoid
* pixels
,
127 const struct gl_pixelstore_attrib
*packing
,
128 struct gl_texture_object
*texObj
,
129 struct gl_texture_image
*texImage
)
132 intelTexSubimage(ctx
, 3,
134 xoffset
, yoffset
, zoffset
,
135 width
, height
, depth
,
136 format
, type
, pixels
, packing
, texObj
, texImage
);
143 intelTexSubImage2D(GLcontext
* ctx
,
146 GLint xoffset
, GLint yoffset
,
147 GLsizei width
, GLsizei height
,
148 GLenum format
, GLenum type
,
149 const GLvoid
* pixels
,
150 const struct gl_pixelstore_attrib
*packing
,
151 struct gl_texture_object
*texObj
,
152 struct gl_texture_image
*texImage
)
155 intelTexSubimage(ctx
, 2,
159 format
, type
, pixels
, packing
, texObj
, texImage
);
165 intelTexSubImage1D(GLcontext
* ctx
,
170 GLenum format
, GLenum type
,
171 const GLvoid
* pixels
,
172 const struct gl_pixelstore_attrib
*packing
,
173 struct gl_texture_object
*texObj
,
174 struct gl_texture_image
*texImage
)
176 intelTexSubimage(ctx
, 1,
180 format
, type
, pixels
, packing
, texObj
, texImage
);