mesa.git
9 years agoi965/disasm: Print the type after the swizzle also for 3src src operands
Ville Syrjälä [Tue, 31 Mar 2015 12:01:24 +0000 (15:01 +0300)]
i965/disasm: Print the type after the swizzle also for 3src src operands

The disassembly currently has the swizzle after the type for 3src source
operands, and the other way around for 2src. Flip the type and swizzle
around for 3src so that the output matches 2src.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
9 years agoi965: Move brw_link_shader's GLSL IR transformations into a helper.
Kenneth Graunke [Tue, 7 Apr 2015 23:28:10 +0000 (16:28 -0700)]
i965: Move brw_link_shader's GLSL IR transformations into a helper.

This function was getting a bit large and unwieldy.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
9 years agoi965: Change brw_shader to gl_shader in brw_link_shader().
Kenneth Graunke [Tue, 7 Apr 2015 23:29:32 +0000 (16:29 -0700)]
i965: Change brw_shader to gl_shader in brw_link_shader().

Nothing actually wanted brw_shader fields - we just had to type
shader->base all over the place for no reason.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
9 years agonir: Constify nir_lower_sampler's gl_shader_program pointer.
Kenneth Graunke [Tue, 7 Apr 2015 22:50:54 +0000 (15:50 -0700)]
nir: Constify nir_lower_sampler's gl_shader_program pointer.

Now that we're not generating linker errors, we don't actually modify
this.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
9 years agonir: Remove linker_error calls from nir_lower_samplers().
Kenneth Graunke [Tue, 7 Apr 2015 22:46:56 +0000 (15:46 -0700)]
nir: Remove linker_error calls from nir_lower_samplers().

These should never happen.  Plus, NIR passes really shouldn't be
reporting linker errors - this is past link time.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
9 years agonir: Make nir_lower_samplers take a gl_shader_stage, not a gl_program *.
Kenneth Graunke [Tue, 7 Apr 2015 22:14:16 +0000 (15:14 -0700)]
nir: Make nir_lower_samplers take a gl_shader_stage, not a gl_program *.

We don't actually need a gl_program struct.  We only used it to
translate prog->Target (i.e. GL_VERTEX_PROGRAM) to the gl_shader_stage
(i.e. MESA_SHADER_VERTEX).  We may as well just pass that.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
9 years agonir: Move gl_shader_stage enum from mtypes.h to shader_enums.h.
Kenneth Graunke [Tue, 7 Apr 2015 22:18:43 +0000 (15:18 -0700)]
nir: Move gl_shader_stage enum from mtypes.h to shader_enums.h.

I want to use this in some code that doesn't currently include mtypes.h.
It seems like a better place for it anyway.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
9 years agonir: Fix #include guards in shader_enums.h.
Kenneth Graunke [Tue, 7 Apr 2015 22:16:51 +0000 (15:16 -0700)]
nir: Fix #include guards in shader_enums.h.

This header was originally going to be called pipeline.h, but it got
renamed at the last minute.  Make the include guards match.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
9 years agonir: Constify prog_to_nir's gl_program pointer.
Kenneth Graunke [Tue, 7 Apr 2015 22:07:33 +0000 (15:07 -0700)]
nir: Constify prog_to_nir's gl_program pointer.

prog_to_nir should not modify the incoming Mesa IR program - just
translate it.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
9 years agogallivm: Fix build since llvm-3.7.0svn r234460.
Vinson Lee [Thu, 9 Apr 2015 05:51:57 +0000 (22:51 -0700)]
gallivm: Fix build since llvm-3.7.0svn r234460.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89963
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
9 years agodraw: (trivial) don't print the shader twice with GALLIVM_DEBUG=tgsi (or ir)
Roland Scheidegger [Sat, 4 Apr 2015 14:49:08 +0000 (16:49 +0200)]
draw: (trivial) don't print the shader twice with GALLIVM_DEBUG=tgsi (or ir)

Neither the shader nor the key change when doing elts or linear variant, so
this was just annoying (probably mildly useful at some point when we printed
the IR per function too).

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
9 years agogallivm: don't use control flow when doing indirect constant buffer lookups
Roland Scheidegger [Wed, 8 Apr 2015 22:49:11 +0000 (00:49 +0200)]
gallivm: don't use control flow when doing indirect constant buffer lookups

