mesa.git
8 years agost/mesa: fix GLSL uniform updates for glBitmap & glDrawPixels (v2)
Marek Olšák [Sun, 6 Dec 2015 12:36:57 +0000 (13:36 +0100)]
st/mesa: fix GLSL uniform updates for glBitmap & glDrawPixels (v2)

Spotted by luck. The GLSL uniform storage is only associated once
in LinkShader and can't be reallocated afterwards, because that would
break the association.

v2: don't remove st_upload_constants calls, clarify why they're needed

Cc: 11.0 11.1 <mesa-stable@lists.freedesktop.org>
8 years agoprogram: add _mesa_reserve_parameter_storage
Marek Olšák [Sun, 6 Dec 2015 12:31:25 +0000 (13:31 +0100)]
program: add _mesa_reserve_parameter_storage

The next commit will use this.

Reviewed-by: Brian Paul <brianp@vmware.com>
Cc: 11.0 11.1 <mesa-stable@lists.freedesktop.org>
8 years agomesa: Fix warning with MESA_VERBOSE=api for BindBufferRange
Jordan Justen [Sat, 2 Jan 2016 00:58:49 +0000 (16:58 -0800)]
mesa: Fix warning with MESA_VERBOSE=api for BindBufferRange

Reported-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agonv50,nvc0: make sure there's pushbuf space and that we ref the bo early
Ilia Mirkin [Fri, 1 Jan 2016 01:33:15 +0000 (20:33 -0500)]
nv50,nvc0: make sure there's pushbuf space and that we ref the bo early

First off, we can't flush in the middle of a command. Secondly
requesting the extra push space might cause a flush to happen. If that
flush happens, we'd have to do the PUSH_REFN again. So instead do
PUSH_REFN after the push space request. This helps avoid rare crashes
with supertuxkart in libdrm due to assertion failures.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
8 years agost/mesa: sort extensions enablement array
Ilia Mirkin [Thu, 31 Dec 2015 21:22:40 +0000 (16:22 -0500)]
st/mesa: sort extensions enablement array

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agonir/lower_clip: add missing writemask on store
Rob Clark [Fri, 1 Jan 2016 17:52:22 +0000 (12:52 -0500)]
nir/lower_clip: add missing writemask on store

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
8 years agomesa: Add MESA_VERBOSE=api for GL_ARB_program_interface_query
Jordan Justen [Wed, 30 Dec 2015 21:08:07 +0000 (13:08 -0800)]
mesa: Add MESA_VERBOSE=api for GL_ARB_program_interface_query

v2:
 * Add braces '{}' when the _mesa_debug call spans multiple lines (Ken)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agomesa: Add MESA_VERBOSE=api for several indexed BindBuffer variants
Jordan Justen [Tue, 29 Dec 2015 22:24:09 +0000 (14:24 -0800)]
mesa: Add MESA_VERBOSE=api for several indexed BindBuffer variants

v2:
 * Add braces '{}' when the _mesa_debug call spans multiple lines (Ken)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agost/glsl_to_tgsi: fix block movs for doubles
Dave Airlie [Sat, 19 Dec 2015 04:43:19 +0000 (14:43 +1000)]
st/glsl_to_tgsi: fix block movs for doubles

While playing with fp64, I disable varying packing to debug
something else, and noticed we never emitted half the output
movs for double matrix arrays.

We should be moving the left index two slots for dual
source doubles, and the right index two slots for non-vs
input doubles.

Signed-off-by: Dave Airlie <airlied@redhat.com>
8 years agost/glsl_to_tgsi: handle different attrib size
Dave Airlie [Sat, 19 Dec 2015 04:43:18 +0000 (14:43 +1000)]
st/glsl_to_tgsi: handle different attrib size

vertex inputs are counted differently in some cases, with
vertex inputs we need to make sure we don't double count them.

Signed-off-by: Dave Airlie <airlied@redhat.com>
8 years agost/glsl_to_tgsi: readd the double_reg2 for input index mapping
Dave Airlie [Sat, 19 Dec 2015 04:43:17 +0000 (14:43 +1000)]
st/glsl_to_tgsi: readd the double_reg2 for input index mapping

Otherwise we end up emitting the wrong index for the second
double.

This fixes dmat-vs-gs-tcs-tes.shader_test and dvec3-vs-gs-tcs-tes.shader_test

Signed-off-by: Dave Airlie <airlied@redhat.com>
8 years agost/glsl_to_tgsi: when doing reladdr get vec4 of correct type
Dave Airlie [Sat, 19 Dec 2015 04:43:16 +0000 (14:43 +1000)]
st/glsl_to_tgsi: when doing reladdr get vec4 of correct type

This fixes fp64 relative addressing, in the upcoming
dmat-vs-gs-tcs-tes.shader_test.

Signed-off-by: Dave Airlie <airlied@redhat.com>
8 years agost/glsl_to_tgsi: handle double immediates in matrices properly.
Dave Airlie [Sat, 19 Dec 2015 04:43:15 +0000 (14:43 +1000)]
st/glsl_to_tgsi: handle double immediates in matrices properly.

This handles matrix initialisation properly.

Signed-off-by: Dave Airlie <airlied@redhat.com>
8 years agost/glsl_to_tgsi: setup writemask for double arrays and matricies.
Dave Airlie [Sat, 19 Dec 2015 04:43:14 +0000 (14:43 +1000)]
st/glsl_to_tgsi: setup writemask for double arrays and matricies.

It's important for the double instruction emission code that
the writemasks are correct going in for double so it know
which channels to replicate.

This fixes it for the array and matrix cases.

Signed-off-by: Dave Airlie <airlied@redhat.com>
8 years agost/glsl_to_tgsi: handle doubles in array shrinking code.
Dave Airlie [Sat, 19 Dec 2015 04:43:13 +0000 (14:43 +1000)]
st/glsl_to_tgsi: handle doubles in array shrinking code.

This code takes into account double inputs in the array
shrinking code. This fixes some issues with doubles
and geom/tess inputs.

Signed-off-by: Dave Airlie <airlied@redhat.com>
8 years agost/glsl_to_tgsi: handle doubles outputs in arrays.
Dave Airlie [Sat, 19 Dec 2015 04:43:12 +0000 (14:43 +1000)]
st/glsl_to_tgsi: handle doubles outputs in arrays.

