blob: e8e4c9ea2f1ceb3e5956254d569105dbd958a14c [file] [log] [blame]
Geoff Langda507fe2013-08-20 12:01:42 -04001//
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
14namespace gl
15{
16class Framebuffer;
17}
18
19namespace rx
20{
21class Renderer11;
Geoff Lang3b866b62013-09-30 15:21:00 -040022class RenderTarget11;
Geoff Langda507fe2013-08-20 12:01:42 -040023
24class Clear11
25{
26 public:
27 explicit Clear11(Renderer11 *renderer);
28 ~Clear11();
29
30 // Clears the framebuffer with the supplied clear parameters, assumes that the framebuffer is currently applied.
31 void clearFramebuffer(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer);
32
33 private:
34 Renderer11 *mRenderer;
35
36 struct ClearBlendInfo
37 {
Geoff Lang3b866b62013-09-30 15:21:00 -040038 bool maskChannels[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT][4];
Geoff Langda507fe2013-08-20 12:01:42 -040039 };
40 typedef bool (*ClearBlendInfoComparisonFunction)(const ClearBlendInfo&, const ClearBlendInfo &);
41 typedef std::map<ClearBlendInfo, ID3D11BlendState*, ClearBlendInfoComparisonFunction> ClearBlendStateMap;
42 ClearBlendStateMap mClearBlendStates;
43
Geoff Lang3b866b62013-09-30 15:21:00 -040044 ID3D11BlendState *getBlendState(const gl::ClearParameters &clearParams, const std::vector<RenderTarget11*>& rts);
Geoff Langda507fe2013-08-20 12:01:42 -040045
46 struct ClearShader
47 {
48 ID3D11InputLayout *inputLayout;
49 ID3D11VertexShader *vertexShader;
50 ID3D11PixelShader *pixelShader;
51 };
52 ClearShader mFloatClearShader;
53 ClearShader mUintClearShader;
54 ClearShader mIntClearShader;
55
56 template <unsigned int vsSize, unsigned int psSize>
57 static ClearShader CreateClearShader(ID3D11Device *device, DXGI_FORMAT colorType, const BYTE (&vsByteCode)[vsSize], const BYTE (&psByteCode)[psSize]);
58
59 struct ClearDepthStencilInfo
60 {
61 bool clearDepth;
62 bool clearStencil;
63 UINT8 stencilWriteMask;
64 };
65 typedef bool (*ClearDepthStencilInfoComparisonFunction)(const ClearDepthStencilInfo&, const ClearDepthStencilInfo &);
66 typedef std::map<ClearDepthStencilInfo, ID3D11DepthStencilState*, ClearDepthStencilInfoComparisonFunction> ClearDepthStencilStateMap;
67 ClearDepthStencilStateMap mClearDepthStencilStates;
68
69 ID3D11DepthStencilState *getDepthStencilState(const gl::ClearParameters &clearParams);
70
71 ID3D11Buffer *mVertexBuffer;
72 ID3D11RasterizerState *mRasterizerState;
73};
74
75}
76
77#endif // LIBGLESV2_RENDERER_CLEAR11_H_