X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fpipelinestate.cpp;h=6078db5d0aa24d39bfb9fcf0a8ce1187e5215dcf;hb=cdefdb4b0f94613c2b41757fb33ae155efa9a205;hp=5ad51502010a1b1c2a2c37e7dd21b2a680dbdf2f;hpb=63458ee3bedacf4d498074fcec15600a4932ae7b;p=libs%2Fgl.git diff --git a/source/core/pipelinestate.cpp b/source/core/pipelinestate.cpp index 5ad51502..6078db5d 100644 --- a/source/core/pipelinestate.cpp +++ b/source/core/pipelinestate.cpp @@ -1,7 +1,9 @@ #include #include +#include #include "error.h" #include "pipelinestate.h" +#include "program.h" #include "uniformblock.h" using namespace std; @@ -70,11 +72,21 @@ void PipelineState::set_texture(unsigned binding, const Texture *tex, int level, if(level>=0 && !can_bind_tex_level(level)) throw invalid_operation("PipelineState::set_texture"); + set_texture_resource(binding, tex, level, samp); +} + +void PipelineState::set_storage_texture(unsigned binding, const Texture *tex) +{ + set_texture_resource(binding, tex, 0, 0); +} + +void PipelineState::set_texture_resource(unsigned binding, const Texture *tex, int level, const Sampler *samp) +{ auto i = lower_bound_member(resources, static_cast(binding), &BoundResource::binding); if(i==resources.end() || i->binding!=static_cast(binding)) i = resources.insert(i, BoundResource(binding)); - ResourceType type = (tex ? TEXTURE : NO_RESOURCE); + ResourceType type = (tex ? samp ? SAMPLED_TEXTURE : STORAGE_TEXTURE : NO_RESOURCE); if(i->type!=type || tex!=i->texture || level!=i->mip_level || samp!=i->sampler) { i->type = type; @@ -82,7 +94,7 @@ void PipelineState::set_texture(unsigned binding, const Texture *tex, int level, i->sampler = samp; i->mip_level = level; i->changed = true; - i->used = (tex && samp); + i->used = tex; changes |= RESOURCES; } } @@ -97,6 +109,11 @@ void PipelineState::set_primitive_type(PrimitiveType t) set(primitive_type, t, PRIMITIVE_TYPE); } +void PipelineState::set_patch_size(unsigned s) +{ + set(patch_size, s, PATCH_SIZE); +} + void PipelineState::set_front_face(FaceWinding w) { set(front_face, w, FACE_CULL); @@ -122,5 +139,27 @@ void PipelineState::set_blend(const Blend &b) set(blend, b, BLEND); } +void PipelineState::check_bound_resources() const +{ + if(!shprog) + return; + + for(const ReflectData::UniformBlockInfo &b: shprog->get_uniform_blocks()) + if(b.bind_point!=ReflectData::DEFAULT_BLOCK) + { + auto i = lower_bound_member(resources, b.bind_point, &PipelineState::BoundResource::binding); + if(i==resources.end() || i->binding!=b.bind_point) + IO::print(IO::cerr, "Warning: No resource present for uniform block binding %d:%d (%s)\n", b.bind_point>>20, b.bind_point&0xFFFFF, b.name); + } + + for(const ReflectData::UniformInfo &u: shprog->get_uniforms()) + if(u.binding>=0 && is_image(u.type)) + { + auto i = lower_bound_member(resources, u.binding, &PipelineState::BoundResource::binding); + if(i==resources.end() || i->binding!=u.binding) + IO::print(IO::cerr, "Warning: No resource present for texture binding %d:%d (%s)\n", u.binding>>20, u.binding&0xFFFFF, u.name); + } +} + } // namespace GL } // namespace Msp