summaryrefslogtreecommitdiffstats
path: root/src/glsl/linker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* glsl: do not try to reserve explicit locations for buffer variablesTapani Pälli2015-10-211-2/+2
| | | | | | | | Explicit locations are only used with uniform variables. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Marta Lofstedt <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* mesa: replace UsesClipDistance with ClipDistanceArraySizeMarek Olšák2015-10-201-21/+18
| | | | | | | This is more practical and needed by gallium. Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: add AoA support for linking interface blocks with unsized membersTimothy Arceri2015-10-151-4/+5
| | | | Reviewed-by: Ian Romanick <[email protected]>
* glsl: Enable split of lower UBOs and SSBO also for compute shadersMarta Lofstedt2015-10-141-1/+1
| | | | | | | | | | | | | The split of Uniform blocks and shader storage block only loops up to MESA_SHADER_FRAGMENT and igonres compute shaders. This cause segfault when running the OpenGL ES 3.1 CTS tests with GL_ARB_compute_shader enabled. V2: Changed to use MESA_SHADER_STAGES instead of MESA_SHADER_COMPUTE Reviewed-by: Francisco Jerez <[email protected]> Signed-off-by: Marta Lofstedt <[email protected]>
* glsl: Include util/strndup.h.Jose Fonseca2015-10-141-0/+1
| | | | | | Fixes Windows builds. Trivial.
* glsl: calculate TOP_LEVEL_ARRAY_SIZE and STRIDE when adding resourcesTapani Pälli2015-10-141-0/+241
| | | | | | | | | | Patch moves existing calculation code from shader_query.cpp to happen during program resource list creation. No Piglit or CTS regressions were observed during testing. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* mesa: Add {Num}UniformBlocks and {Num}ShaderStorageBlocks to gl_shader{_program}Iago Toral Quiroga2015-10-141-0/+61
| | | | | | These arrays provide backends with separate index spaces for UBOS and SSBOs. Reviewed-by: Kristian Høgsberg <[email protected]>
* mesa: Rename {Num}UniformBlocks to {Num}BufferInterfaceBlocksIago Toral Quiroga2015-10-141-22/+22
| | | | | | | | | | | | | | Currently, these arrays in gl_shader and gl_shader_program hold both UBOs and SSBOs, so this looks like a better name. We were already using NumBufferInterfaceBlocks in gl_shader_program, so this makes things more consistent as well. In a later patch we will add {Num}UniformBlocks and {Num}ShaderStorageBlocks which will contain only references to UBOs and SSBOs respectively that will provide backends with a separate index space for both types of objects. Reviewed-by: Kristian Høgsberg <[email protected]>
* glsl: add varyings to resource list only with SSOTapani Pälli2015-10-081-4/+7
| | | | | | | | | | | | | | | | | | | | Varyings can be considered inputs or outputs of a program only when SSO is in use. With multi-stage programs, inputs contain only inputs for first stage and outputs contains outputs of the final shader stage. I've tested that fix works for Assault Android Cactus (demo version) and does not cause Piglit or CTS regressions in glGetProgramiv tests. Following ES 3.1 CTS separate shader tests that do query properties of varyings in SSO shader programs pass: ES31-CTS.program_interface_query.separate-programs-vertex ES31-CTS.program_interface_query.separate-programs-fragment Signed-off-by: Tapani Pälli <[email protected]> Tested-by: Dieter Nützel <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92122
* glsl: reduce memory footprint of uniform_storage structTimothy Arceri2015-10-051-1/+1
| | | | | | | | The uniform will only be of a single type so store the data for opaque types in a single array. Cc: Francisco Jerez <[email protected]> Cc: Ilia Mirkin <[email protected]>
* mesa: remove Driver.DeleteShaderMarek Olšák2015-10-031-4/+4
| | | | | | | Nothing overrides it. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: apply shader storage block member rules when adding program resourcesSamuel Iglesias Gonsalvez2015-09-301-0/+58
| | | | | | | | | | | | | | | | From ARB_program_interface_query: "For an active shader storage block member declared as an array, an entry will be generated only for the first array element, regardless of its type. For arrays of aggregate types, the enumeration rules are applied recursively for the single enumerated array element." v2: - Simplify 'if' conditions and return true if it is not a buffer variable, because these rules only apply to buffer variables (Timothy). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: use correct number of uniform blocks in error messageSamuel Iglesias Gonsalvez2015-09-291-1/+1
| | | | | Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa: rename gl_shader_program's NumUniformBlocks to NumBufferInterfaceBlocksSamuel Iglesias Gonsalvez2015-09-291-5/+5
| | | | | | | | | | | Because it counts shader storage blocks too. v2: - Use NumBufferInterfaceBlocks instead (Jordan). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Kristian Høgsberg <[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]>
* main: Add SHADER_STORAGE_BLOCK and BUFFER_VARIABLE support for ↵Samuel Iglesias Gonsalvez2015-09-251-3/+7
| | | | | | | | | | | | | 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: 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: 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-251-1/+1
| | | | | | | | | | | | | | | 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 support for unsized arrays in shader storage blocksSamuel Iglesias Gonsalvez2015-09-251-36/+71
| | | | | | | | | | | | | | | | | | | 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: 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]>
* glsl: Move link_get_main_function_signature to a common locationJordan Justen2015-09-131-29/+2
| | | | | | | | | | | Also rename to _mesa_get_main_function_signature. We will call it near the end of compilation to insert some code into main for initializing some compute shader global variables. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]>
* glsl: Silence unused parameter warningsIan Romanick2015-09-091-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | builtin_variables.cpp:1062:53: warning: unused parameter 'name_as_gs_input' [-Wunused-parameter] const char *name_as_gs_input) ^ builtin_functions.cpp:4774:47: warning: unused parameter 'intrinsic_name' [-Wunused-parameter] const char *intrinsic_name, ^ builtin_functions.cpp:4907:66: warning: unused parameter 'state' [-Wunused-parameter] _mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state *state, ^ builtin_functions.cpp:4915:49: warning: unused parameter 'num_arguments' [-Wunused-parameter] unsigned num_arguments, ^ builtin_functions.cpp:4916:49: warning: unused parameter 'flags' [-Wunused-parameter] unsigned flags) ^ ir_print_visitor.cpp:589:37: warning: unused parameter 'ir' [-Wunused-parameter] ir_print_visitor::visit(ir_barrier *ir) ^ linker.cpp:3212:48: warning: unused parameter 'ctx' [-Wunused-parameter] build_program_resource_list(struct gl_context *ctx, ^ standalone_scaffolding.cpp:65:57: warning: unused parameter ‘id’ [-Wunused-parameter] _mesa_shader_debug(struct gl_context *, GLenum, GLuint *id, ^ v2: Rebase on top of GL_ARB_shader_image_size work (especially 58a86897). Silence more warnings added by that work. v3: Remove mention of the removed parameter from comments. Suggested by Iago. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> [v1] Reviewed-by: Iago Toral Quiroga <[email protected]> Cc: "Martin Peres <[email protected]>"
* glsl: error out on ES 3.1 if VS or FS present but not bothTapani Pälli2015-09-041-4/+25
| | | | | Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: error on linking if no shaders are attached to programTapani Pälli2015-09-041-0/+19
| | | | | | | This applies to OpenGL Core >= 4.5 and OpenGL ES >= 3.1. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Remove unused total_attribs_size variable.Kenneth Graunke2015-09-031-1/+0
| | | | | | Accidentally left behind by my previous patch. Signed-off-by: Kenneth Graunke <[email protected]>
* glsl: Handle attribute aliasing in attribute storage limit check.Kenneth Graunke2015-09-021-28/+36
| | | | | | | | | | | | | | | | | | | | | | | | | In various versions of OpenGL and GLSL, it's possible to declare multiple VS input variables with aliasing attribute locations. So, when computing the storage requirements for vertex attributes, we can't simply add up the sizes. Instead, we need to look at the enabled slots. This patch begins tracking which attributes are double types that are larger than 128-bits (i.e. take up two vec4 slots). We then count normal attributes once, and count the double-size attributes a second time. Fixes deQP functional.attribute_location.bind_aliasing.max_cond_* tests on i965, which regressed with commit ad208d975a6d3aebe14f7c2c16039ee20. No Piglit changes on llvmpipe (which actually supports dvecs). Cc: "10.6 11.0" <[email protected]> Tested-by: Mark Janes <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]>
* linker: Silence GCC unused parameter warningsIan Romanick2015-09-021-14/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | linker.cpp:320:55: warning: unused parameter 'ir' [-Wunused-parameter] virtual ir_visitor_status visit_leave(ir_function *ir) ^ linker.cpp:327:53: warning: unused parameter 'ir' [-Wunused-parameter] virtual ir_visitor_status visit_leave(ir_return *ir) ^ linker.cpp:333:49: warning: unused parameter 'ir' [-Wunused-parameter] virtual ir_visitor_status visit_enter(ir_if *ir) ^ linker.cpp:339:49: warning: unused parameter 'ir' [-Wunused-parameter] virtual ir_visitor_status visit_leave(ir_if *ir) ^ linker.cpp:345:51: warning: unused parameter 'ir' [-Wunused-parameter] virtual ir_visitor_status visit_enter(ir_loop *ir) ^ linker.cpp:351:51: warning: unused parameter 'ir' [-Wunused-parameter] virtual ir_visitor_status visit_leave(ir_loop *ir) ^ linker.cpp:2824:53: warning: unused parameter 'ctx' [-Wunused-parameter] link_calculate_subroutine_compat(struct gl_context *ctx, struct gl_shader_program *prog) ^ linker.cpp:2854:47: warning: unused parameter 'ctx' [-Wunused-parameter] check_subroutine_resources(struct gl_context *ctx, struct gl_shader_program *prog) ^ linker.cpp:3368:49: warning: unused parameter 'ctx' [-Wunused-parameter] link_assign_subroutine_types(struct gl_context *ctx, ^ Also make link_assign_subroutine_types static since it is only called from this file. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: Rename MaxCombinedImageUnitsAndFragmentOutputs to ↵Francisco Jerez2015-08-201-1/+1
| | | | | | | | | | | | | MaxCombinedShaderOutputResources. The name of both the GLSL built-in variable and the glGetInteger param with the same value changed in GLSL ES 3.1 and GL 4.5. Its semantics also changed slightly, since the limit now also takes into account the number of SSBs in use. Switch our internal data structures to the up-to-date name. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: make linker error message more informativeTimothy Arceri2015-08-131-2/+3
| | | | Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: remove stage ref generation for transform feedbackTimothy Arceri2015-08-071-6/+4
| | | | | | | | | Stage ref cannot be queried for transform feedback. Also simplify the build_stageref function by passing the correct mode for uniforms. Reviewed-by: Tapani Pälli <[email protected]>
* glsl: add variable mode check to build_stagerefTapani Pälli2015-08-051-4/+13
| | | | | | | | | | | | | Currently stage reference mask is built using the variable name only. However it can happen that input of one stage has same name as output from another stage. Adding check of variable mode makes sure we do not pick wrong variable. Fixes some subcases from ES31-CTS.program_interface_query.no-locations Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: set stage flag for structs and arrays in resource listTimothy Arceri2015-07-301-3/+13
| | | | | | | | This fixes the remaining failing tests in: ES31-CTS.program_interface_query.uniform-types Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: verify location when dual source blendingTapani Pälli2015-07-291-0/+19
| | | | | | | | | | | | Same check is made for glBindFragDataLocationIndexed but it was missing when using layout qualifiers. Fixes following Piglit test: arb_blend_func_extended-output-location Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Anuj Phogat <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: move max_index calc to assign_attribute_or_color_locationsTapani Pälli2015-07-291-8/+15
| | | | | | | | | | | Change function to get all gl_constants for inspection, this is used by follow-up patch. v2: rebase, update function documentation Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Anuj Phogat <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: add uniform and program resource support (v2)Dave Airlie2015-07-231-3/+179
| | | | | | | | | | | | | | | | | | | This adds linker support for subroutine uniforms, they have some subtle differences from real uniforms, we also hide them and they are given internal uniform names. This also adds the subroutine locations and subroutine uniforms to the program resource tracking for later use. v1.1: drop is_subroutine_def v2: handle explicit location properly, ARB_explicit_location has a lot of language for subroutine shaders. Calculate a link time the number of compatible subroutines for a uniform, to make program resource easier later. Acked-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: validate restrictions on use of barrier()Chris Forbes2015-07-231-0/+99
| | | | | | | | | | With the exception of always-taken switch cases (which are indistinguishable from straight line code in our IR), this disallows use of the builtin barrier() function in all the places it may not appear. Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: analyze TES usage of gl_ClipDistanceChris Forbes2015-07-231-0/+19
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: push vertex count determination down one levelChris Forbes2015-07-231-9/+4
| | | | | | | We have the prog here, so we don't need the caller to work this out for us. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: lower gl_TessLevel* from float[n] to vecn.Fabian Bieler2015-07-231-0/+4
| | | | | | | | | | Similar to gl_ClipDistance -> gl_ClipDistanceMESA v2: - renamed is_mesa_var to lowered_builtin_array_variable - moved LowerTessLevel into gl_constants - cosmetic changes in lower_tess_level.cpp Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: allow linking of tessellation shaders.Chris Forbes2015-07-231-1/+279
| | | | | | | Marek: require a tess eval shader if a tess control shader is present Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: check for leading zeros in array index validationTimothy Arceri2015-07-221-0/+4
| | | | | Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: link buffer variables and shader storage buffer interface blocksKristian Høgsberg2015-07-141-2/+2
| | | | Reviewed-by: Jordan Justen <[email protected]>
* mesa: rename is_in_uniform_block to is_in_buffer_blockIago Toral Quiroga2015-07-141-1/+1
| | | | | | | Since this now checks if a variable is inside a uniform or a shader storage block. Reviewed-by: Jordan Justen <[email protected]>
* mesa: use implementation specified MAX_VERTEX_ATTRIBS rather than hardcoded ↵Timothy Arceri2015-07-081-6/+2
| | | | | | value Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: update types for unsized arrays of membersTimothy Arceri2015-07-041-2/+16
| | | | | | | Assigns a new array type based on the max access of unsized array members. This is to support arrays of arrays. Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: create program resource list after LinkShaderTapani Pälli2015-07-011-4/+0
| | | | | | | | | Resource list can be created properly only after LinkShader hook has been called to make sure all dead variables have been removed. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Martin Peres <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90925
* glsl: expose build_program_resource_list functionTapani Pälli2015-07-011-1/+1
| | | | | | | | This is required so that we can move resource list creation to happen later. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Martin Peres <[email protected]>
* glsl: build stageref mask using IR, not symbol tableTapani Pälli2015-07-011-3/+11
| | | | | | | | | Instead of using symbol table, build mask by inspecting IR. This change is required by further patches to move resource list creation to happen later when symbol table does not exist anymore. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Martin Peres <[email protected]>
* glsl: validate sampler array indexing for 'constant-index-expression'Tapani Pälli2015-06-301-0/+77
| | | | | | | | | | | | | | Desktop GLSL < 130 and GLSL ES < 300 allow sampler array indexing where index can contain a loop induction variable. This extra check will warn during linking if some of the indexes could not be turned in to constant expressions. v2: warning instead of error for backends that did not enable EmitNoIndirectSampler option (have dynamic indexing) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Francisco Jerez <[email protected]> Cc: "10.5" and "10.6" <[email protected]>