summaryrefslogtreecommitdiffstats
path: root/src/glsl/linker.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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]>
* Revert "glsl: clone inputs and outputs during linking"Kenneth Graunke2015-06-281-3/+1
| | | | | | | | | | | This reverts commit c2ff3485b3d48749ea9dcad07bc1a691627dc3e5. Ilia and I noticed a memory leak caused by this patch: at least with fixed-function programs, we clone things using ProgramResourceList as the context before reralloc makes it non-NULL. I believe Tapani found other bugs with these patches, so I'm just going to revert them for now and let him pursue them further.
* glsl: clone inputs and outputs during linkingTapani Pälli2015-06-241-1/+3
| | | | | | | | | | | This increases memory pressure during linking but makes it easier for backend to free IR after it is not needed anymore. v2: use resource list as ralloc context in case of relink (Kenneth) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: [email protected]
* glsl: Fail linkage when UBO exceeds GL_MAX_UNIFORM_BLOCK_SIZE.Jose Fonseca2015-06-191-0/+7
| | | | | | | | | | | | | | | | | | | | | | | It's not totally clear whether other Mesa drivers can safely cope with over-sized UBOs, but at least for llvmpipe receiving a UBO larger than its limit causes problems, as it won't fit into its internal display lists. This fixes piglit "arb_uniform_buffer_object-maxuniformblocksize fsexceed" without regressions for llvmpipe. NVIDIA driver also fails to link the shader from "arb_uniform_buffer_object-maxuniformblocksize fsexceed". Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65525 PS: I don't recommend cherry-picking this for Mesa stable, as some app might inadvertently been relying on UBOs larger than GL_MAX_UNIFORM_BLOCK_SIZE to work on other drivers, so even if this commit is universally accepted it's probably best to let it mature in master for a while. Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: reference built-in uniforms into gl_uniform_storageMartin Peres2015-06-041-3/+3
| | | | | | | | | | | | | | | This change introduces a new field in gl_uniform_storage to explicitely say that a uniform is built-in. In the case where it is, no storage is defined to make it clear that it is read-only from the mesa side. I fixed all the places in the code that made use of the structure that I changed. Any place making a wrong assumption and using the storage straight away will just crash. This patch seems to implement the path of least resistance towards listing built-in uniforms in GL_ACTIVE_UNIFORM (and other APIs). Reviewed-by: Tapani Pälli <[email protected]> Signed-off-by: Martin Peres <[email protected]>
* glsl: avoid leaking linked gl_shader when there's a late linker errorIlia Mirkin2015-05-251-2/+8
| | | | | | | | | | This makes piglit mixing-clip-distance-and-clip-vertex-disallowed have 0 definitely lost blocks with valgrind. (Same non-0 number of possibly lost blocks though.) Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Tobias Klausmann <[email protected]> Cc: "10.5 10.6" <[email protected]>
* glsl: remove element_type() helperTimothy Arceri2015-05-221-2/+2
| | | | | | | | | | | | | | We now have is_array() and without_array() that make the code much clearer and remove the need for this. For all remaining calls to this we already knew that the type was an array so returning a null wasn't adding any value. v2: use without_array() in _mesa_ast_array_index_to_hir() and don't use without_array() in lower_clip_distance_visitor() as we want to make sure the array is 2D. Reviewed-by: Matt Turner <[email protected]>
* glsl: add stage references for UBO uniformsTapani Pälli2015-05-181-0/+10
| | | | | | | | Patch marks uniforms inside UBO properly referenced by stages. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Samuel Iglesias Gonsalvez <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90397
* glsl: check total count of multi-slot double vertex attribsDave Airlie2015-05-081-1/+40
| | | | | | | | | | | | The spec is vague all over the place about this, but this seems to be the intent, we can probably make this optional later if someone makes hw that cares and writes a driver. Basically we need to double count some of the d types but only for totalling not for slot number assignment. Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: mark special built-in inputs referenced by vertex stageTapani Pälli2015-05-061-1/+6
| | | | | | | | | | | | | | | Refactoring done on active attribute queries did not take in to account special built-in inputs for the vertex stage. This commit sets them referenced by vertex stage so that they get enumerated properly. Fixes Piglit test 'get-active-attrib-returns-all-inputs' failure. Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90243 Acked-by: Jose Fonseca <[email protected]> Tested-by: Dieter Nützel <[email protected]> Reviewed-By: Martin Peres <[email protected]>
* glsl: Keep track of the early_fragment_tests flag in gl_shader.Francisco Jerez2015-05-041-0/+2
| | | | | | | | And rename _mesa_glsl_parse_state::early_fragment_tests to fs_early_fragment_tests for consistency with other FS-specific flags in the same struct. Reviewed-by: Matt Turner <[email protected]>
* glsl: correct indentation of comment, Trivial.Tapani Pälli2015-04-211-1/+1
| | | | Signed-off-by: Tapani Pälli <[email protected]>
* glsl: add fallthrough comment on switchTapani Pälli2015-04-211-1/+2
| | | | | Signed-off-by: Tapani Pälli <[email protected]> Reviewed-By: Martin Peres <[email protected]>
* mesa,glsl: rename `interface` to `programInterface`.Jose Fonseca2015-04-161-4/+4
| | | | | | | | | | | | | | | | | `interface` is a define on Windows -- an alias for `struct` keyword, used when declaring COM interfaces in C or C++. So use instead `programInterface`, therefore matching the name used in GL_ARB_program_interface_query spec/headers, which was renamed exactly for the same reason: "Revision 10, May 10, 2012 (pbrown) - Rename the formal parameter <interface> used by the functions in this extension to <programInterface>. Certain versions of the Microsoft C/C++ compiler and/or its headers cause "interface" to be treated as a reserved keyword." Trivial.
* mesa/glsl: build list of program resources during linkingTapani Pälli2015-04-161-0/+192
| | | | | | | | | | | | | | | | Patch adds ProgramResourceList to gl_shader_program structure. List contains references to active program resources and is constructed during linking phase. This list will be used by follow-up patches to implement hooks for GL_ARB_program_interface_query. It can be also used to implement any of the older shader program query APIs. v2: code cleanups + note for SSBO and subroutines (Ilia Mirkin) v3: code cleanups + assert(MESA_SHADER_STAGES < 8) (Martin Peres) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Martin Peres <[email protected]>
* linker: fix varying linking if SSO program has only gs and fsTapani Pälli2015-04-161-12/+17
| | | | | | | | | | | | | | | | Previously linker did not take in to account case where one would have only gs and fs (with SSO), patch adds the case by refactoring code around assign_varying_locations. This makes sure locations for gs get populated correctly. This was found with some of the SSO subtests of Martin's upcoming GetProgramInterfaceiv Piglit test which passes with the patch, no Piglit regressions. v2: code cleanups (Martin Peres) Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Martin Peres <[email protected]>
* glsl: Generate link error for non-matching gl_FragCoord redeclarationsAnuj Phogat2015-03-241-13/+2
| | | | | | | | | | | in different fragment shaders. This also applies to a case when gl_FragCoord is redeclared with no layout qualifiers in one fragment shader and not declared but used in other fragment shader. Signed-off-by: Anuj Phogat <[email protected]> Khronos Bug#12957 Cc: "10.5" <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* glsl: Avoid GLboolean vs bool arithmetic MSVC warnings.Jose Fonseca2015-03-221-2/+3
| | | | | | | | | | | | | Note that GLboolean is an alias for unsigned char, which lacks the implicit true/false semantics that C++/C99 bool have. Reviewed-by: Brian Paul <[email protected]> v2: Change gl_shader::IsES and gl_shader_program::IsES to be bool as recommended by Ian Romanick. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>