~gabriel1984sibiu/minitube/qt5.6

« back to all changes in this revision

Viewing changes to src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d9/StateManager9.h

  • Committer: Grevutiu Gabriel
  • Date: 2017-06-13 08:43:17 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20170613084317-ek0zqe0u9g3ocvi8
OriginalĀ upstreamĀ code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Copyright (c) 2015 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
// StateManager9.h: Defines a class for caching D3D9 state
 
8
 
 
9
#ifndef LIBANGLE_RENDERER_D3D9_STATEMANAGER9_H_
 
10
#define LIBANGLE_RENDERER_D3D9_STATEMANAGER9_H_
 
11
 
 
12
#include "libANGLE/angletypes.h"
 
13
#include "libANGLE/Data.h"
 
14
#include "libANGLE/State.h"
 
15
#include "libANGLE/renderer/d3d/RendererD3D.h"
 
16
 
 
17
namespace rx
 
18
{
 
19
 
 
20
class Renderer9;
 
21
 
 
22
struct dx_VertexConstants9
 
23
{
 
24
    float depthRange[4];
 
25
    float viewAdjust[4];
 
26
    float viewCoords[4];
 
27
};
 
28
 
 
29
struct dx_PixelConstants9
 
30
{
 
31
    float depthRange[4];
 
32
    float viewCoords[4];
 
33
    float depthFront[4];
 
34
};
 
35
 
 
36
class StateManager9 final : angle::NonCopyable
 
37
{
 
38
  public:
 
39
    StateManager9(Renderer9 *renderer9);
 
40
    ~StateManager9();
 
41
 
 
42
    void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits);
 
43
 
 
44
    gl::Error setBlendDepthRasterStates(const gl::State &glState, unsigned int sampleMask);
 
45
    void setScissorState(const gl::Rectangle &scissor, bool enabled);
 
46
    void setViewportState(const gl::Caps *caps,
 
47
                          const gl::Rectangle &viewport,
 
48
                          float zNear,
 
49
                          float zFar,
 
50
                          GLenum drawMode,
 
51
                          GLenum frontFace,
 
52
                          bool ignoreViewport);
 
53
 
 
54
    void setShaderConstants();
 
55
 
 
56
    void forceSetBlendState();
 
57
    void forceSetRasterState();
 
58
    void forceSetDepthStencilState();
 
59
    void forceSetScissorState();
 
60
    void forceSetViewportState();
 
61
    void forceSetDXUniformsState();
 
62
 
 
63
    void updateDepthSizeIfChanged(bool depthStencilInitialized, unsigned int depthSize);
 
64
    void updateStencilSizeIfChanged(bool depthStencilInitialized, unsigned int stencilSize);
 
65
 
 
66
    void setRenderTargetBounds(size_t width, size_t height);
 
67
 
 
68
    int getRenderTargetWidth() const { return mRenderTargetBounds.width; }
 
69
    int getRenderTargetHeight() const { return mRenderTargetBounds.height; }
 
70
 
 
71
    void resetDirtyBits() { mDirtyBits.reset(); }
 
72
 
 
73
  private:
 
74
    // Blend state functions
 
75
    void setBlendEnabled(bool enabled);
 
76
    void setBlendColor(const gl::BlendState &blendState, const gl::ColorF &blendColor);
 
77
    void setBlendFuncsEquations(const gl::BlendState &blendState);
 
78
    void setColorMask(const gl::Framebuffer *framebuffer,
 
79
                      bool red,
 
80
                      bool blue,
 
81
                      bool green,
 
82
                      bool alpha);
 
83
    void setSampleAlphaToCoverage(bool enabled);
 
84
    void setDither(bool dither);
 
85
    void setSampleMask(unsigned int sampleMask);
 
86
 
 
87
    // Current raster state functions
 
88
    void setCullMode(bool cullFace, GLenum cullMode, GLenum frontFace);
 
89
    void setDepthBias(bool polygonOffsetFill,
 
90
                      GLfloat polygonOffsetFactor,
 
91
                      GLfloat polygonOffsetUnits);
 
92
 
 
93
    // Depth stencil state functions
 
94
    void setStencilOpsFront(GLenum stencilFail,
 
95
                            GLenum stencilPassDepthFail,
 
96
                            GLenum stencilPassDepthPass,
 
97
                            bool frontFaceCCW);
 
98
    void setStencilOpsBack(GLenum stencilBackFail,
 
99
                           GLenum stencilBackPassDepthFail,
 
100
                           GLenum stencilBackPassDepthPass,
 
101
                           bool frontFaceCCW);
 
102
    void setStencilBackWriteMask(GLuint stencilBackWriteMask, bool frontFaceCCW);
 
103
    void setDepthFunc(bool depthTest, GLenum depthFunc);
 
104
    void setStencilTestEnabled(bool enabled);
 
105
    void setDepthMask(bool depthMask);
 
106
    void setStencilFuncsFront(GLenum stencilFunc,
 
107
                              GLuint stencilMask,
 
108
                              GLint stencilRef,
 
109
                              bool frontFaceCCW,
 
110
                              unsigned int maxStencil);
 
111
    void setStencilFuncsBack(GLenum stencilBackFunc,
 
112
                             GLuint stencilBackMask,
 
113
                             GLint stencilBackRef,
 
114
                             bool frontFaceCCW,
 
115
                             unsigned int maxStencil);
 
116
    void setStencilWriteMask(GLuint stencilWriteMask, bool frontFaceCCW);
 
117
 
 
118
    void setScissorEnabled(bool scissorEnabled);
 
119
    void setScissorRect(const gl::Rectangle &scissor, bool enabled);
 
120
 
 
121
    enum DirtyBitType
 
122
    {
 
123
        // Blend dirty bits
 
124
        DIRTY_BIT_BLEND_ENABLED,
 
125
        DIRTY_BIT_BLEND_COLOR,
 
126
        DIRTY_BIT_BLEND_FUNCS_EQUATIONS,
 
127
        DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE,
 
128
        DIRTY_BIT_COLOR_MASK,
 
129
        DIRTY_BIT_DITHER,
 
130
        DIRTY_BIT_SAMPLE_MASK,
 
131
 
 
132
        // Rasterizer dirty bits
 
133
        DIRTY_BIT_CULL_MODE,
 
134
        DIRTY_BIT_DEPTH_BIAS,
 
135
 
 
136
        // Depth stencil dirty bits
 
137
        DIRTY_BIT_STENCIL_DEPTH_MASK,
 
138
        DIRTY_BIT_STENCIL_DEPTH_FUNC,
 
139
        DIRTY_BIT_STENCIL_TEST_ENABLED,
 
140
        DIRTY_BIT_STENCIL_FUNCS_FRONT,
 
141
        DIRTY_BIT_STENCIL_FUNCS_BACK,
 
142
        DIRTY_BIT_STENCIL_WRITEMASK_FRONT,
 
143
        DIRTY_BIT_STENCIL_WRITEMASK_BACK,
 
144
        DIRTY_BIT_STENCIL_OPS_FRONT,
 
145
        DIRTY_BIT_STENCIL_OPS_BACK,
 
146
 
 
147
        // Scissor dirty bits
 
148
        DIRTY_BIT_SCISSOR_ENABLED,
 
149
        DIRTY_BIT_SCISSOR_RECT,
 
150
 
 
151
        // Viewport dirty bits
 
152
        DIRTY_BIT_VIEWPORT,
 
153
 
 
154
        DIRTY_BIT_MAX
 
155
    };
 
156
 
 
157
    typedef std::bitset<DIRTY_BIT_MAX> DirtyBits;
 
158
 
 
159
    // Currently applied blend state
 
160
    gl::BlendState mCurBlendState;
 
161
    gl::ColorF mCurBlendColor;
 
162
    unsigned int mCurSampleMask;
 
163
    DirtyBits mBlendStateDirtyBits;
 
164
 
 
165
    // Currently applied raster state
 
166
    gl::RasterizerState mCurRasterState;
 
167
    unsigned int mCurDepthSize;
 
168
    DirtyBits mRasterizerStateDirtyBits;
 
169
 
 
170
    // Currently applied depth stencil state
 
171
    gl::DepthStencilState mCurDepthStencilState;
 
172
    int mCurStencilRef;
 
173
    int mCurStencilBackRef;
 
174
    bool mCurFrontFaceCCW;
 
175
    unsigned int mCurStencilSize;
 
176
    DirtyBits mDepthStencilStateDirtyBits;
 
177
 
 
178
    // Currently applied scissor states
 
179
    gl::Rectangle mCurScissorRect;
 
180
    bool mCurScissorEnabled;
 
181
    gl::Extents mRenderTargetBounds;
 
182
    DirtyBits mScissorStateDirtyBits;
 
183
 
 
184
    // Currently applied viewport states
 
185
    bool mForceSetViewport;
 
186
    gl::Rectangle mCurViewport;
 
187
    float mCurNear;
 
188
    float mCurFar;
 
189
    float mCurDepthFront;
 
190
    bool mCurIgnoreViewport;
 
191
 
 
192
    dx_VertexConstants9 mVertexConstants;
 
193
    dx_PixelConstants9 mPixelConstants;
 
194
    bool mDxUniformsDirty;
 
195
 
 
196
    // FIXME: Unsupported by D3D9
 
197
    static const D3DRENDERSTATETYPE D3DRS_CCW_STENCILREF       = D3DRS_STENCILREF;
 
198
    static const D3DRENDERSTATETYPE D3DRS_CCW_STENCILMASK      = D3DRS_STENCILMASK;
 
199
    static const D3DRENDERSTATETYPE D3DRS_CCW_STENCILWRITEMASK = D3DRS_STENCILWRITEMASK;
 
200
 
 
201
    Renderer9 *mRenderer9;
 
202
    DirtyBits mDirtyBits;
 
203
};
 
204
 
 
205
}  // namespace rx
 
206
#endif  // LIBANGLE_RENDERER_D3D9_STATEMANAGER9_H_