+ dev_state.n_clip_distances = ncd;
+ }
+ }
+
+ if(changes&PipelineState::RESOURCES)
+ {
+ for(const PipelineState::BoundResource &r: self.resources)
+ {
+ if(!r.changed && changes!=~0U)
+ continue;
+
+ if(r.used)
+ {
+ if(r.type==PipelineState::UNIFORM_BLOCK)
+ {
+ if(r.binding>=0)
+ {
+ 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(r.binding==ReflectData::DEFAULT_BLOCK && self.shprog)
+ {
+ const char *data = static_cast<const char *>(r.block->get_data_pointer());
+ for(const Program::UniformCall &call: self.shprog->uniform_calls)
+ call.func(call.location, call.size, data+call.location*16);
+ }
+ }
+ else if(r.type==PipelineState::SAMPLED_TEXTURE)
+ {
+ if(ARB_direct_state_access)
+ glBindTextureUnit(r.binding, r.texture->id);
+ else
+ {
+ glActiveTexture(GL_TEXTURE0+r.binding);
+ if(dev_state.bound_tex_targets[r.binding] && static_cast<int>(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[r.binding] = r.texture->target;
+
+ 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;