Explorar o código

shaderpipeline: Fix crash with shadow samplers in structs/arrays

We don't actually need this fix for non-Cg shaders anyway, and Cg shaders don't have these in structs
rdb %!s(int64=5) %!d(string=hai) anos
pai
achega
904cd09430
Modificáronse 1 ficheiros con 3 adicións e 4 borrados
  1. 3 4
      panda/src/shaderpipeline/shaderModuleSpirV.cxx

+ 3 - 4
panda/src/shaderpipeline/shaderModuleSpirV.cxx

@@ -122,10 +122,9 @@ ShaderModuleSpirV(Stage stage, std::vector<uint32_t> words) :
           // a shadow sampler; this isn't always done by the compiler, and the
           // spec isn't clear that this is necessary, but it helps spirv-cross
           // properly generate shadow samplers.
-          const ShaderType::SampledImage *sampled_image_type;
-          DCAST_INTO_V(sampled_image_type, def._type);
-
-          if (!sampled_image_type->is_shadow()) {
+          const ShaderType::SampledImage *sampled_image_type =
+            def._type->as_sampled_image();
+          if (sampled_image_type != nullptr && !sampled_image_type->is_shadow()) {
             // No, change the type of this variable.
             var.type = ShaderType::register_type(ShaderType::SampledImage(
               sampled_image_type->get_texture_type(),