This handles the case where a double output is stored
in an array, and tracks it for use in the double
instruction emit code.

Signed-off-by: Dave Airlie <airlied@redhat.com>
8 years agost/glsl_to_tgsi: store if dst is double in array
Dave Airlie [Sat, 19 Dec 2015 04:43:11 +0000 (14:43 +1000)]
st/glsl_to_tgsi: store if dst is double in array

This is just a precursor patch to a fix for doubles with
tessellation that I've written.

We need to descend into output arrays in that case and
mark dst's as double.

Signed-off-by: Dave Airlie <airlied@redhat.com>
8 years agonvc0: Set winding order regardless of domain.
Kenneth Graunke [Wed, 30 Dec 2015 10:53:08 +0000 (02:53 -0800)]
nvc0: Set winding order regardless of domain.

Quads need to respect winding order, too - not just triangles.

Fixes rendering in GFXBench 4.0's tessellation benchmark.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
8 years agoglsl: Fix varying struct locations when varying packing is disabled.
Kenneth Graunke [Wed, 30 Dec 2015 10:33:00 +0000 (02:33 -0800)]
glsl: Fix varying struct locations when varying packing is disabled.

varying_matches::record tries to compute the number of components in
each varying, which varying_matches::assign_locations uses to assign
locations.  With varying packing, it uses glsl_type::component_slots()
to come up with a reasonable value.

Without varying packing, it fell back to an open-coded computation
that didn't bother to handle structs at all.  I believe we can simply
use 4 * glsl_type::count_attribute_slots(false), which already handles
these cases correctly.

Partially fixes rendering in GFXBench 4.0's tessellation benchmark.
(NVE0 is almost right after this, but i965 is still mostly garbage.)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
8 years agodrirc: Disable ARB_blend_func_extended for Heaven 4.0/Valley 1.0.
Kenneth Graunke [Mon, 28 Dec 2015 22:20:28 +0000 (14:20 -0800)]
drirc: Disable ARB_blend_func_extended for Heaven 4.0/Valley 1.0.

Unigine Heaven 4.0 and Valley 1.0 use dual color blending but don't
specify which fragment shader output is which, so there's at best a
50/50 chance of us guessing it correctly.  This is invalid.

Unigine fixed this in 4.1 and 1.1 versions over a year and a half ago,
but hasn't actually released them for whatever reason.  So, add the
workaround back so that it works for most people.

Fixes Heaven 4.0/Valley 1.0 rendering on Ivybridge.  For whatever
reason, Broadwell worked.  4.1 and 1.1 have always worked.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92233
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Cc: mesa-stable@lists.freedesktop.org
8 years agoglsl: add GL_ARB_shader_draw_parameters define
Ilia Mirkin [Wed, 30 Dec 2015 23:47:18 +0000 (18:47 -0500)]
glsl: add GL_ARB_shader_draw_parameters define

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
8 years agonvc0: add ARB_shader_draw_parameters support
Ilia Mirkin [Wed, 30 Dec 2015 19:50:02 +0000 (14:50 -0500)]
nvc0: add ARB_shader_draw_parameters support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agost/mesa: add GL_ARB_shader_draw_parameters support
Ilia Mirkin [Tue, 29 Dec 2015 21:39:16 +0000 (16:39 -0500)]
st/mesa: add GL_ARB_shader_draw_parameters support

Hooks up the new system values, passes the drawid in.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
8 years agogallium: add a drawid to pipe_draw_info
Ilia Mirkin [Tue, 29 Dec 2015 22:00:05 +0000 (17:00 -0500)]
gallium: add a drawid to pipe_draw_info

This will allow the state tracker to inform the driver where in a
broken-up multidraw we currently are. This can then be passed into the
vertex shader.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
8 years agogallium: add PIPE_CAP_DRAW_PARAMETERS
Ilia Mirkin [Tue, 29 Dec 2015 21:49:32 +0000 (16:49 -0500)]
gallium: add PIPE_CAP_DRAW_PARAMETERS

This allows the state tracker to know that the various draw parameters
are available in vertex shaders.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
8 years agogallium: add baseinstance/drawid semantics
Ilia Mirkin [Tue, 29 Dec 2015 21:37:19 +0000 (16:37 -0500)]
gallium: add baseinstance/drawid semantics

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
8 years agonv50/ir: attempt to do more constant folding on mad -> add conversion
Ilia Mirkin [Mon, 7 Dec 2015 04:49:48 +0000 (23:49 -0500)]
nv50/ir: attempt to do more constant folding on mad -> add conversion

The add might actually have a 0 as an argument, which would convert it
into a mov. Make sure to detect that. Also avoid the hack of putting the
immediate directly into the instruction, instead use a mov to put it
into place and let the later LoadPropagation pass place it if possible.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agoi965/gen8: Always use BRW_REGISTER_TYPE_UW for MUL on GEN8+
Marta Lofstedt [Tue, 29 Dec 2015 15:15:45 +0000 (16:15 +0100)]
i965/gen8: Always use BRW_REGISTER_TYPE_UW for MUL on GEN8+

The imulExtended tests of the shader bitfield tests of the
OpenGL ES 3.1 CTS, fail on gen8+, when BRW_REGISTER_TYPE_W
is used for SHADER_OPECODE_MULH.

Also, remove unused helper function:
static inline bool type_is_signed(unsigned type)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92595
Signed-off-by: Marta Lofstedt <marta.lofstedt@linux.intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agoglsl: tidy up struct with a single member
Timothy Arceri [Tue, 29 Dec 2015 10:02:56 +0000 (21:02 +1100)]
glsl: tidy up struct with a single member

There used to be more members but they now share other fields
in order to keep memory use low.

Also making the naming more generic will allow us to reuse the
field for explicit byte offsets within blocks for
ARB_enhanced_layouts.

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
8 years agoglsl/linker: annotate static functions as such
Emil Velikov [Tue, 29 Dec 2015 10:02:55 +0000 (21:02 +1100)]
glsl/linker: annotate static functions as such

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
8 years agoglsl: annotate ast_process_struct_or_iface_block_members() as static
Emil Velikov [Tue, 29 Dec 2015 10:02:54 +0000 (21:02 +1100)]
glsl: annotate ast_process_struct_or_iface_block_members() as static

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
8 years agonir/builder: Add an init function that creates a simple shader for you
Jason Ekstrand [Tue, 29 Dec 2015 17:56:44 +0000 (09:56 -0800)]
nir/builder: Add an init function that creates a simple shader for you

