Commit Graph

4624 Commits

Author SHA1 Message Date
Jason Ekstrand 0fe4580e64 nir/spirv: Add support for multiple entrypoints per shader
This is done by passing the entrypoint name into spirv_to_nir.  It will
then process the shader as if that were the only entrypoint we care about.
Instead of returning a nir_shader, it now returns a nir_function.
2015-12-30 17:45:43 -08:00
Jason Ekstrand e993e45eb1 nir/spirv: Get the shader stage from the SPIR-V
Previously, we depended on it being passed in.
2015-12-30 17:45:43 -08:00
Jason Ekstrand db3a64fcea nir/spirv: Use shader stage for determining variable locations 2015-12-30 17:45:43 -08:00
Jason Ekstrand d7ae2200f9 nir/spirv: Get rid of default GS info
shaderc has been fixed for a while now.
2015-12-30 17:45:43 -08:00
Jason Ekstrand d9c9a117dc nir/spirv: Handle execution modes as decorations
They're basically the same thing.
2015-12-30 17:45:43 -08:00
Jason Ekstrand 2b6bcaf91a nir/spirv: Separate handling of preamble from type/var/const instructions 2015-12-30 17:45:43 -08:00
Jason Ekstrand 07b4f17aaf nir/spirv/GLSL450: Add support for SAbs 2015-12-30 14:41:49 -08:00
Kenneth Graunke e6cd0c0e1c nir/spirv: Implement IsInf and IsNan built-ins. 2015-12-30 14:10:44 -08:00
Kenneth Graunke 9f23116bfa Revert "nir/spirv: Update to the 1.0 GLSL.std.450 header"
This reverts commit b33f5d3889,
and also removes the (empty) case statements for the new built-ins.

It doesn't look like glslang has updated yet, so updating the header
just breaks everything, as we no longer agree on opcode numbers.
2015-12-30 13:26:56 -08:00
Kristian Høgsberg Kristensen 91d93f7908 nir/spirv: Lower gl_GlobalInvocationID correctly
Use nir_intrinsic_load_local_invocation_id, not
nir_intrinsic_load_invocation_id (missing 'local'), which is a geometry
shader built-in.
2015-12-30 00:03:54 -08:00
Jason Ekstrand 451fe2670c nir/spirv/cfg: Handle discard 2015-12-29 19:23:25 -08:00
Jason Ekstrand 5693637faa nir/print: Handle variables with var->name == NULL 2015-12-29 16:58:00 -08:00
Jason Ekstrand 8cc55780fd nir/inline_functions: Switch to inlining everything 2015-12-29 16:58:00 -08:00
Kenneth Graunke 7cdcee3bed nir/spirv/glsl450: Enumerate more built-in opcodes. 2015-12-29 16:06:35 -08:00
Jason Ekstrand 2a58cb03d0 nir/spirv: Use instr_rewrite_src for updating phi sources
You can't just add a new source to a phi because use/def information won't
get updated properly.  Instead, you have to use one of the core helpers.
Some day, we may want to add a nir_phi_instr_add_src helper.
2015-12-29 15:44:39 -08:00
Jason Ekstrand 69d5838aee nir/validate: Don't validate the return deref for void function calls 2015-12-29 15:35:29 -08:00
Jason Ekstrand 51b04d03d5 nir/dominance: Handle unreachable blocks
Previously, nir_dominance.c didn't properly handle unreachable blocks.
This can happen if, for instance, you have something like this:

loop {
   if (...) {
      break;
   } else {
      break;
   }
}

