mesa.git
8 years agomesa: fix malformed assertion in _image_format_class_to_glenum()
Brian Paul [Tue, 8 Mar 2016 01:57:33 +0000 (18:57 -0700)]
mesa: fix malformed assertion in _image_format_class_to_glenum()

Reviewed-by: Vinson Lee <vlee@freedesktop.org>
8 years agoprogram: minor whitespace clean-ups in program_parse_extra.c
Brian Paul [Mon, 7 Mar 2016 18:10:45 +0000 (11:10 -0700)]
program: minor whitespace clean-ups in program_parse_extra.c

8 years agost/mesa: conditionally enable GL_NV_vdpau_interop
Christian König [Wed, 20 Jan 2016 15:19:08 +0000 (16:19 +0100)]
st/mesa: conditionally enable GL_NV_vdpau_interop

Only enable it when we compile the state tracker as well.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agoradeon/uvd: disable MPEG1
Christian König [Fri, 5 Feb 2016 08:25:59 +0000 (09:25 +0100)]
radeon/uvd: disable MPEG1

The hardware simply doesn't support that correctly.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
8 years agoi965/vec4/nir: no need to use surface_access:: to call emit_untyped_atomic
Alejandro Piñeiro [Fri, 4 Mar 2016 17:20:09 +0000 (18:20 +0100)]
i965/vec4/nir: no need to use surface_access:: to call emit_untyped_atomic

Now that brw_vec4_visitor::emit_untyped_atomic was removed, there is no need
to explicitly set it.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoi965/vec4/nir: remove emit_untyped_surface_read and emit_untyped_atomic at brw_vec4_v...
Alejandro Piñeiro [Fri, 4 Mar 2016 16:32:08 +0000 (17:32 +0100)]
i965/vec4/nir: remove emit_untyped_surface_read and emit_untyped_atomic at brw_vec4_visitor

surface_access emit_untyped_read and emit_untyped_atomic provides the same
functionality.

v2: surface parameter of emit_untyped_atomic is a const, no need to
    specify default predicate on emit_untyped_atomic, use retype
    (Francisco Jerez).

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoi965/vec4: pass the correct src_sz to emit_send at emit_untyped_atomic
Alejandro Piñeiro [Fri, 4 Mar 2016 18:20:27 +0000 (19:20 +0100)]
i965/vec4: pass the correct src_sz to emit_send at emit_untyped_atomic

If the src is invalid, so src size is zero, the src_sz passed to emit
send should be zero too, instead of a default 1 if we are in a simd4x2
case. This can happens if using emit_untyped_atomic for an atomic
dec/inc.

v2: use the proper src_sz when calling emit_send, instead of just
    avoid loading src at emit_send if BAD_FILE (Francisco Jerez)

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoglcpp: Remove empty mid-rule action which changes test behavior.
Kenneth Graunke [Sat, 5 Mar 2016 02:52:47 +0000 (18:52 -0800)]
glcpp: Remove empty mid-rule action which changes test behavior.

Apparently this causes a slight difference in the parser's token
expectations, leading to a different error message.

It seems harmless, but I wanted to be cautious and separate it out.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agoglcpp: Clean up most empty mid-rule actions left by previous commit.
Kenneth Graunke [Sat, 5 Mar 2016 02:47:39 +0000 (18:47 -0800)]
glcpp: Clean up most empty mid-rule actions left by previous commit.

I didn't want to pollute the previous patch with all the $4 -> $3
changes.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agoglcpp: Delete unnecessary implicit version resolves.
Kenneth Graunke [Sat, 5 Mar 2016 02:45:35 +0000 (18:45 -0800)]
glcpp: Delete unnecessary implicit version resolves.

We now have a bigger hammer.  The HASH_TOKEN NEWLINE rule still needs
to exist to ensure the 146-version-hash-first.c test still passes.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agoglcpp: Implicitly resolve version after the first non-space/hash token.
Kenneth Graunke [Sat, 5 Mar 2016 02:26:00 +0000 (18:26 -0800)]
glcpp: Implicitly resolve version after the first non-space/hash token.

We resolved the implicit version directive when processing control lines,
such as #ifdef, to ensure any built-in macros exist.  However, we failed
to resolve it when handling ordinary text.