A hugely common case when using nir_builder is to have a shader with a
single function called main.  This adds a helper that gives you just that.
This commit also makes us use it in the NIR control-flow unit tests as well
as tgsi_to_nir and prog_to_nir.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agomesa/st: Pad out _mesa_sysval_to_semantic for new SYSTEM_VALUE_* enums
Kristian Høgsberg Kristensen [Tue, 29 Dec 2015 19:14:07 +0000 (11:14 -0800)]
mesa/st: Pad out _mesa_sysval_to_semantic for new SYSTEM_VALUE_* enums

GL_ARB_shader_draw_parameters added two new system values.  This gets us
back to mapping mesa system values to the right TGSI semantics.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonv50/ir: float(s32 & 0xff) = float(u8), not s8
Ilia Mirkin [Tue, 29 Dec 2015 20:05:34 +0000 (15:05 -0500)]
nv50/ir: float(s32 & 0xff) = float(u8), not s8

Make sure to make conversion unsigned when we're ANDing the high bits
away. Fixes corruption in dolphin.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
8 years agoi965: Reemit vertex state between indirect multi draws
Kristian Høgsberg Kristensen [Tue, 15 Dec 2015 07:36:06 +0000 (23:36 -0800)]
i965: Reemit vertex state between indirect multi draws

If we're doing an indirect draw, prims[i].basevertex is always 0 and the
real base vertex value is in the indirect parameter buffer. We try to
avoid flagging BRW_NEW_VERTICES if prims[i].basevertex doesn't change,
which then breaks down for indirect draws. Thus, if a program uses base
vertex or base instance, and the draw call is indirect, always flag
BRW_NEW_VERTICES.  A new piglit test,
spec/ARB_shader_draw_parameters/drawid-indirect-vertexid tests this.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
8 years agonir: Teach nir_opt_algebraic about adding and subtracting the same thing
Kristian Høgsberg Kristensen [Tue, 15 Dec 2015 01:44:23 +0000 (17:44 -0800)]
nir: Teach nir_opt_algebraic about adding and subtracting the same thing

This optimizes a + b - b to just a. Modest shader-db results (BDW):

  total instructions in shared programs: 7842452 -> 7841862 (-0.01%)
  instructions in affected programs:     61938 -> 61348 (-0.95%)
  total loops in shared programs:        2131 -> 2131 (0.00%)
  helped:                                263
  HURT:                                  0
  GAINED:                                0
  LOST:                                  0

but the optimization turns

  gl_VertexID - gl_BaseVertexARB

into just a reference to SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, which the
i965 hardware supports natively. That means we can avoid using the
internal vertex buffer for gl_BaseVertexARB in this case.

Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
8 years agoi965: Add support for gl_DrawIDARB and enable extension
Kristian Høgsberg Kristensen [Thu, 10 Dec 2015 20:27:38 +0000 (12:27 -0800)]
i965: Add support for gl_DrawIDARB and enable extension

We have to break open a new vec4 for gl_DrawIDARB. We've used up all
space in the vec4 we use for SGVS and gl_DrawIDARB has to come from its
own separate vertex buffer anyway.  This is because we point the vb for
base vertex and base instance into the draw parameter BO for indirect
draw calls, but the draw id is generated by mesa in a different buffer.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
8 years agoi965: Add support for gl_BaseVertexARB and gl_BaseInstanceARB
Kristian Høgsberg Kristensen [Thu, 10 Dec 2015 20:24:50 +0000 (12:24 -0800)]
i965: Add support for gl_BaseVertexARB and gl_BaseInstanceARB

We already have gl_BaseVertexARB in the .x component of the SGVS vec4
and plug gl_BaseInstanceARB into the last free component (.y).

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
8 years agoi965: Assert that SYSTEM_VALUE_VERTEX_ID gets lowered
Kristian Høgsberg Kristensen [Thu, 10 Dec 2015 20:10:28 +0000 (12:10 -0800)]
i965: Assert that SYSTEM_VALUE_VERTEX_ID gets lowered

fs_visitor::emit_vs_system_value() looks like it's trying to handle
SYSTEM_VALUE_VERTEX_ID, but we should never see that value in the
backend.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agomesa: Add core mesa support for GL_ARB_shader_draw_parameters
Kristian Høgsberg Kristensen [Thu, 10 Dec 2015 20:07:43 +0000 (12:07 -0800)]
mesa: Add core mesa support for GL_ARB_shader_draw_parameters

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
8 years agomesa/vbo: Add draw_id field to struct _mesa_prim
Kristian Høgsberg Kristensen [Thu, 10 Dec 2015 20:06:17 +0000 (12:06 -0800)]
mesa/vbo: Add draw_id field to struct _mesa_prim

The drivers will need this for passing in gl_DrawIDARB. For indirect
multidraw calls, we get the prim array and prim[i].draw_id == i and is
redundant. But for non-indirect calls, we get one primitive at a time
and need the draw_id field.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
8 years agonir: Remove function overload in control flow test
Aaron Watry [Tue, 29 Dec 2015 16:51:54 +0000 (10:51 -0600)]
nir: Remove function overload in control flow test

Fixes make check.

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
8 years agoradeonsi: add RADEON_REPLACE_SHADERS debug option
Nicolai Hähnle [Tue, 15 Dec 2015 01:41:15 +0000 (20:41 -0500)]
radeonsi: add RADEON_REPLACE_SHADERS debug option

