summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Fix condition to generate shader link errorAnuj Phogat2014-02-181-4/+5
| | | | | | | | | | | | | | | | | | | GL_ARB_ES2_compatibility doesn't say anything about shader linking when one of the shaders (vertex or fragment shader) is absent. So, the extension shouldn't change the behavior specified in GLSL specification. Tested the behavior on proprietary linux drivers of NVIDIA and AMD. Both of them allow linking a version 100 shader program in OpenGL context, when one of the shaders is absent. Makes following Khronos CTS tests to pass: successfulcompilevert_linkprogram.test successfulcompilefrag_linkprogram.test Cc: [email protected] Signed-off-by: Anuj Phogat <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: rename _restrict to restrict_flagBrian Paul2014-02-127-8/+8
| | | | | | | | | | | To fix MSVC compile breakage. Evidently, _restrict is an MSVC keyword, though the docs only mention __restrict (with two underscores). Note: we may want to also rename _volatile to volatile_flag to be consistent. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74900 Reviewed-by: Ian Romanick <[email protected]>
* glsl/linker: Propagate image uniform access qualifiers to the driver.Francisco Jerez2014-02-121-0/+35
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/linker: Assign image uniform indices.Francisco Jerez2014-02-121-1/+23
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/linker: Count and check image resources.Francisco Jerez2014-02-122-1/+59
| | | | | | | v2: Add comment about the reason why image variables take up space from the default uniform block. Reviewed-by: Paul Berry <[email protected]>
* glsl: Add image built-in function generator.Francisco Jerez2014-02-121-0/+251
| | | | | | | | | | | | | | | | | | Because of the combinatorial explosion of different image built-ins with different image dimensionalities and base data types, enumerating all the 242 possibilities would be annoying and a waste of .text space. Instead use a special path in the built-in builder that loops over all the known image types. v2: Generate built-ins on GLSL version 4.20 too. Rename '_has_float_data_type' to '_supports_float_data_type'. Avoid duplicating enumeration of image built-ins in create_intrinsics() and create_builtins(). v3: Use a more orthodox approach for passing image built-in generator parameters. v4: Cosmetic changes. Acked-by: Paul Berry <[email protected]>
* glsl: Add built-in constants for ARB_shader_image_load_store.Francisco Jerez2014-02-123-0/+37
| | | | | | v2: Add them on GLSL version 4.20 too. Reviewed-by: Paul Berry <[email protected]>
* glcpp: Add built-in define for ARB_shader_image_load_store.Francisco Jerez2014-02-121-0/+3
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl: Add built-in types defined by ARB_shader_image_load_store.Francisco Jerez2014-02-122-0/+104
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/ast: Generalize some sampler variable restrictions to all opaque types.Francisco Jerez2014-02-122-31/+36
| | | | | | | | | | | | No opaque types may be statically initialized in the shader, all opaque variables must be declared uniform or be part of an "in" function parameter declaration, no opaque types may be used as the return type of a function. v2: Add explicit check for opaque types in interface blocks. Check for opaque types in ir_dereference::is_lvalue(). Reviewed-by: Paul Berry <[email protected]>
* glsl/ast: Forbid declaration of image variables in structures and uniform ↵Francisco Jerez2014-02-121-0/+10
| | | | | | | | | | | | | | | | | blocks. Aggregating images inside uniform blocks is explicitly disallowed by the standard, aggregating them inside structures is not (as of GL 4.4), but there is a similar problem as with atomic counters: image uniform declarations require either a "writeonly" memory qualifier or an explicit format qualifier, which are explicitly forbidden in structure member declarations. In the resolution of Khronos bug #10903 the same wording applied to atomic counters was decided to mean that they're not allowed inside structures -- Rejecting image member declarations within structures seems the most reasonable option for now. Reviewed-by: Paul Berry <[email protected]>
* glsl/ast: Make sure that image argument qualifiers match the function prototype.Francisco Jerez2014-02-121-1/+6
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/ast: Verify that function calls don't discard image format qualifiers.Francisco Jerez2014-02-121-0/+58
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/ast: Validate and apply memory qualifiers to image variables.Francisco Jerez2014-02-121-0/+51
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/parser: Handle image built-in types.Francisco Jerez2014-02-121-0/+33
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/parser: Handle image memory qualifiers.Francisco Jerez2014-02-121-0/+83
| | | | | | v2: Make the "map" array static const. Reviewed-by: Paul Berry <[email protected]>
* glsl/parser: Handle the early_fragment_tests input layout qualifier.Francisco Jerez2014-02-123-1/+20
| | | | | | v2: Only allow the early_fragment_tests qualifier in fragment shaders. Reviewed-by: Paul Berry <[email protected]>
* glsl/lexer: Add new tokens for ARB_shader_image_load_store.Francisco Jerez2014-02-122-39/+56
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl/ast: Keep track of type qualifiers defined by ARB_shader_image_load_store.Francisco Jerez2014-02-123-3/+38
| | | | | | | | v2: Add comment next to the read_only and write_only qualifier flags. Change temporary copies of the type qualifier mask to use uint64_t too. Reviewed-by: Paul Berry <[email protected]>
* glsl: Add gl_uniform_storage fields to keep track of image uniform indices.Francisco Jerez2014-02-121-18/+23
| | | | | | v2: Promote anonymous struct into named struct. Reviewed-by: Paul Berry <[email protected]>
* glsl: Add image memory and layout qualifiers to ir_variable.Francisco Jerez2014-02-122-0/+19
| | | | | | v2: Add comment next to the read_only and write_only qualifier flags. Reviewed-by: Paul Berry <[email protected]>
* glsl: Add helper methods to glsl_type for dealing with images.Francisco Jerez2014-02-124-7/+35
| | | | | | | | | | | | Add predicates to query if a GLSL type is or contains an image. Rename sampler_coordinate_components() to coordinate_components(). v2: Use assert instead of unreachable. v3: No need to use a separate code-path for images in coordinate_components() after merging image and sampler fields in the glsl_type structure. Reviewed-by: Paul Berry <[email protected]>
* glsl: Add image type to the GLSL IR.Francisco Jerez2014-02-126-52/+68
| | | | | | | | | v2: Reuse the glsl_sampler_dim enum for images. Reuse the glsl_type::sampler_* fields instead of creating new ones specific to image types. Reuse the same constructor as for samplers adding a new 'base_type' argument. Reviewed-by: Paul Berry <[email protected]>
* glsl: Add ARB_shader_image_load_store extension enables.Francisco Jerez2014-02-122-0/+3
| | | | Reviewed-by: Paul Berry <[email protected]>
* glsl: Do not vectorize vector array dereferences.Matt Turner2014-02-111-0/+14
| | | | | | | | | | Array dereferences must have scalar indices, so we cannot vectorize them. Cc: "10.1" <[email protected]> Reported-by: Andrew Guertin <[email protected]> Tested-by: Andrew Guertin <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Add locking to builtin_builder singletonDaniel Kurtz2014-02-111-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider a multithreaded program with two contexts A and B, and the following scenario: 1. Context A calls initialize(), which allocates mem_ctx and starts building built-ins. 2. Context B calls initialize(), which sees mem_ctx != NULL and assumes everything is already set up. It returns. 3. Context B calls find(), which fails to find the built-in since it hasn't been created yet. 4. Context A finally finishes initializing the built-ins. This will break at step 3. Adding a lock ensures that subsequent callers of initialize() will wait until initialization is actually complete. Similarly, if any thread calls release while another thread is still initializing, or calling find(), the mem_ctx/shader would get free'd while from under it, leading to corruption or use-after-free crashes. Fixes sporadic failures in Piglit's glx-multithread-shader-compile. Bugzilla: https://bugs.freedesktop.org/69200 Signed-off-by: Daniel Kurtz <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: "10.1 10.0" <[email protected]>
* glsl: Optimize triop_csel with all-true or all-false.Eric Anholt2014-02-071-0/+7
| | | | Reviewed-by: Matt Turner <[email protected]>
* glsl: Optimize various cases of fma (aka MAD).Eric Anholt2014-02-071-0/+13
| | | | Reviewed-by: Matt Turner <[email protected]>
* glsl: Optimize lrp(x, x, coefficient) --> x.Eric Anholt2014-02-071-0/+2
| | | | | | | | | | | total instructions in shared programs: 1627754 -> 1624534 (-0.20%) instructions in affected programs: 45748 -> 42528 (-7.04%) GAINED: 3 LOST: 0 (serious sam, humus domino demo) Reviewed-by: Matt Turner <[email protected]>
* glsl: Optimize pow(x, 1) -> x.Eric Anholt2014-02-071-0/+4
| | | | | | | | | | | total instructions in shared programs: 1627826 -> 1627754 (-0.00%) instructions in affected programs: 6640 -> 6568 (-1.08%) GAINED: 0 LOST: 0 (HoN and savage2) Reviewed-by: Matt Turner <[email protected]>
* glsl: Optimize log(exp(x)) and exp(log(x)) into x.Eric Anholt2014-02-071-0/+36
| | | | Reviewed-by: Matt Turner <[email protected]>
* glsl: Optimize ~~x into x.Eric Anholt2014-02-071-0/+5
| | | | | | | v2: Fix pasteo of an extra abs being inserted (caught by many). Rewrite to drop the silly switch statement. Reviewed-by: Matt Turner <[email protected]> (v1)
* glsl: Don't lose precision qualifiers when encountering "centroid".Kenneth Graunke2014-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mesa fails to retain the precision qualifier when parsing: #version 300 es centroid in mediump vec2 v; Consider how the parser's type_qualifier production is applied. First, the precision_qualifier rule creates a new ast_type_qualifier: <precision: mediump> Then the storage_qualifier rule creates a second one: <flags: in> and calls merge_qualifier() to fold in any previous qualifications, returning: <flags: in, precision: mediump> Finally, the auxiliary_storage_qualifier creates one for "centroid": <flags: centroid> it then does $$ = $1 and $$.flags |= $2.flags, resulting in: <flags: centroid, in> Since precision isn't stored in the flags bitfield, it is lost. We need to instead call merge_qualifier to combine all the fields. Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reported-by: Kevin Rogovin <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: Fix null access on file read errorJuha-Pekka Heikkila2014-02-071-1/+2
| | | | | Signed-off-by: Juha-Pekka Heikkila <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: Initialize ubo_binding_mask flags to zero.Matt Turner2014-02-061-0/+1
| | | | | | | | | Missed in commit e63bb298. Caused sporadic test failures, like incorrect-in-layout-qualifier-repeated-prim.geom. Cc: "10.0" <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl/cs: Prohibit mixing of compute and non-compute shaders.Paul Berry2014-02-051-0/+7
| | | | | | | Fixes piglit test: spec/ARB_compute_shader/linker/mix_compute_and_non_compute Reviewed-by: Jordan Justen <[email protected]>
* glsl/cs: Prohibit user-defined ins/outs in compute shaders.Paul Berry2014-02-051-0/+7
| | | | Reviewed-by: Jordan Justen <[email protected]>
* mesa/cs: Handle compute shader local size during linking.Paul Berry2014-02-051-0/+64
| | | | Reviewed-by: Jordan Justen <[email protected]>
* glsl/cs: Handle compute shader local_size_{x,y,z} declaration.Paul Berry2014-02-058-36/+274
| | | | Reviewed-by: Jordan Justen <[email protected]>
* mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_COUNT constant.Paul Berry2014-02-055-0/+13
| | | | | | | | v2: Document that the 3-element array MaxComputeWorkGroupCount is indexed by dimension. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_INVOCATIONS constant.Paul Berry2014-02-052-0/+2
| | | | | | | | Reviewed-by: Matt Turner <[email protected]> v2: Use CONTEXT_INT rather than CONTEXT_ENUM. Reviewed-by: Jordan Justen <[email protected]>
* mesa/cs: Implement MAX_COMPUTE_WORK_GROUP_SIZE constant.Paul Berry2014-02-055-0/+40
| | | | | | | | v2: Document that the 3-element array MaxComputeWorkGroupSize is indexed by dimension. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl/cs: update main.cpp to use the ".comp" extension for compute shaders.Paul Berry2014-02-051-0/+2
| | | | Reviewed-by: Matt Turner <[email protected]>
* glsl/cs: Populate default values for ctx->Const.Program[MESA_SHADER_COMPUTE].Paul Berry2014-02-052-0/+8
| | | | Reviewed-by: Matt Turner <[email protected]>
* mesa/cs: Add a MESA_SHADER_COMPUTE stage and update switch statements.Paul Berry2014-02-053-0/+28
| | | | | | | | | This patch adds MESA_SHADER_COMPUTE to the gl_shader_stage enum. Also, where it is trivial to do so, it adds a compute shader case to switch statements that switch based on the type of shader. This avoids "unhandled switch case" compiler warnings. Reviewed-by: Matt Turner <[email protected]>
* glsl/cs: Change some linker loops to use MESA_SHADER_FRAGMENT as a bound.Paul Berry2014-02-051-4/+4
| | | | | | | | | Linker loops that iterate through all the stages in the pipeline need to use MESA_SHADER_FRAGMENT as a bound, so that we can add an additional MESA_SHADER_COMPUTE stage, without it being erroneously included in the pipeline. Reviewed-by: Matt Turner <[email protected]>
* mesa/cs: Add extension enable flags for ARB_compute_shader.Paul Berry2014-02-054-0/+7
| | | | Reviewed-by: Matt Turner <[email protected]>
* glsl: Fix continue statements in do-while loops.Paul Berry2014-02-041-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From the GLSL 4.40 spec, section 6.4 (Jumps): The continue jump is used only in loops. It skips the remainder of the body of the inner most loop of which it is inside. For while and do-while loops, this jump is to the next evaluation of the loop condition-expression from which the loop continues as previously defined. Previously, we incorrectly treated a "continue" statement as jumping to the top of a do-while loop. This patch fixes the problem by replicating the loop condition when converting the "continue" statement to IR. (We already do a similar thing in "for" loops, to ensure that "continue" causes the loop expression to be executed). Fixes piglit tests: - glsl-fs-continue-inside-do-while.shader_test - glsl-vs-continue-inside-do-while.shader_test - glsl-fs-continue-in-switch-in-do-while.shader_test - glsl-vs-continue-in-switch-in-do-while.shader_test Cc: [email protected] Acked-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Make condition_to_hir() callable from outside ast_iteration_statement.Paul Berry2014-02-042-7/+6
| | | | | | | | | | | | | | | | In addition to making it public, we also need to change its first argument from an ir_loop * to an exec_list *, so that it can be used to insert the condition anywhere in the IR (rather than just in the body of the loop). This will be necessary in order to make continue statements work properly in do-while loops. Cc: [email protected] Acked-by: Carl Worth <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Expand non-expr & non-swizzle scalar rvalues in vectorizing.Matt Turner2014-01-311-6/+8
|