llvm goes crazy when doing that, using way more memory and time, though there's
probably more to it - this points to a very much similar issue as fixed in
8a9f5ecdb116d0449d63f7b94efbfa8b205d826f. In any case I've seen a quite
plain looking vertex shader with just ~50 simple tgsi instructions (but with a
dozen or so such indirect constant buffer lookups) go from a terribly high
~440ms compile time (consuming 25MB of memory in the process) down to a still
awful ~230ms and 13MB with this fix (with llvm 3.3), so there's still obvious
improvements possible (but I have no clue why it's so slow...).
The resulting shader is most likely also faster (certainly seemed so though
I don't have any hard numbers as it may have been influenced by compile times)
since generally fetching constants outside the buffer range is most likely an
app error (that is we expect all indices to be valid).
It is possible this fixes some mysterious vertex shader slowdowns we've seen
ever since we are conforming to newer apis at least partially (the main draw
loop also has similar looking conditionals which we probably could do without -
if not for the fetch at least for the additional elts condition.)

v2: use static vars for the fake bufs, minor code cleanups

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
9 years agoglsl: check for forced_language_version in is_version()
Brian Paul [Wed, 1 Apr 2015 20:36:09 +0000 (14:36 -0600)]
glsl: check for forced_language_version in is_version()

This is a follow-on fix from the earlier "glsl: allow ForceGLSLVersion
to override #version directives" change.  Since we're not changing
the language_version field, we have to check forced_language_version
here.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
9 years agoi965/skl: Fix the order of the arguments for the LD sampler message
Neil Roberts [Fri, 6 Mar 2015 19:11:19 +0000 (19:11 +0000)]
i965/skl: Fix the order of the arguments for the LD sampler message

In Skylake the order of the arguments for sample messages with the LD
type are u, v, lod, r whereas previously they were u, lod, v, r.

This fixes 144 Piglit tests including ones that directly use
texelFetch and also some using the meta stencil blit path which
appears to use texelFetch in its shader.

v2: Fix sampling 1D textures

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
9 years agoi965: Fix depth field setting in surface state for raw buffer on Gen7/8
Zhenyu Wang [Tue, 7 Apr 2015 05:48:38 +0000 (13:48 +0800)]
i965: Fix depth field setting in surface state for raw buffer on Gen7/8

On Gen7/8 for RAW surface format, the depth field (surf[3]) in surface
state means [30:21] bits of number of entries which is different from
other surface format which uses [26:21] bits field.

Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
9 years agou_tile: fix warnings about incompatible casts.
Dave Airlie [Wed, 8 Apr 2015 00:31:14 +0000 (10:31 +1000)]
u_tile: fix warnings about incompatible casts.

Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agor600g/sb: Enable SB for geometry shaders
Glenn Kennard [Tue, 7 Apr 2015 01:00:20 +0000 (03:00 +0200)]
r600g/sb: Enable SB for geometry shaders

Add SV_GEOMETRY_EMIT special variable type to track the
implicit dependencies between CUT/EMIT_VERTEX/MEM_RING
instructions so GCM/scheduler doesn't reorder them.

Mark emit instructions as unkillable so DCE doesn't eat them.

Enable only for evergreen/cayman as there are a few
unexplained GS piglit regressions on R6xx/R7xx with SB
enabled otherwise.

Signed-off-by: Glenn Kennard <glenn.kennard@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agor600g/sb: Update last_cf for loops
Glenn Kennard [Thu, 26 Mar 2015 01:56:50 +0000 (02:56 +0100)]
r600g/sb: Update last_cf for loops

CF_END could end up emitted in the middle of a shader on cayman
when there was a loop at the very end.

Fixes glsl-1.50-geometry-end-primitive and
ext_transform_feedback-geometry-shaders-basic piglit tests.

Signed-off-by: Glenn Kennard <glenn.kennard@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agou_tile: fix stencil texturing tests under softpipe
Dave Airlie [Mon, 6 Apr 2015 23:52:41 +0000 (09:52 +1000)]
u_tile: fix stencil texturing tests under softpipe

arb_stencil_texturing-draw failed under softpipe because we got a float
back from the texturing function, and then tried to U2F it, stencil
texturing returns ints, so we should fix the tiling to retrieve
the stencil values as integers not floats.

Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agonir: Make nir_*_instr_create take a nir_shader instead of a void * context
Jason Ekstrand [Tue, 7 Apr 2015 19:33:17 +0000 (12:33 -0700)]
nir: Make nir_*_instr_create take a nir_shader instead of a void * context

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
9 years agonir: Implement a nir_sweep() pass.
Kenneth Graunke [Sat, 28 Mar 2015 02:50:29 +0000 (19:50 -0700)]
nir: Implement a nir_sweep() pass.

This pass performs a mark and sweep pass over a nir_shader's associated
memory - anything still connected to the program will be kept, and any
dead memory we dropped on the floor will be freed.

The expectation is that this will be called when finished building and
optimizing the shader.  However, it's also fine to call it earlier, and
many times, to free up memory earlier.

v2: (feedback from Jason Ekstrand)
- Skip sweeping impl->start_block, as it's already in the CF list.
- Don't sweep SSA defs (they're owned by their defining instruction)
- Don't steal phi sources (they're owned by nir_phi_instr).
- Don't steal tex->src (it's owned by the tex_inst itself)
- Don't sweep dereference chains (top-level dereferences are owned by
  the instruction; sub-dereferences are owned by the parent deref).
- Don't sweep sources and destinations (SSA defs are handled as part of
  the defining instruction, and registers are handled as part of
  function implementations).
- Just steal instructions; don't walk them (no longer required).

v3: (feedback from Jason Ekstrand)
- Steal indirect sources from nir_src/nir_dest.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agonir: Allocate dereferences out of their parent instruction or deref.
Kenneth Graunke [Fri, 3 Apr 2015 04:24:38 +0000 (21:24 -0700)]
nir: Allocate dereferences out of their parent instruction or deref.

Jason pointed out that variable dereferences in NIR are really part of
their parent instruction, and should have the same lifetime.

Unlike in GLSL IR, they're not used very often - just for intrinsic
variables, call parameters & return, and indirect samplers for
texturing.  Also, nir_deref_var is the top-level concept, and
nir_deref_array/nir_deref_record are child nodes.

This patch attempts to allocate nir_deref_vars out of their parent
instruction, and any sub-dereferences out of their parent deref.
It enforces these restrictions in the validator as well.

This means that freeing an instruction should free its associated
dereference chain as well.  The memory sweeper pass can also happily
ignore them.

v2: Rename make_deref to evaluate_deref and make it take a nir_instr *
    instead of void *.  This involves adding &instr->instr everywhere.
    (Requested by Jason Ekstrand.)

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agonir: Allocate nir_ssa_def::uses/if_uses out of the instruction.
Kenneth Graunke [Sat, 28 Mar 2015 17:02:17 +0000 (10:02 -0700)]
nir: Allocate nir_ssa_def::uses/if_uses out of the instruction.

