[core] use constexpr string concatenation for uniform/attribute names
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/gfx/attribute.hpp>
|
||||
#include <mbgl/gl/types.hpp>
|
||||
#include <mbgl/util/ignore.hpp>
|
||||
#include <mbgl/util/literal.hpp>
|
||||
#include <mbgl/util/indexed_tuple.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
|
||||
@@ -50,13 +51,15 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
return Locations{ maybeBindLocation(As::attributeName())... };
|
||||
return Locations{ maybeBindLocation(
|
||||
concat_literals<&string_literal<'a', '_'>::value, &As::name>::value())... };
|
||||
}()) {
|
||||
}
|
||||
|
||||
template <class BinaryProgram>
|
||||
AttributeLocations(const BinaryProgram& program)
|
||||
: locations{ program.attributeLocation(As::attributeName())... } {
|
||||
: locations{ program.attributeLocation(
|
||||
concat_literals<&string_literal<'a', '_'>::value, &As::name>::value())... } {
|
||||
}
|
||||
|
||||
NamedAttributeLocations getNamedLocations() const {
|
||||
@@ -68,7 +71,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
util::ignore({ (maybeAddLocation(As::attributeName(), locations.template get<As>()), 0)... });
|
||||
util::ignore({ (maybeAddLocation(concat_literals<&string_literal<'a', '_'>::value, &As::name>::value(),
|
||||
locations.template get<As>()),
|
||||
0)... });
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
#include <mbgl/gl/uniform.hpp>
|
||||
#include <mbgl/util/literal.hpp>
|
||||
#include <mbgl/util/ignore.hpp>
|
||||
|
||||
#include <vector>
|
||||
@@ -27,16 +28,19 @@ private:
|
||||
|
||||
public:
|
||||
void queryLocations(const ProgramID& id) {
|
||||
state = State{ gl::uniformLocation(id, Ts::uniformName())... };
|
||||
state = State{ gl::uniformLocation(id,
|
||||
concat_literals<&string_literal<'u', '_'>::value, &Ts::name>::value())... };
|
||||
}
|
||||
|
||||
template <class BinaryProgram>
|
||||
void loadNamedLocations(const BinaryProgram& program) {
|
||||
state = State{ program.textureLocation(Ts::uniformName())... };
|
||||
state = State{ program.textureLocation(
|
||||
concat_literals<&string_literal<'u', '_'>::value, &Ts::name>::value())... };
|
||||
}
|
||||
|
||||
NamedUniformLocations getNamedLocations() const {
|
||||
return NamedUniformLocations{ { Ts::uniformName(), state.template get<Ts>().location }... };
|
||||
return NamedUniformLocations{ { concat_literals<&string_literal<'u', '_'>::value, &Ts::name>::value(),
|
||||
state.template get<Ts>().location }... };
|
||||
}
|
||||
|
||||
void bind(gl::Context& context, const gfx::TextureBindings<TypeList<Ts...>>& bindings) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/gfx/uniform.hpp>
|
||||
#include <mbgl/gl/types.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
#include <mbgl/util/literal.hpp>
|
||||
#include <mbgl/util/ignore.hpp>
|
||||
#include <mbgl/util/indexed_tuple.hpp>
|
||||
|
||||
@@ -73,21 +74,21 @@ public:
|
||||
util::ignore(
|
||||
{ // Some shader programs have uniforms declared, but not used, so they're not active.
|
||||
// Therefore, we'll only verify them when they are indeed active.
|
||||
(active.find(Us::uniformName()) != active.end()
|
||||
? verifyUniform<typename Us::Value>(active.at(Us::uniformName()))
|
||||
(active.find(concat_literals<&string_literal<'u', '_'>::value, &Us::name>::value()) != active.end()
|
||||
? verifyUniform<typename Us::Value>(active.at(concat_literals<&string_literal<'u', '_'>::value, &Us::name>::value()))
|
||||
: false)... });
|
||||
#endif
|
||||
|
||||
state = State{ gl::uniformLocation(id, Us::uniformName())... };
|
||||
state = State{ gl::uniformLocation(id, concat_literals<&string_literal<'u', '_'>::value, &Us::name>::value())... };
|
||||
}
|
||||
|
||||
template <class BinaryProgram>
|
||||
void loadNamedLocations(const BinaryProgram& program) {
|
||||
state = State{ UniformState<typename Us::Value>(program.uniformLocation(Us::uniformName()))... };
|
||||
state = State{ UniformState<typename Us::Value>(program.uniformLocation(concat_literals<&string_literal<'u', '_'>::value, &Us::name>::value()))... };
|
||||
}
|
||||
|
||||
NamedUniformLocations getNamedLocations() const {
|
||||
return NamedUniformLocations{ { Us::uniformName(), state.template get<Us>().location }... };
|
||||
return NamedUniformLocations{ { concat_literals<&string_literal<'u', '_'>::value, &Us::name>::value(), state.template get<Us>().location }... };
|
||||
}
|
||||
|
||||
void bind(const gfx::UniformValues<TypeList<Us...>>& values) {
|
||||
|
||||
Reference in New Issue
Block a user