mesa.git
8 years agoglsl: Clarify "mask" variable in add_interface_variables().
Kenneth Graunke [Tue, 29 Mar 2016 18:37:48 +0000 (11:37 -0700)]
glsl: Clarify "mask" variable in add_interface_variables().

This is a bitfield of which stages refer to a variable.  It is not used
to mask off bits.  In fact, it's used to contribute additional bits.

Rename it and tidy a bit of the logic.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
8 years agoglsl: Pass stage to add_interface_variables().
Kenneth Graunke [Tue, 29 Mar 2016 18:31:10 +0000 (11:31 -0700)]
glsl: Pass stage to add_interface_variables().

add_interface_variables is supposed to add variables from either the
first or last stage of a linked shader.  But it has no way of knowing
the stage it's being asked to process, which makes it impossible to
produce correct stagerefs.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
8 years agoglsl: Make vertex ID lowering declare gl_BaseVertex as hidden.
Kenneth Graunke [Sat, 2 Apr 2016 03:52:33 +0000 (20:52 -0700)]
glsl: Make vertex ID lowering declare gl_BaseVertex as hidden.

If the GL_ARB_shader_draw_parameters extension is enabled, we'll already
have a gl_BaseVertex variable.  It will have var->how_declared set to
ir_var_declared_implicitly, and will appear in the program resource
list.

If not, we make one for internal use.  We don't want it to be listed
in the program resource list, as the application won't be expecting
it.  Marking it hidden will properly exclude it.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agoglsl: Exclude ir_var_hidden variables from the program resource list.
Kenneth Graunke [Sat, 2 Apr 2016 04:00:32 +0000 (21:00 -0700)]
glsl: Exclude ir_var_hidden variables from the program resource list.

We occasionally generate variables internally that we want to exclude
from the program resource list, as applications won't be expecting them
to be present.

The next patch will make use of this.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agomesa: Make _mesa_choose_tex_format() handle stencil textures.
Kenneth Graunke [Mon, 21 Mar 2016 21:01:24 +0000 (14:01 -0700)]
mesa: Make _mesa_choose_tex_format() handle stencil textures.

This is necessary for ARB_texture_stencil8 support on classic drivers.
Presumably Gallium works because it implements its own ChooseTexFormat.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
8 years agoglsl: Don't require matching centroid qualifiers
Jordan Justen [Sat, 12 Mar 2016 00:44:06 +0000 (16:44 -0800)]
glsl: Don't require matching centroid qualifiers

Note: This patch appears to violate older OpenGL and OpenGLES specs.

The OpenGLES GLSL 3.1 and OpenGL GLSL 4.3 specifications both remove
the requirement for the output and input centroid qualifiers to match.

The deqp
dEQP-GLES3.functional.shaders.linkage.varying.rules.differing_interpolation_2
test wants the newer OpenGLES 3.1 specification behavior, even for
OpenGLES 3.0. This patch simply removes the checking in all cases.

The OpenGLES 3.0 conformance test suite doesn't appear to require the
older ("must match") spec behavior.

For reference, here are the relavent spec citations:

  The OpenGL 4.2 spec says: "the last active shader stage output
  variables and fragment shader input variables of the same name must
  match in type and qualification (other than out matching to in)"

  The OpenGL 4.3 spec says: "interpolation qualification (e.g., flat)
  and auxiliary qualification (e.g. centroid) may differ."

  The OpenGLES GLSL 3.00.4 specification says: "The output of the
  vertex shader and the input of the fragment shader form an
  interface. For this interface, vertex shader output variables and
  fragment shader input variables of the same name must match in type
  and qualification (other than precision and out matching to in)."

  The OpenGLES GLSL 3.10 Specification says: "interpolation
  qualification (e.g., flat) and auxiliary qualification (e.g.
  centroid) may differ"

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92743
Bugzilla: https://cvs.khronos.org/bugzilla/show_bug.cgi?id=7819
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Cc: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agogallium: distinguish between shader IR in get_compute_param
Bas Nieuwenhuizen [Fri, 25 Mar 2016 01:06:50 +0000 (02:06 +0100)]
gallium: distinguish between shader IR in get_compute_param

For radeonsi, native and TGSI use different compilers and this results
in different limits for different IR's.

The set we strictly need for radeonsi is only the MAX_BLOCK_SIZE
and MAX_THREADS_PER_BLOCK params, but I added a few others as shader
related that seemed like they would also typically depend on the
compiler.

Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agogallium: add global buffer memory barrier bit
Bas Nieuwenhuizen [Thu, 24 Mar 2016 22:11:03 +0000 (23:11 +0100)]
gallium: add global buffer memory barrier bit

Currently radeonsi synchronizes after every dispatch and Clover
does nothing to synchronize. This is overzealous, especially with
GL compute, so add a barrier for global buffers.

Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agogallium: add threads per block TGSI property
Bas Nieuwenhuizen [Mon, 28 Mar 2016 00:40:03 +0000 (02:40 +0200)]
gallium: add threads per block TGSI property

The value 0 for unknown has been chosen to so that
drivers using tgsi_scan_shader do not need to detect
missing properties if they zero-initialize the struct.

Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agogallium: add compute shader IR type
Bas Nieuwenhuizen [Thu, 17 Mar 2016 13:15:39 +0000 (14:15 +0100)]
gallium: add compute shader IR type

Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: remove tabs and fix some other style issues in glcpp-parse.y
Timothy Arceri [Thu, 31 Mar 2016 05:49:59 +0000 (16:49 +1100)]
glsl: remove tabs and fix some other style issues in glcpp-parse.y

Note there are still tabs left in the parser rules.

