2
0

CmGpuProgramManager.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __GpuProgramManager_H_
  25. #define __GpuProgramManager_H_
  26. // Precompiler options
  27. #include "CmPrerequisites.h"
  28. #include "CmException.h"
  29. #include "CmGpuProgram.h"
  30. #include "CmModule.h"
  31. namespace CamelotEngine {
  32. /** \addtogroup Core
  33. * @{
  34. */
  35. /** \addtogroup Resources
  36. * @{
  37. */
  38. class CM_EXPORT GpuProgramManager : public Module<GpuProgramManager>
  39. {
  40. public:
  41. typedef set<String>::type SyntaxCodes;
  42. protected:
  43. /** General create method
  44. */
  45. virtual GpuProgram* create(GpuProgramType gptype, const String& syntaxCode) = 0;
  46. public:
  47. GpuProgramManager();
  48. virtual ~GpuProgramManager();
  49. /** Loads a GPU program from a string of assembly code.
  50. @remarks
  51. The assembly code must be compatible with this manager - call the
  52. getSupportedSyntax method for details of the supported syntaxes
  53. @param name The identifying name to give this program, which can be used to
  54. retrieve this program later with getByName.
  55. @param groupName The name of the resource group
  56. @param code A string of assembly code which will form the program to run
  57. @param gptype The type of program to create.
  58. @param syntaxCode The name of the syntax to be used for this program e.g. arbvp1, vs_1_1
  59. */
  60. virtual GpuProgramPtr load(const String& code, GpuProgramType gptype,
  61. const String& syntaxCode);
  62. /** Returns the syntaxes that this manager supports. */
  63. virtual const SyntaxCodes& getSupportedSyntax(void) const;
  64. /** Returns whether a given syntax code (e.g. "ps_1_3", "fp20", "arbvp1") is supported. */
  65. virtual bool isSyntaxSupported(const String& syntaxCode) const;
  66. /** Converts a generic GpuProgramProfile identifier into a render-system specific one.
  67. *
  68. * Returns an empty string if it can't convert it.
  69. */
  70. virtual String gpuProgProfileToRSSpecificProfile(GpuProgramProfile gpuProgProfile) const;
  71. /** Creates a new GpuProgramParameters instance which can be used to bind
  72. parameters to your programs.
  73. @remarks
  74. Program parameters can be shared between multiple programs if you wish.
  75. */
  76. virtual GpuProgramParametersSharedPtr createParameters(void);
  77. /** Create a GPU program from a string of assembly code.
  78. @remarks
  79. Use this method in preference to the 'load' methods if you wish to define
  80. a GpuProgram, but not load it yet; useful for saving memory.
  81. @par
  82. The assembly code must be compatible with this manager - call the
  83. getSupportedSyntax method for details of the supported syntaxes
  84. @param name The identifying name to give this program, which can be used to
  85. retrieve this program later with getByName.
  86. @param groupName The name of the resource group
  87. @param code A string of assembly code which will form the program to run
  88. @param gptype The type of program to create.
  89. @param syntaxCode The name of the syntax to be used for this program e.g. arbvp1, vs_1_1
  90. */
  91. virtual GpuProgramPtr createProgram(const String& code,
  92. GpuProgramType gptype, const String& syntaxCode);
  93. };
  94. /** @} */
  95. /** @} */
  96. }
  97. #endif