CmD3D11RenderSystem.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #pragma once
  2. #include "CmD3D11Prerequisites.h"
  3. #include "CmRenderSystem.h"
  4. namespace CamelotFramework
  5. {
  6. class CM_D3D11_EXPORT D3D11RenderSystem : public RenderSystem
  7. {
  8. public:
  9. ~D3D11RenderSystem();
  10. /**
  11. * @copydoc RenderSystem::getName()
  12. */
  13. const String& getName() const;
  14. /**
  15. * @copydoc RenderSystem::getShadingLanguageName()
  16. */
  17. const String& getShadingLanguageName() const;
  18. void setBlendState(const BlendStatePtr& blendState);
  19. void setRasterizerState(const RasterizerStatePtr& rasterizerState);
  20. void setDepthStencilState(const DepthStencilStatePtr& depthStencilState, UINT32 stencilRefValue);
  21. void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SamplerStatePtr& samplerState);
  22. void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const TexturePtr &texPtr);
  23. void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit);
  24. void beginFrame();
  25. void endFrame();
  26. void clear(RenderTargetPtr target, unsigned int buffers, const Color& color = Color::Black, float depth = 1.0f, unsigned short stencil = 0);
  27. void setRenderTarget(RenderTargetPtr target);
  28. void setViewport(ViewportPtr& vp);
  29. void setScissorRect(UINT32 left = 0, UINT32 top = 0, UINT32 right = 800, UINT32 bottom = 600);
  30. void setVertexBuffer(UINT32 index, const VertexBufferPtr& buffer);
  31. void setIndexBuffer(const IndexBufferPtr& buffer);
  32. void setVertexDeclaration(VertexDeclarationPtr vertexDeclaration);
  33. void setDrawOperation(DrawOperationType op);
  34. /** @copydoc RenderSystem::draw() */
  35. void draw(UINT32 vertexCount);
  36. /** @copydoc RenderSystem::drawIndexed() */
  37. void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexCount);
  38. /** @copydoc RenderSystem::bindGpuProgram() */
  39. void bindGpuProgram(HGpuProgram prg);
  40. /** @copydoc RenderSystem::unbindGpuProgram() */
  41. void unbindGpuProgram(GpuProgramType gptype);
  42. /** @copydoc RenderSystem::bindGpuParams() */
  43. void bindGpuParams(GpuProgramType gptype, BindableGpuParams& params);
  44. void setClipPlanesImpl(const PlaneList& clipPlanes);
  45. RenderSystemCapabilities* createRenderSystemCapabilities() const;
  46. void initialiseFromRenderSystemCapabilities(RenderSystemCapabilities* caps);
  47. String getErrorDescription(long errorNumber) const;
  48. void convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest, bool forGpuProgram = false);
  49. VertexElementType getColorVertexElementType() const;
  50. float getHorizontalTexelOffset();
  51. float getVerticalTexelOffset();
  52. float getMinimumDepthInputValue();
  53. float getMaximumDepthInputValue();
  54. /************************************************************************/
  55. /* Internal use by DX11 RenderSystem only */
  56. /************************************************************************/
  57. void determineFSAASettings(UINT32 fsaa, const String& fsaaHint, DXGI_FORMAT format, DXGI_SAMPLE_DESC* outFSAASettings);
  58. bool checkTextureFilteringSupported(TextureType ttype, PixelFormat format, int usage);
  59. IDXGIFactory* getDXGIFactory() const { return mDXGIFactory; }
  60. D3D11Device& getPrimaryDevice() const { return *mDevice; }
  61. /**
  62. * @brief Returns a total number of outputs (e.g. monitors), across all adapters.
  63. */
  64. D3D11DriverList* getDriverList() const { return mDriverList; }
  65. protected:
  66. friend class D3D11RenderSystemFactory;
  67. D3D11RenderSystem();
  68. /**
  69. * @copydoc RenderSystem::initialize_internal().
  70. */
  71. void initialize_internal(AsyncOp& asyncOp);
  72. /**
  73. * @copydoc RenderSystem::destroy_internal().
  74. */
  75. void destroy_internal();
  76. private:
  77. IDXGIFactory* mDXGIFactory;
  78. D3D11Device* mDevice;
  79. D3D11DriverList* mDriverList;
  80. D3D11Driver* mActiveD3DDriver;
  81. D3D_FEATURE_LEVEL mFeatureLevel;
  82. D3D11HLSLProgramFactory* mHLSLFactory;
  83. D3D11InputLayoutManager* mIAManager;
  84. // State variables
  85. UINT32 mStencilRef;
  86. D3D11_VIEWPORT mViewport;
  87. D3D11_RECT mScissorRect;
  88. VertexDeclarationPtr mActiveVertexDeclaration;
  89. D3D11HLSLProgramPtr mActiveVertexShader;
  90. /**
  91. * @brief Creates or retrieves a proper input layout depending on the currently set vertex shader
  92. * and vertex buffer.
  93. *
  94. * Applies the input layout to the pipeline.
  95. */
  96. void applyInputLayout();
  97. };
  98. }