Acked-by: Dave Airlie <airlied@redhat.com>
8 years agoi965: Add an implemnetation of nir_op_fquantize2f16
Jason Ekstrand [Fri, 25 Mar 2016 20:57:15 +0000 (13:57 -0700)]
i965: Add an implemnetation of nir_op_fquantize2f16

Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agonir: Add an opcode for stomping a 32-bit value to 16-bit precision
Jason Ekstrand [Fri, 25 Mar 2016 20:58:17 +0000 (13:58 -0700)]
nir: Add an opcode for stomping a 32-bit value to 16-bit precision

This correlates directly to the SPIR-V opcode OpQuantizeToF16

Reviewed-by: Rob Clark <robdclark@gmail.com>
8 years agonvc0: enable compute shaders on GK104 and GM107+
Samuel Pitoiset [Mon, 8 Feb 2016 17:19:47 +0000 (18:19 +0100)]
nvc0: enable compute shaders on GK104 and GM107+

Compute support on GK110 is still unstable for weird reasons, but
this can be fixed later as the NVF0_COMPUTE envvar prevent using
compute.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0: bump the maximum number of UBOs for compute on Kepler
Samuel Pitoiset [Mon, 8 Feb 2016 17:20:02 +0000 (18:20 +0100)]
nvc0: bump the maximum number of UBOs for compute on Kepler

The maximum number of uniform blocks (MAX_COMPUTE_UNIFORM_BLOCKS)
per compute program must be at least 12.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0/ir: do not lower shared+atomics on GM107+
Samuel Pitoiset [Mon, 7 Mar 2016 17:56:21 +0000 (18:56 +0100)]
nvc0/ir: do not lower shared+atomics on GM107+

For Maxwell, the ATOMS instruction can be used to perform atomic
operations on shared memory instead of this load/store lowering pass.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0/ir: add atomics support on shared memory for Kepler
Samuel Pitoiset [Wed, 10 Feb 2016 21:37:42 +0000 (22:37 +0100)]
nvc0/ir: add atomics support on shared memory for Kepler

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0/ir: fix wrong pred emission for ld lock on GK104
Samuel Pitoiset [Mon, 22 Feb 2016 22:20:30 +0000 (23:20 +0100)]
nvc0/ir: fix wrong pred emission for ld lock on GK104

This fixes 84b9b8f (nvc0/ir: add missing emission of locked load
predicate).

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0/ir: add support for compute UBOs on Kepler
Samuel Pitoiset [Wed, 30 Mar 2016 22:50:39 +0000 (00:50 +0200)]
nvc0/ir: add support for compute UBOs on Kepler

Make sure to avoid out of bounds access in presence of indirect
array indexing by loading the size from the driver constant buffer.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0: add indirect compute support on Kepler
Samuel Pitoiset [Thu, 14 Jan 2016 17:24:53 +0000 (18:24 +0100)]
nvc0: add indirect compute support on Kepler

The grid size is stored as three 32-bits integers in the indirect
buffer but the launch descriptor uses a 32-bits integer for both
griddim_y and griddim_z like this (z << 16) | y. To make it work,
the 16 high bits of griddim_y are overwritten by griddim_z.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0: reduce likelihood of collision for real buffers on Kepler
Samuel Pitoiset [Mon, 22 Feb 2016 20:44:25 +0000 (21:44 +0100)]
nvc0: reduce likelihood of collision for real buffers on Kepler

Reduce likelihood of collision with real buffers by placing the
hole at the top of the 4G area. This fixes some indirect draw+compute
tests with large buffers.

Suggested by Ilia Mirkin.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0: store ubo info to the driver constbuf on Kepler
Samuel Pitoiset [Wed, 30 Mar 2016 22:50:23 +0000 (00:50 +0200)]
nvc0: store ubo info to the driver constbuf on Kepler

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0: bind user uniforms for compute on Kepler
Samuel Pitoiset [Mon, 11 Jan 2016 20:22:58 +0000 (21:22 +0100)]
nvc0: bind user uniforms for compute on Kepler

Uniform buffer objects will be sticked to the driver constant buffer
like buffers because the launch descriptor only allows 8 CBs.

Input kernel parameters for OpenCL are still uploaded to screen->parm
which is bound on c0, but this will be changed later with a new series.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0: bind shader buffers for compute on Kepler
Samuel Pitoiset [Mon, 11 Jan 2016 15:05:59 +0000 (16:05 +0100)]
nvc0: bind shader buffers for compute on Kepler

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0: bind driver cb for compute on c7[] for Kepler
Samuel Pitoiset [Wed, 24 Feb 2016 16:03:57 +0000 (17:03 +0100)]
nvc0: bind driver cb for compute on c7[] for Kepler

Instead of using the screen->parm buffer object which will be removed,
upload auxiliary constants to uniform_bo to be consistent regarding
what we already do for Fermi.

This breaks surfaces support (for compute only) but this will be
properly re-introduced later for ARB_shader_image_load_store.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agogallivm: Prevent disassembly debug output from being truncated.
Jose Fonseca [Fri, 1 Apr 2016 20:17:18 +0000 (21:17 +0100)]
gallivm: Prevent disassembly debug output from being truncated.

By using os_log_message directly, as _debug_vprintf truncates messages
to 4K.

Also cleanup the disassemble interface.

Spotted by Roland.

Trivial.

8 years agocompiler: random comment fixup
Rob Clark [Tue, 29 Mar 2016 14:49:03 +0000 (10:49 -0400)]
compiler: random comment fixup

Just noticed this in passing..  gl_shader_stage already has tess so this
comment no longer applies.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
8 years agodocs: minor updates to license.html file
Brian Paul [Thu, 31 Mar 2016 16:30:07 +0000 (10:30 -0600)]
docs: minor updates to license.html file

Mesa demos are no longer part of the main Mesa tree/tarball.
Add Gallium and GLX code to list of major components.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
8 years agoradeonsi: use util_strchrnul() to fix android build error
Mauro Rossi [Sun, 21 Feb 2016 19:57:47 +0000 (20:57 +0100)]
radeonsi: use util_strchrnul() to fix android build error