This option allows replacing a single shader by a pre-compiled ELF object
as generated by LLVM's llc, for example. This can be useful for debugging a
deterministically occuring error in shaders (and has in fact helped find
the causes of https://bugs.freedesktop.org/show_bug.cgi?id=93264).

v2: drop the debug flag, use DEBUG_GET_ONCE_OPTION instead

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agoradeonsi: count compilations in si_compile_llvm
Nicolai Hähnle [Tue, 15 Dec 2015 00:34:45 +0000 (19:34 -0500)]
radeonsi: count compilations in si_compile_llvm

This changes the count slightly (because of si_generate_gs_copy_shader), but
this is only relevant for the driver-specific num-compilations query. It sets
the stage for the next commit.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agogallium/util: add DEBUG_GET_ONCE_OPTION
Nicolai Hähnle [Mon, 21 Dec 2015 21:11:37 +0000 (16:11 -0500)]
gallium/util: add DEBUG_GET_ONCE_OPTION

This is analogous to the alreading existing macros for BOOL, NUM, and FLAGS.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agor600: fix constant buffer size programming
Grazvydas Ignotas [Tue, 22 Dec 2015 02:12:07 +0000 (04:12 +0200)]
r600: fix constant buffer size programming

When buffer size is less than 16, zero ends up being programmed as
size, which prevents the hardware from fetching the correct values.
Fix it by combining shift and align so that the value is always
rounded up.

Cc: "11.1 11.0 10.6" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92229
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agodocs: Mark ARB_tessellation_shader as done on all i965 platforms.
Kenneth Graunke [Fri, 25 Dec 2015 01:19:14 +0000 (17:19 -0800)]
docs: Mark ARB_tessellation_shader as done on all i965 platforms.

We now support all Intel GPUs which can do tessellation.

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Enable ARB_tessellation_shader on Gen7-7.5.
Kenneth Graunke [Thu, 26 Nov 2015 01:56:33 +0000 (17:56 -0800)]
i965: Enable ARB_tessellation_shader on Gen7-7.5.

We've resolved all the GPU hangs, and everything seems to be working.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Don't set interleave or complete on TCS EOT message.
Kenneth Graunke [Thu, 24 Dec 2015 21:09:26 +0000 (13:09 -0800)]
i965: Don't set interleave or complete on TCS EOT message.

Setting interleave on the TCS EOT message causes Ivybridge hardware to
GPU hang like crazy.  Individual tests would pass, but running even a
simple test like nop.shader_test in a loop would hang within 1-3 runs.
Adding sleep delays worked around the problem, somehow.

Interleave doesn't make much sense given that we only have one patch
URB handle, not two.  Complete doesn't seem useful either.

There's no reason to actually set those bits.  We were just being lazy.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Relase input URB Handles on Gen7/7.5 when TCS threads finish.
Kenneth Graunke [Thu, 26 Nov 2015 01:54:22 +0000 (17:54 -0800)]
i965: Relase input URB Handles on Gen7/7.5 when TCS threads finish.

Pre-Broadwell hardware requires us to manually release the ICP Handles
by issuing URB read messages with the "Complete" bit set.  We can do
this in pairs to use fewer URB read messages.

Based heavily on work from Chris Forbes.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Use proper TCS barrier ID bits for Ivybridge/Baytrail.
Kenneth Graunke [Thu, 24 Dec 2015 23:26:55 +0000 (15:26 -0800)]
i965: Use proper TCS barrier ID bits for Ivybridge/Baytrail.

Gen7 uses bits 15:12 while Gen7+ uses bits 16:13.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Use proper TCS Instance ID bits for Ivybridge/Baytrail.
Kenneth Graunke [Thu, 26 Nov 2015 07:27:02 +0000 (23:27 -0800)]
i965: Use proper TCS Instance ID bits for Ivybridge/Baytrail.

Gen7 uses 22:16 while Gen7.5+ uses 23:17.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Port tessellation evaluation shaders to vec4 mode.
Kenneth Graunke [Tue, 17 Nov 2015 09:30:35 +0000 (01:30 -0800)]
i965: Port tessellation evaluation shaders to vec4 mode.

This can be used on Broadwell by setting INTEL_SCALAR_TES=0.
More importantly, it will be used for Ivybridge and Haswell.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Emit a real 3DSTATE_DS on Gen7.
Kenneth Graunke [Thu, 26 Nov 2015 01:18:50 +0000 (17:18 -0800)]
i965: Emit a real 3DSTATE_DS on Gen7.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Emit a real 3DSTATE_HS on Gen7.
Kenneth Graunke [Thu, 26 Nov 2015 01:12:17 +0000 (17:12 -0800)]
i965: Emit a real 3DSTATE_HS on Gen7.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Add the TCS/TES state upload atoms to the gen7_atoms list.
Kenneth Graunke [Wed, 2 Dec 2015 06:41:32 +0000 (22:41 -0800)]
i965: Add the TCS/TES state upload atoms to the gen7_atoms list.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agonir: Get rid of function overloads
Jason Ekstrand [Sat, 26 Dec 2015 18:00:47 +0000 (10:00 -0800)]
nir: Get rid of function overloads

When Connor originally drafted NIR, he copied the same function+overload
system that GLSL IR had with a few names changed.  However, this
double-indirection is not really needed and has only served to confuse
people.  Instead, let's just have functions which may not have unique names
and may or may not have an implementation.  If someone wants to do overload
resolving, they can hav a hash table based function+overload system in the
overload resolving pass.  There's no good reason to keep it in core NIR.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
ir3 bits are

Reviewed-by: Rob Clark <robclark@gmail.com>
8 years agonvc0: don't forget to reset VTX_TMP bufctx slot after blit completion
Ilia Mirkin [Mon, 28 Dec 2015 01:44:01 +0000 (20:44 -0500)]
nvc0: don't forget to reset VTX_TMP bufctx slot after blit completion

Also release the scratch allocation if any.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
8 years agonv50,nvc0: add a note when converting vertex elements using CPU
Ilia Mirkin [Sun, 27 Dec 2015 20:13:21 +0000 (15:13 -0500)]
nv50,nvc0: add a note when converting vertex elements using CPU

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agogallium/auxiliary: don't build NIR sources with MSVC2008 flags
Connor Abbott [Sun, 20 Dec 2015 16:42:56 +0000 (11:42 -0500)]
gallium/auxiliary: don't build NIR sources with MSVC2008 flags

NIR has never been built with MSVC2008, so we shouldn't add
MSVC2008_COMPAT_CFLAGS to anything that uses it. This allows us to get
rid of the pragma in tgsi_to_nir.c.

Build tested with freedreno.

v2: Use MSVC2013_COMPAT_CLFAGS instead.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Signed-off-by: Connor Abbott <cwabbott0@gmail.com>
8 years agoi965: Add tr_mode and mip tail information in surface state dump
Anuj Phogat [Wed, 23 Dec 2015 19:14:20 +0000 (11:14 -0800)]
i965: Add tr_mode and mip tail information in surface state dump

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
8 years agoi965/gen8/cs: Gen8 requires 64 byte alignment for push constant data
Jordan Justen [Wed, 23 Dec 2015 07:42:52 +0000 (23:42 -0800)]
i965/gen8/cs: Gen8 requires 64 byte alignment for push constant data

The BDW PRM Vol2a: Command Reference: Instructions, section MEDIA_CURBE_LOAD,
says that 'CURBE Total Data Length' and 'CURBE Data Start Address' are
64-byte aligned. This is different from previous gens, that were 32-byte
aligned.

v2 (Jordan):
  - CURBE Data Start Address is also 64-byte aligned.
    - The call to brw_state_batch should also use 64-byte alignment.
      - Improve PRM reference.

v3:
 * New patch from Jordan. Always align base and size to 64 bytes.

Fixes the following SSBO CTS tests on BDW:
ES31-CTS.shader_storage_buffer_object.basic-atomic-case1-cs
ES31-CTS.shader_storage_buffer_object.basic-operations-case1-cs
ES31-CTS.shader_storage_buffer_object.basic-operations-case2-cs
ES31-CTS.shader_storage_buffer_object.basic-stdLayout_UBO_SSBO-case2-cs
ES31-CTS.shader_storage_buffer_object.advanced-write-fragment-cs
ES31-CTS.shader_storage_buffer_object.advanced-indirectAddressing-case2-cs
ES31-CTS.shader_storage_buffer_object.advanced-matrix-cs

And many other CS CTS tests as reported by Marta Lofstedt.

(Commit message is from Iago, but in v3, code is from Jordan.)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Tested-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agofreedreno/ir3: spelling..
Rob Clark [Wed, 23 Dec 2015 05:06:00 +0000 (00:06 -0500)]
freedreno/ir3: spelling..

Signed-off-by: Rob Clark <robclark@freedesktop.org>
8 years agonir/print: print variable constant-initializers
Rob Clark [Tue, 22 Dec 2015 21:50:23 +0000 (16:50 -0500)]
nir/print: print variable constant-initializers

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agodocs: Clarify that ARB_tessellation_shader is only done on i965/gen8+.
Kenneth Graunke [Wed, 23 Dec 2015 04:14:35 +0000 (20:14 -0800)]
docs: Clarify that ARB_tessellation_shader is only done on i965/gen8+.

Requested by kisak on IRC.

8 years agodocs: Mark ARB_tessellation_shader as done on i965/gen8+.
Kenneth Graunke [Wed, 23 Dec 2015 02:50:18 +0000 (18:50 -0800)]
docs: Mark ARB_tessellation_shader as done on i965/gen8+.

8 years agoi965: Enable ARB_tessellation_shader on Gen8+.
Kenneth Graunke [Mon, 27 Jul 2015 21:19:31 +0000 (14:19 -0700)]
i965: Enable ARB_tessellation_shader on Gen8+.

Everything is in place and I'm not aware of any further issues.

Tested with:
- Piglit
- Tessmark
- Unigine Heaven
- Shadow of Mordor
- GRID Autosport

I have patches to backport this to Haswell, Ivybridge, and Baytrail as
well (the first Intel hardware to support tessellation), but there are
still a lot of GPU hangs left to debug.  So that will come later.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Handle mix-and-match TCS/TES with separate shader objects.
Kenneth Graunke [Tue, 8 Dec 2015 04:18:42 +0000 (20:18 -0800)]
i965: Handle mix-and-match TCS/TES with separate shader objects.

GL_ARB_separate_shader_objects allows the application to mix-and-match
TCS and TES programs separately.  This means that the interface between
the two stages isn't known until the final SSO pipeline is in place.

This isn't a great match for our hardware: the TCS and TES have to agree
on the Patch URB entry layout.  Since we store data as per-patch slots
followed by per-vertex slots, changing the number of per-patch slots can
significantly alter the layout.  This can easily happen with SSO.

To handle this, we store the [Patch]OutputsWritten and [Patch]InputsRead
bitfields in the TCS/TES program keys, introducing program recompiles.
brw_upload_programs() decides the layout for both TCS and TES, and
passes it to brw_upload_tcs/tes(), which store it in the key.

When creating the NIR for a shader specialization, we override
nir->info.inputs_read (and friends) to the program key's values.
Since everything uses those, no further compiler changes are needed.
This also replaces the hack in brw_create_nir().

To avoid recompiles, brw_precompile_tes() looks to see if there's a
TCS in the linked shader.  If so, it accounts for the TCS outputs,
just as brw_upload_programs() would.  This eliminates all recompiles
in the non-SSO case.  In the SSO case, there should only be recompiles
when using a TCS and TES that have different input/output interfaces.

Fixes Piglit's mix-and-match-tcs-tes test.

v2: Pull the brw_upload_programs code into a brw_upload_tess_programs()
    helper function (requested by Jordan Justen).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Defer input lowering for tessellation stages until specialization.
Kenneth Graunke [Tue, 8 Dec 2015 01:58:35 +0000 (17:58 -0800)]
i965: Defer input lowering for tessellation stages until specialization.

With tessellation shaders and SSO, we won't be able to always decide on
VUE map layouts at LinkProgram time.  Unfortunately, we have to delay it
until shader specialization time.

However, uniform lowering cannot be deferred - brw_codegen_*_prog()
reads nir->num_uniforms.  Fortunately, we don't need to defer it -
uniform, system value, atomic, and sampler lowering can safely stay
where it is.  This patch moves those to brw_lower_nir()'s only caller,
renames brw_lower_nir() to brw_nir_lower_io(), and introduces calls
to that.

For non-tessellation stages, I chose to call brw_nir_lower_io() from
brw_create_nir(), so it's still done at the same time.  There's no
need to defer it, and doing it at LinkProgram time is nice.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Automatically create a passthrough TCS when needed.
Kenneth Graunke [Fri, 18 Dec 2015 10:23:39 +0000 (02:23 -0800)]
i965: Automatically create a passthrough TCS when needed.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Start program_string_id from 1, not 0.
Kenneth Graunke [Fri, 18 Dec 2015 11:18:11 +0000 (03:18 -0800)]
i965: Start program_string_id from 1, not 0.

This way, I can safely use brw_tcs_prog_key::program_string_id == 0
to mean "not filled out because no program exists", which avoids the
need for adding an extra boolean to that struct.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Create and set a new brw_tcs_prog_data::outputs_written field.
Kenneth Graunke [Fri, 18 Dec 2015 05:39:28 +0000 (21:39 -0800)]
i965: Create and set a new brw_tcs_prog_data::outputs_written field.

When the application hasn't supplied a TCS, and we have to create one,
we need to know what VS outputs to copy to TES inputs.

To do this, we create a new program key field, and set it to the TES
InputsRead bitfield.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Upload HS push constants whenever default tess. levels change.
Kenneth Graunke [Fri, 18 Dec 2015 11:13:07 +0000 (03:13 -0800)]
i965: Upload HS push constants whenever default tess. levels change.

When using tessellation on OpenGL without a TCS, default values for
gl_TessLevelOuter/gl_TessLevelInner are provided via the API.

Core Mesa will flag ctx->DriverFlags.NewDefaultTessLevels whenever those
values change.  We add a corresponding BRW_NEW_DEFAULT_TESS_LEVELS flag
and hook it up to HS push constants (which will be used to upload these
default values to the autogenerated TCS).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Only call _mesa_load_state_parameters if prog exists.
Kenneth Graunke [Fri, 18 Dec 2015 10:57:05 +0000 (02:57 -0800)]
i965: Only call _mesa_load_state_parameters if prog exists.

With the automatic-TCS creation, we won't have a prog, but still need to
upload push constants.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Switch TCS gl_program/gl_shader_program checks over to TES.
Kenneth Graunke [Fri, 18 Dec 2015 05:24:32 +0000 (21:24 -0800)]
i965: Switch TCS gl_program/gl_shader_program checks over to TES.

Tessellation control shaders are optional, but evaluation shaders will
always be present when using tessellation.  However, we'll always enable
the TCS (HS) hardware stage when using tessellation - we'll just create
a program on the fly.

That program, however, won't have a gl_program or gl_shader_program.
So we shouldn't check brw->tess_ctrl_program or
shader_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL] - if we want to know
whether tessellation is enabled, we should look for a TES.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Remove unnecessary brw->tess_ctrl_program assertions.
Kenneth Graunke [Fri, 18 Dec 2015 05:17:07 +0000 (21:17 -0800)]
i965: Remove unnecessary brw->tess_ctrl_program assertions.

