aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
...
* glsl, glsl_to_tgsi: fix sampler/image constantsRhys Perry2018-08-011-2/+30
| | | | | Signed-off-by: Rhys Perry <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* glsl: allow ?: operator with images and samplers when bindless is enabledRhys Perry2018-08-011-3/+5
| | | | | Signed-off-by: Rhys Perry <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* nir/linker: Add the start of a pure-NIR linker for XFBNeil Roberts2018-07-313-0/+320
| | | | | | | | | | | | | | | | | | | | v2: ignore names on purpose, for consistency with other places where we are doing the same (Alejandro) v3: changes proposed by Timothy Arceri, implemented by Alejandro Piñeiro: * Remove redundant 'struct active_xfb_varying' * Update several comments, including spec quotes if needed * Rename struct 'active_xfb_varying_array' to 'active_xfb_varyings' * Rename variable 'array' to 'active_varyings' * Replace one if condition for an assert (<MAX_FEEDBACK_BUFFERS) * Remove BufferMode initialization (was already done) v4: simplify output pointer handling (Timothy) Signed-off-by: Neil Roberts <[email protected]> Signed-off-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: Add members for the explicit XFB properties to nir_variableNeil Roberts2018-07-311-0/+4
| | | | | | | | These are copied from the from the corresponding values in ir_variable. The intention is to eventually use them in a pure-NIR linker. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: use only copy_propagation_elementsCaio Marcelo de Oliveira Filho2018-07-275-374/+0
| | | | | | | | Now that the elements version handles both cases, remove the non-elements version. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* glsl: teach copy_propagation_elements to deal with whole variablesCaio Marcelo de Oliveira Filho2018-07-271-29/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Keep information in acp_entry whether the entry is full or not, and use the ACP in more nodes when visiting the instructions: - add_copy: write whole variables to the ACP state (regardless the type). - visit(ir_dereference_variable *): perform the propagation here if we have a full candidate. Element-wise here doesn't apply because the mask isn't available at this point. - visit_leave(ir_assignment *): process beyond scalar and vector, as the full variables might have other types. Also import an improvement from opt_copy_propagation.cpp: if ir_call is an intrinsic, we know the variables affected, so keep going. v2: (all from Eric Anholt) Describe how acp_entry attributes are used. Don't do book-keeping to avoid adding repeated element to the dsts in write_elements(). v3: Use _mesa_set_remove_key. (Thomas Helland) Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* python: Use range() instead of xrange()Mathieu Bridon2018-07-241-1/+1
| | | | | | | | | | | | | | | | Python 2 has a range() function which returns a list, and an xrange() one which returns an iterator. Python 3 lost the function returning a list, and renamed the function returning an iterator as range(). As a result, using range() makes the scripts compatible with both Python versions 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* python: Better use iteratorsMathieu Bridon2018-07-241-1/+3
| | | | | | | | | | | | | | | | | In Python 2, iterators had a .next() method. In Python 3, instead they have a .__next__() method, which is automatically called by the next() builtin. In addition, it is better to use the iter() builtin to create an iterator, rather than calling its __iter__() method. These were also introduced in Python 2.6, so using it makes the script compatible with Python 2 and 3. Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* glsl: remove delegating constructors to allow build with C++98Caio Marcelo de Oliveira Filho2018-07-231-6/+8
| | | | | | | | | | | | | | Delegating constructors is a C++11 feature, so this was breaking when compiling with C++98. Change the copy_propagation_state() calls that used the convenience constructor to use a static member function instead. Since copy_propagation_state is expected to be heap allocated, this change is a good fit. Tested-by: Vinson Lee <[email protected]> Reviewed-by: Matt Turner <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107305
* glsl: don't let an 'if' then-branch kill copy propagation (elements) for ↵Caio Marcelo de Oliveira Filho2018-07-191-19/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | else-branch When handling 'if' in copy propagation elements, if a certain variable was killed when processing the first branch of the 'if', then the second would get any propagation from previous nodes. x = y; if (...) { z = x; // This would turn into z = y. x = 22; // x gets killed. } else { w = x; // This would NOT turn into w = y. } With the change, we let copy propagation happen independently in the two branches and only then apply the killed values for the subsequent code. One example in shader-db part of shaders/unity/8.shader_test: (assign (xyz) (var_ref col_1) (var_ref tmpvar_8) ) (if (expression bool < (swiz y (var_ref xlv_TEXCOORD0) )(constant float (0.000000)) ) ( (assign (xyz) (var_ref col_1) (expression vec3 + (var_ref tmpvar_8) ... ) ... ) ) ( (assign (xyz) (var_ref col_1) (expression vec3 lrp (var_ref col_1) ... ) ... ) )) The variable col_1 was replaced by tmpvar_8 in the then-part but not in the else-part. NIR deals well with copy propagation, so it already covered for the missing ones that this patch fixes. Reviewed-by: Eric Anholt <[email protected]>
* glsl: change opt_copy_propagation_elements data structuresCaio Marcelo de Oliveira Filho2018-07-191-117/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of keeping multiple acp_entries in lists, have a single acp_entry per variable. With this, the implementation of clone is more convenient and now fully implemented. In the previous code, clone was only partial. Before this patch, each acp_entry struct represented a write to a variable including LHS, RHS and a mask of what channels were written to. There were two main hash tables, the first (lhs_ht) stored a list of acp_entries per LHS variable, with the values available to copy for that variable; the second (rhs_ht) was a "reverse index" for the first hash table, so stored acp_entries per RHS variable. After the patch, there's a single acp_entry struct per LHS variable, it contains an array with references to the RHS variables per channel. There now is a single hash table, from LHS variable to the corresponding entry. The "reverse index" is stored in the ACP entry, in the form of a set of variables that copy from the LHS. To make the clone operation cheaper, the ACP entries are created on demand. This should not change the result of copy propagation, a later patch will take advantage of the clone operation. v2: Add note clarifying how the hashtable is destroyed. v3: (all from Eric Anholt) Add remove_unused_var_from_dsts() function for reuse. Remove from dsts as we go instead of clearing at the end. Add clarifying comment to erase(). Reviewed-by: Eric Anholt <[email protected]>
* glsl: separate copy propagation stateCaio Marcelo de Oliveira Filho2018-07-191-126/+142
| | | | | | | | | | | Separate higher level logic of visiting instructions and chosing when to store and use new copy data from the datastructure holding the copy propagation information. This will also make easier later patches that change the structure. v2: Remove empty destructor and clarify how hash tables are destroyed. Reviewed-by: Eric Anholt <[email protected]>
* glsl: remove unnecessary parenthesis from macroCaio Marcelo de Oliveira Filho2018-07-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The "__inst" will contain the name used for the variable of type "__type *". Parenthesis is not necessary as the name itself shouldn't be an expression. Fixes warning: In file included from ../../src/mesa/main/mtypes.h:49, from ../../src/intel/compiler/brw_compiler.h:30, from ../../src/intel/compiler/brw_shader.h:29, from ../../src/intel/compiler/brw_fs.h:31, from ../../src/intel/compiler/brw_fs_cse.cpp:24: ../../src/intel/compiler/brw_fs_cse.cpp: In member function ‘bool fs_visitor::opt_cse_local(bblock_t*)’: ../../src/compiler/glsl/list.h:675:12: warning: unnecessary parentheses in declaration of ‘entry’ [-Wparentheses] __type *(__inst); \ ^ ../../src/intel/compiler/brw_fs_cse.cpp:257:10: note: in expansion of macro ‘foreach_in_list_use_after’ foreach_in_list_use_after(aeb_entry, entry, &aeb) { ^~~~~~~~~~~~~~~~~~~~~~~~~ Reviewed-by: Anuj Phogat <[email protected]>
* glsl: do second pass of const propagation in loopsCaio Marcelo de Oliveira Filho2018-07-161-6/+23
| | | | | | | | | | | | | When handling loops in constant propagation, implement the "FINISHME" comment like copy propagation: perform a first pass to find values that can't be propagated, then perform a second pass with the ACP containing still valid values. Certain values are killed because the loop may run more than one iteration, so we can't copy propagate them as they would be invalid in the later iterations. Reviewed-by: Eric Anholt <[email protected]>
* glsl: don't let an 'if' then-branch kill const propagation for else-branchCaio Marcelo de Oliveira Filho2018-07-161-16/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When handling 'if' in constant propagation, if a certain variable was killed when processing the first branch of the 'if', then the second would get any propagation from previous nodes. This is similar to the change done for copy propagation code. x = 1; if (...) { z = x; // This would turn into z = 1. x = 22; // x gets killed. } else { w = x; // This would NOT turn into w = 1. } With the change, we let constant propagation happen independently in the two branches and only then apply the killed values for the subsequent code. The new code use a single hash table for keeping the kills of both branches (the branches only write to it), and it gets deleted after we use -- instead of waiting for mem_ctx to collect it. NIR deals well with constant propagation, so it already covered for the missing ones that this patch fixes. Reviewed-by: Eric Anholt <[email protected]>
* glsl: remove struct kill_entry in constant propagationCaio Marcelo de Oliveira Filho2018-07-121-26/+7
| | | | | | | | | | The only value in kill_entry is the writemask, which can be stored in the data pointer of the hash table entry. Suggested by Eric Anholt. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* glsl: slim the kill_entry struct used in const propagationCaio Marcelo de Oliveira Filho2018-07-121-8/+5
| | | | | | | | | | | | | | | | | Since 4654439fdd7 "glsl: Use hash tables for opt_constant_propagation() kill sets." uses a hash_table for storing kill_entries, so the structs can be simplified. Remove the exec_node from kill_entry since it is not used in an exec_list anymore. Remove the 'var' from kill_entry since it is now redundant with the key of the hash table. Suggested by Eric Anholt. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
* mesa: Add disk shader cache driver blob callbackJordan Justen2018-07-091-0/+8
| | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Treat sampler2DRect and sampler2DRectShadow as reserved in ES2zhaowei yuan2018-07-091-2/+2
| | | | | | | | | | "sampler2DRect" and "sampler2DRectShadow" are specified as reserved from GLSL 1.1 and GLSL ES 1.0 Signed-off-by: zhaowei yuan <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106906 Reviewed-by: Eric Anholt <[email protected]> Fixes: 34f7e761bc61 ("glsl/parser: Track built-in types using the glsl_type directly")
* nir/linker: fix msvc buildRoland Scheidegger2018-07-051-1/+1
| | | | | | | | | Empty initializer braces aren't valid c (it's a gnu extension, and it's valid in c++). Hopefully fixes appveyor / msvc build... Fixes 6677e131b806b10754adcb7cf3f427a7fcc2aa09 Reviewed-by: Timothy Arceri <[email protected]>
* nir: Fix OpAtomicCounterIDecrement for uniform atomic countersAntia Puentes2018-07-032-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From the SPIR-V 1.0 specification, section 3.32.18, "Atomic Instructions": "OpAtomicIDecrement: <skip> The instruction's result is the Original Value." However, we were implementing it, for uniform atomic counters, as a pre-decrement operation, as was the one available from GLSL. Renamed the former nir intrinsic 'atomic_counter_dec*' to 'atomic_counter_pre_dec*' for clarification purposes, as it implements a pre-decrement operation as specified for GLSL. From GLSL 4.50 spec, section 8.10, "Atomic Counter Functions": "uint atomicCounterDecrement (atomic_uint c) Atomically 1. decrements the counter for c, and 2. returns the value resulting from the decrement operation. These two steps are done atomically with respect to the atomic counter functions in this table." Added a new nir intrinsic 'atomic_counter_post_dec*' which implements a post-decrement operation as required by SPIR-V. v2: (Timothy Arceri) * Add extra spec quotes on commit message * Use "post" instead "pos" to avoid confusion with "position" Signed-off-by: Antia Puentes <[email protected]> Signed-off-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir/linker: Add a pure NIR implementation of the atomic counter linkerNeil Roberts2018-07-033-0/+286
| | | | | | | | | | | | This is mostly just a straight-forward conversion of link_assign_atomic_counter_resources to C directly using nir variables instead of GLSL IR variables. It is based on the version of link_assign_atomic_counter_resources in 6b8909f2d1906. I’m noting this here to make it easier to track changes and keep the NIR version up-to-date. Reviewed-by: Timothy Arceri <[email protected]>
* nir/linker: handle uniforms without explicit locationAlejandro Piñeiro2018-07-031-2/+62
| | | | | | | | | | | | | | | | | ARB_gl_spirv points that uniforms in general need explicit location. But there are still some cases of uniforms without location, like for example uniform atomic counters. Those doesn't have a location from the OpenGL point of view (they are identified with a binding and offset), but Mesa internally assigns it a location. Signed-off-by: Eduardo Lima <[email protected]> Signed-off-by: Alejandro Piñeiro <[email protected]> Signed-off-by: Neil Roberts <[email protected]> v2: squash with another patch, minor variable name tweak (Timothy Arceri) Reviewed-by: Timothy Arceri <[email protected]>
* compiler/glsl: refactor empty_uniform_block utilities to linker_utilAlejandro Piñeiro2018-07-035-63/+79
| | | | | | | | | | | | | | | This includes: * Move the defition of empty_uniform_block to linker_util.h * Move find_empty_block (with a rename) to linker_util.h * Refactor some code at linker.cpp to a new method at linker_util.h (link_util_update_empty_uniform_locations) So all that code could be used by the GLSL linker and the NIR linker used for ARB_gl_spirv. v2: include just "ir_uniform.h" (Timothy Arceri) Reviewed-by: Timothy Arceri <[email protected]>
* glsl/cache: save and restore ExternalSamplersUsedMarek Olšák2018-06-301-0/+2
| | | | | | | | Shaders that need special code for external samplers were broken if they were loaded from the cache. Cc: 18.1 <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: skip comparison opt when adding vars of different sizeTimothy Arceri2018-06-281-0/+6
| | | | | | | | | | | The spec allows adding scalars with a vector or matrix. In this case the opt was losing swizzle and size information. This fixes a bug with Doom (2016) shaders. Fixes: 34ec1a24d61f ("glsl: Optimize (x + y cmp 0) into (x cmp -y).") Reviewed-by: Ian Romanick <[email protected]>
* glsl: Make sure that packed varyings reflect always_active_io properly.Eric Anholt2018-06-271-2/+7
| | | | | | | | The always_active_io flag was only set according to the first variable that got packed in, so NIR io compaction would end up compacting XFB varyings that shouldn't move at that point. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: serialize data from glTransformFeedbackVaryingsTapani Pälli2018-06-261-0/+20
| | | | | | | | | | While XFB has been enabled for cache, we did not serialize enough data for the whole API to work (such as glGetProgramiv). Fixes: 6d830940f7 "Allow shader cache usage with transform feedback" Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106907 Reviewed-by: Jordan Justen <[email protected]>
* nir: Remove old-school deref chain supportJason Ekstrand2018-06-223-6/+0
| | | | | | | Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Remove deref chain support from lower_atomicsJason Ekstrand2018-06-221-144/+2
| | | | | | | Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/lower_samplers: remove legacy versionRob Clark2018-06-223-166/+0
| | | | | | | | Signed-off-by: Rob Clark <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: convert lower_samplers_as_deref to deref instructionsRob Clark2018-06-221-65/+117
| | | | | | | | | | This also removes the legacy version of lower_samplers. Signed-off-by: Rob Clark <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Use derefs in nir_lower_samplersJason Ekstrand2018-06-222-69/+88
| | | | | | | | | | | We change glsl_to_nir to provide derefs for bot textures and samplers while we're at it. This makes the lowering much easier since we only either replace sources or remove them. Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/lower_samplers: Clean up function argumentsJason Ekstrand2018-06-221-8/+8
| | | | | | | | | | This little refactor makes us stop passing stage around and puts the builder as the first parameter to some functions. Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/lower_samplers: split out _legacy version for deref chainsRob Clark2018-06-223-0/+166
| | | | | | | | | | | | | | | | | | To simplify the transition, and make things bisectable, split out a legacy copy or lower_samplers. This way the i965 and gallium drivers can independently switch over to deref instructions. Since the lower_samplers_as_deref pass is only used by gallium drivers, it can be converted in lock-step with moving the lower_deref_instrs pass, and so does not need a corresponding _legacy clone. This legacy pass will be removed in a future commit. Signed-off-by: Rob Clark <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir,spirv: Rework function callsJason Ekstrand2018-06-221-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit completely reworks function calls in NIR. Instead of having a set of variables for the parameters and return value, nir_call_instr now has simply has a number of sources which get mapped to load_param intrinsics inside the functions. It's up to the client API to build an ABI on top of that. In SPIR-V, out parameters are handled by passing the result of a deref through as an SSA value and storing to it. This virtue of this approach can be seen by how much it allows us to delete from core NIR. In particular, nir_inline_functions gets halved and goes from a fairly difficult pass to understand in detail to almost trivial. It also simplifies spirv_to_nir somewhat because NIR functions never were a good fit for SPIR-V. Unfortunately, there is no good way to do this without a mega-commit. Core NIR and SPIR-V have to be changed at the same time. This also requires changes to anv and radv because nir_inline_functions couldn't handle deref instructions before this change and can't work without them after this change. Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Support deref instructions in lower_atomicsJason Ekstrand2018-06-221-9/+112
| | | | | | | | Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/nir: Use deref instructions instead of dref chainsJason Ekstrand2018-06-221-145/+94
| | | | | | | | Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl/nir: Only claim to handle intrinsic functionsJason Ekstrand2018-06-221-23/+2
| | | | | | | | | | | | Non-intrinsic function handling has never actually been tested and probably doesn't work. Just get rid of it for now. We can always add it back in later if it's useful. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: add deref lowering sanity checkingRob Clark2018-06-223-0/+6
| | | | | | | | | | | | | This will be removed at the end of the transition, but add some tracking plus asserts to help ensure that lowering passes are called at the correct point (pre or post deref instruction lowering) as passes are converted and the point where lower_deref_instrs() is called is moved. Signed-off-by: Rob Clark <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/linker: Add nir_build_program_resource_list()Eduardo Lima Mitev2018-06-213-0/+71
| | | | | | | | | | | | | | | | | | This function is equivalent to the linker.cpp build_program_resource_list() but will extract the resources from NIR shaders instead. For now, only uniforms and program inputs are implemented. v2: move from compiler/nir to compiler/glsl (Timothy Arceri) v3: remove support for inputs, that is still WIP (spotted by Timothy Arceri) Signed-off-by: Eduardo Lima <[email protected]> Signed-off-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* compiler/link: move add_program_resource to linker_utilAlejandro Piñeiro2018-06-214-56/+90
| | | | | | | | | | So it could be used by the GLSL and NIR linker. v2: (Timothy Arceri) * Moved from compiler to compiler/glsl * Method renamed to link_util_add_program_resource Reviewed-by: Timothy Arceri <[email protected]>
* nir/linker: Set the uniform initial valuesNeil Roberts2018-06-214-0/+297
| | | | | | | | This is based on link_uniform_initializers.cpp. v2: move from compiler/nir to compiler/glsl (Timothy Arceri) Reviewed-by: Timothy Arceri <[email protected]>
* nir/linker: Add gl_nir_link_uniforms()Eduardo Lima Mitev2018-06-213-0/+504
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function will be the entry point for linking the uniforms from the nir_shader objects associated with the gl_linked_shaders of a program. This patch includes initial support for linking uniforms from NIR shaders. It is tailored for the ARB_gl_spirv needs, and it is far from complete, but it should handle most cases of uniforms, array uniforms, structs, samplers and images. There are some FIXMEs related to specific features that will be implemented in following patches, like atomic counters, UBOs and SSBOs. Also, note that ARB_gl_spirv makes mandatory explicit location for normal uniforms, so this code only handles uniforms with explicit location. But there are cases, like uniform atomic counters, that doesn't have a location from the OpenGL point of view (they have a binding), but that Mesa assign internally a location. That will be handled on following patches. A nir_linker.h file is also added. More NIR-linking related API will be added in subsequent patches and those will include stuff from Mesa, so reusing nir.h didn't seem a good idea. v2: move from compiler/nir to compiler/glsl (Timothy Arceri) v3: sets var->driver.location if the uniform was found from a previous stage (Neil Roberts). Signed-off-by: Eduardo Lima <[email protected]> Signed-off-by: Neil Roberts <[email protected] Signed-off-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* compiler/link: add linker_util.h, move linker_error/warning to itAlejandro Piñeiro2018-06-215-14/+47
| | | | | | | | | | | | Linker utilities common to the GLSL IR and NIR linker (the latter to be used for ARB_gl_spirv). We need to move it to a new header as the NIR linker doesn't need to know about ir_variable, and others, included at linker.h. v2: move from src/compiler to src/compiler/glsl (Timothy Arceri) Reviewed-by: Timothy Arceri <[email protected]>
* nir/lower_samplers: Limit assert to GLSL shader programsEduardo Lima Mitev2018-06-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | Vulkan has the concept of separate image and sampler objects in the SPIR-V code whereas GL conflates them into one. nir_lower_samplers contains an assert to verify that sampler operand is not being set on the nir instruction. However when the code comes from spirv_to_nir the sampler operand is always set. GL_arb_gl_spirv explicitly states that OpTypeSampler is not supported so it retains the GL behaviour of not being able to seperate them. Therefore the sampler will always be the same as the texture. This GL version of the lowering code ignores instr->sampler and sets instr->sampler_index to the same value as instr->texture_index. Some other places in the code (such as in nir_print) assume that once the instruction is lowered then both instr->texture and instr->sampler will be NULL, so to keep this behaviour we now set instr->sampler to NULL after ignoring it to fill in instr->sampler_index. Signed-off-by: Eduardo Lima <[email protected]> Signed-off-by: Neil Roberts <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: Add explicit_binding to nir_variableNeil Roberts2018-06-211-0/+1
| | | | | | | This is copied from the corresponding value in ir_variable. The intention is to eventually use it in a pure-NIR linker. Reviewed-by: Timothy Arceri <[email protected]>
* glsl/tests/glcpp: reinstate "error out if no tests found"Emil Velikov2018-06-211-0/+9
| | | | | | | | | | | | | | | With the recent rework of converting the shell script to a python one the check for actual tests was dropped. Bring that back, since it was explicitly added considering we had a ~2 year period, during which the tests were not run. v2: use raise Exception() over print() & return false (Dylan) Fixes: db8cd8e36771 ("glcpp/tests: Convert shell scripts to a python script") Cc: Dylan Baker <[email protected]> Signed-off-by: Emil Velikov <[email protected]>
* glsl/glcpp/tests: reinstate srcdir/abs_builddir blurbEmil Velikov2018-06-211-0/+13
| | | | | | | | | | | Bring back the "detection" of the said variables, to allow standalone execution. Fixes: db8cd8e36771 ("glcpp/tests: Convert shell scripts to a python script") Cc: Dylan Baker <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* glsl: fold glcpp-test-cr-lf.sh into glcpp-test.shEmil Velikov2018-06-212-4/+1
| | | | | | | | | | | As of recently both of these have been reworked so they invoke a python script. At the same time the latter can be executed with the combined arguments of both scripts. AKA we no longer need to have them separate. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Dylan Baker <[email protected]>