CmGpuProgramManager.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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() = 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. /** Create a new HighLevelGpuProgram.
  52. @par
  53. This method creates a new program of the specified language. You need to set other
  54. properties like source, entry point, type, profile manually.
  55. @param language Code of the language to use (e.g. "cg")
  56. */
  57. GpuProgramPtr create(const String& language);
  58. /**
  59. * @brief Creates a completely empty and uninitialized HighLevelGpuProgram.
  60. * Should only be used for VERY specific purposes, like deserialization,
  61. * as it requires additional manual initialization that is not required normally.
  62. */
  63. GpuProgramPtr createEmpty(const String& language);
  64. };
  65. }