summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texgetimage.c
Commit message (Collapse)AuthorAgeFilesLines
* mesa: remove dd_function_table::GetCompressedTexSubImage and clean it upMarek Olšák2018-01-061-12/+11
| | | | Reviewed-by: Ian Romanick <[email protected]>
* mesa/main: Fix GetTextureImage error reportingIago Toral Quiroga2017-09-061-1/+1
| | | | | | | | | | | | | | | | | GetTex*Image should return INVALID_ENUM if target is not valid, however, GetTextureImage does not receive a target, and instead should return INVALID_OPERATION if the effective target is not valid. From the OpenGL 4.6 core profile spec, section 8.11 Texture Queries: "An INVALID_OPERATION error is generated by GetTextureImage if the effective target is not one of TEXTURE_1D, TEXTURE_2D, TEXTURE_3D, TEXTURE_1D_ARRAY, TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY, TEXTURE_RECTANGLE, or TEXTURE_CUBE_MAP (for GetTextureImage only)." Fixes: KHR-GL45.direct_state_access.textures_image_query_errors Reviewed-by: Samuel Pitoiset <[email protected]>
* Revert "getteximage: Return correct error value when texure object is not found"Juan A. Suarez Romero2017-06-221-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | From OpenGL 4.5 spec PDF, section '8.11. Texture Queries', page 236: "An INVALID_VALUE error is generated if texture is not the name of an existing texture object." Same wording applies to the compressed version. But turns out this is a spec bug, and Khronos is fixing it for the next revisions. The proposal is to return INVALID_OPERATION in these cases. This reverts commit 633c959faeae5099fd095f27da7b954e4a36254b. v2: - Use _mesa_lookup_texture_err (Samuel Pitoiset) v3: - _mesa_lookup_texture_err() already handles texture > 0 (Samuel Pitoiset) - Just revert 633c959fae (Juan A. Suarez) Reviewed-by: Samuel Pitoiset <[email protected]> Signed-off-by: Juan A. Suarez Romero <[email protected]>
* getteximage: fix _mesa_GetTextureSubImage()Samuel Pitoiset2017-03-061-1/+1
| | | | | | | | | Oops. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100088 Fixes: 5ae54c0cf7 ("getteximage: avoid to lookup textures with id 0") Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* getteximage: avoid to lookup textures with id 0Samuel Pitoiset2017-03-061-3/+7
| | | | | | | | | | This fixes the following assertion when the key is 0. main/hash.c:181: _mesa_HashLookup_unlocked: Assertion `key' failed. Fixes: 633c959fae ("getteximage: Return correct error value when texure object is not found") Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* getteximage: Return correct error value when texure object is not foundEduardo Lima Mitev2017-02-151-2/+4
| | | | | | | | | | | | | | | | | | | | | glGetTextureSubImage() and glGetCompressedTextureSubImage() are currently returning INVALID_OPERATION error when the passed texture argument does not correspond to an existing texture object. However, the error should be INVALID_VALUE instead. From OpenGL 4.5 spec PDF, section '8.11. Texture Queries', page 236: "An INVALID_VALUE error is generated if texture is not the name of an existing texture object." Same wording applies to the compressed version. The INVALID_OPERATION error is coming from the call to _mesa_lookup_texture_err(). This patch uses _mesa_lookup_texture() instead and emits the correct error in the caller. Fixes: GL45-CTS.get_texture_sub_image.errors_test Reviewed-by: Nicolai Hähnle <[email protected]>
* texgetimage: Add check for the effective target to GetTextureSubImageEduardo Lima Mitev2017-02-031-0/+6
| | | | | | | | | | | | | | | | | | | OpenGL 4.5 spec, section "8.11.4 Texture Image Queries", page 233 of the PDF states: "An INVALID_OPERATION error is generated if texture is the name of a buffer or multisample texture." This is currently not being checked and e.g a multisample texture image can be passed down to the driver hook. On i965, it is crashing the driver with an assertion: intel_mipmap_tree.c:3125: intel_miptree_map: Assertion `mt->num_samples <= 1' failed. v2: (Ilia Mirkin) Move the check from gettextimage_error_check() to GetTextureSubImage() and use the texObj target. Reviewed-by: Ilia Mirkin <[email protected]>
* mesa/getteximage: Add validation of target to glGetTextureImageEduardo Lima Mitev2016-11-241-0/+5
| | | | | | | | | | | | | | | | | | | | There is an specific list of texture targets that can be used with glGetTextureImage. From OpenGL 4.5 spec, section '8.11 Texture Queries', page 234 of the PDF: "An INVALID_ENUM error is generated if the effective target is not one of TEXTURE_1D , TEXTURE_2D , TEXTURE_3D , TEXTURE_1D_- ARRAY , TEXTURE_2D_ARRAY , TEXTURE_CUBE_MAP_ARRAY , TEXTURE_- RECTANGLE , one of the targets from table 8.19 (for GetTexImage and GetnTexImage only), or TEXTURE_CUBE_MAP (for GetTextureImage only)." We are currently not validating the target for glGetTextureImage. As an example, calling this function on a texture with target GL_TEXTURE_2D_MULTISAMPLE should return INVALID_ENUM, but instead it hits an assertion down the road in the i965 driver. Reviewed-by: Nicolai Hähnle <[email protected]>
* main/getteximage: Use the height argument to calculate memcpy copy sizeEduardo Lima Mitev2016-11-231-1/+1
| | | | | | | | | | | | | | | | | | In get_tex_memcpy, when copying texture data directly from source to destination (when row strides match for both src and dst), the copy size is currently calculated using the full texture height instead of the sub-region height parameter that was passed. This can cause a read past the end of the mapped buffer when y-offset is greater than zero, leading to a segfault. Fixes CTS test (from crash to pass): * GL45-CTS/get_texture_sub_image/functional_test v2: (Jason) Use the passed 'height' instead of copying til the end of the buffer (tex-height - yoffset). Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: fix format conversion bug in get_tex_rgba_uncompressed()Brian Paul2016-08-291-6/+8
| | | | | | | | | | | We need to set the need_convert flag with each loop iteration, not just when the rgba pointer is null. Bug reported by Markus Müller <[email protected]> on mesa-users list. Fixes new piglit arb_texture_float-get-tex3d test. Cc: <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* mesa: Add a helper function for shared code in get_tex_rgba_{un}compressedAnuj Phogat2016-06-091-45/+38
| | | | | Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: remove null check before freeThomas Hindoe Paaboel Andersen2016-05-051-2/+1
| | | | Reviewed-by: Eduardo Lima Mitev <[email protected]>
* mesa: Handle 3d block sizes in getteximage error checksAnuj Phogat2016-05-031-4/+17
| | | | | Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: remove _ARB suffix from cube map enumsBrian Paul2016-02-121-7/+7
| | | | | | | Just minor clean-up so we're consistent everywhere. Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* texgetimage: consolidate 1D array handling code.Dave Airlie2015-11-241-15/+11
| | | | | | | | | | | | | This should fix the getteximage-depth test that currently asserts. I was hitting problem with virgl as well in this area. This moves the 1D array handling code to a single place. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ben Skeggs <[email protected]> Cc: "10.6 11.0 11.1" <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* mesa: minor formatting fix in get_tex_rgba_compressed()Brian Paul2015-10-281-2/+1
|
* mesa: handle SwapBytes in compressed texture get code.Dave Airlie2015-09-021-0/+7
| | | | | | | | This case just wasn't handled, so add support for it. Cc: "11.0" <[email protected]> Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* mesa: fix SwapBytes handling in numerous placesDave Airlie2015-09-021-11/+3
| | | | | | | | | | | | | | | | | | | In a number of places the SwapBytes handling didn't handle cases with GL_(UN)PACK_ALIGNMENT set and 7 byte width cases aligned to 8 bytes. This adds a common routine to swap bytes a 2D image and uses this code in: texture storage texture get readpixels swrast drawpixels. [airlied: updated with Brian's nitpicks]. Cc: "11.0" <[email protected]> Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* mesa/texgetimage: fix missing stencil checkDave Airlie2015-08-261-0/+7
| | | | | | | | | | | | GetTexImage can read to stencil8 but only from a stencil or depthstencil textures. This fixes a bunch of failures in CTS GL33-CTS.gtf32.GL3Tests.packed_pixels Reviewed-by: Marek Olšák <[email protected]> Cc: "11.0" <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* mesa/formats: remove compressed formats from matching functionNanley Chery2015-08-251-1/+1
| | | | | | | | | | | | | | | All compressed formats return GL_FALSE and there isn't any evidence to support that this behaviour would change. Remove all switch cases for compressed formats. v2. Since the exhaustive switch is removed, add a gtest to ensure all formats are handled. v3. Ensure that GL_NO_ERROR is set before returning. v4. Fix an arg to _mesa_uncompressed_format_to_type_and_comps(); fix formatting and misc improvements (Chad). Reviewed-by: Chad Versace <[email protected]> Signed-off-by: Nanley Chery <[email protected]>
* mesa: fix error checking for getting zero-sized texture imagesIlia Mirkin2015-07-241-9/+9
| | | | | | | | | | | | | | | | | | Commit 17f714836 (mesa: rearrange texture error checking order) moved the width/height/depth == 0 allowance before checking if the image was there. This was in part due to depth having to be == 1 for 2D images and width having to be == 1 for 1D images. Instead relax the height/depth checks to also accept 0 as valid. With this change, bin/arb_direct_state_access-get-textures starts passing again. Fixes: 17f714836 (mesa: rearrange texture error checking order) Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: rearrange texture error checking orderIlia Mirkin2015-07-231-13/+13
| | | | | | | | | | | | | This moves the width/height/depth == 0 check to the front and avoids doing any other checking when that is the case. Also moves the dimensions check after the format/type checks so that we don't bail out with success on a width/height/depth == 0 request when the format/type don't match. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91425 Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: adjust error message when there's a missing teximageIlia Mirkin2015-07-231-2/+1
| | | | | | | The current message makes it seem like the zoffset is invalid. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: fix typo s/glGetTextImage/glGetTexImage/Brian Paul2015-07-221-1/+1
| | | | Trivial.
* mesa: add new _mesa_Get[Compressed]TextureSubImage() functionsBrian Paul2015-07-211-1/+61
| | | | | | Simple implementations in terms of get_[compressed_]texture_image(). Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: overhaul the glGetCompressedTexImage codeBrian Paul2015-07-211-142/+198
| | | | | | | Same idea as the previous patch. v2: a few clean-ups spotted by Ilia Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: overhaul the glGetTexImage codeBrian Paul2015-07-211-195/+428
| | | | | | | | | | | | | | 1. Reorganize the error checking code. 2. Lay groundwork for getting sub images by passing image offset and dimensions to the error checking code. 3. Implement _mesa_GetnTexImageARB(), _mesa_GetTexImage() and _mesa_GetTextureImage() all in terms of get_texture_image(). v2: pass offset/width/height/depth arguments to the error checking function, avoid using magic width/height/depth values. v3: remove unused bufSize param to get_texture_image() Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: 80-column wrapping in texgetimage.cBrian Paul2015-07-211-5/+8
| | | | Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: replace Driver.GetCompressedTexImage() w/ GetCompressedTexSubImage()Brian Paul2015-07-211-12/+16
| | | | | | | For now, pass offsets of zero and width/height/depth equal to the whole image. Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: make _mesa_get_[compressed_]texture_image() staticBrian Paul2015-07-211-12/+12
| | | | | | These functions are only called from teximage.c Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: plumb offset/size parameters through GetTexSubImage codeBrian Paul2015-07-211-57/+80
| | | | | | | | | | | | | | Needed for GL_ARB_get_texture_sub_image. But at this point, the offsets are always zero and the sizes match the whole texture image. v2: Fixes, suggestions from Laura Ekstrand: * Fix calls to ctx->Driver.UnmapTextureImage() to pass the correct slice value. * Added comments and assertions to check zoffset+depth<=tex->Depth before the 'img' loops. * Added a new zoffset==0 assert in get_tex_memcpy(). Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: replace Driver.GetTexImage with GetTexSubImage()Brian Paul2015-07-211-5/+10
| | | | | | | | | | | | | | | The new driver hook has x/y/zoffset and width/height/depth parameters for the new glGetTextureSubImage() function. The meta code and gallium state tracker are updated to handle the new parameters. Callers to Driver.GetTexSubImage() pass in offsets=0 and sizes equal to the whole texture size. v2: update i965 driver code, s/GLint/GLsizei/ in GetTexSubImage hook Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: Rename _mesa_lookup_enum_by_nr() to _mesa_enum_to_string().Kenneth Graunke2015-07-201-2/+2
| | | | | | | Generated by sed; no manual changes. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* Revert "mesa: Add ARB_direct_state_access checks in texture functions"Ian Romanick2015-05-281-14/+0
| | | | | | | This reverts commit 8940957238e8584ce27295791cee4cc3d6f7cf1e. Acked-by: Fredrik Höglund <[email protected]> Cc: "10.6" <[email protected]>
* mesa: Add ARB_direct_state_access checks in texture functionsFredrik Höglund2015-05-141-0/+14
| | | | | Signed-off-by: Fredrik Höglund <[email protected]> Reviewed-by: Adam Jackson <[email protected]>
* mesa: finish implementing ARB_texture_stencil8 (v5)Dave Airlie2015-04-231-1/+49
| | | | | | | | | | | | | | Parts of this were implemented previously, so finish it off. v2: fix getteximage falling into the integer check add fixes for the FBO paths, (fbo-stencil8 test). v3: fix getteximage path harder. v4: remove swapbytes from getteximage path (Ilia) v5: brown paper bag the swapbytes removal. (Ilia) Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* mesa: Fix typo in a commentAnuj Phogat2015-04-221-2/+2
| | | | | Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* main: Checking for cube completeness in GetCompressedTextureImage.Laura Ekstrand2015-03-091-1/+10
| | | | | | | | | v2: Review from Anuj Phogat - Remove redundant copies of the cube map block comment - Replace redundant "if (!texImage) return;" statements with assert(texImage) Reviewed-by: Anuj Phogat <[email protected]>
* main: assert(texImage) in ARB_DSA texture cube map functions.Laura Ekstrand2015-03-091-2/+3
| | | | | | | | | | | | | ARB_direct_state_access functions that deal with texture cube maps need to make sure that texture images are not NULL before operating on them. In the following cases, the error check functions already throw an error if texImage == NULL, so an assert can be raised instead. v2: Review from Anuj Phogat - Replace redundant "if (!texImage) return;" statements with assert(texImage) Reviewed-by: Anuj Phogat <[email protected]>
* main: Remove redundant copy of cube map block comment in GetTextureImage.Laura Ekstrand2015-03-091-29/+3
| | | | | | | | | | | | The comment describing why ARB_direct_state_access texture cube map functions use _mesa_cube_level_complete is very long. To save room in the files, readers are now referred to one central comment on texturesubimage in teximage.c. v2: Review from Anuj Phogat - Remove redundant copies of the cube map block comment Reviewed-by: Anuj Phogat <[email protected]>
* main: Remove redundant NumLayers checks.Laura Ekstrand2015-03-091-13/+0
| | | | | | | | ARB_direct_state_access texture functions that operate on cube maps no longer need to verify that cube map texture objects contain six texture images because _mesa_cube_level_complete now does that for them. Reviewed-by: Anuj Phogat <[email protected]>
* mesa: silence unused var warning in get_tex_rgba_uncompressed()Brian Paul2015-02-271-1/+2
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Fixed _mesa_GetCompressedTexImage_sw to copy slices correctly.Laura Ekstrand2015-02-171-2/+2
| | | | | | | | | | | Previously array textures were not working with GetCompressedTextureImage, leading to failures in the test arb_direct_state_access/getcompressedtextureimage.c. Tested-by: Laura Ekstrand <[email protected]> Reviewed-by: Brian Paul <[email protected]> Cc: "10.4, 10.5" <[email protected]>
* mesa: silence uninitialized var warning in get_tex_rgba_uncompressed()Brian Paul2015-02-161-2/+1
| | | | Reviewed-by: Matt Turner <[email protected]>
* mesa: Fix element count for byte-swaps in texstore, readpix and texgetimageIago Toral Quiroga2015-02-161-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some old format conversion code in pack.c implemented byte-swapping like this: GLint comps = _mesa_components_in_format(dstFormat); GLint swapSize = _mesa_sizeof_packed_type(dstType); if (swapSize == 2) _mesa_swap2((GLushort *) dstAddr, n * comps); else if (swapSize == 4) _mesa_swap4((GLuint *) dstAddr, n * comps); where n is the pixel count. But this is incorrect for packed formats, where _mesa_sizeof_packed_type is already returning the size of a pixel instead of the size of a single component, so multiplying this by the number of components in the format results in a larger element count for _mesa_swap than we want. Unfortunately, we followed the same implementation for byte-swapping in the rewrite of the format conversion code for texstore, readpixels and texgetimage. This patch computes the correct element counts for _mesa_swap calls by computing the bytes per pixel in the image and dividing that by the swap size to obtain the number of swaps required per pixel. Then multiplies that by the number of pixels in the image to obtain the swap count that we need to use. Also, when handling byte-swapping in texstore_rgba, we were ignoring the image's depth. This patch fixes this too. Reviewed-by: Jason Ekstrand <[email protected]> Cc: "10.5" <[email protected]>
* mesa: Fix some signed-unsigned comparison warningsJan Vesely2015-01-211-3/+3
| | | | | | | | v2: s/unsigned int/unsigned/ in prog_optimize.c Signed-off-by: Jan Vesely <[email protected]> Reviewed-by: David Heidelberg <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
* mesa: rename RGBA8888_* format constants to something appropriate.Iago Toral Quiroga2015-01-141-2/+2
| | | | | | | | The 8888 suggests 8-bit components which is not correct, so replace that with the actual size of the components in each format. Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Use _mesa_format_convert to implement get_tex_rgba_compressed.Iago Toral Quiroga2015-01-121-39/+34
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: use _mesa_format_convert to implement get_tex_rgba_uncompressed.Iago Toral Quiroga2015-01-121-117/+133
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: fix MSVC compilation errorsBrian Paul2015-01-081-5/+5
| | | | | | Move assertions after declarations and don't use void pointer arithmetic. Reviewed-by: Jose Fonseca <[email protected]>