summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: revert "glsl: atomic counters can be declared as buffer-qualified ↵Iago Toral Quiroga2015-09-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | variables" This reverts commit 586142658e2927a68c. The specs are not explicit about any restrictions related to the types allowed on buffer variables, however, the description of opaque types (like atomic counters) is in conclict with the purpose of buffer variables: "The opaque types declare variables that are effectively opaque handles to other objects. These objects are accessed through built-in functions, not through direct reading or writing of the declared variable. (...) Opaque variables cannot be treated as l-values;(...)" Also, Mesa is already disallowing opaque types in interface blocks anyway, so that commit was not really achieving anything. Reviewed-by: Francisco Jerez <[email protected]>
* glsl: fix component size calculation for tessellation and geom shadersTimothy Arceri2015-09-281-1/+1
| | | | | | Broken in commit abdab88b30ab when adding arrays of arrays support Reviewed-by: Dave Airlie <[email protected]>
* nir: Add a function to count the number of vertices a GS emits.Kenneth Graunke2015-09-263-0/+96
| | | | | | | | | | | Some hardware (such as Broadwell) can run geometry shaders more efficiently when the number of vertices emitted is statically known. This pass provides a way to obtain the constant vertex count, or -1 indicating that the vertex count is unknown/non-constant. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: calculate component size for arrays of arrays when varying packing ↵Timothy Arceri2015-09-261-3/+10
| | | | | | | | disabled Signed-off-by: Timothy Arceri <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: validate binding qualifier for AoATimothy Arceri2015-09-261-1/+1
| | | | | Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: add helper for calculating size of AoATimothy Arceri2015-09-261-0/+19
| | | | | | | V2: return 0 if not array rather than -1 Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: clean-up link uniform codeTimothy Arceri2015-09-261-11/+6
| | | | | | | These changes are also needed to allow linking of struct and interface arrays of arrays. Reviewed-by: Thomas Helland <[email protected]>
* glsl: fix packed varyings interface type and add default caseTapani Pälli2015-09-251-0/+4
| | | | | | | | fixes Piglit test: arb_program_interface_query/linker/query-varyings.shader_test Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Mark as active all elements of shared/std140 block arraysAntia Puentes2015-09-251-0/+24
| | | | | | | | | | | | | | | | | | | | | | | Commit 1ca25ab (glsl: Do not eliminate 'shared' or 'std140' blocks or block members) considered as active 'shared' and 'std140' uniform blocks and uniform block arrays, but did not include the block array elements. Because of that, it was possible to have an active uniform block array without any elements marked as used, making the assertion ((b->num_array_elements > 0) == b->type->is_array()) in link_uniform_blocks() fail. Fixes the following 5 dEQP tests: * dEQP-GLES3.functional.ubo.random.nested_structs_instance_arrays.18 * dEQP-GLES3.functional.ubo.random.nested_structs_instance_arrays.24 * dEQP-GLES3.functional.ubo.random.nested_structs_arrays_instance_arrays.19 * dEQP-GLES3.functional.ubo.random.all_per_block_buffers.49 * dEQP-GLES3.functional.ubo.random.all_shared_buffer.36 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83508 Tested-by: Tapani Pälli <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* mesa: enable ARB_shader_storage_buffer_object extension for GLES 3.1Samuel Iglesias Gonsalvez2015-09-252-2/+2
| | | | | | Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* main: Add SHADER_STORAGE_BLOCK and BUFFER_VARIABLE support for ↵Samuel Iglesias Gonsalvez2015-09-253-3/+15
| | | | | | | | | | | | | ARB_program_interface_query Including TOP_LEVEL_ARRAY_SIZE and TOP_LEVEL_ARRAY_STRIDE queries. v2: - Use std430_array_stride() to get top level array stride following std430's rules. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Do not allow reads from write-only buffer variablesIago Toral Quiroga2015-09-251-0/+56
| | | | | | | | | | | | | The error location won't be right, but fixing that would require to check for this as we process each type of AST node that can involve a variable read. v2: - Limit the check to buffer variables, image variables have different semantics involved. Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Do not allow assignments to read-only buffer variablesIago Toral Quiroga2015-09-251-1/+10
| | | | | | | | | | | v2: - Merge the error check for the readonly qualifier with the already existing check for variables flagged as readonly (Timothy). - Limit the check to buffer variables, image variables have different semantics involved (Curro). Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Allow memory qualifiers on shader storage buffer blocksSamuel Iglesias Gonsalvez2015-09-251-0/+14
| | | | | | | | v2: - Memory qualifiers on shader storage buffer objects do not come in the form of layout qualifiers, they are block-level qualifiers. Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Apply memory qualifiers to buffer variablesIago Toral Quiroga2015-09-253-3/+91
| | | | | | | | | | | | v2: - Save memory qualifier info in the top level members of a shader storage block. - Add a checks to record_compare() which is used when comparing shader storage buffer declarations in different shaders. - Always report an error for incompatible readonly/writeonly definitions, whether they are present at block or field level. Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Allow use of memory qualifiers with ARB_shader_storage_buffer_object.Iago Toral Quiroga2015-09-251-5/+5
| | | | Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: First argument to atomic functions must be a buffer variableIago Toral Quiroga2015-09-251-0/+42
| | | | | | | | | | | v2: - Add ssbo_in the names of the static functions so it is clear that this is specific to SSBO atomics. v3: - Move the check after the loop (Kristian Høgsberg) Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: Implement lowered SSBO atomic intrinsicsIago Toral Quiroga2015-09-252-0/+82
| | | | | | | | | | | | The original GLSL IR intrinsics have been lowered to an internal version that accepts a block index and an offset instead of a SSBO reference. v2 (Connor): - Document the sources used by the atomic intrinsics. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: lower SSBO atomic intrinsicsIago Toral Quiroga2015-09-251-0/+159
| | | | | | | | | | | | | The first argument to SSBO atomics is a reference to a SSBO buffer variable so we want to compute its block index and offset and provide these values to an internal version of the intrinsic that takes them instead of the buffer variable reference. v2: - Support single components of integer vectors to be passed in as arguments. - Get interface packing information from interface's type. Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: use ir_rvalue instead of ir_dereference in auxiliary functionsSamuel Iglesias Gonsalvez2015-09-251-4/+4
| | | | | | | | | | In a later commit we will need to handle ir_swizzle nodes too, which are not an ir_dereference. That can happen, for example, when we pass a component of an integer vector as argument to any of the SSBO atomic functions. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Add atomic functions from ARB_shader_storage_buffer_objectIago Toral Quiroga2015-09-251-0/+185
| | | | Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Rename atomic counter functionsIago Toral Quiroga2015-09-251-15/+15
| | | | | | | | | Shader Storage Buffer Object will add new atomic functions that are not associated with counters, so better have atomic counter-specific functions explicitly include the word "counter" in their names. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: atomic counters can be declared as buffer-qualified variablesSamuel Iglesias Gonsalvez2015-09-251-3/+3
| | | | | Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir/glsl_to_nir: ignore an instruction's dest if it hasn't anyIago Toral Quiroga2015-09-251-1/+2
| | | | | Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: Implement __intrinsic_load_ssboIago Toral Quiroga2015-09-253-1/+70
| | | | | | | | | | | v2: - Fix ssbo loads with boolean variables. v3: - Simplify the changes (Kristian) Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: modify the instruction insertion in nir_visitor::visit(ir_call *ir)Samuel Iglesias Gonsalvez2015-09-251-4/+10
| | | | | | | | | | | | This patch moves nir_instr_insert_after_cf_list call into each case in the intrinsics switch at nir_visitor::visit(ir_call *ir) and define a nir_dest variable which will be used when handling ir->return_deref after the switch. This patch simplifies the code for nir_intrinsic_load_ssbo implementation changes we are going to do next. Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: Implement __intrinsic_store_ssboIago Toral Quiroga2015-09-252-8/+48
| | | | | | | | v2 (Connor): - Make the STORE() macro take arguments for the extra sources (and their size) and any extra indices required. Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: shader storage blocks use different max block size values than uniformsSamuel Iglesias Gonsalvez2015-09-251-1/+11
| | | | | Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: ignore buffer variables when counting uniform componentsSamuel Iglesias Gonsalvez2015-09-251-5/+11
| | | | | | Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: number of active shader storage blocks must be within allowed limitsSamuel Iglesias Gonsalvez2015-09-251-4/+39
| | | | | | | | | Notice that we should differentiate between shader storage blocks and uniform blocks, since they have different limits. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: a shader storage buffer must be smaller than the maximum size allowedSamuel Iglesias Gonsalvez2015-09-253-1/+21
| | | | | | | | | | | | | | | Otherwise, generate a link time error as per the ARB_shader_storage_buffer_object spec. v2: - Fix error message (Jordan) v3: - Move std140_size() changes to its own patch (Kristian) Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: add std430 interface packing support to ssbo related operationsSamuel Iglesias Gonsalvez2015-09-251-30/+81
| | | | | | | | | | | | | | | | | | | v2: - Get interface packing information from interface's type, not the variable type. - Simplify is_std430 condition in emit_access() for readability (Jordan) - Add a commment explaing why array of three-component vector case is different in std430 than the rest of cases. - Add calls to std430_array_stride(). v3: - Simplify size_mul change for std430's case (Jordan) - Fix commit log lines length (Jordan) - Pass 'packing' instead of 'is_std430' to emit_access() (Kristian) Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Add std430 support to program_resource_visitor's member functionsSamuel Iglesias Gonsalvez2015-09-253-39/+84
| | | | | | | | | | | | | They are used to calculate the offset, array stride of uniform/shader storage buffer variables. Take into account this info to get the right value for std430. v2: - Fix commit log line length and indention. (Jordan) Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Add parser/compiler support for std430 interface packing qualifierSamuel Iglesias Gonsalvez2015-09-256-8/+36
| | | | | | | | | | | | | v2: - Fix a missing check in has_layout() v3: - Mention shader storage block in error message for layout qualifiers (Kristian). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Add std430 related member functions to glsl_type classSamuel Iglesias Gonsalvez2015-09-252-0/+226
| | | | | | | | | | | | They are used to calculate size, base alignment and array stride values for a glsl_type following std430 rules. v2: - Paste OpenGL 4.3 spec wording as it mentions stride of array. (Jordan) Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: allow default qualifiers for shader storage block definitionsSamuel Iglesias Gonsalvez2015-09-253-3/+70
| | | | | | | | | | | This kind of definitions: layout(xxx) buffer; was not supported by commit 84fc5fece006. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Move interface block processing to glsl_parser_extras.cppSamuel Iglesias Gonsalvez2015-09-253-126/+128
| | | | | | No functional changes. Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: ignore default qualifier declarations when checking for duplicate ↵Samuel Iglesias Gonsalvez2015-09-253-1/+8
| | | | | | | layout qualifiers Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: layout qualifier can appear more than once since OpenGL 4.20Samuel Iglesias Gonsalvez2015-09-251-2/+8
| | | | | | | Also if GL_ARB_shading_language_420pack extension is enabled. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* nir: Implement ir_unop_get_buffer_sizeSamuel Iglesias Gonsalvez2015-09-252-0/+17
| | | | | | | | This is how backends provide the buffer size required to compute the size of unsized arrays in the previous patch Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: implement unsized array lengthSamuel Iglesias Gonsalvez2015-09-251-0/+182
| | | | | | | | | | | | | | | v2: - Reduce the number of lines over 80 character line width limit. (Thomas Hellan) v3: - Inject the formula to compute the array length in the IR, backends only need to provide the buffer size (Curro) - Create an auxiliary function to simplify code (Jordan Justen) - Rename variables (Jordan Justen) Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Add parser/compiler support for unsized array's length()Samuel Iglesias Gonsalvez2015-09-255-7/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The unsized array length is computed with the following formula: array.length() = max((buffer_object_size - offset_of_array) / stride_of_array, 0) Of these, only the buffer size needs to be provided by the backends, the frontend already knows the values of the two other variables. This patch identifies the cases where we need to get the length of an unsized array, injecting ir_unop_ssbo_unsized_array_length expressions that will be lowered (in a later patch) to inject the formula mentioned above. It also adds the ir_unop_get_buffer_size expression that drivers will implement to provide the buffer length. v2: - Do not define a triop that will force backends to implement the entire formula, they should only need to provide the buffer size since the other values are known by the frontend (Curro). v3: - Call state->has_shader_storage_buffer_objects() in ast_function.cpp instead of using state->ARB_shader_storage_buffer_object_enable (Tapani). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: Add unsized array support to glsl_type::std140_size()Samuel Iglesias Gonsalvez2015-09-251-1/+6
| | | | Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: fix indention in glsl_types.cppSamuel Iglesias Gonsalvez2015-09-251-70/+70
| | | | | | | No functional changes. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: add support for unsized arrays in shader storage blocksSamuel Iglesias Gonsalvez2015-09-255-49/+150
| | | | | | | | | | | | | | | | | | | They only can be defined in the last position of the shader storage blocks. When an unsized array is used in different shaders, it might be converted in different sized arrays, avoid get a linker error in that case. v2: - Rework error condition and error messages (Timothy Arceri) v3: - Move OpenGL ES check to its own patch. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: return error if unsized arrays are found in OpenGL ESSamuel Iglesias Gonsalvez2015-09-251-0/+16
| | | | | | Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: add packed varyings to program resource listTapani Pälli2015-09-251-4/+76
| | | | | | | | | | | | | | This makes sure that user is still able to query properties about variables that have gotten packed by lower_packed_varyings pass. Fixes following OpenGL ES 3.1 test: ES31-CTS.program_interface_query.separate-programs-vertex v2: fix 'name included in packed list' check (Ilia Mirkin) v3: iterate over instances of name using strtok_r (Ilia Mirkin) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Marta Lofstedt <[email protected]>
* mesa: add packed_varyings list to gl_shaderTapani Pälli2015-09-251-4/+12
| | | | | | | | | This is required to store information about packed varyings, currently these variables get lost and cannot be retrieved later in sensible way for program interface queries. List will be utilized by next patch. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Marta Lofstedt <[email protected]>
* glsl: Expose gl_MaxTess{Control,Evaluation}AtomicCounters.Matt Turner2015-09-241-8/+4
| | | | | | | | | | | | | | | | | | | | | ... with only ARB_shader_atomic_counters. I expected to see interactions with ARB_tessellation_shader in the ARB_shader_atomic_counters spec, but they do not exist. It seems that we should unconditionally expose these variables in the presence of ARB_shader_atomic_counters: gl_MaxTessControlAtomicCounters gl_MaxTessEvaluationAtomicCounters This partially reverts commit da7adb99e8. The commit also affected gl_MaxTessControlImageUniforms and gl_MaxTessEvaluationImageUniforms similarly but the ARB_shader_image_load_store spec does list an interaction with ARB_tessellation_shader. Cc: "11.0" <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92095 Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: correctly detect inactive UBO arraysTimothy Arceri2015-09-242-9/+4
| | | | | | | | | Previously the code was trying to get the packing type from the array not the interface. Cc: Ian Romanick <[email protected]> Cc: Antia Puentes <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>