Android Bionic does not support strchrnul() string function,
gallium auxiliary util/u_string.h provides util_strchrnul()

This change avoids the following building error:

external/mesa/src/gallium/drivers/radeonsi/si_shader.c:3863: error:
undefined reference to 'strchrnul'
collect2: error: ld returned 1 exit status

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
8 years agoegl: android: enable EGL_FRAMEBUFFER_TARGET_ANDROID and EGL_RECORDABLE_ANDROID
Rob Herring [Tue, 2 Feb 2016 20:23:11 +0000 (14:23 -0600)]
egl: android: enable EGL_FRAMEBUFFER_TARGET_ANDROID and EGL_RECORDABLE_ANDROID

Set EGL_FRAMEBUFFER_TARGET_ANDROID and EGL_RECORDABLE_ANDROID config
attributes to true for Android. These are required in Marshmallow.

The implementation of EGL_RECORDABLE_ANDROID support has 2 options in
the definition of the extension. Android implements the 2nd option
which is the encoder must support RGB input. The requested input format
is RGB888, so setting the attribute on all the native Android visual
formats should be sufficient.

Similarly, setting EGL_FRAMEBUFFER_TARGET_ANDROID for all configs with
a EGL_NATIVE_VISUAL_ID should be sufficient. Most likely, the HWC should
support the same set of formats the underlying DRM driver supports.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
8 years agoegl: Add EGL_RECORDABLE_ANDROID attribute
Rob Herring [Tue, 2 Feb 2016 20:23:08 +0000 (14:23 -0600)]
egl: Add EGL_RECORDABLE_ANDROID attribute

This is used by Android to select an eglconfig compatible with screen
recording.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Rob Herring <robh@kernel.org>
[Emil Velikov: add the _eglIsConfigAttribValid check]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
8 years agoegl: Add EGL_FRAMEBUFFER_TARGET_ANDROID attribute
Rob Herring [Tue, 2 Feb 2016 20:23:07 +0000 (14:23 -0600)]
egl: Add EGL_FRAMEBUFFER_TARGET_ANDROID attribute

This is used by Android to select an eglconfig compatible with HWComposer.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Rob Herring <robh@kernel.org>
[Emil Velikov: add the _eglIsConfigAttribValid check]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
8 years agoAndroid: fix x86 gallium builds
Rob Herring [Tue, 2 Feb 2016 20:45:07 +0000 (14:45 -0600)]
Android: fix x86 gallium builds

Builds with gallium enabled fail on x86 with linker error:

external/mesa3d/src/mesa/vbo/vbo_exec_array.c:127: error: undefined reference to '_mesa_uint_array_min_max'

The problem is sse_minmax.c is not included in the libmesa_st_mesa
library. Since the SSE4.1 files are needed for both libmesa_st_mesa
and libmesa_dricore, move SSE4.1 files into a separate static library
that can be used by both.

Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
8 years agogallivm: Use vector selects on LLVM 3.3+.
Jose Fonseca [Thu, 31 Mar 2016 22:37:34 +0000 (23:37 +0100)]
gallivm: Use vector selects on LLVM 3.3+.

This is an old patch I had around.

Vector selects seem to work well from LLVM 3.3.  Using them should
improve code quality, as it might make constant propagation pass more
effective.

Tested lp_test_*

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
8 years agoglsl: do not raise unitialized variable warnings on builtins/reserved GL variables
Alejandro Piñeiro [Fri, 1 Apr 2016 07:11:15 +0000 (09:11 +0200)]
glsl: do not raise unitialized variable warnings on builtins/reserved GL variables

Needed because not all the built-in variables are marked as system
values, so they still have the mode ir_var_auto. Right now it fixes
raising the warning when gl_GlobalInvocationID and
gl_LocalInvocationIndex are used.

v2: use is_gl_identifier instead of filtering for some names (Ilia
    Mirkin)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agonv50,nvc0: add PIPE_BIND_LINEAR support to is_format_supported
Ilia Mirkin [Fri, 1 Apr 2016 01:52:13 +0000 (21:52 -0400)]
nv50,nvc0: add PIPE_BIND_LINEAR support to is_format_supported

vdpau has recently come to rely on this, so make sure to check it
properly.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agomesa: add GL_OES/EXT_draw_buffers_indexed support
Ilia Mirkin [Thu, 31 Mar 2016 04:48:01 +0000 (00:48 -0400)]
mesa: add GL_OES/EXT_draw_buffers_indexed support

This is the same ext as ARB_draw_buffers_blend (plus some core
functionality that already exists). Add the alias entrypoints.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoi965: Use brw->urb.min_vs_urb_entries instead of 32 for BLORP.
Kenneth Graunke [Thu, 31 Mar 2016 07:53:21 +0000 (00:53 -0700)]
i965: Use brw->urb.min_vs_urb_entries instead of 32 for BLORP.

Haswell GT2 and GT3 have a minimum of 64 entries.  Hardcoding 32
is not legal.

v2: Delete stale comment (caught by Alejandro).

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
8 years agoi965: Fix textureSize() depth value for 1 layer surfaces on Gen4-6.
Kenneth Graunke [Tue, 29 Mar 2016 16:58:11 +0000 (09:58 -0700)]
i965: Fix textureSize() depth value for 1 layer surfaces on Gen4-6.

According to the Sandybridge PRM's description of the resinfo message,
the .z value returned will be Depth == 0 ? 0 : Depth + 1.  The earlier
PRMs have the same table.

This means we return 0 for array textures with a single slice, when
we ought to return 1.  Just override it to max(depth, 1).