This is trying to enforce the fact that the hardware requires HS, TE,
and DS to be enabled or disabled together.  But it's kind of an ad-hoc
attempt, and not too useful.

More importantly, we aren't going to have a gl_shader_program for the
TCS which is automatically generated when none is present.  (We'll just
handle it in the driver backend.)  So, these will trip for no reason.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Consolidate BRW_NEW_TESS_{CTRL,EVAL}_PROGRAM flags.
Kenneth Graunke [Fri, 18 Dec 2015 05:02:40 +0000 (21:02 -0800)]
i965: Consolidate BRW_NEW_TESS_{CTRL,EVAL}_PROGRAM flags.

For several reasons, I don't think it's particularly useful to have
separate flags:

1. Most of the time, tessellation shaders are paired, so both will be
   replaced at the same time.

2. The data layout is tightly coupled.  Both need to agree on the number
   of per-patch slots in the VUE map.  Even adding extra TCS outputs
   that aren't read by the TES will trigger the need for recompiles.

3. The TCS is optional from an API perspective, but required by the
   hardware whenever tessellation is enabled.  So, atoms that deal with
   the TCS must check brw->tess_eval_program (BRW_NEW_TESS_EVAL_PROGRAM?)
   rather than brw->tess_ctrl_program to tell whether tessellation is
   enabled.

