Commit Graph

76841 Commits

Author SHA1 Message Date
Kenneth Graunke 07ec67d85c 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>
2016-03-07 23:01:43 -08:00
Tim Rowley 90f9df3210 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>
2016-03-07 17:22:24 -06:00
Tim Rowley 035d39b539 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>
2016-03-07 16:58:48 -06:00
Kenneth Graunke af41c0b7e0 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>
2016-03-07 14:09:55 -08:00
Kenneth Graunke c4960068d5 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>
2016-03-07 14:09:31 -08:00
Kenneth Graunke 1107e48b9a 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>
2016-03-07 14:01:34 -08:00
Kenneth Graunke 2f8a43586e 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>
2016-03-07 14:01:22 -08:00
Samuel Pitoiset 8f99c1bbce 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>
2016-03-07 22:13:14 +01:00
Samuel Pitoiset 7f8565f0b2 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>
2016-03-07 22:13:08 +01:00
Samuel Pitoiset c82086f7e9 gm107/ir: add emission for BAR
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
2016-03-07 18:39:50 +01:00
Samuel Pitoiset 8a109c0375 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>
2016-03-07 18:39:48 +01:00
Samuel Pitoiset f4d2d49152 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>
2016-03-07 18:39:46 +01:00
Samuel Pitoiset cba89fdaa1 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>
2016-03-07 18:39:43 +01:00
Samuel Pitoiset 5777e87bed 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>
2016-03-07 18:39:41 +01:00
Brian Paul 3af78b426e 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>
2016-03-07 09:33:15 -07:00
Brian Paul 7e8cf34546 svga: add new flush-time HUD query
To measure the time spent flushing the command buffer.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
2016-03-07 09:33:15 -07:00
Brian Paul 903afc370f svga: also dump SVGA3D_BUFFER surfaces in svga_screen_cache_dump()
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
2016-03-07 09:33:15 -07:00
Ilia Mirkin 0941ef3dd5 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>
2016-03-07 00:36:08 -05:00
Ilia Mirkin f6827e20d1 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>
2016-03-07 00:36:08 -05:00
Francisco Jerez 3dd0441f6c 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>
2016-03-06 12:22:40 -08:00
Francisco Jerez c70b7c80e3 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>
2016-03-06 12:22:40 -08:00
Francisco Jerez dcf5e19e65 i965/vec4: Use swizzle() to swizzle immediates during constant propagation.
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2016-03-06 12:22:40 -08:00
Francisco Jerez ff7a2b489e 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 58fa9d47b5 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>
2016-03-06 12:22:40 -08:00
Francisco Jerez 537d3df974 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>
2016-03-06 12:22:39 -08:00
Ilia Mirkin ff085d014e 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>
2016-03-06 10:14:52 -05:00
Ilia Mirkin fa43c4bd99 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>
2016-03-05 23:26:03 -05:00
Ilia Mirkin 313205cb8f 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>
2016-03-05 23:26:03 -05:00
Ilia Mirkin dcbf8377be 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>
2016-03-05 23:25:52 -05:00
Brian Paul a4678311be st/mesa: 78-column wrapping in st_extensions.c
Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
2016-03-05 09:21:05 -07:00
Brian Paul 9e6a6bd575 gallium/util: add new comments, assertions in u_debug_refcnt.c
Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
2016-03-05 09:20:34 -07:00
Brian Paul b6a607b221 gallium/util: update comments and URL in u_debug_refcnt.c
Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
2016-03-05 09:20:28 -07:00
Brian Paul cbca6964e2 gallium/util: make stream variable static in u_debug_refcnt.c
Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
2016-03-05 09:20:23 -07:00
Brian Paul fb0abedce7 gallium/util: re-indent u_debug_refcnt.[ch]
Wrap comments to 78 columns, etc.

Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
2016-03-05 09:20:14 -07:00
Brian Paul a7ba29f6d8 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>
2016-03-05 09:15:44 -07:00
Timothy Arceri 31943e6ba5 glsl: replace remaining tabs in link_varyings.cpp
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
2016-03-05 20:50:10 +11:00
Timothy Arceri e2415e8467 glsl: replace remaining tabs in link_uniforms.cpp
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
2016-03-05 20:50:05 +11:00
Timothy Arceri 3322cb7b8d 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>
2016-03-05 19:39:13 +11:00
Timothy Arceri 037f68d81e 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>
2016-03-05 19:39:07 +11:00
Timothy Arceri 5a27fefffe glsl: parse align layout qualifier
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
2016-03-05 19:39:01 +11:00
Timothy Arceri 22b0082b9d docs: mark explicit byte offsets as DONE
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
2016-03-05 19:38:55 +11:00
Timothy Arceri 802262c0af glsl: use explicit offset when lowering buffer access
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
2016-03-05 19:38:49 +11:00
Timothy Arceri 96527c3cf2 glsl: copy explicit offset to uniform storage
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
2016-03-05 19:38:44 +11:00
Timothy Arceri e12a49ac12 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>
2016-03-05 19:38:39 +11:00
Timothy Arceri 9f24f42c49 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>
2016-03-05 19:38:34 +11:00
Timothy Arceri 8abed7f185 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>
2016-03-05 19:38:30 +11:00
Timothy Arceri 6f45484ac7 glsl: enable offset layout qualifier for ARB_enhanced_layouts
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
2016-03-05 19:38:26 +11:00
Timothy Arceri 1824ff1c2a 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>
2016-03-05 19:07:09 +11:00
Timothy Arceri bd53cc7b45 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>
2016-03-05 19:07:04 +11:00
Timothy Arceri 78d3098c05 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>
2016-03-05 19:07:00 +11:00
Timothy Arceri d244986bf2 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>
2016-03-05 19:06:56 +11:00