X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Fpipelinestate_backend.cpp;h=204e8139f0fc70802aaf3592b68a60779a124bae;hb=9eb9f592d37e9a1e05c2ff70887a1c5f26b98864;hp=3117a271c405308b8b0a628a9f722e4dd8fcd02f;hpb=2f2048a186c6a10f04999d8a01a3bcf63adc7c75;p=libs%2Fgl.git diff --git a/source/backends/opengl/pipelinestate_backend.cpp b/source/backends/opengl/pipelinestate_backend.cpp index 3117a271..204e8139 100644 --- a/source/backends/opengl/pipelinestate_backend.cpp +++ b/source/backends/opengl/pipelinestate_backend.cpp @@ -1,8 +1,10 @@ #include #include +#include #include #include #include +#include #include #include #include "blend.h" @@ -105,55 +107,58 @@ void OpenGLPipelineState::apply() const } } - if(changes&PipelineState::UNIFORMS) + if(changes&PipelineState::RESOURCES) { - for(const PipelineState::BoundUniformBlock &u: self.uniform_blocks) - if(u.changed || changes==~0U) + for(const PipelineState::BoundResource &r: self.resources) + { + if(!r.changed && changes!=~0U) + continue; + + if(r.used) { - if(u.used) + if(r.type==PipelineState::UNIFORM_BLOCK) { - if(u.binding>=0) + if(r.binding>=0) { - glBindBufferRange(GL_UNIFORM_BUFFER, u.binding, u.buffer->id, u.block->get_offset(), u.block->get_data_size()); - dev_state.bound_uniform_blocks[u.binding] = 1; + glBindBufferRange(GL_UNIFORM_BUFFER, r.binding, r.buffer->id, r.block->get_offset(), r.block->get_data_size()); + dev_state.bound_uniform_blocks[r.binding] = 1; } - else if(u.binding==ReflectData::DEFAULT_BLOCK && self.shprog) + else if(r.binding==ReflectData::DEFAULT_BLOCK && self.shprog) { - const char *data = static_cast(u.block->get_data_pointer()); + const char *data = static_cast(r.block->get_data_pointer()); for(const Program::UniformCall &call: self.shprog->uniform_calls) call.func(call.location, call.size, data+call.location*16); } } - - u.changed = false; - } - } - - if(changes&PipelineState::TEXTURES) - { - for(const PipelineState::BoundTexture &t: self.textures) - if(t.changed || changes==~0U) - { - if(t.used) + else if(r.type==PipelineState::SAMPLED_TEXTURE) { if(ARB_direct_state_access) - glBindTextureUnit(t.binding, t.texture->id); + glBindTextureUnit(r.binding, r.texture->id); else { - glActiveTexture(GL_TEXTURE0+t.binding); - if(dev_state.bound_tex_targets[t.binding] && static_cast(t.texture->target)!=dev_state.bound_tex_targets[t.binding]) - glBindTexture(dev_state.bound_tex_targets[t.binding], 0); - glBindTexture(t.texture->target, t.texture->id); + glActiveTexture(GL_TEXTURE0+r.binding); + if(dev_state.bound_tex_targets[r.binding] && static_cast(r.texture->target)!=dev_state.bound_tex_targets[r.binding]) + glBindTexture(dev_state.bound_tex_targets[r.binding], 0); + glBindTexture(r.texture->target, r.texture->id); } - dev_state.bound_tex_targets[t.binding] = t.texture->target; + dev_state.bound_tex_targets[r.binding] = r.texture->target; - glBindSampler(t.binding, t.sampler->id); - t.sampler->refresh(); + 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); - t.changed = false; + dev_state.bound_storage_textures[r.binding] = 1; + } } + + r.changed = false; + } } if(changes&PipelineState::VERTEX_SETUP) @@ -176,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); @@ -233,6 +245,11 @@ 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); } applied_to = &device; @@ -265,6 +282,13 @@ void OpenGLPipelineState::clear() dev_state.bound_tex_targets[i] = 0; } + for(unsigned i=0; i