So, not only is it unlikely to be useful, it's a bit confusing to get
right.  Simply using one flag for both simplifies this.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Only call brw_upload_tcs/tes_prog when using tessellation.
Kenneth Graunke [Tue, 15 Dec 2015 11:04:50 +0000 (03:04 -0800)]
i965: Only call brw_upload_tcs/tes_prog when using tessellation.

If there's no evaluation shader, tessellation is disabled.  The upload
functions would just bail.  Instead, don't bother calling them.

This will simplify the optional-TCS case a bit, as brw_upload_tcs can
assume that we're doing tessellation.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agonir: Add a glsl_vec_type() helper.
Kenneth Graunke [Fri, 18 Dec 2015 08:42:03 +0000 (00:42 -0800)]
nir: Add a glsl_vec_type() helper.

I need access to glsl_type::vec2_type from C.  Wrapping vec() also gives
us access to vec3 if we need it.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agonir: Use writemasked store_vars in glsl_to_nir.
Kenneth Graunke [Mon, 30 Nov 2015 07:23:44 +0000 (23:23 -0800)]
nir: Use writemasked store_vars in glsl_to_nir.

Instead of performing the read-modify-write cycle in glsl->nir, we can
simply emit a partial writemask.  For locals, nir_lower_vars_to_ssa will
do the equivalent read-modify-write cycle for us, so we continue to get
the same SSA values we had before.

Because glsl_to_nir calls nir_lower_outputs_to_temporaries, all outputs
are shadowed with temporary values, and written out as whole vectors at
the end of the shader.  So, most consumers will still not see partial
writemasks.

However, nir_lower_outputs_to_temporaries bails for tessellation control
shader outputs.  So those remain actual variables, and stores to those
variables now get a writemask.  nir_lower_io passes that through.  This
means that TCS outputs should actually work now.

This is a functional change for tessellation control shaders.

v2: Relax the nir_validate assert to allow partial writemasks.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
8 years agonir: Add a writemask to store intrinsics.
Kenneth Graunke [Tue, 17 Nov 2015 08:26:37 +0000 (00:26 -0800)]
nir: Add a writemask to store intrinsics.

