mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 14:38:06 +02:00
virgl, nir_to_tgsi: Add a hack for promoting partial memory barriers
Most drivers will want nir_opt_barrier_modes() to optimize out unnecessary memory barrier modes. However, virgl has to translate back to GLSL, which means it can really only handle partial memory barriers in compute shaders today, because there isn't a proper way to express them otherwise. Just ask nir_to_tgsi to promote these back to full barriers as a workaround. See KHR-GL43.shader_storage_buffer_object.advanced-readWrite-case1 on virpipe-on-gl as a case where this hack is needed. Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24842>
This commit is contained in:
parent
dd92fd8fcc
commit
fb3e37a014
3 changed files with 20 additions and 1 deletions
|
|
@ -2458,6 +2458,23 @@ ntt_emit_barrier(struct ntt_compile *c, nir_intrinsic_instr *intr)
|
|||
if (modes & nir_var_mem_global)
|
||||
membar |= TGSI_MEMBAR_SHADER_BUFFER;
|
||||
|
||||
/* Hack for virglrenderer: the GLSL specific memory barrier functions,
|
||||
* memoryBarrier{Buffer,Image,Shared,AtomicCounter}(), are only
|
||||
* available in compute shaders prior to GLSL 4.30. In other stages,
|
||||
* it needs to use the full memoryBarrier(). It may be possible to
|
||||
* make them available via #extension directives in older versions,
|
||||
* but it's confusingly underspecified, and Mesa/virglrenderer don't
|
||||
* currently agree on how to do it. So, just promote partial memory
|
||||
* barriers back to full ones outside of compute shaders when asked.
|
||||
*/
|
||||
if (membar && !compute &&
|
||||
c->options->non_compute_membar_needs_all_modes) {
|
||||
membar |= TGSI_MEMBAR_SHADER_BUFFER |
|
||||
TGSI_MEMBAR_ATOMIC_BUFFER |
|
||||
TGSI_MEMBAR_SHADER_IMAGE |
|
||||
TGSI_MEMBAR_SHARED;
|
||||
}
|
||||
|
||||
/* If we only need workgroup scope (not device-scope), we might be able to
|
||||
* optimize a bit.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ struct nir_to_tgsi_options {
|
|||
bool lower_fabs;
|
||||
bool unoptimized_ra;
|
||||
bool lower_ssbo_bindings;
|
||||
bool non_compute_membar_needs_all_modes;
|
||||
uint32_t ubo_vec4_max;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -710,7 +710,8 @@ static void *virgl_shader_encoder(struct pipe_context *ctx,
|
|||
.unoptimized_ra = true,
|
||||
.lower_fabs = true,
|
||||
.lower_ssbo_bindings =
|
||||
rs->caps.caps.v2.host_feature_check_version >= 16
|
||||
rs->caps.caps.v2.host_feature_check_version >= 16,
|
||||
.non_compute_membar_needs_all_modes = true
|
||||
};
|
||||
|
||||
if (!(rs->caps.caps.v2.capability_bits_v2 & VIRGL_CAP_V2_TEXTURE_SHADOW_LOD) &&
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue