Explorar o código

glsl: Conditionally add EXT_texture_shadow_lod

ameerj %!s(int64=5) %!d(string=hai) anos
pai
achega
a0d0704aff

+ 5 - 3
src/shader_recompiler/backend/glsl/emit_context.cpp

@@ -302,9 +302,11 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
         break;
         break;
     case Stage::Compute:
     case Stage::Compute:
         stage_name = "cs";
         stage_name = "cs";
+        const u32 local_x{std::max(program.workgroup_size[0], 1u)};
+        const u32 local_y{std::max(program.workgroup_size[1], 1u)};
+        const u32 local_z{std::max(program.workgroup_size[2], 1u)};
         header += fmt::format("layout(local_size_x={},local_size_y={},local_size_z={}) in;",
         header += fmt::format("layout(local_size_x={},local_size_y={},local_size_z={}) in;",
-                              program.workgroup_size[0], program.workgroup_size[1],
-                              program.workgroup_size[2]);
+                              local_x, local_y, local_z);
         break;
         break;
     }
     }
     SetupOutPerVertex(*this, header);
     SetupOutPerVertex(*this, header);
@@ -346,7 +348,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
 }
 }
 
 
 void EmitContext::SetupExtensions() {
 void EmitContext::SetupExtensions() {
-    if (profile.support_gl_texture_shadow_lod) {
+    if (info.uses_shadow_lod && profile.support_gl_texture_shadow_lod) {
         header += "#extension GL_EXT_texture_shadow_lod : enable\n";
         header += "#extension GL_EXT_texture_shadow_lod : enable\n";
     }
     }
     if (info.uses_int64) {
     if (info.uses_int64) {

+ 9 - 1
src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp

@@ -636,7 +636,6 @@ void VisitUsages(Info& info, IR::Inst& inst) {
     case IR::Opcode::ImageGatherDref:
     case IR::Opcode::ImageGatherDref:
     case IR::Opcode::ImageFetch:
     case IR::Opcode::ImageFetch:
     case IR::Opcode::ImageQueryDimensions:
     case IR::Opcode::ImageQueryDimensions:
-    case IR::Opcode::ImageQueryLod:
     case IR::Opcode::ImageGradient: {
     case IR::Opcode::ImageGradient: {
         const TextureType type{inst.Flags<IR::TextureInstInfo>().type};
         const TextureType type{inst.Flags<IR::TextureInstInfo>().type};
         info.uses_sampled_1d |= type == TextureType::Color1D || type == TextureType::ColorArray1D;
         info.uses_sampled_1d |= type == TextureType::Color1D || type == TextureType::ColorArray1D;
@@ -644,6 +643,15 @@ void VisitUsages(Info& info, IR::Inst& inst) {
             inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp) != nullptr;
             inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp) != nullptr;
         break;
         break;
     }
     }
+    case IR::Opcode::ImageQueryLod: {
+        const auto flags{inst.Flags<IR::TextureInstInfo>()};
+        const TextureType type{flags.type};
+        info.uses_sampled_1d |= type == TextureType::Color1D || type == TextureType::ColorArray1D;
+        info.uses_shadow_lod |= flags.is_depth != 0;
+        info.uses_sparse_residency |=
+            inst.GetAssociatedPseudoOperation(IR::Opcode::GetSparseFromOp) != nullptr;
+        break;
+    }
     case IR::Opcode::ImageRead: {
     case IR::Opcode::ImageRead: {
         const auto flags{inst.Flags<IR::TextureInstInfo>()};
         const auto flags{inst.Flags<IR::TextureInstInfo>()};
         info.uses_typeless_image_reads |= flags.image_format == ImageFormat::Typeless;
         info.uses_typeless_image_reads |= flags.image_format == ImageFormat::Typeless;

+ 1 - 0
src/shader_recompiler/shader_info.h

@@ -196,6 +196,7 @@ struct Info {
     bool uses_int64_bit_atomics{};
     bool uses_int64_bit_atomics{};
     bool uses_global_memory{};
     bool uses_global_memory{};
     bool uses_atomic_image_u32{};
     bool uses_atomic_image_u32{};
+    bool uses_shadow_lod{};
 
 
     IR::Type used_constant_buffer_types{};
     IR::Type used_constant_buffer_types{};
     IR::Type used_storage_buffer_types{};
     IR::Type used_storage_buffer_types{};