From: Mikko Rasa Date: Fri, 1 Oct 2021 16:35:32 +0000 (+0300) Subject: Refactor VertexSetup format checking X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=526960705d8108dcc46dbb71d0d00d680b0b1bb3;p=libs%2Fgl.git Refactor VertexSetup format checking --- diff --git a/source/core/vertexsetup.cpp b/source/core/vertexsetup.cpp index 55424d6c..892cec86 100644 --- a/source/core/vertexsetup.cpp +++ b/source/core/vertexsetup.cpp @@ -43,7 +43,7 @@ void VertexSetup::set_format(const VertexFormat &vfmt) if(!vertex_format.empty()) throw invalid_operation("VertexSetup::set_format"); - require_format(vfmt); + require_format(vfmt, false); vertex_format = vfmt; } @@ -55,8 +55,8 @@ void VertexSetup::set_format_instanced(const VertexFormat &vfmt, const VertexFor 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; @@ -84,8 +84,6 @@ void VertexSetup::set_instance_array(const VertexArray &a) if(!a.get_buffer()) throw invalid_argument("VertexSetup::set_instance_array"); - static Require req(ARB_instanced_arrays); - inst_array = &a; dirty |= INSTANCE_ARRAY; } @@ -102,23 +100,16 @@ bool VertexSetup::verify_format(const VertexFormat &fmt) 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)