In this case, the block right after the if statement will be unreachable.
This commit makes two changes to handle this.  First, it removes an assert
and allows block->imm_dom to be null if the block is unreachable.  Second,
it properly skips unreachable blocks in calc_dom_frontier_cb.
2015-12-29 15:29:27 -08:00
Kenneth Graunke b4a1c9b506 nir/spirv/glsl450: Implement inverse hyperbolic trig built-ins. 2015-12-29 15:27:03 -08:00
Kenneth Graunke 2ea111664c nir/spirv/glsl450: Implement Refract built-in. 2015-12-29 15:27:03 -08:00
Kenneth Graunke 74529a2c50 nir/spirv/glsl450: Implement hyperbolic trig built-ins. 2015-12-29 15:27:03 -08:00
Kenneth Graunke 0b1a436ac8 nir/spirv/glsl450: implement Reflect built-in. 2015-12-29 15:27:03 -08:00
Kenneth Graunke 659a3623b0 nir/spirv/glsl450: Implement FaceForward built-in. 2015-12-29 15:27:03 -08:00
Kenneth Graunke b10af36d93 nir/spirv/glsl450: Implement SmoothStep. 2015-12-29 15:27:03 -08:00
Kenneth Graunke 6a0fa2d758 nir/spirv/glsl450: Implement Cross built-in. 2015-12-29 15:27:03 -08:00
Kenneth Graunke 083fd6ec2a nir/spirv/glsl450: Implement Clamp/SClamp/UClamp. 2015-12-29 15:27:03 -08:00
Kenneth Graunke 034010924e nir/spirv/glsl450: Implement the Log built-in. 2015-12-29 15:27:03 -08:00
Kenneth Graunke ffc5ae7c9e nir/spirv/glsl450: Implement Exp built-in. 2015-12-29 15:27:03 -08:00
Kenneth Graunke 227e250005 nir/spirv/glsl450: Add a helper for doing fclamp(). 2015-12-29 15:27:03 -08:00
Kenneth Graunke 0f801752f2 nir/spirv/glsl450: Add helpers for calculating exp() and log(). 2015-12-29 15:27:03 -08:00
Kenneth Graunke 9c9edd1ce8 nir/spirv/glsl450: Add an 'nb' shortcut variable.
"nb" is shorter and more convenient than "&b->nb", especially
when several operations are composed together into a larger expression
tree.
2015-12-29 15:27:03 -08:00
Jason Ekstrand 5f04a61219 nir/lower_returns: Don't just change the type of a jump.
It doesn't give core NIR the opportunity to update predecessors and
successors.  Instead, we have to remove and re-insert the instruction.
2015-12-29 14:51:47 -08:00
Jason Ekstrand 6fa47c9c17 nir/builder: Add a nir_jump helper 2015-12-29 14:48:34 -08:00
Jason Ekstrand 37a38548d4 glsl/types.cpp: Fix function_key_compare 2015-12-29 14:32:10 -08:00
Jason Ekstrand b33f5d3889 nir/spirv: Update to the 1.0 GLSL.std.450 header 2015-12-29 14:29:03 -08:00
Jason Ekstrand a33fcc0fd4 Merge remote-tracking branch 'mesa-public/master' into vulkan
This pulls in nir_builder_init_simple_shader and allows us to delete
anv_nir_builder.h entirely.
2015-12-29 13:53:41 -08:00
Jason Ekstrand 0119773ffc 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>
2015-12-29 13:44:05 -08:00
Jason Ekstrand 5dd4386b92 nir/spirv: Use a C99-style initializer for structure fields
This ensures that all unknown fields get zero-initizlied so we don't have
undefined values floating around.
2015-12-29 13:15:20 -08:00
Jason Ekstrand 0a2ab87947 nir/spirv: Move CF emit code into vtn_cfg.c 2015-12-29 12:50:31 -08:00
Jason Ekstrand 4e22cd2e32 nir/spirv: Add support for switch statements 2015-12-29 12:50:31 -08:00
Jason Ekstrand cf555dc1c2 nir/spirv: A couple simple loop fixes 2015-12-29 12:50:31 -08:00
Jason Ekstrand 303d095f58 nir/spirv: Add an actual CFG data structure
The current data structure doesn't handle much that we couldn't handle
before.  However, this will be absolutely crucial for doing swith
statements.  Also, this should fix structured continues.
2015-12-29 12:50:31 -08:00
Kristian Høgsberg Kristensen f9283f2668 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>
2015-12-29 10:39:25 -08:00
Kristian Høgsberg Kristensen 1a59aeaebd mesa: Add core mesa support for GL_ARB_shader_draw_parameters
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2015-12-29 10:39:25 -08:00
Aaron Watry 70d8dbc9a1 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>
2015-12-29 09:42:14 -08:00
Jason Ekstrand b005fd62f9 nir/spirv: Add GLSL.std.450.h
It accidentally got removed during the mass rename.
2015-12-28 15:46:22 -08:00
Jason Ekstrand 763176a3e2 nir/lower_returns: Fix a bug in loop lowering 2015-12-28 13:22:09 -08:00
Jason Ekstrand 7aaed91581 nir/spirv: Move to its own directory 2015-12-28 11:49:39 -08:00
Jason Ekstrand d5fa51bdee Merge remote-tracking branch 'mesa-public/master' into vulkan
This pulls in the removal of nir_function_overload
2015-12-28 10:56:31 -08:00
Jason Ekstrand d9dcfafacc nir/spirv: Use nir_build_alu for alu instructions 2015-12-28 10:35:31 -08:00
Jason Ekstrand 237f2f2d8b 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>
2015-12-28 09:59:53 -08:00