mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 05:57:29 +02:00
using gpu::Pipeline it s mostly working but still glUniforms to get rid of
This commit is contained in:
parent
1746c1de46
commit
c9e0360394
6 changed files with 203 additions and 239 deletions
|
@ -370,8 +370,9 @@ void GLBackend::do_glUseProgram(Batch& batch, uint32 paramOffset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batch::_glUniform1f(GLint location, GLfloat v0) {
|
void Batch::_glUniform1f(GLint location, GLfloat v0) {
|
||||||
|
if (location < 0)
|
||||||
|
return;
|
||||||
ADD_COMMAND_GL(glUniform1f);
|
ADD_COMMAND_GL(glUniform1f);
|
||||||
|
|
||||||
_params.push_back(v0);
|
_params.push_back(v0);
|
||||||
_params.push_back(location);
|
_params.push_back(location);
|
||||||
|
|
||||||
|
|
|
@ -79,9 +79,7 @@ public:
|
||||||
public:
|
public:
|
||||||
class Command {
|
class Command {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void run(GLBackend* backend) = 0;
|
virtual void run(GLBackend* backend) = 0;
|
||||||
|
|
||||||
Command() {}
|
Command() {}
|
||||||
virtual ~Command() {};
|
virtual ~Command() {};
|
||||||
};
|
};
|
||||||
|
@ -89,46 +87,32 @@ public:
|
||||||
template <class T> class Command1 : public Command {
|
template <class T> class Command1 : public Command {
|
||||||
public:
|
public:
|
||||||
typedef void (GLBackend::*GLFunction)(typename T);
|
typedef void (GLBackend::*GLFunction)(typename T);
|
||||||
|
|
||||||
void run(GLBackend* backend) { (backend->*(_func))(_param); }
|
void run(GLBackend* backend) { (backend->*(_func))(_param); }
|
||||||
|
|
||||||
Command1(GLFunction func, T param) : _func(func), _param(param) {};
|
Command1(GLFunction func, T param) : _func(func), _param(param) {};
|
||||||
|
|
||||||
GLFunction _func;
|
GLFunction _func;
|
||||||
T _param;
|
T _param;
|
||||||
};
|
};
|
||||||
template <class T, class U> class Command2 : public Command {
|
template <class T, class U> class Command2 : public Command {
|
||||||
public:
|
public:
|
||||||
typedef void (*GLFunction)(typename T, typename U);
|
typedef void (GLBackend::*GLFunction)(typename T, typename U);
|
||||||
|
void run(GLBackend* backend) { (backend->*(_func))(_param0, _param1); }
|
||||||
void run(GLBackend* backend) { (_func)(_param0, _param1); }
|
|
||||||
|
|
||||||
Command2(GLFunction func, T param0, U param1) : _func(func), _param0(param0), _param1(param1) {};
|
Command2(GLFunction func, T param0, U param1) : _func(func), _param0(param0), _param1(param1) {};
|
||||||
|
|
||||||
GLFunction _func;
|
GLFunction _func;
|
||||||
T _param0;
|
T _param0;
|
||||||
U _param1;
|
U _param1;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class U, class V, class W> class Command4 : public Command {
|
template <class T, class U, class V> class Command3 : public Command {
|
||||||
public:
|
public:
|
||||||
typedef void (*GLFunction)(typename T, typename U, typename V, typename W);
|
typedef void (GLBackend::*GLFunction)(typename T, typename U, typename V);
|
||||||
|
void run(GLBackend* backend) { (backend->*(_func))(_param0, _param1, _param2); }
|
||||||
void run(GLBackend* backend) { (_func)(_param0, _param1, _param2, _param3); }
|
Command3(GLFunction func, T param0, U param1, V param2) : _func(func), _param0(param0), _param1(param1), _param2(param2) {};
|
||||||
|
|
||||||
Command4(GLFunction func, T param0, U param1, V param2, W param3) :
|
|
||||||
_func(func),
|
|
||||||
_param0(param0),
|
|
||||||
_param1(param1),
|
|
||||||
_param2(param2),
|
|
||||||
_param3(param3) {};
|
|
||||||
|
|
||||||
GLFunction _func;
|
GLFunction _func;
|
||||||
T _param0;
|
T _param0;
|
||||||
U _param1;
|
U _param1;
|
||||||
V _param2;
|
V _param2;
|
||||||
W _param3;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr< Command > CommandPointer;
|
typedef std::shared_ptr< Command > CommandPointer;
|
||||||
typedef std::vector< CommandPointer > Commands;
|
typedef std::vector< CommandPointer > Commands;
|
||||||
|
|
||||||
|
@ -137,6 +121,8 @@ public:
|
||||||
|
|
||||||
GLState();
|
GLState();
|
||||||
~GLState();
|
~GLState();
|
||||||
|
|
||||||
|
friend class GLBackend;
|
||||||
};
|
};
|
||||||
static GLState* syncGPUObject(const State& state);
|
static GLState* syncGPUObject(const State& state);
|
||||||
|
|
||||||
|
@ -156,7 +142,7 @@ public:
|
||||||
uint32 getNumInputBuffers() const { return _input._buffersState.size(); }
|
uint32 getNumInputBuffers() const { return _input._buffersState.size(); }
|
||||||
|
|
||||||
|
|
||||||
|
// The State setters called by the GLState::Commands when a new state is assigned
|
||||||
void do_setStateFillMode(int32 mode);
|
void do_setStateFillMode(int32 mode);
|
||||||
void do_setStateCullMode(int32 mode);
|
void do_setStateCullMode(int32 mode);
|
||||||
void do_setStateFrontClockwise(int32 isFrontClockwise);
|
void do_setStateFrontClockwise(int32 isFrontClockwise);
|
||||||
|
@ -167,11 +153,12 @@ public:
|
||||||
|
|
||||||
void do_setStateDepthTest(State::DepthTest test);
|
void do_setStateDepthTest(State::DepthTest test);
|
||||||
|
|
||||||
void do_setStateStencilEnable(int32 enable);
|
void do_setStateStencil(State::StencilActivation activation, State::StencilTest frontTest, State::StencilTest backTest);
|
||||||
|
|
||||||
void do_setStateAlphaToCoverageEnable(int32 enable);
|
void do_setStateAlphaToCoverageEnable(int32 enable);
|
||||||
|
|
||||||
void do_setStateBlendEnable(int32 enable);
|
void do_setStateBlend(State::BlendFunction blendFunction, Vec4 blendFactor);
|
||||||
|
void do_setStateColorWriteMask(int32 mask);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -24,23 +24,10 @@ GLBackend::GLState::~GLState() {
|
||||||
typedef GLBackend::GLState::Command Command;
|
typedef GLBackend::GLState::Command Command;
|
||||||
typedef GLBackend::GLState::CommandPointer CommandPointer;
|
typedef GLBackend::GLState::CommandPointer CommandPointer;
|
||||||
typedef GLBackend::GLState::Command1<int32> Command1I;
|
typedef GLBackend::GLState::Command1<int32> Command1I;
|
||||||
typedef GLBackend::GLState::Command1<State::DepthTest> Command1DT;
|
typedef GLBackend::GLState::Command1<State::DepthTest> CommandDepthTest;
|
||||||
typedef GLBackend::GLState::Command1<GLenum> Command1E;
|
typedef GLBackend::GLState::Command3<State::StencilActivation, State::StencilTest, State::StencilTest> CommandStencil;
|
||||||
typedef GLBackend::GLState::Command2<GLenum, GLenum> Command2E;
|
typedef GLBackend::GLState::Command2<State::BlendFunction, Vec4> CommandBlend;
|
||||||
typedef GLBackend::GLState::Command2<GLfloat, GLfloat> Command2F;
|
|
||||||
typedef GLBackend::GLState::Command4<GLenum, GLenum, GLenum, GLenum> Command4E;
|
|
||||||
typedef GLBackend::GLState::Command4<GLfloat, GLfloat, GLfloat, GLfloat> Command4F;
|
|
||||||
typedef GLBackend::GLState::Command4<GLboolean, GLboolean, GLboolean, GLboolean> Command4B;
|
|
||||||
|
|
||||||
static GLenum GL_COMPARISON_FUNCTIONS[] = {
|
|
||||||
GL_NEVER,
|
|
||||||
GL_LESS,
|
|
||||||
GL_EQUAL,
|
|
||||||
GL_LEQUAL,
|
|
||||||
GL_GREATER,
|
|
||||||
GL_NOTEQUAL,
|
|
||||||
GL_GEQUAL,
|
|
||||||
GL_ALWAYS };
|
|
||||||
|
|
||||||
void generateFillMode(GLBackend::GLState::Commands& commands, State::FillMode fillMode) {
|
void generateFillMode(GLBackend::GLState::Commands& commands, State::FillMode fillMode) {
|
||||||
commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateFillMode, int32(fillMode))));
|
commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateFillMode, int32(fillMode))));
|
||||||
|
@ -86,99 +73,23 @@ void generateAntialiasedLineEnable(GLBackend::GLState::Commands& commands, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateDepthTest(GLBackend::GLState::Commands& commands, State::DepthTest& test) {
|
void generateDepthTest(GLBackend::GLState::Commands& commands, State::DepthTest& test) {
|
||||||
commands.push_back(CommandPointer(new Command1DT(&GLBackend::do_setStateDepthTest, int32(test.getRaw()))));
|
commands.push_back(CommandPointer(new CommandDepthTest(&GLBackend::do_setStateDepthTest, int32(test.getRaw()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateStencilEnable(GLBackend::GLState::Commands& commands, bool enable) {
|
void generateStencil(GLBackend::GLState::Commands& commands, const State& state) {
|
||||||
commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateStencilEnable, int32(enable))));
|
commands.push_back(CommandPointer(new CommandStencil(&GLBackend::do_setStateStencil, state.getStencilActivation(), state.getStencilTestFront(), state.getStencilTestBack())));
|
||||||
}
|
|
||||||
|
|
||||||
void generateStencilWriteMask(GLBackend::GLState::Commands& commands, uint32 mask) {
|
|
||||||
// commands.push_back(CommandPointer(new Command1E((Command1E::GLFunction)glStencilMask, mask)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateStencilState(GLBackend::GLState::Commands& commands, const State& state) {
|
|
||||||
auto frontTest(state.getStencilTestFront());
|
|
||||||
auto backTest(state.getStencilTestBack());
|
|
||||||
|
|
||||||
commands.push_back(CommandPointer(new Command4E((Command4E::GLFunction)glBlendEquationSeparate,
|
|
||||||
GL_FRONT, GL_COMPARISON_FUNCTIONS[frontTest._function], state.getStencilReference(), state.getStencilReadMask())));
|
|
||||||
commands.push_back(CommandPointer(new Command4E((Command4E::GLFunction)glBlendEquationSeparate,
|
|
||||||
GL_BACK, GL_COMPARISON_FUNCTIONS[backTest._function], state.getStencilReference(), state.getStencilReadMask())));
|
|
||||||
|
|
||||||
static GLenum STENCIL_OPS[] = {
|
|
||||||
GL_KEEP,
|
|
||||||
GL_ZERO,
|
|
||||||
GL_REPLACE,
|
|
||||||
GL_INCR_WRAP,
|
|
||||||
GL_DECR_WRAP,
|
|
||||||
GL_INVERT,
|
|
||||||
GL_INCR,
|
|
||||||
GL_DECR };
|
|
||||||
|
|
||||||
commands.push_back(CommandPointer(new Command4E((Command4E::GLFunction)glStencilOpSeparate,
|
|
||||||
GL_FRONT, STENCIL_OPS[frontTest._failOp], STENCIL_OPS[frontTest._passOp], STENCIL_OPS[frontTest._depthFailOp])));
|
|
||||||
commands.push_back(CommandPointer(new Command4E((Command4E::GLFunction)glStencilOpSeparate,
|
|
||||||
GL_BACK, STENCIL_OPS[backTest._failOp], STENCIL_OPS[backTest._passOp], STENCIL_OPS[backTest._depthFailOp])));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateAlphaToCoverageEnable(GLBackend::GLState::Commands& commands, bool enable) {
|
void generateAlphaToCoverageEnable(GLBackend::GLState::Commands& commands, bool enable) {
|
||||||
commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateAlphaToCoverageEnable, int32(enable))));
|
commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateAlphaToCoverageEnable, int32(enable))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateBlendEnable(GLBackend::GLState::Commands& commands, bool enable) {
|
void generateBlend(GLBackend::GLState::Commands& commands, const State& state) {
|
||||||
commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateBlendEnable, int32(enable))));
|
commands.push_back(CommandPointer(new CommandBlend(&GLBackend::do_setStateBlend, state.getBlendFunction(), state.getBlendFactor())));
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateBlendFunction(GLBackend::GLState::Commands& commands, const State& state) {
|
void generateColorWriteMask(GLBackend::GLState::Commands& commands, int32 mask) {
|
||||||
static GLenum GL_BLEND_OPS[] = {
|
commands.push_back(CommandPointer(new Command1I(&GLBackend::do_setStateColorWriteMask, int32(mask))));
|
||||||
GL_FUNC_ADD,
|
|
||||||
GL_FUNC_SUBTRACT,
|
|
||||||
GL_FUNC_REVERSE_SUBTRACT,
|
|
||||||
GL_MIN,
|
|
||||||
GL_MAX };
|
|
||||||
|
|
||||||
auto colorFunction = state.getBlendFunctionColor();
|
|
||||||
auto alphaFunction = state.getBlendFunctionColor();
|
|
||||||
|
|
||||||
commands.push_back(CommandPointer(new Command2E((Command2E::GLFunction)glBlendEquationSeparate,
|
|
||||||
GL_BLEND_OPS[colorFunction._operation],
|
|
||||||
GL_BLEND_OPS[alphaFunction._operation])));
|
|
||||||
|
|
||||||
static GLenum BLEND_ARGS[] = {
|
|
||||||
GL_ZERO,
|
|
||||||
GL_ONE,
|
|
||||||
GL_SRC_COLOR,
|
|
||||||
GL_ONE_MINUS_SRC_COLOR,
|
|
||||||
GL_SRC_ALPHA,
|
|
||||||
GL_ONE_MINUS_SRC_ALPHA,
|
|
||||||
GL_DST_ALPHA,
|
|
||||||
GL_ONE_MINUS_DST_ALPHA,
|
|
||||||
GL_DST_COLOR,
|
|
||||||
GL_ONE_MINUS_DST_COLOR,
|
|
||||||
GL_SRC_ALPHA_SATURATE,
|
|
||||||
GL_CONSTANT_COLOR,
|
|
||||||
GL_ONE_MINUS_CONSTANT_COLOR
|
|
||||||
};
|
|
||||||
|
|
||||||
commands.push_back(CommandPointer(new Command4E((Command4E::GLFunction)glBlendFuncSeparate,
|
|
||||||
BLEND_ARGS[colorFunction._source],
|
|
||||||
BLEND_ARGS[colorFunction._destination],
|
|
||||||
BLEND_ARGS[alphaFunction._source],
|
|
||||||
BLEND_ARGS[alphaFunction._destination])));
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateBlendFactor(GLBackend::GLState::Commands& commands, const Vec4& factor) {
|
|
||||||
commands.push_back(CommandPointer(new Command4F((Command4F::GLFunction)glBlendColor,
|
|
||||||
factor.x, factor.y, factor.z, factor.w)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void generateColorWriteMask(GLBackend::GLState::Commands& commands, State::ColorMask mask) {
|
|
||||||
commands.push_back(CommandPointer(new Command4B((Command4B::GLFunction)glColorMask,
|
|
||||||
mask & State::ColorMask::WRITE_RED,
|
|
||||||
mask & State::ColorMask::WRITE_GREEN,
|
|
||||||
mask & State::ColorMask::WRITE_BLUE,
|
|
||||||
mask & State::ColorMask::WRITE_ALPHA )));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLBackend::GLState* GLBackend::syncGPUObject(const State& state) {
|
GLBackend::GLState* GLBackend::syncGPUObject(const State& state) {
|
||||||
|
@ -200,13 +111,8 @@ GLBackend::GLState* GLBackend::syncGPUObject(const State& state) {
|
||||||
object->_stamp = state.getStamp();
|
object->_stamp = state.getStamp();
|
||||||
|
|
||||||
bool depthBias = false;
|
bool depthBias = false;
|
||||||
|
|
||||||
bool stencilEnabled = false;
|
|
||||||
bool stencilState = false;
|
bool stencilState = false;
|
||||||
|
bool blendState = false;
|
||||||
bool blendEnabled = false;
|
|
||||||
bool blendFunction = false;
|
|
||||||
bool blendFactor = false;
|
|
||||||
|
|
||||||
// go thorugh the list of state fields in the State and record the corresponding gl command
|
// go thorugh the list of state fields in the State and record the corresponding gl command
|
||||||
for (auto field: state.getFields()) {
|
for (auto field: state.getFields()) {
|
||||||
|
@ -224,7 +130,7 @@ GLBackend::GLState* GLBackend::syncGPUObject(const State& state) {
|
||||||
depthBias = true;
|
depthBias = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case State::FRONT_CLOCKWISE: {
|
case State::FRONT_FACE: {
|
||||||
generateFrontClockwise(object->_commands, bool(field.second._integer));
|
generateFrontClockwise(object->_commands, bool(field.second._integer));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -249,14 +155,7 @@ GLBackend::GLState* GLBackend::syncGPUObject(const State& state) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case State::STENCIL_ENABLE: {
|
case State::STENCIL_ACTIVATION:
|
||||||
stencilEnabled = bool(field.second._integer);
|
|
||||||
generateStencilEnable(object->_commands, stencilEnabled);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case State::STENCIL_WRITE_MASK:
|
|
||||||
case State::STENCIL_READ_MASK:
|
|
||||||
case State::STENCIL_REFERENCE:
|
|
||||||
case State::STENCIL_TEST_FRONT:
|
case State::STENCIL_TEST_FRONT:
|
||||||
case State::STENCIL_TEST_BACK: {
|
case State::STENCIL_TEST_BACK: {
|
||||||
stencilState = true;
|
stencilState = true;
|
||||||
|
@ -271,26 +170,17 @@ GLBackend::GLState* GLBackend::syncGPUObject(const State& state) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case State::BLEND_ENABLE: {
|
case State::BLEND_FUNCTION:
|
||||||
blendEnabled = field.second._integer;
|
|
||||||
generateBlendEnable(object->_commands, blendEnabled);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case State::BLEND_FUNCTION_COLOR:
|
|
||||||
case State::BLEND_FUNCTION_ALPHA: {
|
|
||||||
blendFunction = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case State::BLEND_FACTOR_X:
|
case State::BLEND_FACTOR_X:
|
||||||
case State::BLEND_FACTOR_Y:
|
case State::BLEND_FACTOR_Y:
|
||||||
case State::BLEND_FACTOR_Z:
|
case State::BLEND_FACTOR_Z:
|
||||||
case State::BLEND_FACTOR_W: {
|
case State::BLEND_FACTOR_W: {
|
||||||
blendFactor = true;
|
blendState = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case State::COLOR_WRITE_MASK: {
|
case State::COLOR_WRITE_MASK: {
|
||||||
generateColorWriteMask(object->_commands, State::ColorMask(field.second._integer));
|
generateColorWriteMask(object->_commands, field.second._integer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,19 +191,27 @@ GLBackend::GLState* GLBackend::syncGPUObject(const State& state) {
|
||||||
generateDepthBias(object->_commands, state);
|
generateDepthBias(object->_commands, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stencilEnabled) {
|
if (stencilState) {
|
||||||
generateStencilState(object->_commands, state);
|
generateStencil(object->_commands, state);
|
||||||
generateStencilWriteMask(object->_commands, state.getStencilWriteMask());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blendEnabled) {
|
if (blendState) {
|
||||||
generateBlendFunction(object->_commands, state);
|
generateBlend(object->_commands, state);
|
||||||
generateBlendFactor(object->_commands, state.getBlendFactor());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static GLenum GL_COMPARISON_FUNCTIONS[] = {
|
||||||
|
GL_NEVER,
|
||||||
|
GL_LESS,
|
||||||
|
GL_EQUAL,
|
||||||
|
GL_LEQUAL,
|
||||||
|
GL_GREATER,
|
||||||
|
GL_NOTEQUAL,
|
||||||
|
GL_GEQUAL,
|
||||||
|
GL_ALWAYS };
|
||||||
|
|
||||||
void GLBackend::do_setStateFillMode(int32 mode) {
|
void GLBackend::do_setStateFillMode(int32 mode) {
|
||||||
static GLenum GL_FILL_MODES[] = { GL_POINT, GL_LINE, GL_FILL };
|
static GLenum GL_FILL_MODES[] = { GL_POINT, GL_LINE, GL_FILL };
|
||||||
|
@ -386,9 +284,27 @@ void GLBackend::do_setStateDepthTest(State::DepthTest test) {
|
||||||
CHECK_GL_ERROR();
|
CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLBackend::do_setStateStencilEnable(int32 enable) {
|
void GLBackend::do_setStateStencil(State::StencilActivation activation, State::StencilTest frontTest, State::StencilTest backTest) {
|
||||||
if (enable) {
|
if (activation._enabled) {
|
||||||
glEnable(GL_STENCIL_TEST);
|
glEnable(GL_STENCIL_TEST);
|
||||||
|
glStencilMaskSeparate(GL_FRONT, activation._frontWriteMask);
|
||||||
|
glStencilMaskSeparate(GL_BACK, activation._backWriteMask);
|
||||||
|
|
||||||
|
static GLenum STENCIL_OPS[] = {
|
||||||
|
GL_KEEP,
|
||||||
|
GL_ZERO,
|
||||||
|
GL_REPLACE,
|
||||||
|
GL_INCR_WRAP,
|
||||||
|
GL_DECR_WRAP,
|
||||||
|
GL_INVERT,
|
||||||
|
GL_INCR,
|
||||||
|
GL_DECR };
|
||||||
|
|
||||||
|
glStencilFuncSeparate(GL_FRONT, STENCIL_OPS[frontTest._failOp], STENCIL_OPS[frontTest._passOp], STENCIL_OPS[frontTest._depthFailOp]);
|
||||||
|
glStencilFuncSeparate(GL_FRONT, GL_COMPARISON_FUNCTIONS[frontTest._function], frontTest._reference, frontTest._readMask);
|
||||||
|
|
||||||
|
glStencilFuncSeparate(GL_BACK, STENCIL_OPS[backTest._failOp], STENCIL_OPS[backTest._passOp], STENCIL_OPS[backTest._depthFailOp]);
|
||||||
|
glStencilFuncSeparate(GL_BACK, GL_COMPARISON_FUNCTIONS[backTest._function], backTest._reference, backTest._readMask);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
}
|
}
|
||||||
|
@ -404,12 +320,50 @@ void GLBackend::do_setStateAlphaToCoverageEnable(int32 enable) {
|
||||||
CHECK_GL_ERROR();
|
CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLBackend::do_setStateBlend(State::BlendFunction function, Vec4 factor ) {
|
||||||
void GLBackend::do_setStateBlendEnable(int32 enable) {
|
if (function._enabled) {
|
||||||
if (enable) {
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
|
static GLenum GL_BLEND_OPS[] = {
|
||||||
|
GL_FUNC_ADD,
|
||||||
|
GL_FUNC_SUBTRACT,
|
||||||
|
GL_FUNC_REVERSE_SUBTRACT,
|
||||||
|
GL_MIN,
|
||||||
|
GL_MAX };
|
||||||
|
|
||||||
|
glBlendEquationSeparate(GL_BLEND_OPS[function._operationColor], GL_BLEND_OPS[function._operationAlpha]);
|
||||||
|
|
||||||
|
static GLenum BLEND_ARGS[] = {
|
||||||
|
GL_ZERO,
|
||||||
|
GL_ONE,
|
||||||
|
GL_SRC_COLOR,
|
||||||
|
GL_ONE_MINUS_SRC_COLOR,
|
||||||
|
GL_SRC_ALPHA,
|
||||||
|
GL_ONE_MINUS_SRC_ALPHA,
|
||||||
|
GL_DST_ALPHA,
|
||||||
|
GL_ONE_MINUS_DST_ALPHA,
|
||||||
|
GL_DST_COLOR,
|
||||||
|
GL_ONE_MINUS_DST_COLOR,
|
||||||
|
GL_SRC_ALPHA_SATURATE,
|
||||||
|
GL_CONSTANT_COLOR,
|
||||||
|
GL_ONE_MINUS_CONSTANT_COLOR,
|
||||||
|
GL_CONSTANT_ALPHA,
|
||||||
|
GL_ONE_MINUS_CONSTANT_ALPHA,
|
||||||
|
};
|
||||||
|
|
||||||
|
glBlendFuncSeparate(BLEND_ARGS[function._sourceColor], BLEND_ARGS[function._destinationColor],
|
||||||
|
BLEND_ARGS[function._sourceAlpha], BLEND_ARGS[function._destinationAlpha]);
|
||||||
|
|
||||||
|
glBlendColor(factor.x, factor.y, factor.z, factor.w);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
CHECK_GL_ERROR();
|
CHECK_GL_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLBackend::do_setStateColorWriteMask(int32 mask) {
|
||||||
|
glColorMask(mask & State::ColorMask::WRITE_RED,
|
||||||
|
mask & State::ColorMask::WRITE_GREEN,
|
||||||
|
mask & State::ColorMask::WRITE_BLUE,
|
||||||
|
mask & State::ColorMask::WRITE_ALPHA );
|
||||||
|
}
|
|
@ -32,31 +32,25 @@ public:
|
||||||
enum Field {
|
enum Field {
|
||||||
FILL_MODE,
|
FILL_MODE,
|
||||||
CULL_MODE,
|
CULL_MODE,
|
||||||
|
FRONT_FACE,
|
||||||
DEPTH_BIAS,
|
|
||||||
DEPTH_BIAS_SLOPE_SCALE,
|
|
||||||
|
|
||||||
FRONT_CLOCKWISE,
|
|
||||||
DEPTH_CLIP_ENABLE,
|
DEPTH_CLIP_ENABLE,
|
||||||
SCISSOR_ENABLE,
|
SCISSOR_ENABLE,
|
||||||
MULTISAMPLE_ENABLE,
|
MULTISAMPLE_ENABLE,
|
||||||
ANTIALISED_LINE_ENABLE,
|
ANTIALISED_LINE_ENABLE,
|
||||||
|
|
||||||
|
DEPTH_BIAS,
|
||||||
|
DEPTH_BIAS_SLOPE_SCALE,
|
||||||
|
|
||||||
DEPTH_TEST,
|
DEPTH_TEST,
|
||||||
|
|
||||||
STENCIL_ENABLE,
|
STENCIL_ACTIVATION,
|
||||||
STENCIL_READ_MASK,
|
|
||||||
STENCIL_WRITE_MASK,
|
|
||||||
STENCIL_TEST_FRONT,
|
STENCIL_TEST_FRONT,
|
||||||
STENCIL_TEST_BACK,
|
STENCIL_TEST_BACK,
|
||||||
STENCIL_REFERENCE,
|
|
||||||
|
|
||||||
SAMPLE_MASK,
|
SAMPLE_MASK,
|
||||||
ALPHA_TO_COVERAGE_ENABLE,
|
ALPHA_TO_COVERAGE_ENABLE,
|
||||||
|
|
||||||
BLEND_ENABLE,
|
BLEND_FUNCTION,
|
||||||
BLEND_FUNCTION_COLOR,
|
|
||||||
BLEND_FUNCTION_ALPHA,
|
|
||||||
BLEND_FACTOR_X,
|
BLEND_FACTOR_X,
|
||||||
BLEND_FACTOR_Y,
|
BLEND_FACTOR_Y,
|
||||||
BLEND_FACTOR_Z,
|
BLEND_FACTOR_Z,
|
||||||
|
@ -121,9 +115,11 @@ public:
|
||||||
DEST_COLOR,
|
DEST_COLOR,
|
||||||
INV_DEST_COLOR,
|
INV_DEST_COLOR,
|
||||||
SRC_ALPHA_SAT,
|
SRC_ALPHA_SAT,
|
||||||
BLEND_FACTOR,
|
FACTOR_COLOR,
|
||||||
INV_BLEND_FACTOR,
|
INV_FACTOR_COLOR,
|
||||||
|
FACTOR_ALPHA,
|
||||||
|
INV_FACTOR_ALPHA,
|
||||||
|
|
||||||
NUM_BLEND_ARGS,
|
NUM_BLEND_ARGS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -153,37 +149,65 @@ public:
|
||||||
bool _writeMask = true;
|
bool _writeMask = true;
|
||||||
bool _enabled = false;
|
bool _enabled = false;
|
||||||
|
|
||||||
DepthTest(bool enable, bool writeMask, ComparisonFunction func) :
|
DepthTest(bool enabled, bool writeMask, ComparisonFunction func) :
|
||||||
_function(func), _writeMask(writeMask), _enabled(enable) {}
|
_function(func), _writeMask(writeMask), _enabled(enabled) {}
|
||||||
|
|
||||||
|
|
||||||
int32 getRaw() const { return *(reinterpret_cast<const int32*>(this)); }
|
int32 getRaw() const { return *(reinterpret_cast<const int32*>(this)); }
|
||||||
DepthTest(int32 raw) { *(reinterpret_cast<int32*>(this)) = raw; }
|
DepthTest(int32 raw) { *(reinterpret_cast<int32*>(this)) = raw; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class StencilTest {
|
class StencilTest {
|
||||||
public:
|
public:
|
||||||
int8 _failOp = STENCIL_OP_KEEP;
|
uint8 _reference;
|
||||||
int8 _depthFailOp = STENCIL_OP_KEEP;
|
uint8 _readMask;
|
||||||
int8 _passOp = STENCIL_OP_KEEP;
|
int8 _function : 4;
|
||||||
int8 _function = ALWAYS;
|
int8 _failOp : 4;
|
||||||
|
int8 _depthFailOp : 4;
|
||||||
StencilTest(StencilOp failOp, StencilOp depthFailOp, StencilOp passOp, ComparisonFunction func) :
|
int8 _passOp : 4;
|
||||||
_failOp(failOp), _depthFailOp(depthFailOp), _passOp(passOp), _function(func) {}
|
|
||||||
|
StencilTest(uint8 reference = 0, uint8 readMask =0xFF, ComparisonFunction func = ALWAYS, StencilOp failOp = STENCIL_OP_KEEP, StencilOp depthFailOp = STENCIL_OP_KEEP, StencilOp passOp = STENCIL_OP_KEEP) :
|
||||||
int32 raw() const { return *(reinterpret_cast<const int32*>(this)); }
|
_reference(reference), _readMask(readMask), _function(func), _failOp(failOp), _depthFailOp(depthFailOp), _passOp(passOp) {}
|
||||||
|
|
||||||
|
int32 getRaw() const { return *(reinterpret_cast<const int32*>(this)); }
|
||||||
StencilTest(int32 raw) { *(reinterpret_cast<int32*>(this)) = raw; }
|
StencilTest(int32 raw) { *(reinterpret_cast<int32*>(this)) = raw; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class StencilActivation {
|
||||||
|
public:
|
||||||
|
uint8 _frontWriteMask;
|
||||||
|
uint8 _backWriteMask;
|
||||||
|
int16 _enabled;
|
||||||
|
|
||||||
|
StencilActivation(bool enabled, uint8 frontWriteMask = 0xFF, uint8 backWriteMask = 0xFF) :
|
||||||
|
_frontWriteMask(frontWriteMask), _backWriteMask(backWriteMask), _enabled(enabled) {}
|
||||||
|
|
||||||
|
int32 getRaw() const { return *(reinterpret_cast<const int32*>(this)); }
|
||||||
|
StencilActivation(int32 raw) { *(reinterpret_cast<int32*>(this)) = raw; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BlendFunction {
|
class BlendFunction {
|
||||||
public:
|
public:
|
||||||
int8 _source = ONE;
|
int8 _enabled;
|
||||||
int8 _operation = BLEND_OP_ADD;
|
int8 _sourceColor : 4;
|
||||||
int8 _destination = ZERO;
|
int8 _sourceAlpha : 4;
|
||||||
int8 _spare = 0;
|
int8 _destinationColor : 4;
|
||||||
|
int8 _destinationAlpha : 4;
|
||||||
|
int8 _operationColor : 4;
|
||||||
|
int8 _operationAlpha : 4;
|
||||||
|
|
||||||
BlendFunction(BlendArg source, BlendOp operation, BlendArg destination) :
|
BlendFunction(bool enabled,
|
||||||
_source(source), _operation(operation), _destination(destination) {}
|
BlendArg sourceColor, BlendOp operationColor, BlendArg destinationColor,
|
||||||
|
BlendArg sourceAlpha, BlendOp operationAlpha, BlendArg destinationAlpha) :
|
||||||
|
_enabled(enabled),
|
||||||
|
_sourceColor(sourceColor), _operationColor(operationColor), _destinationColor(destinationColor),
|
||||||
|
_sourceAlpha(sourceAlpha), _operationAlpha(operationAlpha), _destinationAlpha(destinationAlpha) {}
|
||||||
|
|
||||||
|
BlendFunction(bool enabled, BlendArg source, BlendOp operation, BlendArg destination) :
|
||||||
|
_enabled(enabled),
|
||||||
|
_sourceColor(source), _operationColor(operation), _destinationColor(destination),
|
||||||
|
_sourceAlpha(source), _operationAlpha(operation), _destinationAlpha(destination) {}
|
||||||
|
|
||||||
int32 raw() const { return *(reinterpret_cast<const int32*>(this)); }
|
int32 raw() const { return *(reinterpret_cast<const int32*>(this)); }
|
||||||
BlendFunction(int32 raw) { *(reinterpret_cast<int32*>(this)) = raw; }
|
BlendFunction(int32 raw) { *(reinterpret_cast<int32*>(this)) = raw; }
|
||||||
|
@ -214,65 +238,61 @@ public:
|
||||||
void setCullMode(CullMode cull) { set(CULL_MODE, uint32(cull)); }
|
void setCullMode(CullMode cull) { set(CULL_MODE, uint32(cull)); }
|
||||||
CullMode getCullMode() const { return CullMode(get(CULL_MODE)._integer); }
|
CullMode getCullMode() const { return CullMode(get(CULL_MODE)._integer); }
|
||||||
|
|
||||||
void setFrontClockwise(bool enable) { set(FRONT_CLOCKWISE, enable); }
|
void setFrontFace(bool isClockwise) { set(FRONT_FACE, isClockwise); }
|
||||||
void setDepthClipEnable(bool enable) { set(DEPTH_CLIP_ENABLE, enable); }
|
void setDepthClipEnable(bool enable) { set(DEPTH_CLIP_ENABLE, enable); }
|
||||||
|
void setScissorEnable(bool enable) { set(SCISSOR_ENABLE, enable); }
|
||||||
|
void setMultisampleEnable(bool enable) { set(MULTISAMPLE_ENABLE, enable); }
|
||||||
|
void setAntialiasedLineEnable(bool enable) { set(ANTIALISED_LINE_ENABLE, enable); }
|
||||||
|
|
||||||
|
bool isFrontFaceClockwise() const { return get(FRONT_FACE)._integer; }
|
||||||
|
bool isDepthClipEnable() const { return get(DEPTH_CLIP_ENABLE)._integer; }
|
||||||
|
bool isScissorEnable() const { return get(SCISSOR_ENABLE)._integer; }
|
||||||
|
bool isMultisampleEnable() const { return get(MULTISAMPLE_ENABLE)._integer; }
|
||||||
|
bool isAntialiasedLineEnable() const { return get(ANTIALISED_LINE_ENABLE)._integer; }
|
||||||
|
|
||||||
void setDepthBias(float bias) { set(DEPTH_BIAS, bias); }
|
void setDepthBias(float bias) { set(DEPTH_BIAS, bias); }
|
||||||
void setDepthBiasSlopeScale(float scale) { set(DEPTH_BIAS_SLOPE_SCALE, scale); }
|
void setDepthBiasSlopeScale(float scale) { set(DEPTH_BIAS_SLOPE_SCALE, scale); }
|
||||||
float getDepthBias() const { return get(DEPTH_BIAS)._integer; }
|
float getDepthBias() const { return get(DEPTH_BIAS)._integer; }
|
||||||
float getDepthBiasSlopeScale() const { return get(DEPTH_BIAS_SLOPE_SCALE)._float; }
|
float getDepthBiasSlopeScale() const { return get(DEPTH_BIAS_SLOPE_SCALE)._float; }
|
||||||
|
|
||||||
|
|
||||||
void setScissorEnable(bool enable) { set(SCISSOR_ENABLE, enable); }
|
|
||||||
void setMultisampleEnable(bool enable) { set(MULTISAMPLE_ENABLE, enable); }
|
|
||||||
void setAntialiasedLineEnable(bool enable) { set(ANTIALISED_LINE_ENABLE, enable); }
|
|
||||||
bool getFrontClockwise() const { return get(FRONT_CLOCKWISE)._integer; }
|
|
||||||
bool getDepthClipEnable() const { return get(DEPTH_CLIP_ENABLE)._integer; }
|
|
||||||
bool getScissorEnable() const { return get(SCISSOR_ENABLE)._integer; }
|
|
||||||
bool getMultisampleEnable() const { return get(MULTISAMPLE_ENABLE)._integer; }
|
|
||||||
bool getAntialiasedLineEnable() const { return get(ANTIALISED_LINE_ENABLE)._integer; }
|
|
||||||
|
|
||||||
void setDepthTest(bool enable, bool writeMask, ComparisonFunction func) { set(DEPTH_TEST, DepthTest(enable, writeMask, func).getRaw()); }
|
void setDepthTest(bool enable, bool writeMask, ComparisonFunction func) { set(DEPTH_TEST, DepthTest(enable, writeMask, func).getRaw()); }
|
||||||
DepthTest getDepthTest() const { return DepthTest(get(DEPTH_TEST)._integer); }
|
DepthTest getDepthTest() const { return DepthTest(get(DEPTH_TEST)._integer); }
|
||||||
bool getDepthTestEnabled() const { return getDepthTest()._enabled; }
|
bool isDepthTestEnabled() const { return getDepthTest()._enabled; }
|
||||||
bool getDepthTestWriteMask() const { return getDepthTest()._writeMask; }
|
bool getDepthTestWriteMask() const { return getDepthTest()._writeMask; }
|
||||||
ComparisonFunction getDepthTestFunc() const { return ComparisonFunction(getDepthTest()._function); }
|
ComparisonFunction getDepthTestFunc() const { return ComparisonFunction(getDepthTest()._function); }
|
||||||
|
|
||||||
void setStencilEnable(bool enable) { set(STENCIL_ENABLE, enable); }
|
void setStencilTest(bool enabled, uint8 frontWriteMask, StencilTest frontTest, uint8 backWriteMask, StencilTest backTest) {
|
||||||
void setStencilReadMask(uint8 mask) { set(STENCIL_READ_MASK, mask); }
|
set(STENCIL_ACTIVATION, StencilActivation(enabled, frontWriteMask, backWriteMask).getRaw());
|
||||||
void setStencilWriteMask(uint8 mask) { set(STENCIL_WRITE_MASK, mask); }
|
set(STENCIL_TEST_FRONT, frontTest.getRaw()); set(STENCIL_TEST_BACK, backTest.getRaw());
|
||||||
bool getStencilEnable() const { return get(STENCIL_ENABLE)._integer; }
|
}
|
||||||
uint8 getStencilReadMask() const { return get(STENCIL_READ_MASK)._unsigned_integer; }
|
void setStencilTest(bool enabled, uint8 frontWriteMask, StencilTest frontTest) { setStencilTest(enabled, frontWriteMask, frontTest, frontWriteMask, frontTest); }
|
||||||
uint8 getStencilWriteMask() const { return get(STENCIL_WRITE_MASK)._unsigned_integer; }
|
|
||||||
|
|
||||||
void setStencilTestFront(StencilTest test) { set(STENCIL_TEST_FRONT, test.raw()); }
|
StencilActivation getStencilActivation() const { return StencilActivation(get(STENCIL_ACTIVATION)._integer); }
|
||||||
void setStencilTestBack(StencilTest test) { set(STENCIL_TEST_BACK, test.raw()); }
|
bool isStencilEnabled() const { return getStencilActivation()._enabled != 0; }
|
||||||
|
uint8 getStencilWriteMaskFront() const { return getStencilActivation()._frontWriteMask; }
|
||||||
|
uint8 getStencilWriteMaskBack() const { return getStencilActivation()._backWriteMask; }
|
||||||
StencilTest getStencilTestFront() const { return StencilTest(get(STENCIL_TEST_FRONT)._integer); }
|
StencilTest getStencilTestFront() const { return StencilTest(get(STENCIL_TEST_FRONT)._integer); }
|
||||||
StencilTest getStencilTestBack() const { return StencilTest(get(STENCIL_TEST_BACK)._integer); }
|
StencilTest getStencilTestBack() const { return StencilTest(get(STENCIL_TEST_BACK)._integer); }
|
||||||
|
|
||||||
void setStencilReference(uint32 ref) { set(STENCIL_REFERENCE, ref); }
|
|
||||||
uint32 getStencilReference() const { return get(STENCIL_REFERENCE)._unsigned_integer; }
|
|
||||||
|
|
||||||
void setAlphaToCoverageEnable(bool enable) { set(ALPHA_TO_COVERAGE_ENABLE, enable); }
|
void setAlphaToCoverageEnable(bool enable) { set(ALPHA_TO_COVERAGE_ENABLE, enable); }
|
||||||
bool getAlphaToCoverageEnable() const { return get(ALPHA_TO_COVERAGE_ENABLE)._integer; }
|
bool isAlphaToCoverageEnabled() const { return get(ALPHA_TO_COVERAGE_ENABLE)._integer; }
|
||||||
|
|
||||||
void setSampleMask(uint32 mask) { set(SAMPLE_MASK, mask); }
|
void setSampleMask(uint32 mask) { set(SAMPLE_MASK, mask); }
|
||||||
uint32 getSampleMask() const { return get(SAMPLE_MASK)._unsigned_integer; }
|
uint32 getSampleMask() const { return get(SAMPLE_MASK)._unsigned_integer; }
|
||||||
|
|
||||||
void setBlendEnable(bool enable) { set(BLEND_ENABLE, enable); }
|
void setBlendFunction(BlendFunction function) { set(BLEND_FUNCTION, function.raw()); }
|
||||||
bool getBlendEnable() const { return get(BLEND_ENABLE)._integer; }
|
void setBlendFunction(bool enabled, BlendArg sourceColor, BlendOp operationColor, BlendArg destinationColor,
|
||||||
|
BlendArg sourceAlpha, BlendOp operationAlpha, BlendArg destinationAlpha) {
|
||||||
void setBlendFunctionColor(BlendFunction function) { set(BLEND_FUNCTION_COLOR, function.raw()); }
|
setBlendFunction(BlendFunction(enabled, sourceColor, operationColor, destinationColor, sourceAlpha, operationAlpha, destinationAlpha)); }
|
||||||
BlendFunction getBlendFunctionColor() const { return BlendFunction(get(BLEND_FUNCTION_COLOR)._integer); }
|
void setBlendFunction(bool enabled, BlendArg source, BlendOp operation, BlendArg destination) {
|
||||||
void setBlendFunctionAlpha(BlendFunction function) { set(BLEND_FUNCTION_ALPHA, function.raw()); }
|
setBlendFunction(BlendFunction(enabled, source, operation, destination)); }
|
||||||
BlendFunction getBlendFunctionAlpha() const { return BlendFunction(get(BLEND_FUNCTION_ALPHA)._integer); }
|
bool isBlendEnabled() const { return BlendFunction(get(BLEND_FUNCTION)._integer)._enabled; }
|
||||||
|
BlendFunction getBlendFunction() const { return BlendFunction(get(BLEND_FUNCTION)._integer); }
|
||||||
void setBlendFactor(const Vec4& factor) { set(BLEND_FACTOR_X, factor.x); set(BLEND_FACTOR_Y, factor.y); set(BLEND_FACTOR_Z, factor.z); set(BLEND_FACTOR_W, factor.w); }
|
void setBlendFactor(const Vec4& factor) { set(BLEND_FACTOR_X, factor.x); set(BLEND_FACTOR_Y, factor.y); set(BLEND_FACTOR_Z, factor.z); set(BLEND_FACTOR_W, factor.w); }
|
||||||
Vec4 getBlendFactor() const { return Vec4(get(BLEND_FACTOR_X)._float, get(BLEND_FACTOR_Y)._float, get(BLEND_FACTOR_Z)._float, get(BLEND_FACTOR_W)._float); }
|
Vec4 getBlendFactor() const { return Vec4(get(BLEND_FACTOR_X)._float, get(BLEND_FACTOR_Y)._float, get(BLEND_FACTOR_Z)._float, get(BLEND_FACTOR_W)._float); }
|
||||||
|
|
||||||
|
void setColorWriteMask(int32 mask) { set(COLOR_WRITE_MASK, mask); }
|
||||||
void setColorWriteMask(ColorMask mask) { set(COLOR_WRITE_MASK, mask); }
|
int32 getColorWriteMask() const { return ColorMask(get(COLOR_WRITE_MASK)._integer); }
|
||||||
ColorMask getColorWriteMask() const { return ColorMask(get(COLOR_WRITE_MASK)._integer); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
State(const State& state);
|
State(const State& state);
|
||||||
|
@ -280,7 +300,7 @@ protected:
|
||||||
|
|
||||||
FieldMap _fields;
|
FieldMap _fields;
|
||||||
|
|
||||||
Stamp _stamp;
|
Stamp _stamp = 0;
|
||||||
|
|
||||||
// This shouldn't be used by anything else than the Backend class with the proper casting.
|
// This shouldn't be used by anything else than the Backend class with the proper casting.
|
||||||
mutable GPUObject* _gpuObject = nullptr;
|
mutable GPUObject* _gpuObject = nullptr;
|
||||||
|
|
|
@ -217,8 +217,8 @@ SunSkyStage::SunSkyStage() :
|
||||||
auto skyShader = gpu::ShaderPointer(gpu::Shader::createProgram(skyFromAtmosphereVertex, skyFromAtmosphereFragment));
|
auto skyShader = gpu::ShaderPointer(gpu::Shader::createProgram(skyFromAtmosphereVertex, skyFromAtmosphereFragment));
|
||||||
|
|
||||||
auto skyState = gpu::StatePointer(new gpu::State());
|
auto skyState = gpu::StatePointer(new gpu::State());
|
||||||
skyState->setStencilEnable(false);
|
// skyState->setStencilEnable(false);
|
||||||
skyState->setBlendEnable(false);
|
// skyState->setBlendEnable(false);
|
||||||
|
|
||||||
_skyPipeline = gpu::PipelinePointer(gpu::Pipeline::create(skyShader, skyState));
|
_skyPipeline = gpu::PipelinePointer(gpu::Pipeline::create(skyShader, skyState));
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,9 @@ void Model::RenderPipelineLib::addRenderPipeline(Model::RenderKey& key,
|
||||||
state->setDepthTest(true, !key.isTranslucent(), gpu::State::LESS_EQUAL);
|
state->setDepthTest(true, !key.isTranslucent(), gpu::State::LESS_EQUAL);
|
||||||
|
|
||||||
// Blend on transparent
|
// Blend on transparent
|
||||||
state->setBlendEnable(key.isTranslucent());
|
state->setBlendFunction(key.isTranslucent(),
|
||||||
|
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||||
|
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||||
|
|
||||||
auto it = insert(value_type(key.getRaw(),
|
auto it = insert(value_type(key.getRaw(),
|
||||||
RenderPipeline(
|
RenderPipeline(
|
||||||
|
|
Loading…
Reference in a new issue