For example,

        int x = __VERSION__;

should resolve __VERSION__ to 110, but since we never resolved the implicit
version, none of the built-in macros exist, so it was left as is.

This also meant we allowed the following shader to slop through:

        123
        #version 120

Nothing would cause the implicit version to take effect, so when we saw
the #version directive, we thought everything was peachy.

This patch makes the lexer's per-token action resolve the implicit
version on the first non-space/newline/hash token that isn't part of
a #version directive, fulfilling the GLSL language spec:

"The #version directive must occur in a shader before anything else,
 except for comments and white space."

Because we emit #version as HASH_TOKEN then VERSION_TOKEN, we have to
allow HASH_TOKEN to slop through as well, so we don't resolve the
implicit version as soon as we see the # character.  However, this is
fine, because the parser's HASH_TOKEN NEWLINE rule does resolve the
version, disallowing cases like:

        #
        #version 120

This patch also adds the above shaders as new glcpp tests.

Fixes dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.
{gl_es_1_vertex,gl_es_1_fragment}.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agogallium/swr: fix issues preventing a 32-bit build
Tim Rowley [Fri, 4 Mar 2016 19:28:33 +0000 (13:28 -0600)]
gallium/swr: fix issues preventing a 32-bit build

Not a currently tested configuration, but these couple of small changes
allow a 32-bit build.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94383
Acked-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Brian Paul <brianp@vmware.com>
8 years agogallium/swr: remove use of UINT64 from swr_fence
Tim Rowley [Mon, 7 Mar 2016 20:59:34 +0000 (14:59 -0600)]
gallium/swr: remove use of UINT64 from swr_fence

Remove use of a win32-style type leaked from the swr rasterizer.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agoglsl: Add function parameters to the parser symbol table.
Kenneth Graunke [Sat, 5 Mar 2016 05:19:49 +0000 (21:19 -0800)]
glsl: Add function parameters to the parser symbol table.

In a shader such as:

    struct S { float f; }
    float identity(float S) { return S; }

we would think that "S" in "return S" referred to a structure, even
though it's shadowed by the "float S" parameter in the inner struct.

This led to the parser's grammar seeing TYPE_IDENTIFIER and getting
confused.

Fixes dEQP-GLES2.functional.shaders.scoping.valid.
function_parameter_hides_struct_type_{vertex,fragment}.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
8 years agoglsl: Add single declaration variables to the symbol table too.
Kenneth Graunke [Sat, 5 Mar 2016 04:32:26 +0000 (20:32 -0800)]
glsl: Add single declaration variables to the symbol table too.

The lexer/parser use a symbol table to classify identifiers as
variables, functions, or structure types.

For some reason, we neglected to add variables in simple declarations
such as

    int x = 5;

but did add subsequent variables in multi-declarations:

    int x = 5, y = 6; // y gets added, but not x, for some reason

Fixes four dEQP-GLES2.functional.shaders.scoping.valid subcases:
- local_int_variable_hides_struct_type_vertex
- local_int_variable_hides_struct_type_fragment
- local_struct_variable_hides_struct_type_vertex
- local_struct_variable_hides_struct_type_fragment

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
8 years agomesa: Change GLboolean to bool in GenerateMipmap target checker.
Kenneth Graunke [Fri, 4 Mar 2016 05:38:32 +0000 (21:38 -0800)]
mesa: Change GLboolean to bool in GenerateMipmap target checker.

This is not API facing, so just use bool.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agomesa: Make GenerateMipmap check the target before finding an object.
Kenneth Graunke [Thu, 3 Mar 2016 09:03:59 +0000 (01:03 -0800)]
mesa: Make GenerateMipmap check the target before finding an object.

If glGenerateMipmap was called with a bogus target, then it would
pass that to _mesa_get_current_tex_object(), which would raise a
_mesa_problem() telling people to file bugs.  We'd then do the
proper error checking, raise an error, and bail.

Doing the check first avoids the _mesa_problem().  The DSA variant
doesn't take a target parameter, so we leave the target validation
exactly as it was in that case.

Fixes one dEQP GLES2 test:
dEQP-GLES2.functional.negative_api.texture.generatemipmap.invalid_target.

