EEVEE: Fix Fallback Shader Shadow Page Tile Store #113649

Merged
Jeroen Bakker merged 1 commits from Jeroen-Bakker/blender:eevee/fix-stage-interfaces into main 2023-10-13 10:42:35 +02:00
4 changed files with 43 additions and 8 deletions

View File

@ -58,9 +58,12 @@ void main()
/* Write result to atlas. */
# ifdef GPU_METAL
/* NOTE: Use the fastest possible write function without any parameter wrapping or conversion.*/
shadow_atlas_img.texture->write(u_depth, ushort2(out_texel_xy), out_page_z);
shadow_atlas_img.texture->write(
u_depth, ushort2(interp_noperspective.out_texel_xy), interp_flat.out_page_z);
# else
imageStore(shadow_atlas_img, ivec3(out_texel_xy, out_page_z), uvec4(u_depth));
imageStore(shadow_atlas_img,
ivec3(interp_noperspective.out_texel_xy, interp_flat.out_page_z),
uvec4(u_depth));
# endif
}

View File

@ -23,8 +23,8 @@ void main()
/* Load where fragment should write the tile data. */
uvec3 dst_page_co = shadow_page_unpack(dst_coord_buf[tile_id]);
/* Interpolate output texel */
out_texel_xy = (vec2(dst_page_co.xy) + tile_corner) * vec2(SHADOW_PAGE_RES);
out_page_z = dst_page_co.z;
interp_noperspective.out_texel_xy = (vec2(dst_page_co.xy) + tile_corner) * vec2(SHADOW_PAGE_RES);
interp_flat.out_page_z = dst_page_co.z;
#endif
/* Load where the quad should be positioned. */

View File

@ -227,8 +227,9 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_page_tile_clear)
#endif
/* Interface for passing precalculated values in accumulation vertex to frag. */
GPU_SHADER_INTERFACE_INFO(eevee_shadow_page_tile_store_iface, "")
.no_perspective(Type::VEC2, "out_texel_xy")
GPU_SHADER_INTERFACE_INFO(eevee_shadow_page_tile_store_noperspective_iface, "interp_noperspective")
.no_perspective(Type::VEC2, "out_texel_xy");
GPU_SHADER_INTERFACE_INFO(eevee_shadow_page_tile_store_flat_iface, "interp_flat")
.flat(PAGE_Z_TYPE, "out_page_z");
#undef PAGE_Z_TYPE
@ -247,7 +248,8 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_page_tile_store)
Qualifier::READ_WRITE,
ImageType::UINT_2D_ARRAY,
"shadow_atlas_img")
.vertex_out(eevee_shadow_page_tile_store_iface)
.vertex_out(eevee_shadow_page_tile_store_noperspective_iface)
.vertex_out(eevee_shadow_page_tile_store_flat_iface)
.vertex_source("eevee_shadow_page_tile_vert.glsl")
.fragment_source("eevee_shadow_page_tile_frag.glsl");

View File

@ -243,7 +243,37 @@ std::string ShaderCreateInfo::check_error() const
}
}
#ifdef DEBUG
if (!this->geometry_source_.is_empty()) {
if (bool(this->builtins_ & BuiltinBits::BARYCENTRIC_COORD)) {
error += "Shader " + this->name_ +
" has geometry stage and uses barycentric coordinates. This is not allowed as "
"fallback injects a geometry stage.\n";
}
if (bool(this->builtins_ & BuiltinBits::VIEWPORT_INDEX)) {
error += "Shader " + this->name_ +
" has geometry stage and uses multi-viewport. This is not allowed as "
"fallback injects a geometry stage.\n";
}
if (bool(this->builtins_ & BuiltinBits::LAYER)) {
error += "Shader " + this->name_ +
" has geometry stage and uses layer output. This is not allowed as "
"fallback injects a geometry stage.\n";
}
}
#ifndef NDEBUG
if (bool(this->builtins_ &
(BuiltinBits::BARYCENTRIC_COORD | BuiltinBits::VIEWPORT_INDEX | BuiltinBits::LAYER)))
{
for (const StageInterfaceInfo *interface : this->vertex_out_interfaces_) {
if (interface->instance_name.is_empty()) {
error += "Shader " + this->name_ + " uses interface " + interface->name +
" that doesn't contain an instance name, but is required for the fallback "
"geometry shader.\n";
}
}
}
if (!this->is_vulkan_compatible()) {
error += this->name_ +
" contains a stage interface using an instance name and mixed interpolation modes. "