Browse Source

shaderpipeline: Stub out ShaderCompilerCg

Mitchell Stokes 6 years ago
parent
commit
2a0cfda92c

+ 2 - 0
panda/src/shaderpipeline/config_shaderpipeline.cxx

@@ -15,6 +15,7 @@
 
 #include "shaderCompilerRegistry.h"
 #include "shaderCompilerGlslPreProc.h"
+#include "shaderCompilerCg.h"
 
 #include "dconfig.h"
 
@@ -42,4 +43,5 @@ init_libshaderpipeline() {
 
   ShaderCompilerRegistry *reg = ShaderCompilerRegistry::get_global_ptr();
   reg->register_compiler(new ShaderCompilerGlslPreProc());
+  reg->register_compiler(new ShaderCompilerCg());
 }

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

@@ -3,4 +3,5 @@
 #include "shaderModuleGlsl.cxx"
 #include "shaderCompiler.cxx"
 #include "shaderCompilerGlslPreProc.cxx"
+#include "shaderCompilerCg.cxx"
 #include "shaderCompilerRegistry.cxx"

+ 49 - 0
panda/src/shaderpipeline/shaderCompilerCg.cxx

@@ -0,0 +1,49 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University.  All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license.  You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file shaderCompilerCg.cxx
+ * @author Mitchell Stokes
+ * @date 2019-02-16
+ */
+
+#include "shaderCompilerCg.h"
+#include "config_shaderpipeline.h"
+
+#include "dcast.h"
+
+TypeHandle ShaderCompilerCg::_type_handle;
+
+/**
+ *
+ */
+ShaderCompilerCg::
+ShaderCompilerCg() {
+}
+
+/**
+ *
+ */
+std::string ShaderCompilerCg::
+get_name() const {
+  return "Cg Compiler";
+}
+
+/**
+ *
+ */
+ShaderLanguages ShaderCompilerCg::
+get_languages() const {
+  return {
+    Shader::SL_Cg
+  };
+}
+
+PT(ShaderModule) ShaderCompilerCg::
+compile_now(ShaderModule::Stage stage, std::istream &in) const {
+  return nullptr;
+}

+ 56 - 0
panda/src/shaderpipeline/shaderCompilerCg.h

@@ -0,0 +1,56 @@
+/**
+ * PANDA 3D SOFTWARE
+ * Copyright (c) Carnegie Mellon University.  All rights reserved.
+ *
+ * All use of this software is subject to the terms of the revised BSD
+ * license.  You should have received a copy of this license along
+ * with this source code in a file named "LICENSE."
+ *
+ * @file shaderCompilerCg.h
+ * @author Mitchell Stokes
+ * @date 2019-04-03
+ */
+
+#ifndef SHADERCOMPILERCG_H
+#define SHADERCOMPILERCG_H
+
+#include "pandabase.h"
+
+#include "shaderCompiler.h"
+
+
+/**
+ * This defines the compiler interface to read Cg shaders
+ */
+class EXPCL_PANDA_SHADERPIPELINE ShaderCompilerCg : public ShaderCompiler {
+public:
+  ShaderCompilerCg();
+
+PUBLISHED:
+  virtual std::string get_name() const override;
+  virtual ShaderLanguages get_languages() const override;
+  virtual PT(ShaderModule) compile_now(Stage stage, std::istream &in) const override;
+
+
+public:
+  static TypeHandle get_class_type() {
+    return _type_handle;
+  }
+  static void init_type() {
+    ShaderCompiler::init_type();
+    register_type(_type_handle, "ShaderCompilerCg",
+                  ShaderCompiler::get_class_type());
+  }
+  virtual TypeHandle get_type() const override {
+    return get_class_type();
+  }
+  virtual TypeHandle force_init_type() override {
+    init_type();
+    return get_class_type();
+  }
+
+private:
+  static TypeHandle _type_handle;
+};
+
+#endif

+ 5 - 1
tests/shaderpipeline/test_shadercompilerregistry.py

@@ -9,6 +9,10 @@ def test_shadercompilerregistry_glslpreproc_loaded(registry):
     assert core.ShaderCompilerGlslPreProc in [type(i) for i in registry.compilers]
     assert registry.get_compiler_from_language(core.Shader.SL_GLSL) is not None
 
+def test_shadercompilerregistry_cg_loaded(registry):
+    assert core.ShaderCompilerCg in [type(i) for i in registry.compilers]
+    assert registry.get_compiler_from_language(core.Shader.SL_Cg) is not None
+
 def test_shadercompilerregistry_missing_lang(registry):
     assert core.ShaderCompilerGlslPreProc in [type(i) for i in registry.compilers]
-    assert registry.get_compiler_from_language(core.Shader.SL_Cg) is None
+    assert registry.get_compiler_from_language(core.Shader.SL_none) is None