v2: Rebase on Antia's recent patch to this area.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com> [v1]
Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agogm107/ir: add emission for ATOMS
Samuel Pitoiset [Mon, 7 Mar 2016 17:57:39 +0000 (18:57 +0100)]
gm107/ir: add emission for ATOMS

This allows to perform atomic operations on shared memory.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agotgsi: fix parsing of shared memory declarations
Samuel Pitoiset [Mon, 7 Mar 2016 17:52:19 +0000 (18:52 +0100)]
tgsi: fix parsing of shared memory declarations

The SHARED TGSI keyword is only allowed with TGSI_FILE_MEMORY and not
with TGSI_FILE_BUFFER. I have found this by using the nouveau_compiler
from command line.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.2" <mesa-stable@lists.freedesktop.org>
8 years agogm107/ir: add emission for BAR
Samuel Pitoiset [Tue, 1 Mar 2016 17:57:58 +0000 (18:57 +0100)]
gm107/ir: add emission for BAR

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agogk110/ir: add missing src predicate emission for BAR.RED
Samuel Pitoiset [Sun, 28 Feb 2016 21:44:24 +0000 (22:44 +0100)]
gk110/ir: add missing src predicate emission for BAR.RED

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agogk110/ir: allow to emit immediates for BAR
Samuel Pitoiset [Sun, 28 Feb 2016 21:43:50 +0000 (22:43 +0100)]
gk110/ir: allow to emit immediates for BAR

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agogk110/ir: fix wrong emission of BAR.SYNC
Samuel Pitoiset [Sun, 28 Feb 2016 21:38:43 +0000 (22:38 +0100)]
gk110/ir: fix wrong emission of BAR.SYNC

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0/ir: make sure that thread count immediate for BAR fit
Samuel Pitoiset [Mon, 7 Mar 2016 17:26:43 +0000 (18:26 +0100)]
nvc0/ir: make sure that thread count immediate for BAR fit

The limit of the thread count immediate value is 12 bits.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agosvga: add new surface-write-flushes HUD query
Brian Paul [Fri, 4 Mar 2016 22:59:32 +0000 (15:59 -0700)]
svga: add new surface-write-flushes HUD query

To know when we're flushing the command buffer because we need to
write to surface in the command buffer.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
8 years agosvga: add new flush-time HUD query
Brian Paul [Fri, 4 Mar 2016 16:14:34 +0000 (09:14 -0700)]
svga: add new flush-time HUD query

To measure the time spent flushing the command buffer.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
8 years agosvga: also dump SVGA3D_BUFFER surfaces in svga_screen_cache_dump()
Brian Paul [Fri, 4 Mar 2016 22:58:02 +0000 (15:58 -0700)]
svga: also dump SVGA3D_BUFFER surfaces in svga_screen_cache_dump()

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
8 years agomesa: flip current tf object back to default if current is being deleted
Ilia Mirkin [Sun, 6 Mar 2016 17:36:19 +0000 (12:36 -0500)]
mesa: flip current tf object back to default if current is being deleted

In the rather unusual case of Bind + Delete, we need to make sure that
we unbind the current tf object.

Fixes dEQP-GLES3.functional.lifetime.delete_bound.transform_feedback

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agoglsl: avoid stack smashing when there are too many attributes
Ilia Mirkin [Sun, 6 Mar 2016 17:19:04 +0000 (12:19 -0500)]
glsl: avoid stack smashing when there are too many attributes

This fixes a crash in

dEQP-GLES3.functional.transform_feedback.array_element.separate.points.lowp_mat3x2

and likely others. The vertex shader has > 16 input variables (without
explicit locations), which causes us to index outside of the to_assign
array.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
8 years agoi965/vec4: Propagate swizzles correctly during copy propagation.
Francisco Jerez [Sat, 27 Feb 2016 01:42:27 +0000 (17:42 -0800)]
i965/vec4: Propagate swizzles correctly during copy propagation.

This simplifies the code that iterates over the per-component values
found in the matching copy_entry struct and checks whether the
register regions that were copied to each component are similar enough
to be treated as a single (reswizzled) value which can be propagated
into the current instruction.

Aside from being scattered between opt_copy_propagation(),
try_copy_propagate(), and try_constant_propagate(), what I found
terribly confusing about the preexisting logic was that
opt_copy_propagation() tried to reorder the array of values according
to the swizzle of the instruction source, which meant one would have
had to invert the reordering applied at the top level in order to find
out which component to take from each value (we were just taking the
i-th component from the i-th value, which is not correct in general).
The saturate mask was also being swizzled incorrectly.

This consolidates the logic for matching multiple components of a
copy_entry into a single function which returns the result as a
regular src_reg on success, as if the copy had been performed with a
single MOV instruction copying all components of the src_reg into the
destination.

Fixes several ARB_vertex_program MOV test-cases from:
 https://cgit.freedesktop.org/~kwg/piglit/log/?h=arb_program

Acked-by: Matt Turner <mattst88@gmail.com>
8 years agoi965: Don't try copy propagation if constant propagation succeeded.
Francisco Jerez [Sat, 27 Feb 2016 01:28:03 +0000 (17:28 -0800)]
i965: Don't try copy propagation if constant propagation succeeded.

It cannot get any better.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agoi965/vec4: Use swizzle() to swizzle immediates during constant propagation.
Francisco Jerez [Sat, 27 Feb 2016 01:20:19 +0000 (17:20 -0800)]
i965/vec4: Use swizzle() to swizzle immediates during constant propagation.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agoi965: Add support for swizzling arbitrary immediates to (brw_)swizzle().
Francisco Jerez [Sat, 27 Feb 2016 01:12:27 +0000 (17:12 -0800)]
i965: Add support for swizzling arbitrary immediates to (brw_)swizzle().

Scalar immediates used to be handled correctly by swizzle() (as the
identity) but since commit 58fa9d47b536403c4e3ca5d6a2495691338388fd it
will corrupt the contents of the immediate.  Vector immediates were
never handled correctly, but we had ad-hoc code to swizzle VF
immediates in the vec4 copy propagation pass.  This takes care of
swizzling V and UV in addition.

v2: Don't implement swizzling of V/UV immediates (Matt).  If you need
    to swizzle an integer vector immediate in the future apply the
    following diff to go back to v1:

--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -119,11 +119,10 @@ brw_swap_cmod(uint32_t cmod)
 static unsigned
 imm_shift(enum brw_reg_type type, unsigned i)
 {
-   assert(type != BRW_REGISTER_TYPE_UV && type != BRW_REGISTER_TYPE_V &&
-          "Not implemented.");
-
    if (type == BRW_REGISTER_TYPE_VF)
       return 8 * (i & 3);
+   else if (type == BRW_REGISTER_TYPE_UV || type == BRW_REGISTER_TYPE_V)
+      return 4 * (i & 7);
    else
       return 0;
 }

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agoi965: Pass symbolic swizzle to brw_swizzle() as a single argument.
Francisco Jerez [Sat, 27 Feb 2016 01:04:38 +0000 (17:04 -0800)]
i965: Pass symbolic swizzle to brw_swizzle() as a single argument.

And replace brw_swizzle1() with brw_swizzle().  Seems slightly cleaner
and will allow reusing brw_swizzle() in the vec4 back-end more easily.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agonvc0: reset TFB bufctx when we no longer hold a reference to the buffers
Ilia Mirkin [Tue, 16 Feb 2016 06:02:52 +0000 (01:02 -0500)]
nvc0: reset TFB bufctx when we no longer hold a reference to the buffers

This fixes some use-after-free situations in dEQP when an xfb state is
removed, and then a clear is triggered, which only does a partial
validation. It would attempt to read the no-longer-valid buffers,
resulting in crashes.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
8 years agonv50/ir: using sampleid/pos shouldn't force per-sample interpolation
Ilia Mirkin [Sat, 27 Feb 2016 16:05:04 +0000 (11:05 -0500)]
nv50/ir: using sampleid/pos shouldn't force per-sample interpolation

See https://www.khronos.org/bugzilla/show_bug.cgi?id=1462

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agost/mesa: don't force per-sample interp if only sampleid/pos are used
Ilia Mirkin [Sat, 27 Feb 2016 16:01:27 +0000 (11:01 -0500)]
st/mesa: don't force per-sample interp if only sampleid/pos are used

