summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: rename location layout helperTimothy Arceri2015-11-181-5/+5
| | | | | | | Change name from validate -> apply to more accurately describe what the function does. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: don't validate binding when its not neededTimothy Arceri2015-11-181-2/+5
| | | | | | | | | | | Checking that the flag has been set is all the validation thats needed here. Also not calling the binding validation function will make things much simpler when adding compile time constant support as we won't need to resolve the binding value. Reviewed-by: Emil Velikov <[email protected]>
* glsl: remove temp variable to make code easier to readTimothy Arceri2015-11-181-10/+7
| | | | Reviewed-by: Emil Velikov <[email protected]>
* glsl: cleanup and fix validate matrix function for arraysTimothy Arceri2015-11-181-10/+1
| | | | | | | | | Previously if the member was an array of matrices then a warning message would be incorrectly given. Also the struct case could never be met so it has been removed. Reviewed-by: Emil Velikov <[email protected]>
* glsl: use better location in struct and block error messagesTimothy Arceri2015-11-181-7/+3
| | | | | | | | Previously we only gave the location for some members and never gave the variable location. In those cases we were just giving the location of the struct/block. Reviewed-by: Emil Velikov <[email protected]>
* glsl: only do type and qualifier validation once per declarationTimothy Arceri2015-11-181-99/+97
| | | | | | | | | | | | | | | For struct and block members previously we were doing it for every variable declaration. So for example struct S { atomic_uint x, y, z; }; Would previously generate three error messages when one is sufficient. Reviewed-by: Emil Velikov <[email protected]>
* glsl: rename function that processes struct and iface membersTimothy Arceri2015-11-181-30/+30
| | | | | | | As of the previous commit this function handles only struct/iface members. Reviewed-by: Emil Velikov <[email protected]>
* glsl: move block validation outside function that validates membersTimothy Arceri2015-11-181-8/+8
| | | | Reviewed-by: Emil Velikov <[email protected]>
* glsl: move ast layout qualifier handling code into its own functionTimothy Arceri2015-11-181-202/+212
| | | | | | | | | We now also only apply these rules to variables rather than also trying to apply them to function params. V2: move code for handling stream layout qualifier Reviewed-by: Emil Velikov <[email protected]>
* glsl: copy each field's precision information in glsl_types's structure ↵Samuel Iglesias Gonsálvez2015-11-171-0/+1
| | | | | | | constructor Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: copy each field's precision information from the old gl_PerVertex ↵Samuel Iglesias Gonsálvez2015-11-171-0/+2
| | | | | | | interface block Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: copy each field's precision information when generating varying variablesSamuel Iglesias Gonsálvez2015-11-171-0/+1
| | | | | Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: initialize data.precision value in ir_variable constructorSamuel Iglesias Gonsálvez2015-11-171-0/+1
| | | | | Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl/nir: initialize precision field in glsl_struct_field constructorSamuel Iglesias Gonsálvez2015-11-171-1/+2
| | | | | Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* nir: reduce memory footprint of glsl_struct_field's precisionSamuel Iglesias Gonsálvez2015-11-171-1/+1
| | | | | Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: initialize precision when adding per vertex record fieldsTapani Pälli2015-11-171-0/+1
| | | | | | | | | Fixes issues with tessellation builtin variables since precision was introduced to IR with commit f84bc57d7dc02fceb805803131426c791eadeff9. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/glsl: Fix copy-n-paste mistakes from commit 213f864.Matt Turner2015-11-161-3/+3
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir/glsl_to_nir: use _mesa_fls() to compute num_texturesJuan A. Suarez Romero2015-11-161-7/+2
| | | | | | | | | | | | | Replace the current loop by a direct call to _mesa_fls() function. It also fixes an implicit bug in the current code where num_textures seems to be one value less than it should be when sh->Program->SamplersUsed > 0. For instance, num_textures is 0 instead of 1 when sh->Program->SamplersUsed is 1. Signed-off-by: Juan A. Suarez Romero <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir/copy_propagate: do not copy-propagate MOV srcs with source modifiersIago Toral Quiroga2015-11-161-1/+6
| | | | | | | | | | | | | If a source operand in a MOV has source modifiers, then we cannot copy-propagate it from the parent instruction and remove the MOV. v2: remove the check for source modifiers from is_move() (Jason) v3: Put the check for source modifiers back into is_move() since this function is called from copy_prop_alu_src(). Add source modifiers checks to is_vec() instead. Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Silence GCC maybe-uninitialized warnings.Vinson Lee2015-11-131-0/+3
| | | | | | | | | | | | | nir/nir_control_flow.c: In function ‘split_block_cursor.isra.11’: nir/nir_control_flow.c:460:15: warning: ‘after’ may be used uninitialized in this function [-Wmaybe-uninitialized] *_after = after; ^ nir/nir_control_flow.c:458:16: warning: ‘before’ may be used uninitialized in this function [-Wmaybe-uninitialized] *_before = before; ^ Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* glsl: Allow implicit int -> uint conversions for the % operator.Kenneth Graunke2015-11-131-9/+28
| | | | | | | | | | | | | | | | | GLSL 4.00 and GL_ARB_gpu_shader5 introduced a new int -> uint implicit conversion rule and updated the rules for modulus to use them. (In earlier languages, none of the implicit conversion rules did anything relevant, so there was no point in applying them.) This allows expressions such as: int foo; uint bar; uint mod = foo % bar; Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* nir: Add helpers for getting input/output intrinsic sources.Kenneth Graunke2015-11-132-0/+45
| | | | | | | | | | With the many variants of IO intrinsics, particular sources are often in different locations. It's convenient to say "give me the indirect offset" or "give me the vertex index" and have it just work, without having to think about exactly which kind of intrinsic you have. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Don't lower TCS outputs to temporaries.Kenneth Graunke2015-11-131-0/+3
| | | | | | | | We'd like to shadow these when possible, but the current code doesn't work properly for TCS outputs. For now, disable it. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Allow outputs reads and add the relevant intrinsics.Kenneth Graunke2015-11-134-8/+21
| | | | | | | | | | | | | | | | | | | | | | | | | Normally, we rely on nir_lower_outputs_to_temporaries to create shadow variables for outputs, buffering the results and writing them all out at the end of the program. However, this is infeasible for tessellation control shader outputs. Tessellation control shaders can generate multiple output vertices, and write per-vertex outputs. These are arrays indexed by the vertex number; each thread only writes one element, but can read any other element - including those being concurrently written by other threads. The barrier() intrinsic synchronizes between threads. Even if we tried to shadow every output element (which is of dubious value), we'd have to read updated values in at barrier() time, which means we need to allow output reads. Most stages should continue using nir_lower_outputs_to_temporaries(), but in theory drivers could choose not to if they really wanted. v2: Rebase to accomodate Jason's review feedback. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir/lower_io: Introduce nir_store_per_vertex_output intrinsics.Kenneth Graunke2015-11-133-5/+26
| | | | | | | | | | | Similar to nir_load_per_vertex_input, but for outputs. This is not useful in geometry shaders, but will be useful in tessellation shaders. v2: Change stage_uses_per_vertex_outputs() to is_per_vertex_output(), taking a nir_variable (requested by Jason Ekstrand). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir/lower_io: Use load_per_vertex_input intrinsics for TCS and TES.Kenneth Graunke2015-11-131-4/+8
| | | | | | | | | | | | | | | | Tessellation control shader inputs are an array indexed by the vertex number, like geometry shader inputs. There aren't per-patch TCS inputs. Tessellation evaluation shaders have both per-vertex and per-patch inputs. Per-vertex inputs get the new intrinsics; per-patch inputs continue to use the ordinary load_input intrinsics, as they already work like we want them to. v2: Change stage_uses_per_vertex_inputs into is_per_vertex_input(), which takes a variable (requested by Jason Ekstrand). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* Revert "nir/copy_propagate: do not copy-propagate MOV srcs with source ↵Iago Toral Quiroga2015-11-131-10/+7
| | | | | | | | | | modifiers" The change proposed in the review leads to piglit regressions because is_move() is used in other places and relies on the checks for source modifiers to be there. Revert this until we agree on a better solution.
* glsl: fix 'shared' layout qualifier related regressionsSamuel Iglesias Gonsálvez2015-11-131-0/+5
| | | | | | | | | | | | | | | | Commit 8b28b35 added 'shared' as a keyword for compute shaders but it broke the existing 'shared' layout qualifier support for uniform and shader storage blocks. This patch fixes 578 dEQP-GLES31.functional.ssbo.* tests. v2: - Move SHARED to interface_block_layout_qualifier (Timothy) - Don't remove "shared" case insensitive check (Timothy) - Remove the clearing of shared_storage flag (Timothy) Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir/copy_propagate: do not copy-propagate MOV srcs with source modifiersIago Toral Quiroga2015-11-131-7/+10
| | | | | | | | | If a source operand in a MOV has source modifiers, then we cannot copy-propagate it from the parent instruction and remove the MOV. v2: remove the check for source source modifiers from is_move() (Jason) Reviewed-by: Jason Ekstrand <[email protected]>
* nir/vars_to_ssa: Delete dead output set codeJason Ekstrand2015-11-121-7/+0
| | | | | | | | This was a remnant of an early attempt to handle output reads in vars_to_ssa. That attempt was abandon a long time ago but these few lines were aparently left in the pass and managed to evade review. Reviewed-by: Connor Abbott <[email protected]>
* nir/vars_to_ssa: Rework copy set handling in lower_copies_to_load_storeJason Ekstrand2015-11-121-1/+4
| | | | | | | | | | | | | | | | | | | | | Previously, we walked through a given deref_node's copies and, after lowering the copy away, removed it from both the source and destination copy sets. This commit changes this to only remove it from the other node's copy set (not the one we're lowering). At the end of the loop, we just throw away the copy set for the node we're lowering since that node no longer has any copies. This has two advantages: 1) It's more efficient because we're doing potentially half as many set search operations. 2) It now properly handles copies from a node to itself. Perviously, it would delete the copy from the set when processing the destinatioon and then assert-fail when we couldn't find it for the source. Cc: "11.0" <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92588 Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir/validate: Allow subroutine types for the tails of derefsJason Ekstrand2015-11-121-2/+6
| | | | | | | | | | The shader-subroutine code creates uniforms of type SUBROUTINE for subroutines that are then read as integers in the backends. If we ever want to do any optimizations on these, we'll need to come up with a better plan where they are actual scalars or something, but this works for now. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92859 Reviewed-by: Connor Abbott <[email protected]>
* mesa: Replace gl_extensions::EXT_texture3D with ::dummy_trueNanley Chery2015-11-122-2/+1
| | | | | | | | | | Mesa unconditionally sets this driver flag to true in _mesa_init_extensions(). There is therefore no need for the driver to communicate support for this extension. Replace the driver capability flag with ::dummy_true. Signed-off-by: Nanley Chery <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* glsl: add gl_HelperInvocation system valueIlia Mirkin2015-11-122-0/+4
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Correctly handle vector extract on function parameterJordan Justen2015-11-121-2/+2
| | | | | | | | | | | | | | This commit accidentally used a '==' when '=' was intended. commit 96b22fb080894ba1840af2372f28a46cc0f40c76 Author: Kristian Høgsberg Kristensen <[email protected]> Date: Wed Nov 4 14:58:54 2015 -0800 glsl: Use array deref for access to vector components Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: set matrix_stride for non matrices with atomic counter buffersTapani Pälli2015-11-121-0/+2
| | | | | | | | | | | | | | | | | | Patch sets matrix_stride as 0 for non matrix uniforms that are in a atomic counter buffer. Matrix stride calculation for actual matrix uniforms is done during link_assign_uniform_locations. From ARB_program_interface_query specification: GL_MATRIX_STRIDE: "For active variables not declared as a matrix or array of matrices, zero is written to <params>. For active variables not backed by a buffer object, -1 is written to <params>, regardless of the variable type." Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Marta Lofstedt <[email protected]>
* glsl: do not lose precision information when packing varyingsTapani Pälli2015-11-121-0/+1
| | | | | | | | This information will be used by cross stage validation of varyings for pipeline objects. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: Add precision information to ir_variableIago Toral Quiroga2015-11-124-24/+303
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We will need this later on when we implement proper support for precision qualifiers in the drivers and also to do link time checks for uniforms as indicated by the spec. This patch also adds compile-time checks for variables without precision information (currently, Mesa only checks that a default precision is set for floats in fragment shaders). As indicated by Ian, the addition of the precision information to ir_variable has been done using a bitfield and pahole to identify an available hole so that memory requirements for ir_variable stay the same. v2 (Ian): - Avoid if-ladders by defining arrays of supported sampler names and indexing into them with type->sampler_array + 2 * type->sampler_shadow - Make the code that selects the precision qualifier to use an utility function - Fix a typo v3 (Tapani): - rebased - squashed in "Precision qualifiers are not allowed on structs" - fixed select_gles_precision for sampler arrays - fixed precision_qualifier_allowed for arrays of structs v4 (Tapani): - add atomic_uint handling - do not allow precision qualifier on images (issues reported by Marta) v5 (Tapani): - support precision qualifier on image types v6 (Tapani): - set precision qualifier on interface block members Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: Move the definition of precision_qualifier_allowedIago Toral Quiroga2015-11-121-36/+35
| | | | | | | We will need this to build later patches Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: Add user-defined default precision qualifiers to the symbol tableIago Toral Quiroga2015-11-121-19/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Notice that the spec requires that a default precision has been set for every type used by a shader that can use a precision qualifier and does not have a predefined precision, however, at the moment, Mesa only checks this for floats in the fragment shader. This is probably because the GLSL ES 1.0 specs mentions this case specifically, but GLSL ES 3.0 clarifies that the same applies to other types: "The fragment language has no default precision qualifier for floating point types. Hence for float, floating point vector and matrix variable declarations, either the declaration must include a precision qualifier or the default float precision must have been previously declared. Similarly, there is no default precision qualifier for the following sampler types in either the vertex or fragment language: sampler3D; samplerCubeShadow; sampler2DShadow; sampler2DArray; sampler2DArrayShadow; isampler2D; isampler3D; isamplerCube; isampler2DArray; usampler2D; usampler3D; usamplerCube; usampler2DArray;" we will fix this in a later patch. Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: Add default precision qualifiers to the symbol tableIago Toral Quiroga2015-11-121-0/+12
| | | | | | | | | | | | | | | | The GLSL ES spec specifies default precision qualifiers for certain types, so populate the symbol table with these. Notice that the desktop GLSL spec also indicates defaults for some types but this is not really useful since precision qualifiers are completely ignored in desktop GLSL. v2: simplify and add samplerExternalOES, specified by OES_EGL_image_external (Tapani) v3: add atomic_uint (reported missing by Marta) Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Add API to put default precision qualifiers in the symbol tableIago Toral Quiroga2015-11-122-0/+26
| | | | | | | | These have scoping rules that match the ones defined for other things such as variables, so we want them in the symbol table. Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: add helper to check for enhanced layouts supportTimothy Arceri2015-11-121-0/+5
| | | | Reviewed-by: Emil Velikov <[email protected]>
* mesa: add ARB_enhanced_layoutsTimothy Arceri2015-11-123-0/+4
| | | | Reviewed-by: Emil Velikov <[email protected]>
* nir/nir_opt_peephole_ffma: Move this lowering pass to the i965 driverEduardo Lima Mitev2015-11-103-270/+0
| | | | | | | | | Because the next patch will add an optimization that is specific to i965, we want to move this loweing pass to that driver altogether. This is safe because i965 is the only consumer. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: Use array deref for access to vector componentsKristian Høgsberg Kristensen2015-11-1010-68/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We've assumed that we could lower per-component vector access from vec[i] = scalar to vec = ir_triop_vector_insert(vec, scalar, i) but with SSBOs (and compute shader SLM and tesselation outputs) this is no longer valid. If a vector is "externally visible", multiple threads can write independent components simultaneously. With lowering to ir_triop_vector_insert, each thread read the entire vector, changes one component, then writes out the entire vector. This is racy. Instead of generating a ir_binop_vector_extract when we see v[i], we generate ir_dereference_array. We then add a lowering pass to lower the ir_dereference_array to ir_binop_vector_extract for rvalues and for to vector_insert for lvalues in a separate lowering pass. The resulting IR is the same as before, but we now have a window between ast->ir conversion and the lowering pass where v[i] appears in the IR as an array deref. This lets us run lowering passes that lower the vector access to I/O (eg for SSBO load/store) before we lower the per-component access to full vector writes. Reviewed-by: Jordan Justen <[email protected]> Signed-off-by: Kristian Høgsberg Kristensen <[email protected]>
* glsl: Lower UBO and SSBO access in glsl linkerKristian Høgsberg Kristensen2015-11-101-0/+8
| | | | | | | | | | | All GLSL IR consumers run this lowering pass so we can move it to the linker. This moves the pass up quite a bit, but that's the point: it needs to run before we throw away information about per-component vector access. Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Signed-off-by: Kristian Høgsberg Kristensen <[email protected]>
* glsl: Drop exec_list argument to lower_ubo_referenceKristian Høgsberg Kristensen2015-11-102-3/+3
| | | | | | | | | | | We always pass in shader->ir and we already pass in the shader, so just drop the exec_list. Most passes either take just a exec_list or a shader, so this seems more consistent. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Signed-off-by: Kristian Høgsberg Kristensen <[email protected]>
* nir/glsl: switch to using the builderConnor Abbott2015-11-101-441/+259
| | | | | | | v2: use nir_bulder_cf_insert (Ken) Signed-off-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/glsl: make emit() take nir_ssa_def * sourcesConnor Abbott2015-11-101-18/+18
| | | | | | | Again, this matches what the builder will have to do. Signed-off-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>