Hash :
ff2ab571
Author :
Date :
2015-10-05T16:48:06
Using dirty bits notification for blend state BUG=angleproject:1161 Dirty bit notifications are used in GL for state tracking, but not D3D. Before, D3D would use memcmp to check a change in state for every call. This showed up as a hot spot in the perf test runs. Hence, switching D3D over to the dirty bit system similar to GL backend will help. Change-Id: I482edc852f1dcc888af3038ff3a61916496a02bc Reviewed-on: https://chromium-review.googlesource.com/305295 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tryjob-Request: Dian Xiang <dianx@google.com> Tested-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// StateManagerD3D.h: Defines a class for caching D3D state
#ifndef LIBANGLE_RENDERER_D3D_STATEMANAGERD3D_H_
#define LIBANGLE_RENDERER_D3D_STATEMANAGERD3D_H_
#include "libANGLE/angletypes.h"
#include "libANGLE/Data.h"
#include "libANGLE/State.h"
namespace rx
{
class StateManagerD3D : angle::NonCopyable
{
public:
explicit StateManagerD3D();
virtual ~StateManagerD3D();
void syncExternalDirtyBits(const gl::State::DirtyBits &dirtyBits);
gl::Error syncState(const gl::Data &data, const gl::State::DirtyBits &dirtyBits);
virtual gl::Error setBlendState(const gl::Framebuffer *framebuffer,
const gl::BlendState &blendState,
const gl::ColorF &blendColor,
unsigned int sampleMask,
const gl::State::DirtyBits &dirtyBits) = 0;
virtual gl::Error setDepthStencilState(const gl::DepthStencilState &depthStencilState,
int stencilRef,
int stencilBackRef,
bool frontFaceCCW,
const gl::State::DirtyBits &dirtyBits) = 0;
virtual gl::Error setRasterizerState(const gl::RasterizerState &rasterizerState,
const gl::State::DirtyBits &dirtyBits) = 0;
void setRasterizerScissorEnabled(bool enabled);
void setCurStencilSize(unsigned int size);
unsigned int getCurStencilSize() const;
void forceSetBlendState();
void forceSetDepthStencilState();
void forceSetRasterizerState();
bool isForceSetRasterizerState() const;
bool isForceSetDepthStencilState() const;
bool isForceSetBlendState() const;
protected:
static bool IsBlendStateDirty(const gl::State::DirtyBits &dirtyBits);
static bool IsDepthStencilStateDirty(const gl::State::DirtyBits &dirtyBits);
static bool IsRasterizerStateDirty(const gl::State::DirtyBits &dirtyBits);
void resetRasterizerForceBits();
void resetBlendForceBits();
void resetDepthStencilForceBits();
bool mForceSetDepthStencilState;
bool mForceSetBlendState;
// Blend State
gl::BlendState mCurBlendState;
gl::ColorF mCurBlendColor;
unsigned int mCurSampleMask;
// Depth Stencil State
gl::DepthStencilState mCurDepthStencilState;
int mCurStencilRef;
int mCurStencilBackRef;
unsigned int mCurStencilSize;
// Rasterizer State
gl::RasterizerState mCurRasterizerState;
// Scissor State
bool mCurScissorTestEnabled;
// Local force dirty bits
gl::State::DirtyBits mLocalDirtyBits;
// Copy of dirty bits in state. Synced on syncState. Should be removed after all states are
// moved in
gl::State::DirtyBits mExternalDirtyBits;
static const gl::State::DirtyBits mBlendDirtyBits;
static const gl::State::DirtyBits mDepthStencilDirtyBits;
static const gl::State::DirtyBits mRasterizerDirtyBits;
private:
unsigned int getBlendStateMask(const gl::Framebuffer *framebufferObject,
int samples,
const gl::State &state) const;
};
} // namespace rx
#endif