The OES extensions clarify this behaviour to differentiate between
per-sample invocation and per-sample interpolation. Using sampleid/pos
will force per-sample invocation but not per-sample interpolation.

See https://www.khronos.org/bugzilla/show_bug.cgi?id=1462

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agoswrast: fix GL_ANY_SAMPLES_PASSED values in Result
Ilia Mirkin [Fri, 4 Mar 2016 02:00:06 +0000 (21:00 -0500)]
swrast: fix GL_ANY_SAMPLES_PASSED values in Result

Since commit 922be4eab, the expectation is that the query result
contains the correct value. Unfortunately swrast does not distinguish
between GL_SAMPLES_PASSED and GL_ANY_SAMPLES_PASSED. As a result, we
must fix up the query result in a post-draw fixup.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94274
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Tested-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Cc: "11.2" <mesa-stable@lists.freedesktop.org>
8 years agost/mesa: 78-column wrapping in st_extensions.c
Brian Paul [Fri, 4 Mar 2016 23:28:00 +0000 (16:28 -0700)]
st/mesa: 78-column wrapping in st_extensions.c

Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
8 years agogallium/util: add new comments, assertions in u_debug_refcnt.c
Brian Paul [Fri, 4 Mar 2016 20:19:34 +0000 (13:19 -0700)]
gallium/util: add new comments, assertions in u_debug_refcnt.c

Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
8 years agogallium/util: update comments and URL in u_debug_refcnt.c
Brian Paul [Fri, 4 Mar 2016 20:05:33 +0000 (13:05 -0700)]
gallium/util: update comments and URL in u_debug_refcnt.c

Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
8 years agogallium/util: make stream variable static in u_debug_refcnt.c
Brian Paul [Fri, 4 Mar 2016 20:03:55 +0000 (13:03 -0700)]
gallium/util: make stream variable static in u_debug_refcnt.c

Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
8 years agogallium/util: re-indent u_debug_refcnt.[ch]
Brian Paul [Fri, 4 Mar 2016 20:02:46 +0000 (13:02 -0700)]
gallium/util: re-indent u_debug_refcnt.[ch]

Wrap comments to 78 columns, etc.

Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
8 years agogallium/tests: silence warning in compute.c
Brian Paul [Sat, 5 Mar 2016 01:19:48 +0000 (18:19 -0700)]
gallium/tests: silence warning in compute.c

compute.c: In function ‘launch_grid’:
compute.c:435:20: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
         info.input = input;
                    ^

Maybe the pipe_grid_info::input field should be const void *?

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
8 years agoglsl: replace remaining tabs in link_varyings.cpp
Timothy Arceri [Wed, 24 Feb 2016 08:39:24 +0000 (19:39 +1100)]
glsl: replace remaining tabs in link_varyings.cpp

Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
8 years agoglsl: replace remaining tabs in link_uniforms.cpp
Timothy Arceri [Wed, 24 Feb 2016 08:33:28 +0000 (19:33 +1100)]
glsl: replace remaining tabs in link_uniforms.cpp

Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
8 years agodocs: mark align layout qualifier as DONE
Timothy Arceri [Tue, 12 Jan 2016 03:45:02 +0000 (14:45 +1100)]
docs: mark align layout qualifier as DONE

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
8 years agoglsl: apply align layout qualifier rules to block offsets
Timothy Arceri [Tue, 12 Jan 2016 04:53:53 +0000 (15:53 +1100)]
glsl: apply align layout qualifier rules to block offsets

From Section 4.4.5 (Uniform and Shader Storage Block Layout
Qualifiers) of the OpenGL 4.50 spec:

  "The align qualifier makes the start of each block member have a
  minimum byte alignment.  It does not affect the internal layout
  within each member, which will still follow the std140 or std430
  rules. The specified alignment must be a power of 2, or a
  compile-time error results.

  The actual alignment of a member will be the greater of the
  specified align alignment and the standard (e.g., std140) base
  alignment for the member's type. The actual offset of a member is
  computed as follows: If offset was declared, start with that
  offset, otherwise start with the next available offset. If the
  resulting offset is not a multiple of the actual alignment,
  increase it to the first offset that is a multiple of the actual
  alignment. This results in the actual offset the member will have.

  When align is applied to an array, it affects only the start of
  the array, not the array's internal stride. Both an offset and an
  align qualifier can be specified on a declaration.

  The align qualifier, when used on a block, has the same effect as
  qualifying each member with the same align value as declared on
  the block, and gets the same compile-time results and errors as if
  this had been done. As described in general earlier, an individual
  member can specify its own align, which overrides the block-level
  align, but just for that member.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
