aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/link_interface_blocks.cpp
Commit message (Collapse)AuthorAgeFilesLines
* mesa: include mtypes.h lessMarek Olšák2018-04-121-0/+1
| | | | | | | | | | - remove mtypes.h from most header files - add main/menums.h for often used definitions - remove main/core.h v2: fix radv build Reviewed-by: Brian Paul <[email protected]>
* glsl: don't run intrastage array validation when the interface type is not ↵Samuel Iglesias Gonsálvez2017-12-041-1/+1
| | | | | | | | | | | | | | | | | an array We validate that the interface block array type's definition matches. However, previously, the function could be called if an non-array interface block has different type definitions -for example, when the precision qualifier differs in a GLSL ES shader, we would create two different types-, and it would return invalid as both definitions are non-arrays. We fix this by specifying that at least one definition should be an array to call the validation. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/es: precision qualifier doesn't need to match in UBOsSamuel Iglesias Gonsálvez2017-12-041-1/+1
| | | | | | | | | They might mismatch due to the two shaders using different GLSL versions, and that's ok in desktop GL. In ES, precision qualifiers don't need to match. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/linker: Check that re-declared, inter-shader built-in blocks matchEduardo Lima Mitev2017-10-301-0/+29
| | | | | | | | | | | | | | | | | | | | | | | >From GLSL 4.5 spec, section "7.1 Built-In Language Variables", page 130 of the PDF states: "If multiple shaders using members of a built-in block belonging to the same interface are linked together in the same program, they must all redeclare the built-in block in the same way, as described in section 4.3.9 “Interface Blocks” for interface-block matching, or a link-time error will result." Fixes: * GL45-CTS.CommonBugs.CommonBug_PerVertexValidation v2 (Neil Roberts): Explicitly look for gl_PerVertex in the symbol tables instead of waiting to find a variable in the interface. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102677 Reviewed-by: Kenneth Graunke <[email protected]> Signed-off-by: Eduardo Lima Mitev <[email protected]> Signed-off-by: Neil Roberts <[email protected]>
* st/mesa/glsl: move Version to gl_shader_program_dataTimothy Arceri2016-12-021-3/+3
| | | | | | | | | | | This is mostly just used during linking however the st uses it when updating textures. In order to store gl_program in the CurrentProgram array rather than gl_shader_program we need to move this field to the shared gl_shader_program_data struct. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: validate output blocks against input blocksIago Toral Quiroga2016-11-101-11/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now were validating in/out blocks by listing the inputs in the consumer stage and then, for each output of the producer, we checked that it was a match if it was consumed. This method does not catch the case where the consumer has an input that is not present as an output in the producer stage, because it only generates link errors for outputs present in the producer stage that don't match the inputs in the consumer stage. The current method does catch the case were an output from the producer stage is not consumed, which is irrelevant and is ignored. By reversing the way we do this, we can detect this situation, so this patch lists the outputs of the producer stage and then validates inputs of the consumer stage against them. If we see an input in the consumer for which there is no associated output in the producer, we produce a link error. The only exception to this is the special built-in input block gl_in[], since this is implicitly generated for geometry and tessellation stages, but we don't generate it if the producer stage does not write to any of the pre-defined outputs (for example, if the vertex shader does not write to gl_Position, etc). Since writing to these is not mandatory, do not produce a link error in that case. There is a CTS tessellation test (GL45-CTS.tessellation_shader.program_object_properties) that has an empty vertex shader (so it does not produce gl_in[]) and would fail to link if we don't do this. This fixes the following dEQP test: dEQP-GLES31.functional.shaders.linkage.io_block.missing_output_block Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98245 Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl/es31: precision qualifier doesn't need to match in shader interface ↵Samuel Iglesias Gonsálvez2016-10-241-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | block members It is specific only to GLSL ES 3.1. From the spec, section 4.3.9 "Interface Blocks": "Matched block names within a shader interface (as defined above) must match in terms of having the same number of declarations with the same sequence of types and the same sequence of member names, as well as having the same qualification as specified in section 9.2 (“Matching of Qualifiers“)." But in GLSL ES 3.0 and 3.2, it is the opposite: "Matched block names within a shader interface (as defined above) must match in terms of having the same number of declarations with the same sequence of types, precisions and the same sequence of member names, as well as having the matching member-wise layout qualification as defined in section 9.2 (“Matching of Qualifiers”)." Fixes: dEQP-GLES31.functional.shaders.linkage.uniform.block.differing_precision Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98243 Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: move intrastage_match() after interstage_member_mismatch()Samuel Iglesias Gonsálvez2016-10-241-46/+46
| | | | | Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl/mesa: split gl_shader in twoTimothy Arceri2016-06-301-5/+5
| | | | | | | | | | | | | | | | | There are two distinctly different uses of this struct. The first is to store GL shader objects. The second is to store information about a shader stage thats been linked. The two uses actually share few fields and there is clearly confusion about their use. For example the linked shaders map one to one with a program so can simply be destroyed along with the program. However previously we were calling reference counting on the linked shaders. We were also creating linked shaders with a name even though it is always 0 and called the driver version of the _mesa_new_shader() function unnecessarily for GL shader objects. Acked-by: Iago Toral Quiroga <[email protected]>
* glsl: fix error message on uniform block mismatchDave Airlie2016-05-261-1/+1
| | | | | | | This looks like a cut-paste from above. Reviewed-by: Anuj Phogat <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: make max array trackers ints and use -1 as base. (v2)Dave Airlie2016-05-241-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug that breaks cull distances. The problem is the max array accessors can't tell the difference between an never accessed unsized array and an accessed at location 0 unsized array. This leads to converting an undeclared unused gl_ClipDistance inside or outside gl_PerVertex to a size 1 array. However we need to the number of active clip distances to work out the starting point for the cull distances, and this offset by one when it's not being used isn't possible to distinguish from the case were only the first element is accessed. I tried to use ->used for this, but that doesn't work when gl_ClipDistance is part of an interface block. So this changes things so that max_array_access is an int and initialised to -1. This also allows unsized arrays to proceed further than that could before, but we really shouldn't mind as they will get eliminated if nothing uses them later. For initialised uniforms we no longer change their array size at runtime, if these are unused they will get eliminated eventually. v2: use ralloc_array (Ilia) Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: generate named interface block names correctlyTimothy Arceri2016-03-311-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Firstly this updates the named interface lowering pass to store the interface without the arrays removed. Note we need to remove the arrays in the interface/varying matching code to not regress things but in future this should be fixed futher as it would seem we currently successfully match interface blocks with differnt array sizes. Since we now know if the interface was an array we can reduce the IR flags from_named_ifc_block_array and from_named_ifc_block_nonarray to just from_named_ifc_block. Next rather than having a different code path for named interface blocks in program_resource_visitor we just make use of the one used by UBOs this allows us to now handle arrays of arrays correctly. Finally we add a new param to the recursion function named_ifc_member this is because we only want to process a single member at a time. Note that this is also the glsl_struct_field from the original ifc type before lowering rather than the type from the lowered variable. This fixes a bug in Mesa where we would generate the names like WithInstArray[0].g[0][0] when it should be WithInstArray[0].g[0] for the following interface. out WithInstArray { float g[3]; } instArray[2]; Reviewed-by: Dave Airlie <[email protected]>
* glsl: don't always reject shaders with mismatching ifc blocksTimothy Arceri2016-03-091-6/+72
| | | | | | | | | Since we store some member qualifiers in the interface type we need to be more careful about rejecting shaders just because the pointer doesn't match. Its perfectly valid for some qualifiers such as precision to not match across shader interfaces. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: make interstage_match() staticTimothy Arceri2016-03-091-1/+1
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: move to compiler/Emil Velikov2016-01-261-0/+357
Signed-off-by: Emil Velikov <[email protected]> Acked-by: Matt Turner <[email protected]> Acked-by: Jose Fonseca <[email protected]>