CmD3D9HLSLProgram.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 __D3D9HLSLProgram_H__
  25. #define __D3D9HLSLProgram_H__
  26. #include "CmD3D9Prerequisites.h"
  27. #include "CmHighLevelGpuProgram.h"
  28. namespace CamelotFramework {
  29. /** Specialisation of HighLevelGpuProgram to provide support for D3D9
  30. High-Level Shader Language (HLSL).
  31. */
  32. class CM_D3D9_EXPORT D3D9HLSLProgram : public HighLevelGpuProgram
  33. {
  34. public:
  35. LPD3DXBUFFER getMicroCode();
  36. public:
  37. /// Shader optimisation level
  38. enum OptimisationLevel
  39. {
  40. /// default - no optimisation in debug mode, OPT_1 in release mode
  41. OPT_DEFAULT,
  42. /// No optimisation
  43. OPT_NONE,
  44. /// Optimisation level 0
  45. OPT_0,
  46. /// Optimisation level 1
  47. OPT_1,
  48. /// Optimisation level 2
  49. OPT_2,
  50. /// Optimisation level 3
  51. OPT_3
  52. };
  53. protected:
  54. OptimisationLevel mOptimisationLevel;
  55. public:
  56. ~D3D9HLSLProgram();
  57. /** Sets the preprocessor defines use to compile the program. */
  58. void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
  59. /** Sets the preprocessor defines use to compile the program. */
  60. const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
  61. /** Sets whether matrix packing in column-major order. */
  62. void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
  63. /** Gets whether matrix packed in column-major order. */
  64. bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
  65. /** Sets the optimisation level to use.
  66. @param opt Optimisation level
  67. */
  68. void setOptimisationLevel(OptimisationLevel opt) { mOptimisationLevel = opt; }
  69. /** Gets the optimisation level to use. */
  70. OptimisationLevel getOptimisationLevel() const { return mOptimisationLevel; }
  71. /// Overridden from GpuProgram
  72. bool isSupported(void) const;
  73. /// Overridden from GpuProgram
  74. GpuParamsPtr createParameters();
  75. /// Overridden from GpuProgram
  76. const String& getLanguage(void) const;
  77. protected:
  78. friend class D3D9HLSLProgramFactory;
  79. D3D9HLSLProgram(const String& source, const String& entryPoint, const String& language,
  80. GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>::type* includes,
  81. bool isAdjacencyInfoRequired = false);
  82. /**
  83. * @copydoc HighLevelGpuProgram::initialize_internal().
  84. */
  85. void initialize_internal();
  86. /**
  87. * @copydoc HighLevelGpuProgram::destroy_internal().
  88. */
  89. void destroy_internal();
  90. String mPreprocessorDefines;
  91. bool mColumnMajorMatrices;
  92. LPD3DXBUFFER mpMicroCode;
  93. /************************************************************************/
  94. /* SERIALIZATION */
  95. /************************************************************************/
  96. public:
  97. friend class D3D9HLSLProgramRTTI;
  98. static RTTITypeBase* getRTTIStatic();
  99. virtual RTTITypeBase* getRTTI() const;
  100. };
  101. }
  102. #endif