summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* nir: Add barrier intrinsic functionJordan Justen2015-06-122-1/+4
| | | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Chris Forbes <[email protected]> Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Ben Widawsky <[email protected]>
* glsl: Add builtin barrier() functionChris Forbes2015-06-121-0/+18
| | | | | | | [[email protected]: Add CS support] Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ben Widawsky <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add ir node for barrierChris Forbes2015-06-128-0/+55
| | | | | | | | | v2: * Changes suggested by mattst88 [[email protected]: Add nir support] Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ben Widawsky <[email protected]>
* mesa; add a dummy _mesa_error_no_memory() symbol to libglsl_utilEmil Velikov2015-06-124-46/+7
| | | | | | | | | | | | Rather than forcing everyone to provide their own definition of the symbol provide a common (dummy) one. This helps us resolve the build of the standalone pipe-drivers (amongst others), which are missing the symbol. Cc: Rob Clark <[email protected]> Cc: "10.6" <[email protected]> Signed-off-by: Emil Velikov <[email protected]>
* glsl: fix constructing a vector from a matrixMartin Peres2015-06-111-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | Without this patch, the following constructs (not an extensive list) would crash mesa: - mat2 foo = mat2(1); vec4 bar = vec4(foo); - mat3 foo = mat3(1); vec4 bar = vec4(foo); - mat3 foo = mat3(1); ivec4 bar = ivec4(foo); The first case is explicitely allowed by the GLSL spec, as seen on page 101 of the GLSL 4.40 spec: "vec4(mat2) // the vec4 is column 0 followed by column 1" The other cases are implicitely allowed also. The actual changes are quite minimal. We first split each column of the matrix to a list of vectors and then use them to initialize the vector. An additional check to make sure that we are not trying to copy 0 elements of a vector fix the (i)vec4(mat3) case as the last vector (3rd column) is not needed at all. Reviewed-by: Tapani Pälli <[email protected]> Signed-off-by: Martin Peres <[email protected]>
* glsl: remove restriction on unsized arrays in GLSL ES 3.10Timothy Arceri2015-06-101-1/+9
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* android: build with libcxx on android lollipopChih-Wei Huang2015-06-091-1/+0
| | | | | | | | On Lollipop, apparently stlport is gone and libcxx must be used instead. We still support stlport when building on earlier android releases. Signed-off-by: Chih-Wei Huang <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* glsl: fix comment typo: s/accpet/accept/Brian Paul2015-06-091-1/+1
|
* glsl_compiler: Remove unused extra argument to printf in usage_failAlan Coopersmith2015-06-041-1/+1
| | | | | | | | | | | | Flagged by Oracle's parfait static analyzer: Error: Format string argument mismatch (CWE 628) In call to printf with format string "usage: %s [options] <file.vert | file.geom | file.frag>\n\nPossible options are:\n" Too many arguments for format string (got more than 1 arguments) at line 285 of src/glsl/main.cpp in function 'usage_fail'. Signed-off-by: Alan Coopersmith <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* mesa: reference built-in uniforms into gl_uniform_storageMartin Peres2015-06-046-37/+39
| | | | | | | | | | | | | | | This change introduces a new field in gl_uniform_storage to explicitely say that a uniform is built-in. In the case where it is, no storage is defined to make it clear that it is read-only from the mesa side. I fixed all the places in the code that made use of the structure that I changed. Any place making a wrong assumption and using the storage straight away will just crash. This patch seems to implement the path of least resistance towards listing built-in uniforms in GL_ACTIVE_UNIFORM (and other APIs). Reviewed-by: Tapani Pälli <[email protected]> Signed-off-by: Martin Peres <[email protected]>
* nir: use src for ssa helperTimothy Arceri2015-06-031-5/+1
| | | | | Reviewed-by: Thomas Helland <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir: remove extra semicolonTimothy Arceri2015-06-031-1/+1
| | | | | | Reviewed-by: Thomas Helland <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir: prevent use-after-free condition in should_lower_phi()Eduardo Lima Mitev2015-06-021-0/+5
| | | | | | | | | | | | | | | | | | lower_phis_to_scalar() pass recurses the instruction dependence graph to determine if all the sources of a given instruction are scalarizable. To prevent cycles, it temporary marks the phi instruction before recursing in, then updates the entry with the resulting value. However, it does not consider that the entry value may have changed after a recursion pass, hence causing a use-after-free situation and a crash. This patch fixes this by reloading the entry corresponding to the 'phi' after recursing and before updating its value. The crash can be reproduced ~20% of times with the dEQP test: dEQP-GLES3.functional.shaders.loops.while_constant_iterations.nested_sequence_fragment Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Fix output swizzle in get_mul_for_srcIago Toral Quiroga2015-05-281-10/+9
| | | | | | | | When we compute the output swizzle we want to consider the number of components in the add operation. So far we were using the writemask of the multiplication for this instead, which is not correct. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: avoid leaking linked gl_shader when there's a late linker errorIlia Mirkin2015-05-251-2/+8
| | | | | | | | | | This makes piglit mixing-clip-distance-and-clip-vertex-disallowed have 0 definitely lost blocks with valgrind. (Same non-0 number of possibly lost blocks though.) Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Tobias Klausmann <[email protected]> Cc: "10.5 10.6" <[email protected]>
* nir: Remove sRGB colorspace conversion round-trip.Matt Turner2015-05-221-0/+2
| | | | | | | | | | | | | | | | | | Some shaders in Civilization V and Beyond Earth do pow(pow(x, 2.2), 0.454545) which is converting to and from sRGB colorspace. A more general rule that replaces pow(pow(a, b), c) with pow(a, b * c) actually regresses two shaders in Sun Temple in which the result of the inner pow is used twice, once by another pow and once by another instruction. Also, since 2.2 * 0.454545 isn't exactly one, the more general pattern would have still left us with a pow, and I'm 2.2 * 0.454545 percent sure that's not what they want. instructions in affected programs: 934 -> 886 (-5.14%) helped: 16
* glsl: remove element_type() helperTimothy Arceri2015-05-2211-36/+23
| | | | | | | | | | | | | | We now have is_array() and without_array() that make the code much clearer and remove the need for this. For all remaining calls to this we already knew that the type was an array so returning a null wasn't adding any value. v2: use without_array() in _mesa_ast_array_index_to_hir() and don't use without_array() in lower_clip_distance_visitor() as we want to make sure the array is 2D. Reviewed-by: Matt Turner <[email protected]>
* glsl: Use AM_V_GEN/AM_V_at in NIR rules.Matt Turner2015-05-211-10/+10
|
* nir: Get rid of the array elements parameter on load/store intrinsicsJason Ekstrand2015-05-202-12/+9
| | | | | | | | | | | | | Previously, we used intrinsic->const_index[1] to represent "the number of array elements to load" for load/store intrinsics. However, this set to 1 by every pass that ever creates a load/store intrinsic. Also, while it might make some sense for registers, it makes no sense whatsoever in SSA. On top of that, the i965 backend was the only backend to ever support it; freedreno and vc4 just assert that it's always 1. Let's just delete it. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* glsl: add stage references for UBO uniformsTapani Pälli2015-05-181-0/+10
| | | | | | | | Patch marks uniforms inside UBO properly referenced by stages. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsalvez <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90397
* nir: Translate memory barrier intrinsics from GLSL IR.Francisco Jerez2015-05-121-0/+4
| | | | | Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Translate image load, store and atomic intrinsics from GLSL IR.Francisco Jerez2015-05-121-11/+115
| | | | | | | v2: Undefine coordinate components not applicable to the target. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Fix indexing of atomic counter arrays with a constant value.Francisco Jerez2015-05-121-1/+2
| | | | | Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add memory barrier intrinsic.Francisco Jerez2015-05-121-0/+7
| | | | | Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Define image load, store and atomic intrinsics.Francisco Jerez2015-05-121-0/+27
| | | | | | | v2: Undefine coordinate components not applicable to the target. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: fix sampler lowering pass for arraysTapani Pälli2015-05-121-19/+12
| | | | | | | | | | | | | | | | | | This fixes bugs with special cases where we have arrays of structures containing samplers or arrays of samplers. I've verified that patch results in calculating same index value as returned by _mesa_get_sampler_uniform_value for IR. Patch makes following ES3 conformance test pass: ES3-CTS.shaders.struct.uniform.sampler_array_fragment v2: remove unnecessary comment (Topi) simplify changes and the overall code (Jason) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90114
* nir: Fix aggressive typos in nir_from_ssa.c.Kenneth Graunke2015-05-081-5/+5
| | | | | | s/agressive/aggressive/g Trivial.
* nir/search: Save/restore the variables_seen bitmask when matchingJason Ekstrand2015-05-081-0/+12
| | | | | | | | | | | | | Shader-db results on Broadwell: total instructions in shared programs: 7152330 -> 7137006 (-0.21%) instructions in affected programs: 1330548 -> 1315224 (-1.15%) helped: 5797 HURT: 76 GAINED: 0 LOST: 8 Reviewed-by: Connor Abbott <[email protected]>
* nir/search: Assert that variable id's are in rangeJason Ekstrand2015-05-081-0/+1
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir/search: handle explicitly sized sources in match_valueJason Ekstrand2015-05-081-8/+8
| | | | | | | | | | Previously, this case was being handled in match_expression prior to calling match_value. However, there is really no good reason for this given that match_value has all of the information it needs. Also, they weren't being handled properly in the commutative case and putting it in match_value gives us that for free. Reviewed-by: Connor Abbott <[email protected]>
* nir/nir: Use a linked list instead of a hash set for use/def setsJason Ekstrand2015-05-0814-306/+281
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit switches us from the current setup of using hash sets for use/def sets to using linked lists. Doing so should save us quite a bit of memory because we aren't carrying around 3 hash sets per register and 2 per SSA value. It should also save us CPU time because adding/removing things from use/def sets is 4 pointer manipulations instead of a hash lookup. Running shader-db 50 times with USE_NIR=0, NIR, and NIR + use/def lists: GLSL IR Only: 586.4 +/- 1.653833 NIR with hash sets: 675.4 +/- 2.502108 NIR + use/def lists: 641.2 +/- 1.557043 I also ran a memory usage experiment with Ken's patch to delete GLSL IR and keep NIR. This patch cuts an aditional 42.9 MiB of ralloc'd memory over and above what we gained by deleting the GLSL IR on the same dota trace. On the code complexity side of things, some things are now much easier and others are a bit harder. One of the operations we perform constantly in optimization passes is to replace one source with another. Due to the fact that an instruction can use the same SSA value multiple times, we had to iterate through the sources of the instruction and determine if the use we were replacing was the only one before removing it from the set of uses. With this patch, uses are per-source not per-instruction so we can just remove it safely. On the other hand, trying to iterate over all of the instructions that use a given value is more difficult. Fortunately, the two places we do that are the ffma peephole where it doesn't matter and GCM where we already gracefully handle duplicates visits to an instruction. Another aspect here is that using linked lists in this way can be tricky to get right. With sets, things were quite forgiving and the worst that happened if you didn't properly remove a use was that it would get caught in the validator. With linked lists, it can lead to linked list corruption which can be harder to track. However, we do just as much validation of the linked lists as we did of the sets so the validator should still catch these problems. While working on this series, the vast majority of the bugs I had to fix were caught by assertions. I don't think the lists are going to be that much worse than the sets. Reviewed-by: Connor Abbott <[email protected]>
* nir: Use nir_instr_rewrite_src in copy propagationJason Ekstrand2015-05-081-61/+10
| | | | | | | We were rolling our own rewrite_src variant in copy-propagation. Let's stop doing that and use the ones in core NIR. Reviewed-by: Connor Abbott <[email protected]>
* nir: Add a function for rewriting the condition of an if statementJason Ekstrand2015-05-082-0/+23
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir: Add and use initializer #defines for nir_src and nir_destJason Ekstrand2015-05-086-18/+15
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir: Modernize the out-of-SSA passJason Ekstrand2015-05-081-103/+36
| | | | | | | | | The out-of-SSA pass was one of the first passes written when getting SSA up-and-going (for obvious reasons). As such, it came before a lot of the nifty SSA-based helpers were introduced. This commit modernizes it so that we're no longer doing nearly as much manual banging on use/def sets. Reviewed-by: Connor Abbott <[email protected]>
* nir/validate: Validate SSA def parent instructionsJason Ekstrand2015-05-081-0/+2
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir: Delete all traces of nir_op_flogIan Romanick2015-05-082-7/+0
| | | | | | | | Nothing produces it, and nothing can consume it. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* nir: Don't produce nir_op_flog from GLSL IRIan Romanick2015-05-081-1/+1
| | | | | | | | | All paths that produce GLSL IR for NIR lower ir_unop_log. All paths that consume NIR will explode if they geta nir_op_flog. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* nir: Delete all traces of nir_op_fexpIan Romanick2015-05-082-8/+0
| | | | | | | | Nothing produces it, and nothing can consume it. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* nir: Don't produce nir_op_fexp from GLSL IRIan Romanick2015-05-081-1/+1
| | | | | | | | | All paths that produce GLSL IR for NIR lower ir_unop_exp. All paths that consume NIR will explode if they geta nir_op_fexp. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* glsl: check total count of multi-slot double vertex attribsDave Airlie2015-05-081-1/+40
| | | | | | | | | | | | The spec is vague all over the place about this, but this seems to be the intent, we can probably make this optional later if someone makes hw that cares and writes a driver. Basically we need to double count some of the d types but only for totalling not for slot number assignment. Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: track which program inputs are doublesDave Airlie2015-05-081-13/+3
| | | | | | | | instead of doing the attempts at dual slot handling here, let the backend do it. Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: add ARB_vertex_attrib_64bit support. (v2)Dave Airlie2015-05-084-0/+9
| | | | | | | | | | | Just more boilerplate stuff. v2: bad fallthrough on versioning, this is my ugly but self contained solution (Ian) Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* nir: Allow feq/fne/ieq/ine to be optimized with inot.Matt Turner2015-05-071-0/+4
| | | | | | | | instructions in affected programs: 380 -> 376 (-1.05%) helped: 2 Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Glenn Kennard <[email protected]>
* nir: Recognize (a < c || b < c) as min(a, b) < c.Matt Turner2015-05-071-0/+2
| | | | | | | | | | | | | | ... and (a >= c) || (b >= c) as max(a, b) >= c. Similar to commit 97e6c1b9. total instructions in shared programs: 6182276 -> 6182180 (-0.00%) instructions in affected programs: 6400 -> 6304 (-1.50%) helped: 68 HURT: 4 Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Glenn Kennard <[email protected]>
* nir: Recognize trivial min/max.Matt Turner2015-05-071-0/+6
| | | | | | | No changes, but does prevent some regressions in the next commit. Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Glenn Kennard <[email protected]>
* nir: Recognize i2b(b2i(x)) as x.Matt Turner2015-05-071-0/+1
| | | | | | | | | | Helps the same set of programs as the previous commit. instructions in affected programs: 4490 -> 4346 (-3.21%) helped: 8 Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Glenn Kennard <[email protected]>
* nir: Recognize imul(b2i(a), b2i(b)) as a logical AND.Matt Turner2015-05-071-0/+1
| | | | | | | | | | | | Four shaders in Unreal 4's Sun Temple are helped, and gain SIMD16 because we avoid an integer multiplication. instructions in affected programs: 2353 -> 2245 (-4.59%) helped: 4 GAINED: 4 Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Glenn Kennard <[email protected]>
* glsl: mark special built-in inputs referenced by vertex stageTapani Pälli2015-05-061-1/+6
| | | | | | | | | | | | | | | Refactoring done on active attribute queries did not take in to account special built-in inputs for the vertex stage. This commit sets them referenced by vertex stage so that they get enumerated properly. Fixes Piglit test 'get-active-attrib-returns-all-inputs' failure. Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90243 Acked-by: Jose Fonseca <[email protected]> Tested-by: Dieter Nützel <[email protected]> Reviewed-By: Martin Peres <[email protected]>
* glsl: add parens in shader_integer_mix() to silence compiler warningBrian Paul2015-05-051-1/+1
| | | | | | | | Silences gcc warning: builtin_functions.cpp:204:23: warning: suggest parentheses around '&&' within '||' [-Wparentheses] Reviewed-by: Ilia Mirkin <[email protected]>