summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Fix buffer overflow with an atomic buffer binding out of range.Eric Anholt2019-01-081-1/+2
| | | | | | | | | | | | | | | | | | | The binding is checked against the limits later in the function, so we need to make sure we don't overflow before the check here. Fixes this valgrind warning (and sometimes segfault): ==1460== Invalid write of size 4 ==1460== at 0x74C98DD: ast_declarator_list::hir(exec_list*, _mesa_glsl_parse_state*) (ast_to_hir.cpp:4943) ==1460== by 0x74C054F: _mesa_ast_to_hir(exec_list*, _mesa_glsl_parse_state*) (ast_to_hir.cpp:159) ==1460== by 0x7435C12: _mesa_glsl_compile_shader (glsl_parser_extras.cpp:2130) in dEQP-GLES31.functional.debug.negative_coverage.get_error.compute. exceed_atomic_counters_limit Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: Fix unmatched TCS outputs being reduced to local variableDanylo Piliaiev2019-01-091-0/+6
| | | | | | | | | | | | Always match TCS outputs since they are shared by all invocations within the patch and should not be converted to local variables. This is one of the issues found in Downward. Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104297
* nir: rename global/local to private/function memoryKarol Herbst2019-01-081-5/+5
| | | | | | | | | | | | | | | | | | the naming is a bit confusing no matter how you look at it. Within SPIR-V "global" memory is memory accessible from all threads. glsl "global" memory normally refers to shader thread private memory declared at global scope. As we already use "shared" for memory shared across all thrads of a work group the solution where everybody could be happy with is to rename "global" to "private" and use "global" later for memory usually stored within system accessible memory (be it VRAM or system RAM if keeping SVM in mind). glsl "local" memory is memory only accessible within a function, while SPIR-V "local" memory is memory accessible within the same workgroup. v2: rename local to function as well v3: rename vtn_variable_mode_local as well Signed-off-by: Karol Herbst <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl_type: Add support for explicitly laid out matrices and arraysJason Ekstrand2019-01-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | SPIR-V allows for matrix and array types to be decorated with explicit byte stride decorations and matrix types to be decorated row- or column-major. This commit adds support to glsl_type to encode this information. Because this doesn't work nicely with std430 and std140 alignments, we add asserts to ensure that we don't use any of the std430 or std140 layout functions with explicitly laid out types. In SPIR-V, the layout information for matrices is applied to the parent struct member instead of to the matrix type itself. However, this is gets rather clumsy when you're walking derefs trying to compute offsets because, the moment you hit a matrix, you have to crawl back the deref chain and find the struct. Instead, we take the same path here as we've taken in spirv_to_nir and put the decorations on the matrix type itself. This also subtly adds support for strided vector types. These don't come up in SPIR-V directly but you can get one as the result of taking a column from a row-major matrix or a row from a column-major matrix. Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl_type: Drop the glsl_get_array_instance C helperJason Ekstrand2019-01-081-1/+1
| | | | | | | | It was added in bce6f9987522 even though it's completely redundant with glsl_array_type(). Reviewed-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* nir: Distinguish between normal uniforms and UBOsJason Ekstrand2019-01-082-3/+6
| | | | | | | | | | | | | | | | Previously, NIR had a single nir_var_uniform mode used for atomic counters, UBOs, samplers, images, and normal uniforms. This commit splits this into nir_var_uniform and nir_var_ubo where nir_var_uniform is still a bit of a catch-all but the nir_var_ubo is specific to UBOs. While we're at it, we also rename shader_storage to ssbo to follow the convention. We need this so that we can distinguish between normal uniforms and UBO access at the deref level without going all the way back variable and seeing if it has an interface type. Reviewed-by: Alejandro Piñeiro <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
* nir: Make gl_nir_lower_samplers use gl_nir_lower_samplers_as_derefKenneth Graunke2019-01-071-47/+28
| | | | | | | | | | | | | | | | | | | | | | | | These days, we have two sampler lowering passes. The newer one, gl_nir_lower_samplers_as_deref, is used by radeonsi. It rewrites variables to drop structures out of sampler deref chains, to make life simpler. It then sets var->data.binding for non-bindless sampler and image variables based on the GL uniform storage's opaque index values. The older one converts sampler deref chains (nir_tex_src_texture_deref) to a numerical offset (nir_tex_src_texture_offset). It also stores the constant-valued portion of that number in tex->texture_index, making life really simple for drivers that don't support indirects. It too pokes at GL uniform storage's opaque index values. Logically, we can do the first pass (simplify derefs, set bindings) then the second (turn derefs to offsets, set texture_index). This patch does exactly that, eliminating some redundancy (only one pass has to poke at GL uniform storage), and gaining proper var->data.binding values for drivers using the full lowering. Reviewed-by: Ian Romanick <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* nir: Fix gl_nir_lower_samplers_as_deref's structure type handling.Kenneth Graunke2019-01-071-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | We recurse to remove structures, and at each step, re-modify the resulting type for our link in the deref chain. For arrays, the result of recursion is the new underlying type - so we wrap it with the array dimensionality again. For structs, we want to simply use the new underlying type, skipping the struct altogether. The correct way to do this is to do nothing at all. Previously, we had reset type to next->type, which is the /old/ field type, not the new field type we obtained by recursing. This undid our recursive work. Fixes about 338 tests with nested structs, such as: dEQP-GLES2.functional.uniform_api.value.initial.get_uniform.nested_structs_arrays.sampler2D_samplerCube_fragment Note that currently only radeonsi uses this pass, and NIR support is disabled there by default, so the breakage was likely not seen by most people. The next commit uses this pass for more drivers, so this fix prevents regressions from that change. Reviewed-by: Ian Romanick <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* glsl: correct typo in GLSL compilation error messageAndres Gomez2019-01-071-1/+1
| | | | | | | | | v2: Add the "fix" tag (Erik). Fixes: 037f68d81e1 ("glsl: apply align layout qualifier rules to block offsets") Cc: Timothy Arceri <[email protected]> Signed-off-by: Andres Gomez <[email protected]> Reviewed-by: Erik Faye-Lund <[email protected]>
* glsl/linker: complete documentation for assign_attribute_or_color_locationsAndres Gomez2019-01-041-9/+13
| | | | | | | | | Commit 27f1298b9d9 ("glsl/linker: validate attribute aliasing before optimizations") forgot to complete the documentation. Cc: Tapani Pälli <[email protected]> Signed-off-by: Andres Gomez <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* nir: Switch to using 1-bit Booleans for almost everythingJason Ekstrand2018-12-161-4/+11
| | | | | | | | | | | | | | | | This is a squash of a few distinct changes: glsl,spirv: Generate 1-bit Booleans Revert "Use 32-bit opcodes in the NIR producers and optimizations" Revert "nir/builder: Generate 32-bit bool opcodes transparently" nir/builder: Generate 1-bit Booleans in nir_build_imm_bool Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]> Tested-by: Bas Nieuwenhuizen <[email protected]>
* nir: Make boolean conversions sized just like the othersJason Ekstrand2018-12-051-1/+1
| | | | | | | | | Instead of a single i2b and b2i, we now have i2b32 and b2iN where N is one if 8, 16, 32, or 64. This leads to having a few more opcodes but now everything is consistent and booleans aren't a weird special case anymore. Reviewed-by: Connor Abbott <[email protected]>
* mesa: expose AMD_texture_texture4Marek Olšák2018-12-043-0/+13
| | | | | | because the closed driver exposes it. Tested by piglit. Reviewed-by: Ilia Mirkin <[email protected]>
* mesa: Revert INTEL_fragment_shader_ordering supportMatt Turner2018-12-035-27/+0
| | | | | | | | | | | | | | | | This extension is not properly tested (testing for GL_ARB_fragment_shader_interlock is not sufficient), and since this was noted in review on August 28th no tests have been sent. Revert "i965: Add INTEL_fragment_shader_ordering support." Revert "mesa: Add GL/GLSL plumbing for INTEL_fragment_shader_ordering" This reverts commit 03ecec9ed2099f6e2b62994b33dc948dc731e7b8. This reverts commit 119435c8778dd26cb7c8bcde9f04b3982239fe60. Cc: [email protected] Acked-by: Jason Ekstrand <[email protected]> Acked-by: Eric Anholt <[email protected]>
* glsl: Remove unused member variableMatt Turner2018-11-271-4/+0
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* glsl: free or reuse memory allocated for TF varyingGert Wollny2018-11-261-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | When a shader program is de-serialized the gl_shader_program passed in may actually still hold memory allocations for the transform feedback varyings. If that is the case, free the varying names and reallocate the new storage for the names array. This fixes a memory leak: Direct leak of 48 byte(s) in 6 object(s) allocated from: in malloc (/usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/libasan.so+0xdb880) in transform_feedback_varyings ../../samba/mesa/src/mesa/main/transformfeedback.c:875 in _mesa_TransformFeedbackVaryings ../../samba/mesa/src/mesa/main/transformfeedback.c:985 ... Indirect leak of 42 byte(s) in 6 object(s) allocated from: in __interceptor_strdup (/usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/libasan.so+0x761c8) in transform_feedback_varyings ../../samba/mesa/src/mesa/main/transformfeedback.c:887 in _mesa_TransformFeedbackVaryings ../../samba/mesa/src/mesa/main/transformfeedback.c:985 Fixes: ab2643e4b06f63c93a57624003679903442634a8 glsl: serialize data from glTransformFeedbackVaryings Signed-off-by: Gert Wollny <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* meson: Add tests to suitesDylan Baker2018-11-202-5/+14
| | | | | | | | | | | | | | | | Meson test has a concepts of suites, which allow tests to be grouped together. This allows for a subtest of tests to be run only (say only the tests for nir). A test can be added to more than one suite, but for the most part I've only added a test to a single suite, though I've added a compiler group that includes nir, glsl, and glcpp tests. To use this you'll need to invoke meson test directly, instead of ninja test (which always runs all targets). it can be invoked as: `meson test -C builddir --suite $suitename` (meson test has addition options that are pretty useful). Tested-By: Gert Wollny <[email protected]> Acked-by: Eric Engestrom <[email protected]>
* nir: Add alignment parameters to SSBO, UBO, and shared accessJason Ekstrand2018-11-151-0/+14
| | | | | | | | | | This also changes spirv_to_nir and glsl_to_nir to set them. The one place that doesn't set them is shared memory access lowering in nir_lower_io. That will have to be updated before any consumers of it can effectively use these new alignments. Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Acked-by: Karol Herbst <[email protected]>
* nir/glsl: Force 32-bit for UBO and SSBO BooleansJason Ekstrand2018-11-151-5/+12
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* glsl: Refactor type checking for redeclarationsIan Romanick2018-11-151-12/+7
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Omit redundant qualifier checks on redeclarationsIan Romanick2018-11-151-6/+3
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: prevent qualifiers modification of predeclared variablesIan Romanick2018-11-151-24/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Section 3.7 (Identifiers) of the GLSL spec says: However, as noted in the specification, there are some cases where previously declared variables can be redeclared to change or add some property, and predeclared "gl_" names are allowed to be redeclared in a shader only for these specific purposes. More generally, it is an error to redeclare a variable, including those starting "gl_". This patch should fix piglit tests: clip-distance-redeclare-without-inout.frag clip-distance-redeclare-without-inout.vert However, this causes a regression in clip-distance-out-values.shader_test. A fix for that test has been sent to the piglit list for review: https://patchwork.freedesktop.org/patch/255201/ As far as I understood following mailing thread: https://lists.freedesktop.org/archives/piglit/2013-October/007935.html looks like we have accepted to remove an ability to change qualifiers but have not done it yet. Unless I missed something) v2 (idr): Move 'earlier->data.mode != var->data.mode' test much earlier in the function. Add special handling for gl_LastFragData. Signed-off-by: Andrii Simiklit <[email protected]> Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/test: Fix use after free in test_optpass.Hanno Böck2018-11-121-1/+4
| | | | | | | | | | | The variable state is free'd and afterwards state->error is used as the return value, resulting in a use after free bug detected by memory safety tools like address sanitizer. Signed-off-by: Hanno Böck <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108636 Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Add pragma to disable all warningsIan Romanick2018-11-088-10/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | Use #pragma warning(off) and #pragma warning(on) to disable or enable all warnings. This is a big hammer. If we ever need a smaller hammer, we can enhance this functionality. There is one lame thing about this. Because we parse everything, create an AST, then convert the AST to GLSL IR, we have to treat the #pragma like a statment. This means that you can't do something like ' void ' #pragma warning(off) ' __foo ' #pragma warning(on) ' (float param0); Fixing that would, as far as I can tell, require a huge amount of work. I did try just handling the #pragma during parsing (like we do for state for the whole shader. v2: Fix the #pragma lines in the commit message that git-commit ate. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add warning tests for identifiers with __Ian Romanick2018-11-082-0/+25
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: do not allow implicit casts of unsized array initializersErik Faye-Lund2018-11-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The GLSL 4.6 specification (section 4.1.14. "Implicit Conversions") says: "There are no implicit array or structure conversions. For example, an array of int cannot be implicitly converted to an array of float." So let's add a check in place when assigning array initializers to implicitly sized arrays, to avoid incorrectly allowing code on the form: int[] foo = float[](1.0, 2.0, 3.0) This fixes the following dEQP test-cases: - dEQP-GLES31.functional.shaders.implicit_conversions.es31.invalid.arrays.int_to_float_vertex - dEQP-GLES31.functional.shaders.implicit_conversions.es31.invalid.arrays.int_to_float_fragment - dEQP-GLES31.functional.shaders.implicit_conversions.es31.invalid.arrays.int_to_uint_vertex - dEQP-GLES31.functional.shaders.implicit_conversions.es31.invalid.arrays.int_to_uint_fragment - dEQP-GLES31.functional.shaders.implicit_conversions.es31.invalid.arrays.uint_to_float_vertex - dEQP-GLES31.functional.shaders.implicit_conversions.es31.invalid.arrays.uint_to_float_fragment - dEQP-GLES31.functional.shaders.implicit_conversions.es32.invalid.arrays.int_to_float_vertex - dEQP-GLES31.functional.shaders.implicit_conversions.es32.invalid.arrays.int_to_float_fragment - dEQP-GLES31.functional.shaders.implicit_conversions.es32.invalid.arrays.int_to_uint_vertex - dEQP-GLES31.functional.shaders.implicit_conversions.es32.invalid.arrays.int_to_uint_fragment - dEQP-GLES31.functional.shaders.implicit_conversions.es32.invalid.arrays.uint_to_float_vertex - dEQP-GLES31.functional.shaders.implicit_conversions.es32.invalid.arrays.uint_to_float_fragment Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* mesa/glsl: add support for EXT_shader_implicit_conversionsErik Faye-Lund2018-11-023-2/+7
| | | | | | | | | | | EXT_shader_implicit_conversions adds support for implicit conversions for GLES 3.1 and above. This is essentially a subset of ARB_gpu_shader5, and augments OES_gpu_shader5. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: fall back to inexact function-matchErik Faye-Lund2018-11-021-1/+6
| | | | | | | | | | | | | | | In GLES, we currently either need an exact match with a local function, or an exact match with a builtin. However, if we add support for implicit conversions for GLES shaders, we also need to fall back to a non-exact match in the case where there were no builtin match either. Luckily, we already have a variable ready with this, so let's just return it if the builtin-search failed. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: add has_implicit_uint_to_int_conversion()-helperErik Faye-Lund2018-11-022-2/+8
| | | | | | | | This makes the code a bit easier to read, as well as reduces repetition, especially when we add support for EXT_shader_implicit_conversions. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: add has_implicit_conversions()-helperErik Faye-Lund2018-11-022-1/+6
| | | | | | | | This makes the code a bit easier to read, as well as will reduce repetition when we add support for EXT_shader_implicit_conversions. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* configure: allow building with python3Emil Velikov2018-10-313-3/+3
| | | | | | | | | | | | | | | Pretty much all of the scripts are python2+3 compatible. Check and allow using python3, while adjusting the PYTHON2 refs. Note: - python3.4 is used as it's the earliest supported version - python2 chosen prior to python3 v2: use python2 by default Cc: Ilia Mirkin <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Acked-by: Eric Engestrom <[email protected]>
* glsl/linker: validate attribute aliasing before optimizationsTapani Pälli2018-10-311-3/+28
| | | | | | | | | | | | | | | | | Patch does a 'dry run' of assign_attribute_or_color_locations before optimizations to catch cases where we have aliasing of unused attributes which is forbidden by the GLSL ES 3.x specifications. We need to run this pass before unused attributes may be removed and with attribute binding information from program, therefore we re-use existing pass in linker rather than attempt to write another one. This fixes WebGL2 test 'gl-bindAttribLocation-aliasing-inactive' and Piglit test 'gles-3.0-attribute-aliasing'. Signed-off-by: Tapani Pälli <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106833 Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Add missing include guardsMichał Janiszewski2018-10-301-0/+5
| | | | | | Signed-off-by: Michał Janiszewski <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl/linker: Fix out variables linking during single stageVadym Shovkoplias2018-10-301-1/+2
| | | | | | | | | | | | | Since out variables are copied from shader objects instruction streams to linked shader instruction steam it should be cloned at first to keep source instruction steam unaltered. Fixes: 966a797e433 ("glsl/linker: Link all out vars from a shader objects on a single stage") Signed-off-by: Vadym Shovkoplias <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105731
* glsl/nir: Use i2b instead of ine for fixing UBO/SSBO BooleansJason Ekstrand2018-10-261-19/+5
| | | | | | | | They do the same thing in the end but i2b is a bit simpler. Also, let's clean up the mess of code for SSBO handling with one line of builder. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* util: use C99 declaration in the for-loop set_foreach() macroEric Engestrom2018-10-252-3/+0
| | | | | Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util: use C99 declaration in the for-loop hash_table_foreach() macroEric Engestrom2018-10-256-8/+0
| | | | | Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: Use nir_src_is_const and nir_src_as_* in core codeJason Ekstrand2018-10-221-5/+2
| | | | Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* glsl: Check the subroutine associated functions namesVadym Shovkoplias2018-10-161-0/+36
| | | | | | | | | | | | | | | | | | | Adding compile time check for subroutine functions with the same names. Similar check for intrastage linking was already landed in commit 5f0567a4f60. From Section 6.1.2 (Subroutines) of the GLSL 4.00 specification "A program will fail to compile or link if any shader or stage contains two or more functions with the same name if the name is associated with a subroutine type." Fixes: * no-overloads.vert Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108109 Signed-off-by: Vadym Shovkoplias <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl/linker: Change the format of spec quotationVadym Shovkoplias2018-10-161-6/+5
| | | | | | | | Also there is no "OpenGL ES Shading Language 4.00" spec, so change it to GLSL 4.00 spec. Signed-off-by: Vadym Shovkoplias <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: remove redundant es_shader checksTimothy Arceri2018-10-111-4/+0
| | | | | | The es check is already covered by the is_version() check. Reviewed-by: Ian Romanick <[email protected]>
* glsl: ignore trailing whitespace when define redefinedTimothy Arceri2018-10-103-3/+25
| | | | | | | | | The Nvidia/AMD binary drivers allow this, as does GCC. This fixes shader compilation issues in the latest update of No Mans Sky. Reviewed-by: Ian Romanick <[email protected]>
* meson: Don't build glsl compiler tests unless OpenGL is enabledDylan Baker2018-10-092-2/+2
| | | | | | Since there are no other users of the glsl compiler. Reviewed-by: Eric Engestrom <[email protected]>
* glsl: fix array assignments of a swizzled vectorIlia Mirkin2018-10-081-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | This happens in situations where we might do vec.wzyx[i] = ... The swizzle would get effectively ignored because of the interaction between how ir_assignment->set_lhs works and overwriting the write_mask. There are two cases, one where i is a constant, and another where i is variable. We have to be extra-careful in both cases. Fixes the following WebGL test: https://www.khronos.org/registry/webgl/sdk/tests/conformance2/glsl3/vector-dynamic-indexing-swizzled-lvalue.html And the new piglit tests: swizzled-writemask-indexing-nonconst.shader_test swizzled-writemask-indexing.shader_test Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Cc: [email protected]
* glsl: do not attempt assignment if operand type not parsed correctlyTapani Pälli2018-10-081-0/+6
| | | | | | | | | v2: check types of both operands (Ian) Cc: [email protected] Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108012
* glsl/linker: Check the subroutine associated functions namesVadym Shovkoplias2018-10-041-0/+40
| | | | | | | | | | | | | | | | | | | | | >From Section 6.1.2 (Subroutines) of the GLSL 4.00 specification "A program will fail to compile or link if any shader or stage contains two or more functions with the same name if the name is associated with a subroutine type." v2: - error out earlier (Tapani) - style fixes (Iago) Fixes: * no-overloads.vert Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108109 Signed-off-by: Vadym Shovkoplias <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Add an assert when cloning ir_dereference_record with invalid fieldDanylo Piliaiev2018-09-201-0/+1
| | | | | Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Avoid propagating incompatible type of initializerDanylo Piliaiev2018-09-201-29/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | do_assignment validated assigment but when rhs type was not compatible it proceeded without issues and returned error_emitted = false. On the other hand process_initializer expected do_assignment to always return compatible type and never fail. As a result when variable was initialized with incompatible type the type of variable changed to the incompatible one. This manifested in unnecessary error messages and in one case in crash. Example GLSL: vec4 tmp = vec2(0.0); tmp.z -= 1.0; Past error messages: initializer of type vec2 cannot be assigned to variable of type vec4 invalid swizzle / mask `z' type mismatch operands to arithmetic operators must be numeric After this patch: initializer of type vec2 cannot be assigned to variable of type vec4 In the other case when we initialize variable with incompatible struct, accessing variable's field leaded to a crash. Example: uniform struct {float field;} data; ... vec4 tmp = data; tmp.x -= 1.0; After the patch there is only error line without a crash: initializer of type #anon_struct cannot be assigned to variable of type vec4 Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107547
* glsl/linker: Check the invariance of built-in special variablesVadym Shovkoplias2018-09-121-0/+66
| | | | | | | | | | | | | | | | | | | | | | From Section 4.6.4 (Invariance and Linkage) of the GLSL ES 1.0 specification "The invariance of varyings that are declared in both the vertex and fragment shaders must match. For the built-in special variables, gl_FragCoord can only be declared invariant if and only if gl_Position is declared invariant. Similarly gl_PointCoord can only be declared invariant if and only if gl_PointSize is declared invariant. It is an error to declare gl_FrontFacing as invariant. The invariance of gl_FrontFacing is the same as the invariance of gl_Position." Fixes: * glsl-pcoord-invariant.shader_test * glsl-fcoord-invariant.shader_test * glsl-fface-invariant.shader_test Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107734 Signed-off-by: Vadym Shovkoplias <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* Replace uses of _mesa_bitcount with util_bitcountDylan Baker2018-09-074-8/+10
| | | | | | | | | | | | | and _mesa_bitcount_64 with util_bitcount_64. This fixes a build problem in nir for platforms that don't have popcount or popcountll, such as 32bit msvc. v2: - Fix additional uses of _mesa_bitcount added after this was originally written Acked-by: Eric Engestrom <[email protected]> (v1) Acked-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>