We can't allocate them out of the nir_ssa_def itself, because it may not
be ralloc'd (for example, nir_dest embeds a nir_ssa_def).

However, allocating them out of the instruction should work.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agonir: Allocate nir_phi_src values out of the nir_phi_instr.
Kenneth Graunke [Thu, 2 Apr 2015 23:15:11 +0000 (16:15 -0700)]
nir: Allocate nir_phi_src values out of the nir_phi_instr.

Phi sources are part of the phi instruction and should have the same
lifetime.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agonir: Allocate nir_call_instr::params out of the nir_call itself.
Kenneth Graunke [Tue, 7 Apr 2015 07:32:55 +0000 (00:32 -0700)]
nir: Allocate nir_call_instr::params out of the nir_call itself.

The lifetime of the params array needs to be match the nir_call_instr
itself.  So, allocate it using the instruction itself as the context.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoi965: Add the ability to render to I8/L8 and I16/L16 UNORM formats.
Kenneth Graunke [Sun, 29 Mar 2015 10:45:16 +0000 (03:45 -0700)]
i965: Add the ability to render to I8/L8 and I16/L16 UNORM formats.

This allows those formats to work with the meta PBO upload path.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
9 years agoi965: Use SET_FIELD in 3DSTATE_STREAMOUT packets.
Kenneth Graunke [Mon, 6 Apr 2015 23:09:35 +0000 (16:09 -0700)]
i965: Use SET_FIELD in 3DSTATE_STREAMOUT packets.

Suggested by Topi Pohjolainen.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
9 years agonir/lower_tex_projector: Don't use designated initializers
Jason Ekstrand [Tue, 7 Apr 2015 04:04:42 +0000 (21:04 -0700)]
nir/lower_tex_projector: Don't use designated initializers

These don't work in MSVC or in older versions of GCC

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89899
Reviewed-by: Mark Janes <mark.a.janes@intel.com>
9 years agoglsl: relax input->output validation for SSO programs
Tapani Pälli [Thu, 2 Apr 2015 09:59:55 +0000 (12:59 +0300)]
glsl: relax input->output validation for SSO programs

Commit 18004c3 introduced more restrictive validation to linker
between inputs and outputs. This patch skips the additional check
for programs that utilize GL_ARB_separate_shader_objects, there
inputs and outputs might not make exact match during linking but
only when constructing the final pipeline.

This made some of the GL_ARB_program_interface_query tests shaders
fail to link, these tests can be used to verify the change.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
9 years agonv50,nvc0: limit the y-tiling of 3d textures to the first level's tiling
Ilia Mirkin [Sun, 5 Apr 2015 21:40:44 +0000 (17:40 -0400)]
nv50,nvc0: limit the y-tiling of 3d textures to the first level's tiling

We limit y-tiling to 0x20 when depth is involved. However the function is
run for each miplevel, and the hardware expects miplevel 0 to have the
highest tiling settings. Perform the y-tiling limit on all levels of a
3d texture, not just the ones that have depth.

Fixes:
  texelFetch fs sampler3D 98x129x1-98x129x9

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Tested-by: Nick Tenney <nick.tenney@gmail.com> # GT216
Cc: "10.4 10.5" <mesa-stable@lists.freedesktop.org>
9 years agor600g: fix op3 abs issue
Dave Airlie [Tue, 31 Mar 2015 05:18:47 +0000 (15:18 +1000)]
r600g: fix op3 abs issue

This code to handle absolute values on op3 srcs was a bit too simple,
it really needs a temp reg per src, not one per channel, make it
easier and let sb clean up the mess.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89831

Reviewed-by: Glenn Kennard <glenn.kennard@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
9 years agoi965: Do not render primitives in non-zero streams then TF is disabled
Iago Toral Quiroga [Mon, 9 Mar 2015 14:17:03 +0000 (15:17 +0100)]
i965: Do not render primitives in non-zero streams then TF is disabled

Haswell hardware seems to ignore Render Stream Select bits from
3DSTATE_STREAMOUT packet when the SOL stage is disabled even if
the PRM says otherwise. Because of this, all primitives are sent
down the pipeline for rasterization, which is wrong. If SOL is
enabled, Render Stream Select is honored and primitives bound to
non-zero streams are discarded after stream output.

Since the only purpose of primives sent to non-zero streams is to
be recorded by transform feedback, we can simply discard all geometry
bound to non-zero streams then transform feedback is disabled
to prevent it from ever reaching the rasterization stage.

Notice that this patch introduces a small change in the behavior we
get when a geometry shader emits more vertices than the maximum declared:
before, a vertex that was emitted to a non-zero stream when TF was
disabled would still count for the purposes of checking that we don't
exceed the maximum number of output vertices declared by the shader. With
this change, these vertices are completely ignored and won't increase
the output vertex count, making more room for other (hopefully more
useful) vertices.

Fixes piglit test arb_gpu_shader5-emitstreamvertex_nodraw on Haswell
and Broadwell.

v2 (Ken): Drop is_haswell check in favor of doing this unconditionally.
Broadwell needs the workaround as well, and it doesn't hurt to do it in
general.  Also tweak comments - the Haswell PRM does actually mention
this ("Command Reference: Instructions" page 797).

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83962
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: mesa-stable@lists.freedesktop.org
9 years agoi965: Add forgotten multi-stream code to Gen8 SOL state.
Kenneth Graunke [Fri, 27 Mar 2015 00:21:10 +0000 (17:21 -0700)]
i965: Add forgotten multi-stream code to Gen8 SOL state.

