gl_state: add pipeline state

This commit is contained in:
wwylele 2018-04-10 00:27:16 +03:00
parent 48869c768f
commit 4f9b9c4b80
2 changed files with 15 additions and 0 deletions

View file

@ -71,6 +71,7 @@ OpenGLState::OpenGLState() {
draw.vertex_buffer = 0; draw.vertex_buffer = 0;
draw.uniform_buffer = 0; draw.uniform_buffer = 0;
draw.shader_program = 0; draw.shader_program = 0;
draw.program_pipeline = 0;
scissor.enabled = false; scissor.enabled = false;
scissor.x = 0; scissor.x = 0;
@ -282,6 +283,11 @@ void OpenGLState::Apply() const {
glUseProgram(draw.shader_program); glUseProgram(draw.shader_program);
} }
// Program pipeline
if (draw.program_pipeline != cur_state.draw.program_pipeline) {
glBindProgramPipeline(draw.program_pipeline);
}
// Scissor test // Scissor test
if (scissor.enabled != cur_state.scissor.enabled) { if (scissor.enabled != cur_state.scissor.enabled) {
if (scissor.enabled) { if (scissor.enabled) {
@ -360,6 +366,13 @@ OpenGLState& OpenGLState::ResetProgram(GLuint handle) {
return *this; return *this;
} }
OpenGLState& OpenGLState::ResetPipeline(GLuint handle) {
if (draw.program_pipeline == handle) {
draw.program_pipeline = 0;
}
return *this;
}
OpenGLState& OpenGLState::ResetBuffer(GLuint handle) { OpenGLState& OpenGLState::ResetBuffer(GLuint handle) {
if (draw.vertex_buffer == handle) { if (draw.vertex_buffer == handle) {
draw.vertex_buffer = 0; draw.vertex_buffer = 0;

View file

@ -128,6 +128,7 @@ public:
GLuint vertex_buffer; // GL_ARRAY_BUFFER_BINDING GLuint vertex_buffer; // GL_ARRAY_BUFFER_BINDING
GLuint uniform_buffer; // GL_UNIFORM_BUFFER_BINDING GLuint uniform_buffer; // GL_UNIFORM_BUFFER_BINDING
GLuint shader_program; // GL_CURRENT_PROGRAM GLuint shader_program; // GL_CURRENT_PROGRAM
GLuint program_pipeline; // GL_PROGRAM_PIPELINE_BINDING
} draw; } draw;
struct { struct {
@ -161,6 +162,7 @@ public:
OpenGLState& ResetTexture(GLuint handle); OpenGLState& ResetTexture(GLuint handle);
OpenGLState& ResetSampler(GLuint handle); OpenGLState& ResetSampler(GLuint handle);
OpenGLState& ResetProgram(GLuint handle); OpenGLState& ResetProgram(GLuint handle);
OpenGLState& ResetPipeline(GLuint handle);
OpenGLState& ResetBuffer(GLuint handle); OpenGLState& ResetBuffer(GLuint handle);
OpenGLState& ResetVertexArray(GLuint handle); OpenGLState& ResetVertexArray(GLuint handle);
OpenGLState& ResetFramebuffer(GLuint handle); OpenGLState& ResetFramebuffer(GLuint handle);