aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_glsl_to_nir.cpp
Commit message (Collapse)AuthorAgeFilesLines
* st/glsl_to_nir: disable st_nir_lower_builtin() when packing supportedTimothy Arceri2020-06-301-6/+5
| | | | | | | | | | | | There is no need to lower builtins when uniform packing is supported by the driver. Lowering is only required by other drivers because we prepack builtin uniforms. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3140 CC: <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5656>
* st_glsl_to_nir: fix potential use after freeTimothy Arceri2020-06-171-2/+14
| | | | | | | | | | | | | | | When updating the shader info used by GL for the API we must remember to make sure to restore the pointers to its own name and label strings. There are a number of ways in which the nir copy of these strings can be freed before GL is finished with them. Fixes: 36be8c2fcf94 ("st/glsl_to_nir: use nir_shader_gather_info()") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2875 Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5488>
* nir: add callback to nir_remove_dead_variables()Timothy Arceri2020-06-031-7/+10
| | | | | | | | | | | | This allows us to do API specific checks before removing variable without filling nir_remove_dead_variables() with API specific code. In the following patches we will use this to support the removal of dead uniforms in GLSL. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4797>
* st/nir: Fix assigning PointCoord location with !PIPE_CAP_TEXCOORDConnor Abbott2020-04-251-0/+2
| | | | | | | | This was trying to emulate the effect of mapping GL -> TGSI -> NIR, but failed to handle VARYING_SLOT_PNTC which led to a kludgy workaround in freedreno. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4732>
* st/glsl_to_nir: make use of nir linker for linking uniformsTimothy Arceri2020-04-211-10/+9
| | | | | Reviewed-by: Alejandro Piñeiro <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4395>
* nir/glsl: gather bitmask of images used by programTapani Pälli2020-03-161-0/+1
| | | | | | | In a similar fashion as commit f5c7df4dc95 does for textures. Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4080>
* gallium: Add a cap for enabling lowering of image load/store intrinsics.Eric Anholt2020-02-241-0/+2
| | | | | | | | | The deref stuff is hard to handle in a backend supporting dynamic indexing, while the lowering can easily turn that into the same kind of dynamic indexing we do for textures, UBOs, and SSBOs. Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3728>
* nir: Make image lowering optionally handle the !bindless case as well.Eric Anholt2020-02-241-1/+1
| | | | | | | | iris was doing this internally, but let's rename the function and move the iris code there. Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3728>
* st/nir: Unify inputs_read/outputs_written before serializing NIRDanylo Piliaiev2020-02-181-22/+19
| | | | | | | | | | | | | | | Otherwise input/output interfaces won't be unified when reading NIR from a cache. Fixes piglit test on iris: clip-distance-vs-gs-out.shader_test Fixes: 19ed12af Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3787> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3787>
* nir: Drop the ssbo_offset to atomic lowering.Eric Anholt2020-01-211-1/+1
| | | | | | | | | | | | | The arguments passed in were: - prog->info.num_ssbos - prog->nir->info.num_ssbos - arbitrary values for standalone compilers The num_ssbos should match between the prog's info and prog->nir's info until this lowering happens. Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3240>
* gallium: Pack the atomic counters just above the SSBOs.Eric Anholt2020-01-211-2/+1
| | | | | | | | | | | | | | | | | | | | | We carve out half the SSBO space for atomics, and we were just binding them way up there. freedreno was then using a remapping table to map the sparse buffer index back down, since space in the descriptor array is a shared resource that may limit parallelism. That remapping table generated inside of the ir3 compiler is getting thoroughly in the way of implementing vulkan descriptor sets. We will be able to get rid of the freedreno's remapping table, and hopefully save shared resources on other hardware, by packing the atomics tightly above the SSBOs (like i965 does). We already rebind the shader buffers on program change if either the old or new program has SSBOs or ABOs, so this doesn't necessarily increase the program state change cost (the only cost increase I can come up with is if you're using the same atomic counter without rebinding it across changes of programs with varying SSBO counts, meaning it would now bounce around index space). Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3240>
* mesa: Make atomic lowering put atomics above SSBOs.Eric Anholt2020-01-211-1/+1
| | | | | | | | | | Gallium arbitrarily (it seems) put atomics below SSBOs, resulting in a bunch of extra index management, and surprising shader code when you would see your SSBOs up at index 16. It makes a lot more sense to see atomics converted to SSBOs appear as magic high numbers. Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3240>
* mesa/st: Move the dword slot counting function to glsl_types as well.Eric Anholt2020-01-141-2/+8
| | | | | | | | | | | | | To implement NIR-to-TGSI, we need to be able to get the size of the uniform variable for the TGSI declaration, not just the .driver_location. With its location in mesa/st, drivers couldn't link to it from nir-to-tgsi. This feels like a common enough function to want, so let's share it in the core compiler. Reviewed-by: Kristian H. Kristensen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3297>
* mesa/st: Move the vec4 type size function into core GLSL types.Eric Anholt2020-01-141-1/+8
| | | | | | | | | | The only bit that gallium varied on was handling of bindless. We can retain previous behavior for count_attribute_slots() by passing in "true" (though I suspect this is just giving a silly answer to a silly question), and delete our recursive function from mesa/st. Reviewed-by: Kristian H. Kristensen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3297>
* mesa/st: Deduplicate the NIR uniform lowering code.Eric Anholt2020-01-141-9/+14
| | | | | | | Just a little refactor as I go looking at the type size functions. Reviewed-by: Kristian H. Kristensen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3297>
* mesa: create program resource hash in a single placeTapani Pälli2020-01-091-2/+0
| | | | | | | | | This is a cleanup but also a fix for commit dd09f1d806b. In case of i965 we did not actually create hash for cached shader programs. Fixes: dd09f1d806b "mesa/st/i965: add a ProgramResourceHash for quicker resource lookup" Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* mesa/st/i965: add a ProgramResourceHash for quicker resource lookupTapani Pälli2020-01-071-0/+2
| | | | | | | | | | | | Many resource APIs require searching by name, add a hash table to make this faster. Currently we traverse the whole resource list for name based queries, this change makes all these cases use the hash. Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2203 Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3254> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3254>
* glsl: use nir linker to link atomicsTimothy Arceri2020-01-071-1/+5
| | | | Reviewed-by: Alejandro Piñeiro <[email protected]>
* glsl: rename gl_nir_link() to gl_nir_link_spirv()Timothy Arceri2020-01-071-1/+1
| | | | | | | | A NIR based glsl linking function will be too different to the spirv version to bother attempting any sharing. So lets change the name to be explicit. Reviewed-by: Alejandro Piñeiro <[email protected]>
* st/mesa: Lower vars to ssa and constant prop before gl_nir_lower_buffersKristian H. Kristensen2020-01-061-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The gl_nir_lower_buffers pass relies on recognizing the same literal constants as the GLSL compiler so that constant buffer array indices are constant in nir as well. Without this, get_block_array_index() would see vec1 32 ssa_723 = deref_var &const_temp@1 (function_temp int) vec1 32 ssa_724 = load_const (0x00000001 /* 0.000000 */) ... vec1 32 ssa_5 = deref_var &const_temp@1 (function_temp int) vec1 32 ssa_6 = intrinsic load_deref (ssa_5) (0) /* access=0 */ vec1 32 ssa_7 = deref_var &blockB (ssbo BlockB[1]) vec1 32 ssa_8 = deref_array &(*ssa_7)[ssa_6] (ssbo BlockB) /* &blockB[ssa_6] */ instead of a literal 1, and ultimately generate the block name BlockB[0]. That used to work, since we before the previous commits we'd compact the block binding points and names. Thus, there would always be a BlockB[0]. Now, if an entry in a block array isn't used, we don't generate that block name, which means that if entry 0 isn't used BlockB[0] isn't present and then get_block_array_index() fails to find the block. In most cases we would have dealt with this in the call to st_nir_opts() in st_nir_link_shaders(), but in the num_shaders == 1 case (for example, compute) we would call gl_nir_lower_buffers() before we lowered GLSL constants. Move that corner case up next to where we call st_nir_link_shaders() so we call st_nir_opts() at the same point in the flow for all shaders. Fixes: dEQP-GLES31.functional.ssbo.layout.random.all_per_block_buffers.18 Signed-off-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa/st: glsl_to_nir: don't lower atomics to SSBOs if driver supports HW atomicsGert Wollny2020-01-041-2/+3
| | | | | | | | | | | | | | At least on r600 HW atomic operations are way less expensive than SSBO atomic operations. v2: use st->has_hw_atomics (Erik Anholt) v3: remove second invocation of atomic to ssbo lowering (Erik Anholt) Signed-off-by: Gert Wollny <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3286> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3286>
* st/nir: Optionally unify inputs_read/outputs_written when linking.Kenneth Graunke2020-01-031-0/+22
| | | | | | | | | | | | | i965 and iris use inputs_read/outputs_written for a shader stage to determine the layout of input and output storage. Adjacent stages must agree on the layout, so adjacent input/output bitfields must match. This patch adds a new nir_shader_compiler_options::unify_interfaces flag which asks the linker to unify the input/output interfaces between adjacent stages. Reviewed-by: Timothy Arceri <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3249>
* st/glsl_to_nir: fix SSO validation regressionTimothy Arceri2019-12-131-3/+11
| | | | | | | Fixes: b77907edb554 ("st/glsl_to_nir: use nir based program resource list builder") Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2216 Reviewed-by: Marek Olšák <[email protected]>
* st/glsl_to_nir: use nir based program resource list builderTimothy Arceri2019-12-131-1/+4
| | | | | | | | | | | | | | | | | Here we use the NIR based builder to add everything to the resource list execpt for SSO packed varyings. Since the details of those varyings get lost during packing we leave the special handing to the GLSL IR pass for now. In order to do this we add some bools to the build resource list functions. Using the NIR based resource list builder gets us a step closer to using a native NIR based linker. It should also be faster than the GLSL IR builder, one because the NIR optimisations should mean we add less entries due to better optimisations, and two because nir gives us better lists to work with and we don't need to walk the entire IR to find the resources. Ack-by: Alejandro Piñeiro <[email protected]>
* st/glsl_to_nir: call gl_nir_lower_buffers() a little laterTimothy Arceri2019-12-131-1/+2
| | | | | | | In a following commit we will use a NIR based builder to build the OpenGL resource list, so we want to delay this call a little. Ack-by: Alejandro Piñeiro <[email protected]>
* glsl: move nir_remap_dual_slot_attributes() call out of glsl_to_nir()Timothy Arceri2019-12-131-0/+8
| | | | | | | | | In order to be able to implement a NIR based glsl linker we need to build the program resource list with NIR. This change delays the remaping so that a later commit can call the NIR based resource list builder. Reviewed-by: Alejandro Piñeiro <[email protected]>
* st/mesa: add st_variant base class to simplify code for shader variantsMarek Olšák2019-11-261-7/+1
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: don't use ** in the st_nir_link_shaders signatureMarek Olšák2019-11-261-20/+20
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: simplify looping over linked shaders when linking NIRMarek Olšák2019-11-261-48/+28
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: propagate gl_PatchVerticesIn from TCS to TES before linking for NIRMarek Olšák2019-11-261-2/+2
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: don't call ProgramStringNotify in glsl_to_nirMarek Olšák2019-11-261-7/+10
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: don't use redundant stp->state.ir.nirMarek Olšák2019-11-261-14/+4
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: call nir_sweep in st_finalize_nirMarek Olšák2019-11-191-2/+0
| | | | | This is invoked sooner before (pre-)compiling the first variant and is also applied to fixed-func and ARB programs.
* st/mesa: cleanups after unification of st_vertex/common programMarek Olšák2019-11-191-23/+5
| | | | Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
* st/mesa: rename st_common_program to st_programMarek Olšák2019-11-191-5/+5
| | | | Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
* st/mesa: trivially merge st_vertex_program into st_common_programMarek Olšák2019-11-191-3/+3
| | | | | | | a later commit will add back st_vertex_program as a subclass of st_common_program Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
* mesa/st: make sure we remove dead IO variables before handing NIR to backendsIago Toral Quiroga2019-11-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | Commit "1c2bf82d24a glsl: disable lower_fragdata_array() for NIR drivers" disabled the GLSL IR lowering that turned gl_FragData from an array into a collection of scalar outputs under the assumption that this was already being handled properly elsewhere, however there are some corner cases where NIR would fail to do this, leaving gl_FragData[] as an array variable. This can break backends that assume that all their outputs will be scalar and use the variable definitions from the shader to do their output setup, such as the case of V3D. At least one corner case was found in some Portal shaders from shader-db, where NIR would optimize out the full body of a fragment shader. In this scenario, the empty shader would keep the original array definition of gl_FragData[], causing the backend to assert. We need to do this late enough for it to be effective, since doing it in st_nir_preprocess does not fix the original problem. Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2091 Fixes: 1c2bf82d ("glsl: disable lower_fragdata_array() for NIR drivers") Reviewed-by: Marek Olšák <[email protected]>
* st/mesa: call nir_lower_flrp only once per shaderMarek Olšák2019-11-041-16/+19
| | | | Reviewed-by: Connor Abbott <[email protected]>
* st/mesa: call nir_opt_access only onceMarek Olšák2019-11-041-2/+0
| | | | Reviewed-by: Connor Abbott <[email protected]>
* glsl: just use NIR to lower outputs when driver can't read outputsTimothy Arceri2019-11-011-6/+3
| | | | | | | | | | This will allow us to stop lowering gl_FragData in GLSL IR for NIR drivers which means we won't need the special GLSL IR type handling for building the resource list in a NIR based linker. i965 has been doing this since b828f7a27b2b. Reviewed-by: Marek Olšák <[email protected]>
* st/mesa: use pipe_screen::finalize_nirMarek Olšák2019-10-231-1/+8
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* st/mesa: assign driver locations for VS inputs for NIR before cachingMarek Olšák2019-10-231-9/+6
| | | | | | | fix up edge flags in the NIR pass, because st/mesa doesn't touch the inputs after caching Reviewed-by: Kenneth Graunke <[email protected]>
* st/mesa: don't lower_global_vars_to_local for VS if there are no dead inputsMarek Olšák2019-10-231-2/+7
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* st/mesa: move some NIR lowering before shader cachingMarek Olšák2019-10-231-14/+5
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* st/mesa: merge st_fragment_program into st_common_programMarek Olšák2019-10-171-7/+1
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: rename st_xxx_program::tgsi to stateMarek Olšák2019-10-171-6/+6
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: lower doubles for NIR after linkingMarek Olšák2019-10-171-20/+17
| | | | | | | This allows dropping 1 call to st_nir_opts, because shaders are always optimized after linking. Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: call st_nir_opts for linked shaders only onceMarek Olšák2019-10-171-1/+12
| | | | | | | | | | | | | | | | | | The removed st_nir_opts calls are mostly redundant. There is an improvement with shader-db on radeonsi: Before: real 1m54.047s user 28m37.857s sys 0m7.573s After: real 1m52.012s user 28m3.412s sys 0m7.808s Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: don't call translate_*_program functions for NIRMarek Olšák2019-10-161-0/+13
| | | | | | move the initializaton to st_link_nir Reviewed-by: Timothy Arceri <[email protected]>
* st/mesa: remove st_compute_program in favor of st_common_programMarek Olšák2019-10-161-7/+1
| | | | | | | The conversion from pipe_shader_state to pipe_compute_state is done at the end. Reviewed-by: Timothy Arceri <[email protected]>