shaderModule.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file shaderModule.h
  10. * @author Mitchell Stokes
  11. * @date 2019-02-16
  12. */
  13. #ifndef SHADERMODULE_H
  14. #define SHADERMODULE_H
  15. #include "typedWritableReferenceCount.h"
  16. #include "bamCacheRecord.h"
  17. /**
  18. * Represents a single shader module in some intermediate representation for
  19. * passing to the driver. This could contain compiled bytecode, or in some
  20. * cases, preprocessed source code to be given directly to the driver.
  21. */
  22. class EXPCL_PANDA_SHADERPIPELINE ShaderModule : public TypedWritableReferenceCount {
  23. PUBLISHED:
  24. enum class Stage {
  25. vertex,
  26. tess_control,
  27. tess_evaluation,
  28. geometry,
  29. fragment,
  30. compute,
  31. };
  32. public:
  33. ShaderModule(Stage stage);
  34. virtual ~ShaderModule();
  35. INLINE Stage get_stage() const;
  36. INLINE const Filename &get_source_filename() const;
  37. INLINE void set_source_filename(const Filename &);
  38. static std::string format_stage(Stage stage);
  39. PUBLISHED:
  40. MAKE_PROPERTY(stage, get_stage);
  41. virtual std::string get_ir() const=0;
  42. protected:
  43. Stage _stage;
  44. PT(BamCacheRecord) _record;
  45. //std::pvector<Filename> _source_files;
  46. Filename _source_filename;
  47. //time_t _source_modified = 0;
  48. friend class Shader;
  49. public:
  50. virtual void write_datagram(BamWriter *manager, Datagram &dg) override;
  51. protected:
  52. void fillin(DatagramIterator &scan, BamReader *manager) override;
  53. public:
  54. static TypeHandle get_class_type() {
  55. return _type_handle;
  56. }
  57. static void init_type() {
  58. TypedWritableReferenceCount::init_type();
  59. register_type(_type_handle, "ShaderModule",
  60. TypedWritableReferenceCount::get_class_type());
  61. }
  62. virtual TypeHandle get_type() const override {
  63. return get_class_type();
  64. }
  65. virtual TypeHandle force_init_type() override {
  66. init_type();
  67. return get_class_type();
  68. }
  69. private:
  70. static TypeHandle _type_handle;
  71. };
  72. INLINE std::ostream &operator << (std::ostream &out, ShaderModule::Stage stage) {
  73. return out << ShaderModule::format_stage(stage);
  74. }
  75. #include "shaderModule.I"
  76. #endif