Fixes Piglit's arb_gpu_shader5-xfb-streams-without-invocations.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Cc: mesa-stable@lists.freedesktop.org
9 years agoi965: Fix instanced geometry shaders on Gen8+.
Kenneth Graunke [Sat, 4 Apr 2015 09:00:52 +0000 (02:00 -0700)]
i965: Fix instanced geometry shaders on Gen8+.

Jordan added this in commit 741782b5948bb3d01d699f062a37513c2e73b076 for
Gen7 platforms.  I missed this when adding the Broadwell code.

Fixes Piglit's spec/arb_gpu_shader5/invocation-id-{basic,in-separate-gs}
with MESA_EXTENSION_OVERRIDE=GL_ARB_gpu_shader5 set.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
Cc: mesa-stable@lists.freedesktop.org
9 years agoi965: Free dead GLSL IR one last time.
Kenneth Graunke [Thu, 2 Apr 2015 07:55:45 +0000 (00:55 -0700)]
i965: Free dead GLSL IR one last time.

While working on NIR's memory allocation model, I realized the GLSL IR
memory model was broken.

During glCompileShader, we allocate everything out of the
_mesa_glsl_parse_state context, and reparent it to gl_shader at the end.

During glLinkProgram, we allocate everything out of a temporary context,
then reparent it to the exec_list containing the linked IR.

But during brw_link_shader - the driver's final opportunity to do
lowering and optimization - we just allocated everything out of the
permanent context given to us by the linker.  That memory stayed
forever.

Notably, passes like brw_fs_channel_expressions cause us to churn the
majority of the code, so we really want to free dead IR here.

Saves 125MB of memory when replaying a Dota 2 trace on Broadwell.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoi965: Implement SIMD16 texturing on Gen4.
Kenneth Graunke [Fri, 20 Feb 2015 23:11:49 +0000 (15:11 -0800)]
i965: Implement SIMD16 texturing on Gen4.

This allows SIMD16 mode to work for a lot more programs.  Texturing is
also more efficient in SIMD16 mode than SIMD8.  Several messages don't
actually exist in SIMD8 mode, so we did SIMD16 messages and threw away
half of the data.  Now we compute real data in both halves.

Also, the SIMD16 "sample" message doesn't require all three coordinate
components to exist (like the SIMD8 one), so we can shorten the message
lengths, cutting register usage a bit.

I chose to implement the visitor functionality in a separate function,
since mixing true SIMD16 with SIMD8 code that uses SIMD16 fallbacks
seemed like a mess.  The new code bails on a few cases where we'd
have to do two SIMD8 messages - we just fall back to SIMD8 for now.

Improves performance in "Shadowrun: Dragonfall - Director's Cut" by
about 20% on GM45 (measured with LIBGL_SHOW_FPS=1 while standing around
in the first mission).

v2: Add ir_txf to the has_lod case (caught by Jordan Justen).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
9 years agoi965: Use SIMD16 instead of SIMD8 on Gen4 when possible.
Kenneth Graunke [Fri, 20 Feb 2015 22:09:17 +0000 (14:09 -0800)]
i965: Use SIMD16 instead of SIMD8 on Gen4 when possible.

Gen5+ systems allow you to specify multiple shader programs - both SIMD8
and SIMD16 - and the hardware will automatically dispatch to the most
appropriate one, given the number of subspans to be processed.

However, that is not the case on Gen4.  Instead, you program a single
shader.  If you enable multiple dispatch modes (SIMD8 and SIMD16), the
shader is supposed to contain a series of jump instructions at the
beginning.  The hardware will launch the shader at a small offset,
hitting one of the jumps.

We've always thought that sounds like a pain, and weren't clear how it
affected performance - is it worth having multiple shader types?  So,
we never bothered with SIMD16 until now.

This patch takes a simpler approach: try and compile a SIMD16 shader.
If possible, set the no_8 flag, telling the hardware to just use the
SIMD16 variant all the time.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
9 years agoi965: Respect the no_8 flag on Gen4-5.
Kenneth Graunke [Sat, 10 Jan 2015 21:31:48 +0000 (13:31 -0800)]
i965: Respect the no_8 flag on Gen4-5.

This flag means to ignore the SIMD8 program and only use the SIMD16 one.
It was originally meant for repdata clear shaders, but I plan to use it
for other things on Gen4 as well.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
9 years agoi965/fp: Set coord_components correctly for cube textures.
Kenneth Graunke [Sat, 4 Apr 2015 01:30:57 +0000 (18:30 -0700)]
i965/fp: Set coord_components correctly for cube textures.

I've no idea why this was 4.  It certainly seems wrong.

Prevents assertion failures in fp-incomplete-tex with some upcoming
patches of mine.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
9 years agoglsl/cse: Maintain a list of free ae_entry objects
Ian Romanick [Thu, 26 Mar 2015 00:23:40 +0000 (17:23 -0700)]
glsl/cse: Maintain a list of free ae_entry objects

The CSE algorithm will continuously allocate new ae_entry objects.  As
each new basic block is exited, all of the previously allocated objects
are dumped.  Instead, put them in a free list and re-use them in the
next basic block.  Reduce, reuse, recycle!

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
9 years agonir: Remove fsin_reduced/fcos_reduced.
Matt Turner [Thu, 2 Apr 2015 01:25:02 +0000 (18:25 -0700)]
nir: Remove fsin_reduced/fcos_reduced.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agost/mesa: Remove unused emit_scs().
Matt Turner [Thu, 2 Apr 2015 01:23:58 +0000 (18:23 -0700)]
st/mesa: Remove unused emit_scs().

Was only used by the sin_reduced/cos_reduced cases, which themselves
were impossible to reach.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoprogram: Remove unused emit_scs().
Matt Turner [Thu, 2 Apr 2015 01:22:52 +0000 (18:22 -0700)]
program: Remove unused emit_scs().

