if(!vertex_format.empty())
throw invalid_operation("VertexSetup::set_format");
- require_format(vfmt);
+ require_format(vfmt, false);
vertex_format = vfmt;
}
if(!vertex_format.empty())
throw invalid_operation("VertexSetup::set_format");
- require_format(vfmt);
- require_format(ifmt);
+ require_format(vfmt, false);
+ require_format(ifmt, true);
vertex_format = vfmt;
inst_format = ifmt;
if(!a.get_buffer())
throw invalid_argument("VertexSetup::set_instance_array");
- static Require req(ARB_instanced_arrays);
-
inst_array = &a;
dirty |= INSTANCE_ARRAY;
}
if(fmt.empty())
return false;
- unsigned max_attribs = DeviceInfo::get_global().limits.max_vertex_attributes;
-
- for(VertexAttribute a: fmt)
- if(get_attribute_semantic(a)>=max_attribs)
- return false;
-
- return true;
+ static unsigned max_attribs = DeviceInfo::get_global().limits.max_vertex_attributes;
+ return all_of(fmt.begin(), fmt.end(), [](VertexAttribute a){ return get_attribute_semantic(a)<max_attribs; });
}
-void VertexSetup::require_format(const VertexFormat &fmt)
+void VertexSetup::require_format(const VertexFormat &fmt, bool instanced)
{
- bool has_int = false;
- for(VertexAttribute a: fmt)
- has_int = has_int | is_integer_attribute(a);
-
- if(has_int)
+ if(any_of(fmt.begin(), fmt.end(), is_integer_attribute))
static Require _req(EXT_gpu_shader4);
+ if(instanced)
+ static Require req(ARB_instanced_arrays);
}
void VertexSetup::update() const
private:
static bool verify_format(const VertexFormat &);
- static void require_format(const VertexFormat &);
+ static void require_format(const VertexFormat &, bool);
void update() const;
void update_vertex_array(const VertexArray &, unsigned, unsigned, bool) const;