Kaynağa Gözat

glgsg: check for SPIR-V support, check if reflection is needed

rdb 5 yıl önce
ebeveyn
işleme
ac92a91c64

+ 4 - 2
panda/src/glstuff/glShaderContext_src.cxx

@@ -282,7 +282,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
   }
   }
 
 
   // Is this a SPIR-V shader?  If so, we've already done the reflection.
   // Is this a SPIR-V shader?  If so, we've already done the reflection.
-  if (true) {//s->get_language() != Shader::SL_GLSL) {
+  if (!_needs_reflection) {
     // Do we have unbound inputs?  Ask the driver for their locations.
     // Do we have unbound inputs?  Ask the driver for their locations.
     size_t num_inputs = s->_mat_spec.size();
     size_t num_inputs = s->_mat_spec.size();
     for (size_t i = 0; i < num_inputs;) {
     for (size_t i = 0; i < num_inputs;) {
@@ -3135,7 +3135,7 @@ attach_shader(const ShaderModule *module) {
   }
   }
 
 
 #ifndef OPENGLES
 #ifndef OPENGLES
-  if (module->is_of_type(ShaderModuleSpirV::get_class_type())) {
+  if (module->is_of_type(ShaderModuleSpirV::get_class_type()) && _glgsg->_supports_spir_v) {
     // Load a SPIR-V binary.
     // Load a SPIR-V binary.
     if (GLCAT.is_debug()) {
     if (GLCAT.is_debug()) {
       GLCAT.debug()
       GLCAT.debug()
@@ -3161,6 +3161,8 @@ attach_shader(const ShaderModule *module) {
     std::string text = glsl_module->get_ir();
     std::string text = glsl_module->get_ir();
     const char *text_str = text.c_str();
     const char *text_str = text.c_str();
     _glgsg->_glShaderSource(handle, 1, &text_str, nullptr);
     _glgsg->_glShaderSource(handle, 1, &text_str, nullptr);
+
+    _needs_reflection = true;
   } else {
   } else {
     GLCAT.error()
     GLCAT.error()
       << "Unsupported shader module type " << module->get_type() << "!\n";
       << "Unsupported shader module type " << module->get_type() << "!\n";

+ 1 - 0
panda/src/glstuff/glShaderContext_src.h

@@ -74,6 +74,7 @@ private:
   };
   };
   typedef pvector<Module> Modules;
   typedef pvector<Module> Modules;
   Modules _modules;
   Modules _modules;
+  bool _needs_reflection = false;
 
 
   WCPT(RenderState) _state_rs;
   WCPT(RenderState) _state_rs;
   CPT(TransformState) _modelview_transform;
   CPT(TransformState) _modelview_transform;