summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* glsl: fix subroutine mismatch between declarations/definitionsSamuel Pitoiset2017-03-035-8/+18
| | | | | | | | | | | | | | | | | | | | | Previously, when q.subroutine was set to 1, a new subroutine declaration was added to the AST, while 0 meant a subroutine definition has been detected by the parser. Thus, setting the q.subroutine flag in both situations is obviously wrong because a new type identifier is added instead of trying to match the declaration. To fix it up, introduce ast_type_qualifier::is_subroutine_decl() to differentiate declarations and definitions easily. This fixes a regression with: arb_shader_subroutine/compiler/direct-call.vert Cc: Mark Janes <[email protected]> Fixes: be8aa76afd ("glsl: remove unecessary flags.q.subroutine_def") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100026 Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* i965: Do int64 lowering in NIRJason Ekstrand2017-03-011-54/+53
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir: Add a simple int64 lowering passJason Ekstrand2017-03-013-0/+289
| | | | | | | | | | | | | | | | | | The algorithms used by this pass, especially for division, are heavily based on the work Ian Romanick did for the similar int64 lowering pass in the GLSL compiler. v2: Properly handle vectors v3: Get rid of log2_denom stuff. Since we're using bcsel, we do all the calculations anyway and this is just extra instructions. v4: - Add back in the log2_denom stuff since it's needed for ensuring that the shifts don't overflow. - Rework the looping part of the pass to be easier to expand. Reviewed-by: Matt Turner <[email protected]>
* spirv: Use nir_builder for control flowJason Ekstrand2017-03-011-31/+14
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir/lower_indirect: Use nir_builder control-flow helpersJason Ekstrand2017-03-011-30/+5
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir/lower_gs_intrinsics: Use nir_builder control-flow helpersJason Ekstrand2017-03-011-6/+3
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl/nir: Use nir_builder's new control-flow helpersJason Ekstrand2017-03-011-27/+11
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* nir/builder: Add support for easily building control-flowJason Ekstrand2017-03-011-0/+95
| | | | | | | | | | | Each of the pop functions (and push_else) take a control flow parameter as their second argument. If NULL, it assumes that the builder is in a block that's a direct child of the control-flow node you want to pop off the virtual stack. This is what 90% of consumers will want. The SPIR-V pass, however, is a bit more "creative" about how it walks the CFG and it needs to be able to pop multiple levels at a time, hence the argument. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl/int64: Fix a typo in imod64Jason Ekstrand2017-03-012-15/+9
| | | | | | | The zy swizzle gives us one component of quotient and one component of remainder. What we wanted was zw for the remainder. Reviewed-by: Matt Turner <[email protected]>
* glsl: remove unecessary flags.q.subroutine_defSamuel Pitoiset2017-03-015-10/+7
| | | | | | | | | | | | | | | This bit is definitely not necessary because subroutine_list can be used instead. This frees one more bit in the flags.q struct which is nice because arb_bindless_texture will need 4 bits for the new layout qualifiers. No piglit regressions found (including compiler tests) with "-t subroutine". v2: set the subroutine flag for validating illegal flags Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* compiler: Free types in _mesa_glsl_release_types() rather than autofree.Kenneth Graunke2017-02-271-1/+4
| | | | | | | | | | | | | | | | | Instead of using ralloc_autofree_context() to install an atexit() handler to ralloc_free(glsl_type::mem_ctx), we can simply free them from _mesa_glsl_release_types(). This is effectively the same, because _mesa_glsl_release_types() is called from _mesa_destroy_shader_compiler(), which is called from Mesa's one_time_fini() function, which Mesa installs as an atexit() handler. The one advantage here is that it ensures the built-in functions are destroyed before the types. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
* glsl: reject samplers not declared as uniform/function params earlierSamuel Pitoiset2017-02-271-0/+9
| | | | | | | | | | | | | | This improves consistency with image variables and atomic counters which are already rejected the same way. Note that opaque variables can't be treated as l-values, which means only the 'in' function parameter is allowed. v2: rewrite commit message Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> (v1) Reviewed-by: Marek Olšák <[email protected]> (v2)
* glsl: use is_sampler() anywhere it's possibleSamuel Pitoiset2017-02-274-16/+15
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: use is_image() anywhere it's possibleSamuel Pitoiset2017-02-272-3/+2
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: add missing blend_support qualifier in validate_flags()Samuel Pitoiset2017-02-271-1/+2
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Andres Gomez <[email protected]>
* glsl: use an enum for AMD_conservative_depth layout qualifiersSamuel Pitoiset2017-02-274-35/+40
| | | | | | | | | | | | | | | | | | | | | | | The main idea behind this is to free some bits in the flags.q struct because currently all 64-bits are used and we can't add more layout qualifiers without reaching a static assert. In order to do that (mainly for ARB_bindless_texture), use an enumeration for the AMD_conservative_depth layout qualifiers because it's forbidden to declare more than one depth qualifier for gl_FragDepth. Note that ast_type_qualifier::merge_qualifier() will prevent using duplicate layout qualifiers by returning a compile-time error. No piglit regressions found (including compiler tests) with RX480 on RadeonSI. v2: use a switch case Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Andres Gomez <[email protected]> (v1)
* glsl: add has_shader_image_load_store()Samuel Pitoiset2017-02-273-4/+7
| | | | | | | | Preliminary work for ARB_bindless_texture which can interact with ARB_shader_image_load_store. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Anuj Phogat <[email protected]>
* nir: Delete unused arg in get_iterationElie TOURNIER2017-02-271-2/+2
| | | | | | | nir_const_value is not needed in get_iteration Signed-off-by: Elie Tournier <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
* compiler: style clean-ups in blob.hTimothy Arceri2017-02-251-21/+21
| | | | Reviewed-by: Elie Tournier <[email protected]>
* glsl: Fix missing-braces warning.Vinson Lee2017-02-241-1/+1
| | | | | | | | | CXX glsl/ast_to_hir.lo glsl/ast_to_hir.cpp: In member function 'virtual ir_rvalue* ast_declarator_list::hir(exec_list*, _mesa_glsl_parse_state*)': glsl/ast_to_hir.cpp:4846:42: warning: missing braces around initializer for 'unsigned int [16]' [-Wmissing-braces] Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Andres Gomez <[email protected]>
* nir: delete magic numberElie TOURNIER2017-02-241-1/+11
| | | | | Signed-off-by: Elie Tournier <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: automake: add the README to the tarballEmil Velikov2017-02-241-0/+1
| | | | | | | | | Similar to other accompanying documentation we have in-tree. For example glsl/README. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Andreas Boll <[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: refactor get_variable_being_redeclared() to return always an ↵Samuel Iglesias Gonsálvez2017-02-231-27/+34
| | | | | | | | | | | | | ir_variable pointer It will return the current variable ('var') or the earlier declaration ('earlier') in case of redeclaration of that variable. In order to distinguish between both, 'is_redeclaration' boolean will indicate in which case we are. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* glsl: fix heap-use-after-free in ast_declarator_list::hir()Samuel Iglesias Gonsálvez2017-02-231-2/+4
| | | | | | | | | | | | | | | | | | | | | The get_variable_being_redeclared() function can free 'var' because a re-declaration of an unsized array variable can establish the size, so we set the array type to the 'earlier' declaration and free 'var' as it is not needed anymore. However, the same 'var' is referenced later in ast_declarator_list::hir(). This patch fixes it by picking the ir_variable_mode from the proper ir_variable. This error was detected by Address Sanitizer. Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Suggested-by: Ian Romanick <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99677 Cc: "17.0" <[email protected]> Cc: "13.0" <[email protected]>
* util/disk_cache: create timestamp and gpu_id dirs when MESA_GLSL_CACHE_DIR ↵Timothy Arceri2017-02-221-0/+40
| | | | | | | | is used The make check test is also updated to make sure these dirs are created. Reviewed-by: Nicolai Hähnle <[email protected]>
* nir: do not #include util/debug.h within extern C {}Emil Velikov2017-02-211-1/+4
| | | | | | | | It's a problem waiting to happen. Individual headers should be annotated if needed. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: resolve extern C workarounds/hacksEmil Velikov2017-02-213-8/+4
| | | | | | | | Do not wrap header inclusion in extern C since it can cause issues. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl/tests: Add UINT64 and INT64 typesRhys Kidd2017-02-211-0/+18
| | | | | | | | | | | | glsl/tests/uniform_initializer_utils.cpp:83:14: warning: enumeration value ‘GLSL_TYPE_UINT64’ not handled in switch [-Wswitch] switch (type->base_type) { ^ glsl/tests/uniform_initializer_utils.cpp:83:14: warning: enumeration value ‘GLSL_TYPE_INT64’ not handled in switch [-Wswitch] Fixes: 8ce53d4a2f3 ("glsl: Add basic ARB_gpu_shader_int64 types") Signed-off-by: Rhys Kidd <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Elie Tournier <[email protected]>
* android: glsl: build shader cache sourcesMauro Rossi2017-02-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Fixes the following building errors: external/mesa/src/compiler/glsl/linker.cpp:4642: error: undefined reference to 'shader_cache_read_program_metadata(gl_context*, gl_shader_program*)' external/mesa/src/mesa/program/ir_to_mesa.cpp:3135: error: undefined reference to 'shader_cache_write_program_metadata(gl_context*, gl_shader_program*)' clang++: error: linker command failed with exit code 1 ... external/mesa/src/mesa/program/ir_to_mesa.cpp:3135: error: undefined reference to 'shader_cache_write_program_metadata(gl_context*, gl_shader_program*)' external/mesa/src/compiler/glsl/linker.cpp:4642: error: undefined reference to 'shader_cache_read_program_metadata(gl_context*, gl_shader_program*)' clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. build/core/ninja.mk:148: recipe for target 'ninja_wrapper' failed make: *** [ninja_wrapper] Error 1 Fixes: 9f8dc3bf03e ("utils: build sha1/disk cache only with Android/Autoconf") Acked-by: Emil Velikov <[email protected]>
* glsl: link error if unsized array not-last in ssboJose Maria Casanova Crespo2017-02-171-1/+7
| | | | | | | | | | | | | | | | | | | | | | If an unsized declared array is not the last in an SSBO and an implicit size can not be defined on linking time, the linker should raise an error instead of reaching an assertion on GL. This reverts part of commit 3da08e166415a745139c1127040a24e8a45dc553 getting back to the behavior of commit 5b2675093e863a52b610f112884ae12d42513770 The original patch was correct for GLES that should produce a compile-time error but the linker error is still necessary in desktop GL. Fixes the following piglit tests: tests/spec/arb_shader_storage_buffer_object/non_integral_size_array_member.shader_test tests/spec/arb_shader_storage_buffer_object/unsized_array_member.shader_test Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Signed-off-by: Jose Maria Casanova Crespo <[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.
* nir/algebraic: Optimize 64bit pack/unpackJason Ekstrand2017-02-161-0/+6
| | | | | | This reduces the instruction count in some fp64 and int64 piglit tests Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Rename lower_double_pack to lower_64bit_packJason Ekstrand2017-02-163-6/+5
| | | | | | | There's nothing "double" about it other than, perhaps, the fact that it packs two 32-bit values. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Combine the int and double [un]pack opcodesJason Ekstrand2017-02-167-73/+35
| | | | | | | NIR is a typeless IR and the two opcodes, when considered bitwise, do exactly the same thing. There's no reason to have two versions. Reviewed-by: Kenneth Graunke <[email protected]>
* util/disk_cache: allow drivers to pass a directory structureTimothy Arceri2017-02-171-10/+10
| | | | | | | | | | | | | | In order to avoid costly fallback recompiles when cache items are created with an old version of Mesa or for a different gpu on the same system we want to create directories that look like this: ./{TIMESTAMP}_{LLVM_TIMESTAMP}/{GPU_ID} Note: The disk cache util will take a single timestamp string, it is up to the backend to concatenate the llvm string with the mesa string if applicable. Reviewed-by: Nicolai Hähnle <[email protected]>
* st/mesa/glsl: build string of dri options and use as input to building sha ↵Timothy Arceri2017-02-171-0/+6
| | | | | | for shaders Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: reserve parameter storage on cache restoreTimothy Arceri2017-02-171-0/+1
| | | | | | | Since we know how big the list will be we can allocate the storage upfront. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: don't try to load/store buffer object values in the cacheTimothy Arceri2017-02-171-2/+11
| | | | | | Also add an assert to catch buffer overflows. Reviewed-by: Nicolai Hähnle <[email protected]>
* 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 lose uniform values when falling back to full compileTimothy Arceri2017-02-171-8/+23
| | | | | | | | | Here we skip the recreation of uniform storage if we are relinking after a cache miss. This is improtant because uniform values may have already been set by the application and we don't want to reset 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]>
* mesa/glsl: add cache_fallback flag to gl_shader_program_dataTimothy Arceri2017-02-171-1/+1
| | | | | | | | | | | This will allow us to skip certain things when falling back to a full recompile on a cache miss such as avoiding reinitialising uniforms. In this change we use it to avoid reading the program metadata from the cache and skipping linking during a fallback. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add api and glsl version to hash generation for shadersTimothy Arceri2017-02-171-0/+8
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: cache uniform valuesTimothy Arceri2017-02-171-0/+33
| | | | | | | These may be lowered constant arrays or uniform values that we set before linking so we need to cache the actual uniform values. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: make uniform values helper available for use elsewhereTimothy Arceri2017-02-172-1/+4
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: cache some more image metadataTimothy Arceri2017-02-171-0/+10
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: add support for caching atomic buffersTimothy Arceri2017-02-171-0/+89
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>