aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: cleanup, remove duplicate assignmentTapani Pälli2013-11-171-1/+0
| | | | | Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Apply the transformation "1/rsq(x) == sqrt(x)" in opt_algebraic.Eric Anholt2013-11-151-3/+4
| | | | | | | | | | | | | The comment was stale, because the lowering in question wasn't happening in lower_instructions.cpp. Presumably if the lowering ever moves there, we can plumb the lowering mask through to opt_algebraic. total instructions in shared programs: 1618696 -> 1616810 (-0.12%) instructions in affected programs: 243018 -> 241132 (-0.78%) GAINED: 0 LOST: 0 Reviewed-by: Jordan Justen <[email protected]>
* glsl: Apply the transformation "(a ^^ a) -> false" in opt_algebraic.Eric Anholt2013-11-151-1/+3
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl: Apply the transformation "(a && a) -> a" in opt_algebraic.Eric Anholt2013-11-151-1/+3
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl: Apply the transformation "(a || a) -> a" in opt_algebraic.Eric Anholt2013-11-151-1/+3
| | | | | | | | | | | total instructions in shared programs: 1732385 -> 1732373 (-0.00%) instructions in affected programs: 416 -> 404 (-2.88%) GAINED: 0 LOST: 0 (That's 4 already-short fragment shaders in dota2) Reviewed-by: Jordan Justen <[email protected]>
* glsl: Move the CSE equality functions to the ir class.Eric Anholt2013-11-154-179/+222
| | | | | | | | I want to reuse them in opt_algebraic. v2: Merge in Chris Forbes's break fix. Reviewed-by: Jordan Justen <[email protected]>
* glsl: Rework interface block linking.Paul Berry2013-11-151-20/+251
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, when doing intrastage and interstage interface block linking, we only checked the interface type; this prevented us from catching some link errors. We now check the following additional constraints: - For intrastage linking, the presence/absence of interface names must match. - For shader ins/outs, the interface names themselves must match when doing intrastage linking (note: it's not clear from the spec whether this is necessary, but Mesa's implementation currently relies on it). - Array vs. nonarray must be consistent, taking into account the special rules for vertex-geometry linkage. - Array sizes must be consistent (exception: during intrastage linking, an unsized array matches a sized array). Note: validate_interstage_interface_blocks currently handles both uniforms and in/out variables. As a result, if all three shader types are present (VS, GS, and FS), and a uniform interface block is mentioned in the VS and FS but not the GS, it won't be validated. I plan to address this in later patches. Fixes the following piglit tests in spec/glsl-1.50/linker: - interface-blocks-vs-fs-array-size-mismatch - interface-vs-array-to-fs-unnamed - interface-vs-unnamed-to-fs-array - intrastage-interface-unnamed-array v2: Simplify logic in intrastage_match() for handling array sizes. Make extra_array_level const. Use an unnamed temporary interface_block_definition in validate_interstage_interface_blocks()'s first call to definitions->store(). Cc: "10.0" <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: fix missing breaks in equals(ir_texture,..)Chris Forbes2013-11-101-0/+2
| | | | | | Signed-off-by: Chris Forbes <[email protected]> Cc: "10.0" <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Linker support for ARB_shader_atomic_counters.Francisco Jerez2013-11-074-1/+306
| | | | | | | | | | | | | | | v2: Add comments on the purpose of the auxiliary data structures. Check for atomic counter overlaps. Use the contains_atomic() convenience method. Add static assert with the number of expected shader stages. v3: Don't resize atomic arrays. v4: Add comment on the reason why we don't resize atomic counter arrays. Use 'strcmp(...) == 0' instead of '!strcmp(...)'. v5 (idr): Don't use STL in the linker. Signed-off-by: Francisco Jerez <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Implement parser support for atomic counters.Francisco Jerez2013-11-076-6/+103
| | | | | | | | | | | | | | | | v2: Mark atomic counters as read-only variables. Move offset overlap code to the linker. Use the contains_atomic() convenience method. v3: Use pointer to integer instead of non-const reference. Add comment so we remember to add a spec quotation from the next GLSL release once the issue of atomic counter aggregation within structures is clarified. v4 (idr): Don't use std::map because it's overkill. Add an assertion that ctx->Const.MaxAtomicBufferBindings <= MAX_COMBINED_ATOMIC_BUFFERS. Signed-off-by: Francisco Jerez <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Enable dFdx, dFdy, and fwidth by default in GLSL ES 3.00.Kenneth Graunke2013-11-071-1/+2
| | | | | | | | | | | | | | | Previously, we only exposed them in desktop GL or with: #extension GL_OES_standard_derivatives : enable GLSL ES 3.00 includes these without an extension, so we need to expose them by default. Note that the above #extension line results in an error or desktop GL, so we don't need to worry about this. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Don't generate misleading debug names when packing gs inputs.Paul Berry2013-11-041-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | Previously, when packing geometry shader input varyings like this: in float foo[3]; in float bar[3]; lower_packed_varyings would declare a packed varying like this: (declare (shader_in flat) (array ivec4 3) packed:foo[0],bar[0]) That's confusing, since the packed varying acutally stores all three values of foo and all three values of bar. This patch causes it to generate the more sensible declaration: (declare (shader_in flat) (array ivec4 3) packed:foo,bar) Note that there should be no functional change for users of geometry shaders, since the packed name is only used for generating debug output. But this should reduce confusion when using INTEL_DEBUG=gs. Reviewed-by: Eric Anholt <[email protected]>
* glsl: Add new builtins required by GL_ARB_sample_shadingAnuj Phogat2013-11-011-0/+18
| | | | | | | | | | | | | | | | New builtins added by GL_ARB_sample_shading: in vec2 gl_SamplePosition in int gl_SampleID in int gl_NumSamples out int gl_SampleMask[] V2: - Use SWIZZLE_XXXX for STATE_NUM_SAMPLES. - Use "result.samplemask" in arb_output_attrib_string. - Add comment to explain the size of gl_SampleMask[] array. - Make gl_SampleID and gl_SamplePosition system values. Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Add infrastructure for GL_ARB_sample_shadingAnuj Phogat2013-11-014-0/+7
| | | | | | | | | | | This patch implements the common support code required for the GL_ARB_sample_shading extension. V2: Move GL_ARB_sample_shading to ARB extension list. Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Ken Graunke <[email protected]>
* glsl: Add a CSE pass.Eric Anholt2013-11-015-0/+608
| | | | | | | | | | | | | | | | | | | | | | | | This only operates on constant/uniform values for now, because otherwise I'd have to deal with killing my available CSE entries when assignments happen, and getting even this working in the tree ir was painful enough. As is, it has the following effect in shader-db: total instructions in shared programs: 1524077 -> 1521964 (-0.14%) instructions in affected programs: 50629 -> 48516 (-4.17%) GAINED: 0 LOST: 0 And, for tropics, that accounts for most of the effect, the FPS improvement is 11.67% +/- 0.72% (n=3). v2: Use read_only field of the variable, manually check the lod_info union members, use get_num_operands(), rename cse_operands_visitor to is_cse_candidate_visitor, move all is-a-candidate logic to that function, and call it before checking for CSE on a given rvalue, more comments, use private keyword. Reviewed-by: Paul Berry <[email protected]>
* glsl: fix MSVC int->bool conversion warningBrian Paul2013-10-311-1/+1
|
* glsl: Move layout(location) checks to AST-to-HIR conversionIan Romanick2013-10-303-22/+43
| | | | | | | | | | | | | This will simplify the addition of layout(location) qualifiers for separate shader objects. This was validated with new piglit tests arb_explicit_attrib_location/1.30/compiler/not-enabled-01.vert and arb_explicit_attrib_location/1.30/compiler/not-enabled-02.vert. v2: Refactor error checking to check_explicit_attrib_location_allowed and eliminate the gotos. Suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Slightly restructure error generation in validate_explicit_locationIan Romanick2013-10-301-11/+11
| | | | | | | | | | | | | Use mode_string to get the name of the variable mode. Slightly change the control flow. Both of these changes make it easier to support separate shader object location layouts. The format of the message changed because mode_string can return a string like "shader output". This would result in an awkward message like "vertex shader shader output..." Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Make mode_string function globally availableIan Romanick2013-10-303-23/+46
| | | | | | | | | | | | | | | | | | I made this a function (instead of a method of ir_variable) because it made the change set smaller, and I expect that there will be an overload that takes an ir_var_mode enum. Having both functions used the same way seemed better. v2: Add missing case for ir_var_system_value. v3: Change the ir_var_mode_count case to just break. Move the assertion and the return outside the switch-statment. In the unlikely event that var->mode is an invalid value other than ir_var_mode_count, the assertion will still fire, and in release builds we won't wind up returning a garbage pointer. Suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Eliminate the global check in validate_explicit_locationIan Romanick2013-10-301-3/+2
| | | | | | | | | Since the separation of ir_var_function_in and ir_var_shader_in (similar for out), this check is no longer necessary. Previously, global_scope was the only way to tell which was which. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Extract explicit location code from apply_type_qualifier_to_variableIan Romanick2013-10-301-75/+84
| | | | | | | | | | | | Future patches will add some extra code to this path, and some of that code will want to exit from the explicit location code early. v2: Change a geometry shader "break" to a "return" so that try to apply a bogus geometry shader location qualifier (which could cause cascading errors). Suggested by Paul. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: fix crash introduced by the previous commitMarek Olšák2013-10-301-1/+1
|
* glsl: break the gl_FragData array into separate gl_FragData[i] variablesMarek Olšák2013-10-291-33/+134
| | | | | | | | | | | | | | | | This avoids a defect in lower_output_reads. The problem is lower_output_reads treats the gl_FragData array as a single variable. It first redirects all output writes to a temporary variable (array) and then writes the whole temporary variable to the output, generating assignments to all elements of gl_FragData. BTW this pass can be modified to lower all arrays, not just inputs and outputs. The question is whether it is worth it. Reviewed-by: Paul Berry <[email protected]> v2: addressed Paul Berry's comments
* glsl: Fix the function inlining pass to deal with general opaque arguments.Francisco Jerez2013-10-291-33/+33
| | | | | | | Almost a trivial change, it boils down to renaming a few identifiers so their names still make sense for opaque types other than sampler. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add built-in functions and constants required for ↵Francisco Jerez2013-10-295-0/+89
| | | | | | | | ARB_shader_atomic_counters. v2: Represent atomics as GLSL intrinsics. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Basic support for built-in intrinsics.Francisco Jerez2013-10-294-11/+64
| | | | | | | | | | | | | | | | | Fix the linker to deal with intrinsic functions which are undefined all the way down to the driver back-end, and introduce intrinsic definition helpers in the built-in generator. We still need to figure out what kind of interface we want for drivers to communicate to the GLSL front-end which of the supported intrinsics should use a default GLSL implementation and which should use a hardware-specific override. As there's no default GLSL implementation for atomic ops, this seems like something we can worry about later on. Reviewed-by: Ian Romanick <[email protected]> v2: Define local helper function to generate ir_call nodes in the builtin generator.
* glsl: Add type predicate to check whether a type contains any opaque types.Francisco Jerez2013-10-293-0/+27
| | | | | | | | | | | And use it to forbid comparisons of opaque operands. According to the GL 4.2 specification: > Except for array indexing, structure member selection, and > parentheses, opaque variables are not allowed to be operands in > expressions. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add new atomic_uint built-in GLSL type.Francisco Jerez2013-10-2910-1/+49
| | | | | | | | | v2: Fix GLSL version in which the type became available. Add contains_atomic() convenience method. Split off atomic counter comparison error checking to a separate patch that will handle all opaque types. Include new ir_variable fields for atomic types. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add extension enables for ARB_shader_atomic_counters.Francisco Jerez2013-10-292-0/+3
| | | | | Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: Add support for ARB_shader_atomic_counters.Francisco Jerez2013-10-292-0/+8
| | | | | | | | | | | | | | | This patch implements the common support code required for the ARB_shader_atomic_counters extension. It defines the necessary data structures for tracking atomic counter buffer objects (from now on "ABOs") associated with some specific context or shader program, it implements support for binding buffers to an ABO binding point and querying the existing atomic counters and buffers declared by GLSL shaders. v2: Fix extension checks. Drop unused MAX_ATOMIC_BUFFERS constant. Acked-by: Paul Berry <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* ralloc: Hook up C++ destructors to ralloc when necessary.Francisco Jerez2013-10-291-0/+14
| | | | | | | | | | | | | This patch makes sure that class destructors are called as they should be when a C++ object allocated by ralloc is released. Based on a previous patch by Kenneth Graunke, but it doesn't exhibit the ~0.8% performance regression in shader compilation times because we now use the HAS_TRIVIAL_DESTRUCTOR() macro to detect the typical case where the indirect function call can be avoided because the object's destructor doesn't need to do anything. Reviewed-by: Ian Romanick <[email protected]>
* glsl: Generalize MSVC fix for strcasecmp().Paul Berry2013-10-291-7/+1
| | | | | | | | This will let us use strcasecmp() from anywhere inside Mesa without having to worry about the fact that it doesn't exist in MSVC. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Drop no-op shifts involving 0.Eric Anholt2013-10-281-0/+10
| | | | | | | | | | | | I noticed this in a shader in Unigine Heaven that was spilling. While it doesn't really reduce register pressure, it shaves a few instructions anyway (7955 -> 7882). v2: Fix turning "0 >> x" into "x" instead of "0" (caught by Erik Faye-Lund). Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Use ir_builder more in opt_algebraic.Eric Anholt2013-10-281-30/+10
| | | | | | | | | While ir_builder is slightly less efficient, we're only increasing the work when there's actual optimization being done, and it's way more readable code. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Move common code out of opt_algebraic's handle_expression().Eric Anholt2013-10-281-78/+39
| | | | | | | | | | Matt and I had each screwed up these common required patterns recently, in ways that wouldn't have been noticed for a long time if not for code review. Just enforce it in the caller so that we don't rely on code review catching these bugs. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add check for unsized arrays to glsl typesTimothy Arceri2013-10-287-26/+30
| | | | | | | | | | | | | | | | | | | | The main purpose of this patch is to increase readability of the array code by introducing is_unsized_array() to glsl_types. Some redundent is_array() checks are also removed, and small number of other related clean ups. The introduction of is_unsized_array() should also make the ARB_arrays_of_arrays code simpler and more readable when it arrives. V2: Also replace code that checks for unsized arrays directly with the length variable Signed-off-by: Timothy Arceri <[email protected]> v3 (Paul Berry <[email protected]>): clean up formatting. Separate whitespace cleanups to their own patch. Reviewed-by: Paul Berry <[email protected]>
* glsl: whitespace cleanups.Timothy Arceri2013-10-281-3/+0
| | | | | | | | | Signed-off-by: Timothy Arceri <[email protected]> v2 (Paul Berry <[email protected]>): Separate from "glsl: Add check for unsized arrays to glsl types". Reviewed-by: Paul Berry <[email protected]>
* glsl: Fix commentTimothy Arceri2013-10-281-1/+1
| | | | | Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Paul Berry <[email protected]>
* glsl: Move error message inside validation check reducing duplicate message ↵Timothy Arceri2013-10-271-13/+14
| | | | | | | | | handling v2 (Paul Berry <[email protected]): Fix precedence error in call to _mesa_glsl_error(). Reviewed-by: Paul Berry <[email protected]>
* glsl: add signatures for textureGatherOffsets()Chris Forbes2013-10-261-0/+30
| | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: add support for texture functions with offset arraysChris Forbes2013-10-261-0/+9
| | | | | | | This is needed for textureGatherOffsets() Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add new textureGather[Offset]() overloads for shadow samplersChris Forbes2013-10-261-0/+10
| | | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: Add support for separate reference Z for shadow samplersChris Forbes2013-10-261-5/+15
| | | | | | | | | | ARB_gpu_shader5's textureGather*() functions which take shadow samplers have a separate `refz` parameter rather than adding it to the coordinate. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: relax const offset requirement for textureGatherOffsetChris Forbes2013-10-261-20/+41
| | | | | | | | | | Prior to ARB_gpu_shader5 / GLSL 4.0, the offset is required to be a constant expression. With that extension, it is relaxed to be an arbitrary expression. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add ARB_gpu_shader5 textureGatherOffset signaturesChris Forbes2013-10-261-0/+16
| | | | | | | | - gsampler2DRect - optional `comp` parameter Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Optimize (not A) and (not B) into not (A or B).Matt Turner2013-10-251-0/+9
| | | | | | No shader-db changes, but seems like a good idea. Reviewed-by: Eric Anholt <[email protected]>
* glsl: Optimize (not A) or (not B) into not (A and B).Matt Turner2013-10-251-0/+12
| | | | | | | | A few Serious Sam 3 shaders affected: instructions in affected programs: 4384 -> 4344 (-0.91%) Reviewed-by: Eric Anholt <[email protected]>
* glsl: When disabling gl_PerVertex variables, check that mode matches.Paul Berry2013-10-241-1/+2
| | | | | | | | | | | | | | | | | | | In commit 1b4a737 (glsl: Support redeclaration of VS and GS gl_PerVertex output), I added code to ensure that when an unnamed gl_PerVertex interface block is redeclared, any ir_variables that weren't included in the redeclaration are removed from the IR (and the symbol table). This ensures that only those variables that were explicitly redeclared may be used. However, when I wrote this code, I neglected to match the variable mode when finding variables to remove. This meant that redeclaring a built-in output block might cause the built-in input gl_in to be accidentally removed. Fixes piglit test gs-redeclares-pervertex-out-only. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Remove unused gl_PerVertex interface blocks.Paul Berry2013-10-241-0/+90
| | | | | | | | | | | | | | | | The GLSL 4.10 rules for redeclaration of built-in interface blocks (which we've chosen to regard as clarifications of GLSL 1.50) only require gl_PerVertex blocks to match in shaders that actually use those blocks. The easiest way to implement this is to detect situations where a compiled shader doesn't refer to any elements of gl_PerVertex, and remove all the associated ir_variables from the shader at the end of ast-to-ir conversion. Fixes piglit tests linker/interstage-{pervertex,pervertex-in,pervertex-out}-redeclaration-unneeded. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Call check_builtin_array_max_size when redeclaring gl_in.Paul Berry2013-10-241-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | Normally when a built-in array (such as gl_ClipDistance) is redeclared, we call get_variable_being_redeclared() to do the redeclaration, and it in turn calls check_builtin_array_max_size() to make sure that the redeclared array size isn't too large. However when a built-in array is redeclared as part of redeclaring gl_in, we don't call get_variable_being_redeclared() (since the individual built-ins aren't each represented by their own ir_variable anymore). So we need to add an explicit call to check_builtin_array_max_size() to make sure the new array size isn't too large. Note: at the moment this is redundant with a test that's done at link time, so there's no change to piglit results. But the patch that follows will prevent link errors from being reported if gl_PerVertex isn't used, so in order to prevent that patch from causing regressions, we need to add the compile check now. Besides, it's nicer to report this error at compile time anyhow. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>