Tessellation control shaders need to be careful when writing outputs.
Because multiple threads can concurrently write the same output
variables, we need to only write the exact components we were told.

Traditionally, for sub-vector writes, we've read the whole vector,
updated the temporary, and written the whole vector back.  This breaks
down with concurrent access.

This patch prepares the way for a solution by adding a writemask field
to store_var intrinsics, as well as the other store intrinsics.  It then
updates all produces to emit a writemask of "all channels enabled".  It
updates nir_lower_io to copy the writemask to output store intrinsics.

Finally, it updates nir_lower_vars_to_ssa to handle partial writemasks
by doing a read-modify-write cycle (which is safe, because local
variables are specific to a single thread).

This should have no functional change, since no one actually emits
partial writemasks yet.

v2: Make nir_validate momentarily assert that writemasks cover the
    complete value - we shouldn't have partial writemasks yet
    (requested by Jason Ekstrand).

v3: Fix accidental SSBO change that arose from merge conflicts.

v4: Don't try to handle writemasks in ir3_compiler_nir - my code
    for indirects was likely wrong, and TTN doesn't generate partial
    writemasks today anyway.  Change them to asserts as requested by
    Rob Clark.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com> [v3]
8 years agomesa: update gl_HelperInvocation support status in docs
Tapani Pälli [Wed, 16 Dec 2015 06:42:25 +0000 (08:42 +0200)]
mesa: update gl_HelperInvocation support status in docs

Was enabled for i965 and nvc0 by following commits:

c875e3cdd21811ad6669160d59fa39a4526ef872
39f51ec96f00f601b9c4d4e321dacb3af9dc866f

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Marta Lofstedt <marta.lofstedt@intel.com>
Acked-by: Matt Turner <mattst88@gmail.com>
8 years agomesa: fix interface matching done in validate_io
Tapani Pälli [Wed, 16 Dec 2015 06:24:52 +0000 (08:24 +0200)]
mesa: fix interface matching done in validate_io

Patch makes following changes for interface matching:

   - do not try to match builtin variables
   - handle swizzle in input name, as example 'a.z' should
     match with 'a'
   - add matching by location
   - check that amount of inputs and outputs matches

These changes make interface matching tests to work in:
   ES31-CTS.sepshaderobjs.StateInteraction

The test still does not pass completely due to errors in rendering
output. IMO this is unrelated to interface matching.

Note that type matching is not done due to varying packing which
changes type of variable, this can be added later on. Preferably
when we have quicker way to iterate resources and have a complete
list of all existed varyings (before packing) available.

v2: add spec reference, return true on desktop since we do not
    have failing cases for it, inputs and outputs amount do not
    need to match on desktop.

v3: add some more spec reference, remove desktop specifics since
    not used for now on desktop, add match by location qualifier,
    rename input_stage and output_stage as producer and consumer
    as suggested by Timothy.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
8 years agomesa: add SSBOs to the list of fragment shader side effects
Iago Toral Quiroga [Fri, 18 Dec 2015 09:18:01 +0000 (10:18 +0100)]
mesa: add SSBOs to the list of fragment shader side effects

The i965 driver uses this function to decide if it can disable the
FS unit in the absence of color/depth writes. We don't want to disable
the unit in the presence of SSBOs, since the fragment shader could
be writing to it.

We could go a step further and check not just for the presence of SSBOs
but also if the shader code writes to them. Does not look worth the trouble
though and we are not doing this for atomic buffers either anyway.

v2: put this into a generic _mesa_active_fragment_shader_has_side_effects
    function instead of having one specific for SSBOs (Jason).

Fixes the following CTS test:
ES31-CTS.shader_storage_buffer_object.advanced-usage-sync-vsfs

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoi965: Ensure FS execution in presence of atomic buffers
Iago Toral Quiroga [Fri, 18 Dec 2015 09:18:00 +0000 (10:18 +0100)]
i965: Ensure FS execution in presence of atomic buffers

On Haswell we need to set the UAV_ONLY WM state bit when there are no colour
or depth buffer writes and on all hardware we should set the early
depth/stencil control field to PSEXEC unless early fragment tests are enabled
to make sure that the fragment shader is executed regardless of whether
per-fragment tests pass or not as the spec requires.

So far we have been doing this for images only, but we should apply the same
treatment to all side effectful scenarios. Suggested by Curro.

This is not strictly required for compliance with the original
ARB_shader_atomic_counters extension, it's only necessary to get the execution
semantics specified in GL4.2+ right.

v2:
- Mark active_fs_has_side_effects as constant. (Curro)
- Mention that this is only only necessary to get the execution semantics
specified in GL4.2+ right. (Curro)

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agomesa: Add a _mesa_active_fragment_shader_has_side_effects helper
Iago Toral Quiroga [Fri, 18 Dec 2015 09:17:59 +0000 (10:17 +0100)]
mesa: Add a _mesa_active_fragment_shader_has_side_effects helper

Some drivers can disable the FS unit if there is nothing in the shader code
that writes to an output (i.e. color, depth, etc). Right now, mesa has
a function to check for atomic buffers and the i965 driver also checks for
images. Refactor this logic into a generic function that we can use for
any source of side effects in a fragment shader. Suggested by Jason.

v2:
- Use '_Shader', as suggested by Tapani, to fix the following CTS test:

ES31-CTS.shader_atomic_counters.advanced-usage-many-draw-calls2

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
8 years agoi965: Implement gl_PatchVerticesIn by baking it into brw_tcs_prog_key.
Kenneth Graunke [Thu, 26 Nov 2015 07:35:29 +0000 (23:35 -0800)]
i965: Implement gl_PatchVerticesIn by baking it into brw_tcs_prog_key.

The hardware provides us no decent way of getting at the number of input
vertices in the patch topology from the tessellation control shader.
It's actually very surprising - normally this sort of information would
be available in the thread payload.

For the precompile, we guess that the number of vertices will be the
same for both the input and output patches.  This usually seems to be
the case.

On Gen8+, we could pass in an extra push constant containing this value.
We may be able to do that on Haswell too.  It's quite a bit trickier on
Ivybridge, however.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Add tessellation control shaders.
Kenneth Graunke [Tue, 17 Nov 2015 09:07:39 +0000 (01:07 -0800)]
i965: Add tessellation control shaders.