8 years agoglsl: parse align layout qualifier
Timothy Arceri [Tue, 12 Jan 2016 01:41:32 +0000 (12:41 +1100)]
glsl: parse align layout qualifier

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
8 years agodocs: mark explicit byte offsets as DONE
Timothy Arceri [Fri, 8 Jan 2016 12:20:25 +0000 (23:20 +1100)]
docs: mark explicit byte offsets as DONE

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
8 years agoglsl: use explicit offset when lowering buffer access
Timothy Arceri [Fri, 8 Jan 2016 11:49:24 +0000 (22:49 +1100)]
glsl: use explicit offset when lowering buffer access

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
8 years agoglsl: copy explicit offset to uniform storage
Timothy Arceri [Fri, 8 Jan 2016 10:06:41 +0000 (21:06 +1100)]
glsl: copy explicit offset to uniform storage

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
8 years agoglsl: update comment on offset field
Timothy Arceri [Wed, 30 Dec 2015 04:03:41 +0000 (15:03 +1100)]
glsl: update comment on offset field

The old comment was for the location not the offset, we now use
the field for block members so mention that also.

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
8 years agoglsl: add offset to glsl interface type
Timothy Arceri [Wed, 30 Dec 2015 02:31:24 +0000 (13:31 +1100)]
glsl: add offset to glsl interface type

In this patch we also copy the offset value from the ast and
implement offset linking rules by adding it to the record_compare()
function.

From Section 4.4.5 (Uniform and Shader Storage Block Layout Qualifiers)
of the GLSL 4.50 spec:

   "Two blocks linked together in the same program with the same block
   name must have the exact same set of members qualified with
   offset and their integral-constant-expression values must be the
   same, or a link-time error results."

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
8 years agoglsl: apply compile-time rules for the offset layout qualifier
Timothy Arceri [Wed, 30 Dec 2015 00:09:22 +0000 (11:09 +1100)]
glsl: apply compile-time rules for the offset layout qualifier

This implements the rules for the offset qualifier on block members.

From Section 4.4.5 (Uniform and Shader Storage Block Layout Qualifiers)
of the GLSL 4.50 spec:

   "The offset qualifier can only be used on block members of blocks
   declared with std140 or std430 layouts."

   ...

   "It is a compile-time error to specify an offset that is smaller than
   the offset of the previous member in the block or that lies within the
   previous member of the block."

   ...

   "The specified offset must be a multiple of the base alignment of the
   type of the block member it qualifies, or a compile-time error results."

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
8 years agoglsl: enable offset layout qualifier for ARB_enhanced_layouts
Timothy Arceri [Tue, 29 Dec 2015 10:15:52 +0000 (21:15 +1100)]
glsl: enable offset layout qualifier for ARB_enhanced_layouts

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
8 years agoglsl: reject invalid input layout qualifiers
Timothy Arceri [Sat, 13 Feb 2016 05:17:12 +0000 (16:17 +1100)]
glsl: reject invalid input layout qualifiers

Global in validation is already handled, this will do the validation
for variables, blocks and block members.

This fixes some CTS tests for the new enhanced layouts transform
feedback qualifiers.

V2: add some more valid input flags
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
8 years agoglsl: only apply default stream to output blocks
Timothy Arceri [Thu, 25 Feb 2016 23:59:14 +0000 (10:59 +1100)]
glsl: only apply default stream to output blocks

This is needed to allow invalid qualifier checks on inputs.

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
8 years agoglsl: rework parsing of blocks
Timothy Arceri [Sun, 14 Feb 2016 03:45:04 +0000 (14:45 +1100)]
glsl: rework parsing of blocks

Previously interface blocks were giving the global default flags of
uniform blocks. This meant we could not check for invalid qualifiers
on interface blocks because they always contained invalid flags.