Was only used by the sin_reduced/cos_reduced cases, which themselves
were impossible to reach.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoi965/vec4: Remove emit_scs() prototype.
Matt Turner [Thu, 2 Apr 2015 01:21:41 +0000 (18:21 -0700)]
i965/vec4: Remove emit_scs() prototype.

This has never existed.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoglsl: Remove never used sin_reduced/cos_reduced.
Matt Turner [Thu, 2 Apr 2015 00:44:16 +0000 (17:44 -0700)]
glsl: Remove never used sin_reduced/cos_reduced.

These were added in commit f2616e56, presumably in preparation for
translating ARB vp/fp into GLSL IR. That never happened, and neither did
a lowering pass that actually generated these instructions.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agoglsl: Update the #line behaviour on GLSL 3.30+ and GLSL ES+
Antia Puentes [Tue, 17 Mar 2015 18:12:23 +0000 (19:12 +0100)]
glsl: Update the #line behaviour on GLSL 3.30+ and GLSL ES+

From GLSL 3.30 and GLSL ES 1.00 on, after processing the line
directive (including its new-line), the implementation should
behave as if it is compiling at the line number passed as
argument. In previous versions, it behaved as if compiling
at the passed line number + 1.

Partially fixes https://bugs.freedesktop.org/show_bug.cgi?id=88815

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
9 years agoglsl: respect the source number set by #line <line> <source>
Antia Puentes [Tue, 17 Mar 2015 18:28:25 +0000 (19:28 +0100)]
glsl: respect the source number set by #line <line> <source>

From GLSL 1.30.10, section 3.3 (Preprocessor):
"#line line source-string-number ... After processing this directive
(including its new-line), the implementation will behave as if it is
compiling at ... source string number source-string-number. Subsequent
source strings will be numbered sequentially, until another #line
directive overrides that numbering."

In the previous implementation the source number was always zero.
Subsequent source strings are still not numbered sequentially, because
in the glShaderSource implementation we are concatenating the source code
strings into one long string.

Partially fixes https://bugs.freedesktop.org/show_bug.cgi?id=88815

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
9 years agoi965: Make sure we always mark array surfaces as such
Iago Toral Quiroga [Tue, 3 Feb 2015 11:34:29 +0000 (12:34 +0100)]
i965: Make sure we always mark array surfaces as such

Even if they only have one slice, otherwise textureSize() won't
produce correct results for the depth value.

Fixes 10 dEQP tests in this category:
dEQP-GLES3.functional.shaders.texture_functions.texturesize.sampler2darray*

Reviewed-by: Mark Janes <mark.a.janes at intel.com>
9 years agofreedreno/ir3: add NIR compiler
Rob Clark [Thu, 12 Mar 2015 21:18:33 +0000 (17:18 -0400)]
freedreno/ir3: add NIR compiler

The NIR compiler frontend is an alternative to the TGSI f/e, producing
the same ir3 IR and using the same backend passes for scheduling, etc.

It is not enabled by default yet, as there are still some regressions.
To enable, use 'FD_MESA_DEBUG=nir'.  It is enough to use with, for
example, xonotic or supertuxkart.

With the NIR f/e, scalarizing and a number of other lowering steps
happen in NIR, so we don't have to do them in ir3.  Which simplifies the
f/e and allows the lowered instructions to pass through other
optimization stages.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno/a3xx: don't decode srgb on mem2gmem
Ilia Mirkin [Wed, 4 Mar 2015 01:36:39 +0000 (20:36 -0500)]
freedreno/a3xx: don't decode srgb on mem2gmem

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno/a3xx: pass sprite coord mode through to program emit
Ilia Mirkin [Sat, 4 Apr 2015 06:53:52 +0000 (02:53 -0400)]
freedreno/a3xx: pass sprite coord mode through to program emit

Use the correct sprite replacement depending on the flip of the coord
mode, using either T or 1-T depending on whether we have an upper-left or
lower-left coordinate origin. This fixes all the point sprite piglits.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno/a3xx: add UBO support
Ilia Mirkin [Tue, 31 Mar 2015 15:51:00 +0000 (11:51 -0400)]
freedreno/a3xx: add UBO support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno/ir3: insert nop between sfu/mem operations
Ilia Mirkin [Sat, 4 Apr 2015 17:37:45 +0000 (13:37 -0400)]
freedreno/ir3: insert nop between sfu/mem operations

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno: dirty context when reallocating a bound bo
Ilia Mirkin [Sat, 4 Apr 2015 02:29:44 +0000 (22:29 -0400)]
freedreno: dirty context when reallocating a bound bo

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno: keep track of buffer valid ranges
Ilia Mirkin [Fri, 3 Apr 2015 06:15:17 +0000 (02:15 -0400)]
freedreno: keep track of buffer valid ranges

Copies nouveau_buffer and radeon_buffer. This allows a write to proceed
to an uninitialized part of a buffer even when the GPU is using the
previously-initialized portions.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno: mark resources as being read so that writes flush the queue
Ilia Mirkin [Fri, 3 Apr 2015 00:48:44 +0000 (20:48 -0400)]
freedreno: mark resources as being read so that writes flush the queue

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno: don't bother setting resource timestamps
Ilia Mirkin [Sat, 4 Apr 2015 03:39:38 +0000 (23:39 -0400)]
freedreno: don't bother setting resource timestamps

