| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- #pragma once
- #include "BsD3D11Prerequisites.h"
- #include "BsRenderSystem.h"
- namespace BansheeEngine
- {
- /**
- * @brief Implementation of a render system using DirectX 11. Provides abstracted
- * access to various low level DX11 methods.
- */
- class BS_D3D11_EXPORT D3D11RenderSystem : public RenderSystem
- {
- public:
- D3D11RenderSystem();
- ~D3D11RenderSystem();
- /**
- * @copydoc RenderSystem::getName
- */
- const String& getName() const;
-
- /**
- * @copydoc RenderSystem::getShadingLanguageName
- */
- const String& getShadingLanguageName() const;
- /**
- * @copydoc RenderSystem::setBlendState
- */
- void setBlendState(const SPtr<BlendStateCore>& blendState);
- /**
- * @copydoc RenderSystem::setRasterizerState
- */
- void setRasterizerState(const SPtr<RasterizerStateCore>& rasterizerState);
- /**
- * @copydoc RenderSystem::setDepthStencilState
- */
- void setDepthStencilState(const SPtr<DepthStencilStateCore>& depthStencilState, UINT32 stencilRefValue);
- /**
- * @copydoc RenderSystem::setSamplerState
- */
- void setSamplerState(GpuProgramType gptype, UINT16 texUnit, const SPtr<SamplerStateCore>& samplerState);
- /**
- * @copydoc RenderSystem::setTexture
- */
- void setTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& texPtr);
- /**
- * @copydoc RenderSystem::setLoadStoreTexture
- */
- void setLoadStoreTexture(GpuProgramType gptype, UINT16 unit, bool enabled, const SPtr<TextureCore>& texPtr,
- const TextureSurface& surface);
- /**
- * @copydoc RenderSystem::disableTextureUnit
- */
- void disableTextureUnit(GpuProgramType gptype, UINT16 texUnit);
- /**
- * @copydoc RenderSystem::beginFrame
- */
- void beginFrame();
- /**
- * @copydoc RenderSystem::endFrame
- */
- void endFrame();
- /**
- * @copydoc RenderSystem::clearRenderTarget
- */
- void clearRenderTarget(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0);
- /**
- * @copydoc RenderSystem::clearViewport
- */
- void clearViewport(UINT32 buffers, const Color& color = Color::Black, float depth = 1.0f, UINT16 stencil = 0);
- /**
- * @copydoc RenderSystem::setRenderTarget
- */
- void setRenderTarget(const SPtr<RenderTargetCore>& target);
- /**
- * @copydoc RenderSystem::setViewport
- */
- void setViewport(const Rect2& vp);
- /**
- * @copydoc RenderSystem::setScissorRect
- */
- void setScissorRect(UINT32 left, UINT32 top, UINT32 right, UINT32 bottom);
- /**
- * @copydoc RenderSystem::setVertexBuffers
- */
- void setVertexBuffers(UINT32 index, SPtr<VertexBufferCore>* buffers, UINT32 numBuffers);
- /**
- * @copydoc RenderSystem::setIndexBuffer
- */
- void setIndexBuffer(const SPtr<IndexBufferCore>& buffer);
- /**
- * @copydoc RenderSystem::setVertexDeclaration
- */
- void setVertexDeclaration(const SPtr<VertexDeclarationCore>& vertexDeclaration);
- /**
- * @copydoc RenderSystem::setDrawOperation
- */
- void setDrawOperation(DrawOperationType op);
- /**
- * @copydoc RenderSystem::draw
- */
- void draw(UINT32 vertexOffset, UINT32 vertexCount);
- /**
- * @copydoc RenderSystem::drawIndexed
- */
- void drawIndexed(UINT32 startIndex, UINT32 indexCount, UINT32 vertexOffset, UINT32 vertexCount);
- /**
- * @copydoc RenderSystem::bindGpuProgram
- */
- void bindGpuProgram(const SPtr<GpuProgramCore>& prg);
- /**
- * @copydoc RenderSystem::unbindGpuProgram
- */
- void unbindGpuProgram(GpuProgramType gptype);
- /**
- * @copydoc RenderSystem::bindGpuParams
- */
- void bindGpuParams(GpuProgramType gptype, const SPtr<GpuParamsCore>& params);
-
- /**
- * @copydoc RenderSystem::setClipPlanesImpl
- */
- void setClipPlanesImpl(const PlaneList& clipPlanes);
- /**
- * @copydoc RenderSystem::convertProjectionMatrix
- */
- void convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest);
- /**
- * @copydoc RenderSystem::getColorVertexElementType
- */
- VertexElementType getColorVertexElementType() const;
- /**
- * @copydoc RenderSystem::getHorizontalTexelOffset
- */
- float getHorizontalTexelOffset();
- /**
- * @copydoc RenderSystem::getVerticalTexelOffset
- */
- float getVerticalTexelOffset();
- /**
- * @copydoc RenderSystem::getMinimumDepthInputValue
- */
- float getMinimumDepthInputValue();
- /**
- * @copydoc RenderSystem::getMaximumDepthInputValue
- */
- float getMaximumDepthInputValue();
- /************************************************************************/
- /* Internal use by DX11 RenderSystem only */
- /************************************************************************/
- /**
- * @brief Determines DXGI multisample settings from the provided parameters.
- *
- * @param multisampleCount Number of requested samples.
- * @param format Pixel format used by the render target.
- * @param outputSampleDesc Output structure that will contain the requested multisample settings.
- */
- void determineMultisampleSettings(UINT32 multisampleCount, DXGI_FORMAT format, DXGI_SAMPLE_DESC* outputSampleDesc);
- /**
- * @brief Returns the main DXGI factory object.
- */
- IDXGIFactory* getDXGIFactory() const { return mDXGIFactory; }
- /**
- * @brief Returns the primary DX11 device object.
- */
- D3D11Device& getPrimaryDevice() const { return *mDevice; }
-
- /**
- * @brief Returns information describing all available drivers.
- */
- D3D11DriverList* getDriverList() const { return mDriverList; }
- protected:
- friend class D3D11RenderSystemFactory;
- /**
- * @copydoc RenderSystem::initializePrepare
- */
- void initializePrepare();
- /**
- * @copydoc RenderSystem::initializeFinalize
- */
- void initializeFinalize(const SPtr<RenderWindowCore>& primaryWindow);
- /**
- * @copydoc RenderSystem::destroy_internal
- */
- void destroy_internal();
- /**
- * @brief Creates or retrieves a proper input layout depending on the currently set vertex shader
- * and vertex buffer.
- *
- * Applies the input layout to the pipeline.
- */
- void applyInputLayout();
- /**
- * @brief Recalculates actual viewport dimensions based on currently
- * set viewport normalized dimensions and render target and applies
- * them for further rendering.
- */
- void applyViewport();
- /**
- * @brief Creates and populates a set of render system capabilities describing which functionality
- * is available.
- */
- RenderSystemCapabilities* createRenderSystemCapabilities() const;
- private:
- IDXGIFactory* mDXGIFactory;
- D3D11Device* mDevice;
- D3D11DriverList* mDriverList;
- D3D11Driver* mActiveD3DDriver;
- D3D_FEATURE_LEVEL mFeatureLevel;
- D3D11HLSLProgramFactory* mHLSLFactory;
- D3D11InputLayoutManager* mIAManager;
- std::pair<SPtr<TextureCore>, TextureViewPtr> mBoundUAVs[D3D11_PS_CS_UAV_REGISTER_COUNT];
- UINT32 mStencilRef;
- Rect2 mViewportNorm;
- D3D11_VIEWPORT mViewport;
- D3D11_RECT mScissorRect;
- SPtr<VertexDeclarationCore> mActiveVertexDeclaration;
- SPtr<D3D11GpuProgramCore> mActiveVertexShader;
- DrawOperationType mActiveDrawOp;
- };
- }
|