This changes parsing so that interface blocks now get an empty
set of layouts.

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
8 years agoglsl: don't apply uniform/buffer layouts to interface blocks
Timothy Arceri [Sun, 14 Feb 2016 05:18:36 +0000 (16:18 +1100)]
glsl: don't apply uniform/buffer layouts to interface blocks

If the following patch we will stop setting these layouts by default
on interface blocks, so we need to do this to avoid hitting the
assert.

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
8 years agoi965: Only magnify depth for 3D textures, not array textures.
Kenneth Graunke [Thu, 3 Mar 2016 19:13:29 +0000 (11:13 -0800)]
i965: Only magnify depth for 3D textures, not array textures.

When BaseLevel > 0, we magnify the dimensions to fill out the size of
miplevels [0..BaseLevel).  In particular, this was magnifying depth,
thinking that the depth doubles at each level.  This is perfectly
reasonable for 3D textures, but dead wrong for array textures.

Changing the depth != 1 condition to a target == GL_TEXTURE_3D check
should make this only happen in the appropriate cases.

Fixes about 32 dEQP tests:
- dEQP-GLES31.functional.texture.gather.*.level_{1,2}

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Cc: mesa-stable@lists.freedesktop.org
8 years agoi965/vec4: add opportunistic behaviour to opt_vector_float()
Juan A. Suarez Romero [Wed, 2 Mar 2016 12:21:02 +0000 (13:21 +0100)]
i965/vec4: add opportunistic behaviour to opt_vector_float()

opt_vector_float() transforms several scalar MOV operations to a single
vectorial MOV.

This is done when those MOV covers all the components of the destination
register. So something like:

mov vgrf3.0.xy:D, 0D
mov vgrf3.0.w:D, 1065353216D
mov vgrf3.0.z:D, 0D

is transformed in:

mov vgrf3.0:F, [0F, 0F, 0F, 1F]

But there are cases where not all the components are written. For
example, in:

mov vgrf2.0.x:D, 1073741824D
mov vgrf3.0.xy:D, 0D
mov vgrf3.0.w:D, 1065353216D
mov vgrf4.0.xy:D, 1065353216D
mov vgrf4.0.w:D, 0D
mov vgrf6.0:UD, u4.xyzw:UD

Nor vgrf3 nor vgrf4 .z components are written, so the optimization is
not applied.

But it could be applied anyway with the components covered, using a
writemask to select the ones written. So we could transform it in:

mov vgrf2.0.x:D, 1073741824D
mov vgrf3.0.xyw:F, [0F, 0F, 0F, 1F]
mov vgrf4.0.xyw:F, [1F, 1F, 0F, 0F]
mov vgrf6.0:UD, u4.xyzw:UD

This commit does precisely that: opportunistically apply
opt_vector_float() when possible.

total instructions in shared programs: 7124660 -> 7114784 (-0.14%)
instructions in affected programs: 443078 -> 433202 (-2.23%)
helped: 4998
HURT: 0

total cycles in shared programs: 64757760 -> 64728016 (-0.05%)
cycles in affected programs: 1401686 -> 1371942 (-2.12%)
helped: 3243
HURT: 38

v2: change vectorize_mov() signature (Matt).
v3: take in account predicates (Juan).
v4 [mattst88]: Update shader-db numbers. Fix some whitespace issues.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
8 years agost/xlib: Don't destroy screen on XCloseDisplay()
George Kyriazis [Fri, 4 Mar 2016 19:26:00 +0000 (12:26 -0700)]
st/xlib: Don't destroy screen on XCloseDisplay()

screen may still be used by other resources that are not yet freed.
To correctly fix this there will be a need to account for resources
differently, but this quick fix is not any worse than the original
code that leaked screens anyway.

Reviewed-by: Brian Paul <brianp@vmware.com>
8 years agoi965/fs: Optimize float conversions of byte/word extract.
Matt Turner [Thu, 21 Jan 2016 17:10:09 +0000 (09:10 -0800)]
i965/fs: Optimize float conversions of byte/word extract.

   instructions in affected programs: 31535 -> 29966 (-4.98%)
   helped: 23

   cycles in affected programs: 272648 -> 266022 (-2.43%)
   helped: 14
   HURT: 1

