summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/linker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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: make use glsl_type::is_atomic_uint()Samuel Pitoiset2017-04-211-2/+1
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
* glsl: delay optimisations on individual shaders when cache is availableTimothy Arceri2017-04-151-3/+0
| | | | | | | | | | | | | | | | | | | | | | Due to a max limit of 65,536 entries on the index table that we use to decide if we can skip compiling individual shaders, it is very likely we will have collisions. To avoid doing too much work when the linked program may be in the cache this patch delays calling the optimisations until link time. Improves cold cache start-up times on Deus Ex by ~20 seconds. When deleting the cache index to simulate a worst case scenario of collisions in the index, warm cache start-up time improves by ~45 seconds. V2: fix indentation, make sure to call optimisations on cache fallback, make sure optimisations get called for XFB. Tested-by: Grazvydas Ignotas <[email protected]> Tested-by: Dieter Nützel <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Interface Block instances don't need linking validationAndres Gomez2017-03-271-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From page 45 (page 52 of the PDF) of the GLSL ES 3.00 v.6 spec: " When instance names are present on matched block names, it is allowed for the instance names to differ; they need not match for the blocks to match. From page 51 (page 57 of the PDF) of the GLSL 4.30 v.8 spec: " When instance names are present on matched block names, it is allowed for the instance names to differ; they need not match for the blocks to match." Therefore, no cross linking validation is needed for the instance name of an Interface Block. This patch will make that no link error will be reported on a program like this: "# VS layout(binding = 1) Block1 { vec4 color; } uni_block; ... # FS layout(binding = 2) Block2 { vec4 color; } uni_block; ..." Fixes GL45-CTS.enhanced_layouts.ssb_layout_qualifier_conflict Signed-off-by: Andres Gomez <[email protected]> Cc: Timothy Arceri <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: on UBO/SSBOs link error reset the number of active blocks to 0Andres Gomez2017-03-271-0/+6
| | | | | | | | | | | | | While it's legal to have an active blocks count > 0 on link failure. Unless we actually assign memory for the blocks array we can end up segfaulting in calls such as glUniformBlockBinding(). To avoid having to NULL check these api calls we simply reset the block count to 0 if the array was not created. Signed-off-by: Andres Gomez <[email protected]> Cc: Timothy Arceri <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Raise a link error for non-SSO ES programs with a TES but no TCS.Kenneth Graunke2017-02-231-0/+10
| | | | | | | | | | | | | | | OpenGL allows the TCS to be missing and supplies an implicit passthrough shader, but OpenGL ES does not (see section 7.3 of the ES 3.2 spec, cited above in the code). One open question is how to handle this for ARB_ES3_2_compatibility. This patch raises the link error for all ES shading language programs, but it might make sense to base it on the API. The approach taken in this patch is more restrictive, but should still allow any valid ES programs to work in GL. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Andres Gomez <[email protected]>
* glsl: enable early_fragment_tests implicitly with post_depth_coverageIago Toral Quiroga2017-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | From ARB_post_depth_coverage: "This extension allows the fragment shader to control whether values in gl_SampleMaskIn[] reflect the coverage after application of the early depth and stencil tests. This feature can be enabled with the following layout qualifier in the fragment shader: layout(post_depth_coverage) in; Use of this feature implicitly enables early fragment tests." And a bit later it also adds: "early_fragment_tests" requests that fragment tests be performed before fragment shader execution, as described in section 15.2.4 "Early Fragment Tests" of the OpenGL Specification. If neither this nor post_depth_coverage are declared, per-fragment tests will be performed after fragment shader execution." Fixes: GL45-CTS.post_depth_coverage_tests.PostDepthSampleMask Reviewed-by: Marek Olšák <[email protected]>
* glsl: fix scons builds with shader cacheTimothy Arceri2017-02-171-0/+2
| | | | | For now its disabled for scons so wrap glsl cache calls in a define conditional.
* glsl: don't reprocess or clear UBOs on cache fallbackTimothy Arceri2017-02-171-29/+33
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: skip more uniform initialisation when doing fallback linkingTimothy Arceri2017-02-171-8/+12
| | | | | | | We already pull these values from the metadata cache so no need to recreate them. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: don't reference shader prog data during cache fallbackTimothy Arceri2017-02-171-1/+2
| | | | | | We already have a reference. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add support for caching shaders with xfb qualifiersTimothy Arceri2017-02-171-1/+13
| | | | | | | | For now this disables the shader cache when transform feedback is enabled via the GL API as we don't currently allow for it when generating the sha for the shader. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: make use of on disk shader cacheTimothy Arceri2017-02-171-0/+5
| | | | | | | | | | | | | | | The hash key for glsl metadata is a hash of the hashes of each GLSL source string. This commit uses the put_key/get_key support in the cache put the SHA-1 hash of the source string for each successfully compiled shader into the cache. This allows for early, optimistic returns from glCompileShader (if the identical source string had been successfully compiled in the past), in the hope that the final, linked shader will be found in the cache. This is based on the intial patch by Carl. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Drop resize-to-MaxPatchVertices hack.Kenneth Graunke2017-02-121-32/+0
| | | | | | | | | | | | | | TCS and TES inputs without an array size are implicitly sized to gl_MaxPatchVertices. But TCS outputs are apparently not: "If no size is specified, it will be taken from the output patch size (gl_VerticesOut) declared in the shader." Fixes dEQP-GLES31.functional.program_interface_query.program_output. array_size.separable_tess_ctrl.var. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: Update a comment about link errors for TCS && !TES.Kenneth Graunke2017-02-121-1/+9
| | | | | | | | OpenGL ES actually has spec text to prohibit this. It's just OpenGL that's confusing. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Alejandro Piñeiro <[email protected]>
* st/mesa/i965: create link status enumTimothy Arceri2017-02-091-3/+3
| | | | | | | | | | | | For the on-disk shader cache we want to be able to differentiate between a program that was linked and one that was loaded from cache. V2: - don't return the new enum directly to the application when queried, instead return GL_TRUE or GL_FALSE as required. Fixes google-chrome corruptions when using cache. Reviewed-by: Anuj Phogat <[email protected]>
* glsl: lower constant arrays to uniform arrays before optimisation loopTimothy Arceri2017-01-251-13/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the constant array would not get copy propagated until the backend did its GLSL IR opt loop. I plan on removing that from i965 shortly which caused huge regressions in Deus-ex and Tomb Raider which have large constant arrays. Moving lowering before the opt loop in the GLSL linker fixes this and unexpectedly improves some compute shaders also. shader-db results BDW: instructions helped: shaders/closed/steam/deus-ex-mankind-divided/374.shader_test CS SIMD16: 204 -> 194 (-4.90%) instructions helped: shaders/closed/steam/deus-ex-mankind-divided/318.shader_test CS SIMD8: 1010 -> 741 (-26.63%) instructions helped: shaders/closed/steam/deus-ex-mankind-divided/144.shader_test CS SIMD8: 542 -> 385 (-28.97%) cycles helped: shaders/closed/steam/deus-ex-mankind-divided/318.shader_test CS SIMD8: 1831382 -> 1818492 (-0.70%) cycles helped: shaders/closed/steam/deus-ex-mankind-divided/144.shader_test CS SIMD8: 216238 -> 206180 (-4.65%) cycles helped: shaders/closed/steam/deus-ex-mankind-divided/374.shader_test CS SIMD16: 18484 -> 16644 (-9.95%) total instructions in shared programs: 13060313 -> 13059877 (-0.00%) instructions in affected programs: 1756 -> 1320 (-24.83%) helped: 3 HURT: 0 total cycles in shared programs: 256586698 -> 256561910 (-0.01%) cycles in affected programs: 2066104 -> 2041316 (-1.20%) helped: 3 HURT: 0 V3: only call the opt loop if lowering progressed (Suggested by Eric) V2: call opts before and after lowering (Suggested by Ken) Reviewed-by: Eric Anholt <[email protected]>
* glsl: fix tes linking regressionTimothy Arceri2017-01-231-2/+2
| | | | | Fixes regression caused by cbeba6bd48da2c. I accidentally pushed the wrong version of the patch.
* mesa/glsl: set and get cs layouts to and from shader_infoTimothy Arceri2017-01-231-20/+15
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa/glsl: set and get gs layouts directly to and from shader_infoTimothy Arceri2017-01-231-33/+37
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa/glsl/i965: set and get tes layouts directly to and from shader_infoTimothy Arceri2017-01-231-31/+33
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use last_vert_prog to get last {clip,cull}_distance_array_sizeTimothy Arceri2017-01-231-14/+0
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa/glsl: set {clip,cull}_distance_array_size directly in gl_programTimothy Arceri2017-01-231-16/+16
| | | | | | | There are some line wrapping violations here but those lines will get deleted in the following patch. Reviewed-by: Nicolai Hähnle <[email protected]>
* st/mesa/glsl: change xfb_program field to last_vert_progTimothy Arceri2017-01-231-24/+23
| | | | | | | | | | Now that the i965 backend doesn't depend on this field we can make it more generic and short circuit a bunch of code paths. The new field will be used in a following patch for another clean-up. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: Move builtin_function related prototypes to a separate fileIan Romanick2017-01-201-0/+1
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* mesa/glsl: move TransformFeedbackBufferStride to gl_shaderTimothy Arceri2017-01-191-37/+34
| | | | | | | | | | Here we remove the single use of this field in gl_linked_shader which allows us to move the field out of gl_shader_info While we are at it we rewrite link_xfb_stride_layout_qualifiers() to be more clear. Reviewed-by: Lionel Landwerlin <[email protected]>
* glsl: set InnerCoverage directly in gl_programTimothy Arceri2017-01-191-2/+1
| | | | | | Also move out of the shared gl_shader_info. Reviewed-by: Lionel Landwerlin <[email protected]>
* glsl: tidy up PostDepthCoverage shader fieldTimothy Arceri2017-01-191-1/+1
| | | | | | | There is no reason for this to be in the shared gl_shader_info or to copy it to gl_program at the end of linking (its already there). Reviewed-by: Lionel Landwerlin <[email protected]>
* mesa/glsl: move pixel_center_integer to gl_shaderTimothy Arceri2017-01-191-5/+3
| | | | | | | This is only used by gl_linked_shader as a temp during linking so use a temp there instead. Reviewed-by: Lionel Landwerlin <[email protected]>
* mesa/glsl: move origin_upper_left to gl_shaderTimothy Arceri2017-01-191-5/+3
| | | | | | | This is only used by gl_linked_shader as a temp during linking so use a temp there instead. Reviewed-by: Lionel Landwerlin <[email protected]>
* mesa/glsl: move uses_gl_fragcoord to gl_shaderTimothy Arceri2017-01-191-7/+5
| | | | | | | This is only used by gl_linked_shader as a temp during linking so use a temp there instead. Reviewed-by: Lionel Landwerlin <[email protected]>
* mesa/glsl: move redeclares_gl_fragcoord to gl_shaderTimothy Arceri2017-01-191-13/+8
| | | | | | | This is never used in gl_linked_shader other than as a temp during linking so just use a temp instead. Reviewed-by: Lionel Landwerlin <[email protected]>
* mesa/glsl: move ARB_fragment_coord_conventions_enable fieldTimothy Arceri2017-01-191-1/+1
| | | | | | | This is only used by gl_shader not gl_linked_shader so move it there. Reviewed-by: Lionel Landwerlin <[email protected]>
* st/mesa/glsl: set early_fragment_tests directly in shader_infoTimothy Arceri2017-01-191-2/+2
| | | | | | | We also move EarlyFragmentTests out of the gl_shader_info struct as it is now only used by gl_shader. Reviewed-by: Lionel Landwerlin <[email protected]>
* mesa/glsl/i965: set and use tcs vertices_out directlyTimothy Arceri2017-01-191-12/+12
| | | | Reviewed-by: Lionel Landwerlin <[email protected]>
* mesa/glsl: move ProgramResourceList to gl_shader_program_dataTimothy Arceri2017-01-191-10/+10
| | | | | | | | | | We also move NumProgramResourceList at the same time. GLES does interface validation on SSO at runtime so we need to move this to be able to switch to storing gl_program pointers in CurrentProgram. Reviewed-by: Lionel Landwerlin <[email protected]>
* glsl: store number of explicit uniform loactions in gl_shader_programTimothy Arceri2017-01-191-15/+12
| | | | | | | | | This allows us to cleanup the functions that pass this count around, but more importantly we will be able to call the uniform linking functions from that backends linker without having to pass this information to the backend directly via Driver.LinkShader(). Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: create a new link_and_validate_uniforms() helperTimothy Arceri2017-01-191-9/+17
| | | | | | | | | Currently this just breaks up the linking code a bit but in the future i965 will call this from the backend via Driver.LinkShader() so that we can do NIR optimisations before assigning uniform locations. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: move more varying linking code to link_varyings.cppTimothy Arceri2017-01-191-148/+1
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* st/mesa/glsl: set num_images directly in shader_infoTimothy Arceri2017-01-091-3/+4
| | | | | | This change also removes the now duplicate NumImages field. Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa: Introduce a compiler enum for tessellation spacing.Kenneth Graunke2017-01-071-3/+3
| | | | | | | | | | It feels weird using GL_* enums in a Vulkan driver. v2: Fix the TESS_SPACING -> PIPE_TESS_SPACING conversion. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* Revert recent GLSL slot counting fiasco.Kenneth Graunke2017-01-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | I apparently broke mark_whole_variable in ir_set_program_inouts. It was passing a type that wasn't var->type, so the wrapper didn't work out. It's all broken, revert it and start over. Fixes all kinds of things on other drivers. Revert "glsl: Make is_fixed_function_array actually check for varyings." This reverts commit 42699e12711668a142b7acf11c168cf4301c1295. Revert "glsl: Mark whole variable used for ClipDistance and TessLevel*." This reverts commit 5c580e64cc206ab160e1767c42e4d6c81f67da4d. Revert "glsl: Override the # of varying slots for ClipDistance and TessLevel*." This reverts commit 8b5749f65ac434961308ccb579fb8a816e4f29d5. Revert "glsl: Create and use a new ir_variable::count_attribute_slots() wrapper." This reverts commit 6aa5cb34d03765b7be8611aa516bc201bd337f73.
* glsl: Create and use a new ir_variable::count_attribute_slots() wrapper.Kenneth Graunke2017-01-061-3/+3
| | | | | | | | | This wraps glsl_type::count_attribute_slots(), but will soon contain a couple of overrides for a couple of GLSL built-ins variables. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa/glsl: set num_textures per stage directly in shader_infoTimothy Arceri2017-01-061-1/+2
| | | | Reviewed-by: Eric Anholt <[email protected]>
* st/mesa/glsl: add new is_arb_asm flag in gl_programTimothy Arceri2017-01-061-1/+1
| | | | | | | | | | | | | | | | Set the flag via the _mesa_init_gl_program() and NewProgram() helpers. In i965 we currently check for the existance of gl_shader_program to decide if this is an ARB assembly style program or not. Adding a flag makes the code clearer and will help removes a dependency on gl_shader_program in the i965 codegen functions. Also this will allow use to skip initialising sampler units for linked shaders, we currently memset it to zero again during linking. Reviewed-by: Eric Anholt <[email protected]>
* st/mesa/glsl/i965: move ShaderStorageBlocks to gl_programTimothy Arceri2017-01-061-4/+5
| | | | | | | | | | | | Having it here rather than in gl_linked_shader allows us to simplify the code. Also it is error prone to depend on the gl_linked_shader for programs in current use because a failed linking attempt will free infomation about the current program. In i965 we could be trying to recompile a shader variant but may have lost some required fields. Reviewed-by: Lionel Landwerlin <[email protected]>
* st/mesa/glsl/i965: set num_ssbos directly in shader_infoTimothy Arceri2017-01-061-7/+7
| | | | | | | Here we also remove the duplicate field in gl_linked_shader and always get the value from shader_info instead. Reviewed-by: Lionel Landwerlin <[email protected]>
* st/mesa/glsl/i965: move per stage UniformBlocks to gl_programTimothy Arceri2017-01-061-4/+4
| | | | | | | This will help allow us to store pointers to gl_program structs in the CurrentProgram array resulting in a bunch of code simplifications. Reviewed-by: Lionel Landwerlin <[email protected]>
* st/mesa/glsl/i965: set num_ubos directly in shader_infoTimothy Arceri2017-01-061-7/+7
| | | | | | | This also removes the duplicate field in gl_linked_shader, and gets num_ubos from shader_info instead. Reviewed-by: Lionel Landwerlin <[email protected]>
* mesa: add gl_constants::GLSLOptimizeConservativelyMarek Olšák2017-01-051-4/+12
| | | | | | to reduce the amount of GLSL optimizations for drivers that can do better. Reviewed-by: Eric Anholt <[email protected]>