summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: skip tree grafting for sampler and image typesNicolai Hähnle2017-05-061-0/+11
| | | | | | | v2: - use is_sampler()/is_image() instead (Samuel Pitoiset) Reviewed-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: teach lower_ubo_reference about samplers inside structuresSamuel Pitoiset2017-05-061-0/+15
| | | | | | | | | | | | | | In a situation like: (tex vec4 (record_ref (var_ref f) tex) (constant vec2 (0.000000 0.000000)) 0 1 () ) The sampler needs to be lowered, otherwise this ends up with "ir_dereference_variable @ 0x229a100 specifies undeclared variable `ubo_load_temp' @ 0x2290440" Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: link bindless layout qualifiersSamuel Pitoiset2017-05-061-0/+44
| | | | | | | | | | | | From section 4.4.6 of the ARB_bindless_texture spec: "If both bindless_sampler and bound_sampler, or bindless_image and bound_image, are declared at global scope in any compilation unit, a link- time error will be generated." Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: do not count bindless samplers/images when linking uniformsSamuel Pitoiset2017-05-061-2/+2
| | | | | | | | | | | | | From section 2.14.8 of the ARB_bindless_texture spec: "(modify second paragraph, p. 126) ... against the MAX_COMBINED_TEXTURE_IMAGE_UNITS limit. Samplers accessed using texture handles (section 3.9.X) are not counted against this limit." Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: lower bindless sampler/image packed varyingsSamuel Pitoiset2017-05-061-0/+14
| | | | | | | | v3: - rebase (and remove (sampler) ? 1 : vector_elements) Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: implement ARB_bindless_texture conversionsSamuel Pitoiset2017-05-063-10/+84
| | | | | | | | | | | | | | | | | | | | | | | | From section 5.4.1 of the ARB_bindless_texture spec: "In the following four constructors, the low 32 bits of the sampler type correspond to the .x component of the uvec2 and the high 32 bits correspond to the .y component." uvec2(any sampler type) // Converts a sampler type to a // pair of 32-bit unsigned integers any sampler type(uvec2) // Converts a pair of 32-bit unsigned integers to // a sampler type uvec2(any image type) // Converts an image type to a // pair of 32-bit unsigned integers any image type(uvec2) // Converts a pair of 32-bit unsigned integers to // an image type v4: - fix up comment style v3: - rebase (and remove (sampler) ? 1 : vector_elements) Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: allow bindless samplers/images to be used with constructorsSamuel Pitoiset2017-05-061-2/+14
| | | | | | | | | | | | | | | | | | | | | For the explicit conversions. From section 4.1.7 of the ARB_bindless_texture spec: "Samplers are represented using 64-bit integer handles, and may be converted to and from 64-bit integers using constructors." From section 4.1.X of the ARB_bindless_texture spec: "Images are represented using 64-bit integer handles, and may be converted to and from 64-bit integers using constructors." v3: - add spec comment - update the glsl error message Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> (v2) Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add is_valid_constructor() helper functionSamuel Pitoiset2017-05-061-2/+8
| | | | | | | | | This will help for the explicit conversions for sampler and image types as specified by ARB_bindless_texture. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add ARB_bindless_texture operationsSamuel Pitoiset2017-05-062-0/+26
| | | | | | | | For the explicit pack/unpack conversions. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow bindless samplers/images to be initializedSamuel Pitoiset2017-05-061-3/+14
| | | | | | | | | | | | | | | | | | | From section 4.1.7 of the ARB_bindless_texture spec: "Samplers may be declared as shader inputs and outputs, as uniform variables, as temporary variables, and as function parameters." From section 4.1.X of the ARB_bindless_texture spec: "Images may be declared as shader inputs and outputs, as uniform variables, as temporary variables, and as function parameters." v3: - add spec comment - update the glsl error message Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow bindless samplers/images to be l-valuesSamuel Pitoiset2017-05-061-0/+14
| | | | | | | | | | | | | | | | | | | From section 4.1.7 of the ARB_bindless_texture spec: "Samplers can be used as l-values, so can be assigned into and used as "out" and "inout" function parameters." From section 4.1.X of the ARB_bindless_texture spec: "Images can be used as l-values, so can be assigned into and used as "out" and "inout" function parameters." v4: - invert the logic v3: - update spec comment formatting - keep the read_only check Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add _mesa_glsl_parse_state object to is_lvalue()Samuel Pitoiset2017-05-064-7/+9
| | | | | | | | | | | | | | | Yes, this is a bit hacky but we don't really have the choice. Plain GLSL doesn't accept bindless samplers/images as l-values while it's allowed when ARB_bindless_texture is enabled. The default NULL parameter is because we can't access the _mesa_glsl_parse_state object in few places in the compiler. One is_lvalue(NULL) call is for IR validation but other checks happen elsewhere, should be safe. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: relax bindless sampler arrays indexingSamuel Pitoiset2017-05-061-1/+7
| | | | | | | | | | | | | From section 4.1.7 of the ARB_bindless_texture spec: "Samplers aggregated into arrays within a shader (using square brackets []) can be indexed with arbitrary integer expressions." v3: - update spec comment formatting Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: reject bindless samplers/images frag inputs without 'flat'Samuel Pitoiset2017-05-061-0/+20
| | | | | | | | | | | | | | | | | | | From section 4.3.4 of the ARB_bindless_texture spec "(modify last paragraph, p. 35, allowing samplers and images as fragment shader inputs) ... Fragment inputs can only be signed and unsigned integers and integer vectors, floating point scalars, floating-point vectors, matrices, sampler and image types, or arrays or structures of these. Fragment shader inputs that are signed or unsigned integers, integer vectors, or any double-precision floating- point type, or any sampler or image type must be qualified with the interpolation qualifier "flat"." v3: - update spec comment formatting Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow bindless samplers/images as vertex shader inputsSamuel Pitoiset2017-05-061-0/+14
| | | | | | | | | | | | | | | | From section 4.3.4 of the ARB_bindless_texture spec: "(modify third paragraph of the section to allow sampler and image types) ... Vertex shader inputs can only be float, single-precision floating-point scalars, single-precision floating-point vectors, matrices, signed and unsigned integers and integer vectors, sampler and image types." v3: - update spec comment formatting Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow bindless samplers/images as varying variablesSamuel Pitoiset2017-05-061-0/+20
| | | | | | | | | | | | | | | | | | | | | | | From section 4.3.4 of the ARB_bindless_texture spec: "(modify third paragraph of the section to allow sampler and image types) ... Vertex shader inputs can only be float, single-precision floating-point scalars, single-precision floating-point vectors, matrices, signed and unsigned integers and integer vectors, sampler and image types." From section 4.3.6 of the ARB_bindless_texture spec: "Output variables can only be floating-point scalars, floating-point vectors, matrices, signed or unsigned integers or integer vectors, sampler or image types, or arrays or structures of any these." v3: - add spec comment Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow input memory qualifiers for imagesSamuel Pitoiset2017-05-061-0/+10
| | | | | | | | | | | ARB_bindless_texture spec allows images to be declared as shader inputs. v2: - put the */ on the following line (Timothy Arceri) Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow image qualifiers inside structuresSamuel Pitoiset2017-05-061-4/+23
| | | | | | | | | | | | ARB_bindless_texture allows to declare images inside structures which means that qualifiers like writeonly should be allowed. I have a got a confirmation from Jeff Bolz (one author of the spec), because the spec doesn't clearly explain this. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow bindless images to be declared inside structuresSamuel Pitoiset2017-05-061-1/+1
| | | | | | | | | The spec doesn't clearly state this, but I have got clarification from the spec authors. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow bindless samplers/images inside interface blocksSamuel Pitoiset2017-05-061-2/+12
| | | | | | | | | | | | | | | | | From section 4.3.7 of the ARB_bindless_texture spec: "(remove the following bullet from the last list on p. 39, thereby permitting sampler types in interface blocks; image types are also permitted in blocks by this extension)" * sampler types are not allowed v3: - update the spec comment - update the glsl error message Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow bindless samplers/images as function returnSamuel Pitoiset2017-05-061-3/+8
| | | | | | | | | | | | | The ARB_bindless_texture spec doesn't clearly state this, but as it says "Replace Section 4.1.7 (Samplers), p. 25" and, "Replace Section 4.1.X, (Images)", this should be allowed. v3: - add spec comment - update the glsl error message Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow bindless samplers/images as out and inout parametersSamuel Pitoiset2017-05-061-2/+14
| | | | | | | | | | | | | | | | | | | From section 4.1.7 of the ARB_bindless_texture spec: "Samplers can be used as l-values, so can be assigned into and used as "out" and "inout" function parameters." From section 4.1.X of the ARB_bindless_texture spec: "Images can be used as l-values, so can be assigned into and used as "out" and "inout" function parameters." v3: - add spec comment - update the glsl error message Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: allow to declare bindless samplers/images as non-uniformSamuel Pitoiset2017-05-061-17/+66
| | | | | | | | | | | | | | | | | | | | From section 4.1.7 of the ARB_bindless_texture spec: "Samplers may be declared as shader inputs and outputs, as uniform variables, as temporary variables, and as function parameters." From section 4.1.X of the ARB_bindless_texture spec: "Images may be declared as shader inputs and outputs, as uniform variables, as temporary variables, and as function parameters." v3: - add validate_storage_for_sampler_image_types() - update spec comment - update the glsl error message Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: process bindless/bound layout qualifiersSamuel Pitoiset2017-05-069-3/+188
| | | | | | | | | | | | This adds bindless_sampler and bound_sampler (and respectively bindless_image and bound_image) to the parser. v3: - add an extra space in apply_bindless_qualifier_to_variable() - fix indentation in merge_qualifier() Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: do not make sampler/image types readonly variablesSamuel Pitoiset2017-05-062-4/+0
| | | | | | | | | | | | | | | | | In plain GLSL, sampler and image types can only be declared uniform-qualified global variables or 'in' function parameters. Setting the read_only flag seems quite useless because other checks will prevent sampler/image variables to be assigned and also because the flag is not set for atomic_uint types which are opaque types. This will also help for ARB_bindless_texture because samplers and images can be assigned when they are considered bindless. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: make component_slots() returns 2 for samplers/imagesSamuel Pitoiset2017-05-061-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | Bindless samplers/images are 64-bit unsigned integers, which means they consume two components as specified by ARB_bindless_texture. It looks like we are not wasting uniform storage by changing this because default-block uniforms are not packed. So, if we use N uint uniforms, they occupy N * 16 bytes in the constant buffer. This is something that could be improved. Though, count_uniform_size needs to be adjusted to not count a sampler (or image) twice. As a side effect, this will probably break the cache if you have one because it will consider sampler/image types as two components. v3: - update the comments Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: add ARB_bindless_texture enableSamuel Pitoiset2017-05-063-0/+9
| | | | | | | | | This also adds the extension to the standalone GLSL compiler. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: reject memory qualifiers with uniform blocksSamuel Pitoiset2017-05-041-2/+10
| | | | | | | | | | | | | The spec allows memory qualifiers to be used with image variables, buffers variables and shader storage blocks. This patch also fixes validate_memory_qualifier_for_type(). Fixes the following ARB_uniform_buffer_object test: uniform-block-memory-qualifier.frag Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: reject format qualifiers with non-image types everywhereSamuel Pitoiset2017-05-041-0/+2
| | | | | | | | | | | Including structures, interfaces and uniform blocks. Fixes the following ARB_shader_image_load_store test: format-layout-with-non-image-type.frag Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: rework validate_image_qualifier_for_type()Samuel Pitoiset2017-05-041-9/+27
| | | | | | | | | | | | It makes more sense to have two separate validate functions, mainly because memory qualifiers are allowed with members of shader storage blocks. validate_memory_qualifier_for_type() will be fixed in a separate patch. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: rename image_* qualifiers to memory_*Samuel Pitoiset2017-05-049-81/+81
| | | | | | | | | It doesn't make sense to prefix them with 'image' because they are called "Memory Qualifiers" and they can be applied to members of storage buffer blocks. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Andres Gomez <[email protected]>
* glsl: Corrected some typos and error messagesAndres Gomez2017-05-031-4/+5
| | | | | | | v2: left code style/formatting corrections out. Signed-off-by: Andres Gomez <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* Revert "glsl: reject image qualifiers with non-image types inside uniform ↵Matt Turner2017-04-281-2/+0
| | | | | | | | | | | | | | | | | | blocks" This reverts commit 24011ead71ea9980e6b34e40d9dbd64e6560f5a4. This causes lots of ES 3.1 CTS tests to fail to compile a bit of code like: layout(binding = 0) buffer InOut { highp uint inputValues[384]; highp uint outputValues[384]; coherent highp uint groupValues[64]; <----- } sb_inout; error: memory qualifiers may only be applied to images
* glsl: remove the shader_group_vote and shader_ballot expression opsNicolai Hähnle2017-04-283-53/+0
| | | | They are now no longer used.
* glsl: implement arb_shader_ballot builtins using intrinsicsNicolai Hähnle2017-04-281-3/+83
|
* glsl: implement arb_shader_group_vote builtins via intrinsicsNicolai Hähnle2017-04-281-6/+32
| | | | | Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* glsl: add intrinsics for ARB_shader_group_vote and ARB_shader_ballotNicolai Hähnle2017-04-281-0/+7
| | | | | | | | | | These operations are currently implemented as IR expressions. However, they cannot be transformed and moved in the way that other IR expressions can because they have non-trivial interactions with control-flow. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* glsl: reject image qualifiers with non-image types inside uniform blocksSamuel Pitoiset2017-04-281-0/+2
| | | | | | | | | | Fixes the following ARB_shader_image_load_store tests: format-layout-with-non-image-type.frag memory-qualifier-with-non-image-type.frag Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: introduce validate_image_qualifier_for_type() helperSamuel Pitoiset2017-04-281-9/+20
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: fix error when using format qualifiers with non-image typesSamuel Pitoiset2017-04-281-2/+6
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: remove duplicate validationTimothy Arceri2017-04-271-15/+0
| | | | | | | | Varying types have already been validated in apply_type_qualifier_to_variable() by this point. Reviewed-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: use without_array() rather than get_scalar_type()Timothy Arceri2017-04-271-1/+1
| | | | | | | | Here get_scalar_type() was just being use to remove the array after that we converted it back to base_type anyway so just use the without_array() helper. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: Initialize current_varMatt Turner2017-04-251-1/+1
| | | | CID: 1324644 (Uninitialized pointer field)
* glsl: use ARB_enhahnced_layouts for packing where possibleTimothy Arceri2017-04-241-0/+70
| | | | | | | | | | | | | | | | | | | | | If packing doesn't cross locations we can easily make use of ARB_enhanced_layouts to do packing rather than using the GLSL IR lowering pass lower_packed_varyings(). Shader-db Broadwell results: total instructions in shared programs: 12977822 -> 12977819 (-0.00%) instructions in affected programs: 1871 -> 1868 (-0.16%) helped: 4 HURT: 3 total cycles in shared programs: 246567288 -> 246567668 (0.00%) cycles in affected programs: 1370386 -> 1370766 (0.03%) helped: 592 HURT: 733 Acked-by: Elie Tournier <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: disable varying packing for varying used by interpolateAt*Timothy Arceri2017-04-243-7/+19
| | | | | | | | | | | | | | | | | Currently the NIR backends depend on GLSL IR copy propagation to fix up the interpolateAt* function params after varying packing changes the shader input to a global. It's possible copy propagation might not always do what we need it too, and we also shouldn't depend on optimisations to do this type of thing for us. I'm not sure if the same is true for TGSI, but the following commit should re-enable packing for most cases in a safer way, so we just disable it everywhere. No change in shader-db for i965 (BDW) Acked-by: Elie Tournier <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl_to_nir: skip ir_var_shader_shared variablesTimothy Arceri2017-04-241-0/+7
| | | | | | | | | | | | | | These should be lowered away in GLSL IR but if we don't get dead code to clean them up it causes issues in glsl_to_nir. We wan't to drop as many GLSL IR opts in future as we can so this makes glsl_to_nir just ignore the vars if it sees them. In future we will want to just use the nir lowering pass that Vulkan currently uses. Acked-by: Elie Tournier <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: make use of glsl_type::is_float()Samuel Pitoiset2017-04-219-55/+47
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: make use of glsl_type::is_double()Samuel Pitoiset2017-04-2111-44/+44
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: make use of glsl_type::is_integer_64()Samuel Pitoiset2017-04-211-9/+2
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: make use of glsl_type::is_boolean()Samuel Pitoiset2017-04-213-18/+17
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>