Fixes 10 dEQP-GLES3.functional tests on Sandybridge:
shaders.texture_functions.texturesize.sampler2darray_fixed_vertex
shaders.texture_functions.texturesize.sampler2darray_fixed_fragment
shaders.texture_functions.texturesize.sampler2darray_float_vertex
shaders.texture_functions.texturesize.sampler2darray_float_fragment
shaders.texture_functions.texturesize.isampler2darray_vertex
shaders.texture_functions.texturesize.isampler2darray_fragment
shaders.texture_functions.texturesize.usampler2darray_vertex
shaders.texture_functions.texturesize.usampler2darray_fragment
shaders.texture_functions.texturesize.sampler2darrayshadow_vertex
shaders.texture_functions.texturesize.sampler2darrayshadow_fragment

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agonir: Simplify a bcsel to logical-or
Ian Romanick [Tue, 29 Mar 2016 22:25:04 +0000 (15:25 -0700)]
nir: Simplify a bcsel to logical-or

Oddly, this did not affect the shader where I first noticed the pattern.
That particular shader doesn't get its if-statement converted to a bcsel
because there are two assignments in the else-statement.  This led to me
submitting https://bugs.freedesktop.org/show_bug.cgi?id=94747.

shader-db results:

Sandy Bridge
total instructions in shared programs: 8467384 -> 8467069 (-0.00%)
instructions in affected programs: 36594 -> 36279 (-0.86%)
helped: 46
HURT: 0

total cycles in shared programs: 117573448 -> 117568518 (-0.00%)
cycles in affected programs: 339114 -> 334184 (-1.45%)
helped: 46
HURT: 0

Ivy Bridge / Haswell / Broadwell / Skylake:
total instructions in shared programs: 7774258 -> 7773999 (-0.00%)
instructions in affected programs: 30874 -> 30615 (-0.84%)
helped: 46
HURT: 0

total cycles in shared programs: 65739190 -> 65734530 (-0.01%)
cycles in affected programs: 180380 -> 175720 (-2.58%)
helped: 45
HURT: 1

No change on G45 or Ironlake.

I also tried these expressions, but none of them affected any shaders in
shader-db:

   (('bcsel', a, 'a@bool', 'b@bool'), ('ior', a, b)),
   (('bcsel', a, 'b@bool', False),    ('iand', a, b)),
   (('bcsel', a, 'b@bool', 'a@bool'), ('iand', a, b)),

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agoptn: Fix all users of ptn_swizzle
Ian Romanick [Thu, 24 Mar 2016 22:48:55 +0000 (15:48 -0700)]
ptn: Fix all users of ptn_swizzle

None of the callers actually wanted what it did.  In ptn_xpd, you only
ever want a vec3 swizzle.  In ptn_tex, you want a swizzle that matches
the number of required texture coordinates.

shader-db results:

G45:
total instructions in shared programs: 4011240 -> 4010911 (-0.01%)
instructions in affected programs: 59232 -> 58903 (-0.56%)
helped: 114
HURT: 0

total cycles in shared programs: 84314194 -> 84313220 (-0.00%)
cycles in affected programs: 779150 -> 778176 (-0.13%)
helped: 110
HURT: 13

Ironlake:
total instructions in shared programs: 6397262 -> 6396605 (-0.01%)
instructions in affected programs: 117402 -> 116745 (-0.56%)
helped: 227
HURT: 0

total cycles in shared programs: 128889798 -> 128888524 (-0.00%)
cycles in affected programs: 1214644 -> 1213370 (-0.10%)
helped: 179
HURT: 44

Sandy Bridge:
total instructions in shared programs: 8467391 -> 8467384 (-0.00%)
instructions in affected programs: 3107 -> 3100 (-0.23%)
helped: 10
HURT: 6

total cycles in shared programs: 117580120 -> 117573448 (-0.01%)
cycles in affected programs: 103158 -> 96486 (-6.47%)
helped: 84
HURT: 11

Ivy Bridge:
total instructions in shared programs: 7774255 -> 7774258 (0.00%)
instructions in affected programs: 1677 -> 1680 (0.18%)
helped: 8
HURT: 6

total cycles in shared programs: 65743828 -> 65739190 (-0.01%)
cycles in affected programs: 89312 -> 84674 (-5.19%)
helped: 78
HURT: 23

Haswell:
total instructions in shared programs: 7107172 -> 7107150 (-0.00%)
instructions in affected programs: 2048 -> 2026 (-1.07%)
helped: 16
HURT: 0

total cycles in shared programs: 64653636 -> 64647486 (-0.01%)
cycles in affected programs: 86836 -> 80686 (-7.08%)
helped: 85
HURT: 17

Broadwell and Skylake:
total instructions in shared programs: 8447529 -> 8447507 (-0.00%)
instructions in affected programs: 2038 -> 2016 (-1.08%)
helped: 16
HURT: 0

total cycles in shared programs: 66418670 -> 66413416 (-0.01%)
cycles in affected programs: 90110 -> 84856 (-5.83%)
helped: 83
HURT: 20

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agoptn: Silence unused parameter warning
Ian Romanick [Tue, 29 Mar 2016 00:27:36 +0000 (17:27 -0700)]
ptn: Silence unused parameter warning

The KIL instruction doesn't have a destination, so ptn_kil never uses
dest.

program/prog_to_nir.c: In function ‘ptn_kil’:
program/prog_to_nir.c:547:38: warning: unused parameter ‘dest’ [-Wunused-parameter]
 ptn_kil(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src)
                                      ^

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agotgsi: silence compiler warning in fetch_sampler_unit()
Samuel Pitoiset [Thu, 31 Mar 2016 08:54:18 +0000 (10:54 +0200)]
tgsi: silence compiler warning in fetch_sampler_unit()

The unit variable can be used uninitialized.

Fixes: 24e77cb09 ("tgsi: handle indirect sampler arrays. (v2)")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agotgsi: fix out of bounds access in exec_atomop()
Samuel Pitoiset [Thu, 31 Mar 2016 08:54:17 +0000 (10:54 +0200)]
tgsi: fix out of bounds access in exec_atomop()