The TCS is the first tessellation shader stage, and the most
complicated.  It has access to each of the control points in the input
patch, and computes a new output patch.  There is one logical invocation
per output control point; all invocations run in parallel, and can
communicate by reading and writing output variables.

One of the main responsibilities of the TCS is to write the special
gl_TessLevelOuter[] and gl_TessLevelInner[] output variables which
control how much new geometry the hardware tessellation engine will
produce.  Otherwise, it simply writes outputs that are passed along
to the TES.

We run in SIMD4x2 mode, handling two logical invocations per EU thread.
The hardware doesn't properly manage the dispatch mask for us; it always
initializes it to 0xFF.  We wrap the whole program in an IF..ENDIF block
to handle an odd number of invocations, essentially falling back to
SIMD4x1 on the last thread.

v2: Update comments (requested by Jordan Justen).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agoi965: Add tessellation evaluation shaders
Kenneth Graunke [Tue, 10 Nov 2015 22:35:27 +0000 (14:35 -0800)]
i965: Add tessellation evaluation shaders

The TES is essentially a post-tessellator VS, which has access to the
entire TCS output patch, and a special gl_TessCoord input.  Otherwise,
they're very straightforward.

This patch implements SIMD8 tessellation evaluation shaders for Gen8+.
The tessellator can generate a lot of geometry, so operating in SIMD8
mode (8 vertices per thread) is more efficient than SIMD4x2 mode (only
2 vertices per thread).  I have another patch which implements SIMD4x2
mode for older hardware (or via an environment variable override).

We currently handle all inputs via the pull model.

v2: Improve comments (suggested by Jordan Justen).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
8 years agonir: remove field only used in GLSL IR when assigning varying locations
Timothy Arceri [Mon, 21 Dec 2015 22:44:38 +0000 (09:44 +1100)]
nir: remove field only used in GLSL IR when assigning varying locations

This field is used as a flag to optimise out any varyings that don't have
a matching varying on the other side of the interface.

The value should be the same for all varyings (except for SSO but we can't
optimise those) by the time they reach nir and are no longer be needed.

Acked-by: Jason Ekstrand <jason.ekstrand@intel.com>
8 years agonouveau: enable use of new kernel interfaces
Ben Skeggs [Thu, 26 Nov 2015 05:17:53 +0000 (15:17 +1000)]
nouveau: enable use of new kernel interfaces

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
8 years agonvc0: remove use of deprecated sw class identifier
Ben Skeggs [Wed, 16 Dec 2015 23:03:49 +0000 (09:03 +1000)]
nvc0: remove use of deprecated sw class identifier

Also emits a method to properly bind the class to a subchannel, which
was missing previously.  The kernel currently doesn't care, but this
will break if it ever decides to (ie. to support multiple sw classes).

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
8 years agonv50: fix g98+ vdec class allocation
Ben Skeggs [Tue, 24 Nov 2015 23:01:32 +0000 (09:01 +1000)]
nv50: fix g98+ vdec class allocation

The kernel previously exposed incorrect classes for some of the chipsets
that this code supports.  It no longer does, but the older object ioctls
have compatibility to avoid breaking userspace.

This needs to be fixed before switching over to the newer interfaces.

Rather than hardcoding chipset->class like the rest of the driver does,
this makes use of (new) sclass queries to determine what's available.

v2.
- update to use symbolic class identifier from <nvif/class.h>

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
8 years agonouveau: remove use of deprecated nouveau_device_wrap()
Ben Skeggs [Thu, 26 Nov 2015 02:59:13 +0000 (12:59 +1000)]
nouveau: remove use of deprecated nouveau_device_wrap()

Switching to the newer libdrm entry-points tells libdrm that it's OK to
make use of newer kernel interfaces.

We want to be able to isolate any bugs to either the interfaces changes,
or the use of NVIF itself.  As such, this commit has a slight hack which
forces libdrm to continue using the older kernel interfaces.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
8 years agonouveau: fix screen creation failure paths
Ben Skeggs [Thu, 26 Nov 2015 04:34:43 +0000 (14:34 +1000)]
nouveau: fix screen creation failure paths

The winsys layer would attempt to cleanup the nouveau_device if screen
init failed, however, in most paths the pipe driver would have already
destroyed it, resulting in accesses to freed memory etc.

This commit fixes the problem by allowing the winsys to detect whether
the pipe driver's destroy function needs to be called or not.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
8 years agonouveau: return nouveau_screen from hw-specific creation functions
Ben Skeggs [Thu, 26 Nov 2015 04:24:42 +0000 (14:24 +1000)]
nouveau: return nouveau_screen from hw-specific creation functions

Kills off a void cast.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
8 years agonouveau: remove use of deprecated nouveau_device::drm_version
Ben Skeggs [Wed, 25 Nov 2015 23:57:30 +0000 (09:57 +1000)]
nouveau: remove use of deprecated nouveau_device::drm_version

v2. update for libdrm nouveau_drm::lib_version removal

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
8 years agonouveau: remove use of deprecated nouveau_device::fd
Ben Skeggs [Wed, 25 Nov 2015 23:38:35 +0000 (09:38 +1000)]
nouveau: remove use of deprecated nouveau_device::fd

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
8 years agonouveau: bump required libdrm version to 2.4.66
Ben Skeggs [Tue, 3 Nov 2015 05:55:55 +0000 (15:55 +1000)]
nouveau: bump required libdrm version to 2.4.66

v2. forgot bump for non-gallium driver

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
8 years agor600: fix viewport clipping handling (v2)
Dave Airlie [Sat, 19 Dec 2015 23:01:22 +0000 (23:01 +0000)]
r600: fix viewport clipping handling (v2)

If oViewport is written, vertex reuse need to be turned off.
If oViewport is constant, vertex reuse is fine, and VPORT_PROVOKE_DISABLE
need to be set. (we don't have enough info to program VPORT_PROVOKE).

Fixes: arb_viewport_array-render-viewport-2 and some CTS tests.
v2: drop vport provoke write, drop initial state writing this
on evergreen, only program it on evergreen.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>