Browse Source

shader: Properly store BamCacheRecord for compiled shader

rdb 4 years ago
parent
commit
652bf4a6ba

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

@@ -2868,7 +2868,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) {
   }
 
   PT(Shader) shader = new Shader(lang);
-  if (!shader->read(sfile)) {
+  if (!shader->read(sfile, record)) {
     return nullptr;
   }
 

+ 1 - 1
panda/src/shaderpipeline/shaderCompilerGlslang.cxx

@@ -486,7 +486,7 @@ compile_now(ShaderModule::Stage stage, std::istream &in,
     return nullptr;
   }
 
-  return new ShaderModuleSpirV(stage, std::move(optimized));
+  return new ShaderModuleSpirV(stage, std::move(optimized), record);
 }
 
 /**

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

@@ -31,13 +31,14 @@ TypeHandle ShaderModuleSpirV::_type_handle;
  * - Strips debugging information from the module.
  */
 ShaderModuleSpirV::
-ShaderModuleSpirV(Stage stage, std::vector<uint32_t> words) :
+ShaderModuleSpirV(Stage stage, std::vector<uint32_t> words, BamCacheRecord *record) :
   ShaderModule(stage),
   _instructions(std::move(words))
 {
   if (!_instructions.validate_header()) {
     return;
   }
+  _record = record;
 
   InstructionWriter writer(_instructions);
 

+ 1 - 1
panda/src/shaderpipeline/shaderModuleSpirV.h

@@ -26,7 +26,7 @@ class ShaderType;
  */
 class EXPCL_PANDA_SHADERPIPELINE ShaderModuleSpirV final : public ShaderModule {
 public:
-  ShaderModuleSpirV(Stage stage, std::vector<uint32_t> words);
+  ShaderModuleSpirV(Stage stage, std::vector<uint32_t> words, BamCacheRecord *record = nullptr);
   virtual ~ShaderModuleSpirV();
 
   virtual PT(CopyOnWriteObject) make_cow_copy() override;