summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: enable conservative depth, ssbo based on GLSL versionIlia Mirkin2015-07-271-2/+3
| | | | | | | | Add in missed version checks in the GLSL parser Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: recognize ARB_shading_language_420pack to be enabled with 4.20+Ilia Mirkin2015-07-242-9/+14
| | | | | | | | | The 420pack extension enables various GLSL rules that need to be applied to any GLSL 4.20+ shader even if the extension is not explicitly enabled. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* glsl/glcpp: fix SIGSEGV when checking error condition for macro redefinitionSamuel Iglesias Gonsalvez2015-07-241-2/+2
| | | | | | | | | | | | | | | Commit a6e9cd14c does not take into account than node_{a,b}->next could be NULL in some circumstances, such as in a shader containing this code: #define A 1 /* comment */ #define A 1 /* comment */ This patch fixes the segmentation fault for cases like that. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91290 Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Anuj Phogat <[email protected]> Cc: [email protected]
* i965: add support for ARB_shader_subroutineDave Airlie2015-07-242-2/+3
| | | | | | | | This just adds some missing pieces to nir/i965, it is lightly tested on my Haswell. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: add uniform and program resource support (v2)Dave Airlie2015-07-233-7/+286
| | | | | | | | | | | | | | | | | | | This adds linker support for subroutine uniforms, they have some subtle differences from real uniforms, we also hide them and they are given internal uniform names. This also adds the subroutine locations and subroutine uniforms to the program resource tracking for later use. v1.1: drop is_subroutine_def v2: handle explicit location properly, ARB_explicit_location has a lot of language for subroutine shaders. Calculate a link time the number of compatible subroutines for a uniform, to make program resource easier later. Acked-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/ir: add subroutine lowering pass (v2.3)Dave Airlie2015-07-234-0/+113
| | | | | | | | | | | | | | This lowers the enhanced ir_call using the lookaside table of subroutines into an if ladder. This initially was done at the AST level but it caused some ordering issues so a separate pass was required. v2: clone return value derefs. v2.1: update for subroutine->int convert. v2.2: add a clone for the array index Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: add ast/parser support for subroutine parsing storage (v3.2)Dave Airlie2015-07-239-116/+326
| | | | | | | | | | | | | | | | | | | | | | | | | | This is the guts of the GLSL parser and AST support for shader subroutines. The code creates a subroutine type in the parser, and uses that there to validate the identifiers. The parser also distinguishes between subroutine types/function prototypes /uniforms and subroutine defintions for functions. Then in the AST conversion it recreates the types, and stores the subroutine definition info or subroutine info into the ir_function along with a side lookup table in the parser state. It also converts subroutine calls into the enhanced ir_call. v2: move to handling method calls in function handling not in field selection. v3: merge Chris's previous parser patches in here, to make it clearer what's changed in one place. v3.1: add more documentation, drop unused include v3.2: drop is_subroutine_def Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/ir: allow ir_call to handle subroutine callingDave Airlie2015-07-231-1/+20
| | | | | | | | | This adds a ir_variable which contains the subroutine uniform and an array rvalue for the deref of that uniform, these are stored in the ir_call and lowered later. Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/ir: add subroutine information storage to ir_function (v1.1)Dave Airlie2015-07-234-1/+26
| | | | | | | | | | | We need to store two sets of info into the ir_function, if this is a function definition with a subroutine list (subroutine_def) or if it a subroutine prototype. v1.1: add some more documentation. Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: don't eliminate subroutine types.Dave Airlie2015-07-231-0/+3
| | | | | | | | This stops dead code from removing subroutines types, we need these for the queries to work properly. Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/types: add new subroutine type (v3.2)Dave Airlie2015-07-2312-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | This type will be used to store the name of subroutine types as in subroutine void myfunc(void); will store myfunc into a subroutine type. This is required to the parser can identify a subroutine type in a uniform decleration as a valid type, and also for looking up the type later. Also add contains_subroutine method. v2: handle subroutine to int comparisons, needed for lowering pass. v3: do subroutine to int with it's own IR operation to avoid hacking on asserts (Kayden) v3.1: fix warnings in this patch, fix nir, fix tgsi v3.2: fixup tests Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]> tests: fix warnings
* glsl: Make `subroutine` a reserved keywordChris Forbes2015-07-231-1/+1
| | | | | | | Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Add extension plumbing and define for ARB_shader_subroutineChris Forbes2015-07-234-0/+7
| | | | | | | Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/tests: fix varying_test since tess changes.Dave Airlie2015-07-231-1/+1
| | | | | | | This fixes make check since the tess changes. Tested-by: Michel Dänzer <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: use separate varying slots for patch varyingsMarek Olšák2015-07-233-11/+44
| | | | | | | The idea is to allow 32 normal varyings and 32 patch varyings, a total of 64. Previously, only a total of 32 was allowed. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: fix locations of 2-dimensional varyings without varying packing (v2)Marek Olšák2015-07-231-9/+28
| | | | | | v2: renamed producer/consumer_type -> producer/consumer_stage Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: don't demote tess control shader outputsMarek Olšák2015-07-231-1/+5
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: disable varying packing between tessellation shadersMarek Olšák2015-07-231-8/+21
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: allow indexing of gl_out with a non-const if length isn't knownMarek Olšák2015-07-231-0/+10
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: allow redeclaration of TCS gl_out[]Chris Forbes2015-07-231-4/+16
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: validate restrictions on use of barrier()Chris Forbes2015-07-231-0/+99
| | | | | | | | | | With the exception of always-taken switch cases (which are indistinguishable from straight line code in our IR), this disallows use of the builtin barrier() function in all the places it may not appear. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: allow barrier() in tessellation control shadersMarek Olšák2015-07-231-2/+2
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: analyze TES usage of gl_ClipDistanceChris Forbes2015-07-231-0/+19
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: push vertex count determination down one levelChris Forbes2015-07-233-17/+11
| | | | | | | We have the prog here, so we don't need the caller to work this out for us. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: pass shader stage to lower_output_reads and handle tess controlIlia Mirkin2015-07-232-5/+10
| | | | | | | | | | | | | Tessellation control outputs can be read in directly without first having been written. Accessing these will require some special logic anyways, so just let them through. V2: Never lower tess control output reads, whether patch or not -- both can be read back by other threads. Signed-off-by: Ilia Mirkin <[email protected]> Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: properly size unsized arrays in tess stagesChris Forbes2015-07-231-2/+47
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: restrict indexing for writes to TCS outputs to gl_InvocationIDChris Forbes2015-07-231-11/+58
| | | | | | Marek: handle ir_swizzle Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add builtin constants for ARB_tessellation_shaderChris Forbes2015-07-233-4/+72
| | | | | | Limits from other extensions added by Marek. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: allow nonconst indexing of arrays where we can work out an implicit sizeChris Forbes2015-07-231-1/+36
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: relax unsized input/output block arrays for TCS/TESChris Forbes2015-07-231-7/+30
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: add the tessellation extension to the list for the "layout" qualifierMarek Olšák2015-07-231-1/+2
| | | | | | | | | | | | | | | | This is technically not needed, but it makes the compiler return a better error message if tessellation is used with GLSL < 1.50. Instead of: error: syntax error, unexpected NEW_IDENTIFIER, expecting $end It returns: error: #version 150 layout qualifier `triangles' used And the tessellation spec says: OpenGL 3.2 and GLSL 1.50 are required. So it makes perfect sense. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: don't lower variable indexing on non-patch tessellation inputs/outputsMarek Olšák2015-07-233-16/+50
| | | | | | | | | | | | There is no way to lower them, because the array sizes are unknown at compile time. Based on a patch from: Fabian Bieler <[email protected]> v2: add comments Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: make stand-alone compiler work with tessellation shaders.Fabian Bieler2015-07-233-1/+12
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add "in" or "out" prefix to name when flattening interface blocksFabian Bieler2015-07-231-2/+5
| | | | | | | | This is to prevent a name conflict in tessellation shaders built-in interface blocks. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: lower gl_TessLevel* from float[n] to vecn.Fabian Bieler2015-07-236-13/+516
| | | | | | | | | | Similar to gl_ClipDistance -> gl_ClipDistanceMESA v2: - renamed is_mesa_var to lowered_builtin_array_variable - moved LowerTessLevel into gl_constants - cosmetic changes in lower_tess_level.cpp Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: make lower_clip_distance work with tessellation shaders.Fabian Bieler2015-07-231-80/+105
| | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: allow linking of tessellation shaders.Chris Forbes2015-07-233-7/+294
| | | | | | | Marek: require a tess eval shader if a tess control shader is present Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: add the patch in/out qualifier (v2)Fabian Bieler2015-07-2317-18/+156
| | | | | | v2: Dropped some unrelated reordering in glsl_parser.yy as Ken suggested. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add tessellation shader defines and built-in variables.Fabian Bieler2015-07-233-2/+86
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add tessellation shader parsing support (v2)Fabian Bieler2015-07-236-48/+476
| | | | | | v2: Fixed things that Ken suggested. Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: add tessellation shader enumsFabian Bieler2015-07-231-3/+5
| | | | | | | Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: check for leading zeros in array index validationTimothy Arceri2015-07-221-0/+4
| | | | | Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir: add nir_foreach_instr_safe_reverse()Connor Abbott2015-07-171-0/+2
| | | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* nir: add nir_instr_is_first() and nir_instr_is_last() helpersConnor Abbott2015-07-171-0/+12
| | | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Connor Abbott <[email protected]>
* glsl: avoid compiler's segfault when processing operators with void argumentsRenaud Gaubert2015-07-162-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is done by returning an rvalue of type void in the ast_function_expression::hir function instead of a void expression. This produces (in the case of the ternary) an hir with a call to the void returning function and an assignment of a void variable which will be optimized out (the assignment) during the optimization pass. This fix results in having a valid subexpression in the many different cases where the subexpressions are functions whose return values are void. Thus preventing to dereference NULL in the following cases: * binary operator * unary operators * ternary operator * comparison operators (except equal and nequal operator) Equal and nequal had to be handled as a special case because instead of segfaulting on a forbidden syntax it was now accepting expressions with a void return value on either (or both) side of the expression. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85252 Signed-off-by: Renaud Gaubert <[email protected]> Reviewed-by: Gabriel Laskar <[email protected]> Reviewed-by: Samuel Iglesias Gonsalvez <[email protected]>
* glsl: Lower shader storage buffer object loads to GLSL IR instrinsicsSamuel Iglesias Gonsalvez2015-07-141-8/+65
| | | | | | | | Extend the existing lower_ubo_reference pass to also detect SSBO loads and lower them to __intrinsic_load_ssbo intrinsics. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Lower shader storage buffer object writes to GLSL IR instrinsicsSamuel Iglesias Gonsalvez2015-07-141-130/+311
| | | | | | | | Extend the existing lower_ubo_reference pass to also detect SSBO writes and lower them to __intrinsic_store_ssbo intrinsics. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: Don't do copy propagation on buffer variablesIago Toral Quiroga2015-07-141-1/+1
| | | | | | | | | | | Since the backing storage for these is shared we cannot ensure that the value won't change by writes from other threads. Normally SSBO accesses are not guaranteed to be syncronized with other threads, except when memoryBarrier is used. So, we might be able to optimize some SSBO accesses, but for now we always take the safe path and emit the SSBO access. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Don't do constant variable on buffer variablesIago Toral Quiroga2015-07-141-0/+7
| | | | | | | | | | | Since the backing storage for these is shared we cannot ensure that the value won't change by writes from other threads. Normally SSBO accesses are not guaranteed to be syncronized with other threads, except when memoryBarrier is used. So, we might be able to optimize some SSBO accesses, but for now we always take the safe path and emit the SSBO access. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Don't do constant propagation on buffer variablesIago Toral Quiroga2015-07-141-0/+8
| | | | | | | | | | | Since the backing storage for these is shared we cannot ensure that the value won't change by writes from other threads. Normally SSBO accesses are not guaranteed to be syncronized with other threads, except when memoryBarrier is used. So, we might be able to optimize some SSBO accesses, but for now we always take the safe path and emit the SSBO access. Reviewed-by: Jordan Justen <[email protected]>