CmD3D11HLSLProgram.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include "CmD3D11Prerequisites.h"
  3. #include "CmHighLevelGpuProgram.h"
  4. namespace CamelotFramework
  5. {
  6. class D3D11HLSLProgram : public HighLevelGpuProgram
  7. {
  8. static UINT32 globalProgramId;
  9. public:
  10. ~D3D11HLSLProgram();
  11. const String& getLanguage() const;
  12. bool isSupported() const;
  13. GpuParamsPtr createParameters();
  14. /** Sets whether matrix packing in column-major order. */
  15. void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
  16. /** Gets whether matrix packed in column-major order. */
  17. bool getColumnMajorMatrices() const { return mColumnMajorMatrices; }
  18. /** Sets whether backwards compatibility is enabled. */
  19. void setEnableBackwardsCompatibility(bool enableBackwardsCompatibility) { mEnableBackwardsCompatibility = enableBackwardsCompatibility; }
  20. /** Gets whether backwards compatibility is enabled. */
  21. bool getEnableBackwardsCompatibility() const { return mEnableBackwardsCompatibility; }
  22. const HLSLMicroCode& getMicroCode() const { return mMicrocode; }
  23. VertexDeclarationPtr getInputDeclaration() const { return mInputDeclaration; }
  24. UINT32 getProgramId() const { return mProgramId; }
  25. protected:
  26. friend class D3D11HLSLProgramFactory;
  27. D3D11HLSLProgram(const String& source, const String& entryPoint, const String& language,
  28. GpuProgramType gptype, GpuProgramProfile profile, const Vector<HGpuProgInclude>::type* includes,
  29. bool isAdjacencyInfoRequired = false);
  30. /**
  31. * @copydoc HighLevelGpuProgram::initialize_internal()
  32. */
  33. void initialize_internal();
  34. /**
  35. * @copydoc HighLevelGpuProgram::destroy_internal()
  36. */
  37. void destroy_internal();
  38. private:
  39. bool mColumnMajorMatrices;
  40. bool mEnableBackwardsCompatibility;
  41. UINT32 mProgramId;
  42. HLSLMicroCode mMicrocode;
  43. VertexDeclarationPtr mInputDeclaration;
  44. /**
  45. * @brief Compiles the shader from source and generates the microcode.
  46. */
  47. ID3DBlob* compileMicrocode(const String& profile);
  48. /**
  49. * @brief Reflects the microcode and extracts input/output parameters, and constant
  50. * buffer structures used by the program.
  51. */
  52. void populateParametersAndConstants(ID3DBlob* microcode);
  53. /************************************************************************/
  54. /* SERIALIZATION */
  55. /************************************************************************/
  56. public:
  57. friend class D3D11HLSLProgramRTTI;
  58. static RTTITypeBase* getRTTIStatic();
  59. virtual RTTITypeBase* getRTTI() const;
  60. };
  61. }