The number of channels must be 4 for all RGBA components.

Fixes: 22d129601 ("tgsi: add support for image operations to tgsi_exec. (v2.1)")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agotgsi: split tgsi_util_get_texture_coord_dim() function into two
Brian Paul [Wed, 30 Mar 2016 22:54:08 +0000 (16:54 -0600)]
tgsi: split tgsi_util_get_texture_coord_dim() function into two

It was kind of overloaded, returning two different things.  Now get
the index of the shadow reference src register with a new
tgsi_util_get_shadow_ref_src_index() function.

To verify the new code, I added some temp/debug code which looped
over all TGSI_TEXTURE_x values, calling the old function and new and
checking that the returned indexes matched.

Also tested piglit "shadow" tests with softpipe/llvmpipe.
No testing of ilo and radeonsi changes.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agotgsi: skip texture query opcodes when examining texture targets
Brian Paul [Wed, 30 Mar 2016 15:55:56 +0000 (09:55 -0600)]
tgsi: skip texture query opcodes when examining texture targets

Should fix the assertion in piglit
spec@arb_gpu_shader5@texturegather@fs-r-none-shadow-2d when the
TXQ instruction specifies a 2D target but the sampler view was
declared as SHADOW2D.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
8 years agonv50/ir: Check for valid insn instead of def size
Pierre Moreau [Sat, 19 Mar 2016 13:04:54 +0000 (14:04 +0100)]
nv50/ir: Check for valid insn instead of def size

This fixes a null pointer dereference during the register allocation pass,
if a function had arguments.

Functions arguments get a definition from the function itself, a definition
which is therefore not linked to any instruction. If a value ends up having
a definition but no linked instruction, the register allocation pass doesn't
need to consider whether that value is generated by an instruction that
can only handle "short" registers (on nv50).

Signed-off-by: Pierre Moreau <pierre.morrow@free.fr>
8 years agomesa: add GL_EXT_copy_image support
Ilia Mirkin [Wed, 17 Feb 2016 18:27:14 +0000 (13:27 -0500)]
mesa: add GL_EXT_copy_image support

The extension is identical to GL_OES_copy_image. But dEQP has tests that
want the EXT variant.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: add GL_OES_copy_image support
Ilia Mirkin [Tue, 16 Feb 2016 01:34:52 +0000 (20:34 -0500)]
mesa: add GL_OES_copy_image support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: remove duplicate MAX_GEOMETRY_SHADER_INVOCATIONS entry
Ilia Mirkin [Thu, 31 Mar 2016 02:03:06 +0000 (22:03 -0400)]
mesa: remove duplicate MAX_GEOMETRY_SHADER_INVOCATIONS entry

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agost/mesa: add ES sample-shading support
Ilia Mirkin [Tue, 16 Feb 2016 06:27:27 +0000 (01:27 -0500)]
st/mesa: add ES sample-shading support

We require the full ARB_gpu_shader5 for now, but in the future some
other CAP could get exposed to indicate that only the multisample-related
behavior of ARB_gpu_shader5 is available.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: add GL_OES_shader_multisample_interpolation support
Ilia Mirkin [Sat, 20 Feb 2016 20:03:55 +0000 (15:03 -0500)]
mesa: add GL_OES_shader_multisample_interpolation support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agomesa: add GL_OES_sample_shading support
Ilia Mirkin [Tue, 16 Feb 2016 19:29:38 +0000 (14:29 -0500)]
mesa: add GL_OES_sample_shading support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agoglsl: add GL_OES_sample_variables support
Ilia Mirkin [Fri, 19 Feb 2016 18:23:10 +0000 (13:23 -0500)]
glsl: add GL_OES_sample_variables support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agomesa: add OES_sample_variables to extension table, add enable bit
Ilia Mirkin [Tue, 16 Feb 2016 06:20:15 +0000 (01:20 -0500)]
mesa: add OES_sample_variables to extension table, add enable bit

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agoglsl: add gl_MaxSamples, new in GL 4.5 / GL ES 3.2
Ilia Mirkin [Fri, 19 Feb 2016 18:20:48 +0000 (13:20 -0500)]
glsl: add gl_MaxSamples, new in GL 4.5 / GL ES 3.2

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agoi965: Don't add barrier deps for FB write messages.
Matt Turner [Sun, 13 Mar 2016 05:16:03 +0000 (21:16 -0800)]
i965: Don't add barrier deps for FB write messages.

Ken did this earlier, and this is just me reimplementing his patch a
little differently.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoi965: Add and use is_scheduling_barrier() function.
Matt Turner [Sun, 13 Mar 2016 05:15:19 +0000 (21:15 -0800)]
i965: Add and use is_scheduling_barrier() function.

8 years agoi965: Remove NOP insertion kludge in scheduler.
Matt Turner [Mon, 15 Feb 2016 18:43:39 +0000 (10:43 -0800)]
i965: Remove NOP insertion kludge in scheduler.

Instead of removing every instruction in add_insts_from_block(), just
move the instruction to its scheduled location. This is a step towards
doing both bottom-up and top-down scheduling without conflicts.

Note that this patch changes cycle counts for programs because it begins
including control flow instructions in the estimates.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoi965: Assert that an instruction is not inserted around itself.
Matt Turner [Mon, 15 Feb 2016 18:42:14 +0000 (10:42 -0800)]
i965: Assert that an instruction is not inserted around itself.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoi965: Relax restriction on scheduling last instruction.
Matt Turner [Mon, 15 Feb 2016 18:05:33 +0000 (10:05 -0800)]
i965: Relax restriction on scheduling last instruction.

