Sync ordering of gl fields/reset commands

This commit is contained in:
Zach Pomerantz 2016-03-29 15:47:00 -07:00
parent 830d08c385
commit 6ae03fe72e
3 changed files with 5 additions and 3 deletions

View file

@ -158,7 +158,6 @@ public:
~GLState();
// The state commands to reset to default,
// WARNING depending on the order of the State::Field enum
static const Commands _resetStateCommands;
friend class GLBackend;

View file

@ -35,6 +35,7 @@ const GLBackend::GLState::Commands makeResetStateCommands();
const GLBackend::GLState::Commands GLBackend::GLState::_resetStateCommands = makeResetStateCommands();
// NOTE: This must stay in sync with the ordering of the State::Field enum
const GLBackend::GLState::Commands makeResetStateCommands() {
// Since State::DEFAULT is a static defined in another .cpp the initialisation order is random
// and we have a 50/50 chance that State::DEFAULT is not yet initialized.
@ -69,9 +70,9 @@ const GLBackend::GLState::Commands makeResetStateCommands() {
CommandPointer(stencilCommand),
CommandPointer(stencilCommand),
std::make_shared<Command1B>(&GLBackend::do_setStateAlphaToCoverageEnable, DEFAULT.alphaToCoverageEnable),
std::make_shared<Command1U>(&GLBackend::do_setStateSampleMask, DEFAULT.sampleMask),
std::make_shared<Command1B>(&GLBackend::do_setStateAlphaToCoverageEnable, DEFAULT.alphaToCoverageEnable),
std::make_shared<CommandBlend>(&GLBackend::do_setStateBlend, DEFAULT.blendFunction),

View file

@ -345,6 +345,7 @@ public:
uint8 getColorWriteMask() const { return _values.colorWriteMask; }
// All the possible fields
// NOTE: If you change this, you must update GLBackend::GLState::_resetStateCommands
enum Field {
FILL_MODE,
CULL_MODE,
@ -364,6 +365,7 @@ public:
STENCIL_TEST_BACK,
SAMPLE_MASK,
ALPHA_TO_COVERAGE_ENABLE,
BLEND_FUNCTION,