summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* spirv: Claim support for the simple memory modelJason Ekstrand2017-10-261-1/+2
| | | | | | | | | | It's rather surprising that we've never actually hit this before. Aparently, Ian's SPIR-V generator currently claims the Simple when you don't do anything complex. We really shouldn't assert-fail on it. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]> Cc: [email protected]
* glsl/linker: Fix type checks for location aliasingIago Toral Quiroga2017-10-261-3/+19
| | | | | | | | | | | | | | From the OpenGL 4.6 spec, section 4.4.1 Input Layout Qualifiers, Page 68, (Location aliasing): "Further, when location aliasing, the aliases sharing the location must have the same underlying numerical type (floating-point or integer)." The current implementation is too strict, since it checks that the the base types are an exact match instead. Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/linker: refactor check_location_aliasingIago Toral Quiroga2017-10-261-64/+46
| | | | | | | Mostly, this merges the type checks with all the other checks so we only have a single loop for this. Acked-by: Ilia Mirkin <[email protected]>
* glsl/linker: validate explicit locations for SSO programsIago Toral Quiroga2017-10-263-0/+71
| | | | | | | | | | | v2: - we only need to validate inputs to the first stage and outputs from the last stage, everything else has already been validated during cross_validate_outputs_to_inputs (Timothy). - Use MAX_VARYING instead of MAX_VARYINGS_INCL_PATCH (Illia) Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/linker: generalize validate_explicit_variable_location for SSOIago Toral Quiroga2017-10-261-2/+16
| | | | | | | | | | | | | | | | | | | For non-SSO programs, we only need to validate outputs, since the cross validation of outputs to inputs will ensure that we produce linker errors for invalid inputs too. Hoever, for the SSO path there is no output to input validation, so we need to validate inputs explicitly. Generalize the function so it can handle this as well. Also, notice that vertex shader inputs and fragment shader outputs are already validated in assign_attribute_or_color_locations() for both SSO and non-SSO paths, so we should not try to validate that here again (in fact, the function would require explicit paths to handle these two cases properly). Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/linker: create a helper function to validate explicit locationsIago Toral Quiroga2017-10-261-39/+55
| | | | | | | | | Currently, we only validate explicit locations for non-SSO programs. This creates a helper that we can call from both SSO and non-SSO paths directly, so we can reuse all the logic behind this. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/linker: outputs in the same location must share auxiliary storageIago Toral Quiroga2017-10-261-6/+30
| | | | | | | | | | | | | | | | | | From ARB_enhanced_layouts: "[...]when location aliasing, the aliases sharing the location must have the same underlying numerical type (floating-point or integer) and the same auxiliary storage and interpolation qualification.[...]" Add code to the linker to validate that aliased locations do have the same aux storage. Fixes: KHR-GL45.enhanced_layouts.varying_location_aliasing_with_mixed_auxiliary_storage Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/linker: outputs in the same location must share interpolationIago Toral Quiroga2017-10-261-4/+41
| | | | | | | | | | | | | | | | | From ARB_enhanced_layouts: "[...]when location aliasing, the aliases sharing the location must have the same underlying numerical type (floating-point or integer) and the same auxiliary storage and interpolation qualification.[...]" Add code to the linker to validate that aliased locations do have the same interpolation. Fixes: KHR-GL45.enhanced_layouts.varying_location_aliasing_with_mixed_interpolation Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: fix location aliasing checks for interface variablesIago Toral Quiroga2017-10-261-12/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing code was checking the whole interface variable rather than its members, which is not what we want: we want to check aliasing for each member in the interface variable. Surprisingly, there are piglit tests that verify this and were passing due to a bug in the existing code: when we were computing the last component used by an interface variable we would use the 'vector' path and multiply by vector_elements, which is 0 for interface variables. This made the loop that checks for aliasing be a no-op and not add the interface variable to the list of outputs so then we would fail to link when we did not see a matching output for the same input in the next stage. Since the tests expect a linker error to happen, they would pass, but not for the right reason. Unfortunately, the current implementation uses ir_variable instances to keep track of explicit locations. Since we don't have ir_variables instances for individual interface members, we need to have a custom struct with the data we need. This struct has the ir_variable (which for interface members is the whole interface variable), plus the data that we need to validate for each aliased location, for now only the base type, which for interface members we will take from the appropriate field inside the interface variable. Later patches will expand this custom struct so we can also check other requirements for location aliasing, specifically that we have matching interpolation and auxiliary storage, that once again, we will take from the appropriate field members for the interface variables. v2: - Use MAX_VARYING instead of MAX_VARYINGS_INCL_PATCH (Illia) Fixes: KHR-GL45.enhanced_layouts.varying_block_automatic_member_locations Fixes (these were passing before but for incorrect reasons): tests/spec/arb_enhanced_layouts/linker/block-member-locations/named-block-member-location-overlap.shader_test tests/spec/arb_enhanced_layouts/linker/block-member-locations/named-block-member-mixed-order-overlap.shader_test Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* glsl/linker: refactor link-time validation of output locationsIago Toral Quiroga2017-10-261-55/+73
| | | | | | | | | Move the checks for explicit locations to a separate function. We will use this in a follow-up patch to validate locations for interface variables where we need to validate each interface member rather than the interface variable itself. Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: report linker errors for invalid explicit locations on inputsIago Toral Quiroga2017-10-261-0/+7
| | | | | | | | | | | We were assuming that if an input has an invalid explicit location it would fail to link because it would not find the corresponding output, however, since we look for the matching output by indexing the explicit_locations array with the input location, we still need to ensure that we don't index out of bounds. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
* nir/opt_intrinsics: Rework progressJason Ekstrand2017-10-251-5/+9
| | | | | | | | | This commit fixes two issues: First, we were returning false regardless of whether or not the function made progress. Second, we were calling nir_metadata_preserve far more often than needed; we only need to call it once per impl. Reviewed-by: Lionel Landwerlin <[email protected]>
* nir/lower_wpos_ytransform: Support system value intrinsicsJason Ekstrand2017-10-251-0/+4
| | | | Reviewed-by: Lionel Landwerlin <[email protected]>
* glsl_to_nir: Zero nir_constant in constant_copy for valgrind & nir_serializeJordan Justen2017-10-251-1/+1
| | | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl_to_nir: Zero nir_variable struct for valgrind & nir_serializeJordan Justen2017-10-251-1/+1
| | | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Zero nir_load_const_instr::value for valgrind & nir_serializeJordan Justen2017-10-251-1/+1
| | | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Zero local_size const struct for valgrind & nir_serializeJordan Justen2017-10-251-0/+1
| | | | | | | Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: Add field initializers for glsl_struct_field default constructorJordan Justen2017-10-251-0/+7
| | | | | | | | This helps valgrind when encode_type_to_blob is used. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* compiler/types: Support [de]serializing void typesJason Ekstrand2017-10-251-0/+3
| | | | | Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* nir/intrinsics: Set the correct num_indices for load_outputJason Ekstrand2017-10-251-1/+1
| | | | | | | Cc: [email protected] Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* glsl: move shader_cache type handling to glsl_typesConnor Abbott2017-10-253-171/+178
| | | | | | | | | Not sure if this is the best place to put it, but we're going to need this for NIR too. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* meson: extract out variable for nir_algebraic.pyRob Clark2017-10-241-0/+2
| | | | | | | | Also needed in freedreno/ir3. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
* glsl: fix derived cs variablesIlia Mirkin2017-10-239-118/+244
| | | | | | | | | | | | | | | | | | | | | | | | | | | There are two issues with the current implementation. First, it relies on the layout(local_size_*) happening in the same shader as the main function, and secondly it doesn't work for variable group sizes. In both cases, the simplest fix is to move the setup of these derived values to a later time, similar to how the gl_VertexID workarounds are done. There already exist system values defined for both of the derived values, so we use them unconditionally, and lower them after linking is performed. While we're at it, we move to using gl_LocalGroupSizeARB instead of gl_WorkGroupSize for variable group sizes. Also the dead code elimination avoidance can be removed, since there can be situations where gl_LocalGroupSizeARB is needed but has not been inserted for the shader with main function. As a result, the lowering code has to insert its own copies of the system values if needed. Reported-by: Stephane Chevigny <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103393 Cc: [email protected] Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
* nir: Print the components referenced for split or packed shader in/outs.Eric Anholt2017-10-201-1/+25
| | | | | | | | | | | | | | Having 4 variables all called "gl_in_TexCoord0@n" isn't very informative, much better to see: decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0 (VARYING_SLOT_VAR0.x, 1, 0) decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0@0 (VARYING_SLOT_VAR0.y, 1, 0) decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0@1 (VARYING_SLOT_VAR0.z, 1, 0) decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0@2 (VARYING_SLOT_VAR0.w, 1, 0) v2: Handle arrays and structs better (by Timothy) Reviewed-by: Timothy Arceri <[email protected]>
* nir: Add a safety check that we don't remove dead I/O vars after lowering.Eric Anholt2017-10-201-4/+14
| | | | | | | | | The pass only looks at var load/store intrinsics, not input load/store intrinsics, so assert that we don't see the other type. v2: Adjust comment indentation. Reviewed-by: Timothy Arceri <[email protected]>
* nir: Get rid of nir_shader::stageJason Ekstrand2017-10-2025-87/+90
| | | | | | | | It's redundant with nir_shader::info::stage. Acked-by: Timothy Arceri <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* nir: set default lod to texture opcodes that needed it but don't provide itSamuel Iglesias Gonsálvez2017-10-201-0/+13
| | | | | | | | | | | | v2: - Use helper to add a new source to the texture instruction. v3: - Use nir_tex_instr_src_index() to simplify the patch (Jason). Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl/linker: produce error when invalid explicit locations are usedIago Toral Quiroga2017-10-193-5/+43
| | | | | | | | | | | | | | We only need to add a check to validate output locations here. For inputs with invalid locations we will fail to link when we can't find a matching output in the same (invalid) location. v2: compute location slots properly depending on shader stage and variable type / direction Fixes: KHR-GL45.enhanced_layouts.varying_location_limit Reviewed-by: Nicolai Hähnle <[email protected]>
* nir: Add a helper for adding texture instruction sourcesJason Ekstrand2017-10-173-25/+28
| | | | Reviewed-by: Lionel Landwerlin <[email protected]>
* nir: add component level support to remove_unused_io_vars()Timothy Arceri2017-10-161-16/+21
| | | | Reviewed-by: Eric Anholt <[email protected]>
* glsl: mark xfb inputs as always_active_ioTimothy Arceri2017-10-161-3/+19
| | | | | | | | | We won't split varyings marked as always active because there is no point in doing so. This means we need to mark both sides of the interface as always active otherwise we will have a mismatch and start removing things we shouldn't. Reviewed-by: Eric Anholt <[email protected]>
* nir: add variant of lower_io_to_scalar to be called earlierTimothy Arceri2017-10-162-0/+255
| | | | | | | | | | | This is intended to be called before nir_lower_io() so that we can do some linking optimisations with the results. It can also be used with drivers that don't use nir_lower_io() at all such as RADV. v2: pass mode mask rather than first and last stage integer. Reviewed-by: Eric Anholt <[email protected]>
* nir: add glsl_channel_type() helperTimothy Arceri2017-10-162-0/+29
| | | | Reviewed-by: Eric Anholt <[email protected]>
* nir: add glsl_type_is_64bit() to nir_typesTimothy Arceri2017-10-162-0/+7
| | | | | Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* blob: Use intptr_t instead of ssize_tJason Ekstrand2017-10-132-7/+7
| | | | | | | | | | | ssize_t is a GNU extension and is not available on Windows or MacOS. Instead, we use intptr_t which should be effectively equivalent and is part of the C standard. This should fix the Windows and Mac OS builds. Fixes: 3af1c829891a4530682bce113fdd512d4f2de3c6 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103253 Reviewed-by: Jose Fonseca <[email protected]> Tested-by: Vinson Lee <[email protected]>
* meson: fix blob test includesDylan Baker2017-10-131-1/+1
| | | | | | | | | Since blob.h moved up to src/compiler the test should include that instead of src/compiler/glsl fixes: 0e3bd56c6ea783dbc ("compiler: Move blob up a level") Signed-off-by: Dylan Baker <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Get rid of the variable on vote intrinsicsJason Ekstrand2017-10-122-5/+3
| | | | | | | | This looks like a copy+paste error. They don't actually write into that variable as would be implied by putting the return there. Reviewed-by: Lionel Landwerlin <[email protected]> Cc: [email protected]
* nir/opcodes: Fix constant-folding of ufind_msbJason Ekstrand2017-10-121-1/+1
| | | | | | | | | We didn't fold correctly in the case of 0x1 because we never let the loop counter hit 0. Switching it to bit >= 0 solves this problem. Reviewed-by: Bas Nieuwenhuizen <[email protected]> Reviewed-by: Connor Abbott <[email protected]> Cc: [email protected]
* compiler/blob: Make some parameters void instead of uint8_tJason Ekstrand2017-10-122-5/+5
| | | | | | | | | There are certain advantages to using uint8_t internally such as well-defined arithmetic on all platforms. However, interfaces that work in terms of raw data should use a void* type. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* compiler/blob: Constify the readerJason Ekstrand2017-10-123-11/+11
| | | | | Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* compiler/blob: Add (reserve|overwrite)_(uint32|intptr) helpersJason Ekstrand2017-10-122-2/+61
| | | | | | | | These helpers not only call blob_reserve_bytes but also make sure that the blob is properly aligned as if blob_write_* were called. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* compiler/blob: make blob_reserve_bytes() more usefulConnor Abbott2017-10-123-20/+12
| | | | | | | | | | | | | | | | Despite the name, it could only be used if you immediately wrote to the pointer. Noboby was using it outside of one test, so clearly this behavior wasn't that useful. Instead, make it return an offset into the data buffer so that the result isn't invalidated if you later write to the blob. In conjunction with blob_overwrite_bytes(), this will be useful for leaving a placeholder and then filling it in later, which we'll need to do for handling phi nodes when serializing NIR. v2 (Jason Ekstrand): - Detect overflow in the offset + to_write computation Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* compiler/blob: Allow for fixed-size blobs with a NULL data pointerJason Ekstrand2017-10-122-3/+10
| | | | | | | | These can be used to easily count up the number of bytes that will be required by "writing" it into the NULL blob. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* compiler/blob: Add a concept of a fixed-allocation blobJason Ekstrand2017-10-122-1/+37
| | | | | Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* compiler/blob: Switch to init/finish instead of create/destroyJason Ekstrand2017-10-124-76/+68
| | | | | | | | | There's no reason why that tiny bit of memory needs to be on the heap. We always put blob_reader on the stack, so why not do the same with the writable blob. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* compiler: Move blob up a levelJason Ekstrand2017-10-125-5/+5
| | | | | | | | We're going to want to use the blob for Vulkan pipeline caching so it makes sense to have it in libcompiler not libglsl. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* meson: Add inc_compiler to the libglsl includesJason Ekstrand2017-10-121-1/+1
|
* glsl/blob: Return false from grow_to_fit if we've ever failedJason Ekstrand2017-10-122-1/+13
| | | | | | | | | | | | Otherwise we could have a failure followed by a smaller write that succeeds and get a corrupted blob. If we ever OOM, we should stop. v2 (Jason Ekstrand): - Initialize the new boolean member in create_blob Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Cc: [email protected]
* glsl/blob: Return false from ensure_can_read on overrunJason Ekstrand2017-10-121-0/+3
| | | | | | | | | Otherwise, if you have a large read fail and then try to do a small read, the small read may succeed even though it's at the wrong offset. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Cc: [email protected]
* nir: Make nir_shader_gather_info() track texelFetch texture accesses.Kenneth Graunke2017-10-121-1/+13
| | | | | | | | For TGSI-based drivers, st_glsl_to_tgsi records this information. For NIR-based drivers, nir_shader_gather_info() will do so. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>