diff options
author | marha <marha@users.sourceforge.net> | 2013-06-04 09:07:26 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-06-04 09:48:59 +0200 |
commit | fd2b28971a2afbf54b6cb641aa6a2d5e940a1450 (patch) | |
tree | 1b103a8b2114125ffa8d79827d931aba3744a0d2 /mesalib/src/mesa/swrast/s_texture.c | |
parent | 62a1ce0583cf41c173f4edb91511430b552e04da (diff) | |
download | vcxsrv-fd2b28971a2afbf54b6cb641aa6a2d5e940a1450.tar.gz vcxsrv-fd2b28971a2afbf54b6cb641aa6a2d5e940a1450.tar.bz2 vcxsrv-fd2b28971a2afbf54b6cb641aa6a2d5e940a1450.zip |
xwininfo fontconfig libX11 libXau libXdmcp libXext mesa libXinerama libxcb libxcb/xcb-proto libfontenc pixman xkbcomp mkfontscale xkeyboard-config git update 4 Jun 2013
xserver commit c21344add2fc589df83b29be5831c36a372201bd
libxcb commit 9ae84ad187e2ba440c40f44b8eb21c82c2fdbf12
libxcb/xcb-proto commit bdfedfa57a13ff805580cfacafc70f9cc55df363
xkeyboard-config commit dad9ade4e83d1ef5a517fcc4cc9ad3a79b47acce
libX11 commit 8496122eb00ce6cd5d2308ee54f64b68c378e455
libXdmcp commit 0b443c1b769b9c9a3b45b4252afe07e18b709ff4
libXext commit d8366afbb0d2e4fbb1e419b1187f490522270bea
libfontenc commit 3acba630d8b57084f7e92c15732408711ed5137a
libXinerama commit 6e1d1dc328ba8162bba2f4694e7f3c706a1491ff
libXau commit 899790011304c4029e15abf410e49ce7cec17e0a
xkbcomp commit ed582f4fccd4e23abcfba8b3b03649fea6414f44
pixman commit 2acfac5f8e097ee2ae225d986f981b55d65dd152
mkfontscale commit 19e2cb7c6a3ec2c5b1bc0d24866fa685eef0ee13
xwininfo commit ba0d1b0da21d2dbdd81098ed5778f3792b472e13
fontconfig commit cd9b1033a68816a7acfbba1718ba0aa5888f6ec7
mesa commit 7bafd88c153e395274b632e7eae4bc9fc3aec1d2
Diffstat (limited to 'mesalib/src/mesa/swrast/s_texture.c')
-rw-r--r-- | mesalib/src/mesa/swrast/s_texture.c | 186 |
1 files changed, 106 insertions, 80 deletions
diff --git a/mesalib/src/mesa/swrast/s_texture.c b/mesalib/src/mesa/swrast/s_texture.c index 8ae3d5bd0..27803c553 100644 --- a/mesalib/src/mesa/swrast/s_texture.c +++ b/mesalib/src/mesa/swrast/s_texture.c @@ -16,9 +16,10 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS 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. + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. */ /** @@ -58,6 +59,26 @@ _swrast_delete_texture_image(struct gl_context *ctx, _mesa_delete_texture_image(ctx, texImage); } +static unsigned int +texture_slices(struct gl_texture_image *texImage) +{ + if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) + return texImage->Height; + else + return texImage->Depth; +} + +unsigned int +_swrast_teximage_slice_height(struct gl_texture_image *texImage) +{ + /* For 1D array textures, the slices are all 1 pixel high, and Height is + * the number of slices. + */ + if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) + return 1; + else + return texImage->Height; +} /** * Called via ctx->Driver.AllocTextureImageBuffer() @@ -67,31 +88,28 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, struct gl_texture_image *texImage) { struct swrast_texture_image *swImg = swrast_texture_image(texImage); - GLuint bytes = _mesa_format_image_size(texImage->TexFormat, texImage->Width, - texImage->Height, texImage->Depth); + GLuint bytesPerSlice; + GLuint slices = texture_slices(texImage); GLuint i; - assert(!swImg->Buffer); - swImg->Buffer = _mesa_align_malloc(bytes, 512); - if (!swImg->Buffer) + if (!_swrast_init_texture_image(texImage)) return GL_FALSE; - /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */ - swImg->RowStride = texImage->Width; + bytesPerSlice = _mesa_format_image_size(texImage->TexFormat, texImage->Width, + _swrast_teximage_slice_height(texImage), 1); - /* Allocate the ImageOffsets array and initialize to typical values. - * We allocate the array for 1D/2D textures too in order to avoid special- - * case code in the texstore routines. - */ - swImg->ImageOffsets = malloc(texImage->Depth * sizeof(GLuint)); - if (!swImg->ImageOffsets) + assert(!swImg->Buffer); + swImg->Buffer = _mesa_align_malloc(bytesPerSlice * slices, 512); + if (!swImg->Buffer) return GL_FALSE; - for (i = 0; i < texImage->Depth; i++) { - swImg->ImageOffsets[i] = i * texImage->Width * texImage->Height; - } + /* RowStride and ImageSlices[] describe how to address texels in 'Data' */ + swImg->RowStride = _mesa_format_row_stride(texImage->TexFormat, + texImage->Width); - _swrast_init_texture_image(texImage); + for (i = 0; i < slices; i++) { + swImg->ImageSlices[i] = swImg->Buffer + bytesPerSlice * i; + } return GL_TRUE; } @@ -100,11 +118,11 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, /** * Code that overrides ctx->Driver.AllocTextureImageBuffer may use this to * initialize the fields of swrast_texture_image without allocating the image - * buffer or initializing ImageOffsets or RowStride. + * buffer or initializing RowStride or the contents of ImageSlices. * * Returns GL_TRUE on success, GL_FALSE on memory allocation failure. */ -void +GLboolean _swrast_init_texture_image(struct gl_texture_image *texImage) { struct swrast_texture_image *swImg = swrast_texture_image(texImage); @@ -128,6 +146,13 @@ _swrast_init_texture_image(struct gl_texture_image *texImage) swImg->HeightScale = (GLfloat) texImage->Height; swImg->DepthScale = (GLfloat) texImage->Depth; } + + assert(!swImg->ImageSlices); + swImg->ImageSlices = calloc(texture_slices(texImage), sizeof(void *)); + if (!swImg->ImageSlices) + return GL_FALSE; + + return GL_TRUE; } @@ -144,8 +169,8 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx, swImage->Buffer = NULL; } - free(swImage->ImageOffsets); - swImage->ImageOffsets = NULL; + free(swImage->ImageSlices); + swImage->ImageSlices = NULL; } @@ -206,25 +231,15 @@ _swrast_map_teximage(struct gl_context *ctx, *mapOut = NULL; return; } - - map = swImage->Buffer; - - if (texImage->TexObject->Target == GL_TEXTURE_3D || - texImage->TexObject->Target == GL_TEXTURE_2D_ARRAY) { - GLuint sliceSize = _mesa_format_image_size(texImage->TexFormat, - texImage->Width, - texImage->Height, - 1); - assert(slice < texImage->Depth); - map += slice * sliceSize; - } else if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) { - GLuint sliceSize = _mesa_format_image_size(texImage->TexFormat, - texImage->Width, - 1, - 1); - assert(slice < texImage->Height); - map += slice * sliceSize; - } + + /* This function can only be used with a swrast-allocated buffer, in which + * case ImageSlices is populated with pointers into Buffer. + */ + assert(swImage->Buffer); + assert(swImage->Buffer == swImage->ImageSlices[0]); + + assert(slice < texture_slices(texImage)); + map = swImage->ImageSlices[slice]; /* apply x/y offset to map address */ map += stride * (y / bh) + texelSize * (x / bw); @@ -251,12 +266,42 @@ _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj) for (face = 0; face < faces; face++) { for (level = texObj->BaseLevel; level < MAX_TEXTURE_LEVELS; level++) { struct gl_texture_image *texImage = texObj->Image[face][level]; - if (texImage) { - struct swrast_texture_image *swImage = - swrast_texture_image(texImage); + struct swrast_texture_image *swImage = swrast_texture_image(texImage); + unsigned int i; + + if (!texImage) + continue; + + /* In the case of a swrast-allocated texture buffer, the ImageSlices + * and RowStride are always available. + */ + if (swImage->Buffer) { + assert(swImage->ImageSlices[0] == swImage->Buffer); + continue; + } - /* XXX we'll eventually call _swrast_map_teximage() here */ - swImage->Map = swImage->Buffer; + for (i = 0; i < texture_slices(texImage); i++) { + GLubyte *map; + GLint rowStride; + + if (swImage->ImageSlices[i]) + continue; + + ctx->Driver.MapTextureImage(ctx, texImage, i, + 0, 0, + texImage->Width, texImage->Height, + GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, + &map, &rowStride); + + swImage->ImageSlices[i] = map; + /* A swrast-using driver has to return the same rowstride for + * every slice of the same texture, since we don't track them + * separately. + */ + if (i == 0) + swImage->RowStride = rowStride; + else + assert(swImage->RowStride == rowStride); } } } @@ -272,12 +317,20 @@ _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj) for (face = 0; face < faces; face++) { for (level = texObj->BaseLevel; level < MAX_TEXTURE_LEVELS; level++) { struct gl_texture_image *texImage = texObj->Image[face][level]; - if (texImage) { - struct swrast_texture_image *swImage - = swrast_texture_image(texImage); + struct swrast_texture_image *swImage = swrast_texture_image(texImage); + unsigned int i; + + if (!texImage) + continue; - /* XXX we'll eventually call _swrast_unmap_teximage() here */ - swImage->Map = NULL; + if (swImage->Buffer) + return; + + for (i = 0; i < texture_slices(texImage); i++) { + if (swImage->ImageSlices[i]) { + ctx->Driver.UnmapTextureImage(ctx, texImage, i); + swImage->ImageSlices[i] = NULL; + } } } } @@ -322,30 +375,3 @@ _swrast_unmap_textures(struct gl_context *ctx) enabledUnits &= ~(1 << unit); } } - - -/** - * Called via ctx->Driver.AllocTextureStorage() - * Just have to allocate memory for the texture images. - */ -GLboolean -_swrast_AllocTextureStorage(struct gl_context *ctx, - struct gl_texture_object *texObj, - GLsizei levels, GLsizei width, - GLsizei height, GLsizei depth) -{ - const GLint numFaces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; - GLint face, level; - - for (face = 0; face < numFaces; face++) { - for (level = 0; level < levels; level++) { - struct gl_texture_image *texImage = texObj->Image[face][level]; - if (!_swrast_alloc_texture_image_buffer(ctx, texImage)) { - return GL_FALSE; - } - } - } - - return GL_TRUE; -} - |