BsD3D11RenderSystem.h 4.4 KB

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