Browse Source

shaderpipeline: More fixes, particularly for preprocessed GLSL

rdb 5 năm trước cách đây
mục cha
commit
d12702543e

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 292 - 509
panda/src/glstuff/glShaderContext_src.cxx


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

@@ -140,7 +140,6 @@ private:
   void report_program_errors(GLuint program, bool fatal);
   bool attach_shader(const ShaderModule *module);
   bool compile_and_link();
-  bool parse_and_set_short_hand_shader_vars(Shader::Parameter &arg_id, GLenum param_type, GLint param_size, Shader *s);
   void release_resources();
 
 public:

+ 6 - 1
panda/src/gobj/shader.cxx

@@ -2106,7 +2106,12 @@ bind_parameter(const Parameter &param) {
       bind._id = param;
       bind._part = STO_stage_i;
       bind._name = 0;
-      bind._desired_type = Texture::TT_2d_texture;
+
+      const ::ShaderType::SampledImage *sampled_image_type = type->as_sampled_image();
+      if (sampled_image_type == nullptr) {
+        return report_parameter_error(name, type, "expected sampled image");
+      }
+      bind._desired_type = sampled_image_type->get_texture_type();
 
       std::string tail;
       bind._stage = string_to_int(pieces[1].substr(7), tail);

+ 9 - 0
panda/src/shaderpipeline/shaderCompilerGlslang.cxx

@@ -14,6 +14,7 @@
 #include "shaderCompilerGlslang.h"
 #include "config_shaderpipeline.h"
 #include "virtualFile.h"
+#include "shaderCompilerGlslPreProc.h"
 
 #ifndef CPPPARSER
 #include <glslang/Public/ShaderLang.h>
@@ -292,6 +293,14 @@ compile_now(ShaderModule::Stage stage, std::istream &in,
     return nullptr;
   }
 
+  if (!is_cg && glsl_version < 330 && glsl_version != 150) {
+    // Fall back to GlslPreProc handler.  Cleaner way to do this?
+    static ShaderCompilerGlslPreProc preprocessor;
+
+    std::istringstream stream(std::string((const char *)&code[0], code.size()));
+    return preprocessor.compile_now(stage, stream, filename, record);
+  }
+
   static bool is_initialized = false;
   if (!is_initialized) {
     ShInitialize();

+ 0 - 1
panda/src/shaderpipeline/shaderModuleSpirV.cxx

@@ -1196,7 +1196,6 @@ r_define_type(InstructionIterator &it, const ShaderType *type) {
       0, // Access qualifier
     };
 
-    Texture::TextureType texture_type;
     switch (image_type->get_texture_type()) {
     case Texture::TT_1d_texture:
       args[2] = spv::Dim1D;

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác