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.
7
// StateManager9.h: Defines a class for caching D3D9 state
9
#ifndef LIBANGLE_RENDERER_D3D9_STATEMANAGER9_H_
10
#define LIBANGLE_RENDERER_D3D9_STATEMANAGER9_H_
12
#include "libANGLE/angletypes.h"
13
#include "libANGLE/Data.h"
14
#include "libANGLE/State.h"
15
#include "libANGLE/renderer/d3d/RendererD3D.h"
22
struct dx_VertexConstants9
29
struct dx_PixelConstants9
36
class StateManager9 final : angle::NonCopyable
39
StateManager9(Renderer9 *renderer9);
42
void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits);
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,
54
void setShaderConstants();
56
void forceSetBlendState();
57
void forceSetRasterState();
58
void forceSetDepthStencilState();
59
void forceSetScissorState();
60
void forceSetViewportState();
61
void forceSetDXUniformsState();
63
void updateDepthSizeIfChanged(bool depthStencilInitialized, unsigned int depthSize);
64
void updateStencilSizeIfChanged(bool depthStencilInitialized, unsigned int stencilSize);
66
void setRenderTargetBounds(size_t width, size_t height);
68
int getRenderTargetWidth() const { return mRenderTargetBounds.width; }
69
int getRenderTargetHeight() const { return mRenderTargetBounds.height; }
71
void resetDirtyBits() { mDirtyBits.reset(); }
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,
83
void setSampleAlphaToCoverage(bool enabled);
84
void setDither(bool dither);
85
void setSampleMask(unsigned int sampleMask);
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);
93
// Depth stencil state functions
94
void setStencilOpsFront(GLenum stencilFail,
95
GLenum stencilPassDepthFail,
96
GLenum stencilPassDepthPass,
98
void setStencilOpsBack(GLenum stencilBackFail,
99
GLenum stencilBackPassDepthFail,
100
GLenum stencilBackPassDepthPass,
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,
110
unsigned int maxStencil);
111
void setStencilFuncsBack(GLenum stencilBackFunc,
112
GLuint stencilBackMask,
113
GLint stencilBackRef,
115
unsigned int maxStencil);
116
void setStencilWriteMask(GLuint stencilWriteMask, bool frontFaceCCW);
118
void setScissorEnabled(bool scissorEnabled);
119
void setScissorRect(const gl::Rectangle &scissor, bool enabled);
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,
130
DIRTY_BIT_SAMPLE_MASK,
132
// Rasterizer dirty bits
134
DIRTY_BIT_DEPTH_BIAS,
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,
147
// Scissor dirty bits
148
DIRTY_BIT_SCISSOR_ENABLED,
149
DIRTY_BIT_SCISSOR_RECT,
151
// Viewport dirty bits
157
typedef std::bitset<DIRTY_BIT_MAX> DirtyBits;
159
// Currently applied blend state
160
gl::BlendState mCurBlendState;
161
gl::ColorF mCurBlendColor;
162
unsigned int mCurSampleMask;
163
DirtyBits mBlendStateDirtyBits;
165
// Currently applied raster state
166
gl::RasterizerState mCurRasterState;
167
unsigned int mCurDepthSize;
168
DirtyBits mRasterizerStateDirtyBits;
170
// Currently applied depth stencil state
171
gl::DepthStencilState mCurDepthStencilState;
173
int mCurStencilBackRef;
174
bool mCurFrontFaceCCW;
175
unsigned int mCurStencilSize;
176
DirtyBits mDepthStencilStateDirtyBits;
178
// Currently applied scissor states
179
gl::Rectangle mCurScissorRect;
180
bool mCurScissorEnabled;
181
gl::Extents mRenderTargetBounds;
182
DirtyBits mScissorStateDirtyBits;
184
// Currently applied viewport states
185
bool mForceSetViewport;
186
gl::Rectangle mCurViewport;
189
float mCurDepthFront;
190
bool mCurIgnoreViewport;
192
dx_VertexConstants9 mVertexConstants;
193
dx_PixelConstants9 mPixelConstants;
194
bool mDxUniformsDirty;
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;
201
Renderer9 *mRenderer9;
202
DirtyBits mDirtyBits;
206
#endif // LIBANGLE_RENDERER_D3D9_STATEMANAGER9_H_