The patch decreases the number of instructions in the two Unigine
programs by:

 #1721: 4374 -> 4155 instructions (-5.01%)
 #1706: 3582 -> 3363 instructions (-6.11%)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agonir: Recognize open-coded extract_u16.
Matt Turner [Wed, 3 Feb 2016 22:28:31 +0000 (14:28 -0800)]
nir: Recognize open-coded extract_u16.

No shader-db changes, but does recognize some extract_u16 which enables
the next patch to optimize some code.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agonir: Recognize open-coded extract_u8.
Matt Turner [Thu, 21 Jan 2016 17:09:48 +0000 (09:09 -0800)]
nir: Recognize open-coded extract_u8.

Two shaders that appear in Unigine benchmarks (Heaven and Valley) unpack
three bytes from an integer and convert each into a float:

   float((val >> 16u) & 0xffu)
   float((val >>  8u) & 0xffu)
   float((val >>  0u) & 0xffu)

Instead of shifting, masking, and type converting like this:

   shr(8)          g15<1>UD        g25<8,8,1>UD    0x00000010UD
   and(8)          g16<1>UD        g15<8,8,1>UD    0x000000ffUD
   mov(8)          g17<1>F         g16<8,8,1>UD

   shr(8)          g18<1>UD        g25<8,8,1>UD    0x00000008UD
   and(8)          g19<1>UD        g18<8,8,1>UD    0x000000ffUD
   mov(8)          g20<1>F         g19<8,8,1>UD

   and(8)          g21<1>UD        g25<8,8,1>UD    0x000000ffUD
   mov(8)          g22<1>F         g21<8,8,1>UD

i965 can simply extract a byte and convert to float in a single
instruction:

   mov(8)          g17<1>F         g25.2<32,8,4>UB
   mov(8)          g20<1>F         g25.1<32,8,4>UB
   mov(8)          g22<1>F         g25.0<32,8,4>UB

This patch implements the first step: recognizing byte extraction. A
later patch will optimize out the conversion to float.

   instructions in affected programs: 28568 -> 27450 (-3.91%)
   helped: 7

   cycles in affected programs: 210076 -> 203144 (-3.30%)
   helped: 7

This patch decreases the number of instructions in the two Unigine
programs by:

 #1721: 4520 -> 4374 instructions (-3.23%)
 #1706: 3752 -> 3582 instructions (-4.53%)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agost/xlib: Hang off screen destructor off main XCloseDisplay() callback.
George Kyriazis [Thu, 3 Mar 2016 01:28:00 +0000 (18:28 -0700)]
st/xlib: Hang off screen destructor off main XCloseDisplay() callback.

This resolves some order dependencies between the already existing
callback the newly created one.

Tested-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
8 years agost/xlib: Support unlimited number of display connections
George Kyriazis [Thu, 3 Mar 2016 01:28:00 +0000 (18:28 -0700)]
st/xlib: Support unlimited number of display connections

There is a limit of 10 display connections, which was a
problem for apps/tests that were continuously opening/closing display
connections.

This fix uses XAddExtension() and XESetCloseDisplay() to keep track
of the status of the display connections from the X server, freeing
mesa-related data as X displays get destroyed by the X server.

Poster child is the VTK "TimingTests"

Tested-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
8 years agosvga: add new command-buffer-size HUD query
Brian Paul [Mon, 29 Feb 2016 21:26:12 +0000 (14:26 -0700)]
svga: add new command-buffer-size HUD query

To plot a graph of the command buffer size.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
8 years agosvga: add new svga_winsys_context::get_command_buffer_size()
Brian Paul [Mon, 29 Feb 2016 21:25:09 +0000 (14:25 -0700)]
svga: add new svga_winsys_context::get_command_buffer_size()

To ask how large the current command buffer is.  Will be used for
a new GALLIUM_HUD graph.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
8 years agosvga: reorder SVGA_QUERY_ switch cases to match declaration order
Brian Paul [Mon, 29 Feb 2016 19:01:10 +0000 (12:01 -0700)]
svga: reorder SVGA_QUERY_ switch cases to match declaration order

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
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>