Waiting on a bo being ready is handled in fd_bo_cpu_prep. No need to
keep separate timestamps around.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno: add a reading flag to indicate gpu is reading rsc
Ilia Mirkin [Fri, 3 Apr 2015 06:25:58 +0000 (02:25 -0400)]
freedreno: add a reading flag to indicate gpu is reading rsc

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno: fix resource flushing confusion
Ilia Mirkin [Fri, 3 Apr 2015 02:28:21 +0000 (22:28 -0400)]
freedreno: fix resource flushing confusion

A resource flush is an upload of a hypothetically-staging texture to the
GPU. For a UMA system, this will largely be a no-op or
cache-maintenance. Move the render flush logic into transfer_map where
it belongs, and clear out the transfer_flush function.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno: remove tex_resource
Ilia Mirkin [Fri, 3 Apr 2015 02:26:03 +0000 (22:26 -0400)]
freedreno: remove tex_resource

pipe_sampler_view already contains a texture, remove the redundant
tex_resource member which pointed at the same thing.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agofreedreno/ir3: handle FRAG IN's without interpolation specified
Rob Clark [Wed, 1 Apr 2015 16:31:46 +0000 (12:31 -0400)]
freedreno/ir3: handle FRAG IN's without interpolation specified

Fallback to picking based on semantic name.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno/ir3/cmdline: add @const headers for immediates
Rob Clark [Wed, 1 Apr 2015 14:52:29 +0000 (10:52 -0400)]
freedreno/ir3/cmdline: add @const headers for immediates

Since NIR f/e currently encodes immediates in instructions (rather than
passing via const), we need to ensure that when const's are used the get
initialized to the proper values.  Otherwise comparing NIR to TGSI
compiler, it will use proper immediate values in one case, and randomly
initialize values in the other.  Which confuses ir3test.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno/ir3/cmdline: remove hack for old compiler
Rob Clark [Wed, 1 Apr 2015 14:28:58 +0000 (10:28 -0400)]
freedreno/ir3/cmdline: remove hack for old compiler

Since we dropped the old compiler, we don't need this hack anymore.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno/ir3: handle const/immed/abs/neg in cp
Rob Clark [Sun, 29 Mar 2015 15:24:57 +0000 (11:24 -0400)]
freedreno/ir3: handle const/immed/abs/neg in cp

Be smarter about propagating copies from const or immed, or with abs/neg
modifiers.  Also, realize that absneg.s and absneg.f are really "fancy"
mov instructions.

This opens up the possibility to remove more copies.  It helps the TGSI
frontend a bit, but will be really needed for the NIR f/e which builds
everything up in SSA form (ie. will *always* insert a mov from const or
immediate).

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno/ir3: split float/int abs/neg
Rob Clark [Sun, 29 Mar 2015 15:18:29 +0000 (11:18 -0400)]
freedreno/ir3: split float/int abs/neg

Even though in the end, they map to the same bits, the backend will need
to be able to differentiate float abs/neg vs integer abs/neg.  Rather
than making the backend figure it out based on instruction opcode (which
when combined with mov/absneg instructions, can be awkward), just split
out different flags for each so the frontend can signal it's intentions
more clearly.  Also, since (neg) for bitwise op's is actually a bitwise-
not, split it out into bnot flag.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno/ir3: add ir3 builder helpers
Rob Clark [Wed, 18 Mar 2015 23:26:13 +0000 (19:26 -0400)]
freedreno/ir3: add ir3 builder helpers

Add helpers for constructing SSA forms of instructions.

Only partial cat5/cat6 coverage.. but we can add stuff as needed.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agofreedreno/ir3: fix sam argument order comment
Rob Clark [Mon, 30 Mar 2015 18:14:31 +0000 (14:14 -0400)]
freedreno/ir3: fix sam argument order comment

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agoxa: support for drivers which use NIR
Rob Clark [Fri, 3 Apr 2015 18:01:47 +0000 (14:01 -0400)]
xa: support for drivers which use NIR

We need to pull in libnir.la and it's dependency libglsl_util.la.  Also,
_mesa_error_no_memory() must be defined.

Fortunately with libnir.la (vs pulling in all of libglsl.la) we don't
also need libstdc++.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agobuild: add libnir.la
Rob Clark [Fri, 3 Apr 2015 17:57:46 +0000 (13:57 -0400)]
build: add libnir.la

If we want to use NIR from state trackers that don't already pull in the
whole of glsl (ie. anything other than mesa state tracker), we need a
separate more minimal libnir.  Possibly NIR should be better split out
from glsl, but for now, generate a second smaller libnir.la for those
who just want NIR but not all of glsl.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
9 years agogallium/ttn: MOD is an integer instruction
Rob Clark [Sat, 4 Apr 2015 22:15:24 +0000 (18:15 -0400)]
gallium/ttn: MOD is an integer instruction

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net
9 years agogallium/ttn: add UMAD
Rob Clark [Sat, 4 Apr 2015 22:15:00 +0000 (18:15 -0400)]
gallium/ttn: add UMAD

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
9 years agonir: add lowering for idiv/udiv/umod
Rob Clark [Tue, 31 Mar 2015 21:03:39 +0000 (17:03 -0400)]
nir: add lowering for idiv/udiv/umod

Based on the algo from NV50LegalizeSSA::handleDIV() and handleMOD().
See also trans_idiv() in freedreno/ir3/ir3_compiler.c (which was an
adaptation of the nv50 code from Ilia Mirkin).

A python/numpy script which implements the same algorithm (and is
possibly useful for debugging or analysis) can be found here:

  http://people.freedesktop.org/~robclark/div-lowering.py

I've tested this on i965 hacked up to insert the idiv lowering pass,
and on freedreno with NIR frontend.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Tested-by: Eric Anholt <eric@anholt.net> (vc4)
9 years agonir: fix typo for f2b/i2b/b2i expressions (v2)
Rob Clark [Tue, 31 Mar 2015 19:13:00 +0000 (15:13 -0400)]
nir: fix typo for f2b/i2b/b2i expressions (v2)