I think when this code was written, basic blocks were always ended by a
control flow instruction or an end-of-thread message. That's no longer
the case, and removing this restriction actually helps things:

   instructions in affected programs: 7267 -> 7244 (-0.32%)
   helped: 4

   total cycles in shared programs: 66559580 -> 66431900 (-0.19%)
   cycles in affected programs: 28310152 -> 28182472 (-0.45%)
   helped: 9577
   HURT: 879

   GAINED: 2

The addition of the is_control_flow() checks is not a functional change,
since the add_insts_from_block() does not put them in the list of
instructions to schedule. I plan to change this in a later patch.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoi965/vec4/tcs: Set conditional mod on TCS_OPCODE_SRC0_010_IS_ZERO.
Matt Turner [Tue, 15 Mar 2016 00:39:19 +0000 (17:39 -0700)]
i965/vec4/tcs: Set conditional mod on TCS_OPCODE_SRC0_010_IS_ZERO.

Missing this causes an assertion failure in the scheduler with the next
patch.

Additionally, this gives cmod propagation enough information to optimize
code better.

total instructions in shared programs: 7112991 -> 7112852 (-0.00%)
instructions in affected programs: 25704 -> 25565 (-0.54%)
helped: 139

total cycles in shared programs: 64812898 -> 64810674 (-0.00%)
cycles in affected programs: 127224 -> 125000 (-1.75%)
helped: 139

Acked-by: Francisco Jerez <currojerez@riseup.net>
8 years agoRevert "i965: Don't add barrier deps for FB write messages."
Matt Turner [Wed, 17 Feb 2016 19:04:50 +0000 (11:04 -0800)]
Revert "i965: Don't add barrier deps for FB write messages."

This reverts commit d0e1d6b7e27bf5f05436e47080d326d7daa63af2.

The change in the vec4 code is a mistake -- there's never an
FS_OPCODE_FB_WRITE in vec4 code.

The change in the fs code had the (harmless) effect of not recognizing
an FB_WRITE as a scheduling barrier even if it was marked EOT --
harmless because the scheduler marked the last instruction of a block as
a barrier, something I'm changing in the following patches.

This will be reimplemented later in the series.

8 years agoi965: Simplify full scheduling-barrier conditions.
Matt Turner [Mon, 15 Feb 2016 07:21:03 +0000 (23:21 -0800)]
i965: Simplify full scheduling-barrier conditions.

All of these were simply code for "architecture register file" (and in
the case of destinations, "not the null register").

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoi965: Remove incorrect cycle estimates.
Matt Turner [Mon, 15 Feb 2016 07:23:53 +0000 (23:23 -0800)]
i965: Remove incorrect cycle estimates.

These printed the cycle count the last basic block (sched.time is set
per basic block!). We have accurate, full program, data printed
elsewhere.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agost/mesa: fix fallout from xfb changes.
Dave Airlie [Thu, 31 Mar 2016 02:35:25 +0000 (12:35 +1000)]
st/mesa: fix fallout from xfb changes.

Failed to update state tracker with new buffer interface.

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
8 years agonir: Fix typo from commit 6702f1acde9.
Matt Turner [Thu, 31 Mar 2016 02:18:16 +0000 (19:18 -0700)]
nir: Fix typo from commit 6702f1acde9.

8 years agodocs: mark xfb_* qualifiers as DONE
Timothy Arceri [Thu, 10 Mar 2016 05:41:03 +0000 (16:41 +1100)]
docs: mark xfb_* qualifiers as DONE

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: add query support for GL_TRANSFORM_FEEDBACK_BUFFER interface
Timothy Arceri [Thu, 10 Mar 2016 05:17:13 +0000 (16:17 +1100)]
mesa: add query support for GL_TRANSFORM_FEEDBACK_BUFFER interface

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add transform feedback buffers to resource list
Timothy Arceri [Thu, 10 Mar 2016 04:04:02 +0000 (15:04 +1100)]
glsl: add transform feedback buffers to resource list

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: add support to query GL_TRANSFORM_FEEDBACK_BUFFER_INDEX
Timothy Arceri [Thu, 10 Mar 2016 04:57:19 +0000 (15:57 +1100)]
mesa: add support to query GL_TRANSFORM_FEEDBACK_BUFFER_INDEX

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: add support to query GL_OFFSET for GL_TRANSFORM_FEEDBACK_VARYING
Timothy Arceri [Thu, 10 Mar 2016 00:40:37 +0000 (11:40 +1100)]
mesa: add support to query GL_OFFSET for GL_TRANSFORM_FEEDBACK_VARYING

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: rename tranform feeback varying macro XFB to XFV
Timothy Arceri [Thu, 10 Mar 2016 04:20:32 +0000 (15:20 +1100)]
mesa: rename tranform feeback varying macro XFB to XFV

A latter patch will use XFB for buffers.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: always enable transform feedback mode when xfb_stride defined
Timothy Arceri [Mon, 14 Mar 2016 00:16:55 +0000 (11:16 +1100)]
glsl: always enable transform feedback mode when xfb_stride defined

This enables in shader defined transform feedback mode even if the
only place xfb_stride is defined is on the global out.

We don't worry about xfb_buffer since Issue 22 c) in the spec says:

   "If the shader has an "xfb_buffer" qualifier identifying a buffer,
    but doesn't declare "xfb_offset" on anything associated with it,
    what happens?

    ...

    variables not qualified with "xfb_offset" are not captured, which
    makes the associated "xfb_buffer" qualifier irrelevant."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: handle varyings that are not written to but have an xfb_offset
Timothy Arceri [Sun, 13 Mar 2016 23:32:17 +0000 (10:32 +1100)]
glsl: handle varyings that are not written to but have an xfb_offset

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: when lowering named interface set assigned flag
Timothy Arceri [Sun, 13 Mar 2016 23:17:48 +0000 (10:17 +1100)]
glsl: when lowering named interface set assigned flag

