Vertex attribute by index instead of map (#2116)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include <mbgl/gfx/drawable_tweaker.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/renderer/layers/render_symbol_layer.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/gfx/types.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
#include <mbgl/tile/geometry_tile_data.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/gfx/polyline_generator.hpp>
|
||||
@@ -137,8 +136,8 @@ public:
|
||||
/// Set the name given to new drawables
|
||||
void setDrawableName(std::string value) { drawableName = std::move(value); }
|
||||
|
||||
/// The attribute names for vertex/position attributes
|
||||
void setVertexAttrNameId(const StringIdentity id) { vertexAttrNameId = id; }
|
||||
/// The attribute id for vertex/position attribute
|
||||
void setVertexAttrId(const size_t id) { vertexAttrId = id; }
|
||||
|
||||
/// @brief Get the texture at the given internal ID.
|
||||
const gfx::Texture2DPtr& getTexture(size_t id) const;
|
||||
@@ -216,7 +215,7 @@ protected:
|
||||
protected:
|
||||
std::string name;
|
||||
std::string drawableName;
|
||||
StringIdentity vertexAttrNameId;
|
||||
std::size_t vertexAttrId;
|
||||
mbgl::RenderPass renderPass;
|
||||
bool enabled = true;
|
||||
bool enableColor = true;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using StringIdentity = std::size_t;
|
||||
using StringIDSetsPair = std::pair<unordered_set<std::string_view>, unordered_set<size_t>>;
|
||||
|
||||
namespace gfx {
|
||||
|
||||
@@ -147,10 +147,9 @@ public:
|
||||
/// @param propertiesAsUniforms Set of data driven properties as uniforms.
|
||||
/// @param firstAttribName Name of the first attribute
|
||||
/// @return A `gfx::ShaderPtr`
|
||||
virtual gfx::ShaderPtr getOrCreateShader(
|
||||
gfx::Context&,
|
||||
[[maybe_unused]] const mbgl::unordered_set<StringIdentity>& propertiesAsUniforms,
|
||||
[[maybe_unused]] std::string_view firstAttribName = "a_pos") {
|
||||
virtual gfx::ShaderPtr getOrCreateShader(gfx::Context&,
|
||||
[[maybe_unused]] const StringIDSetsPair& propertiesAsUniforms,
|
||||
[[maybe_unused]] std::string_view firstAttribName = "a_pos") {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -162,9 +161,9 @@ protected:
|
||||
}
|
||||
|
||||
/// Generate a map key for the specified combination of properties
|
||||
PropertyHashType propertyHash(const mbgl::unordered_set<StringIdentity>& propertiesAsUniforms) {
|
||||
const auto beg = propertiesAsUniforms.cbegin();
|
||||
const auto end = propertiesAsUniforms.cend();
|
||||
PropertyHashType propertyHash(const StringIDSetsPair& propertiesAsUniforms) {
|
||||
const auto beg = propertiesAsUniforms.second.cbegin();
|
||||
const auto end = propertiesAsUniforms.second.cend();
|
||||
return util::order_independent_hash<decltype(beg), PropertyHashType>(beg, end);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <mbgl/gfx/gfx_types.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
#include <mbgl/util/containers.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -33,6 +32,7 @@ class VertexAttributeArray;
|
||||
class VertexVectorBase;
|
||||
|
||||
using UniqueVertexAttribute = std::unique_ptr<VertexAttribute>;
|
||||
using StringIDSetsPair = std::pair<unordered_set<std::string_view>, unordered_set<size_t>>;
|
||||
|
||||
class VertexAttribute {
|
||||
public:
|
||||
@@ -279,15 +279,14 @@ protected:
|
||||
/// Stores a collection of vertex attributes by name
|
||||
class VertexAttributeArray {
|
||||
public:
|
||||
using AttributeMap = mbgl::unordered_map<StringIdentity, std::unique_ptr<VertexAttribute>>;
|
||||
|
||||
using AttributeVector = std::array<std::unique_ptr<VertexAttribute>, shaders::maxVertexAttributeCountPerShader>;
|
||||
VertexAttributeArray() = default;
|
||||
VertexAttributeArray(VertexAttributeArray&&);
|
||||
VertexAttributeArray(const VertexAttributeArray&) = delete; // Would need to use the virtual assignment operator
|
||||
virtual ~VertexAttributeArray() = default;
|
||||
|
||||
/// Number of elements
|
||||
std::size_t size() const { return attrs.size(); }
|
||||
/// Number of maximum allocated elements
|
||||
std::size_t allocatedSize() const { return attrs.size(); }
|
||||
|
||||
/// Sum of element strides, and the total size of a vertex in the buffer
|
||||
std::size_t getTotalSize() const;
|
||||
@@ -295,64 +294,46 @@ public:
|
||||
/// Get the largest count value of the attribute elements
|
||||
std::size_t getMaxCount() const;
|
||||
|
||||
/// Add a new attribute element.
|
||||
/// Returns a pointer to the new element on success, or null if the attribute already exists.
|
||||
/// The result is valid only until the next non-const method call on this class.
|
||||
const std::unique_ptr<VertexAttribute>& get(const StringIdentity id) const;
|
||||
/// Get a attribute element.
|
||||
/// Returns a pointer to the element on success, or null if the attribute doesn't exists.
|
||||
const std::unique_ptr<VertexAttribute>& get(const size_t id) const;
|
||||
|
||||
/// Add a new attribute element.
|
||||
/// Set a new attribute element or replace the existing one.
|
||||
/// Returns a pointer to the new element on success, or null if the attribute already exists.
|
||||
/// The result is valid only until the next non-const method call on this class.
|
||||
/// @param count Number of items, zero for shared data
|
||||
const std::unique_ptr<VertexAttribute>& add(const StringIdentity id,
|
||||
int index = -1,
|
||||
AttributeDataType type = AttributeDataType::Invalid,
|
||||
std::size_t count = 0);
|
||||
|
||||
/// Add a new attribute element if it doesn't already exist.
|
||||
/// Returns a pointer to the new element on success, or null if the type or count conflict with an existing entry.
|
||||
/// The result is valid only until the next non-const method call on this class.
|
||||
/// @param index index to match, or -1 for any
|
||||
/// @param type type to match, or `Invalid` for any
|
||||
/// @param count Number of items, zero for shared data
|
||||
const std::unique_ptr<VertexAttribute>& getOrAdd(const StringIdentity id,
|
||||
int index = -1,
|
||||
AttributeDataType type = AttributeDataType::Invalid,
|
||||
std::size_t count = 0);
|
||||
|
||||
// Set a value if the element is present
|
||||
template <typename T>
|
||||
bool set(const StringIdentity id, std::size_t i, T value) {
|
||||
if (const auto& item = get(id)) {
|
||||
return item->set(i, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const std::unique_ptr<VertexAttribute>& set(const size_t id,
|
||||
int index = -1,
|
||||
AttributeDataType type = AttributeDataType::Invalid,
|
||||
std::size_t count = 0);
|
||||
|
||||
/// Indicates whether any values have changed
|
||||
virtual bool isDirty() const {
|
||||
return std::any_of(
|
||||
attrs.begin(), attrs.end(), [](const auto& kv) { return kv.second && kv.second->isDirty(); });
|
||||
return std::any_of(attrs.begin(), attrs.end(), [](const auto& attr) { return attr && attr->isDirty(); });
|
||||
}
|
||||
|
||||
/// Clear the collection
|
||||
void clear();
|
||||
|
||||
/// Do something with each attribute
|
||||
template <typename Func /* void(StringIdentity, VertexAttribute&) */>
|
||||
template <typename Func /* void(VertexAttribute&) */>
|
||||
void visitAttributes(Func f) {
|
||||
std::for_each(attrs.begin(), attrs.end(), [&](const auto& kv) {
|
||||
if (kv.second) {
|
||||
f(kv.first, *kv.second);
|
||||
std::for_each(attrs.begin(), attrs.end(), [&](const auto& attr) {
|
||||
if (attr) {
|
||||
f(*attr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Call the provided delegate with each value, providing the override if one exists.
|
||||
template <typename Func /* void(const StringIdentity, VertexAttribute&, const std::unique_ptr<VertexAttribute>&) */>
|
||||
template <typename Func /* void(const size_t, VertexAttribute&, const std::unique_ptr<VertexAttribute>&) */>
|
||||
void resolve(const VertexAttributeArray& overrides, Func delegate) const {
|
||||
for (auto& kv : attrs) {
|
||||
delegate(kv.first, *kv.second, overrides.get(kv.first));
|
||||
for (size_t id = 0; id < attrs.size(); id++) {
|
||||
if (const auto& attr = attrs[id]) {
|
||||
delegate(id, *attr, overrides.get(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,14 +349,18 @@ public:
|
||||
template <typename... DataDrivenPaintProperty, typename Binders, typename Evaluated>
|
||||
void readDataDrivenPaintProperties(const Binders& binders,
|
||||
const Evaluated& evaluated,
|
||||
mbgl::unordered_set<StringIdentity>* propertiesAsUniforms) {
|
||||
StringIDSetsPair* propertiesAsUniforms,
|
||||
const size_t firstDataDrivenAttrId) {
|
||||
// Read each property in the type pack
|
||||
if (propertiesAsUniforms) {
|
||||
propertiesAsUniforms->reserve(sizeof...(DataDrivenPaintProperty));
|
||||
propertiesAsUniforms->first.reserve(sizeof...(DataDrivenPaintProperty));
|
||||
propertiesAsUniforms->second.reserve(sizeof...(DataDrivenPaintProperty));
|
||||
}
|
||||
size_t dataDrivenAttrId = firstDataDrivenAttrId;
|
||||
(readDataDrivenPaintProperty<DataDrivenPaintProperty>(binders.template get<DataDrivenPaintProperty>(),
|
||||
isConstant<DataDrivenPaintProperty>(evaluated),
|
||||
propertiesAsUniforms),
|
||||
propertiesAsUniforms,
|
||||
dataDrivenAttrId),
|
||||
...);
|
||||
}
|
||||
|
||||
@@ -388,12 +373,17 @@ public:
|
||||
template <typename... DataDrivenPaintProperty, typename Binders, typename Evaluated>
|
||||
void readDataDrivenPaintProperties(const Binders& binders,
|
||||
const Evaluated& evaluated,
|
||||
mbgl::unordered_set<StringIdentity>& propertiesAsUniforms) {
|
||||
StringIDSetsPair& propertiesAsUniforms,
|
||||
const size_t firstDataDrivenAttrId) {
|
||||
// Read each property in the type pack
|
||||
propertiesAsUniforms.reserve(sizeof...(DataDrivenPaintProperty));
|
||||
propertiesAsUniforms.first.reserve(sizeof...(DataDrivenPaintProperty));
|
||||
propertiesAsUniforms.second.reserve(sizeof...(DataDrivenPaintProperty));
|
||||
|
||||
size_t dataDrivenAttrId = firstDataDrivenAttrId;
|
||||
(readDataDrivenPaintProperty<DataDrivenPaintProperty>(binders.template get<DataDrivenPaintProperty>(),
|
||||
isConstant<DataDrivenPaintProperty>(evaluated),
|
||||
&propertiesAsUniforms),
|
||||
&propertiesAsUniforms,
|
||||
dataDrivenAttrId),
|
||||
...);
|
||||
}
|
||||
|
||||
@@ -407,28 +397,27 @@ protected:
|
||||
template <typename DataDrivenPaintProperty, typename Binder>
|
||||
void readDataDrivenPaintProperty(const Binder& binder,
|
||||
const bool isConstant,
|
||||
mbgl::unordered_set<StringIdentity>* propertiesAsUniforms) {
|
||||
StringIDSetsPair* propertiesAsUniforms,
|
||||
size_t& dataDrivenAttrId) {
|
||||
if (!binder) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Consider each attribute name in the attribute (e.g., pattern_from, pattern_to)
|
||||
for (std::size_t attrIndex = 0; attrIndex < DataDrivenPaintProperty::AttributeNames.size(); ++attrIndex) {
|
||||
auto& attributeNameID = DataDrivenPaintProperty::AttributeNameIDs[attrIndex];
|
||||
if (!attributeNameID) {
|
||||
const auto& attributeName = DataDrivenPaintProperty::AttributeNames[attrIndex];
|
||||
attributeNameID = stringIndexer().get(attributePrefix + attributeName.data());
|
||||
}
|
||||
const auto& attributeName = DataDrivenPaintProperty::AttributeNames[attrIndex];
|
||||
|
||||
// Apply the property, or add it to the uniforms collection if it's constant.
|
||||
if (!isConstant && binder->getVertexCount() > 0) {
|
||||
using Attribute = typename DataDrivenPaintProperty::Attribute;
|
||||
const auto& attr = getOrAdd(
|
||||
*attributeNameID, /*index=*/-1, /*type=*/gfx::AttributeDataType::Invalid, /*count=*/0);
|
||||
applyPaintProperty<Attribute>(attrIndex, attr, binder);
|
||||
if (const auto& attr = set(dataDrivenAttrId)) {
|
||||
applyPaintProperty<Attribute>(attrIndex, attr, binder);
|
||||
}
|
||||
} else if (propertiesAsUniforms) {
|
||||
propertiesAsUniforms->emplace(*attributeNameID);
|
||||
propertiesAsUniforms->first.emplace(attributeName);
|
||||
propertiesAsUniforms->second.emplace(dataDrivenAttrId);
|
||||
}
|
||||
dataDrivenAttrId++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,8 +448,6 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
const UniqueVertexAttribute& add(const StringIdentity id, std::unique_ptr<VertexAttribute>&&);
|
||||
|
||||
virtual UniqueVertexAttribute create(int index, AttributeDataType dataType, std::size_t count) const {
|
||||
return std::make_unique<VertexAttribute>(index, dataType, count);
|
||||
}
|
||||
@@ -470,7 +457,7 @@ protected:
|
||||
}
|
||||
|
||||
protected:
|
||||
AttributeMap attrs;
|
||||
AttributeVector attrs;
|
||||
static const std::unique_ptr<VertexAttribute> nullref;
|
||||
static const std::string attributePrefix;
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <mbgl/gl/vertex_array.hpp>
|
||||
#include <mbgl/gl/vertex_attribute_gl.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -45,7 +44,7 @@ public:
|
||||
const gfx::UniformBufferArray& getUniformBuffers() const override;
|
||||
gfx::UniformBufferArray& mutableUniformBuffers() override;
|
||||
|
||||
void setVertexAttrNameId(const StringIdentity id);
|
||||
void setVertexAttrId(const size_t id);
|
||||
|
||||
void upload(gfx::UploadPass&);
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <mbgl/gfx/draw_mode.hpp>
|
||||
#include <mbgl/mtl/upload_pass.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -45,7 +44,7 @@ public:
|
||||
const gfx::UniformBufferArray& getUniformBuffers() const override;
|
||||
gfx::UniformBufferArray& mutableUniformBuffers() override;
|
||||
|
||||
void setVertexAttrNameId(const StringIdentity);
|
||||
void setVertexAttrId(const size_t);
|
||||
|
||||
void upload(gfx::UploadPass&);
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ class RenderTree;
|
||||
class UnwrappedTileID;
|
||||
|
||||
using mat4 = std::array<double, 16>;
|
||||
using StringIdentity = std::size_t;
|
||||
|
||||
/**
|
||||
Base class for layer tweakers, which manipulate layer group per frame
|
||||
|
||||
@@ -27,9 +27,9 @@ struct alignas(16) CustomSymbolIconParametersUBO {
|
||||
static_assert(sizeof(CustomSymbolIconParametersUBO) == 3 * 16);
|
||||
|
||||
enum {
|
||||
idCustomSymbolIconDrawableUBO,
|
||||
idCustomSymbolIconParametersUBO,
|
||||
customDrawableUBOCount
|
||||
idCustomSymbolDrawableUBO,
|
||||
idCustomSymbolParametersUBO,
|
||||
customSymbolUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
~ShaderGroupGL() noexcept override = default;
|
||||
|
||||
gfx::ShaderPtr getOrCreateShader(gfx::Context& context,
|
||||
const mbgl::unordered_set<StringIdentity>& propertiesAsUniforms,
|
||||
const StringIDSetsPair& propertiesAsUniforms,
|
||||
std::string_view firstAttribName) override {
|
||||
constexpr auto& name = shaders::ShaderSource<ShaderID, gfx::Backend::Type::OpenGL>::name;
|
||||
constexpr auto& vert = shaders::ShaderSource<ShaderID, gfx::Backend::Type::OpenGL>::vertex;
|
||||
@@ -38,11 +38,10 @@ public:
|
||||
|
||||
// No match, we need to create the shader.
|
||||
std::string additionalDefines;
|
||||
additionalDefines.reserve(propertiesAsUniforms.size() * 48);
|
||||
for (const auto nameID : propertiesAsUniforms) {
|
||||
additionalDefines.reserve(propertiesAsUniforms.first.size() * 48);
|
||||
for (const auto propertyName : propertiesAsUniforms.first) {
|
||||
// We expect the names to be prefixed by "a_", but we need just the base here.
|
||||
const auto prefixedAttrName = stringIndexer().get(nameID);
|
||||
const auto* prefix = prefixedAttrName.data();
|
||||
const auto* prefix = propertyName.data();
|
||||
if (prefix[0] == 'a' && prefix[1] == '_') {
|
||||
prefix += 2;
|
||||
}
|
||||
@@ -58,6 +57,7 @@ public:
|
||||
firstAttribName,
|
||||
shaders::ShaderInfo<ShaderID, gfx::Backend::Type::OpenGL>::uniformBlocks,
|
||||
shaders::ShaderInfo<ShaderID, gfx::Backend::Type::OpenGL>::textures,
|
||||
shaders::ShaderInfo<ShaderID, gfx::Backend::Type::OpenGL>::attributes,
|
||||
vert,
|
||||
frag,
|
||||
additionalDefines);
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
struct AttributeInfo {
|
||||
AttributeInfo(std::string_view name, std::size_t id);
|
||||
std::string_view name;
|
||||
std::size_t id;
|
||||
};
|
||||
|
||||
struct UniformBlockInfo {
|
||||
UniformBlockInfo(std::string_view name, std::size_t id);
|
||||
std::string_view name;
|
||||
@@ -26,156 +32,182 @@ struct ShaderInfo;
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::BackgroundShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::CircleShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::CollisionBoxShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::CollisionCircleShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::DebugShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::FillShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::FillOutlineShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::FillPatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::HeatmapShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::HillshadeShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::LineGradientShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::LinePatternShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::LineSDFShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::LineShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::LineBasicShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::SymbolIconShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderInfo<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::OpenGL> {
|
||||
static const std::vector<AttributeInfo> attributes;
|
||||
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||
static const std::vector<TextureInfo> textures;
|
||||
};
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
const std::string_view firstAttribName,
|
||||
const std::vector<shaders::UniformBlockInfo>& uniformBlocksInfo,
|
||||
const std::vector<shaders::TextureInfo>& texturesInfo,
|
||||
const std::vector<shaders::AttributeInfo>& attributesInfo,
|
||||
const std::string& vertexSource,
|
||||
const std::string& fragmentSource,
|
||||
const std::string& additionalDefines = "") noexcept(false);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
#include <mbgl/shaders/background_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/mtl/common.hpp>
|
||||
#include <mbgl/shaders/mtl/shader_program.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -16,19 +16,15 @@ namespace mbgl {
|
||||
namespace mtl {
|
||||
|
||||
class ShaderGroupBase : public gfx::ShaderGroup {
|
||||
public:
|
||||
using StringIDSet = mbgl::unordered_set<StringIdentity>;
|
||||
|
||||
protected:
|
||||
ShaderGroupBase(const ProgramParameters& parameters_)
|
||||
: programParameters(parameters_) {}
|
||||
|
||||
using DefinesMap = mbgl::unordered_map<std::string, std::string>;
|
||||
void addAdditionalDefines(const StringIDSet& propertiesAsUniforms, DefinesMap& additionalDefines) {
|
||||
additionalDefines.reserve(propertiesAsUniforms.size());
|
||||
for (const auto nameID : propertiesAsUniforms) {
|
||||
void addAdditionalDefines(const StringIDSetsPair& propertiesAsUniforms, DefinesMap& additionalDefines) {
|
||||
additionalDefines.reserve(propertiesAsUniforms.first.size());
|
||||
for (const auto name : propertiesAsUniforms.first) {
|
||||
// We expect the names to be prefixed by "a_", but we need just the base here.
|
||||
const auto name = stringIndexer().get(nameID);
|
||||
const auto* base = (name[0] == 'a' && name[1] == '_') ? &name[2] : name.data();
|
||||
additionalDefines.insert(std::make_pair(std::string(uniformPrefix) + base, std::string()));
|
||||
}
|
||||
@@ -48,7 +44,7 @@ public:
|
||||
~ShaderGroup() noexcept override = default;
|
||||
|
||||
gfx::ShaderPtr getOrCreateShader(gfx::Context& gfxContext,
|
||||
const mbgl::unordered_set<StringIdentity>& propertiesAsUniforms,
|
||||
const StringIDSetsPair& propertiesAsUniforms,
|
||||
std::string_view /*firstAttribName*/) override {
|
||||
using ShaderSource = shaders::ShaderSource<ShaderID, gfx::Backend::Type::Metal>;
|
||||
constexpr auto& name = ShaderSource::name;
|
||||
@@ -78,7 +74,7 @@ public:
|
||||
|
||||
using ShaderClass = shaders::ShaderSource<ShaderID, gfx::Backend::Type::Metal>;
|
||||
for (const auto& attrib : ShaderClass::attributes) {
|
||||
if (!propertiesAsUniforms.count(attrib.nameID)) {
|
||||
if (!propertiesAsUniforms.second.count(attrib.id)) {
|
||||
shader->initAttribute(attrib);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
struct AttributeInfo {
|
||||
AttributeInfo(std::size_t index, gfx::AttributeDataType dataType, std::string_view name);
|
||||
AttributeInfo(std::size_t index, gfx::AttributeDataType dataType, std::size_t id);
|
||||
std::size_t index;
|
||||
gfx::AttributeDataType dataType;
|
||||
std::string_view name;
|
||||
StringIdentity nameID;
|
||||
std::size_t id;
|
||||
};
|
||||
struct UniformBlockInfo {
|
||||
UniformBlockInfo(std::size_t index, bool vertex, bool fragment, std::size_t size, std::size_t id);
|
||||
|
||||
@@ -20,10 +20,17 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
// UBO defines
|
||||
enum {
|
||||
idClippingMaskUBO,
|
||||
clippingMaskUBOCount
|
||||
};
|
||||
|
||||
static constexpr auto maxUBOCountPerShader = std::max({static_cast<size_t>(backgroundUBOCount),
|
||||
static_cast<size_t>(circleUBOCount),
|
||||
static_cast<size_t>(clippingMaskUBOCount),
|
||||
static_cast<size_t>(collisionUBOCount),
|
||||
static_cast<size_t>(customDrawableUBOCount),
|
||||
static_cast<size_t>(customSymbolUBOCount),
|
||||
static_cast<size_t>(debugUBOCount),
|
||||
static_cast<size_t>(fillUBOCount),
|
||||
static_cast<size_t>(fillOutlineUBOCount),
|
||||
@@ -42,6 +49,7 @@ static constexpr auto maxUBOCountPerShader = std::max({static_cast<size_t>(backg
|
||||
static_cast<size_t>(rasterUBOCount),
|
||||
static_cast<size_t>(symbolUBOCount)});
|
||||
|
||||
// Texture defines
|
||||
enum {
|
||||
idBackgroundImageTexture,
|
||||
backgroundTextureCount
|
||||
@@ -51,13 +59,17 @@ enum {
|
||||
circleTextureCount
|
||||
};
|
||||
|
||||
enum {
|
||||
clippingMaskTextureCount
|
||||
};
|
||||
|
||||
enum {
|
||||
collisionTextureCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCustomSymbolIconTexture,
|
||||
customSymbolIconTextureCount
|
||||
idCustomSymbolImageTexture,
|
||||
customSymbolTextureCount
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -66,13 +78,13 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
idFillExtrusionImageTexture,
|
||||
fillExtrusionTextureCount
|
||||
idFillImageTexture,
|
||||
fillTextureCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idFillImageTexture,
|
||||
fillTextureCount
|
||||
idFillExtrusionImageTexture,
|
||||
fillExtrusionTextureCount
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -105,8 +117,9 @@ enum {
|
||||
|
||||
static constexpr auto maxTextureCountPerShader = std::max({static_cast<size_t>(backgroundTextureCount),
|
||||
static_cast<size_t>(circleTextureCount),
|
||||
static_cast<size_t>(clippingMaskTextureCount),
|
||||
static_cast<size_t>(collisionTextureCount),
|
||||
static_cast<size_t>(customSymbolIconTextureCount),
|
||||
static_cast<size_t>(customSymbolTextureCount),
|
||||
static_cast<size_t>(debugTextureCount),
|
||||
static_cast<size_t>(fillTextureCount),
|
||||
static_cast<size_t>(fillExtrusionTextureCount),
|
||||
@@ -116,5 +129,150 @@ static constexpr auto maxTextureCountPerShader = std::max({static_cast<size_t>(b
|
||||
static_cast<size_t>(rasterTextureCount),
|
||||
static_cast<size_t>(symbolTextureCount)});
|
||||
|
||||
// Vertex attribute defines
|
||||
enum {
|
||||
idBackgroundPosVertexAttribute,
|
||||
backgroundVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCirclePosVertexAttribute,
|
||||
|
||||
// Data driven
|
||||
idCircleColorVertexAttribute,
|
||||
idCircleRadiusVertexAttribute,
|
||||
idCircleBlurVertexAttribute,
|
||||
idCircleOpacityVertexAttribute,
|
||||
idCircleStrokeColorVertexAttribute,
|
||||
idCircleStrokeWidthVertexAttribute,
|
||||
idCircleStrokeOpacityVertexAttribute,
|
||||
|
||||
circleVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idClippingMaskPosVertexAttribute,
|
||||
clippingMaskVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCollisionPosVertexAttribute,
|
||||
idCollisionAnchorPosVertexAttribute,
|
||||
idCollisionExtrudeVertexAttribute,
|
||||
idCollisionPlacedVertexAttribute,
|
||||
idCollisionShiftVertexAttribute,
|
||||
collisionVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCustomSymbolPosVertexAttribute,
|
||||
idCustomSymbolTexVertexAttribute,
|
||||
customSymbolVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idDebugPosVertexAttribute,
|
||||
debugVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idFillPosVertexAttribute,
|
||||
|
||||
// Data driven
|
||||
idFillColorVertexAttribute,
|
||||
idFillOpacityVertexAttribute,
|
||||
idFillOutlineColorVertexAttribute,
|
||||
idFillPatternFromVertexAttribute,
|
||||
idFillPatternToVertexAttribute,
|
||||
|
||||
fillVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idFillExtrusionPosVertexAttribute,
|
||||
idFillExtrusionNormalEdVertexAttribute,
|
||||
|
||||
// Data driven
|
||||
idFillExtrusionBaseVertexAttribute,
|
||||
idFillExtrusionColorVertexAttribute,
|
||||
idFillExtrusionHeightVertexAttribute,
|
||||
idFillExtrusionPatternFromVertexAttribute,
|
||||
idFillExtrusionPatternToVertexAttribute,
|
||||
|
||||
fillExtrusionVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idHeatmapPosVertexAttribute,
|
||||
|
||||
// Data driven
|
||||
idHeatmapWeightVertexAttribute,
|
||||
idHeatmapRadiusVertexAttribute,
|
||||
|
||||
heatmapVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idHillshadePosVertexAttribute,
|
||||
idHillshadeTexturePosVertexAttribute,
|
||||
hillshadeVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idLinePosNormalVertexAttribute,
|
||||
idLineDataVertexAttribute,
|
||||
|
||||
// Data driven
|
||||
idLineColorVertexAttribute,
|
||||
idLineBlurVertexAttribute,
|
||||
idLineOpacityVertexAttribute,
|
||||
idLineGapWidthVertexAttribute,
|
||||
idLineOffsetVertexAttribute,
|
||||
idLineWidthVertexAttribute,
|
||||
idLineFloorWidthVertexAttribute,
|
||||
idLinePatternFromVertexAttribute,
|
||||
idLinePatternToVertexAttribute,
|
||||
|
||||
lineVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idRasterPosVertexAttribute,
|
||||
idRasterTexturePosVertexAttribute,
|
||||
rasterVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idSymbolPosOffsetVertexAttribute,
|
||||
idSymbolDataVertexAttribute,
|
||||
idSymbolPixelOffsetVertexAttribute,
|
||||
idSymbolProjectedPosVertexAttribute,
|
||||
idSymbolFadeOpacityVertexAttribute,
|
||||
|
||||
// Data driven
|
||||
idSymbolOpacityVertexAttribute,
|
||||
idSymbolColorVertexAttribute,
|
||||
idSymbolHaloColorVertexAttribute,
|
||||
idSymbolHaloWidthVertexAttribute,
|
||||
idSymbolHaloBlurVertexAttribute,
|
||||
|
||||
symbolVertexAttributeCount
|
||||
};
|
||||
|
||||
static constexpr auto maxVertexAttributeCountPerShader = std::max(
|
||||
{static_cast<size_t>(backgroundVertexAttributeCount),
|
||||
static_cast<size_t>(circleVertexAttributeCount),
|
||||
static_cast<size_t>(clippingMaskVertexAttributeCount),
|
||||
static_cast<size_t>(collisionVertexAttributeCount),
|
||||
static_cast<size_t>(customSymbolVertexAttributeCount),
|
||||
static_cast<size_t>(debugVertexAttributeCount),
|
||||
static_cast<size_t>(fillVertexAttributeCount),
|
||||
static_cast<size_t>(fillExtrusionVertexAttributeCount),
|
||||
static_cast<size_t>(heatmapVertexAttributeCount),
|
||||
static_cast<size_t>(hillshadeVertexAttributeCount),
|
||||
static_cast<size_t>(lineVertexAttributeCount),
|
||||
static_cast<size_t>(rasterVertexAttributeCount),
|
||||
static_cast<size_t>(symbolVertexAttributeCount)});
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <mbgl/gfx/uniform_block.hpp>
|
||||
#include <mbgl/gfx/vertex_attribute.hpp>
|
||||
#include <mbgl/util/identity.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
@@ -19,7 +18,7 @@ protected:
|
||||
~ShaderProgramBase() noexcept override = default;
|
||||
|
||||
template <typename T>
|
||||
bool set(gfx::VertexAttributeArray& attrs, const StringIdentity id, std::size_t i, T value) {
|
||||
bool set(gfx::VertexAttributeArray& attrs, const size_t id, std::size_t i, T value) {
|
||||
const auto& item = attrs.get(id);
|
||||
if (item && i < item->getCount()) {
|
||||
item->set(i, value);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <mbgl/gfx/vertex_attribute.hpp>
|
||||
#include <mbgl/renderer/render_pass.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
#include <mbgl/gfx/gfx_types.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -13,7 +12,7 @@ namespace gfx {
|
||||
|
||||
DrawableBuilder::DrawableBuilder(std::string name_)
|
||||
: name(std::move(name_)),
|
||||
vertexAttrNameId(stringIndexer().get("a_pos")),
|
||||
vertexAttrId(0),
|
||||
renderPass(mbgl::RenderPass::Opaque),
|
||||
impl(std::make_unique<Impl>()) {}
|
||||
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
#include <mbgl/gfx/drawable_builder_impl.hpp>
|
||||
|
||||
#include <mbgl/gfx/drawable_impl.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/gfx/polyline_generator.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gfx {
|
||||
|
||||
using namespace shaders;
|
||||
|
||||
DrawableBuilder::Impl::LineLayoutVertex DrawableBuilder::Impl::layoutVertex(
|
||||
Point<int16_t> p, Point<double> e, bool round, bool up, int8_t dir, int32_t linesofar /*= 0*/) {
|
||||
/*
|
||||
@@ -61,18 +63,14 @@ void DrawableBuilder::Impl::addPolyline(gfx::DrawableBuilder& builder,
|
||||
|
||||
void DrawableBuilder::Impl::setupForPolylines(gfx::Context& context, gfx::DrawableBuilder& builder) {
|
||||
// setup vertex attributes
|
||||
static const StringIdentity idVertexAttribName = stringIndexer().get("a_pos_normal");
|
||||
static const StringIdentity idDataAttribName = stringIndexer().get("a_data");
|
||||
|
||||
builder.setVertexAttrNameId(idVertexAttribName);
|
||||
|
||||
builder.setVertexAttrId(idLinePosNormalVertexAttribute);
|
||||
builder.setRawVertices({}, polylineVertices.elements(), gfx::AttributeDataType::Short2);
|
||||
|
||||
auto attrs = context.createVertexAttributeArray();
|
||||
using VertexVector = gfx::VertexVector<LineLayoutVertex>;
|
||||
std::shared_ptr<VertexVector> verts = std::make_shared<VertexVector>(std::move(polylineVertices));
|
||||
|
||||
if (const auto& attr = attrs->add(idVertexAttribName)) {
|
||||
if (const auto& attr = attrs->set(idLinePosNormalVertexAttribute)) {
|
||||
attr->setSharedRawData(verts,
|
||||
offsetof(LineLayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -80,7 +78,7 @@ void DrawableBuilder::Impl::setupForPolylines(gfx::Context& context, gfx::Drawab
|
||||
gfx::AttributeDataType::Short2);
|
||||
}
|
||||
|
||||
if (const auto& attr = attrs->add(idDataAttribName)) {
|
||||
if (const auto& attr = attrs->set(idLineDataVertexAttribute)) {
|
||||
attr->setSharedRawData(verts,
|
||||
offsetof(LineLayoutVertex, a2),
|
||||
/*vertexOffset=*/0,
|
||||
|
||||
@@ -13,9 +13,6 @@ enum class SymbolType : uint8_t;
|
||||
namespace gfx {
|
||||
|
||||
struct SymbolDrawableData : public DrawableData {
|
||||
constexpr static std::size_t LinearThreshold = 10;
|
||||
using PropertyMapType = util::TinyUnorderedMap<StringIdentity, bool, LinearThreshold>;
|
||||
|
||||
SymbolDrawableData(const bool isHalo_,
|
||||
const bool bucketVariablePlacement_,
|
||||
const style::SymbolType symbolType_,
|
||||
|
||||
@@ -93,65 +93,37 @@ VertexAttributeArray& VertexAttributeArray::operator=(VertexAttributeArray&& oth
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::unique_ptr<VertexAttribute>& VertexAttributeArray::get(const StringIdentity id) const {
|
||||
const auto result = attrs.find(id);
|
||||
return (result != attrs.end()) ? result->second : nullref;
|
||||
const std::unique_ptr<VertexAttribute>& VertexAttributeArray::get(const size_t id) const {
|
||||
return (id < attrs.size()) ? attrs[id] : nullref;
|
||||
}
|
||||
|
||||
const std::unique_ptr<VertexAttribute>& VertexAttributeArray::add(const StringIdentity id,
|
||||
const std::unique_ptr<VertexAttribute>& VertexAttributeArray::set(const size_t id,
|
||||
int index,
|
||||
AttributeDataType dataType,
|
||||
std::size_t count) {
|
||||
const auto result = attrs.insert(std::make_pair(id, std::unique_ptr<VertexAttribute>()));
|
||||
if (result.second) {
|
||||
result.first->second = create(index, dataType, count);
|
||||
return result.first->second;
|
||||
} else {
|
||||
assert(id < attrs.size());
|
||||
if (id >= attrs.size()) {
|
||||
return nullref;
|
||||
}
|
||||
}
|
||||
|
||||
const std::unique_ptr<VertexAttribute>& VertexAttributeArray::getOrAdd(const StringIdentity id,
|
||||
int index,
|
||||
AttributeDataType dataType,
|
||||
std::size_t count) {
|
||||
const auto result = attrs.insert(std::make_pair(id, std::unique_ptr<VertexAttribute>()));
|
||||
auto& attr = result.first->second;
|
||||
if (result.second) {
|
||||
// inserted
|
||||
attr = create(index, dataType, count);
|
||||
} else {
|
||||
// already present
|
||||
assert(dataType == AttributeDataType::Invalid || attr->getDataType() == dataType);
|
||||
assert((index < 0 || attr->getIndex() == index) && (count == 0 || attr->getCount() == count));
|
||||
}
|
||||
return attr;
|
||||
attrs[id] = create(index, dataType, count);
|
||||
return attrs[id];
|
||||
}
|
||||
|
||||
std::size_t VertexAttributeArray::getTotalSize() const {
|
||||
return std::accumulate(attrs.begin(), attrs.end(), std::size_t(0), [](const auto acc, const auto& kv) {
|
||||
return acc + kv.second->getStride();
|
||||
return std::accumulate(attrs.begin(), attrs.end(), std::size_t(0), [](const auto acc, const auto& attr) {
|
||||
return acc + (attr ? attr->getStride() : 0);
|
||||
});
|
||||
}
|
||||
|
||||
std::size_t VertexAttributeArray::getMaxCount() const {
|
||||
return std::accumulate(attrs.begin(), attrs.end(), std::size_t(0), [](const auto acc, const auto& kv) {
|
||||
return std::max(acc, kv.second->getCount());
|
||||
return std::accumulate(attrs.begin(), attrs.end(), std::size_t(0), [](const auto acc, const auto& attr) {
|
||||
return std::max(acc, (attr ? attr->getCount() : 0));
|
||||
});
|
||||
}
|
||||
|
||||
void VertexAttributeArray::clear() {
|
||||
attrs.clear();
|
||||
}
|
||||
|
||||
const UniqueVertexAttribute& VertexAttributeArray::add(const StringIdentity id,
|
||||
std::unique_ptr<VertexAttribute>&& attr) {
|
||||
const auto result = attrs.insert(std::make_pair(id, std::unique_ptr<VertexAttribute>()));
|
||||
if (result.second) {
|
||||
result.first->second = std::move(attr);
|
||||
return result.first->second;
|
||||
} else {
|
||||
return nullref;
|
||||
for (auto& attr : attrs) {
|
||||
attr = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/shaders/gl/shader_program_gl.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gl {
|
||||
@@ -98,8 +97,8 @@ gfx::UniformBufferArray& DrawableGL::mutableUniformBuffers() {
|
||||
return impl->uniformBuffers;
|
||||
}
|
||||
|
||||
void DrawableGL::setVertexAttrNameId(const StringIdentity id) {
|
||||
impl->idVertexAttrName = id;
|
||||
void DrawableGL::setVertexAttrId(const size_t id) {
|
||||
impl->vertexAttrId = id;
|
||||
}
|
||||
|
||||
void DrawableGL::bindUniformBuffers() const {
|
||||
@@ -169,7 +168,7 @@ void DrawableGL::upload(gfx::UploadPass& uploadPass) {
|
||||
const auto& defaults = shader->getVertexAttributes();
|
||||
const auto& overrides = *vertexAttributes;
|
||||
|
||||
const auto& indexAttribute = defaults.get(impl->idVertexAttrName);
|
||||
const auto& indexAttribute = defaults.get(impl->vertexAttrId);
|
||||
const auto vertexAttributeIndex = static_cast<std::size_t>(indexAttribute ? indexAttribute->getIndex() : -1);
|
||||
|
||||
std::vector<std::unique_ptr<gfx::VertexBufferResource>> vertexBuffers;
|
||||
|
||||
@@ -23,7 +23,7 @@ std::unique_ptr<gfx::Drawable::DrawSegment> DrawableGLBuilder::createSegment(gfx
|
||||
void DrawableGLBuilder::init() {
|
||||
auto& drawableGL = static_cast<DrawableGL&>(*currentDrawable);
|
||||
|
||||
drawableGL.setVertexAttrNameId(vertexAttrNameId);
|
||||
drawableGL.setVertexAttrId(vertexAttrId);
|
||||
|
||||
if (impl->rawVerticesCount) {
|
||||
auto raw = impl->rawVertices;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
@@ -49,7 +48,7 @@ public:
|
||||
gfx::CullFaceMode cullFaceMode;
|
||||
GLfloat pointSize = 0.0f;
|
||||
|
||||
StringIdentity idVertexAttrName = stringIndexer().get("a_pos");
|
||||
size_t vertexAttrId = 0;
|
||||
};
|
||||
|
||||
struct DrawableGL::DrawSegmentGL final : public gfx::Drawable::DrawSegment {
|
||||
|
||||
@@ -192,7 +192,7 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
|
||||
const gfx::BufferUsageType usage,
|
||||
/*out*/ std::vector<std::unique_ptr<gfx::VertexBufferResource>>& outBuffers) {
|
||||
AttributeBindingArray bindings;
|
||||
bindings.resize(defaults.size());
|
||||
bindings.resize(defaults.allocatedSize());
|
||||
|
||||
constexpr std::size_t align = 16;
|
||||
constexpr std::uint8_t padding = 0;
|
||||
@@ -216,7 +216,7 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
|
||||
}
|
||||
|
||||
// For each attribute in the program, with the corresponding default and optional override...
|
||||
const auto resolveAttr = [&](const StringIdentity id, auto& defaultAttr, auto& overrideAttr) -> void {
|
||||
const auto resolveAttr = [&](const size_t id, auto& defaultAttr, auto& overrideAttr) -> void {
|
||||
auto& effectiveAttr = overrideAttr ? *overrideAttr : defaultAttr;
|
||||
const auto& defaultGL = static_cast<const VertexAttributeGL&>(defaultAttr);
|
||||
const auto stride = defaultAttr.getStride();
|
||||
@@ -262,7 +262,7 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
|
||||
// something else, the binding is invalid
|
||||
// TODO: throw?
|
||||
Log::Warning(Event::General,
|
||||
"Got " + util::toString(rawData.size()) + " bytes for attribute '" + stringIndexer().get(id) +
|
||||
"Got " + util::toString(rawData.size()) + " bytes for attribute '" + util::toString(id) +
|
||||
"' (" + util::toString(defaultGL.getIndex()) + "), expected " + util::toString(stride) +
|
||||
" or " + util::toString(stride * vertexCount));
|
||||
return;
|
||||
|
||||
@@ -183,15 +183,15 @@ const std::vector<std::uint8_t>& VertexAttributeGL::getRaw(gfx::VertexAttribute&
|
||||
}
|
||||
|
||||
bool VertexAttributeArrayGL::isDirty() const {
|
||||
return std::any_of(attrs.begin(), attrs.end(), [](const auto& kv) {
|
||||
if (kv.second) {
|
||||
return std::any_of(attrs.begin(), attrs.end(), [](const auto& attr) {
|
||||
if (attr) {
|
||||
// If we have shared data, the dirty flag from that overrides ours
|
||||
const auto& glAttrib = static_cast<const VertexAttributeGL&>(*kv.second);
|
||||
const auto& glAttrib = static_cast<const VertexAttributeGL&>(*attr);
|
||||
if (const auto& shared = glAttrib.getSharedRawData()) {
|
||||
return shared->getDirty();
|
||||
}
|
||||
}
|
||||
return kv.second && kv.second->isDirty();
|
||||
return attr && attr->isDirty();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -317,14 +317,13 @@ void Drawable::setVertices(std::vector<uint8_t>&& data, std::size_t count, gfx::
|
||||
if (!vertexAttributes) {
|
||||
vertexAttributes = std::make_shared<VertexAttributeArray>();
|
||||
}
|
||||
if (auto& attrib = vertexAttributes->getOrAdd(impl->idVertexAttrName, /*index=*/-1, type)) {
|
||||
if (auto& attrib = vertexAttributes->set(impl->vertexAttrId, /*index=*/-1, type)) {
|
||||
attrib->setRawData(std::move(data));
|
||||
attrib->setStride(VertexAttribute::getStrideOf(type));
|
||||
} else {
|
||||
using namespace std::string_literals;
|
||||
Log::Warning(
|
||||
Event::General,
|
||||
"Vertex attribute type mismatch: "s + name + " / " + stringIndexer().get(impl->idVertexAttrName));
|
||||
Log::Warning(Event::General,
|
||||
"Vertex attribute type mismatch: "s + name + " / " + util::toString(impl->vertexAttrId));
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
@@ -338,8 +337,8 @@ gfx::UniformBufferArray& Drawable::mutableUniformBuffers() {
|
||||
return impl->uniformBuffers;
|
||||
}
|
||||
|
||||
void Drawable::setVertexAttrNameId(const StringIdentity value) {
|
||||
impl->idVertexAttrName = value;
|
||||
void Drawable::setVertexAttrId(const size_t id) {
|
||||
impl->vertexAttrId = id;
|
||||
}
|
||||
|
||||
void Drawable::bindAttributes(RenderPass& renderPass) const noexcept {
|
||||
@@ -540,7 +539,7 @@ void Drawable::upload(gfx::UploadPass& uploadPass_) {
|
||||
vertexBuffers);
|
||||
impl->attributeBuffers = std::move(vertexBuffers);
|
||||
|
||||
vertexAttributes->visitAttributes([](const auto&, gfx::VertexAttribute& attrib) { attrib.setDirty(false); });
|
||||
vertexAttributes->visitAttributes([](gfx::VertexAttribute& attrib) { attrib.setDirty(false); });
|
||||
|
||||
if (impl->attributeBindings != attributeBindings_) {
|
||||
impl->attributeBindings = std::move(attributeBindings_);
|
||||
|
||||
@@ -22,7 +22,7 @@ std::unique_ptr<gfx::Drawable::DrawSegment> DrawableBuilder::createSegment(gfx::
|
||||
void DrawableBuilder::init() {
|
||||
auto& drawable = static_cast<Drawable&>(*currentDrawable);
|
||||
|
||||
drawable.setVertexAttrNameId(vertexAttrNameId);
|
||||
drawable.setVertexAttrId(vertexAttrId);
|
||||
|
||||
if (impl->rawVerticesCount) {
|
||||
auto raw = impl->rawVertices;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <Foundation/NSSharedPtr.hpp>
|
||||
#include <Metal/MTLVertexDescriptor.hpp>
|
||||
@@ -53,7 +52,7 @@ public:
|
||||
gfx::StencilMode stencilMode;
|
||||
gfx::CullFaceMode cullFaceMode;
|
||||
// GLfloat pointSize = 0.0f;
|
||||
StringIdentity idVertexAttrName = stringIndexer().get("a_pos");
|
||||
std::size_t vertexAttrId = 0;
|
||||
|
||||
VertexBufferResource* noBindingBuffer = nullptr;
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
|
||||
const gfx::BufferUsageType usage,
|
||||
/*out*/ std::vector<std::unique_ptr<gfx::VertexBufferResource>>& outBuffers) {
|
||||
gfx::AttributeBindingArray bindings;
|
||||
bindings.resize(defaults.size());
|
||||
bindings.resize(defaults.allocatedSize());
|
||||
|
||||
constexpr std::size_t align = 16;
|
||||
constexpr std::uint8_t padding = 0;
|
||||
@@ -169,7 +169,7 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
|
||||
uint32_t vertexStride = 0;
|
||||
|
||||
// For each attribute in the program, with the corresponding default and optional override...
|
||||
const auto resolveAttr = [&](const StringIdentity id, auto& default_, auto& override_) -> void {
|
||||
const auto resolveAttr = [&](const size_t id, auto& default_, auto& override_) -> void {
|
||||
auto& effectiveAttr = override_ ? *override_ : default_;
|
||||
const auto& defaultAttr = static_cast<const VertexAttribute&>(default_);
|
||||
const auto stride = defaultAttr.getStride();
|
||||
|
||||
@@ -34,15 +34,15 @@ const gfx::UniqueVertexBufferResource& VertexAttribute::getBuffer(gfx::VertexAtt
|
||||
}
|
||||
|
||||
bool VertexAttributeArray::isDirty() const {
|
||||
return std::any_of(attrs.begin(), attrs.end(), [](const auto& kv) {
|
||||
if (kv.second) {
|
||||
return std::any_of(attrs.begin(), attrs.end(), [](const auto& attr) {
|
||||
if (attr) {
|
||||
// If we have shared data, the dirty flag from that overrides ours
|
||||
const auto& attrib = static_cast<const VertexAttribute&>(*kv.second);
|
||||
const auto& attrib = static_cast<const VertexAttribute&>(*attr);
|
||||
if (const auto& shared = attrib.getSharedRawData()) {
|
||||
return shared->getDirty();
|
||||
}
|
||||
}
|
||||
return kv.second && kv.second->isDirty();
|
||||
return attr && attr->isDirty();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
#include <mbgl/style/layers/circle_layer_properties.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#if MLN_RENDER_BACKEND_METAL
|
||||
#include <mbgl/shaders/mtl/circle.hpp>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/renderer/layer_tweaker.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/renderer/layer_tweaker.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/renderer/layer_tweaker.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <mbgl/shaders/heatmap_layer_ubo.hpp>
|
||||
#include <mbgl/style/layers/heatmap_layer_properties.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#if MLN_RENDER_BACKEND_METAL
|
||||
#include <mbgl/shaders/mtl/heatmap.hpp>
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <mbgl/shaders/heatmap_texture_layer_ubo.hpp>
|
||||
#include <mbgl/style/layers/heatmap_layer_properties.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <mbgl/shaders/hillshade_layer_ubo.hpp>
|
||||
#include <mbgl/style/layers/hillshade_layer_properties.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <mbgl/shaders/hillshade_prepare_layer_ubo.hpp>
|
||||
#include <mbgl/style/layers/hillshade_layer_properties.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <mbgl/util/convert.hpp>
|
||||
#include <mbgl/gfx/image_drawable_data.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
using namespace shaders;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -308,6 +309,7 @@ void RenderBackgroundLayer::update(gfx::ShaderRegistry& shaders,
|
||||
}
|
||||
|
||||
auto verticesCopy = rawVertices;
|
||||
builder->setVertexAttrId(idBackgroundPosVertexAttribute);
|
||||
builder->setRawVertices(std::move(verticesCopy), vertexCount, gfx::AttributeDataType::Short2);
|
||||
builder->setSegments(gfx::Triangles(), indexes.vector(), segs.data(), segs.size());
|
||||
builder->flush(context);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <mbgl/renderer/update_parameters.hpp>
|
||||
#include <mbgl/shaders/circle_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/shader_program_base.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
#endif
|
||||
|
||||
namespace mbgl {
|
||||
@@ -264,7 +263,6 @@ bool RenderCircleLayer::queryIntersectsFeature(const GeometryCoordinates& queryG
|
||||
namespace {
|
||||
|
||||
constexpr auto CircleShaderGroupName = "CircleShader";
|
||||
const StringIdentity idVertexAttribName = stringIndexer().get("a_pos");
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -314,7 +312,7 @@ void RenderCircleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
[&](gfx::Drawable& drawable) { return drawable.getTileID() && !hasRenderTile(*drawable.getTileID()); });
|
||||
|
||||
const auto& evaluated = static_cast<const CircleLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
mbgl::unordered_set<StringIdentity> propertiesAsUniforms;
|
||||
StringIDSetsPair propertiesAsUniforms;
|
||||
|
||||
for (const RenderTile& tile : *renderTiles) {
|
||||
const auto& tileID = tile.getOverscaledTileID();
|
||||
@@ -367,7 +365,9 @@ void RenderCircleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
|
||||
const auto interpBuffer = context.createUniformBuffer(&interpolateUBO, sizeof(interpolateUBO));
|
||||
|
||||
propertiesAsUniforms.clear();
|
||||
propertiesAsUniforms.first.clear();
|
||||
propertiesAsUniforms.second.clear();
|
||||
|
||||
auto circleVertexAttrs = context.createVertexAttributeArray();
|
||||
circleVertexAttrs->readDataDrivenPaintProperties<CircleColor,
|
||||
CircleRadius,
|
||||
@@ -376,17 +376,14 @@ void RenderCircleLayer::update(gfx::ShaderRegistry& shaders,
|
||||
CircleStrokeColor,
|
||||
CircleStrokeWidth,
|
||||
CircleStrokeOpacity>(
|
||||
paintPropertyBinders, evaluated, propertiesAsUniforms);
|
||||
paintPropertyBinders, evaluated, propertiesAsUniforms, idCircleColorVertexAttribute);
|
||||
|
||||
if (!circleShaderGroup) {
|
||||
continue;
|
||||
}
|
||||
const auto circleShader = circleShaderGroup->getOrCreateShader(context, propertiesAsUniforms);
|
||||
if (!circleShader) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (const auto& attr = circleVertexAttrs->add(idVertexAttribName)) {
|
||||
if (const auto& attr = circleVertexAttrs->set(idCirclePosVertexAttribute)) {
|
||||
attr->setSharedRawData(bucket.sharedVertices,
|
||||
offsetof(CircleLayoutVertex, a1),
|
||||
0,
|
||||
|
||||
@@ -38,12 +38,6 @@ using namespace shaders;
|
||||
|
||||
namespace {
|
||||
|
||||
#if MLN_DRAWABLE_RENDERER
|
||||
const StringIdentity idPosAttribName = stringIndexer().get("a_pos");
|
||||
const StringIdentity idNormAttribName = stringIndexer().get("a_normal_ed");
|
||||
|
||||
#endif // MLN_DRAWABLE_RENDERER
|
||||
|
||||
inline const FillExtrusionLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) {
|
||||
assert(impl->getTypeInfo() == FillExtrusionLayer::Impl::staticTypeInfo());
|
||||
return static_cast<const FillExtrusionLayer::Impl&>(*impl);
|
||||
@@ -338,7 +332,7 @@ void RenderFillExtrusionLayer::update(gfx::ShaderRegistry& shaders,
|
||||
|
||||
tileLayerGroup->setStencilTiles(renderTiles);
|
||||
|
||||
mbgl::unordered_set<StringIdentity> propertiesAsUniforms;
|
||||
StringIDSetsPair propertiesAsUniforms;
|
||||
for (const RenderTile& tile : *renderTiles) {
|
||||
const auto& tileID = tile.getOverscaledTileID();
|
||||
|
||||
@@ -408,13 +402,15 @@ void RenderFillExtrusionLayer::update(gfx::ShaderRegistry& shaders,
|
||||
continue;
|
||||
}
|
||||
|
||||
propertiesAsUniforms.clear();
|
||||
propertiesAsUniforms.first.clear();
|
||||
propertiesAsUniforms.second.clear();
|
||||
|
||||
auto vertexAttrs = context.createVertexAttributeArray();
|
||||
vertexAttrs->readDataDrivenPaintProperties<FillExtrusionBase,
|
||||
FillExtrusionColor,
|
||||
FillExtrusionHeight,
|
||||
FillExtrusionPattern>(binders, evaluated, propertiesAsUniforms);
|
||||
FillExtrusionPattern>(
|
||||
binders, evaluated, propertiesAsUniforms, idFillExtrusionBaseVertexAttribute);
|
||||
|
||||
const auto shader = std::static_pointer_cast<gfx::ShaderProgramBase>(
|
||||
shaderGroup->getOrCreateShader(context, propertiesAsUniforms));
|
||||
@@ -473,14 +469,14 @@ void RenderFillExtrusionLayer::update(gfx::ShaderRegistry& shaders,
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto& attr = vertexAttrs->add(idPosAttribName)) {
|
||||
if (const auto& attr = vertexAttrs->set(idFillExtrusionPosVertexAttribute)) {
|
||||
attr->setSharedRawData(bucket.sharedVertices,
|
||||
offsetof(FillExtrusionLayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
sizeof(FillExtrusionLayoutVertex),
|
||||
gfx::AttributeDataType::Short2);
|
||||
}
|
||||
if (const auto& attr = vertexAttrs->add(idNormAttribName)) {
|
||||
if (const auto& attr = vertexAttrs->set(idFillExtrusionNormalEdVertexAttribute)) {
|
||||
attr->setSharedRawData(bucket.sharedVertices,
|
||||
offsetof(FillExtrusionLayoutVertex, a2),
|
||||
/*vertexOffset=*/0,
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <mbgl/renderer/update_parameters.hpp>
|
||||
#include <mbgl/shaders/fill_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/shader_program_base.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
#include <mbgl/shaders/line_layer_ubo.hpp>
|
||||
#endif
|
||||
|
||||
@@ -49,8 +48,6 @@ constexpr auto FillOutlineTriangulatedShaderName = "LineBasicShader";
|
||||
constexpr auto FillOutlineShaderName = "FillOutlineShader";
|
||||
constexpr auto FillPatternShaderName = "FillPatternShader";
|
||||
constexpr auto FillOutlinePatternShaderName = "FillOutlinePatternShader";
|
||||
|
||||
const StringIdentity idPosAttribName = stringIndexer().get("a_pos");
|
||||
#endif // MLN_DRAWABLE_RENDERER
|
||||
|
||||
inline const FillLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) {
|
||||
@@ -479,7 +476,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
|
||||
fillTileLayerGroup->setStencilTiles(renderTiles);
|
||||
|
||||
mbgl::unordered_set<StringIdentity> propertiesAsUniforms;
|
||||
StringIDSetsPair propertiesAsUniforms;
|
||||
for (const RenderTile& tile : *renderTiles) {
|
||||
const auto& tileID = tile.getOverscaledTileID();
|
||||
|
||||
@@ -608,15 +605,16 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
return atlasTweaker;
|
||||
};
|
||||
|
||||
propertiesAsUniforms.clear();
|
||||
propertiesAsUniforms.first.clear();
|
||||
propertiesAsUniforms.second.clear();
|
||||
|
||||
// `Fill*Program` all use `style::FillPaintProperties`
|
||||
auto vertexAttrs = context.createVertexAttributeArray();
|
||||
vertexAttrs->readDataDrivenPaintProperties<FillColor, FillOpacity, FillOutlineColor, FillPattern>(
|
||||
binders, evaluated, propertiesAsUniforms);
|
||||
binders, evaluated, propertiesAsUniforms, idFillColorVertexAttribute);
|
||||
|
||||
const auto vertexCount = bucket.vertices.elements();
|
||||
if (const auto& attr = vertexAttrs->add(idPosAttribName)) {
|
||||
if (const auto& attr = vertexAttrs->set(idFillPosVertexAttribute)) {
|
||||
attr->setSharedRawData(bucket.sharedVertices,
|
||||
offsetof(FillLayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -682,11 +680,9 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
|
||||
#if MLN_TRIANGULATE_FILL_OUTLINES
|
||||
const auto outlineTriangulatedShader = doOutline && !dataDrivenOutline ? [&]() -> auto {
|
||||
static const mbgl::unordered_set<StringIdentity> outlinePropertiesAsUniforms{
|
||||
stringIndexer().get("a_color"),
|
||||
stringIndexer().get("a_opacity"),
|
||||
stringIndexer().get("a_width"),
|
||||
};
|
||||
static const StringIDSetsPair outlinePropertiesAsUniforms{
|
||||
{"a_color", "a_opacity", "a_width"},
|
||||
{idLineColorVertexAttribute, idLineOpacityVertexAttribute, idLineWidthVertexAttribute}};
|
||||
return std::static_pointer_cast<gfx::ShaderProgramBase>(
|
||||
outlineTriangulatedShaderGroup->getOrCreateShader(context, outlinePropertiesAsUniforms));
|
||||
}()
|
||||
@@ -694,21 +690,18 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
|
||||
auto createOutline = [&](auto& builder, Color color, float opacity) {
|
||||
if (doOutline && builder && bucket.sharedLineIndexes->elements()) {
|
||||
static const StringIdentity idVertexAttribName = stringIndexer().get("a_pos_normal");
|
||||
static const StringIdentity idDataAttribName = stringIndexer().get("a_data");
|
||||
builder->setVertexAttrNameId(idVertexAttribName);
|
||||
builder->setShader(outlineTriangulatedShader);
|
||||
builder->setRawVertices({}, bucket.lineVertices.elements(), gfx::AttributeDataType::Short2);
|
||||
|
||||
auto attrs = context.createVertexAttributeArray();
|
||||
if (const auto& attr = attrs->add(idVertexAttribName)) {
|
||||
if (const auto& attr = attrs->set(idLinePosNormalVertexAttribute)) {
|
||||
attr->setSharedRawData(bucket.sharedLineVertices,
|
||||
offsetof(LineLayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
sizeof(LineLayoutVertex),
|
||||
gfx::AttributeDataType::Short2);
|
||||
}
|
||||
if (const auto& attr = attrs->add(idDataAttribName)) {
|
||||
if (const auto& attr = attrs->set(idLineDataVertexAttribute)) {
|
||||
attr->setSharedRawData(bucket.sharedLineVertices,
|
||||
offsetof(LineLayoutVertex, a2),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -770,7 +763,6 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
const size_t interpolateUBOId,
|
||||
const auto& interpolateUBO,
|
||||
FillVariant type) {
|
||||
builder.setVertexAttrNameId(idPosAttribName);
|
||||
builder.flush(context);
|
||||
|
||||
for (auto& drawable : builder.clearDrawables()) {
|
||||
@@ -897,7 +889,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
}
|
||||
|
||||
const auto finish = [&](gfx::DrawableBuilder& builder,
|
||||
const StringIdentity interpolateNameId,
|
||||
const size_t interpolateNameId,
|
||||
const auto& interpolateUBO,
|
||||
const size_t tileUBOId,
|
||||
const auto& tileUBO,
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <mbgl/gfx/drawable_builder.hpp>
|
||||
#include <mbgl/gfx/shader_group.hpp>
|
||||
#include <mbgl/gfx/shader_registry.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
#endif
|
||||
|
||||
namespace mbgl {
|
||||
@@ -278,8 +277,6 @@ namespace {
|
||||
constexpr auto HeatmapShaderGroupName = "HeatmapShader";
|
||||
constexpr auto HeatmapTextureShaderGroupName = "HeatmapTextureShader";
|
||||
|
||||
const StringIdentity idVertexAttribName = stringIndexer().get("a_pos");
|
||||
|
||||
} // namespace
|
||||
|
||||
using namespace shaders;
|
||||
@@ -345,9 +342,9 @@ void RenderHeatmapLayer::update(gfx::ShaderRegistry& shaders,
|
||||
[&](gfx::Drawable& drawable) { return drawable.getTileID() && !hasRenderTile(*drawable.getTileID()); });
|
||||
|
||||
const auto& evaluated = static_cast<const HeatmapLayerProperties&>(*evaluatedProperties).evaluated;
|
||||
std::optional<mbgl::unordered_set<StringIdentity>> propertiesAsUniforms;
|
||||
std::optional<StringIDSetsPair> propertiesAsUniforms;
|
||||
#if !defined(NDEBUG)
|
||||
std::optional<mbgl::unordered_set<StringIdentity>> previousPropertiesAsUniforms;
|
||||
std::optional<StringIDSetsPair> previousPropertiesAsUniforms;
|
||||
#endif
|
||||
|
||||
gfx::ShaderPtr heatmapShader;
|
||||
@@ -411,13 +408,14 @@ void RenderHeatmapLayer::update(gfx::ShaderRegistry& shaders,
|
||||
}
|
||||
#if !defined(NDEBUG)
|
||||
else {
|
||||
propertiesAsUniforms->clear();
|
||||
propertiesAsUniforms->first.clear();
|
||||
propertiesAsUniforms->second.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
auto heatmapVertexAttrs = context.createVertexAttributeArray();
|
||||
heatmapVertexAttrs->readDataDrivenPaintProperties<HeatmapWeight, HeatmapRadius>(
|
||||
paintPropertyBinders, evaluated, *propertiesAsUniforms);
|
||||
paintPropertyBinders, evaluated, *propertiesAsUniforms, idHeatmapWeightVertexAttribute);
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
// We assume the properties are the same across tiles.
|
||||
@@ -435,7 +433,7 @@ void RenderHeatmapLayer::update(gfx::ShaderRegistry& shaders,
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto& attr = heatmapVertexAttrs->add(idVertexAttribName)) {
|
||||
if (const auto& attr = heatmapVertexAttrs->set(idHeatmapPosVertexAttribute)) {
|
||||
attr->setSharedRawData(bucket.sharedVertices,
|
||||
offsetof(HeatmapLayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -505,7 +503,7 @@ void RenderHeatmapLayer::update(gfx::ShaderRegistry& shaders,
|
||||
const auto textureVertexCount = sharedTextureVertices->elements();
|
||||
|
||||
auto textureVertexAttrs = context.createVertexAttributeArray();
|
||||
if (const auto& attr = textureVertexAttrs->add(idVertexAttribName)) {
|
||||
if (const auto& attr = textureVertexAttrs->set(idHeatmapPosVertexAttribute)) {
|
||||
attr->setSharedRawData(sharedTextureVertices,
|
||||
offsetof(HeatmapLayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
|
||||
@@ -295,9 +295,6 @@ void RenderHillshadeLayer::removeRenderTargets(UniqueChangeRequestVec& changes)
|
||||
static const std::string HillshadePrepareShaderGroupName = "HillshadePrepareShader";
|
||||
static const std::string HillshadeShaderGroupName = "HillshadeShader";
|
||||
|
||||
static const StringIdentity idPosAttribName = stringIndexer().get("a_pos");
|
||||
static const StringIdentity idTexturePosAttribName = stringIndexer().get("a_texture_pos");
|
||||
|
||||
void RenderHillshadeLayer::update(gfx::ShaderRegistry& shaders,
|
||||
gfx::Context& context,
|
||||
[[maybe_unused]] const TransformState& state,
|
||||
@@ -358,14 +355,14 @@ void RenderHillshadeLayer::update(gfx::ShaderRegistry& shaders,
|
||||
if (!hillshadePrepareVertexAttrs) {
|
||||
hillshadePrepareVertexAttrs = context.createVertexAttributeArray();
|
||||
|
||||
if (const auto& attr = hillshadePrepareVertexAttrs->add(idPosAttribName)) {
|
||||
if (const auto& attr = hillshadePrepareVertexAttrs->set(idHillshadePosVertexAttribute)) {
|
||||
attr->setSharedRawData(staticDataSharedVertices,
|
||||
offsetof(HillshadeLayoutVertex, a1),
|
||||
0,
|
||||
sizeof(HillshadeLayoutVertex),
|
||||
gfx::AttributeDataType::Short2);
|
||||
}
|
||||
if (const auto& attr = hillshadePrepareVertexAttrs->add(idTexturePosAttribName)) {
|
||||
if (const auto& attr = hillshadePrepareVertexAttrs->set(idHillshadeTexturePosVertexAttribute)) {
|
||||
attr->setSharedRawData(staticDataSharedVertices,
|
||||
offsetof(HillshadeLayoutVertex, a2),
|
||||
0,
|
||||
@@ -465,14 +462,14 @@ void RenderHillshadeLayer::update(gfx::ShaderRegistry& shaders,
|
||||
if (!hillshadeVertexAttrs) {
|
||||
hillshadeVertexAttrs = context.createVertexAttributeArray();
|
||||
|
||||
if (const auto& attr = hillshadeVertexAttrs->add(idPosAttribName)) {
|
||||
if (const auto& attr = hillshadeVertexAttrs->set(idHillshadePosVertexAttribute)) {
|
||||
attr->setSharedRawData(vertices,
|
||||
offsetof(HillshadeLayoutVertex, a1),
|
||||
0,
|
||||
sizeof(HillshadeLayoutVertex),
|
||||
gfx::AttributeDataType::Short2);
|
||||
}
|
||||
if (const auto& attr = hillshadeVertexAttrs->getOrAdd(idTexturePosAttribName)) {
|
||||
if (const auto& attr = hillshadeVertexAttrs->set(idHillshadeTexturePosVertexAttribute)) {
|
||||
attr->setSharedRawData(vertices,
|
||||
offsetof(HillshadeLayoutVertex, a2),
|
||||
0,
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <mbgl/renderer/update_parameters.hpp>
|
||||
#include <mbgl/shaders/line_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/shader_program_base.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
#endif
|
||||
|
||||
namespace mbgl {
|
||||
@@ -47,8 +46,7 @@ inline const LineLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& imp
|
||||
|
||||
#if MLN_DRAWABLE_RENDERER
|
||||
|
||||
const StringIdentity idVertexAttribName = stringIndexer().get("a_pos_normal");
|
||||
const StringIdentity idDataAttribName = stringIndexer().get("a_data");
|
||||
const auto posNormalAttribName = "a_pos_normal";
|
||||
|
||||
#endif // MLN_DRAWABLE_RENDERER
|
||||
|
||||
@@ -371,19 +369,6 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
layerGroup->addLayerTweaker(layerTweaker);
|
||||
}
|
||||
|
||||
if (!lineShaderGroup) {
|
||||
lineShaderGroup = shaders.getShaderGroup("LineShader");
|
||||
}
|
||||
if (!lineGradientShaderGroup) {
|
||||
lineGradientShaderGroup = shaders.getShaderGroup("LineGradientShader");
|
||||
}
|
||||
if (!linePatternShaderGroup) {
|
||||
linePatternShaderGroup = shaders.getShaderGroup("LinePatternShader");
|
||||
}
|
||||
if (!lineSDFShaderGroup) {
|
||||
lineSDFShaderGroup = shaders.getShaderGroup("LineSDFShader");
|
||||
}
|
||||
|
||||
const RenderPass renderPass = static_cast<RenderPass>(evaluatedProperties->renderPasses &
|
||||
~mbgl::underlying_type(RenderPass::Opaque));
|
||||
|
||||
@@ -407,7 +392,6 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
: gfx::ColorMode::unblended());
|
||||
builder->setCullFaceMode(gfx::CullFaceMode::disabled());
|
||||
builder->setEnableStencil(true);
|
||||
builder->setVertexAttrNameId(idVertexAttribName);
|
||||
|
||||
return builder;
|
||||
};
|
||||
@@ -417,7 +401,7 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
const auto vertexCount = bucket.vertices.elements();
|
||||
builder.setRawVertices({}, vertexCount, gfx::AttributeDataType::Short4);
|
||||
|
||||
if (const auto& attr = vertexAttrs->add(idVertexAttribName)) {
|
||||
if (const auto& attr = vertexAttrs->set(idLinePosNormalVertexAttribute)) {
|
||||
attr->setSharedRawData(bucket.sharedVertices,
|
||||
offsetof(LineLayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -425,7 +409,7 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
gfx::AttributeDataType::Short2);
|
||||
}
|
||||
|
||||
if (const auto& attr = vertexAttrs->add(idDataAttribName)) {
|
||||
if (const auto& attr = vertexAttrs->set(idLineDataVertexAttribute)) {
|
||||
attr->setSharedRawData(bucket.sharedVertices,
|
||||
offsetof(LineLayoutVertex, a2),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -442,7 +426,7 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
|
||||
tileLayerGroup->setStencilTiles(renderTiles);
|
||||
|
||||
mbgl::unordered_set<StringIdentity> propertiesAsUniforms;
|
||||
StringIDSetsPair propertiesAsUniforms;
|
||||
for (const RenderTile& tile : *renderTiles) {
|
||||
const auto& tileID = tile.getOverscaledTileID();
|
||||
|
||||
@@ -547,6 +531,7 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
const auto& linePatternValue = evaluated.get<LinePattern>().constantOr(Faded<expression::Image>{"", ""});
|
||||
const std::optional<ImagePosition> patternPosA = tile.getPattern(linePatternValue.from.id());
|
||||
const std::optional<ImagePosition> patternPosB = tile.getPattern(linePatternValue.to.id());
|
||||
paintPropertyBinders.setPatternParameters(patternPosA, patternPosB, crossfade);
|
||||
|
||||
auto getLinePatternTilePropertiesUBO = [&]() -> const LinePatternTilePropertiesUBO& {
|
||||
if (!linePatternTilePropertiesUBO) {
|
||||
@@ -600,24 +585,30 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
continue;
|
||||
}
|
||||
|
||||
propertiesAsUniforms.first.clear();
|
||||
propertiesAsUniforms.second.clear();
|
||||
|
||||
auto vertexAttrs = context.createVertexAttributeArray();
|
||||
vertexAttrs->readDataDrivenPaintProperties<LineColor,
|
||||
LineBlur,
|
||||
LineOpacity,
|
||||
LineGapWidth,
|
||||
LineOffset,
|
||||
LineWidth,
|
||||
LineFloorWidth,
|
||||
LinePattern>(
|
||||
paintPropertyBinders, evaluated, propertiesAsUniforms, idLineColorVertexAttribute);
|
||||
|
||||
if (!evaluated.get<LineDasharray>().from.empty()) {
|
||||
// dash array line (SDF)
|
||||
if (!lineSDFShaderGroup) {
|
||||
continue;
|
||||
lineSDFShaderGroup = shaders.getShaderGroup("LineSDFShader");
|
||||
if (!lineSDFShaderGroup) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// dash array line (SDF)
|
||||
propertiesAsUniforms.clear();
|
||||
auto vertexAttrs = context.createVertexAttributeArray();
|
||||
vertexAttrs->readDataDrivenPaintProperties<LineColor,
|
||||
LineBlur,
|
||||
LineOpacity,
|
||||
LineGapWidth,
|
||||
LineOffset,
|
||||
LineWidth,
|
||||
LineFloorWidth>(
|
||||
paintPropertyBinders, evaluated, propertiesAsUniforms);
|
||||
|
||||
auto shader = lineSDFShaderGroup->getOrCreateShader(context, propertiesAsUniforms);
|
||||
auto shader = lineSDFShaderGroup->getOrCreateShader(context, propertiesAsUniforms, posNormalAttribName);
|
||||
if (!shader) {
|
||||
continue;
|
||||
}
|
||||
@@ -644,24 +635,15 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
++stats.drawablesAdded;
|
||||
}
|
||||
} else if (!unevaluated.get<LinePattern>().isUndefined()) {
|
||||
// pattern line
|
||||
if (!linePatternShaderGroup) {
|
||||
continue;
|
||||
linePatternShaderGroup = shaders.getShaderGroup("LinePatternShader");
|
||||
if (!linePatternShaderGroup) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// pattern line
|
||||
paintPropertyBinders.setPatternParameters(patternPosA, patternPosB, crossfade);
|
||||
|
||||
propertiesAsUniforms.clear();
|
||||
auto vertexAttrs = context.createVertexAttributeArray();
|
||||
vertexAttrs->readDataDrivenPaintProperties<LineBlur,
|
||||
LineOpacity,
|
||||
LineOffset,
|
||||
LineGapWidth,
|
||||
LineWidth,
|
||||
LinePattern>(
|
||||
paintPropertyBinders, evaluated, propertiesAsUniforms);
|
||||
|
||||
auto shader = linePatternShaderGroup->getOrCreateShader(context, propertiesAsUniforms);
|
||||
auto shader = linePatternShaderGroup->getOrCreateShader(context, propertiesAsUniforms, posNormalAttribName);
|
||||
if (!shader) {
|
||||
continue;
|
||||
}
|
||||
@@ -704,17 +686,16 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
}
|
||||
}
|
||||
} else if (!unevaluated.get<LineGradient>().getValue().isUndefined()) {
|
||||
// gradient line
|
||||
if (!lineGradientShaderGroup) {
|
||||
continue;
|
||||
lineGradientShaderGroup = shaders.getShaderGroup("LineGradientShader");
|
||||
if (!lineGradientShaderGroup) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// gradient line
|
||||
propertiesAsUniforms.clear();
|
||||
auto vertexAttrs = context.createVertexAttributeArray();
|
||||
vertexAttrs->readDataDrivenPaintProperties<LineBlur, LineOpacity, LineGapWidth, LineOffset, LineWidth>(
|
||||
paintPropertyBinders, evaluated, propertiesAsUniforms);
|
||||
|
||||
auto shader = lineGradientShaderGroup->getOrCreateShader(context, propertiesAsUniforms);
|
||||
auto shader = lineGradientShaderGroup->getOrCreateShader(
|
||||
context, propertiesAsUniforms, posNormalAttribName);
|
||||
if (!shader) {
|
||||
continue;
|
||||
}
|
||||
@@ -753,18 +734,15 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// simple line
|
||||
if (!lineShaderGroup) {
|
||||
continue;
|
||||
lineShaderGroup = shaders.getShaderGroup("LineShader");
|
||||
if (!lineShaderGroup) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// simple line
|
||||
propertiesAsUniforms.clear();
|
||||
auto vertexAttrs = context.createVertexAttributeArray();
|
||||
vertexAttrs
|
||||
->readDataDrivenPaintProperties<LineColor, LineBlur, LineOpacity, LineGapWidth, LineOffset, LineWidth>(
|
||||
paintPropertyBinders, evaluated, propertiesAsUniforms);
|
||||
|
||||
auto shader = lineShaderGroup->getOrCreateShader(context, propertiesAsUniforms);
|
||||
auto shader = lineShaderGroup->getOrCreateShader(context, propertiesAsUniforms, posNormalAttribName);
|
||||
if (!shader) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -246,11 +246,6 @@ void RenderRasterLayer::layerIndexChanged(int32_t newLayerIndex, UniqueChangeReq
|
||||
changeLayerIndex(imageLayerGroup, newLayerIndex, changes);
|
||||
}
|
||||
|
||||
static const StringIdentity idPosAttribName = stringIndexer().get("a_pos");
|
||||
static const StringIdentity idTexturePosAttribName = stringIndexer().get("a_texture_pos");
|
||||
static const StringIdentity idTexImage0Name = stringIndexer().get("u_image0");
|
||||
static const StringIdentity idTexImage1Name = stringIndexer().get("u_image1");
|
||||
|
||||
void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
|
||||
gfx::Context& context,
|
||||
const TransformState& /*state*/,
|
||||
@@ -305,7 +300,6 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
|
||||
builder->setDepthType(gfx::DepthMaskType::ReadOnly);
|
||||
builder->setColorMode(gfx::ColorMode::alphaBlended());
|
||||
builder->setCullFaceMode(gfx::CullFaceMode::disabled());
|
||||
builder->setVertexAttrNameId(idPosAttribName);
|
||||
return builder;
|
||||
};
|
||||
|
||||
@@ -358,7 +352,7 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
|
||||
if (!vertexAttrs) {
|
||||
vertexAttrs = context.createVertexAttributeArray();
|
||||
|
||||
if (auto& attr = vertexAttrs->add(idPosAttribName)) {
|
||||
if (auto& attr = vertexAttrs->set(idRasterPosVertexAttribute)) {
|
||||
attr->setSharedRawData(vertices,
|
||||
offsetof(RasterLayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -366,7 +360,7 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
|
||||
gfx::AttributeDataType::Short2);
|
||||
}
|
||||
|
||||
if (auto& attr = vertexAttrs->add(idTexturePosAttribName)) {
|
||||
if (auto& attr = vertexAttrs->set(idRasterTexturePosVertexAttribute)) {
|
||||
attr->setSharedRawData(vertices,
|
||||
offsetof(RasterLayoutVertex, a2),
|
||||
/*vertexOffset=*/0,
|
||||
|
||||
@@ -760,34 +760,29 @@ SymbolDrawableTilePropsUBO buildTileUBO(const SymbolBucket& bucket,
|
||||
};
|
||||
}
|
||||
|
||||
const auto idDataAttibName = stringIndexer().get("a_data");
|
||||
const auto posOffsetAttribName = "a_pos_offset";
|
||||
const auto idPosOffsetAttribName = stringIndexer().get(posOffsetAttribName);
|
||||
const auto idPixOffsetAttribName = stringIndexer().get("a_pixeloffset");
|
||||
const auto idProjPosAttribName = stringIndexer().get("a_projected_pos");
|
||||
const auto idFadeOpacityAttribName = stringIndexer().get("a_fade_opacity");
|
||||
|
||||
void updateTileAttributes(const SymbolBucket::Buffer& buffer,
|
||||
const bool isText,
|
||||
const SymbolBucket::PaintProperties& paintProps,
|
||||
const SymbolPaintProperties::PossiblyEvaluated& evaluated,
|
||||
gfx::VertexAttributeArray& attribs,
|
||||
mbgl::unordered_set<StringIdentity>* propertiesAsUniforms) {
|
||||
if (const auto& attr = attribs.getOrAdd(idPosOffsetAttribName)) {
|
||||
StringIDSetsPair* propertiesAsUniforms) {
|
||||
if (const auto& attr = attribs.set(idSymbolPosOffsetVertexAttribute)) {
|
||||
attr->setSharedRawData(buffer.sharedVertices,
|
||||
offsetof(SymbolLayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
sizeof(SymbolLayoutVertex),
|
||||
gfx::AttributeDataType::Short4);
|
||||
}
|
||||
if (const auto& attr = attribs.getOrAdd(idDataAttibName)) {
|
||||
if (const auto& attr = attribs.set(idSymbolDataVertexAttribute)) {
|
||||
attr->setSharedRawData(buffer.sharedVertices,
|
||||
offsetof(SymbolLayoutVertex, a2),
|
||||
/*vertexOffset=*/0,
|
||||
sizeof(SymbolLayoutVertex),
|
||||
gfx::AttributeDataType::UShort4);
|
||||
}
|
||||
if (const auto& attr = attribs.getOrAdd(idPixOffsetAttribName)) {
|
||||
if (const auto& attr = attribs.set(idSymbolPixelOffsetVertexAttribute)) {
|
||||
attr->setSharedRawData(buffer.sharedVertices,
|
||||
offsetof(SymbolLayoutVertex, a3),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -795,7 +790,7 @@ void updateTileAttributes(const SymbolBucket::Buffer& buffer,
|
||||
gfx::AttributeDataType::Short4);
|
||||
}
|
||||
|
||||
if (const auto& attr = attribs.getOrAdd(idProjPosAttribName)) {
|
||||
if (const auto& attr = attribs.set(idSymbolProjectedPosVertexAttribute)) {
|
||||
using Vertex = gfx::Vertex<SymbolDynamicLayoutAttributes>;
|
||||
attr->setSharedRawData(buffer.sharedDynamicVertices,
|
||||
offsetof(Vertex, a1),
|
||||
@@ -803,7 +798,7 @@ void updateTileAttributes(const SymbolBucket::Buffer& buffer,
|
||||
sizeof(Vertex),
|
||||
gfx::AttributeDataType::Float3);
|
||||
}
|
||||
if (const auto& attr = attribs.getOrAdd(idFadeOpacityAttribName)) {
|
||||
if (const auto& attr = attribs.set(idSymbolFadeOpacityVertexAttribute)) {
|
||||
using Vertex = gfx::Vertex<SymbolOpacityAttributes>;
|
||||
attr->setSharedRawData(buffer.sharedOpacityVertices,
|
||||
offsetof(Vertex, a1),
|
||||
@@ -814,10 +809,10 @@ void updateTileAttributes(const SymbolBucket::Buffer& buffer,
|
||||
|
||||
if (isText) {
|
||||
attribs.readDataDrivenPaintProperties<TextOpacity, TextColor, TextHaloColor, TextHaloWidth, TextHaloBlur>(
|
||||
paintProps.textBinders, evaluated, propertiesAsUniforms);
|
||||
paintProps.textBinders, evaluated, propertiesAsUniforms, idSymbolOpacityVertexAttribute);
|
||||
} else {
|
||||
attribs.readDataDrivenPaintProperties<IconOpacity, IconColor, IconHaloColor, IconHaloWidth, IconHaloBlur>(
|
||||
paintProps.iconBinders, evaluated, propertiesAsUniforms);
|
||||
paintProps.iconBinders, evaluated, propertiesAsUniforms, idSymbolOpacityVertexAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -874,32 +869,26 @@ void updateTileDrawable(gfx::Drawable& drawable,
|
||||
}
|
||||
}
|
||||
|
||||
const StringIdentity idCollisionPosAttribName = stringIndexer().get("a_pos");
|
||||
const StringIdentity idCollisionAnchorPosAttribName = stringIndexer().get("a_anchor_pos");
|
||||
const StringIdentity idCollisionExtrudeAttribName = stringIndexer().get("a_extrude");
|
||||
const StringIdentity idCollisionPlacedAttribName = stringIndexer().get("a_placed");
|
||||
const StringIdentity idCollisionShiftAttribName = stringIndexer().get("a_shift");
|
||||
|
||||
gfx::VertexAttributeArrayPtr getCollisionVertexAttributes(gfx::Context& context,
|
||||
const SymbolBucket::CollisionBuffer& buffer) {
|
||||
auto vertexAttrs = context.createVertexAttributeArray();
|
||||
using LayoutVertex = gfx::Vertex<CollisionBoxLayoutAttributes>;
|
||||
|
||||
if (const auto& attr = vertexAttrs->add(idCollisionPosAttribName)) {
|
||||
if (const auto& attr = vertexAttrs->set(idCollisionPosVertexAttribute)) {
|
||||
attr->setSharedRawData(buffer.sharedVertices,
|
||||
offsetof(LayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
sizeof(LayoutVertex),
|
||||
gfx::AttributeDataType::Short2);
|
||||
}
|
||||
if (const auto& attr = vertexAttrs->add(idCollisionAnchorPosAttribName)) {
|
||||
if (const auto& attr = vertexAttrs->set(idCollisionAnchorPosVertexAttribute)) {
|
||||
attr->setSharedRawData(buffer.sharedVertices,
|
||||
offsetof(LayoutVertex, a2),
|
||||
/*vertexOffset=*/0,
|
||||
sizeof(LayoutVertex),
|
||||
gfx::AttributeDataType::Short2);
|
||||
}
|
||||
if (const auto& attr = vertexAttrs->add(idCollisionExtrudeAttribName)) {
|
||||
if (const auto& attr = vertexAttrs->set(idCollisionExtrudeVertexAttribute)) {
|
||||
attr->setSharedRawData(buffer.sharedVertices,
|
||||
offsetof(LayoutVertex, a3),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -909,14 +898,14 @@ gfx::VertexAttributeArrayPtr getCollisionVertexAttributes(gfx::Context& context,
|
||||
|
||||
using DynamicVertex = gfx::Vertex<CollisionBoxDynamicAttributes>;
|
||||
|
||||
if (const auto& attr = vertexAttrs->add(idCollisionPlacedAttribName)) {
|
||||
if (const auto& attr = vertexAttrs->set(idCollisionPlacedVertexAttribute)) {
|
||||
attr->setSharedRawData(buffer.sharedDynamicVertices,
|
||||
offsetof(DynamicVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
sizeof(DynamicVertex),
|
||||
gfx::AttributeDataType::UShort2);
|
||||
}
|
||||
if (const auto& attr = vertexAttrs->add(idCollisionShiftAttribName)) {
|
||||
if (const auto& attr = vertexAttrs->set(idCollisionShiftVertexAttribute)) {
|
||||
attr->setSharedRawData(buffer.sharedDynamicVertices,
|
||||
offsetof(DynamicVertex, a2),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -1061,9 +1050,8 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
|
||||
collisionBuilder->setRenderPass(passes);
|
||||
collisionBuilder->setCullFaceMode(gfx::CullFaceMode::disabled());
|
||||
collisionBuilder->setColorMode(gfx::ColorMode::alphaBlended());
|
||||
collisionBuilder->setVertexAttrNameId(idCollisionPosAttribName);
|
||||
|
||||
mbgl::unordered_set<StringIdentity> propertiesAsUniforms;
|
||||
StringIDSetsPair propertiesAsUniforms;
|
||||
for (const RenderTile& tile : *renderTiles) {
|
||||
const auto& tileID = tile.getOverscaledTileID();
|
||||
|
||||
@@ -1106,8 +1094,7 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
|
||||
if (hasCollisionBox) {
|
||||
const auto& collisionBox = isText ? bucket.textCollisionBox : bucket.iconCollisionBox;
|
||||
if (const auto shader = std::static_pointer_cast<gfx::ShaderProgramBase>(
|
||||
collisionBoxGroup->getOrCreateShader(
|
||||
context, {}, stringIndexer().get(idCollisionPosAttribName)))) {
|
||||
collisionBoxGroup->getOrCreateShader(context, {}))) {
|
||||
collisionBuilder->setDrawableName(layerCollisionPrefix + suffix + "box");
|
||||
collisionBuilder->setShader(shader);
|
||||
addVertices(collisionBox->vertices().vector());
|
||||
@@ -1123,8 +1110,7 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
|
||||
if (hasCollisionCircle) {
|
||||
const auto& collisionCircle = isText ? bucket.textCollisionCircle : bucket.iconCollisionCircle;
|
||||
if (const auto shader = std::static_pointer_cast<gfx::ShaderProgramBase>(
|
||||
collisionCircleGroup->getOrCreateShader(
|
||||
context, {}, stringIndexer().get(idCollisionPosAttribName)))) {
|
||||
collisionCircleGroup->getOrCreateShader(context, {}))) {
|
||||
collisionBuilder->setDrawableName(layerCollisionPrefix + suffix + "circle");
|
||||
collisionBuilder->setShader(shader);
|
||||
addVertices(collisionCircle->vertices().vector());
|
||||
@@ -1158,7 +1144,8 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
|
||||
return false;
|
||||
}
|
||||
|
||||
propertiesAsUniforms.clear();
|
||||
propertiesAsUniforms.first.clear();
|
||||
propertiesAsUniforms.second.clear();
|
||||
|
||||
const auto& evaluated = getEvaluated<SymbolLayerProperties>(renderData.layerProperties);
|
||||
updateTileDrawable(
|
||||
@@ -1257,7 +1244,9 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
|
||||
|
||||
const auto vertexCount = buffer.vertices().elements();
|
||||
|
||||
propertiesAsUniforms.clear();
|
||||
propertiesAsUniforms.first.clear();
|
||||
propertiesAsUniforms.second.clear();
|
||||
|
||||
auto attribs = context.createVertexAttributeArray();
|
||||
updateTileAttributes(buffer, isText, bucketPaintProperties, evaluated, *attribs, &propertiesAsUniforms);
|
||||
|
||||
@@ -1321,12 +1310,8 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
|
||||
((mbgl::underlying_type(passes) & mbgl::underlying_type(RenderPass::Translucent)) != 0)
|
||||
? gfx::ColorMode::alphaBlended()
|
||||
: gfx::ColorMode::unblended());
|
||||
builder->setVertexAttrNameId(idPosOffsetAttribName);
|
||||
}
|
||||
|
||||
if (!shaderGroup) {
|
||||
return;
|
||||
}
|
||||
const auto shader = std::static_pointer_cast<gfx::ShaderProgramBase>(
|
||||
shaderGroup->getOrCreateShader(context, propertiesAsUniforms, posOffsetAttribName));
|
||||
if (!shader) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/renderer/layer_tweaker.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
#include <mbgl/gfx/cull_face_mode.hpp>
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/gfx/drawable_builder.hpp>
|
||||
#include <mbgl/gfx/shader_group.hpp>
|
||||
#include <mbgl/renderer/layer_group.hpp>
|
||||
#include <mbgl/renderer/render_static_data.hpp>
|
||||
#include <mbgl/shaders/debug_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/shader_program_base.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
#include <mbgl/tile/geojson_tile_data.hpp>
|
||||
#include <mbgl/gfx/polyline_generator.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
@@ -65,7 +65,6 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
if (!debugShader) {
|
||||
return;
|
||||
}
|
||||
static const StringIdentity idVertexAttribName = stringIndexer().get("a_pos");
|
||||
std::unique_ptr<gfx::DrawableBuilder> debugBuilder = [&]() -> std::unique_ptr<gfx::DrawableBuilder> {
|
||||
auto builder = context.createDrawableBuilder("debug-builder");
|
||||
builder->setShader(debugShader);
|
||||
@@ -73,7 +72,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
builder->setEnableDepth(false);
|
||||
builder->setColorMode(gfx::ColorMode::unblended());
|
||||
builder->setCullFaceMode(gfx::CullFaceMode::disabled());
|
||||
builder->setVertexAttrNameId(idVertexAttribName);
|
||||
builder->setVertexAttrId(idDebugPosVertexAttribute);
|
||||
|
||||
return builder;
|
||||
}();
|
||||
@@ -83,14 +82,14 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
gfx::ShaderPtr polylineShader;
|
||||
const auto createPolylineShader = [&]() -> gfx::ShaderPtr {
|
||||
gfx::ShaderGroupPtr shaderGroup = shaders.getShaderGroup("LineShader");
|
||||
const mbgl::unordered_set<StringIdentity> propertiesAsUniforms{
|
||||
stringIndexer().get("a_color"),
|
||||
stringIndexer().get("a_blur"),
|
||||
stringIndexer().get("a_opacity"),
|
||||
stringIndexer().get("a_gapwidth"),
|
||||
stringIndexer().get("a_offset"),
|
||||
stringIndexer().get("a_width"),
|
||||
};
|
||||
const StringIDSetsPair propertiesAsUniforms{
|
||||
{"a_color", "a_blur", "a_opacity", "a_gapwidth", "a_offset", "a_width"},
|
||||
{idLineColorVertexAttribute,
|
||||
idLineBlurVertexAttribute,
|
||||
idLineOpacityVertexAttribute,
|
||||
idLineGapWidthVertexAttribute,
|
||||
idLineOffsetVertexAttribute,
|
||||
idLineWidthVertexAttribute}};
|
||||
return shaderGroup->getOrCreateShader(context, propertiesAsUniforms);
|
||||
};
|
||||
|
||||
@@ -102,7 +101,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
builder->setEnableDepth(false);
|
||||
builder->setColorMode(gfx::ColorMode::alphaBlended());
|
||||
builder->setCullFaceMode(gfx::CullFaceMode::disabled());
|
||||
builder->setVertexAttrNameId(idVertexAttribName);
|
||||
builder->setVertexAttrId(idLinePosNormalVertexAttribute);
|
||||
|
||||
return builder;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
AttributeInfo::AttributeInfo(std::string_view name_, std::size_t id_)
|
||||
: name(name_),
|
||||
id(id_) {}
|
||||
|
||||
UniformBlockInfo::UniformBlockInfo(std::string_view name_, std::size_t id_)
|
||||
: name(name_),
|
||||
id(id_),
|
||||
@@ -15,6 +19,9 @@ TextureInfo::TextureInfo(std::string_view name_, std::size_t id_)
|
||||
id(id_) {}
|
||||
|
||||
// Background
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::BackgroundShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idBackgroundPosVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::BackgroundShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"BackgroundDrawableUBO", idBackgroundDrawableUBO},
|
||||
UniformBlockInfo{"BackgroundLayerUBO", idBackgroundLayerUBO},
|
||||
@@ -22,6 +29,10 @@ const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::BackgroundShader, gfx::B
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::BackgroundShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Background Pattern
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::OpenGL>::attributes =
|
||||
{
|
||||
AttributeInfo{"a_pos", idBackgroundPosVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"BackgroundDrawableUBO", idBackgroundDrawableUBO},
|
||||
@@ -32,6 +43,16 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::BackgroundPatternShader, gfx:
|
||||
};
|
||||
|
||||
// Circle
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::CircleShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idCirclePosVertexAttribute},
|
||||
AttributeInfo{"a_color", idCircleColorVertexAttribute},
|
||||
AttributeInfo{"a_radius", idCircleRadiusVertexAttribute},
|
||||
AttributeInfo{"a_blur", idCircleBlurVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idCircleOpacityVertexAttribute},
|
||||
AttributeInfo{"a_stroke_color", idCircleStrokeColorVertexAttribute},
|
||||
AttributeInfo{"a_stroke_width", idCircleStrokeWidthVertexAttribute},
|
||||
AttributeInfo{"a_stroke_opacity", idCircleStrokeOpacityVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::CircleShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"CircleDrawableUBO", idCircleDrawableUBO},
|
||||
UniformBlockInfo{"CirclePaintParamsUBO", idCirclePaintParamsUBO},
|
||||
@@ -41,6 +62,13 @@ const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::CircleShader, gfx::Backe
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::CircleShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Collision Box
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::CollisionBoxShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idCollisionPosVertexAttribute},
|
||||
AttributeInfo{"a_anchor_pos", idCollisionAnchorPosVertexAttribute},
|
||||
AttributeInfo{"a_extrude", idCollisionExtrudeVertexAttribute},
|
||||
AttributeInfo{"a_placed", idCollisionPlacedVertexAttribute},
|
||||
AttributeInfo{"a_shift", idCollisionShiftVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::CollisionBoxShader, gfx::Backend::Type::OpenGL>::uniformBlocks =
|
||||
{
|
||||
UniformBlockInfo{"CollisionBoxUBO", idCollisionUBO},
|
||||
@@ -48,22 +76,36 @@ const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::CollisionBoxShader, gfx:
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::CollisionBoxShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Collision Circle
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"CustomSymbolIconDrawableUBO", idCustomSymbolIconDrawableUBO},
|
||||
UniformBlockInfo{"CustomSymbolIconParametersUBO", idCustomSymbolIconParametersUBO},
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::CollisionCircleShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idCollisionPosVertexAttribute},
|
||||
AttributeInfo{"a_anchor_pos", idCollisionAnchorPosVertexAttribute},
|
||||
AttributeInfo{"a_extrude", idCollisionExtrudeVertexAttribute},
|
||||
AttributeInfo{"a_placed", idCollisionPlacedVertexAttribute},
|
||||
};
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::OpenGL>::textures = {
|
||||
TextureInfo{"u_texture", idSymbolImageTexture},
|
||||
};
|
||||
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::CollisionCircleShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"CollisionCircleUBO", idCollisionUBO},
|
||||
};
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::CollisionCircleShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Custom Symbol Icon
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idCustomSymbolPosVertexAttribute},
|
||||
AttributeInfo{"a_tex", idCustomSymbolTexVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"CustomSymbolIconDrawableUBO", idCustomSymbolDrawableUBO},
|
||||
UniformBlockInfo{"CustomSymbolIconParametersUBO", idCustomSymbolParametersUBO},
|
||||
};
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::OpenGL>::textures = {
|
||||
TextureInfo{"u_texture", idCustomSymbolImageTexture},
|
||||
};
|
||||
|
||||
// Debug
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::DebugShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idDebugPosVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::DebugShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"DebugUBO", idDebugUBO},
|
||||
};
|
||||
@@ -72,6 +114,11 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::DebugShader, gfx::Backend::Ty
|
||||
};
|
||||
|
||||
// Fill
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::FillShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idFillPosVertexAttribute},
|
||||
AttributeInfo{"a_color", idFillColorVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idFillOpacityVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::FillShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"FillDrawableUBO", idFillDrawableUBO},
|
||||
UniformBlockInfo{"FillEvaluatedPropsUBO", idFillEvaluatedPropsUBO},
|
||||
@@ -80,6 +127,11 @@ const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::FillShader, gfx::Backend
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Fill Outline
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::FillOutlineShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idFillPosVertexAttribute},
|
||||
AttributeInfo{"a_outline_color", idFillOutlineColorVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idFillOpacityVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::FillOutlineShader, gfx::Backend::Type::OpenGL>::uniformBlocks =
|
||||
{
|
||||
UniformBlockInfo{"FillOutlineDrawableUBO", idFillOutlineDrawableUBO},
|
||||
@@ -89,6 +141,12 @@ const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::FillOutlineShader, gfx::
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillOutlineShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Fill Pattern
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::FillPatternShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idFillPosVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idFillOpacityVertexAttribute},
|
||||
AttributeInfo{"a_pattern_from", idFillPatternFromVertexAttribute},
|
||||
AttributeInfo{"a_pattern_to", idFillPatternToVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::FillPatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks =
|
||||
{
|
||||
UniformBlockInfo{"FillPatternDrawableUBO", idFillPatternDrawableUBO},
|
||||
@@ -101,6 +159,13 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillPatternShader, gfx::Backe
|
||||
};
|
||||
|
||||
// Fill Outline Pattern
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::OpenGL>::attributes =
|
||||
{
|
||||
AttributeInfo{"a_pos", idFillPosVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idFillOpacityVertexAttribute},
|
||||
AttributeInfo{"a_pattern_from", idFillPatternFromVertexAttribute},
|
||||
AttributeInfo{"a_pattern_to", idFillPatternToVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"FillOutlinePatternDrawableUBO", idFillOutlinePatternDrawableUBO},
|
||||
@@ -113,6 +178,13 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillOutlinePatternShader, gfx
|
||||
};
|
||||
|
||||
// Fill Extrusion
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idFillExtrusionPosVertexAttribute},
|
||||
AttributeInfo{"a_normal_ed", idFillExtrusionNormalEdVertexAttribute},
|
||||
AttributeInfo{"a_base", idFillExtrusionBaseVertexAttribute},
|
||||
AttributeInfo{"a_height", idFillExtrusionHeightVertexAttribute},
|
||||
AttributeInfo{"a_color", idFillExtrusionColorVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"FillExtrusionDrawableUBO", idFillExtrusionDrawableUBO},
|
||||
@@ -123,6 +195,15 @@ const std::vector<UniformBlockInfo>
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Fill Extrusion Pattern
|
||||
const std::vector<AttributeInfo>
|
||||
ShaderInfo<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idFillExtrusionPosVertexAttribute},
|
||||
AttributeInfo{"a_normal_ed", idFillExtrusionNormalEdVertexAttribute},
|
||||
AttributeInfo{"a_base", idFillExtrusionBaseVertexAttribute},
|
||||
AttributeInfo{"a_height", idFillExtrusionHeightVertexAttribute},
|
||||
AttributeInfo{"a_pattern_from", idFillExtrusionPatternFromVertexAttribute},
|
||||
AttributeInfo{"a_pattern_to", idFillExtrusionPatternToVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"FillExtrusionDrawableUBO", idFillExtrusionDrawableUBO},
|
||||
@@ -135,6 +216,11 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillExtrusionPatternShader, g
|
||||
};
|
||||
|
||||
// Heatmap
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::HeatmapShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idHeatmapPosVertexAttribute},
|
||||
AttributeInfo{"a_weight", idHeatmapWeightVertexAttribute},
|
||||
AttributeInfo{"a_radius", idHeatmapRadiusVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::HeatmapShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"HeatmapDrawableUBO", idHeatmapDrawableUBO},
|
||||
UniformBlockInfo{"HeatmapEvaluatedPropsUBO", idHeatmapEvaluatedPropsUBO},
|
||||
@@ -143,6 +229,9 @@ const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::HeatmapShader, gfx::Back
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::HeatmapShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Heatmap Texture
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idHeatmapPosVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"HeatmapTextureDrawableUBO", idHeatmapTextureDrawableUBO},
|
||||
@@ -153,6 +242,10 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::HeatmapTextureShader, gfx::Ba
|
||||
};
|
||||
|
||||
// Hillshade Prepare
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idHillshadePosVertexAttribute},
|
||||
AttributeInfo{"a_texture_pos", idHillshadeTexturePosVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"HillshadePrepareDrawableUBO", idHillshadePrepareDrawableUBO},
|
||||
@@ -162,6 +255,10 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::HillshadePrepareShader, gfx::
|
||||
};
|
||||
|
||||
// Hillshade
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::HillshadeShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idHillshadePosVertexAttribute},
|
||||
AttributeInfo{"a_texture_pos", idHillshadeTexturePosVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::HillshadeShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"HillshadeDrawableUBO", idHillshadeDrawableUBO},
|
||||
UniformBlockInfo{"HillshadeEvaluatedPropsUBO", idHillshadeEvaluatedPropsUBO},
|
||||
@@ -170,7 +267,35 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::HillshadeShader, gfx::Backend
|
||||
TextureInfo{"u_image", idHillshadeImageTexture},
|
||||
};
|
||||
|
||||
// Line
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::LineShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos_normal", idLinePosNormalVertexAttribute},
|
||||
AttributeInfo{"a_data", idLineDataVertexAttribute},
|
||||
AttributeInfo{"a_color", idLineColorVertexAttribute},
|
||||
AttributeInfo{"a_blur", idLineBlurVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idLineOpacityVertexAttribute},
|
||||
AttributeInfo{"a_gapwidth", idLineGapWidthVertexAttribute},
|
||||
AttributeInfo{"a_offset", idLineOffsetVertexAttribute},
|
||||
AttributeInfo{"a_width", idLineWidthVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LineShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"LineDynamicUBO", idLineDynamicUBO},
|
||||
UniformBlockInfo{"LineUBO", idLineUBO},
|
||||
UniformBlockInfo{"LinePropertiesUBO", idLinePropertiesUBO},
|
||||
UniformBlockInfo{"LineInterpolationUBO", idLineInterpolationUBO},
|
||||
};
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::LineShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Line Gradient
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::LineGradientShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos_normal", idLinePosNormalVertexAttribute},
|
||||
AttributeInfo{"a_data", idLineDataVertexAttribute},
|
||||
AttributeInfo{"a_blur", idLineBlurVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idLineOpacityVertexAttribute},
|
||||
AttributeInfo{"a_gapwidth", idLineGapWidthVertexAttribute},
|
||||
AttributeInfo{"a_offset", idLineOffsetVertexAttribute},
|
||||
AttributeInfo{"a_width", idLineWidthVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LineGradientShader, gfx::Backend::Type::OpenGL>::uniformBlocks =
|
||||
{
|
||||
UniformBlockInfo{"LineDynamicUBO", idLineDynamicUBO},
|
||||
@@ -183,6 +308,17 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::LineGradientShader, gfx::Back
|
||||
};
|
||||
|
||||
// Line Pattern
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::LinePatternShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos_normal", idLinePosNormalVertexAttribute},
|
||||
AttributeInfo{"a_data", idLineDataVertexAttribute},
|
||||
AttributeInfo{"a_blur", idLineBlurVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idLineOpacityVertexAttribute},
|
||||
AttributeInfo{"a_offset", idLineOffsetVertexAttribute},
|
||||
AttributeInfo{"a_gapwidth", idLineGapWidthVertexAttribute},
|
||||
AttributeInfo{"a_width", idLineWidthVertexAttribute},
|
||||
AttributeInfo{"a_pattern_from", idLinePatternFromVertexAttribute},
|
||||
AttributeInfo{"a_pattern_to", idLinePatternToVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LinePatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks =
|
||||
{
|
||||
UniformBlockInfo{"LineDynamicUBO", idLineDynamicUBO},
|
||||
@@ -196,6 +332,17 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::LinePatternShader, gfx::Backe
|
||||
};
|
||||
|
||||
// Line SDF
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::LineSDFShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos_normal", idLinePosNormalVertexAttribute},
|
||||
AttributeInfo{"a_data", idLineDataVertexAttribute},
|
||||
AttributeInfo{"a_color", idLineColorVertexAttribute},
|
||||
AttributeInfo{"a_blur", idLineBlurVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idLineOpacityVertexAttribute},
|
||||
AttributeInfo{"a_gapwidth", idLineGapWidthVertexAttribute},
|
||||
AttributeInfo{"a_offset", idLineOffsetVertexAttribute},
|
||||
AttributeInfo{"a_width", idLineWidthVertexAttribute},
|
||||
AttributeInfo{"a_floorwidth", idLineFloorWidthVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LineSDFShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"LineDynamicUBO", idLineDynamicUBO},
|
||||
UniformBlockInfo{"LineSDFUBO", idLineSDFUBO},
|
||||
@@ -206,16 +353,11 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::LineSDFShader, gfx::Backend::
|
||||
TextureInfo{"u_image", idLineImageTexture},
|
||||
};
|
||||
|
||||
// Line
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LineShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"LineDynamicUBO", idLineDynamicUBO},
|
||||
UniformBlockInfo{"LineUBO", idLineUBO},
|
||||
UniformBlockInfo{"LinePropertiesUBO", idLinePropertiesUBO},
|
||||
UniformBlockInfo{"LineInterpolationUBO", idLineInterpolationUBO},
|
||||
};
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::LineShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Line Basic
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::LineBasicShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos_normal", idLinePosNormalVertexAttribute},
|
||||
AttributeInfo{"a_data", idLineDataVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LineBasicShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"LineBasicUBO", idLineBasicUBO},
|
||||
UniformBlockInfo{"LineBasicPropertiesUBO", idLineBasicPropertiesUBO},
|
||||
@@ -223,6 +365,10 @@ const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LineBasicShader, gfx::Ba
|
||||
const std::vector<TextureInfo> ShaderInfo<BuiltIn::LineBasicShader, gfx::Backend::Type::OpenGL>::textures = {};
|
||||
|
||||
// Raster
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idRasterPosVertexAttribute},
|
||||
AttributeInfo{"a_texture_pos", idRasterTexturePosVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"RasterDrawableUBO", idRasterDrawableUBO},
|
||||
};
|
||||
@@ -232,6 +378,14 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::RasterShader, gfx::Backend::T
|
||||
};
|
||||
|
||||
// Symbol Icon
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::SymbolIconShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos_offset", idSymbolPosOffsetVertexAttribute},
|
||||
AttributeInfo{"a_data", idSymbolDataVertexAttribute},
|
||||
AttributeInfo{"a_pixeloffset", idSymbolPixelOffsetVertexAttribute},
|
||||
AttributeInfo{"a_projected_pos", idSymbolProjectedPosVertexAttribute},
|
||||
AttributeInfo{"a_fade_opacity", idSymbolFadeOpacityVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idSymbolOpacityVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::SymbolIconShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"SymbolDrawableUBO", idSymbolDrawableUBO},
|
||||
UniformBlockInfo{"SymbolDynamicUBO", idSymbolDynamicUBO},
|
||||
@@ -244,6 +398,18 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::SymbolIconShader, gfx::Backen
|
||||
};
|
||||
|
||||
// Symbol SDF
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos_offset", idSymbolPosOffsetVertexAttribute},
|
||||
AttributeInfo{"a_data", idSymbolDataVertexAttribute},
|
||||
AttributeInfo{"a_pixeloffset", idSymbolPixelOffsetVertexAttribute},
|
||||
AttributeInfo{"a_projected_pos", idSymbolProjectedPosVertexAttribute},
|
||||
AttributeInfo{"a_fade_opacity", idSymbolFadeOpacityVertexAttribute},
|
||||
AttributeInfo{"a_fill_color", idSymbolColorVertexAttribute},
|
||||
AttributeInfo{"a_halo_color", idSymbolHaloColorVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idSymbolOpacityVertexAttribute},
|
||||
AttributeInfo{"a_halo_width", idSymbolHaloWidthVertexAttribute},
|
||||
AttributeInfo{"a_halo_blur", idSymbolHaloBlurVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"SymbolDrawableUBO", idSymbolDrawableUBO},
|
||||
@@ -257,6 +423,18 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::SymbolSDFIconShader, gfx::Bac
|
||||
};
|
||||
|
||||
// Symbol Text & Icon
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::OpenGL>::attributes =
|
||||
{
|
||||
AttributeInfo{"a_pos_offset", idSymbolPosOffsetVertexAttribute},
|
||||
AttributeInfo{"a_data", idSymbolDataVertexAttribute},
|
||||
AttributeInfo{"a_projected_pos", idSymbolProjectedPosVertexAttribute},
|
||||
AttributeInfo{"a_fade_opacity", idSymbolFadeOpacityVertexAttribute},
|
||||
AttributeInfo{"a_fill_color", idSymbolColorVertexAttribute},
|
||||
AttributeInfo{"a_halo_color", idSymbolHaloColorVertexAttribute},
|
||||
AttributeInfo{"a_opacity", idSymbolOpacityVertexAttribute},
|
||||
AttributeInfo{"a_halo_width", idSymbolHaloWidthVertexAttribute},
|
||||
AttributeInfo{"a_halo_blur", idSymbolHaloBlurVertexAttribute},
|
||||
};
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"SymbolDrawableUBO", idSymbolDrawableUBO},
|
||||
|
||||
@@ -71,11 +71,10 @@ gfx::AttributeDataType mapType(platform::GLenum attrType) {
|
||||
|
||||
using namespace platform;
|
||||
|
||||
void addAttr(
|
||||
VertexAttributeArrayGL& attrs, const StringIdentity id, GLint index, GLsizei length, GLint count, GLenum glType) {
|
||||
void addAttr(VertexAttributeArrayGL& attrs, const size_t id, GLint index, GLsizei length, GLint count, GLenum glType) {
|
||||
const auto elementType = mapType(glType);
|
||||
if (elementType != gfx::AttributeDataType::Invalid && length > 0) {
|
||||
if (const auto& newAttr = attrs.add(id, index, elementType, count)) {
|
||||
if (const auto& newAttr = attrs.set(id, index, elementType, count)) {
|
||||
const auto& glAttr = static_cast<VertexAttributeGL*>(newAttr.get());
|
||||
glAttr->setGLType(glType);
|
||||
}
|
||||
@@ -115,6 +114,7 @@ std::shared_ptr<ShaderProgramGL> ShaderProgramGL::create(
|
||||
const std::string_view firstAttribName,
|
||||
const std::vector<shaders::UniformBlockInfo>& uniformBlocksInfo,
|
||||
const std::vector<shaders::TextureInfo>& texturesInfo,
|
||||
const std::vector<shaders::AttributeInfo>& attributesInfo,
|
||||
const std::string& vertexSource,
|
||||
const std::string& fragmentSource,
|
||||
const std::string& additionalDefines) noexcept(false) {
|
||||
@@ -171,7 +171,8 @@ std::shared_ptr<ShaderProgramGL> ShaderProgramGL::create(
|
||||
continue;
|
||||
}
|
||||
const GLint location = MBGL_CHECK_ERROR(glGetAttribLocation(program, name.data()));
|
||||
addAttr(attrs, stringIndexer().get(name.data()), location, length, size, glType);
|
||||
assert(attributesInfo[location].name == std::string_view(name.data()));
|
||||
addAttr(attrs, attributesInfo[location].id, location, length, size, glType);
|
||||
}
|
||||
|
||||
return std::make_shared<ShaderProgramGL>(
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 1> ShaderSource<BuiltIn::BackgroundShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Float3, "a_pos"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Float3, idBackgroundPosVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 2> ShaderSource<BuiltIn::BackgroundShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{1, true, false, sizeof(BackgroundDrawableUBO), idBackgroundDrawableUBO},
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 1>
|
||||
ShaderSource<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Float3, "a_pos"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Float3, idBackgroundPosVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 2>
|
||||
ShaderSource<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
|
||||
@@ -4,14 +4,14 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 8> ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Float4, "a_color"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, "a_radius"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, "a_blur"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, "a_opacity"},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float4, "a_stroke_color"},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, "a_stroke_width"},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float2, "a_stroke_opacity"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idCirclePosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Float4, idCircleColorVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, idCircleRadiusVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, idCircleBlurVertexAttribute},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, idCircleOpacityVertexAttribute},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float4, idCircleStrokeColorVertexAttribute},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, idCircleStrokeWidthVertexAttribute},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float2, idCircleStrokeOpacityVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{8, true, false, sizeof(CircleDrawableUBO), idCircleDrawableUBO},
|
||||
|
||||
@@ -6,10 +6,10 @@ namespace shaders {
|
||||
using ShaderType = ShaderSource<BuiltIn::ClippingMaskProgram, gfx::Backend::Type::Metal>;
|
||||
|
||||
const std::array<AttributeInfo, 1> ShaderType::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Float3, "a_pos"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Float3, idClippingMaskPosVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 1> ShaderType::uniforms = {
|
||||
UniformBlockInfo{1, true, false, sizeof(ClipUBO), 0},
|
||||
UniformBlockInfo{1, true, false, sizeof(ClipUBO), idClippingMaskUBO},
|
||||
};
|
||||
const std::array<TextureInfo, 0> ShaderType::textures = {};
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 5> ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short2, "a_anchor_pos"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Short2, "a_extrude"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::UShort2, "a_placed"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, "a_shift"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idCollisionPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short2, idCollisionAnchorPosVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Short2, idCollisionExtrudeVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::UShort2, idCollisionPlacedVertexAttribute},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, idCollisionShiftVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 1> ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{5, true, true, sizeof(CollisionUBO), idCollisionUBO},
|
||||
|
||||
@@ -5,10 +5,10 @@ namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 4> ShaderSource<BuiltIn::CollisionCircleShader, gfx::Backend::Type::Metal>::attributes =
|
||||
{
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short2, "a_anchor_pos"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Short2, "a_extrude"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::UShort2, "a_placed"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idCollisionPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short2, idCollisionAnchorPosVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Short2, idCollisionExtrudeVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::UShort2, idCollisionPlacedVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 1>
|
||||
ShaderSource<BuiltIn::CollisionCircleShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
|
||||
@@ -6,16 +6,16 @@ namespace shaders {
|
||||
const std::array<AttributeInfo, 2>
|
||||
ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
// always attributes
|
||||
AttributeInfo{0, gfx::AttributeDataType::Float2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Float2, "a_tex"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Float2, idCustomSymbolPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Float2, idCustomSymbolTexVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 2>
|
||||
ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{2, true, false, sizeof(CustomSymbolIconDrawableUBO), idCustomSymbolIconDrawableUBO},
|
||||
UniformBlockInfo{3, true, false, sizeof(CustomSymbolIconParametersUBO), idCustomSymbolIconParametersUBO},
|
||||
UniformBlockInfo{2, true, false, sizeof(CustomSymbolIconDrawableUBO), idCustomSymbolDrawableUBO},
|
||||
UniformBlockInfo{3, true, false, sizeof(CustomSymbolIconParametersUBO), idCustomSymbolParametersUBO},
|
||||
};
|
||||
const std::array<TextureInfo, 1> ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Metal>::textures = {
|
||||
TextureInfo{0, idCustomSymbolIconTexture},
|
||||
TextureInfo{0, idCustomSymbolImageTexture},
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 1> ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idDebugPosVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 1> ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{1, true, true, sizeof(DebugUBO), idDebugUBO},
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 3> ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Float4, "a_color"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, "a_opacity"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idFillPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Float4, idFillColorVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, idFillOpacityVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{3, true, false, sizeof(FillDrawableUBO), idFillDrawableUBO},
|
||||
@@ -16,9 +16,9 @@ const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::FillShader, gfx::Bac
|
||||
const std::array<TextureInfo, 0> ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::Metal>::textures = {};
|
||||
|
||||
const std::array<AttributeInfo, 3> ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Float4, "a_outline_color"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, "a_opacity"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idFillPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Float4, idFillOutlineColorVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, idFillOpacityVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{3, true, false, sizeof(FillOutlineDrawableUBO), idFillOutlineDrawableUBO},
|
||||
@@ -28,10 +28,10 @@ const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::FillOutlineShader, g
|
||||
const std::array<TextureInfo, 0> ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::Metal>::textures = {};
|
||||
|
||||
const std::array<AttributeInfo, 4> ShaderSource<BuiltIn::FillPatternShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UShort4, "a_pattern_from"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::UShort4, "a_pattern_to"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, "a_opacity"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idFillPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UShort4, idFillPatternFromVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::UShort4, idFillPatternToVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, idFillOpacityVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::FillPatternShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{4, true, true, sizeof(FillPatternDrawableUBO), idFillPatternDrawableUBO},
|
||||
@@ -45,10 +45,10 @@ const std::array<TextureInfo, 1> ShaderSource<BuiltIn::FillPatternShader, gfx::B
|
||||
|
||||
const std::array<AttributeInfo, 4>
|
||||
ShaderSource<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UShort4, "a_pattern_from"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::UShort4, "a_pattern_to"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, "a_opacity"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idFillPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UShort4, idFillPatternFromVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::UShort4, idFillPatternToVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, idFillOpacityVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::FillOutlinePatternShader,
|
||||
gfx::Backend::Type::Metal>::uniforms = {
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 5> ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short4, "a_normal_ed"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float4, "a_color"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float, "a_base"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float, "a_height"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idFillExtrusionPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short4, idFillExtrusionNormalEdVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float4, idFillExtrusionColorVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float, idFillExtrusionBaseVertexAttribute},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float, idFillExtrusionHeightVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Metal>::uniforms =
|
||||
{
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 6>
|
||||
ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short4, "a_normal_ed"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float, "a_base"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float, "a_height"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::UShort4, "a_pattern_from"},
|
||||
AttributeInfo{5, gfx::AttributeDataType::UShort4, "a_pattern_to"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idFillExtrusionPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short4, idFillExtrusionNormalEdVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float, idFillExtrusionBaseVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float, idFillExtrusionHeightVertexAttribute},
|
||||
AttributeInfo{4, gfx::AttributeDataType::UShort4, idFillExtrusionPatternFromVertexAttribute},
|
||||
AttributeInfo{5, gfx::AttributeDataType::UShort4, idFillExtrusionPatternToVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 4>
|
||||
ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 3> ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Float2, "a_weight"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, "a_radius"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idHeatmapPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Float2, idHeatmapWeightVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, idHeatmapRadiusVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{3, true, false, sizeof(HeatmapDrawableUBO), idHeatmapDrawableUBO},
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 1> ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Metal>::attributes =
|
||||
{
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idHeatmapPosVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 1> ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Metal>::uniforms =
|
||||
{
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 2> ShaderSource<BuiltIn::HillshadeShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short2, "a_texture_pos"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idHillshadePosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short2, idHillshadeTexturePosVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 2> ShaderSource<BuiltIn::HillshadeShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{2, true, true, sizeof(HillshadeDrawableUBO), idHillshadeDrawableUBO},
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 2>
|
||||
ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short2, "a_texture_pos"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idHillshadePosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short2, idHillshadeTexturePosVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 1>
|
||||
ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
|
||||
@@ -4,14 +4,14 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 8> ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos_normal"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, "a_data"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float4, "a_color"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, "a_blur"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, "a_opacity"},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float2, "a_gapwidth"},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, "a_offset"},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float2, "a_width"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idLinePosNormalVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, idLineDataVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float4, idLineColorVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, idLineBlurVertexAttribute},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, idLineOpacityVertexAttribute},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float2, idLineGapWidthVertexAttribute},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, idLineOffsetVertexAttribute},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float2, idLineWidthVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{8, true, false, sizeof(LineDynamicUBO), idLineDynamicUBO},
|
||||
@@ -22,15 +22,15 @@ const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LineShader, gfx::Bac
|
||||
const std::array<TextureInfo, 0> ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal>::textures = {};
|
||||
|
||||
const std::array<AttributeInfo, 9> ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos_normal"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, "a_data"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, "a_blur"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, "a_opacity"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, "a_gapwidth"},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float2, "a_offset"},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, "a_width"},
|
||||
AttributeInfo{7, gfx::AttributeDataType::UShort4, "a_pattern_from"},
|
||||
AttributeInfo{8, gfx::AttributeDataType::UShort4, "a_pattern_to"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idLinePosNormalVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, idLineDataVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, idLineBlurVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, idLineOpacityVertexAttribute},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, idLineGapWidthVertexAttribute},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float2, idLineOffsetVertexAttribute},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, idLineWidthVertexAttribute},
|
||||
AttributeInfo{7, gfx::AttributeDataType::UShort4, idLinePatternFromVertexAttribute},
|
||||
AttributeInfo{8, gfx::AttributeDataType::UShort4, idLinePatternToVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 5> ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{9, true, false, sizeof(LineDynamicUBO), idLinePatternDynamicUBO},
|
||||
@@ -44,15 +44,15 @@ const std::array<TextureInfo, 1> ShaderSource<BuiltIn::LinePatternShader, gfx::B
|
||||
};
|
||||
|
||||
const std::array<AttributeInfo, 9> ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos_normal"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, "a_data"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float4, "a_color"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, "a_blur"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, "a_opacity"},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float2, "a_gapwidth"},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, "a_offset"},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float2, "a_width"},
|
||||
AttributeInfo{8, gfx::AttributeDataType::Float2, "a_floorwidth"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idLinePosNormalVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, idLineDataVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float4, idLineColorVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, idLineBlurVertexAttribute},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, idLineOpacityVertexAttribute},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float2, idLineGapWidthVertexAttribute},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, idLineOffsetVertexAttribute},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float2, idLineWidthVertexAttribute},
|
||||
AttributeInfo{8, gfx::AttributeDataType::Float2, idLineFloorWidthVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{9, true, false, sizeof(LineDynamicUBO), idLineSDFDynamicUBO},
|
||||
@@ -65,8 +65,8 @@ const std::array<TextureInfo, 1> ShaderSource<BuiltIn::LineSDFShader, gfx::Backe
|
||||
};
|
||||
|
||||
const std::array<AttributeInfo, 2> ShaderSource<BuiltIn::LineBasicShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos_normal"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, "a_data"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idLinePosNormalVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, idLineDataVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 2> ShaderSource<BuiltIn::LineBasicShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{2, true, true, sizeof(LineBasicUBO), idLineBasicUBO},
|
||||
|
||||
@@ -4,13 +4,13 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 7> ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos_normal"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, "a_data"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, "a_blur"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, "a_opacity"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, "a_gapwidth"},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float2, "a_offset"},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, "a_width"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idLinePosNormalVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UByte4, idLineDataVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float2, idLineBlurVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float2, idLineOpacityVertexAttribute},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float2, idLineGapWidthVertexAttribute},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float2, idLineOffsetVertexAttribute},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float2, idLineWidthVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{7, true, false, sizeof(LineDynamicUBO), idLineGradientDynamicUBO},
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 2> ShaderSource<BuiltIn::RasterShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, "a_pos"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short2, "a_texture_pos"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idRasterPosVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::Short2, idRasterTexturePosVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 1> ShaderSource<BuiltIn::RasterShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{2, true, true, sizeof(RasterDrawableUBO), idRasterDrawableUBO},
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
#include <mbgl/shaders/shader_manifest.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
|
||||
#include <Metal/MTLLibrary.hpp>
|
||||
#include <Metal/MTLRenderPass.hpp>
|
||||
@@ -24,11 +23,10 @@ using namespace std::string_literals;
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
shaders::AttributeInfo::AttributeInfo(std::size_t index_, gfx::AttributeDataType dataType_, std::string_view name_)
|
||||
shaders::AttributeInfo::AttributeInfo(std::size_t index_, gfx::AttributeDataType dataType_, std::size_t id_)
|
||||
: index(index_),
|
||||
dataType(dataType_),
|
||||
name(name_),
|
||||
nameID(stringIndexer().get(name_)) {}
|
||||
id(id_) {}
|
||||
|
||||
shaders::UniformBlockInfo::UniformBlockInfo(
|
||||
std::size_t index_, bool vertex_, bool fragment_, std::size_t size_, std::size_t id_)
|
||||
@@ -195,19 +193,17 @@ void ShaderProgram::initAttribute(const shaders::AttributeInfo& info) {
|
||||
const auto index = static_cast<int>(info.index);
|
||||
#if !defined(NDEBUG)
|
||||
// Indexes must be unique, if there's a conflict check the `attributes` array in the shader
|
||||
vertexAttributes.visitAttributes(
|
||||
[&](auto, const gfx::VertexAttribute& attrib) { assert(attrib.getIndex() != index); });
|
||||
vertexAttributes.visitAttributes([&](const gfx::VertexAttribute& attrib) { assert(attrib.getIndex() != index); });
|
||||
uniformBlocks.visit([&](const gfx::UniformBlock& block) { assert(block.getIndex() != index); });
|
||||
#endif
|
||||
vertexAttributes.add(stringIndexer().get(info.name), index, info.dataType, 1);
|
||||
vertexAttributes.set(info.id, index, info.dataType, 1);
|
||||
}
|
||||
|
||||
void ShaderProgram::initUniformBlock(const shaders::UniformBlockInfo& info) {
|
||||
const auto index = static_cast<int>(info.index);
|
||||
#if !defined(NDEBUG)
|
||||
// Indexes must be unique, if there's a conflict check the `attributes` array in the shader
|
||||
vertexAttributes.visitAttributes(
|
||||
[&](auto, const gfx::VertexAttribute& attrib) { assert(attrib.getIndex() != index); });
|
||||
vertexAttributes.visitAttributes([&](const gfx::VertexAttribute& attrib) { assert(attrib.getIndex() != index); });
|
||||
uniformBlocks.visit([&](const gfx::UniformBlock& block) { assert(block.getIndex() != index); });
|
||||
#endif
|
||||
if (const auto& block_ = uniformBlocks.set(info.id, index, info.size)) {
|
||||
|
||||
@@ -5,14 +5,14 @@ namespace shaders {
|
||||
|
||||
const std::array<AttributeInfo, 6> ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
// always attributes
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short4, "a_pos_offset"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UShort4, "a_data"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Short4, "a_pixeloffset"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float3, "a_projected_pos"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float, "a_fade_opacity"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short4, idSymbolPosOffsetVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UShort4, idSymbolDataVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Short4, idSymbolPixelOffsetVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float3, idSymbolProjectedPosVertexAttribute},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float, idSymbolFadeOpacityVertexAttribute},
|
||||
|
||||
// sometimes uniforms
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float, "a_opacity"},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float, idSymbolOpacityVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 5> ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{6, true, true, sizeof(SymbolDrawableUBO), idSymbolDrawableUBO},
|
||||
|
||||
@@ -6,18 +6,18 @@ namespace shaders {
|
||||
const std::array<AttributeInfo, 10> ShaderSource<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::Metal>::attributes =
|
||||
{
|
||||
// always attributes
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short4, "a_pos_offset"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UShort4, "a_data"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Short4, "a_pixeloffset"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float3, "a_projected_pos"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float, "a_fade_opacity"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short4, idSymbolPosOffsetVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UShort4, idSymbolDataVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Short4, idSymbolPixelOffsetVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float3, idSymbolProjectedPosVertexAttribute},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float, idSymbolFadeOpacityVertexAttribute},
|
||||
|
||||
// sometimes uniforms
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float4, "a_fill_color"},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float4, "a_halo_color"},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float, "a_opacity"},
|
||||
AttributeInfo{8, gfx::AttributeDataType::Float, "a_halo_width"},
|
||||
AttributeInfo{9, gfx::AttributeDataType::Float, "a_halo_blur"},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float4, idSymbolColorVertexAttribute},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float4, idSymbolHaloColorVertexAttribute},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float, idSymbolOpacityVertexAttribute},
|
||||
AttributeInfo{8, gfx::AttributeDataType::Float, idSymbolHaloWidthVertexAttribute},
|
||||
AttributeInfo{9, gfx::AttributeDataType::Float, idSymbolHaloBlurVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 5> ShaderSource<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::Metal>::uniforms =
|
||||
{
|
||||
|
||||
@@ -6,17 +6,17 @@ namespace shaders {
|
||||
const std::array<AttributeInfo, 9>
|
||||
ShaderSource<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
// always attributes
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short4, "a_pos_offset"},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UShort4, "a_data"},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float3, "a_projected_pos"},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float, "a_fade_opacity"},
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short4, idSymbolPosOffsetVertexAttribute},
|
||||
AttributeInfo{1, gfx::AttributeDataType::UShort4, idSymbolDataVertexAttribute},
|
||||
AttributeInfo{2, gfx::AttributeDataType::Float3, idSymbolProjectedPosVertexAttribute},
|
||||
AttributeInfo{3, gfx::AttributeDataType::Float, idSymbolFadeOpacityVertexAttribute},
|
||||
|
||||
// sometimes uniforms
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float4, "a_fill_color"},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float4, "a_halo_color"},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float, "a_opacity"},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float, "a_halo_width"},
|
||||
AttributeInfo{8, gfx::AttributeDataType::Float, "a_halo_blur"},
|
||||
AttributeInfo{4, gfx::AttributeDataType::Float4, idSymbolColorVertexAttribute},
|
||||
AttributeInfo{5, gfx::AttributeDataType::Float4, idSymbolHaloColorVertexAttribute},
|
||||
AttributeInfo{6, gfx::AttributeDataType::Float, idSymbolOpacityVertexAttribute},
|
||||
AttributeInfo{7, gfx::AttributeDataType::Float, idSymbolHaloWidthVertexAttribute},
|
||||
AttributeInfo{8, gfx::AttributeDataType::Float, idSymbolHaloBlurVertexAttribute},
|
||||
};
|
||||
const std::array<UniformBlockInfo, 5>
|
||||
ShaderSource<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/gfx/drawable_tweaker.hpp>
|
||||
#include <mbgl/shaders/line_layer_ubo.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
@@ -223,8 +222,8 @@ public:
|
||||
|
||||
// set UBOs
|
||||
auto& uniforms = drawable.mutableUniformBuffers();
|
||||
uniforms.createOrUpdate(idCustomSymbolIconDrawableUBO, &drawableUBO, parameters.context);
|
||||
uniforms.createOrUpdate(idCustomSymbolIconParametersUBO, ¶metersUBO, parameters.context);
|
||||
uniforms.createOrUpdate(idCustomSymbolDrawableUBO, &drawableUBO, parameters.context);
|
||||
uniforms.createOrUpdate(idCustomSymbolParametersUBO, ¶metersUBO, parameters.context);
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -317,11 +316,8 @@ void CustomDrawableLayerHost::Interface::addFill(const GeometryCollection& geome
|
||||
gfx::generateFillBuffers(geometry, vertices, triangles, triangleSegments);
|
||||
|
||||
// add to builder
|
||||
static const StringIdentity idVertexAttribName = stringIndexer().get("a_pos");
|
||||
builder->setVertexAttrNameId(idVertexAttribName);
|
||||
|
||||
auto attrs = context.createVertexAttributeArray();
|
||||
if (const auto& attr = attrs->add(idVertexAttribName)) {
|
||||
if (const auto& attr = attrs->set(idFillPosVertexAttribute)) {
|
||||
attr->setSharedRawData(sharedVertices,
|
||||
offsetof(FillLayoutVertex, a1),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -377,19 +373,15 @@ void CustomDrawableLayerHost::Interface::addSymbol(const GeometryCoordinate& poi
|
||||
triangleSegments.emplace_back(Segment<CustomSymbolIcon>{0, 0, 4, 6});
|
||||
|
||||
// add to builder
|
||||
static const StringIdentity idPositionAttribName = stringIndexer().get("a_pos");
|
||||
static const StringIdentity idTextureAttribName = stringIndexer().get("a_tex");
|
||||
builder->setVertexAttrNameId(idPositionAttribName);
|
||||
|
||||
auto attrs = context.createVertexAttributeArray();
|
||||
if (const auto& attr = attrs->add(idPositionAttribName)) {
|
||||
if (const auto& attr = attrs->set(idCustomSymbolPosVertexAttribute)) {
|
||||
attr->setSharedRawData(sharedVertices,
|
||||
offsetof(CustomSymbolIcon, a_pos),
|
||||
/*vertexOffset=*/0,
|
||||
sizeof(CustomSymbolIcon),
|
||||
gfx::AttributeDataType::Float2);
|
||||
}
|
||||
if (const auto& attr = attrs->add(idTextureAttribName)) {
|
||||
if (const auto& attr = attrs->set(idCustomSymbolTexVertexAttribute)) {
|
||||
attr->setSharedRawData(sharedVertices,
|
||||
offsetof(CustomSymbolIcon, a_tex),
|
||||
/*vertexOffset=*/0,
|
||||
@@ -402,7 +394,7 @@ void CustomDrawableLayerHost::Interface::addSymbol(const GeometryCoordinate& poi
|
||||
|
||||
// texture
|
||||
if (symbolOptions.texture) {
|
||||
builder->setTexture(symbolOptions.texture, idCustomSymbolIconTexture);
|
||||
builder->setTexture(symbolOptions.texture, idCustomSymbolImageTexture);
|
||||
}
|
||||
|
||||
// create fill tweaker
|
||||
@@ -467,14 +459,13 @@ void CustomDrawableLayerHost::Interface::finish() {
|
||||
gfx::ShaderPtr CustomDrawableLayerHost::Interface::lineShaderDefault() const {
|
||||
gfx::ShaderGroupPtr shaderGroup = shaders.getShaderGroup("LineShader");
|
||||
|
||||
const mbgl::unordered_set<StringIdentity> propertiesAsUniforms{
|
||||
stringIndexer().get("a_color"),
|
||||
stringIndexer().get("a_blur"),
|
||||
stringIndexer().get("a_opacity"),
|
||||
stringIndexer().get("a_gapwidth"),
|
||||
stringIndexer().get("a_offset"),
|
||||
stringIndexer().get("a_width"),
|
||||
};
|
||||
const StringIDSetsPair propertiesAsUniforms{{"a_color", "a_blur", "a_opacity", "a_gapwidth", "a_offset", "a_width"},
|
||||
{idLineColorVertexAttribute,
|
||||
idLineBlurVertexAttribute,
|
||||
idLineOpacityVertexAttribute,
|
||||
idLineGapWidthVertexAttribute,
|
||||
idLineOffsetVertexAttribute,
|
||||
idLineWidthVertexAttribute}};
|
||||
|
||||
return shaderGroup->getOrCreateShader(context, propertiesAsUniforms);
|
||||
}
|
||||
@@ -482,10 +473,8 @@ gfx::ShaderPtr CustomDrawableLayerHost::Interface::lineShaderDefault() const {
|
||||
gfx::ShaderPtr CustomDrawableLayerHost::Interface::fillShaderDefault() const {
|
||||
gfx::ShaderGroupPtr shaderGroup = shaders.getShaderGroup("FillShader");
|
||||
|
||||
const mbgl::unordered_set<StringIdentity> propertiesAsUniforms{
|
||||
stringIndexer().get("a_color"),
|
||||
stringIndexer().get("a_opacity"),
|
||||
};
|
||||
const StringIDSetsPair propertiesAsUniforms{{"a_color", "a_opacity"},
|
||||
{idFillColorVertexAttribute, idFillOpacityVertexAttribute}};
|
||||
|
||||
return shaderGroup->getOrCreateShader(context, propertiesAsUniforms);
|
||||
}
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
#include <utility>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using StringIdentity = std::size_t;
|
||||
|
||||
namespace style {
|
||||
|
||||
template <class T>
|
||||
@@ -46,12 +43,8 @@ public:
|
||||
using UniformList = TypeList<U>;
|
||||
|
||||
static constexpr const std::array<std::string_view, 1> AttributeNames = {A::name()};
|
||||
static std::array<std::optional<StringIdentity>, 1> AttributeNameIDs;
|
||||
};
|
||||
|
||||
template <class T, class A, class U, bool B>
|
||||
std::array<std::optional<StringIdentity>, 1> DataDrivenPaintProperty<T, A, U, B>::AttributeNameIDs = {std::nullopt};
|
||||
|
||||
template <class T, class A1, class U1, class A2, class U2>
|
||||
class CrossFadedDataDrivenPaintProperty {
|
||||
public:
|
||||
@@ -69,13 +62,8 @@ public:
|
||||
using UniformList = TypeList<U1, U2>;
|
||||
|
||||
static constexpr const std::array<std::string_view, 2> AttributeNames = {A1::name(), A2::name()};
|
||||
static std::array<std::optional<StringIdentity>, 2> AttributeNameIDs;
|
||||
};
|
||||
|
||||
template <class T, class A1, class U1, class A2, class U2>
|
||||
std::array<std::optional<StringIdentity>, 2> CrossFadedDataDrivenPaintProperty<T, A1, U1, A2, U2>::AttributeNameIDs = {
|
||||
std::nullopt, std::nullopt};
|
||||
|
||||
template <class T>
|
||||
class CrossFadedPaintProperty {
|
||||
public:
|
||||
|
||||
@@ -94,16 +94,16 @@ void each_subset(const TSet& sofar, TIter beg, TIter end, TFunc f) {
|
||||
/// Ensure that no combination of attributes used by a shader definition produce a hash conflict
|
||||
template <typename ShaderType>
|
||||
void checkShaderHashes() {
|
||||
using AttribSet = mbgl::unordered_set<StringIdentity>;
|
||||
using AttribSet = mbgl::unordered_set<size_t>;
|
||||
AttribSet attributes;
|
||||
for (const auto& attrib : ShaderType::attributes) {
|
||||
attributes.insert(attrib.nameID);
|
||||
attributes.insert(attrib.id);
|
||||
}
|
||||
|
||||
std::set<std::size_t> subsetHashes;
|
||||
each_subset(AttribSet{}, attributes.cbegin(), attributes.cend(), [&](auto beg, auto end) {
|
||||
if (beg != end) {
|
||||
std::vector<StringIdentity> subset(beg, end);
|
||||
std::vector<size_t> subset(beg, end);
|
||||
std::optional<std::size_t> firstHash;
|
||||
do {
|
||||
const auto hash = util::order_independent_hash(subset.begin(), subset.end());
|
||||
|
||||
Reference in New Issue
Block a user