CmD3D11HLSLProgram.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #include "CmD3D11Prerequisites.h"
  3. #include "CmHighLevelGpuProgram.h"
  4. namespace CamelotEngine
  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, bool isAdjacencyInfoRequired = false);
  29. /**
  30. * @copydoc GpuProgram::loadFromSource()
  31. */
  32. void loadFromSource();
  33. /**
  34. * @copydoc GpuProgram::unload_internal()
  35. */
  36. void unload_internal();
  37. private:
  38. bool mColumnMajorMatrices;
  39. bool mEnableBackwardsCompatibility;
  40. UINT32 mProgramId;
  41. HLSLMicroCode mMicrocode;
  42. VertexDeclarationPtr mInputDeclaration;
  43. /**
  44. * @brief Compiles the shader from source and generates the microcode.
  45. */
  46. ID3DBlob* compileMicrocode(const String& profile);
  47. /**
  48. * @brief Reflects the microcode and extracts input/output parameters, and constant
  49. * buffer structures used by the program.
  50. */
  51. void populateParametersAndConstants(ID3DBlob* microcode);
  52. /************************************************************************/
  53. /* SERIALIZATION */
  54. /************************************************************************/
  55. public:
  56. friend class D3D11HLSLProgramRTTI;
  57. static RTTITypeBase* getRTTIStatic();
  58. virtual RTTITypeBase* getRTTI() const;
  59. };
  60. }