aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/glformats.c
Commit message (Collapse)AuthorAgeFilesLines
* mesa/glformats: refactor compressed format support functionNanley Chery2015-09-191-79/+40
| | | | | | | | | | | Instead of case statements, use _mesa_get_format_layout() to determine if a GL format is part of a family of compressed formats. v2. restrict LATC formats to API_OPENGL_COMPAT (Ilia). rename the variable mFormat to m_format. Reviewed-by: Anuj Phogat <[email protected]> Signed-off-by: Nanley Chery <[email protected]>
* mesa: fix errors when reading depth with glReadPixelsTapani Pälli2015-09-181-1/+6
| | | | | | | | | | | | | | | | | | | | | | | OpenGL ES 3.0 spec 3.7.2 "Transfer of Pixel Rectangles" specifies DEPTH_COMPONENT, UNSIGNED_INT as a valid couple, validation for internal format is checked by is_float_depth(). Fix regression caused by 81d2fd91a90e5b2fd9fd74792a7a7c329f0e4d29 in: ES3-CTS.gtf.GL3Tests.packed_pixels.packed_pixels Test uses GL_DEPTH_COMPONENT, UNSIGNED_INT only when GL_NV_read_depth extension is present. v2: change check in _mesa_error_check_format_and_type to be explicit for ES 2.0+, desktop OpenGL does not allow this behaviour + uses this function for both glReadPixels and glDrawPixels validation. (No Piglit regressions seen with v2.) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Anuj Phogat <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> [v1] Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92009 Cc: "10.6 11.0" <[email protected]>
* mesa/formats: 8-bit channel integer formats additionDave Airlie2015-09-021-0/+8
| | | | | | | | | Add enough 8-bit channel formats to handle all the different things CTS throws at us. Cc: "11.0" <[email protected]> Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* mesa/formats: add some formats from GL3.3Dave Airlie2015-09-021-0/+24
| | | | | | | | | | | | | | | | GL3.3 added GL_ARB_texture_rgb10_a2ui, which specifies a lot more things than just rgb10/a2ui. While playing with ogl conform one of the tests must attempted all valid formats for GL3.3 and hits the unreachable here. This adds the first chunk of formats that hit the assert. Cc: "11.0" <[email protected]> Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* mesa/glformats: recognize ASTC formats as color formatsNanley Chery2015-08-311-0/+28
| | | | | | | ASTC formats contain RGBA components. Reviewed-by: Chad Versace <[email protected]> Signed-off-by: Nanley Chery <[email protected]>
* mesa/glformats: recognize ASTC formats as compressedNanley Chery2015-08-261-0/+29
| | | | | Reviewed-by: Anuj Phogat <[email protected]> Signed-off-by: Nanley Chery <[email protected]>
* mesa: don't enable online compression for ASTC formatsNanley Chery2015-08-261-0/+41
| | | | | | | | | | | | | In agreement with the ASTC spec, this makes calls to TexImage*D unsuccessful. Implied by the spec, Generate[Texture]Mipmap and [Copy]Tex[Sub]Image*D calls must be unsuccessful as well. v2. actually force attempts to compress online to fail. v3. indentation (Matt). v4. update copytexture_error_check to account for CopyTexImage*D (Chad). Reviewed-by: Chad Versace <[email protected]> Signed-off-by: Nanley Chery <[email protected]>
* mesa/formats: don't byteswap when building array formatsOded Gabbay2015-08-121-11/+3
| | | | | | | | | | | | | Because we build here an array format, we don't need to swap the bytes for big endian. If it isn't an array format, the bytes will be swapped in _mesa_format_convert. v2: remove temp variable Signed-off-by: Oded Gabbay <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Cc: "10.5 10.6" <[email protected]>
* mesa: Fix typo in a commentAnuj Phogat2015-07-241-1/+1
| | | | Signed-off-by: Anuj Phogat <[email protected]>
* mesa: Add a helper function _mesa_unpack_format_to_base_format()Anuj Phogat2015-07-241-0/+44
| | | | | Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* mesa: Rename _mesa_lookup_enum_by_nr() to _mesa_enum_to_string().Kenneth Graunke2015-07-201-3/+3
| | | | | | | Generated by sed; no manual changes. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: add GL_RED, GL_RG support for floating point texturesTapani Pälli2015-06-101-3/+34
| | | | | | | | | | | | | | | | | Mesa supports EXT_texture_rg and OES_texture_float. This patch adds support for using unsized enums GL_RED and GL_RG for floating point targets and writes proper checks for internalformat when format is GL_RED or GL_RG and type is of GL_FLOAT or GL_HALF_FLOAT. Later, internalformat will get adjusted by adjust_for_oes_float_texture after these checks. v2: simplify to check vs supported enums v3: follow the style and break out if internalFormat ok (Kenneth) Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90748 Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: allow unsized formats GL_RG, GL_RED for GLES 3.0 with half floatTapani Pälli2015-06-101-0/+4
| | | | | | | | v2: && -> ||, we enable on gles3 or if ARB_texture_rg is enabled Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90748 Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: add const qualifer on _mesa_is_compressed_format()Brian Paul2015-05-261-1/+1
| | | | Reviewed-by: Topi Pohjolainen <[email protected]>
* main: replace __FUNCTION__ with __func__Marius Predut2015-04-141-1/+1
| | | | | | | | | | | Consistently just use C99's __func__ everywhere. The patch was verified with Microsoft Visual studio 2013 redistributable package(RTM version number: 18.0.21005.1) Next MSVC versions intends to support __func__. No functional changes. Acked-by: Matt Turner <[email protected]> Signed-off-by: Marius Predut <[email protected]>
* Mesa: Add support for HALF_FLOAT_OES type.Kalyan Kondapally2015-01-291-4/+43
| | | | | | | | | This patch adds needed support for accepting HALF_FLOAT_OES as valid type for TexImage*D and TexSubImage*D when Texture FLoat extensions are supported. Signed-off-by: Kevin Rogovin <[email protected]> Signed-off-by: Kalyan Kondapally <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* mesa: change assert to unreachable in two format functionsTobias Klausmann2015-01-211-1/+1
| | | | | | | | | | This fixes two problems reported by osc: I: Program returns random data in a function E: Mesa no-return-in-nonvoid-function ../../src/mesa/main/format_utils.c:180 E: Mesa no-return-in-nonvoid-function ../../src/mesa/main/glformats.c:2714 Reviewed-by: Matt Turner <[email protected]> Signed-off-by: Tobias Klausmann <[email protected]>
* mesa: support GL_RGB for GL_EXT_texture_type_2_10_10_10_REVTapani Pälli2015-01-191-0/+2
| | | | | | | | | | | | | | | | | Commit 8ec6534 changed texture upload path and the way how texture format is being checked, this commit adds support for GL_RGB with GL_UNSIGNED_INT_2_10_10_10_REV as specified by the extension EXT_texture_type_2_10_10_10_REV specification. This fixes regression in ES3 conformance test ES3-CTS.gtf.GL3Tests.packed_pixels.packed_pixels v2: add MESA_FORMAT_R10G10B10X2_UNORM format (Iago Toral) Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88385 Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* mesa: restrict use of GL_ABGR_EXT format to allowed data typesSamuel Iglesias Gonsalvez2015-01-121-15/+46
| | | | | | | | | | | | | GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV data types are not explicitly allowed to work with GL_ABGR_EXT format neither in GL nor GL_EXT_abgr specs. Removed the corresponding mesa formats as there are no other functions using them inside Mesa anymore. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Add helper to convert a GL format and type to a mesa (array) format.Iago Toral Quiroga2015-01-121-0/+277
| | | | | | | | | | | | v2 after review by Jason Ekstrand: - Move _mesa_format_from_format_and_type to glformats - Return a mesa_format for GL_UNSIGNED_INT_8_8_8_8(_REV) v3: - Adapted to the new implementation of mesa_array_format as a plain uint32_t bitfield. Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Expose compute_component_mapping as _mesa_compute_component_mappingIago Toral Quiroga2015-01-121-0/+197
| | | | | | | | | | | | | | This is necessary to handle conversions between array types where the driver does not support the dst format requested by the client and chooses a different format instead. We will need this in _mesa_format_convert, so move it to format_utils.c, prefix it with '_mesa_' and make it available to other files. v2: - Move _mesa_compute_component_mapping to glformats Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Add the format enums for BPTC-compressed imagesNeil Roberts2014-08-121-0/+10
| | | | | | | | | | | | | | | | | | This adds the following four Mesa image format enums which correspond to the four BPTC compressed texture formats: MESA_FORMAT_BPTC_RGBA_UNORM MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT It also updates the format information functions to handle these and the corresponding GL enums. v2: Also modify _mesa_get_format_color_encoding, _mesa_get_srgb_format_linear and _mesa_get_uncompressed_format Reviewed-by: Ian Romanick <[email protected]>
* mesa: Add utility function _mesa_is_enum_format_unorm()Anuj Phogat2014-08-041-0/+71
| | | | | | | | V2: Add missing formats. Cc: <[email protected]> Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Add a helper function _mesa_is_enum_format_unsized()Anuj Phogat2014-08-041-0/+56
| | | | | | | | | | Function is utilized by next patch in the series. V2: Add missing formats. Cc: <[email protected]> Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Add utility function _mesa_is_enum_format_snorm()Anuj Phogat2014-08-041-0/+37
| | | | | | Cc: <[email protected]> Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* Remove the ATI_envmap_bumpmap extensionJason Ekstrand2014-06-301-35/+0
| | | | | | | | | | | As far as I can tell, the Intel mesa driver is the only driver in the world still supporting this legacy extension. If someone wants to do bump mapping, they can use shaders. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> [v1] Reviewed-by: Chris Forbes <[email protected]> [v2] Reviewed-by: Ian Romanick <[email protected]> [v3]
* Remove _mesa_is_type_integer and _mesa_is_enum_format_or_type_integerNeil Roberts2014-06-131-30/+0
| | | | | | | | | | | | | | | | | | | | | | | The comment for _mesa_is_type_integer is confusing because it says that it returns whether the type is an “integer (non-normalized)” format. I don't think it makes sense to say whether a type is normalized or not because it depends on what format it is used with. For example, GL_RGBA+GL_UNSIGNED_BYTE is normalized but GL_RGBA_INTEGER+GL_UNSIGNED_BYTE isn't. If the normalized comment is just a mistake then it still doesn't make much sense because it is missing the packed-pixel types such as GL_UNSIGNED_INT_5_6_5. If those were added then it effectively just returns type != GL_FLOAT. That function was only used in _mesa_is_enum_format_or_type_integer. This function effectively checks whether the format is non-normalized or the type is an integer. I can't think of any situation where that check would make sense. As far as I can tell neither of these functions have ever been used anywhere so we should just remove them to avoid confusion. These functions were added in 9ad8f431b2a47060bf05517246ab0fa8d249c800. Reviewed-by: Brian Paul <[email protected]>
* mesa: Fix error code generation in glReadPixels()Anuj Phogat2014-04-211-0/+16
| | | | | | | | | | | | | | | | | | | | Section 4.3.1, page 220, of OpenGL 3.3 specification explains the error conditions for glreadPixels(): "If the format is DEPTH_STENCIL, then values are taken from both the depth buffer and the stencil buffer. If there is no depth buffer or if there is no stencil buffer, then the error INVALID_OPERATION occurs. If the type parameter is not UNSIGNED_INT_24_8 or FLOAT_32_UNSIGNED_INT_24_8_REV, then the error INVALID_ENUM occurs." Fixes failing Khronos CTS test packed_depth_stencil_error.test V2: Avoid code duplication Cc: <[email protected]> Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: GL_ARB_half_float_pixel is not optionalIan Romanick2014-02-111-18/+6
| | | | | | | | | | | | | | | | | Almost every driver already supported it. All current and future Gallium drivers always support it, and most existing classic drivers support it. This only changes radeon and nouveau. This extension only adds data types that can be passed to, for example, glTexImage2D. It does not add internal formats. Since you can already pass GL_FLOAT to glTexImage2D this shouldn't pose any additional issues with those drivers. Note that r200 and i915 already supported this extension, and they don't support floating-point textures either. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: whitespace fixes in glformats.cBrian Paul2014-01-231-75/+51
| | | | | | | Reindent _mesa_get_nongeneric_internalformat() to match other functions. Remove extraneous empty lines in _mesa_get_linear_internalformat(). Trivial.
* mesa: fix/add some cases in _mesa_get_linear_internalformat()Brian Paul2014-01-231-1/+7
| | | | | | | | In some cases we were converting generic formats to sized formats and vice versa. The point is to simply convert sRGB formats to corresponding linear formats. Reviewed-by: Marek Olšák <[email protected]>
* mesa: Clean up bad code formatting left from previous commitIan Romanick2013-12-201-1/+1
| | | | | | | Also s/_EXT// on enums that are now part of core. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: GL_EXT_packed_depth_stencil is not optionalIan Romanick2013-12-201-5/+1
| | | | | | | | Every driver supports it. All current and future Gallium drivers always support it, and all existing classic drivers support it. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: minor simplification in _mesa_es3_error_check_format_and_type()Brian Paul2013-12-181-3/+1
| | | | The type_valid local was set to true and never changed.
* mesa: Add support to _mesa_bytes_per_vertex_attrib for 10_11_11 format.Chris Forbes2013-11-081-0/+5
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: Restore 78-column wrapping of license text in C-style comments.Kenneth Graunke2013-04-231-3/+4
| | | | | | | | | | | | | | The previous commit introduced extra words, breaking the formatting. This text transformation was done automatically via the following shell command: $ git grep 'THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY' | sed 's/:.*$//' | xargs -I {} sh -c 'vim -e -s {} < vimscript where 'vimscript' is a file containing: /THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY/;/\*\// !fmt -w 78 -p ' * ' :wq Reviewed-by: Brian Paul <[email protected]>
* mesa: Add "OR COPYRIGHT HOLDERS" to license text disclaiming liability.Kenneth Graunke2013-04-231-1/+1
| | | | | | | | | | | | | | | This brings the license text in line with the MIT License as published on the Open Source Initiative website: http://opensource.org/licenses/mit-license.php Generated automatically be the following shell command: $ git grep 'THE AUTHORS BE LIABLE' | sed 's/:.*$//g' | xargs -I '{}' \ sed -i 's/THE AUTHORS/THE AUTHORS OR COPYRIGHT HOLDERS/' {} This introduces some wrapping issues, to be fixed in the next commit. Reviewed-by: Brian Paul <[email protected]>
* mesa: Allow ETC2/EAC formats with ARB_ES3_compatibility.Matt Turner2013-03-081-1/+1
| | | | | | Fixes piglit's oes_compressed_etc2_texture-miptree tests on Desktop GL. Reported-by: Marek Olšák <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* Revert "mesa: Return INVALID_OPERATION when type is known but not allowed"Matt Turner2013-01-301-11/+1
| | | | | | | | | | | | This reverts commit 2906e2034c9d674601960a5b586b6e986e6ef04f. Fixes a regression in the glean depthStencil test. Reverting this does not affect any tests in es3conform, so a more recent patch must have also fixed the failure this one was intended to fix. Reported-by: lu hua <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59494
* mesa: Like EXT_texture_compression_dxt1, advertise ↵Ian Romanick2013-01-231-5/+3
| | | | | | | | | | | | | | | ANGLE_texture_compression_dxt in all APIs This is technically outside the ANGLE spec, but it seems unlikely to cause any harm. v2: Simplify the extension checks by assuming the ANGLE extension will always be enabled by any driver that enables the EXT. Suggested by Eric Anholt. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Lee Salzman <[email protected]>
* mesa: Use a single flag for the S3TC extensions that don't require on-line ↵Ian Romanick2013-01-231-1/+2
| | | | | | | | compression Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Acked-by: Lee Salzman <[email protected]>
* mesa/es3: Allow unsized depth and depth-stencil formats in ES3Ian Romanick2013-01-201-2/+5
| | | | | | | | | They're part of GL_OES_depth_texture_cube_map, and we'll always enable that extension in ES3 contexts. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa/es3: Don't check dimensions in _mesa_es3_error_check_format_and_typeIan Romanick2013-01-171-8/+1
| | | | | | | | | | Filtering of DEPTH_COMPONENT and DEPTH_STENCIL for TEXTURE_3D is already done in texture_error_check because these combinations aren't allowed on desktop GL either. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* mesa: Return INVALID_OPERATION when type is known but not allowedMatt Turner2013-01-151-1/+11
| | | | | | | | INVALID_ENUM is for when the type is simply not known. Fixes part of es3conform's packed_depth_stencil_error test. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glformats: allow GL_RGB+GL_UNSIGNED_INT_2_10_10_10_REV for GLES2/3Jordan Justen2013-01-141-0/+8
| | | | | | | | This format is allowed by the GL_EXT_texture_type_2_10_10_10_REV extension. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glformats: add _mesa_es3_error_check_format_and_typeMatt Turner2013-01-141-0/+439
| | | | | | | | | This function checks for ES3 compatible format/type/internalFormat/dimension combinations. [[email protected]: additional tweaks for gles3-gtf] Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glformats: support _mesa_bytes_per_pixel for 2101010+GL_RGBJordan Justen2013-01-121-1/+2
| | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glformats: add _mesa_base_format_component_countJordan Justen2013-01-121-0/+26
| | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glformats: add functions to detect signed/unsigned integer typesJordan Justen2013-01-121-14/+40
| | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Fix computation of default vertex attrib stride for 2_10_10_10 formats.Paul Berry2012-12-131-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, if the client program didn't specify a stride when setting up a vertex attribute, we used _mesa_sizeof_type() to compute the size of the type, and multiplied it by the number of components. This didn't work for the 2_10_10_10 formats, since _mesa_sizeof_type() returns -1 for those types, resulting in all kinds of havoc, since it was causing the hardware to be programmed with a negative stride value. This patch adds a new function _mesa_bytes_per_vertex_attrib(), which is similar to the existing function _mesa_bytes_per_pixel(), but which computes the size of a vertex attribute based on the type and the number of formats. For packed formats (currently only the 2_10_10_10 formats), it verifies that the number of components is correct and returns the size of the packed format. For unpacked formats, it returns the size of the type times the number of components. In addition, this patch adds an assertion so that if we ever forget to update _mesa_bytes_per_vertex_attrib() when adding a new vertex format, we'll see the problem quickly rather than having to debug a subtle conformance test failure. Fixes GLES3 conformance tests vertex_type_2_10_10_10_rev_{conversion,divisor,stride_pointer}.test. Reviewed-by: Brian Paul <[email protected]>