CmGpuProgramManager.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmModule.h"
  4. #include "CmException.h"
  5. #include "CmGpuProgram.h"
  6. namespace BansheeEngine
  7. {
  8. class CM_EXPORT GpuProgramFactory
  9. {
  10. public:
  11. GpuProgramFactory() {}
  12. virtual ~GpuProgramFactory();
  13. /// Get the name of the language this factory creates programs for
  14. virtual const String& getLanguage(void) const = 0;
  15. virtual GpuProgramPtr create(const String& source, const String& entryPoint,
  16. GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
  17. bool requiresAdjacencyInformation) = 0;
  18. virtual GpuProgramPtr create(GpuProgramType type) = 0;
  19. };
  20. class CM_EXPORT GpuProgramManager : public Module<GpuProgramManager>
  21. {
  22. public:
  23. typedef Map<String, GpuProgramFactory*> FactoryMap;
  24. protected:
  25. /// Factories capable of creating HighLevelGpuProgram instances
  26. FactoryMap mFactories;
  27. /// Factory for dealing with programs for languages we can't create
  28. GpuProgramFactory* mNullFactory;
  29. GpuProgramFactory* getFactory(const String& language);
  30. public:
  31. GpuProgramManager();
  32. ~GpuProgramManager();
  33. /** Add a new factory object for high-level programs of a given language. */
  34. void addFactory(GpuProgramFactory* factory);
  35. /** Remove a factory object for high-level programs of a given language. */
  36. void removeFactory(GpuProgramFactory* factory);
  37. /** Returns whether a given high-level language is supported. */
  38. bool isLanguageSupported(const String& lang);
  39. /** Create a new HighLevelGpuProgram.
  40. @par
  41. This method creates a new program of the type specified as the second and third parameters.
  42. @param name The identifying name of the program
  43. @param groupName The name of the resource group which this program is
  44. to be a member of
  45. @param language Code of the language to use (e.g. "cg")
  46. @param gptype The type of program to create
  47. */
  48. GpuProgramPtr create(const String& source, const String& entryPoint, const String& language,
  49. GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>* includes,
  50. bool requiresAdjacencyInformation = false);
  51. /**
  52. * @brief Creates a completely empty and uninitialized HighLevelGpuProgram.
  53. * Should only be used for VERY specific purposes, like deserialization,
  54. * as it requires additional manual initialization that is not required normally.
  55. */
  56. GpuProgramPtr createEmpty(const String& language, GpuProgramType type);
  57. };
  58. }