v2: discovered that i2b/b2i are also confused

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
9 years agonir: add option to lower slt/sge/seq/sne
Rob Clark [Tue, 31 Mar 2015 15:25:19 +0000 (11:25 -0400)]
nir: add option to lower slt/sge/seq/sne

In freedreno these get implemented as the matching f* instruction plus a
u2f to convert the result to float 1.0/0.0.  But less lines of code to
just let nir_opt_algebraic handle this for us, plus opens up some small
window for other opt passes to improve (ie. if some shader ended up with
both a flt and slt with same src args, for example).

v2: use b2f rather than u2f

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
9 years agomesa: Remove unused variables left over from 107ae27e57d.
Mathias Froehlich [Sun, 5 Apr 2015 07:21:51 +0000 (09:21 +0200)]
mesa: Remove unused variables left over from 107ae27e57d.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
9 years agoi965: Implement support for ARB_clip_control.
Mathias Fröhlich [Sun, 29 Mar 2015 14:52:57 +0000 (16:52 +0200)]
i965: Implement support for ARB_clip_control.

Switch between the two clip space definitions already available
in hardware. Update winding order dependent state according
to the clip control state.
This change did not introduce new piglit quick.test regressions on
an Ivybridge Mobile and a GM45 Express chipset.
Also it enables and passes the clip-control and clip-control-depth-precision
tests on these two chipsets.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
9 years agomesa: Remove the _WindowMap from gl_viewport_attrib.
Mathias Froehlich [Sun, 29 Mar 2015 16:57:46 +0000 (18:57 +0200)]
mesa: Remove the _WindowMap from gl_viewport_attrib.

The _WindowMap can be dropped from gl_viewport_attrib now.
Simplify gl_viewport_attrib handling where possible.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
9 years agotnl: Maintain the _WindowMap matrix in TNLcontext v2.
Mathias Froehlich [Sun, 29 Mar 2015 16:57:45 +0000 (18:57 +0200)]
tnl: Maintain the _WindowMap matrix in TNLcontext v2.

This is the only real user of _WindowMap which has the depth
buffer scaling multiplied in. Maintain the _WindowMap of the
one and only viewport inside TNLcontext.

v2:
Remove unneeded parentheses.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
9 years agoradeon: Make use of _mesa_get_viewport_xform v2.
Mathias Froehlich [Sun, 29 Mar 2015 16:57:45 +0000 (18:57 +0200)]
radeon: Make use of _mesa_get_viewport_xform v2.

Instead of _WindowMap just use the translation and scale
of the viewport transform directly. Thereby avoid dividing by
_DepthMaxF again.

v2:
Change order of assignments.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
9 years agoi965: Make use of _mesa_get_viewport_xform.
Mathias Froehlich [Sun, 29 Mar 2015 16:57:45 +0000 (18:57 +0200)]
i965: Make use of _mesa_get_viewport_xform.

Instead of _WindowMap just use the translation and scale
of the viewport transform directly. Thereby avoid dividing by
_DepthMaxF again.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
9 years agonv50: allocate more offset space for occlusion queries
Ilia Mirkin [Sat, 4 Apr 2015 03:57:43 +0000 (23:57 -0400)]
nv50: allocate more offset space for occlusion queries

Commit 1a170980a09 started writing to q->data[4]/[5] but kept the
per-query space at 16, which meant that in some cases we would write
past the end of the buffer. Rotate by 32, like nvc0 does. This ensures
that we always have 32 bytes in front of us, and the data writes will go
within the allocated space.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89679
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Tested-by: Nick Tenney <nick.tenney@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
Cc: "10.4 10.5" <mesa-stable@lists.freedesktop.org>
9 years agonir/lower_samplers: Use the right memory context for realloc'ing tex sources
Jason Ekstrand [Fri, 3 Apr 2015 22:23:20 +0000 (15:23 -0700)]
nir/lower_samplers: Use the right memory context for realloc'ing tex sources

As of da5ec2a, we allocate instruction sources out of the instruction
itself.  When we realloc the texture sources we need to use the right
memory context or ralloc will get angry and assert-fail

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
9 years agoi965: Use brw_nir_cubemap_normalize for NIR shaders
Jason Ekstrand [Fri, 3 Apr 2015 00:04:28 +0000 (17:04 -0700)]
i965: Use brw_nir_cubemap_normalize for NIR shaders

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
9 years agonir: Add a cubemap normalizing pass
Jason Ekstrand [Thu, 2 Apr 2015 23:38:30 +0000 (16:38 -0700)]
nir: Add a cubemap normalizing pass

This commit adds a pass to L1-normalize cube-map coordinates.  Some hardware
such as i965 requires that largest cube-map coordinate is +-1.  We had a
pass to perform this normalization in GLSL IR but we need it in NIR for
cube maps on ARB programs to work correctly.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
v2 (Suggested by Eric):
 - Do a vector fabs and split into components later
 - Move to core NIR