This will be used when checking if xfb should attempt to capture
a varying.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: reset current stream tracker
Timothy Arceri [Sun, 13 Mar 2016 05:36:25 +0000 (16:36 +1100)]
glsl: reset current stream tracker

When we move to the next buffer we need to reset the stream
so that we don't generate an error message about streams not
matching.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: generate link error when implicit stride is to large
Timothy Arceri [Fri, 11 Mar 2016 02:53:13 +0000 (13:53 +1100)]
glsl: generate link error when implicit stride is to large

This moves the check until after we have done the stride
calculation and applies it to the xfb_* qualifiers.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add xfb_stride link time validation
Timothy Arceri [Thu, 3 Mar 2016 04:26:53 +0000 (15:26 +1100)]
glsl: add xfb_stride link time validation

From the ARB_enhanced_layous spec:

   "It is a compile-time or link-time error to have any *xfb_offset*
    that overflows *xfb_stride*, whether stated on declarations before
    or after the *xfb_stride*, or in different compilation units.

    ...

    When no *xfb_stride* is specified for a buffer, the stride of a
    buffer will be the smallest needed to hold the variable placed at
    the highest offset, including any required padding."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: validate global out xfb_stride qualifiers and set stride on empty buffers
Timothy Arceri [Fri, 11 Mar 2016 00:57:52 +0000 (11:57 +1100)]
glsl: validate global out xfb_stride qualifiers and set stride on empty buffers

Here we use the built-in validation in
ast_layout_expression::process_qualifier_constant() to check for mismatching
global out strides on buffers in a single shader.

From the ARB_enhanced_layouts spec:

   "While *xfb_stride* can be declared multiple times for the same buffer,
   it is a compile-time or link-time error to have different values
   specified for the stride for the same buffer."

For intrastage validation a new helper link_xfb_stride_layout_qualifiers()
is created. We also take this opportunity to make sure stride is at least
a multiple of 4, we will validate doubles at a later stage.

From the ARB_enhanced_layouts spec:

   "If the buffer is capturing any double-typed outputs, the stride must
   be a multiple of 8, otherwise it must be a multiple of 4, or a
   compile-time or link-time error results."

Finally we update store_tfeedback_info() to apply the strides to
LinkedTransformFeedback and update the buffers bitmask to mark any global
buffers with a stride as active. For example a shader with:

layout (xfb_buffer = 0, xfb_offset = 0)  out vec4 gs_fs;
layout (xfb_buffer = 1, xfb_stride = 64) out;

Is expected to have a buffer bound to both 0 and 1.

From the ARB_enhanced_layouts spec:

   "A binding point requires a bound buffer object if and only if its
   associated stride in the program object used for transform feedback
   primitive capture is non-zero."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agomesa: split transform feedback buffer into its own struct
Timothy Arceri [Thu, 10 Mar 2016 04:00:00 +0000 (15:00 +1100)]
mesa: split transform feedback buffer into its own struct

This will be used in a following patch to implement interface
query support for TRANSFORM_FEEDBACK_BUFFER.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: use bitmask of active xfb buffer indices
Timothy Arceri [Thu, 3 Mar 2016 02:20:01 +0000 (13:20 +1100)]
glsl: use bitmask of active xfb buffer indices

This allows us to print the correct binding point when not all
buffers declared in the shader are bound.

For example if we use a single buffer:

layout(xfb_buffer=2, offset=0) out vec4 v;

We now print '2' when the buffer is not bound rather than '0'.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: sort xfb varyings in offset/buffer order
Timothy Arceri [Fri, 11 Mar 2016 12:16:16 +0000 (23:16 +1100)]
glsl: sort xfb varyings in offset/buffer order

The existing transform feedback code expects to receive the list
of varyings in increasing buffer order.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: basic linking support for xfb qualifiers
Timothy Arceri [Wed, 24 Feb 2016 05:40:32 +0000 (16:40 +1100)]
glsl: basic linking support for xfb qualifiers

This adds the initial infrastructure for enabling transform feedback
mode via in shader qualifiers and adds initial buffer support.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add xfb helpers and fields to the tfeedback_decl class
Timothy Arceri [Wed, 24 Feb 2016 05:37:02 +0000 (16:37 +1100)]
glsl: add xfb helpers and fields to the tfeedback_decl class

We also apply any array/struct offsets.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add helper to process xfb qualifiers during linking
Timothy Arceri [Wed, 24 Feb 2016 05:27:03 +0000 (16:27 +1100)]
glsl: add helper to process xfb qualifiers during linking

This function checks for any xfb_* qualifiers which will enable
transform feedback mode and cause any API defined xfb varyings
to be ignored.

It also counts the number of varyings that have a xfb_offset
qualifier and finally it calls the create_xfb_varying_names()
helper to generate the names of varyings to be caputured.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add helper to generate xfb varying names
Timothy Arceri [Wed, 24 Feb 2016 04:40:31 +0000 (15:40 +1100)]
glsl: add helper to generate xfb varying names

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add helper for counting varyings
Timothy Arceri [Tue, 15 Mar 2016 06:52:06 +0000 (17:52 +1100)]
glsl: add helper for counting varyings

This will be used to get a count of the number of varying name
strings we are required to generate for use with the query api.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add xfb qualifier lowering support for named blocks
Timothy Arceri [Mon, 15 Feb 2016 02:27:55 +0000 (13:27 +1100)]
glsl: add xfb qualifier lowering support for named blocks

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add xfb qualifiers to has_layout helper
Timothy Arceri [Fri, 22 Jan 2016 05:22:40 +0000 (16:22 +1100)]
glsl: add xfb qualifiers to has_layout helper

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: apply xfb_stride to implicit offsets for ifc block members
Timothy Arceri [Thu, 10 Mar 2016 00:51:48 +0000 (11:51 +1100)]
glsl: apply xfb_stride to implicit offsets for ifc block members

