]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/pipelinestate_backend.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / backends / opengl / pipelinestate_backend.cpp
index 3b8c6a5ae736c3f33543f9febb1c4b5a17696142..da5f495712408926bde3f9445349b383009c819c 100644 (file)
@@ -1,8 +1,10 @@
 #include <msp/gl/extensions/arb_direct_state_access.h>
 #include <msp/gl/extensions/arb_sampler_objects.h>
+#include <msp/gl/extensions/arb_shader_image_load_store.h>
 #include <msp/gl/extensions/arb_shader_objects.h>
 #include <msp/gl/extensions/arb_uniform_buffer_object.h>
 #include <msp/gl/extensions/arb_vertex_array_object.h>
+#include <msp/gl/extensions/arb_tessellation_shader.h>
 #include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/msp_primitive_restart.h>
 #include "blend.h"
@@ -128,7 +130,7 @@ void OpenGLPipelineState::apply() const
                                                        call.func(call.location, call.size, data+call.location*16);
                                        }
                                }
-                               else if(r.type==PipelineState::TEXTURE)
+                               else if(r.type==PipelineState::SAMPLED_TEXTURE)
                                {
                                        if(ARB_direct_state_access)
                                                glBindTextureUnit(r.binding, r.texture->id);
@@ -145,6 +147,14 @@ void OpenGLPipelineState::apply() const
                                        glBindSampler(r.binding, r.sampler->id);
                                        r.sampler->refresh();
                                }
+                               else if(r.type==PipelineState::STORAGE_TEXTURE)
+                               {
+                                       static Require _req(ARB_shader_image_load_store);
+                                       GLenum gl_format = get_gl_pixelformat(r.texture->get_format());
+                                       glBindImageTexture(r.binding, r.texture->id, 0, true, 0, GL_READ_WRITE, gl_format);
+
+                                       dev_state.bound_storage_textures[r.binding] = 1;
+                               }
                        }
 
                        r.changed = false;
@@ -171,6 +181,13 @@ void OpenGLPipelineState::apply() const
                }
        }
 
+       if(changes&PipelineState::PATCH_SIZE)
+               if(self.patch_size)
+               {
+                       static Require _req(ARB_tessellation_shader);
+                       glPatchParameteri(GL_PATCH_VERTICES, self.patch_size);
+               }
+
        if(changes&PipelineState::FACE_CULL)
        {
                glFrontFace(self.front_face==CLOCKWISE ? GL_CW : GL_CCW);
@@ -228,8 +245,18 @@ void OpenGLPipelineState::apply() const
                        glDisable(GL_BLEND);
                        glColorMask(true, true, true, true);
                }
+
+               if(blend.alpha_to_coverage && self.framebuffer && self.framebuffer->get_format().get_samples()>1)
+                       glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
+               else
+                       glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
        }
 
+#ifdef DEBUG
+       if(changes&(PipelineState::SHPROG|PipelineState::RESOURCES))
+               self.check_bound_resources();
+#endif
+
        applied_to = &device;
        dev_state.last_pipeline = this;
        changes = 0;
@@ -260,6 +287,13 @@ void OpenGLPipelineState::clear()
                                dev_state.bound_tex_targets[i] = 0;
                        }
 
+               for(unsigned i=0; i<dev_state.bound_storage_textures.size(); ++i)
+                       if(dev_state.bound_storage_textures[i])
+                       {
+                               glBindImageTexture(i, 0, 0, true, 0, GL_READ_ONLY, GL_RGBA8);
+                               dev_state.bound_storage_textures[i] = 0;
+                       }
+
                for(unsigned i=0; i<dev_state.bound_uniform_blocks.size(); ++i)
                        if(dev_state.bound_uniform_blocks[i])
                        {