1 // 2 // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // Clear11.h: Framebuffer clear utility class. 8 9 #ifndef LIBGLESV2_RENDERER_CLEAR11_H_ 10 #define LIBGLESV2_RENDERER_CLEAR11_H_ 11 12 #include "libGLESv2/angletypes.h" 13 #include "libGLESv2/Error.h" 14 15 #include <map> 16 #include <vector> 17 18 namespace gl 19 { 20 class Framebuffer; 21 } 22 23 namespace rx 24 { 25 class Renderer11; 26 class RenderTarget11; 27 28 class Clear11 29 { 30 public: 31 explicit Clear11(Renderer11 *renderer); 32 ~Clear11(); 33 34 // Clears the framebuffer with the supplied clear parameters, assumes that the framebuffer is currently applied. 35 gl::Error clearFramebuffer(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer); 36 37 private: 38 Renderer11 *mRenderer; 39 40 struct ClearBlendInfo 41 { 42 bool maskChannels[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT][4]; 43 }; 44 typedef bool (*ClearBlendInfoComparisonFunction)(const ClearBlendInfo&, const ClearBlendInfo &); 45 typedef std::map<ClearBlendInfo, ID3D11BlendState*, ClearBlendInfoComparisonFunction> ClearBlendStateMap; 46 ClearBlendStateMap mClearBlendStates; 47 48 struct MaskedRenderTarget 49 { 50 bool colorMask[4]; 51 RenderTarget11 *renderTarget; 52 }; 53 54 ID3D11BlendState *getBlendState(const std::vector<MaskedRenderTarget> &rts); 55 56 struct ClearShader 57 { 58 ID3D11InputLayout *inputLayout; 59 ID3D11VertexShader *vertexShader; 60 ID3D11PixelShader *pixelShader; 61 }; 62 ClearShader mFloatClearShader; 63 ClearShader mUintClearShader; 64 ClearShader mIntClearShader; 65 66 template <unsigned int vsSize, unsigned int psSize> 67 static ClearShader CreateClearShader(ID3D11Device *device, DXGI_FORMAT colorType, const BYTE (&vsByteCode)[vsSize], const BYTE (&psByteCode)[psSize]); 68 69 struct ClearDepthStencilInfo 70 { 71 bool clearDepth; 72 bool clearStencil; 73 UINT8 stencilWriteMask; 74 }; 75 typedef bool (*ClearDepthStencilInfoComparisonFunction)(const ClearDepthStencilInfo&, const ClearDepthStencilInfo &); 76 typedef std::map<ClearDepthStencilInfo, ID3D11DepthStencilState*, ClearDepthStencilInfoComparisonFunction> ClearDepthStencilStateMap; 77 ClearDepthStencilStateMap mClearDepthStencilStates; 78 79 ID3D11DepthStencilState *getDepthStencilState(const gl::ClearParameters &clearParams); 80 81 ID3D11Buffer *mVertexBuffer; 82 ID3D11RasterizerState *mRasterizerState; 83 }; 84 85 } 86 87 #endif // LIBGLESV2_RENDERER_CLEAR11_H_ 88