Reviewed-by: Eric Anholt <eric@anholt.net>
9 years agoi965: Check the INTEL_USE_NIR environment variable once at context creation
Jason Ekstrand [Fri, 3 Apr 2015 00:02:43 +0000 (17:02 -0700)]
i965: Check the INTEL_USE_NIR environment variable once at context creation

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
9 years agonir/from_ssa: Don't set reg->parent_instr for ssa_undef instructions
Jason Ekstrand [Thu, 2 Apr 2015 19:32:39 +0000 (12:32 -0700)]
nir/from_ssa: Don't set reg->parent_instr for ssa_undef instructions

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
9 years agonir: Add a src_get_parent_instr function
Jason Ekstrand [Thu, 2 Apr 2015 18:07:48 +0000 (11:07 -0700)]
nir: Add a src_get_parent_instr function

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
9 years agoi965: Use the tex projector lowering pass instead of hand-rolling it.
Eric Anholt [Wed, 1 Apr 2015 18:38:53 +0000 (11:38 -0700)]
i965: Use the tex projector lowering pass instead of hand-rolling it.

This only impacts the ARB_fp path.  We can't quite disable the GLSL-level
lowering pass, because it needs to apply before
brw_do_lower_unnormalized_offset().

total instructions in shared programs: 5667857 -> 5667847 (-0.00%)
instructions in affected programs:     1114 -> 1104 (-0.90%)
helped:                                16
HURT:                                  6

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agonir: Add a lowering pass for texture projectors.
Eric Anholt [Fri, 27 Mar 2015 21:18:11 +0000 (14:18 -0700)]
nir: Add a lowering pass for texture projectors.

Not much hardware wants them these days, and it might give us a chance to
do CSE or algebraic at the NIR level.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agonir: Add an interface to turn a nir_src into a nir_ssa_def.
Eric Anholt [Fri, 27 Mar 2015 21:19:46 +0000 (14:19 -0700)]
nir: Add an interface to turn a nir_src into a nir_ssa_def.

We use nir_ssa_defs for nir_builder args, so this takes a nir_src and
makes one so it can be passed in.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agonir: Add an interface for the builder to insert instructions before.
Eric Anholt [Fri, 27 Mar 2015 21:18:54 +0000 (14:18 -0700)]
nir: Add an interface for the builder to insert instructions before.

So far we'd only used nir_builder to build brand new programs.  But if
we're doing modifications to instructions (like in a lowering pass), then
we want to generate new stuff before the instruction we're modifying.

Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agogallium: fix gcc compile errors when using _XOPEN_SOURCE=600 but not std=c99
Jose Fonseca [Thu, 2 Apr 2015 15:35:16 +0000 (17:35 +0200)]
gallium: fix gcc compile errors when using _XOPEN_SOURCE=600 but not std=c99

The fpclassify stuff either needs std=c99 or _XOPEN_SOURCE=600 passed
to gcc, but when using the latter the lrint family of function will be defined
too.

9 years agoi965: Rename do_<stage>_prog to brw_compile_<stage>_prog (and export)
Carl Worth [Fri, 20 Mar 2015 19:10:49 +0000 (12:10 -0700)]
i965: Rename do_<stage>_prog to brw_compile_<stage>_prog (and export)

This is in preparation for these functions to be called from other
files.

This commit is intended to have no functional change. It exists in
preparation for some upcoming code movement in preparation for the
shader cache.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
9 years agoi965: Split out per-stage dirty-bit checking into separate functions
Carl Worth [Fri, 20 Mar 2015 19:01:33 +0000 (12:01 -0700)]
i965: Split out per-stage dirty-bit checking into separate functions

The dirty-bit checking from each brw_upload_<stage>_prog function is
split out into its a new brw_<stage>_state_dirty function.

This commit is intended to have no functional change. It exists in
preparation for some upcoming code movement in preparation for the
shader cache.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
9 years agoi965: Split out brw_<stage>_populate_key into their own functions
Carl Worth [Mon, 23 Feb 2015 22:44:39 +0000 (14:44 -0800)]
i965: Split out brw_<stage>_populate_key into their own functions

This commit splits portions of the existing brw_upload_vs_prog and
brw_upload_gs_prog function into new brw_vs_populate_key and
brw_gs_populate_key functions. This follows the same style as is
already present for all other stages, (see brw_wm_populate_key, etc.).

This commit is intended to have no functional change. It exists in
preparation for some upcoming code movement in preparation for the
shader cache.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
9 years agonv50/ir: avoid folding immediates into imad operations
Ilia Mirkin [Thu, 2 Apr 2015 22:42:31 +0000 (18:42 -0400)]
nv50/ir: avoid folding immediates into imad operations

Commit 09ee907266 added logic to fold immediates into mad operations,
but the emission code is only there for fmad. Only allow it on float
types.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agonv50/ir: fix imad emission when dst == src2
Ilia Mirkin [Thu, 2 Apr 2015 22:33:55 +0000 (18:33 -0400)]
nv50/ir: fix imad emission when dst == src2

Commit fb63df22151f added 4-byte mad support, but only supported
emission for floats. Disable it for ints for now.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
9 years agonir: Allocate nir_tex_instr::sources out of the instruction itself.
Kenneth Graunke [Sat, 28 Mar 2015 07:02:37 +0000 (00:02 -0700)]
nir: Allocate nir_tex_instr::sources out of the instruction itself.

The lifetime of the sources array needs to be match the nir_tex_instr
itself.  So, allocate it using the instruction itself as the context.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agonir: Allocate predecessor and dominance frontier sets from block itself.
Kenneth Graunke [Sat, 28 Mar 2015 04:29:07 +0000 (21:29 -0700)]
nir: Allocate predecessor and dominance frontier sets from block itself.

These sets are part of the block, and their lifetime needs to match the
block itself.  So, allocate them using the block itself as the context.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
9 years agonir: Allocate register fields out of the register itself.
Kenneth Graunke [Sat, 28 Mar 2015 03:21:59 +0000 (20:21 -0700)]
nir: Allocate register fields out of the register itself.

The lifetime of each register's use/def/if_use sets needs to match the
register itself.  So, allocate them using the register itself as the
context.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>