When we have an interface block like:

layout (xfb_buffer = 0, xfb_offset = 0) out Block {
                             vec4 var1;
    layout (xfb_stride = 32) vec4 var2;
                             vec4 var3;
};

We take into account the stride of var2 when calculating the offset
for var3.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add xfb_stride compile time rules
Timothy Arceri [Sat, 13 Feb 2016 03:53:45 +0000 (14:53 +1100)]
glsl: add xfb_stride compile time rules

From the ARB_enhanced_layouts spec:

   "The *xfb_stride* qualifier specifies how many bytes are consumed
   by each captured vertex.  It applies to the transform feedback
   buffer for that declaration, whether it is inherited or explicitly
   declared. It can be applied to variables, blocks, block members,
   or just the qualifier out.  If the buffer is capturing any
   double-typed outputs, the stride must be a multiple of 8, otherwise
   it must be a multiple of 4, or a compile-time or link-time error
   results.

   ...

   The resulting stride (implicit or explicit) must be less than or
   equal to the implementation-dependent constant
   gl_MaxTransformFeedbackInterleavedComponents."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add xfb_offset compile time rules
Timothy Arceri [Wed, 24 Feb 2016 04:21:59 +0000 (15:21 +1100)]
glsl: add xfb_offset compile time rules

We also copy the qualifier values to the IR in this step.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add xfb_buffer compile time rules
Timothy Arceri [Fri, 11 Mar 2016 12:00:16 +0000 (23:00 +1100)]
glsl: add xfb_buffer compile time rules

Also copies the qualifier values to GLSL IR.

From the ARB_enhanced_layouts spec:

    "The *xfb_buffer* qualifier can be applied to the qualifier out,
    to output variables, to output blocks, and to output block
    members.  Shaders in the transform  feedback capturing mode have
    an initial global default of

        layout(xfb_buffer = 0) out;

    This default can be changed by declaring a different buffer with
    xfb_buffer on the interface qualifier out.  This is the only way
    the global default can be changed.  When a variable or output block
    is declared without an  xfb_buffer qualifier, it inherits the global
    default buffer.  When a variable or output block is declared with an
    xfb_buffer qualifier, it has that declared buffer.  All members of a
    block inherit the block's buffer.  A  member is allowed to declare
    an xfb_buffer, but it must match the buffer inherited from its
    block, or a compile-time error results.

    The *xfb_buffer* qualifier follows the same conventions, behavior,
    defaults, and inheritance rules as the qualifier stream, and the
    examples for stream apply here as well.  This includes a block's
    inheritance of the current global default buffer, a block member's
    inheritance of  the block's buffer, and the requirement that any
    *xfb_buffer* declared on a block member must match the buffer
    inherited from the block.

    ...

    It is a compile-time error to specify an *xfb_buffer* that is
    greater than  the implementation-dependent constant
    gl_MaxTransformFeedbackBuffers."

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add field to track if xfb_buffer is an explicit or implicit value
Timothy Arceri [Wed, 24 Feb 2016 04:18:09 +0000 (15:18 +1100)]
glsl: add field to track if xfb_buffer is an explicit or implicit value

Since any of the xfb_* qualifiers trigger the shader to be in
transform feedback mode we need an extra field to track if
the xfb_buffer on interface members was set explicitly since
xfb_buffer will always have a default value.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add xfb_* qualifiers to glsl_struct_field
Timothy Arceri [Wed, 24 Feb 2016 05:06:00 +0000 (16:06 +1100)]
glsl: add xfb_* qualifiers to glsl_struct_field

These will be used to hold qualifier values for interface and
struct members.

Support is added to the struct/interface constructors to copy these
fields upon creation.

We also update record_compare() to ensure we don't reuse a glsl_type
with the wrong xfb_* qualifier values.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add IR fields for transform feedback layout qualifiers
Timothy Arceri [Thu, 21 Jan 2016 05:22:12 +0000 (16:22 +1100)]
glsl: add IR fields for transform feedback layout qualifiers

Adds xfb_buffer/stride fields and adds comment to offset field
which is reused for xfb_offset.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: add validation for out layout qualifiers
Timothy Arceri [Tue, 9 Feb 2016 11:24:30 +0000 (22:24 +1100)]
glsl: add validation for out layout qualifiers

This adds validation for all qualifiers as allowed by the
table in Section 4.4 (Layout Qualifiers) of the GLSL 4.5 spec.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: relax stage restrictions on layout defaults for outputs
Timothy Arceri [Mon, 18 Jan 2016 09:46:29 +0000 (20:46 +1100)]
glsl: relax stage restrictions on layout defaults for outputs

The new xfb_buffer and xfb_stride global qualifiers are allowed in
geom, tess and vertex stages.

Reviewed-by: Dave Airlie <airlied@redhat.com>
8 years agoglsl: parse new transform feedback layout qualifiers
Timothy Arceri [Fri, 22 Jan 2016 01:45:10 +0000 (12:45 +1100)]
glsl: parse new transform feedback layout qualifiers

We reuse the existing offset field for holding the xfb_offset
expression but create a new flag as to avoid hitting the rules
for the offset qualifier for UBOs.

xfb_buffer qualifiers require extra processing when merging as
they can be applied to global out defaults. We just apply the
same rules as we do for the stream qualifier as the spec says:

   "The *xfb_buffer* qualifier follows the same conventions,
    behavior, defaults, and inheritance rules as the qualifier
    stream, and the examples for stream apply here as well."

For xfb_stride we push everything into a global out field for
later processing as xfb_stride applies to the entire buffer.
We still need to have a separate field to store per variable
strides because they can still effect implicit offsets
e.g. when applied to block members with implicit offsets.

Reviewed-by: Dave Airlie <airlied@redhat.com>