summaryrefslogtreecommitdiffstats
path: root/src/mesa
Commit message (Collapse)AuthorAgeFilesLines
* mesa: Add a helper _mesa_compute_rgba2base2rgba_component_mappingIago Toral Quiroga2015-01-122-0/+58
| | | | | | | This will come in handy when callers of _mesa_format_convert need to compute the rebase swizzle parameter to use. Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Add a rebase_swizzle parameter to _mesa_format_convertIago Toral Quiroga2015-01-122-70/+171
| | | | | | | | | | | | | | | | | | | | | The new parameter allows callers to provide a rebase swizzle that the function needs to use to match the requirements of the base internal format involved. This is necessary when the source or destination internal formats (depending on whether we are doing the conversion for a pixel download or a pixel upload respectively) do not match the base formats of the source or destination formats of the conversion. This can happen when the driver does not support the internal formats and uses a different format to store pixel data internally. For example, a texture upload from RGB to Luminance in a driver that does not support textures with a Luminance format may decide to store the Luminance data as RGBA. In this case we want to store the RGBA values as (R,R,R,1). Following the same example, when we download from that texture to RGBA we want to read (R,0,0,1). The rebase_swizzle parameter allows these transforms to happen. Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Expose compute_component_mapping as _mesa_compute_component_mappingIago Toral Quiroga2015-01-123-207/+209
| | | | | | | | | | | | | | 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 an implementation of a master convert function.Jason Ekstrand2015-01-122-0/+418
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | v2 by Iago Toral <[email protected]>: - When testing if we can directly pack we should use the src format to check if we are packing from an RGBA format. The original code used the dst format for the ubyte case by mistake. - Fixed incorrect number of bits for dst, it was computed using the src format instead of the dst format. - If the dst format is an array format, check if it is signed. We were only checking this for the case where it was not an array format, but we need to know this in both scenarios. - Fixed incorrect swizzle transform for the cases where we convert between array formats. - Compute is_signed and bits only once and for the dst format. We were computing these for the src format too but they were overwritten by the dst values immediately after. - Be more careful when selecting the integer path. Specifically, check that both src and dst are integer types. Checking only one of them should suffice since OpenGL does not allow conversions between normalized and integer types, but putting extra care here makes sense and also makes the actual requirements for this path more clear. - The format argument for pack functions is the destination format we are packing to, not the source format (which has to be RGBA). - Expose RGBA8888_* to other files. These will come in handy when in need to test if a given array format is RGBA or in need to pass RGBA formats to mesa_format_convert. v3 by Samuel Iglesias <[email protected]>: - Add an RGBA8888_INT definition. v4 by Iago Toral <[email protected]> after review by Jason Ekstrand: - Added documentation for _mesa_format_convert. - Added additional explanatory comments for integer conversions. - Ensure that we use _messa_swizzle_and_convert for all signed source formats. - Squashed: do not directly (un)pack to RGBA UINT if the source is not unsigned. v5 by Iago Toral <[email protected]>: - Adapted to the new implementation of mesa_array_format as a plain uint32_t bitfield. Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/pack: refactor _mesa_pack_rgba_span_float()Samuel Iglesias Gonsalvez2015-01-122-1166/+153
| | | | | | | | | | | Use autogenerated format pack functions and take advantage of some macros to reduce source code, facilitating its maintenance. Unfortunately, dstType == GL_UNSIGNED_SHORT cannot simplified like the others, so keep it as it is. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/main/pack_tmp.h: Add float conversion supportSamuel Iglesias Gonsalvez2015-01-121-1/+74
| | | | | | | We will use this in a later patch to refactor _mesa_pack_rgba_span_float. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/pack: use autogenerated format_pack functionsSamuel Iglesias Gonsalvez2015-01-121-525/+138
| | | | | | | | | Take advantage of new mesa formats and new format_pack functions to reduce source code in _mesa_pack_rgba_span_from_ints() and _mesa_pack_rgba_span_from_uints(). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: use format conversion functions in swrastSamuel Iglesias Gonsalvez2015-01-121-1237/+122
| | | | | | | | This commit adds a macro to facilitate the task of using format conversions functions but keeps the same API. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/formats: add new mesa formats and their pack/unpack functions.Samuel Iglesias Gonsalvez2015-01-125-1/+145
| | | | | | | | | | | | | This will be used to refactor code in pack.c and support conversion to/from these types in a master convert function that will be added later. v2: - Fix autogeneration of MESA_FORMAT_A2R10G10B10_UNORM pack/unpack functions Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/format_pack: Add _mesa_pack_int_rgba_row()Samuel Iglesias Gonsalvez2015-01-122-0/+88
| | | | | | | | | | | | | | | | | | | | This will be used to unify code in pack.c. v2: - Modify pack_int_*() function generator to use c.datatype() and f.datatype() v3: - Only autogenerate pack_int_*() functions for non-normalized integer formats. v4: - Use _mesa_unsigned_to_unsigned() in pack_int_*() because, in order to be able to pack both signed and unsigned formats, we need to sign-extend. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Add _mesa_pack_uint_rgba_row() format conversion functionSamuel Iglesias Gonsalvez2015-01-122-0/+87
| | | | | | | | | | | | | | | | | | We will use this later on to handle uint conversion scenarios in a master convert function. v2: - Modify pack_uint_*() function generation to use c.datatype() and f.datatype(). - Remove UINT_TO_FLOAT() macro usage from pack_uint*() - Remove "if not f.is_normalized()" conditional as pack_uint*() functions are only autogenerated for non normalized formats. v3: - Add clamping for non-normalized integer formats in pack_uint*() Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Autogenerate format_unpack.cJason Ekstrand2015-01-126-4396/+915
| | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Jason Ekstrand <[email protected]> v2 by Samuel Iglesias <[email protected]>: - Add usage of INDENT_FLAGS in Makefile.am v3 by Samuel Iglesias <[email protected]>: - Modify unpack_float_*() and unpack_ubyte_*() function generation to use c.datatype() and f.datatype() - Fix out-of-tree build v4 by Samuel Iglesias <[email protected]>: - format_unpack.c.mako is now format_unpack.py, with the template code inlined. It now auto-generates format_unpack.c - Add format_unpack.c to gitignore. - Simplify Makefile.am change - Modify SConscript to build format_unpack.c with scons v5 by Samuel Iglesias <[email protected]>: - Don't allow float to non-normalized integer format conversions. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Autogenerate most of format_pack.cJason Ekstrand2015-01-127-2983/+985
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were auto-generating it before. The problem was that the autogeneration tool we were using was called "copy, paste, and edit". Let's use a more sensible solution. Signed-off-by: Jason Ekstrand <[email protected]> v2 by Samuel Iglesias <[email protected]> - Remove format_pack.c as it is now autogenerated - Add usage of INDENT_FLAGS in Makefile.am - Remove trailing blank line v3 by Samuel Iglesias <[email protected]> - Merge format_convert.py into format_parser.py - Adapt pack_*_* function generations - Fix out-of-tree build v4 by Samuel Iglesias <[email protected]> - _get_datatype() is now a helper function v5 by Samuel Iglesias <[email protected]> - format_pack.c.mako is now format_pack.py, with the template code inlined. It now auto-generates format_pack.c - Simplify Makefile.am change. - Modify SConscript to build format_pack.c with scons. - Remove run_mako.py - Add format_pack.c to gitignore v6 by Samuel Iglesias <[email protected]>: - Don't allow float to non-normalized integer format conversions. - Add non-normalized formats support for ubyte packing functions. Merge the previously separated patch. - Add clamping for non-normalized integer formats in pack_ubyte*() v7 by Samuel Iglesias <[email protected]>: - Add assert to check that sRGB formats are 8-bit size. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Add a _mesa_is_format_color_format helperJason Ekstrand2015-01-122-0/+22
| | | | | Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* mesa: Let _mesa_get_format_base_format also handle mesa_array_format.Iago Toral Quiroga2015-01-122-4/+74
| | | | | | | | | | | | | | | | | | | | | | If we need the base format for a mesa_array_format we have to find the matching mesa_format first. This is expensive because it requires to loop through all existing mesa formats until we find the right match. We can resolve the base format of an array format directly by looking at its swizzle information. Also, we can have _mesa_get_format_base_format accept an uint32_t which can pack either a mesa_format or a mesa_array_format and resolve the base format for either type. This way clients do not need to check if they have a mesa_format or a mesa_array_format and call different functions depending on the case. Another reason to resolve the base format for array formats directly is that we don't have matching mesa_format enums for every possible array format, so for some GL format/type combinations we can produce array formats that don't have a corresponding mesa format, in which case we would not be able to find the base format. Example format=GL_RGB, type=GL_UNSIGNED_SHORT. This type would map to something like MESA_FORMAT_RGB_UNORM16, but we don't have that. Reviewed-by: Jason Ekstrand <[email protected]>
* main: Add a concept of an array formatJason Ekstrand2015-01-123-1/+209
| | | | | | | | | | | | | | | | | | | | An array format is a 32-bit integer format identifier that can represent any format that can be represented as an array of standard GL datatypes. Whie the MESA_FORMAT enums provide several of these, they don't account for all of them. v2 by Iago Toral Quiroga <[email protected]>: - Implement mesa_array_format as a plain bitfiled uint32_t type instead of using a struct inside a union to access the various components packed in it. This is necessary to support bigendian properly, as pointed out by Ian. - Squashed: Make float types normalized v3 by Iago Toral Quiroga <[email protected]>: - Include compiler.h in formats.h, which is necessary to build in MSVC as indicated by Brian Paul. Reviewed-by: Jason Ekstrand <[email protected]>
* swrast: Remove unused variable.Iago Toral Quiroga2015-01-121-3/+0
| | | | | Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Fix _mesa_swizzle_and_convert integer conversions to clamp properlySamuel Iglesias Gonsalvez2015-01-122-53/+94
| | | | | | | | | | | | | | | | | | | | | | | | | Fix various conversion paths that involved integer data types of different sizes (uint16_t to uint8_t, int16_t to uint8_t, etc) that were not being clamped properly. Also, one of the paths was incorrectly assigning the value 12, instead of 1, to the constant "one". v2: - Create auxiliary clamping functions and use them in all paths that required clamp because of different source and destination sizes and signed-unsigned conversions. v3: - Create MIN_INT macro and use it. v4: - Add _mesa_float_to_[un]signed() and mesa_half_to_[un]signed() auxiliary functions. - Add clamp for float-to-integer conversions in _mesa_swizzle_and_convert() Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/format_utils: Prefix and expose the conversion helper functionsJason Ekstrand2015-01-122-161/+159
| | | | | | | | | | | Signed-off-by: Jason Ekstrand <[email protected]> v2 by Samuel Iglesias <[email protected]>: - Fix compilation errors Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Fix incorrect assertion in init_teximage_fields_msIago Toral Quiroga2015-01-121-1/+1
| | | | | | | | | | | | | | | | _BaseFormat is a GLenum (unsigned int) so testing if its value is greater than 0 to detect the cases where _mesa_base_tex_format returns -1 doesn't work. Fixing the assertion breaks the arb_texture_view-lifetime-format piglit test on nouveau, since that test calls _mesa_base_tex_format with GL_R16F with a context that does not have ARB_texture_float, so it returns -1 for the BaseFormat, which was not being caught properly by the ASSERT in init_teximage_fields_ms until now. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Fix get_texbuffer_format().Samuel Iglesias Gonsalvez2015-01-121-2/+2
| | | | | | | | | We were returning incorrect mesa formats for GL_LUMINANCE_ALPHA16I_EXT and GL_LUMINANCE_ALPHA32I_EXT. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: Fix A1R5G5B5 packing/unpackingJason Ekstrand2015-01-124-19/+11
| | | | | | | | As with B5G6R5, these have been left broken with comments saying they are. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa/colormac: Remove an unused macroJason Ekstrand2015-01-121-3/+0
| | | | | | | | | The PACK_565_REV macro is no longer used. It was also extremely confusing because it's actually a byteswapped 565 not reversed 565. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Fix packing/unpacking of MESA_FORMAT_R5G6B5_UNORMJason Ekstrand2015-01-126-27/+18
| | | | | | | | | | | | | | Aparently, the packing/unpacking functions for these formats have differed from the format description in formats.h. Instead of fixing this, people simply left a comment saying it was broken. Let's actually fix it for real. v2 by Samuel Iglesias <[email protected]>: - Fix comment in formats.h Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* mesa: Fix clamping to -1.0 in snorm_to_floatJason Ekstrand2015-01-121-1/+1
| | | | | | | | | | | | | This patch fixes the return of a wrong value when x is lower than -MAX_INT(src_bits) as the result would not be between [-1.0 1.0]. v2 by Samuel Iglesias <[email protected]>: - Modify snorm_to_float() to avoid doing the division when x == -MAX_INT(src_bits) Cc: 10.4 <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* i965: Respect the no_8 flag on Gen6, not just Gen7+.Kenneth Graunke2015-01-121-2/+2
| | | | | | | | | | | | | | | When doing repclears, we only want to use the SIMD16 program, not the SIMD8 one. Kristian added this to the Gen7+ code, but apparently we missed it in the Gen6 code. This patch copies that code over. Approximately doubles the performance in a clear microbenchmark from mesa-demos (clearspd -width 500 -height 500 +color) on Sandybridge. Cc: "10.4 10.3" <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]> Reviewed-by: Matt Turner <[email protected]> References: https://code.google.com/p/chrome-os-partner/issues/detail?id=34681
* mesa: Always generate GL_INVALID_OPERATION in _mesa_GetProgramBinaryIan Romanick2015-01-121-0/+2
| | | | | | | | | | | There are no binary formats supported, so what are you doing? At least this gives the application developer some feedback about what's going on. The spec gives no guidance about what to do in this scenario. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87516 Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Leight Bade <[email protected]>
* mesa: Ensure that length is set to zero in _mesa_GetProgramBinaryIan Romanick2015-01-121-6/+20
| | | | | | | | | v2: Fix assignment of length. Noticed by Julien Cristau. Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87516 Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Leight Bade <[email protected]>
* mesa: Add missing error checks in _mesa_ProgramBinaryIan Romanick2015-01-121-2/+25
| | | | | | | Signed-off-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87516 Reviewed-by: Kenneth Graunke <[email protected]> Acked-by: Leight Bade <[email protected]>
* state_tracker: Fix assertion failures in conditional block movs.Eric Anholt2015-01-101-31/+26
| | | | | | | | | | | | | If you had a conditional assignment of an array or struct (say, from the if-lowering pass), we'd try doing swizzle_for_size() on the aggregate type, and it would assertion fail due to vector_elements==0. Instead, extend emit_block_mov() to handle emitting the conditional operations, which also means we'll have appropriate writemasks/swizzles on the CMPs within a struct containing various-sized members. Fixes 20 testcases in es3conform on vc4. Reviewed-by: Jose Fonseca <[email protected]>
* i965: Consider SEL.{GE,L} to be commutative operations.Matt Turner2015-01-082-10/+27
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* i965/cfg: Fix end_ip of last basic block.Matt Turner2015-01-081-1/+1
| | | | | | | start_ip and end_ip are inclusive. Increases instruction counts in 64 shaders in shader-db, likely indicative of them previously being misoptimized.
* mesa: compute row stride outside of loop and fix MSVC compilation errorBrian Paul2015-01-081-2/+4
| | | | | | Can't do void pointer arithmetic with MSVC. Reviewed-by: Jose Fonseca <[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]>
* main: Checking for cube completeness in TextureSubImage.Laura Ekstrand2015-01-081-13/+35
| | | | | | | | This is part of a potential solution to a spec bug. Cube completeness is a concept from glGenerateMipmap, but it seems reasonable to check for it in TextureSubImage when target=GL_TEXTURE_CUBE_MAP. Reviewed-by: Anuj Phogat <[email protected]>
* main: Checking for cube completeness in GetTextureImage.Laura Ekstrand2015-01-081-12/+35
| | | | | | | | This is part of a potential solution to a spec bug. Cube completeness is a concept from glGenerateMipmap, but it seems reasonable to check for it in GetTextureImage when the target is GL_TEXTURE_CUBE_MAP. Reviewed-by: Anuj Phogat <[email protected]>
* main: Added _mesa_cube_level_complete to check for the completeness of an ↵Laura Ekstrand2015-01-082-9/+18
| | | | | | arbitrary cube map level. Reviewed-by: Chad Versace <[email protected]>
* main: glDeleteTextures now throws GL_INVALID_VALUE if n is negative.Laura Ekstrand2015-01-081-0/+5
| | | | | | This is in conformance with the OpenGL spec. Reviewed-by: Anuj Phogat <[email protected]>
* main: Refactor in teximage.c to handle NULL from _mesa_get_current_tex_object.Laura Ekstrand2015-01-081-0/+22
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Added entry point for glTextureBuffer.Laura Ekstrand2015-01-083-16/+86
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Fix texObj->Immutable flag update in _mesa_texture_image_multisample.Laura Ekstrand2015-01-081-1/+1
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Added entry points for glTextureStorage[23]DMultisample.Laura Ekstrand2015-01-083-28/+118
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Added entry point for glGenerateTextureMipmap.Laura Ekstrand2015-01-083-20/+58
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Added entry points for glCompressedTextureSubImage*D.Laura Ekstrand2015-01-083-52/+220
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Added entry point for glGetCompressedTextureImage.Laura Ekstrand2015-01-083-45/+134
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Added entry point for glGetTextureImage.Laura Ekstrand2015-01-083-66/+240
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Nameless texture creation and deletion. Does not affect normal ↵Laura Ekstrand2015-01-082-0/+69
| | | | | | | | | | | | | | | | | | | | creation and deletion paths. In implementing ARB_DIRECT_STATE_ACCESS functions, it is often necessary to abstract the functionality of a traditional GL API function into a backend that both the traditional and dsa API functions can share. For instance, glTexParameteri and glTextureParameteri both call _mesa_texture_parameteri, which takes a context object and a texture object as arguments. The existance of such backend functions provides the opportunity for driver internals (such as meta) to pass around the actual texture object rather than its ID or target, saving on texture object storage and look-up overhead. This patch provides nameless texture creation and deletion for meta. This will be used in an upcoming refactor of meta. Reviewed-by: Anuj Phogat <[email protected]>
* main: Added entry points for CopyTextureSubImage*D.Laura Ekstrand2015-01-083-48/+151
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Fixed some comments in texparam.cLaura Ekstrand2015-01-081-2/+2
| | | | Reviewed-by: Anuj Phogat <[email protected]>
* main: Added entry points for glGetTextureParameteriv, Iiv, and Iuiv.Laura Ekstrand2015-01-083-34/+123
| | | | Reviewed-by: Anuj Phogat <[email protected]>