CmHighLevelGpuProgram.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 __HighLevelGpuProgram_H__
  25. #define __HighLevelGpuProgram_H__
  26. #include "CmPrerequisites.h"
  27. #include "CmGpuProgram.h"
  28. namespace CamelotFramework {
  29. /** \addtogroup Core
  30. * @{
  31. */
  32. /** \addtogroup Resources
  33. * @{
  34. */
  35. /** Abstract base class representing a high-level program (a vertex or
  36. fragment program).
  37. @remarks
  38. High-level programs are vertex and fragment programs written in a high-level
  39. language such as Cg or HLSL, and as such do not require you to write assembler code
  40. like GpuProgram does. However, the high-level program does eventually
  41. get converted (compiled) into assembler and then eventually microcode which is
  42. what runs on the GPU. As well as the convenience, some high-level languages like Cg allow
  43. you to write a program which will operate under both Direct3D and OpenGL, something
  44. which you cannot do with just GpuProgram (which requires you to write 2 programs and
  45. use each in a Technique to provide cross-API compatibility). Ogre will be creating
  46. a GpuProgram for you based on the high-level program, which is compiled specifically
  47. for the API being used at the time, but this process is transparent.
  48. @par
  49. You cannot create high-level programs direct - use HighLevelGpuProgramManager instead.
  50. Plugins can register new implementations of HighLevelGpuProgramFactory in order to add
  51. support for new languages without requiring changes to the core Ogre API. To allow
  52. custom parameters to be set, this class extends StringInterface - the application
  53. can query on the available custom parameters and get/set them without having to
  54. link specifically with it.
  55. */
  56. class CM_EXPORT HighLevelGpuProgram : public GpuProgram
  57. {
  58. public:
  59. virtual ~HighLevelGpuProgram();
  60. /** @copydoc GpuProgram::getBindingDelegate */
  61. virtual GpuProgramPtr getBindingDelegate(void) { return mAssemblerProgram; }
  62. protected:
  63. friend class HighLevelGpuProgramManager;
  64. /** Constructor, should be used only by factory classes. */
  65. HighLevelGpuProgram(const String& source, const String& entryPoint, const String& language,
  66. GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>::type* includes,
  67. bool isAdjacencyInfoRequired = false);
  68. /**
  69. * @copydoc Resource::initialize_internal.
  70. */
  71. virtual void initialize_internal();
  72. /**
  73. * @copydoc Resource::destroy_internal.
  74. */
  75. virtual void destroy_internal();
  76. /// The underlying assembler program
  77. GpuProgramPtr mAssemblerProgram;
  78. /************************************************************************/
  79. /* STATICS */
  80. /************************************************************************/
  81. public:
  82. static HHighLevelGpuProgram create(const String& source, const String& entryPoint,
  83. const String& language, GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>::type* includes = nullptr);
  84. };
  85. /** @} */
  86. }
  87. #endif