Fix #111960, #112200, #112214: EEVEE: Incorrect BuiltinBits::LAYER use

5cf7089e43 added the `BuiltinBits::LAYER` to shaders with a geometry
stage. This causes compilation errors when
`GLContext::layered_rendering_support` is false (otherwise the flag
does nothing).

This PR moves the `LAYER` flags to the `no_geom` shader versions and
adds a check to `ShaderCreateInfo::finalize()` to ensure the `LAYER` flag
is not used in shaders with a geometry stage.

Pull Request: https://projects.blender.org/blender/blender/pulls/112245
This commit is contained in:
Miguel Pozo
2023-09-12 15:39:33 +02:00
parent 5f8dfa231d
commit d81165f3ec
3 changed files with 10 additions and 4 deletions

View File

@@ -227,7 +227,6 @@ GPU_SHADER_INTERFACE_INFO(eevee_legacy_probe_planar_downsample_geom_frag_iface,
GPU_SHADER_CREATE_INFO(eevee_legacy_lightprobe_planar_downsample_common)
.vertex_source("lightprobe_planar_downsample_vert.glsl")
.fragment_source("lightprobe_planar_downsample_frag.glsl")
.builtins(BuiltinBits::LAYER)
.vertex_out(eevee_legacy_probe_planar_downsample_vert_geom_iface)
.vertex_out(eevee_legacy_probe_planar_downsample_vert_geom_flat_iface)
.sampler(0, ImageType::FLOAT_2D_ARRAY, "source")
@@ -246,6 +245,7 @@ GPU_SHADER_CREATE_INFO(eevee_legacy_lightprobe_planar_downsample)
#ifdef WITH_METAL_BACKEND
GPU_SHADER_CREATE_INFO(eevee_legacy_lightprobe_planar_downsample_no_geom)
.additional_info("eevee_legacy_lightprobe_planar_downsample_common")
.builtins(BuiltinBits::LAYER)
.vertex_out(eevee_legacy_probe_planar_downsample_geom_frag_iface)
.metal_backend_only(true)
.do_static_compilation(true)

View File

@@ -18,7 +18,6 @@ GPU_SHADER_CREATE_INFO(eevee_legacy_volumes_clear)
.define("STANDALONE")
.define("VOLUMETRICS")
.define("CLEAR")
.builtins(BuiltinBits::LAYER)
.additional_info("eevee_legacy_common_lib")
.additional_info("draw_view")
.additional_info("draw_resource_id_varying")
@@ -68,7 +67,6 @@ GPU_SHADER_CREATE_INFO(eevee_legacy_volumes_scatter_common)
.define("STANDALONE")
.define("VOLUMETRICS")
.define("VOLUME_SHADOW")
.builtins(BuiltinBits::LAYER)
.additional_info("eevee_legacy_common_lib")
.additional_info("draw_view")
.additional_info("draw_resource_id_varying")
@@ -100,6 +98,7 @@ GPU_SHADER_CREATE_INFO(eevee_legacy_volumes_scatter)
#ifdef WITH_METAL_BACKEND
GPU_SHADER_CREATE_INFO(eevee_legacy_volumes_scatter_no_geom)
.additional_info("eevee_legacy_volumes_scatter_common")
.builtins(BuiltinBits::LAYER)
.vertex_out(legacy_volume_geom_frag_iface)
.metal_backend_only(true)
.do_static_compilation(true)
@@ -133,7 +132,6 @@ GPU_SHADER_CREATE_INFO(eevee_legacy_volumes_integration_common)
.additional_info("draw_view")
.additional_info("eevee_legacy_volumetric_lib")
.additional_info("draw_resource_id_varying")
.builtins(BuiltinBits::LAYER)
/* NOTE: Unique sampler IDs assigned for consistency between library includes,
* and to avoid unique assignment collision validation error.
* However, resources will be auto assigned locations within shader usage. */
@@ -161,6 +159,7 @@ GPU_SHADER_CREATE_INFO(eevee_legacy_volumes_integration_common_geom)
#ifdef WITH_METAL_BACKEND
GPU_SHADER_CREATE_INFO(eevee_legacy_volumes_integration_common_no_geom)
.additional_info("eevee_legacy_volumes_integration_common")
.builtins(BuiltinBits::LAYER)
.vertex_out(legacy_volume_geom_frag_iface);
#endif

View File

@@ -182,6 +182,13 @@ void ShaderCreateInfo::finalize()
}
}
if (!geometry_source_.is_empty() && bool(builtins_ & BuiltinBits::LAYER)) {
std::cout << name_
<< ": Validation failed. BuiltinBits::LAYER shouldn't be used with geometry shaders."
<< std::endl;
BLI_assert(0);
}
if (auto_resource_location_) {
int images = 0, samplers = 0, ubos = 0, ssbos = 0;