mesa.git
8 years agosvga: Force an RGBA view creation for an RGBA resource
Sinclair Yeh [Tue, 1 Mar 2016 23:55:53 +0000 (15:55 -0800)]
svga: Force an RGBA view creation for an RGBA resource

glXCreatePixmap() may specify a GLX_TEXTURE_FORMAT_RGB_EXT format
for an RGBA resource, causing us to create an RGBX view for an
RGBA resource, a combination vgpu10 does not support.

When this is detected, change the request to create an RGBA view
instead.

Reviewed-by: Brian Paul <brianp@vmware.com>
8 years agosvga: fix an error in svga_texture_generate_mipmap
Charmaine Lee [Mon, 29 Feb 2016 20:00:12 +0000 (12:00 -0800)]
svga: fix an error in svga_texture_generate_mipmap

With this patch, make sure the shader resource view is properly created
before referencing it in the generate mipmap command.

Reviewed-by: Brian Paul <brianp@vmware.com>
8 years agowinsys/svga: Increase the fence timeout
Thomas Hellstrom [Thu, 25 Feb 2016 10:02:03 +0000 (11:02 +0100)]
winsys/svga: Increase the fence timeout

If running with a software renderer backend, the timeout may be
insufficient, and we don't want to release busy buffers too early.

In practice, SVGA gpu lockups are extremely rare.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
8 years agowinsys/svga: Fix an uninitialized return value
Thomas Hellstrom [Thu, 25 Feb 2016 10:02:02 +0000 (11:02 +0100)]
winsys/svga: Fix an uninitialized return value

Reported-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviwed-by: Brian Paul <brianp@vmware.com>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
8 years agoi965: Set MaxFramebufferWidth/Height to 16384, not viewport.
Kenneth Graunke [Thu, 3 Mar 2016 09:22:37 +0000 (01:22 -0800)]
i965: Set MaxFramebufferWidth/Height to 16384, not viewport.

dEQP-GLES31.functional.fbo.no_attachments.maximums.{all,height,size,width}
started hitting assertion failures when emitting SURFACE_STATE, after
commit e8fd60e7891c7 where Samuel increased the maximum viewport size to
32768, from 16384.

MaxFramebufferWidth/Height were being set to the maximum viewport size,
but are actually limited by the SURFACE_STATE width/height field range,
which is 16384 on Gen7+ (where ARB_framebuffer_no_attachments is
exposed).  So, reduce these to 16384 explicitly.

Fixes assert fails in the above mentioned dEQP tests.  (Those tests
still fail, however.)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
8 years agoglsl: Improve the accuracy of the acos() approximation.
Francisco Jerez [Thu, 3 Mar 2016 07:50:04 +0000 (23:50 -0800)]
glsl: Improve the accuracy of the acos() approximation.

The adjusted polynomial coefficients come from the numerical
minimization of the L2 norm of the relative error.  The old
coefficients would give a maximum relative error of about 15000 ULP in
the neighborhood around acos(x) = 0, the new ones give a relative
error bounded by less than 2000 ULP in the same neighborhood.

Fixes four dEQP subtests:
dEQP-GLES31.functional.shaders.builtin_functions.precision.acos.
highp_compute.{scalar,vec2,vec3,vec4}

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoglsl: Parameterize asin_expr() on the fit coefficients.
Kenneth Graunke [Thu, 3 Mar 2016 07:39:18 +0000 (23:39 -0800)]
glsl: Parameterize asin_expr() on the fit coefficients.

This will allow us to share the implementation while using different
polynomials for asin() and acos().

Francisco Jerez did this in the SPIR-V front-end; I'm merely porting
his idea to the GLSL world.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agomesa: Allow Get*() of several forgotten IsEnabled() pnames.
Kenneth Graunke [Thu, 3 Mar 2016 08:43:15 +0000 (00:43 -0800)]
mesa: Allow Get*() of several forgotten IsEnabled() pnames.

From section 6.2 ("State Tables") of the GL 2.1 specification
(the text also appears in the GL 3.0 and ES 3.1 specifications):
"However, state variables for which IsEnabled is listed as the query
 command can also be obtained using GetBooleanv, GetIntegerv, GetFloatv,
 and GetDoublev."

GL_DEBUG_OUTPUT, GL_DEBUG_OUTPUT_SYNCHRONOUS, and GL_FRAGMENT_SHADER_ATI
were missing from the glGet*() functions.  All other IsEnabled() pnames
look to be present, as far as I can tell.

Fixes 8 dEQP-GLES31.functional.debug.state_query subtests:
debug_output[_synchronous]_get{boolean,float,integer,integer64}.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
8 years agomesa: Make glGet queries initialize ctx->Debug when necessary.
Kenneth Graunke [Thu, 3 Mar 2016 07:19:27 +0000 (23:19 -0800)]
mesa: Make glGet queries initialize ctx->Debug when necessary.

dEQP-GLES31.functional.debug.state_query.debug_group_stack_depth_*
tries to call glGet on GL_DEBUG_GROUP_STACK_DEPTH right away, before
doing any other debug setup.  This should return 1.

However, because ctx->Debug wasn't allocated, we bailed and returned 0.

This patch removes the open-coded locking and switches the two glGet
functions to use _mesa_lock_debug_state(), which takes care of
allocating and initializing that state on the first time.  It also
conveniently takes care of unlocking on failure for us, so we don't
need to handle that in every caller.

Fixes dEQP-GLES31.functional.debug.state_query.debug_group_stack_depth_
{getboolean,getfloat,getinteger,getinteger64}.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
8 years agoUpdate docs to advertise new support for ARB_internalformat_query2
Eduardo Lima Mitev [Thu, 3 Mar 2016 14:43:01 +0000 (15:43 +0100)]
Update docs to advertise new support for ARB_internalformat_query2

Support in Mesa main and i965 has just been added.

v2: Include note in 'New Features' of docs/relnotes/11.3.0.html.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agoi965: Enable the ARB_internalformat_query2 extension
Antia Puentes [Wed, 21 Oct 2015 13:25:30 +0000 (15:25 +0200)]
i965: Enable the ARB_internalformat_query2 extension

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoi965/formatquery: Add support for INTERNALFORMAT_PREFERRED query
Eduardo Lima Mitev [Tue, 22 Dec 2015 16:16:50 +0000 (17:16 +0100)]
i965/formatquery: Add support for INTERNALFORMAT_PREFERRED query

This pname is tricky. The spec states that an internal format should be
returned, that is compatible with the passed internal format, and has
at least the same precision. There is no clear API to resolve this.

The closest we have (and what other drivers (i.e, NVidia proprietary) do,
is to return the same internal format given as parameter. But we validate
first that the passed internal format is supported by i965.

To check for support, we have the TextureFormatSupported map'. But
this map expects a 'mesa_format', which takes a format+typen. So, we must
first "come up" with a generic type that is suited for this internal format,
then get a mesa_format, and then do the validation.

The cleanest solution here is to add a method that does exactly what
the spec wants: a driver's preferred internal format from a given
internal format. But at this point we lack a clear view of what
defines this preference, and also there seems to be no API for it.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/glformats: Consider DEPTH/STENCIL when resolving a mesa_format
Eduardo Lima Mitev [Wed, 3 Feb 2016 09:57:10 +0000 (10:57 +0100)]
mesa/glformats: Consider DEPTH/STENCIL when resolving a mesa_format

_mesa_format_from_format_and_type() is currently not considering DEPTH and
STENCIL formats, which are not array formats and are not handled anywhere.

This patch adds cases for common combinations of DEPTH/STENCIL format and
types.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Add (GET_)TEXTURE_IMAGE_TYPE pnames
Eduardo Lima Mitev [Tue, 22 Dec 2015 18:33:57 +0000 (19:33 +0100)]
mesa/formatquery: Add (GET_)TEXTURE_IMAGE_TYPE pnames

These basically reuse the default implementation of GL_READ_PIXELS_TYPE.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Add (GET_)TEXTURE_IMAGE_FORMAT pnames
Eduardo Lima Mitev [Tue, 22 Dec 2015 18:19:32 +0000 (19:19 +0100)]
mesa/formatquery: Add (GET_)TEXTURE_IMAGE_FORMAT pnames

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Add READ_PIXELS_TYPE pname
Eduardo Lima Mitev [Tue, 22 Dec 2015 17:52:38 +0000 (18:52 +0100)]
mesa/formatquery: Add READ_PIXELS_TYPE pname

We call the driver to provide its preferred type, but also provide a
default implementation that selects a generic type based on the passed
internal format.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Add READ_PIXELS_FORMAT pname
Eduardo Lima Mitev [Tue, 22 Dec 2015 17:38:06 +0000 (18:38 +0100)]
mesa/formatquery: Add READ_PIXELS_FORMAT pname

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Add support for READ_PIXELS query
Eduardo Lima Mitev [Tue, 22 Dec 2015 17:20:57 +0000 (18:20 +0100)]
mesa/formatquery: Add support for READ_PIXELS query

This is supported since very early version of OpenGL, but we still call the
driver to give it the opportunity to report caveat or no support.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: added FILTER pname support
Alejandro Piñeiro [Tue, 22 Dec 2015 19:06:19 +0000 (20:06 +0100)]
mesa/formatquery: added FILTER pname support

It discards out the targets and internalformats that explicitly
mention (per-spec) that doesn't support filter types other than
NEAREST or NEAREST_MIPMAP_NEAREST. Those are:

  * Texture buffers target
  * Multisample targets
  * Any integer internalformat

For the case of multisample targets, it was used the existing method
_mesa_target_allows_setting_sampler_parameter. This would scalate
better in the future if new targets appear that doesn't allow to
set sampler parameters.

We consider RENDERBUFFER to support LINEAR filters, because although
it doesn't support this filter for sampling, you can set LINEAR
on a blit operation using glBlitFramebuffer.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/texparam: make public target_allows_setting_sampler_parameters
Alejandro Piñeiro [Tue, 22 Dec 2015 19:04:38 +0000 (20:04 +0100)]
mesa/texparam: make public target_allows_setting_sampler_parameters

In order to allow to be used on ARB_internalformat_query2 implementation.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added framebuffer renderability related queries
Antia Puentes [Mon, 21 Dec 2015 17:55:56 +0000 (18:55 +0100)]
mesa/formatquery: Added framebuffer renderability related queries

From the ARB_internalformat_query2 specification:

   "- FRAMEBUFFER_RENDERABLE: The support for rendering to the resource via
      framebuffer attachment is returned in <params>.

    - FRAMEBUFFER_RENDERABLE_LAYERED: The support for layered rendering to
      the resource via framebuffer attachment is returned in <params>.

    - FRAMEBUFFER_BLEND: The support for rendering to the resource
      via framebuffer attachment when blending is enabled is returned in
      <params>."

For all of them,
    "Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
     If the resource is unsupported, NONE is returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added texture gather/shadow related queries
Antia Puentes [Mon, 21 Dec 2015 14:57:25 +0000 (15:57 +0100)]
mesa/formatquery: Added texture gather/shadow related queries

From the ARB_internalformat_query2 specification:

   "- TEXTURE_SHADOW: The support for using the resource with shadow samplers
      is written to <params>.

    - TEXTURE_GATHER: The support for using the resource with texture gather
      operations is written to <params>.

    - TEXTURE_GATHER_SHADOW: The support for using resource with texture gather
      operations with shadow samplers is written to <params>."

For all of them,

    "Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
     If the resource or operation is not supported, NONE is returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added texture view related queries
Antia Puentes [Sat, 19 Dec 2015 19:29:31 +0000 (20:29 +0100)]
mesa/formatquery: Added texture view related queries

From the ARB_internalformat_query2 specification:

   "- TEXTURE_VIEW: The support for using the resource with the TextureView
      command is returned in <params>.
      Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
      If the resource or operation is not supported, NONE is returned.

    - VIEW_COMPATIBILITY_CLASS: The compatibility class of the resource when
      used as a texture view is returned in <params>. The compatibility
      class is one of the values from the /Class/ column of Table 3.X.2. If
      the resource has no other formats that are compatible, the resource
      does not support views, or if texture views are not supported, NONE is
      returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/textureview: Make _lookup_view_class public
Antia Puentes [Mon, 16 Nov 2015 14:45:54 +0000 (15:45 +0100)]
mesa/textureview: Make _lookup_view_class public

It will be used by the ARB_internalformat_query2 implementation to
implement the VIEW_COMPATIBILITY_CLASS <pname> query.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added CLEAR_BUFFER <pname> query
Antia Puentes [Sat, 19 Dec 2015 19:27:16 +0000 (20:27 +0100)]
mesa/formatquery: Added CLEAR_BUFFER <pname> query

From the ARB_internalformat_query2 specification:

   "- CLEAR_BUFFER: The support for using the resource with ClearBuffer*Data
      commands is returned in <params>.
      Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
      If the resource or operation is not supported, NONE is returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added compressed texture related queries
Antia Puentes [Sat, 19 Dec 2015 19:23:29 +0000 (20:23 +0100)]
mesa/formatquery: Added compressed texture related queries

From the ARB_internalformat_query2 specification:

   "- TEXTURE_COMPRESSED: If <internalformat> is a compressed format
      that is supported for this type of resource, TRUE is returned in
      <params>. If the internal format is not compressed, or the type of
      resource is not supported, FALSE is returned.

    - TEXTURE_COMPRESSED_BLOCK_WIDTH: If the resource contains a compressed
      format, the width of a compressed block (in bytes) is returned in
      <params>. If the internal format is not compressed, or the resource
      is not supported, 0 is returned.

    - TEXTURE_COMPRESSED_BLOCK_HEIGHT: If the resource contains a compressed
      format, the height of a compressed block (in bytes) is returned in
      <params>. If the internal format is not compressed, or the resource
      is not supported, 0 is returned.

    - TEXTURE_COMPRESSED_BLOCK_SIZE: If the resource contains a compressed
      format the number of bytes per block is returned in <params>.  If the
      internal format is not compressed, or the resource is not supported,
      0 is returned.
      (combined with the above, allows the bitrate to be computed, and may be
      useful in conjunction with ARB_compressed_texture_pixel_storage)."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added simultaneous texture and depth/stencil queries
Antia Puentes [Sat, 19 Dec 2015 19:17:11 +0000 (20:17 +0100)]
mesa/formatquery: Added simultaneous texture and depth/stencil queries

From the ARB_internalformat_query2 specification:

   "- SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST: The support for using the resource
      both as a source for texture sampling while it is bound as a buffer for
      depth test is written to <params>. For example, a depth (or stencil)
      texture could be bound simultaneously for texturing while it is bound as
      a depth (and/or stencil) buffer without causing a feedback loop, provided
      that depth writes are disabled.

    - SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST: The support for using the resource
      both as a source for texture sampling while it is bound as a buffer for
      stencil test is written to <params>. For example, a depth (or stencil)
      texture could be bound simultaneously for texturing while it is bound as
      a depth (and/or stencil) buffer without causing a feedback loop,
      provided that stencil writes are disabled.

    - SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE: The support for using the resource
      both as a source for texture sampling while performing depth writes to
      the resources is written to <params>.  For example, a depth-stencil
      texture could be bound simultaneously for stencil texturing while it
      is bound as a depth buffer. Feedback loops cannot occur because sampling
      a stencil texture only returns the stencil portion, and thus writes to
      the depth buffer do not modify the stencil portions.

    - SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE: The support for using the resource
      both as a source for texture sampling while performing stencil writes to
      the resources is written to <params>.  For example, a depth-stencil
      texture could be bound simultaneously for depth-texturing while it is
      bound as a stencil buffer. Feedback loops cannot occur because sampling
      a depth texture only returns the depth portion, and thus writes to
      the stencil buffer could not modify the depth portions.

For all of them,
    "Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
     If the resource or operation is not supported, NONE is returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added queries related to image textures
Antia Puentes [Sat, 19 Dec 2015 18:50:25 +0000 (19:50 +0100)]
mesa/formatquery: Added queries related to image textures

From the ARB_internalformat_query2 specification:

   "- IMAGE_TEXEL_SIZE: The size of a texel when the resource when used as
      an image texture is returned in <params>.  This is the value from the
      /Size/ column in Table 3.22. If the resource is not supported for image
      textures, or if image textures are not supported, zero is returned.

    - IMAGE_COMPATIBILITY_CLASS: The compatibility class of the resource when
      used as an image texture is returned in <params>.  This corresponds to
      the value from the /Class/ column in Table 3.22. The possible values
      returned are IMAGE_CLASS_4_X_32, IMAGE_CLASS_2_X_32, IMAGE_CLASS_1_X_32,
      IMAGE_CLASS_4_X_16, IMAGE_CLASS_2_X_16, IMAGE_CLASS_1_X_16,
      IMAGE_CLASS_4_X_8, IMAGE_CLASS_2_X_8, IMAGE_CLASS_1_X_8,
      IMAGE_CLASS_11_11_10, and IMAGE_CLASS_10_10_10_2, which correspond to
      the 4x32, 2x32, 1x32, 4x16, 2x16, 1x16, 4x8, 2x8, 1x8, the class
      (a) 11/11/10 packed floating-point format, and the class (b)
      10/10/10/2 packed formats, respectively.
      If the resource is not supported for image textures, or if image
      textures are not supported, NONE is returned.

    - IMAGE_PIXEL_FORMAT: The pixel format of the resource when used as an
      image texture is returned in <params>.  This is the value
      from the /Pixel format/ column in Table 3.22. If the resource is not
      supported for image textures, or if image textures are not supported,
      NONE is returned.

    - IMAGE_PIXEL_TYPE: The pixel type of the resource when used as an
      image texture is returned in <params>.  This is the value from
      the /Pixel type/ column in Table 3.22. If the resource is not supported
      for image textures, or if image textures are not supported, NONE is
      returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/shaderimage: Added func to get the GL_IMAGE_CLASS from the format
Antia Puentes [Tue, 17 Nov 2015 20:29:04 +0000 (21:29 +0100)]
mesa/shaderimage: Added func to get the GL_IMAGE_CLASS from the format

It will be used by the ARB_internalformat_query2 implementation to
implement the IMAGE_COMPATIBILITY_CLASS <pname> query.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added SHADER_IMAGE_{LOAD,STORE,ATOMIC} <pname> queries
Antia Puentes [Sat, 19 Dec 2015 18:39:53 +0000 (19:39 +0100)]
mesa/formatquery: Added SHADER_IMAGE_{LOAD,STORE,ATOMIC} <pname> queries

From the ARB_internalformat_query2 specification:

    "- SHADER_IMAGE_LOAD: The support for using the resource with image load
      operations in shaders is written to <params>.
      In this case the <internalformat> is the value of the <format> parameter
      that would be passed to BindImageTexture.

    - SHADER_IMAGE_STORE: The support for using the resource with image store
      operations in shaders is written to <params>.
      In this case the <internalformat> is the value of the <format> parameter
      that is passed to BindImageTexture.

    - SHADER_IMAGE_ATOMIC: The support for using the resource with atomic
      memory operations from shaders is written to <params>."

For all of them:

    "Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
     If the resource or operation is not supported, NONE is returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/shaderimage: Make is_image_format_supported public
Antia Puentes [Sun, 15 Nov 2015 17:01:56 +0000 (18:01 +0100)]
mesa/shaderimage: Make is_image_format_supported public

It will be used by the ARB_internalformat_query2 implementation
to implement queries related to the ARB_shader_image_load_store
extension.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added queries related to texture sampling in shaders
Antia Puentes [Sat, 19 Dec 2015 18:24:28 +0000 (19:24 +0100)]
mesa/formatquery: Added queries related to texture sampling in shaders

From the ARB_internalformat_query2 specification:

   "- VERTEX_TEXTURE: The support for using the resource as a source for
      texture sampling in a vertex shader is written to <params>.

    - TESS_CONTROL_TEXTURE: The support for using the resource as a source for
      texture sampling in a tessellation control shader is written to <params>.

    - TESS_EVALUATION_TEXTURE: The support for using the resource as a source
      for texture sampling in a tessellation evaluation shader is written to
      <params>.

    - GEOMETRY_TEXTURE: The support for using the resource as a source for
      texture sampling in a geometry shader is written to <params>.

    - FRAGMENT_TEXTURE: The support for using the resource as a source for
      texture sampling in a fragment shader is written to <params>.

    - COMPUTE_TEXTURE: The support for using the resource as a source for
      texture sampling in a compute shader is written to <params>."

For all of them,

   "Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
    If the resource or operation is not supported, NONE is returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added SRGB_DECODE_ARB <pname> query
Antia Puentes [Sat, 19 Dec 2015 18:17:39 +0000 (19:17 +0100)]
mesa/formatquery: Added SRGB_DECODE_ARB <pname> query

From the ARB_internalformat_query2 specification:

   "- SRGB_DECODE_ARB: The support for toggling whether sRGB decode happens at
      sampling time (see EXT/ARB_texture_sRGB_decode) for the resource is
      returned in <params>.
      Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
      If the resource or operation is not supported, NONE is returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added SRGB_{READ,WRITE} <pname> queries
Antia Puentes [Sat, 19 Dec 2015 18:14:51 +0000 (19:14 +0100)]
mesa/formatquery: Added SRGB_{READ,WRITE} <pname> queries

From the ARB_internalformat_query2 specification:

   "- SRGB_READ: The support for converting from sRGB colorspace on read
      operations (see section 3.9.18) from the resource is returned in
      <params>.
      Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
      If the resource or operation is not supported, NONE is returned.

    - SRGB_WRITE: The support for converting to sRGB colorspace on write
      operations to the resource is returned in <params>.
      This indicates that writing to framebuffers with this internalformat
      will encode to sRGB color spaces when FRAMEBUFFER_SRGB is enabled (see
      section 4.1.8).
      Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
      If the resource or operation is not supported, NONE is returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added COLOR_ENCODING <pname> query.
Antia Puentes [Sat, 19 Dec 2015 18:10:51 +0000 (19:10 +0100)]
mesa/formatquery: Added COLOR_ENCODING <pname> query.

From the ARB_internalformat_query2 specification:

   "- COLOR_ENCODING: The color encoding for the resource is returned in
      <params>.  Possible values for color buffers are LINEAR or SRGB,
      for linear or sRGB-encoded color components, respectively. For non-color
      formats (such as depth or stencil), or for unsupported resources,
      the value NONE is returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/glformats: Add a helper function _mesa_is_srgb_format()
Eduardo Lima Mitev [Wed, 3 Feb 2016 12:40:27 +0000 (13:40 +0100)]
mesa/glformats: Add a helper function _mesa_is_srgb_format()

Returns true if the passed format is an sRGB format, false otherwise.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added mipmap related <pname> queries
Antia Puentes [Sat, 19 Dec 2015 17:49:08 +0000 (18:49 +0100)]
mesa/formatquery: Added mipmap related <pname> queries

Specifically MIPMAP, MANUAL_GENERATE_MIPMAP and AUTO_GENERATE_MIPMAP <pname>
queries.

From the ARB_internalformat_query2 specification:

   "- MIPMAP: If the resource supports mipmaps, TRUE is returned in <params>.
      If the resource is not supported, or if mipmaps are not supported for
      this type of resource, FALSE is returned.

    - MANUAL_GENERATE_MIPMAP: The support for manually generating mipmaps for
      the resource is returned in <params>.
      Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
      If the resource is not supported, or if the operation is not supported,
      NONE is returned.

    - AUTO_GENERATE_MIPMAP: The support for automatic generation of mipmaps
      for the resource is returned in <params>.
      Possible values returned are FULL_SUPPORT, CAVEAT_SUPPORT, or NONE.
      If the resource is not supported, or if the operation is not supported,
      NONE is returned."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/genmipmap: Added a function to validate the internalformat
Antia Puentes [Thu, 26 Nov 2015 14:20:24 +0000 (15:20 +0100)]
mesa/genmipmap: Added a function to validate the internalformat

It will be used by the ARB_internalformat_query2 implementation to
implement mipmap related queries.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/genmipmap: Added a function to check if the target is valid
Antia Puentes [Thu, 26 Nov 2015 14:08:47 +0000 (15:08 +0100)]
mesa/genmipmap: Added a function to check if the target is valid

It will be used by the ARB_internalformat_query2 implementation to
implement mipmap related queries.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added {COLOR,DEPTH,STENCIL}_RENDERABLE <pname> queries
Antia Puentes [Sat, 19 Dec 2015 17:35:57 +0000 (18:35 +0100)]
mesa/formatquery: Added {COLOR,DEPTH,STENCIL}_RENDERABLE <pname> queries

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added {COLOR,DEPTH,STENCIL}_COMPONENTS <pname> queries
Antia Puentes [Tue, 10 Nov 2015 12:53:45 +0000 (13:53 +0100)]
mesa/formatquery: Added {COLOR,DEPTH,STENCIL}_COMPONENTS <pname> queries

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: support for MAX_COMBINED_DIMENSIONS
Alejandro Piñeiro [Sat, 19 Dec 2015 11:15:00 +0000 (12:15 +0100)]
mesa/formatquery: support for MAX_COMBINED_DIMENSIONS

It is implemented combining the values returned by calls to the 32-bit
query _mesa_GetInternalformati32v.

The main reason is simplicity. The other option would be C&P how we
implemented the support of GL_MAX_{WIDTH/HEIGHT/DEPTH} and GL_SAMPLES.

Additionally, doing this way, we avoid adding checks on the code, as
are done by the call to the query itself.

MAX_COMBINED_DIMENSIONS is the only pname pointed on the spec of
needing a 64-bit query. We handle that possibility by packing the
returning value on the two first 32-bit integers of params. This
would work on the 32-bit query as far as the value is not greater
that INT_MAX. On the 64-bit query wrapper we unpack those values
in order to get the final value.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/teximage: add _mesa_is_cube_map_texture utility method
Eduardo Lima Mitev [Tue, 12 Jan 2016 18:36:20 +0000 (19:36 +0100)]
mesa/teximage: add _mesa_is_cube_map_texture utility method

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomain/formatquery: support for MAX_{WIDTH/HEIGHT/DEPTH/LAYERS}
Alejandro Piñeiro [Sat, 19 Dec 2015 10:54:32 +0000 (11:54 +0100)]
main/formatquery: support for MAX_{WIDTH/HEIGHT/DEPTH/LAYERS}

Implemented by calling GetIntegerv with the equivalent pname and
handling individually the exceptions related to dimensions.

All those pnames are used to get the maximum value for each dimension
of the given target. The only difference between this calls and
calling GetInteger with pnames like GL_MAX_TEXTURE_SIZE,
GL_MAX_3D_TEXTURE_SIZE, etc is that GetInternalformat allows to
specify a internalformat.

But at this moment, there is no reason to think that the values would
be different based on the internalformat. The spec already take that
into account, using these specific pnames as example on Issue 7 of
arb_internalformat_query2 spec.

So this seems like a hook to allow to return different values based on
the internalformat in the future.

It is worth to note that the piglit test associated to those pnames
are checking the returned values of GetInternalformat against the
values returned by GetInteger, and the test is passing with NVIDIA
proprietary drivers.

main/formatquery: support for MAX_{WIDTH/HEIGHT/DEPTH/LAYERS}

Implemented by calling GetIntegerv with the equivalent pname and
handling individually the exceptions related to dimensions.

All those pnames are used to get the maximum value for each dimension
of the given target. The only difference between this calls and
calling GetInteger with pnames like GL_MAX_TEXTURE_SIZE,
GL_MAX_3D_TEXTURE_SIZE, etc is that GetInternalformat allows to
specify a internalformat.

But at this moment, there is no reason to think that the values would
be different based on the internalformat. The spec already take that
into account, using these specific pnames as example on Issue 7 of
arb_internalformat_query2 spec.

So this seems like a hook to allow to return different values based on
the internalformat in the future.

It is worth to note that the piglit test associated to those pnames
are checking the returned values of GetInternalformat against the
values returned by GetInteger, and the test is passing with NVIDIA
proprietary drivers.

v2: use _mesa_has## instead of direct ctx->Extensions access (Nanley Chery)

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: support for IMAGE_FORMAT_COMPATIBILITY_TYPE
Alejandro Piñeiro [Sat, 19 Dec 2015 10:02:21 +0000 (11:02 +0100)]
mesa/formatquery: support for IMAGE_FORMAT_COMPATIBILITY_TYPE

From arb_internalformat_query2 spec:

 "IMAGE_FORMAT_COMPATIBILITY_TYPE: The matching criteria use for the
  resource when used as an image textures is returned in
  <params>. This is equivalent to calling GetTexParameter with <value>
  set to IMAGE_FORMAT_COMPATIBILITY_TYPE."

Current implementation of GetTexParameter for this case returns a
field of a texture object, so the support of this pname was
implemented creating a temporal texture object and returning that
value.

It is worth to mention that right now that field is not reassigned
after initialization. So it is somehow hardcoded. An alternative
option would be return that value. That doesn't seems really scalable
though.

v2: use _mesa_has## instead of direct ctx->Extensions access (Nanley Chery)

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: handle unmodified buffer for SAMPLES on the 64-bit query
Alejandro Piñeiro [Sat, 19 Dec 2015 11:45:43 +0000 (12:45 +0100)]
mesa/formatquery: handle unmodified buffer for SAMPLES on the 64-bit query

From arb_internalformat_query2 spec:

" If <internalformat> is not color-renderable, depth-renderable, or
  stencil-renderable (as defined in section 4.4.4), or if <target>
  does not support multiple samples (ie other than
  TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY, or
  RENDERBUFFER), <params> is not modified."

So there are cases where the buffer should not be modified. As the
64-bit query is a wrapper over the 32-bit query, we can't just copy
the values to the equivalent 32-bit buffer, as that would fail if the
original params contained values greater that INT_MAX. So we need to
copy-back only the values that got modified by the 32-bit query. We do
that by filling the temporal buffer by negatives, as the 32-bit query
should not return negative values ever.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: initial implementation for GetInternalformati64v
Alejandro Piñeiro [Thu, 19 Nov 2015 10:37:37 +0000 (11:37 +0100)]
mesa/formatquery: initial implementation for GetInternalformati64v

It just does a wrapping on the existing 32-bit GetInternalformativ.

We will maintain the 32-bit query as default as it is likely that
it would be the one most used.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added INTERNALFORMAT_{X}_{SIZE,TYPE} <pname> queries
Antia Puentes [Sat, 19 Dec 2015 16:21:21 +0000 (17:21 +0100)]
mesa/formatquery: Added INTERNALFORMAT_{X}_{SIZE,TYPE} <pname> queries

From the ARB_internalformat_query2 spec:

   "- INTERNALFORMAT_RED_SIZE
    - INTERNALFORMAT_GREEN_SIZE
    - INTERNALFORMAT_BLUE_SIZE
    - INTERNALFORMAT_ALPHA_SIZE
    - INTERNALFORMAT_DEPTH_SIZE
    - INTERNALFORMAT_STENCIL_SIZE
    - INTERNALFORMAT_SHARED_SIZE
      For uncompressed internal formats, queries of these values return the
      actual resolutions that would be used for storing image array components
      for the resource.
      For compressed internal formats, the resolutions returned specify the
      component resolution of an uncompressed internal format that produces
      an image of roughly the same quality as the compressed algorithm.
      For textures this query will return the same information as querying
      GetTexLevelParameter{if}v for TEXTURE_*_SIZE would return.
      If the internal format is unsupported, or if a particular component is
      not present in the format, 0 is written to <params>.

    - INTERNALFORMAT_RED_TYPE
    - INTERNALFORMAT_GREEN_TYPE
    - INTERNALFORMAT_BLUE_TYPE
    - INTERNALFORMAT_ALPHA_TYPE
    - INTERNALFORMAT_DEPTH_TYPE
    - INTERNALFORMAT_STENCIL_TYPE
      For uncompressed internal formats, queries for these values return the
      data type used to store the component.
      For compressed internal formats the types returned specify how components
      are interpreted after decompression.
      For textures this query returns the same information as querying
      GetTexLevelParameter{if}v for TEXTURE_*TYPE would return.
      Possible values return include, NONE, SIGNED_NORMALIZED,
      UNSIGNED_NORMALIZED, FLOAT, INT, UNSIGNED_INT, representing missing,
      signed normalized fixed point, unsigned normalized fixed point,
      floating-point, signed unnormalized integer and unsigned unnormalized
      integer components. NONE is returned for all component types if the
      format is unsupported."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/main: Extend _mesa_get_format_bits to accept new pnames
Antia Puentes [Tue, 1 Dec 2015 18:34:21 +0000 (19:34 +0100)]
mesa/main: Extend _mesa_get_format_bits to accept new pnames

The new pnames accepted by the function are:

        - INTERNALFORMAT_RED_SIZE
        - INTERNALFORMAT_GREEN_SIZE
        - INTERNALFORMAT_BLUE_SIZE
        - INTERNALFORMAT_ALPHA_SIZE
        - INTERNALFORMAT_DEPTH_SIZE
        - INTERNALFORMAT_STENCIL_SIZE

It will be used by the ARB_internalformat_query2 implementation to
implement those pnames.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/main: Extend _mesa_base_format_has_channel to accept new pnames
Antia Puentes [Mon, 30 Nov 2015 19:26:30 +0000 (20:26 +0100)]
mesa/main: Extend _mesa_base_format_has_channel to accept new pnames

The new pnames accepted by the function are:

        - INTERNALFORMAT_RED_SIZE
        - INTERNALFORMAT_GREEN_SIZE
        - INTERNALFORMAT_BLUE_SIZE
        - INTERNALFORMAT_ALPHA_SIZE
        - INTERNALFORMAT_DEPTH_SIZE
        - INTERNALFORMAT_STENCIL_SIZE
        - INTERNALFORMAT_RED_TYPE
        - INTERNALFORMAT_GREEN_TYPE
        - INTERNALFORMAT_BLUE_TYPE
        - INTERNALFORMAT_ALPHA_TYPE
        - INTERNALFORMAT_DEPTH_TYPE
        - INTERNALFORMAT_STENCIL_TYPE

It will be used by the ARB_internalformat_query2 implementation to
implement those pnames.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/main: Make legal_get_tex_level_parameter_target public
Antia Puentes [Mon, 30 Nov 2015 19:37:24 +0000 (20:37 +0100)]
mesa/main: Make legal_get_tex_level_parameter_target public

It will be used by the ARB_internalformat_query2 implementation
to check if the target is valid for those <pnames> that are said
in the spec that should return the same values than the
'glGetTexLevelParameter{if}v' function:

    - INTERNALFORMAT_RED_SIZE
    - INTERNALFORMAT_GREEN_SIZE
    - INTERNALFORMAT_BLUE_SIZE
    - INTERNALFORMAT_ALPHA_SIZE
    - INTERNALFORMAT_DEPTH_SIZE
    - INTERNALFORMAT_STENCIL_SIZE
    - INTERNALFORMAT_SHARED_SIZE
    - INTERNALFORMAT_RED_TYPE
    - INTERNALFORMAT_GREEN_TYPE
    - INTERNALFORMAT_BLUE_TYPE
    - INTERNALFORMAT_ALPHA_TYPE
    - INTERNALFORMAT_DEPTH_TYPE
    - INTERNALFORMAT_STENCIL_TYPE
    - IMAGE_FORMAT_COMPATIBILITY_TYPE

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added INTERNALFORMAT_PREFERRED pname
Eduardo Lima Mitev [Sat, 19 Dec 2015 16:03:18 +0000 (17:03 +0100)]
mesa/formatquery: Added INTERNALFORMAT_PREFERRED pname

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added the INTERNALFORMAT_SUPPORTED <pname> query
Antia Puentes [Tue, 22 Dec 2015 14:14:23 +0000 (15:14 +0100)]
mesa/formatquery: Added the INTERNALFORMAT_SUPPORTED <pname> query

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added a func to check <internalformat> supported
Antia Puentes [Tue, 22 Dec 2015 14:07:57 +0000 (15:07 +0100)]
mesa/formatquery: Added a func to check <internalformat> supported

From the ARB_internalformat_query2 specification:

  "The INTERNALFORMAT_SUPPORTED <pname> can be used to determine if
   the internal format is supported, and the  other <pnames> are defined
   in terms of whether or not the format is supported."

v2: Consider also FBO base formats when checking if the internalformat is
    supported.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added func to check if the 'resource' is supported
Antia Puentes [Sat, 19 Dec 2015 15:02:05 +0000 (16:02 +0100)]
mesa/formatquery: Added func to check if the 'resource' is supported

Checks that the 'resource', as defined by the ARB_internalformat_query2
specification, is supported by the implementation for those 'pnames'
that require this check.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/main: not fill mesa_error on _mesa_legal_texture_base_format_for_target
Alejandro Piñeiro [Fri, 20 Nov 2015 09:34:50 +0000 (10:34 +0100)]
mesa/main: not fill mesa_error on _mesa_legal_texture_base_format_for_target

This would allow to use this method if you are just querying if it is
allowed, like for arb_internalformat_query2.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/teximage: Make _mesa_format_no_online_compression public
Antia Puentes [Sun, 15 Nov 2015 20:31:36 +0000 (21:31 +0100)]
mesa/teximage: Make _mesa_format_no_online_compression public

It will be used by the ARB_internalformat_query2 implementation
to check if a certain compressed 'internalformat' is supported
by texture 'targets'.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/teximage: make public is_renderable_texture_format
Antia Puentes [Wed, 4 Nov 2015 15:51:01 +0000 (16:51 +0100)]
mesa/teximage: make public is_renderable_texture_format

It will be used by the ARB_internalformat_query2 implementation
to check if the 'internalformat' passed is supported by texture
MULTISAMPLE 'targets'.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/main: Added empty skeleton of glGetInternalformati64v
Antia Puentes [Tue, 17 Nov 2015 17:02:12 +0000 (18:02 +0100)]
mesa/main: Added empty skeleton of glGetInternalformati64v

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: Add dispatch and extension XML for GL_ARB_internalformat_query2
Alejandro Piñeiro [Thu, 19 Nov 2015 10:26:05 +0000 (11:26 +0100)]
mesa: Add dispatch and extension XML for GL_ARB_internalformat_query2

Equivalent to commit bda540 (that added GL_ARB_internalformat_query)

v2: include the new xml to to API_XML list at Makefile.am (Emil Velikov)

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added boilerplate code to extend GetInternalformativ
Antia Puentes [Thu, 17 Dec 2015 15:08:34 +0000 (16:08 +0100)]
mesa/formatquery: Added boilerplate code to extend GetInternalformativ

The goal is to extend the GetInternalformativ query to implement the
ARB_internalformat_query2 specification, keeping the behaviour defined
by the ARB_internalformat_query if ARB_internalformat_query2 is not
supported.

v2: Don't require ARB_internalformat_query when profile is GLES3.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added a func to check if the <target> is supported
Antia Puentes [Wed, 16 Dec 2015 19:46:49 +0000 (20:46 +0100)]
mesa/formatquery: Added a func to check if the <target> is supported

From the ARB_internalformat_query2 spec:

  "If the particular <target> and <internalformat> combination do not make
   sense, or if a particular type of <target> is not supported by the
   implementation the "unsupported" answer should be given. This is not an
   error."

This function checks if the <target> is supported by the implementation.

v2: Allow RENDERBUFFER targets also on GLES 3 profiles.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added function to set 'unsupported' responses
Antia Puentes [Wed, 16 Dec 2015 19:36:31 +0000 (20:36 +0100)]
mesa/formatquery: Added function to set 'unsupported' responses

The ARB_internalformat_query2 specification defines which is the
reponse best representing "not supported" or "not applicable" for
each <pname>.

Queries for unsupported features, targets, internalformats, combinations
of: target and internalformat, target and pname, pname and internalformat,
do not return an error but the corresponding 'unsupported' response.
We will use that response as the default answer.

For SAMPLES the 'unsupported' response is to not modify the 'params' buffer.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Added function to validate parameters
Antia Puentes [Wed, 16 Dec 2015 19:31:15 +0000 (20:31 +0100)]
mesa/formatquery: Added function to validate parameters

Handles the cases where an error should be returned according
to the ARB_internalformat_query and ARB_internalformat_query2
specifications.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/main: Add extension tracking bit for ARB_internalformat_query2
Antia Puentes [Wed, 21 Oct 2015 12:51:09 +0000 (14:51 +0200)]
mesa/main: Add extension tracking bit for ARB_internalformat_query2

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: Completely remove QuerySamplesForFormat from driver func table
Eduardo Lima Mitev [Wed, 16 Dec 2015 17:11:36 +0000 (18:11 +0100)]
mesa: Completely remove QuerySamplesForFormat from driver func table

At this point, all uses have been replaced by the more general hook
QueryInternalFormat, introduced by ARB_internalformat_query2.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Use new driver hook QueryInternalFormat
Eduardo Lima Mitev [Wed, 16 Dec 2015 16:49:29 +0000 (17:49 +0100)]
mesa/formatquery: Use new driver hook QueryInternalFormat

Implements SAMPLES and NUM_SAMPLE_COUNTS queries using the new generic
driver call QueryInternalFormat, which is being introduced as replacement
of QuerySamplesForFormat to support ARB_internalformat_query2.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/formatquery: Remove tracking of number of elements in the response
Eduardo Lima Mitev [Wed, 16 Dec 2015 16:32:19 +0000 (17:32 +0100)]
mesa/formatquery: Remove tracking of number of elements in the response

Currently, the number of integers returned in the response to
GetInternalFormativ is being tracked by a 'count' variable.
This is so only the modified elements from the temporary buffer are copied into
the original user buffer.

However, with the introduction of ARB_internalformat_query2, keeping track
of 'count' would complicate the code a lot, considering the high number of
queries.

So, we propose to forget about tracking count, and move all the 16 elements
in the temporary buffer, back to the user buffer (clamped to user buffer size
of course). This is basically a trade-off between performance and code clarity.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa/multisample: Check sample count using the new driver hook
Eduardo Lima Mitev [Tue, 24 Nov 2015 21:32:00 +0000 (22:32 +0100)]
mesa/multisample: Check sample count using the new driver hook

Use QueryInternalFormat instead of QuerySamplesForFormat to obtain the
highest supported sample. QuerySamplesForFormat is to be removed.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agost/format: Replace QuerySamplesForFormat by new QueryInternalFormat hook
Eduardo Lima Mitev [Tue, 24 Nov 2015 21:22:00 +0000 (22:22 +0100)]
st/format: Replace QuerySamplesForFormat by new QueryInternalFormat hook

The previous code for SAMPLES and NUM_SAMPLE_COUNTS is reused as a private function.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoi965/formatquery: Respond queries SAMPLES and NUM_SAMPLE_COUNTS
Eduardo Lima Mitev [Tue, 24 Nov 2015 20:43:28 +0000 (21:43 +0100)]
i965/formatquery: Respond queries SAMPLES and NUM_SAMPLE_COUNTS

This effectively disables old QuerySamplesForFormat driver hook, since it is
never called by Mesa anymore.

v2: Call brw_query_samples_for_format() with a dummy buffer to calculate num
    samples, to avoid modifying the original buffer.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoi965: Move brw_query_samples_for_format() to brw_queryformat.c
Eduardo Lima Mitev [Sat, 14 Nov 2015 11:21:21 +0000 (12:21 +0100)]
i965: Move brw_query_samples_for_format() to brw_queryformat.c

Now that there is a dedicated source file for internal format queries, this
function belongs there.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoi965: Add boilerplate function for QueryInternalFormat driver hook
Eduardo Lima Mitev [Tue, 27 Oct 2015 15:16:24 +0000 (16:16 +0100)]
i965: Add boilerplate function for QueryInternalFormat driver hook

By default, we call back the driver's hook fallback function that has generic
implementations for the all the queries.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: Add a default QueryInternalFormat() function for drivers
Eduardo Lima Mitev [Tue, 27 Oct 2015 14:58:59 +0000 (15:58 +0100)]
mesa: Add a default QueryInternalFormat() function for drivers

This is a fallback function for drivers not implementing
ARB_internalformat_query2.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: Add QueryInternalFormat to device driver virtual table
Eduardo Lima Mitev [Tue, 27 Oct 2015 14:18:45 +0000 (15:18 +0100)]
mesa: Add QueryInternalFormat to device driver virtual table

This new function queries different driver parameters for a particular target
and texture format. It is basically a driver hook to support
ARB_internalformat_query2.

Since ARB_internalformat_query2 introduced several new query parameters
over ARB_internalformat_query, having one driver hook for each parameter
is no longer feasible. So this is the generic entry-point for calls
to glGetInternalFormativ and glGetInternalFormati64v.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl/opt_array_splitting: Fix indentation
Iago Toral Quiroga [Thu, 3 Mar 2016 08:12:16 +0000 (09:12 +0100)]
glsl/opt_array_splitting: Fix indentation

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
8 years agoglsl/opt_array_splitting: Fix crash when doing array indexing into other arrays
Iago Toral Quiroga [Thu, 3 Mar 2016 08:02:30 +0000 (09:02 +0100)]
glsl/opt_array_splitting: Fix crash when doing array indexing into other arrays

When we find indirect indexing into an array, the current implementation
of the array spliiting optimization pass does not look further into the
expression tree. However, if the variable expression involves variable
indexing into other arrays, we can miss that these other arrays also have
variable indexing. If that happens, the pass will crash later on after
hitting an assertion put there to ensure that split arrays are in fact
always indexed via constants:

shader_runner: opt_array_splitting.cpp:296:
void ir_array_splitting_visitor::split_deref(ir_dereference**): Assertion `constant' failed.

This patch fixes the problem by letting the pass step into the variable
index expression to identify these cases properly.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89607
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
8 years agoradeonsi: Do colorformat endian swap for PIPE_USAGE_STAGING
Oded Gabbay [Wed, 2 Mar 2016 19:11:57 +0000 (21:11 +0200)]
radeonsi: Do colorformat endian swap for PIPE_USAGE_STAGING

There is an old if statement (dated to 2011) that prevented doing
endian swap for colorformat, in case the buffer is marked as
PIPE_USAGE_STAGING.

This is now wrong because st_ReadPixels() reads into a destination
texture that is marked with PIPE_USAGE_STAGING. Therefore, even if
the texture is rendered correctly to the monitor, when reading it
back we get unswapped/wrong values.

This patch makes the check_rgba() function in gl-1.0-readpixsanity
piglit test pass in big-endian.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agor600g: Do colorformat endian swap for PIPE_USAGE_STAGING
Oded Gabbay [Wed, 2 Mar 2016 19:11:49 +0000 (21:11 +0200)]
r600g: Do colorformat endian swap for PIPE_USAGE_STAGING

There is an old if statement (dated to 2011) that prevented doing
endian swap for colorformat, in case the buffer is marked
as PIPE_USAGE_STAGING.

This is now wrong because st_ReadPixels() reads into a destination
texture that is marked with PIPE_USAGE_STAGING. Therefore, even if
the texture is rendered correctly to the monitor, when reading it
back we get unswapped/wrong values.

This patch makes the check_rgba() function in gl-1.0-readpixsanity
piglit test pass in big-endian.

v2: removed duplicate call to r600_colorformat_endian_swap() inside
evergreen_init_color_surface_rat()

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agomesa/build: add OpenSWR to build
Tim Rowley [Thu, 25 Feb 2016 02:56:38 +0000 (20:56 -0600)]
mesa/build: add OpenSWR to build

Tested on Linux (centos, ubuntu, and suse variants)

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
8 years agogallium/docs - add OpenSWR documentation
Tim Rowley [Thu, 25 Feb 2016 00:28:13 +0000 (18:28 -0600)]
gallium/docs - add OpenSWR documentation

Acked-by: Jose Fonseca <jfonseca@vmware.com>
8 years agogallium/target-helpers: add OpenSWR driver
Tim Rowley [Wed, 24 Feb 2016 23:45:55 +0000 (17:45 -0600)]
gallium/target-helpers: add OpenSWR driver

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
8 years agogallium/auxilary: more __cplusplus exports
Tim Rowley [Fri, 19 Feb 2016 03:30:46 +0000 (21:30 -0600)]
gallium/auxilary: more __cplusplus exports

swr driver which is written in C++ needs access to some more
gallium utility functions than are currently exposed.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
8 years agogallium/swr: add OpenSWR rasterizer
Tim Rowley [Tue, 16 Feb 2016 23:28:09 +0000 (17:28 -0600)]
gallium/swr: add OpenSWR rasterizer

Acked-by: Roland Scheidegger <sroland@vmware.com>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
8 years agogallium/swr: add OpenSWR driver
Tim Rowley [Tue, 16 Feb 2016 23:27:28 +0000 (17:27 -0600)]
gallium/swr: add OpenSWR driver

OpenSWR is a new software rasterizer for x86 processors designed
for high performance and high scalablility on visualization workloads.

Acked-by: Roland Scheidegger <sroland@vmware.com>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
8 years agoglsl: replace remaining tabs in ir_builder.cpp
Timothy Arceri [Wed, 24 Feb 2016 08:45:37 +0000 (19:45 +1100)]
glsl: replace remaining tabs in ir_builder.cpp

Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
8 years agomesa: Update comment
Anuj Phogat [Thu, 11 Feb 2016 18:52:49 +0000 (10:52 -0800)]
mesa: Update comment

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
8 years agomesa: Fix function description
Anuj Phogat [Thu, 11 Feb 2016 20:24:40 +0000 (12:24 -0800)]
mesa: Fix function description

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
8 years agometa: Remove the 'allocate_storage' parameter in _mesa_meta_pbo_GetTexSubImage()
Anuj Phogat [Wed, 2 Mar 2016 00:46:22 +0000 (16:46 -0800)]
meta: Remove the 'allocate_storage' parameter in _mesa_meta_pbo_GetTexSubImage()

Texture is already allocated before calling this meta function. So,
the value of 'allocate_storage' passed to the function is always false.

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
8 years agometa: Fix the pbo usage in meta for GLES{1,2} contexts
Anuj Phogat [Fri, 18 Dec 2015 23:33:35 +0000 (15:33 -0800)]
meta: Fix the pbo usage in meta for GLES{1,2} contexts

OpenGL ES 1.0 doesn't support using GL_STREAM_DRAW and both
ES 1.0 and 2.0 don't support GL_STREAM_READ in glBufferData().
So, handle it correctly by calling the _mesa_meta_begin()
before create_texture_for_pbo().

V2: Remove the changes related to allocate_storage. (Ian)

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agoprogram: Clean up after condition code removal.
Matt Turner [Wed, 2 Mar 2016 19:01:33 +0000 (11:01 -0800)]
program: Clean up after condition code removal.

8 years agoprogram: Remove variable used only in assert().
Matt Turner [Wed, 2 Mar 2016 19:00:31 +0000 (11:00 -0800)]
program: Remove variable used only in assert().

8 years agoprogram: Drop GL_FRAGMENT_PROGRAM_NV from switch statement.
Matt Turner [Wed, 2 Mar 2016 19:00:01 +0000 (11:00 -0800)]
program: Drop GL_FRAGMENT_PROGRAM_NV from switch statement.

8 years agogk110/ir: fix wrong emission of NOT modifier for VOTE
Samuel Pitoiset [Wed, 2 Mar 2016 17:11:07 +0000 (18:11 +0100)]
gk110/ir: fix wrong emission of NOT modifier for VOTE

Spotted by Coverity.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reported-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agogallium/cso: fix indentation
Thomas Hindoe Paaboel Andersen [Tue, 1 Mar 2016 21:45:00 +0000 (14:45 -0700)]
gallium/cso: fix indentation

Only one of these were recently introduced. However, since
we keep copy/pasting the same wrong indentation we should
probably just fix it.

Reviewed-by: Brian Paul <brianp@vmware.com>
8 years agost/mesa: move dereference after null check
Thomas Hindoe Paaboel Andersen [Tue, 1 Mar 2016 21:45:00 +0000 (14:45 -0700)]
st/mesa: move dereference after null check

We should not dereference shader before we have done the
null check.

Reviewed-by: Erik Faye-Lund <kusmabite@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
8 years agoi965/gen6/gs: Replace V-immediate with VF-immediate.
Matt Turner [Tue, 1 Mar 2016 23:27:45 +0000 (15:27 -0800)]
i965/gen6/gs: Replace V-immediate with VF-immediate.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agogallium: fix PIPE_BIND_QUERY_BUFFER - PIPE_BIND_SCANOUT overlap
Marek Olšák [Tue, 1 Mar 2016 01:01:59 +0000 (02:01 +0100)]
gallium: fix PIPE_BIND_QUERY_BUFFER - PIPE_BIND_SCANOUT overlap

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
8 years agoi965: set ctx->Const.MaxViewport{Width,Height} to 32k
Samuel Iglesias Gonsálvez [Fri, 26 Feb 2016 07:27:48 +0000 (08:27 +0100)]
i965: set ctx->Const.MaxViewport{Width,Height} to 32k

From ARB_viewport_array spec:

" * On GL3-capable hardware the VIEWPORT_BOUNDS_RANGE should be at least
    [-16384, 16383].
  * On GL4-capable hardware the VIEWPORT_BOUNDS_RANGE should be at least
    [-32768, 32767]."

This range is set using ctx->Const.MaxViewportWidth value, so just bump
those constants to 32k for gen7+ which can support OpenGL 4.0.

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agomain: remove MAX_VIEWPORT_WIDTH and MAX_VIEWPORT_HEIGHT constants
Samuel Iglesias Gonsálvez [Tue, 1 Mar 2016 11:04:52 +0000 (12:04 +0100)]
main: remove MAX_VIEWPORT_WIDTH and MAX_VIEWPORT_HEIGHT constants

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>