BsD3D11RenderSystem.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. /** @copydoc RenderSystem::bindGpuProgram() */
  47. void bindGpuProgram(HGpuProgram prg);
  48. /** @copydoc RenderSystem::unbindGpuProgram() */
  49. void unbindGpuProgram(GpuProgramType gptype);
  50. /** @copydoc RenderSystem::bindGpuParams() */
  51. void bindGpuParams(GpuProgramType gptype, BindableGpuParams& params);
  52. void setClipPlanesImpl(const PlaneList& clipPlanes);
  53. RenderSystemCapabilities* createRenderSystemCapabilities() const;
  54. void initialiseFromRenderSystemCapabilities(RenderSystemCapabilities* caps);
  55. void convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest, bool forGpuProgram = false);
  56. VertexElementType getColorVertexElementType() const;
  57. float getHorizontalTexelOffset();
  58. float getVerticalTexelOffset();
  59. float getMinimumDepthInputValue();
  60. float getMaximumDepthInputValue();
  61. /************************************************************************/
  62. /* Internal use by DX11 RenderSystem only */
  63. /************************************************************************/
  64. void determineMultisampleSettings(UINT32 multisampleCount, const String& multisampleHint, DXGI_FORMAT format, DXGI_SAMPLE_DESC* outputSampleDesc);
  65. bool checkTextureFilteringSupported(TextureType ttype, PixelFormat format, int usage);
  66. IDXGIFactory* getDXGIFactory() const { return mDXGIFactory; }
  67. D3D11Device& getPrimaryDevice() const { return *mDevice; }
  68. /**
  69. * @brief Returns a total number of outputs (e.g. monitors), across all adapters.
  70. */
  71. D3D11DriverList* getDriverList() const { return mDriverList; }
  72. protected:
  73. friend class D3D11RenderSystemFactory;
  74. /**
  75. * @copydoc RenderSystem::initialize_internal().
  76. */
  77. void initialize_internal(AsyncOp& asyncOp);
  78. /**
  79. * @copydoc RenderSystem::destroy_internal().
  80. */
  81. void destroy_internal();
  82. /**
  83. * @brief Creates or retrieves a proper input layout depending on the currently set vertex shader
  84. * and vertex buffer.
  85. *
  86. * Applies the input layout to the pipeline.
  87. */
  88. void applyInputLayout();
  89. private:
  90. IDXGIFactory* mDXGIFactory;
  91. D3D11Device* mDevice;
  92. D3D11DriverList* mDriverList;
  93. D3D11Driver* mActiveD3DDriver;
  94. D3D_FEATURE_LEVEL mFeatureLevel;
  95. D3D11HLSLProgramFactory* mHLSLFactory;
  96. D3D11InputLayoutManager* mIAManager;
  97. UINT32 mStencilRef;
  98. D3D11_VIEWPORT mViewport;
  99. D3D11_RECT mScissorRect;
  100. VertexDeclarationPtr mActiveVertexDeclaration;
  101. D3D11GpuProgramPtr mActiveVertexShader;
  102. DrawOperationType mActiveDrawOp;
  103. };
  104. }