Custom drawable layer v3 (#3210)
This commit is contained in:
@@ -1035,6 +1035,7 @@ if(MLN_WITH_OPENGL)
|
|||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_circle.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_circle.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_collision_box.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_collision_box.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_collision_circle.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_collision_circle.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_custom_geometry.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_custom_symbol_icon.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_custom_symbol_icon.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_debug.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_debug.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill.hpp
|
||||||
@@ -1217,6 +1218,7 @@ if(MLN_WITH_METAL)
|
|||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/clipping_mask.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/clipping_mask.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/common.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/common.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/collision.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/collision.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/custom_geometry.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/custom_symbol_icon.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/custom_symbol_icon.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/debug.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/debug.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/fill.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/fill.hpp
|
||||||
@@ -1226,6 +1228,7 @@ if(MLN_WITH_METAL)
|
|||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/hillshade.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/hillshade.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/hillshade_prepare.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/hillshade_prepare.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/line.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/line.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/location_indicator.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/raster.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/raster.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/shader_group.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/shader_group.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/shader_program.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/shader_program.hpp
|
||||||
@@ -1256,6 +1259,7 @@ if(MLN_WITH_METAL)
|
|||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/circle.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/circle.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/collision.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/collision.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/clipping_mask.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/clipping_mask.cpp
|
||||||
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/custom_geometry.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/custom_symbol_icon.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/custom_symbol_icon.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/debug.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/debug.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/fill.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/fill.cpp
|
||||||
@@ -1265,6 +1269,7 @@ if(MLN_WITH_METAL)
|
|||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/hillshade.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/hillshade.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/hillshade_prepare.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/hillshade_prepare.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/line.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/line.cpp
|
||||||
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/location_indicator.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/raster.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/raster.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/symbol.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/symbol.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/widevector.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/widevector.cpp
|
||||||
@@ -1314,6 +1319,7 @@ if(MLN_WITH_VULKAN)
|
|||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/clipping_mask.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/clipping_mask.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/collision.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/collision.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/common.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/common.hpp
|
||||||
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/custom_geometry.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/custom_symbol_icon.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/custom_symbol_icon.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/fill.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/fill.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/fill_extrusion.hpp
|
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/fill_extrusion.hpp
|
||||||
@@ -1354,6 +1360,7 @@ if(MLN_WITH_VULKAN)
|
|||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/circle.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/circle.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/clipping_mask.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/clipping_mask.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/collision.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/collision.cpp
|
||||||
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/custom_geometry.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/custom_symbol_icon.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/custom_symbol_icon.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/debug.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/debug.cpp
|
||||||
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/fill.cpp
|
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/fill.cpp
|
||||||
|
|||||||
@@ -54,6 +54,14 @@ http_archive(
|
|||||||
urls = ["https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.zip"],
|
urls = ["https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.zip"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
new_git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
|
||||||
|
|
||||||
|
new_git_repository(
|
||||||
|
name = "tinyobjloader",
|
||||||
|
remote = "https://github.com/tinyobjloader/tinyobjloader.git",
|
||||||
|
branch = "release",
|
||||||
|
)
|
||||||
|
|
||||||
darwin_config = use_repo_rule("//platform/darwin:bazel/darwin_config_repository_rule.bzl", "darwin_config")
|
darwin_config = use_repo_rule("//platform/darwin:bazel/darwin_config_repository_rule.bzl", "darwin_config")
|
||||||
|
|
||||||
darwin_config(
|
darwin_config(
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ MLN_GENERATED_OPENGL_SHADER_HEADERS = [
|
|||||||
"include/mbgl/shaders/gl/drawable_circle.hpp",
|
"include/mbgl/shaders/gl/drawable_circle.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_collision_box.hpp",
|
"include/mbgl/shaders/gl/drawable_collision_box.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_collision_circle.hpp",
|
"include/mbgl/shaders/gl/drawable_collision_circle.hpp",
|
||||||
|
"include/mbgl/shaders/gl/drawable_custom_geometry.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_custom_symbol_icon.hpp",
|
"include/mbgl/shaders/gl/drawable_custom_symbol_icon.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_debug.hpp",
|
"include/mbgl/shaders/gl/drawable_debug.hpp",
|
||||||
"include/mbgl/shaders/gl/drawable_fill.hpp",
|
"include/mbgl/shaders/gl/drawable_fill.hpp",
|
||||||
@@ -1010,6 +1011,7 @@ MLN_DRAWABLES_HEADERS = [
|
|||||||
"include/mbgl/shaders/background_layer_ubo.hpp",
|
"include/mbgl/shaders/background_layer_ubo.hpp",
|
||||||
"include/mbgl/shaders/circle_layer_ubo.hpp",
|
"include/mbgl/shaders/circle_layer_ubo.hpp",
|
||||||
"include/mbgl/shaders/collision_layer_ubo.hpp",
|
"include/mbgl/shaders/collision_layer_ubo.hpp",
|
||||||
|
"include/mbgl/shaders/custom_geometry_ubo.hpp",
|
||||||
"include/mbgl/shaders/custom_drawable_layer_ubo.hpp",
|
"include/mbgl/shaders/custom_drawable_layer_ubo.hpp",
|
||||||
"include/mbgl/shaders/debug_layer_ubo.hpp",
|
"include/mbgl/shaders/debug_layer_ubo.hpp",
|
||||||
"include/mbgl/shaders/fill_layer_ubo.hpp",
|
"include/mbgl/shaders/fill_layer_ubo.hpp",
|
||||||
@@ -1081,6 +1083,7 @@ MLN_DRAWABLES_MTL_SOURCE = [
|
|||||||
"src/mbgl/shaders/mtl/circle.cpp",
|
"src/mbgl/shaders/mtl/circle.cpp",
|
||||||
"src/mbgl/shaders/mtl/collision.cpp",
|
"src/mbgl/shaders/mtl/collision.cpp",
|
||||||
"src/mbgl/shaders/mtl/clipping_mask.cpp",
|
"src/mbgl/shaders/mtl/clipping_mask.cpp",
|
||||||
|
"src/mbgl/shaders/mtl/custom_geometry.cpp",
|
||||||
"src/mbgl/shaders/mtl/custom_symbol_icon.cpp",
|
"src/mbgl/shaders/mtl/custom_symbol_icon.cpp",
|
||||||
"src/mbgl/shaders/mtl/debug.cpp",
|
"src/mbgl/shaders/mtl/debug.cpp",
|
||||||
"src/mbgl/shaders/mtl/fill.cpp",
|
"src/mbgl/shaders/mtl/fill.cpp",
|
||||||
@@ -1090,6 +1093,7 @@ MLN_DRAWABLES_MTL_SOURCE = [
|
|||||||
"src/mbgl/shaders/mtl/hillshade.cpp",
|
"src/mbgl/shaders/mtl/hillshade.cpp",
|
||||||
"src/mbgl/shaders/mtl/hillshade_prepare.cpp",
|
"src/mbgl/shaders/mtl/hillshade_prepare.cpp",
|
||||||
"src/mbgl/shaders/mtl/line.cpp",
|
"src/mbgl/shaders/mtl/line.cpp",
|
||||||
|
"src/mbgl/shaders/mtl/location_indicator.cpp",
|
||||||
"src/mbgl/shaders/mtl/raster.cpp",
|
"src/mbgl/shaders/mtl/raster.cpp",
|
||||||
"src/mbgl/shaders/mtl/symbol.cpp",
|
"src/mbgl/shaders/mtl/symbol.cpp",
|
||||||
"src/mbgl/shaders/mtl/widevector.cpp",
|
"src/mbgl/shaders/mtl/widevector.cpp",
|
||||||
@@ -1120,6 +1124,7 @@ MLN_DRAWABLES_MTL_HEADERS = [
|
|||||||
"include/mbgl/shaders/mtl/clipping_mask.hpp",
|
"include/mbgl/shaders/mtl/clipping_mask.hpp",
|
||||||
"include/mbgl/shaders/mtl/collision.hpp",
|
"include/mbgl/shaders/mtl/collision.hpp",
|
||||||
"include/mbgl/shaders/mtl/common.hpp",
|
"include/mbgl/shaders/mtl/common.hpp",
|
||||||
|
"include/mbgl/shaders/mtl/custom_geometry.hpp",
|
||||||
"include/mbgl/shaders/mtl/custom_symbol_icon.hpp",
|
"include/mbgl/shaders/mtl/custom_symbol_icon.hpp",
|
||||||
"include/mbgl/shaders/mtl/debug.hpp",
|
"include/mbgl/shaders/mtl/debug.hpp",
|
||||||
"include/mbgl/shaders/mtl/fill.hpp",
|
"include/mbgl/shaders/mtl/fill.hpp",
|
||||||
@@ -1129,6 +1134,7 @@ MLN_DRAWABLES_MTL_HEADERS = [
|
|||||||
"include/mbgl/shaders/mtl/hillshade.hpp",
|
"include/mbgl/shaders/mtl/hillshade.hpp",
|
||||||
"include/mbgl/shaders/mtl/hillshade_prepare.hpp",
|
"include/mbgl/shaders/mtl/hillshade_prepare.hpp",
|
||||||
"include/mbgl/shaders/mtl/line.hpp",
|
"include/mbgl/shaders/mtl/line.hpp",
|
||||||
|
"include/mbgl/shaders/mtl/location_indicator.hpp",
|
||||||
"include/mbgl/shaders/mtl/raster.hpp",
|
"include/mbgl/shaders/mtl/raster.hpp",
|
||||||
"include/mbgl/shaders/mtl/shader_group.hpp",
|
"include/mbgl/shaders/mtl/shader_group.hpp",
|
||||||
"include/mbgl/shaders/mtl/shader_program.hpp",
|
"include/mbgl/shaders/mtl/shader_program.hpp",
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ public:
|
|||||||
bool persistent = false,
|
bool persistent = false,
|
||||||
bool ssbo = false) = 0;
|
bool ssbo = false) = 0;
|
||||||
|
|
||||||
|
virtual UniqueUniformBufferArray createLayerUniformBufferArray() = 0;
|
||||||
|
|
||||||
/// Get the generic shader with the specified name
|
/// Get the generic shader with the specified name
|
||||||
virtual gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) = 0;
|
virtual gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace gfx {
|
|||||||
class Context;
|
class Context;
|
||||||
class UniformBuffer;
|
class UniformBuffer;
|
||||||
class UniformBufferArray;
|
class UniformBufferArray;
|
||||||
|
class RenderPass;
|
||||||
|
|
||||||
using UniformBufferPtr = std::shared_ptr<UniformBuffer>;
|
using UniformBufferPtr = std::shared_ptr<UniformBuffer>;
|
||||||
using UniqueUniformBuffer = std::unique_ptr<UniformBuffer>;
|
using UniqueUniformBuffer = std::unique_ptr<UniformBuffer>;
|
||||||
@@ -75,6 +76,8 @@ public:
|
|||||||
createOrUpdate(id, data, sizeof(T), context, persistent);
|
createOrUpdate(id, data, sizeof(T), context, persistent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void bind(gfx::RenderPass& renderPass) = 0;
|
||||||
|
|
||||||
UniformBufferArray& operator=(UniformBufferArray&&);
|
UniformBufferArray& operator=(UniformBufferArray&&);
|
||||||
UniformBufferArray& operator=(const UniformBufferArray&);
|
UniformBufferArray& operator=(const UniformBufferArray&);
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public:
|
|||||||
void bind() const;
|
void bind() const;
|
||||||
void unbind() const;
|
void unbind() const;
|
||||||
|
|
||||||
|
void bind(gfx::RenderPass&) override { bind(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<gfx::UniformBuffer> copy(const gfx::UniformBuffer& uniformBuffers) override {
|
std::unique_ptr<gfx::UniformBuffer> copy(const gfx::UniformBuffer& uniformBuffers) override {
|
||||||
return std::make_unique<UniformBufferGL>(static_cast<const UniformBufferGL&>(uniformBuffers).clone());
|
return std::make_unique<UniformBufferGL>(static_cast<const UniformBufferGL&>(uniformBuffers).clone());
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class VertexBufferResource;
|
|||||||
|
|
||||||
using UniqueShaderProgram = std::unique_ptr<ShaderProgram>;
|
using UniqueShaderProgram = std::unique_ptr<ShaderProgram>;
|
||||||
using UniqueVertexBufferResource = std::unique_ptr<VertexBufferResource>;
|
using UniqueVertexBufferResource = std::unique_ptr<VertexBufferResource>;
|
||||||
|
using UniqueUniformBufferArray = std::unique_ptr<gfx::UniformBufferArray>;
|
||||||
|
|
||||||
class Context final : public gfx::Context {
|
class Context final : public gfx::Context {
|
||||||
public:
|
public:
|
||||||
@@ -88,6 +89,8 @@ public:
|
|||||||
bool persistent = false,
|
bool persistent = false,
|
||||||
bool ssbo = false) override;
|
bool ssbo = false) override;
|
||||||
|
|
||||||
|
UniqueUniformBufferArray createLayerUniformBufferArray() override;
|
||||||
|
|
||||||
gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override;
|
gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override;
|
||||||
|
|
||||||
TileLayerGroupPtr createTileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) override;
|
TileLayerGroupPtr createTileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) override;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ namespace mtl {
|
|||||||
|
|
||||||
class IndexBufferResource : public gfx::IndexBufferResource {
|
class IndexBufferResource : public gfx::IndexBufferResource {
|
||||||
public:
|
public:
|
||||||
IndexBufferResource() noexcept = delete;
|
|
||||||
IndexBufferResource(BufferResource&&) noexcept;
|
IndexBufferResource(BufferResource&&) noexcept;
|
||||||
IndexBufferResource(IndexBufferResource&& other) noexcept
|
IndexBufferResource(IndexBufferResource&& other) noexcept
|
||||||
: buffer(std::move(other.buffer)) {}
|
: buffer(std::move(other.buffer)) {}
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bind(RenderPass& renderPass) const noexcept;
|
void bindMtl(RenderPass&) const noexcept;
|
||||||
void unbind(RenderPass&) const noexcept {}
|
void bind(gfx::RenderPass& renderPass) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gfx::UniqueUniformBuffer copy(const gfx::UniformBuffer& buffer) override {
|
gfx::UniqueUniformBuffer copy(const gfx::UniformBuffer& buffer) override {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ namespace mtl {
|
|||||||
|
|
||||||
class VertexBufferResource : public gfx::VertexBufferResource {
|
class VertexBufferResource : public gfx::VertexBufferResource {
|
||||||
public:
|
public:
|
||||||
VertexBufferResource() noexcept = delete;
|
|
||||||
VertexBufferResource(BufferResource&&) noexcept;
|
VertexBufferResource(BufferResource&&) noexcept;
|
||||||
VertexBufferResource(VertexBufferResource&& other) noexcept
|
VertexBufferResource(VertexBufferResource&& other) noexcept
|
||||||
: buffer(std::move(other.buffer)) {}
|
: buffer(std::move(other.buffer)) {}
|
||||||
|
|||||||
16
include/mbgl/shaders/custom_geometry_ubo.hpp
Normal file
16
include/mbgl/shaders/custom_geometry_ubo.hpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mbgl/shaders/layer_ubo.hpp>
|
||||||
|
|
||||||
|
namespace mbgl {
|
||||||
|
namespace shaders {
|
||||||
|
|
||||||
|
struct alignas(16) CustomGeometryDrawableUBO {
|
||||||
|
/* 0 */ std::array<float, 4 * 4> matrix;
|
||||||
|
/* 64 */ Color color;
|
||||||
|
/* 80 */
|
||||||
|
};
|
||||||
|
static_assert(sizeof(CustomGeometryDrawableUBO) == 5 * 16);
|
||||||
|
|
||||||
|
} // namespace shaders
|
||||||
|
} // namespace mbgl
|
||||||
39
include/mbgl/shaders/gl/drawable_custom_geometry.hpp
Normal file
39
include/mbgl/shaders/gl/drawable_custom_geometry.hpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
// Generated code, do not modify this file!
|
||||||
|
#pragma once
|
||||||
|
#include <mbgl/shaders/shader_source.hpp>
|
||||||
|
|
||||||
|
namespace mbgl {
|
||||||
|
namespace shaders {
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ShaderSource<BuiltIn::CustomGeometryShader, gfx::Backend::Type::OpenGL> {
|
||||||
|
static constexpr const char* name = "CustomGeometryShader";
|
||||||
|
static constexpr const char* vertex = R"(layout (std140) uniform CustomGeometryDrawableUBO {
|
||||||
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 a_pos;
|
||||||
|
layout(location = 1) in vec2 a_uv;
|
||||||
|
|
||||||
|
out vec2 frag_uv;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
frag_uv = a_uv;
|
||||||
|
gl_Position = u_matrix * vec4(a_pos, 1.0);
|
||||||
|
})";
|
||||||
|
static constexpr const char* fragment = R"(layout (std140) uniform CustomGeometryDrawableUBO {
|
||||||
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
in vec2 frag_uv;
|
||||||
|
uniform sampler2D u_image;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragColor = texture(u_image, frag_uv) * u_color;
|
||||||
|
})";
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace shaders
|
||||||
|
} // namespace mbgl
|
||||||
@@ -8,8 +8,24 @@ namespace shaders {
|
|||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::LocationIndicatorShader, gfx::Backend::Type::OpenGL> {
|
struct ShaderSource<BuiltIn::LocationIndicatorShader, gfx::Backend::Type::OpenGL> {
|
||||||
static constexpr const char* name = "LocationIndicatorShader";
|
static constexpr const char* name = "LocationIndicatorShader";
|
||||||
static constexpr const char* vertex = R"()";
|
static constexpr const char* vertex = R"(layout (std140) uniform LocationIndicatorDrawableUBO {
|
||||||
static constexpr const char* fragment = R"()";
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 a_pos;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
|
||||||
|
})";
|
||||||
|
static constexpr const char* fragment = R"(layout (std140) uniform LocationIndicatorDrawableUBO {
|
||||||
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragColor = u_color;
|
||||||
|
})";
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace shaders
|
} // namespace shaders
|
||||||
|
|||||||
@@ -8,8 +8,31 @@ namespace shaders {
|
|||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::LocationIndicatorTexturedShader, gfx::Backend::Type::OpenGL> {
|
struct ShaderSource<BuiltIn::LocationIndicatorTexturedShader, gfx::Backend::Type::OpenGL> {
|
||||||
static constexpr const char* name = "LocationIndicatorTexturedShader";
|
static constexpr const char* name = "LocationIndicatorTexturedShader";
|
||||||
static constexpr const char* vertex = R"()";
|
static constexpr const char* vertex = R"(layout (std140) uniform LocationIndicatorDrawableUBO {
|
||||||
static constexpr const char* fragment = R"()";
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 a_pos;
|
||||||
|
layout(location = 1) in vec2 a_uv;
|
||||||
|
|
||||||
|
out vec2 frag_uv;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
frag_uv = a_uv;
|
||||||
|
gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
|
||||||
|
})";
|
||||||
|
static constexpr const char* fragment = R"(layout (std140) uniform LocationIndicatorDrawableUBO {
|
||||||
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
in vec2 frag_uv;
|
||||||
|
uniform sampler2D u_image;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragColor = texture(u_image, frag_uv);
|
||||||
|
})";
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace shaders
|
} // namespace shaders
|
||||||
|
|||||||
@@ -65,6 +65,13 @@ struct ShaderInfo<BuiltIn::CollisionCircleShader, gfx::Backend::Type::OpenGL> {
|
|||||||
static const std::vector<TextureInfo> textures;
|
static const std::vector<TextureInfo> textures;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ShaderInfo<BuiltIn::CustomGeometryShader, gfx::Backend::Type::OpenGL> {
|
||||||
|
static const std::vector<AttributeInfo> attributes;
|
||||||
|
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||||
|
static const std::vector<TextureInfo> textures;
|
||||||
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderInfo<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::OpenGL> {
|
struct ShaderInfo<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::OpenGL> {
|
||||||
static const std::vector<AttributeInfo> attributes;
|
static const std::vector<AttributeInfo> attributes;
|
||||||
@@ -184,6 +191,20 @@ struct ShaderInfo<BuiltIn::LineShader, gfx::Backend::Type::OpenGL> {
|
|||||||
static const std::vector<TextureInfo> textures;
|
static const std::vector<TextureInfo> textures;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ShaderInfo<BuiltIn::LocationIndicatorShader, 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::LocationIndicatorTexturedShader, gfx::Backend::Type::OpenGL> {
|
||||||
|
static const std::vector<AttributeInfo> attributes;
|
||||||
|
static const std::vector<UniformBlockInfo> uniformBlocks;
|
||||||
|
static const std::vector<TextureInfo> textures;
|
||||||
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderInfo<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL> {
|
struct ShaderInfo<BuiltIn::RasterShader, gfx::Backend::Type::OpenGL> {
|
||||||
static const std::vector<AttributeInfo> attributes;
|
static const std::vector<AttributeInfo> attributes;
|
||||||
|
|||||||
70
include/mbgl/shaders/mtl/custom_geometry.hpp
Normal file
70
include/mbgl/shaders/mtl/custom_geometry.hpp
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mbgl/shaders/custom_geometry_ubo.hpp>
|
||||||
|
#include <mbgl/shaders/shader_source.hpp>
|
||||||
|
#include <mbgl/shaders/mtl/shader_program.hpp>
|
||||||
|
|
||||||
|
namespace mbgl {
|
||||||
|
namespace shaders {
|
||||||
|
|
||||||
|
constexpr auto customGeometryShaderPrelude = R"(
|
||||||
|
|
||||||
|
enum {
|
||||||
|
idCustomGeometryDrawableUBO = drawableReservedUBOCount,
|
||||||
|
customGeometryUBOCount
|
||||||
|
};
|
||||||
|
|
||||||
|
struct alignas(16) CustomGeometryDrawableUBO {
|
||||||
|
/* 0 */ float4x4 matrix;
|
||||||
|
/* 64 */ float4 color;
|
||||||
|
/* 80 */
|
||||||
|
};
|
||||||
|
static_assert(sizeof(CustomGeometryDrawableUBO) == 5 * 16, "wrong size");
|
||||||
|
|
||||||
|
)";
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ShaderSource<BuiltIn::CustomGeometryShader, gfx::Backend::Type::Metal> {
|
||||||
|
static constexpr auto name = "CustomGeometryShader";
|
||||||
|
static constexpr auto vertexMainFunction = "vertexMain";
|
||||||
|
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||||
|
|
||||||
|
static const std::array<AttributeInfo, 2> attributes;
|
||||||
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
|
static constexpr auto prelude = customGeometryShaderPrelude;
|
||||||
|
static constexpr auto source = R"(
|
||||||
|
|
||||||
|
struct VertexStage {
|
||||||
|
float3 position [[attribute(customGeometryUBOCount + 0)]];
|
||||||
|
float2 uv [[attribute(customGeometryUBOCount + 1)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FragmentStage {
|
||||||
|
float4 position [[position, invariant]];
|
||||||
|
float2 uv;
|
||||||
|
};
|
||||||
|
|
||||||
|
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||||
|
device const CustomGeometryDrawableUBO& drawable [[buffer(idCustomGeometryDrawableUBO)]]) {
|
||||||
|
|
||||||
|
return {
|
||||||
|
.position = drawable.matrix * float4(vertx.position, 1.0),
|
||||||
|
.uv = vertx.uv
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||||
|
device const CustomGeometryDrawableUBO& drawable [[buffer(idCustomGeometryDrawableUBO)]],
|
||||||
|
texture2d<float, access::sample> colorTexture [[texture(0)]]) {
|
||||||
|
constexpr sampler sampler2d(coord::normalized, filter::linear);
|
||||||
|
const float4 color = colorTexture.sample(sampler2d, in.uv) * drawable.color;
|
||||||
|
|
||||||
|
return half4(color);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace shaders
|
||||||
|
} // namespace mbgl
|
||||||
107
include/mbgl/shaders/mtl/location_indicator.hpp
Normal file
107
include/mbgl/shaders/mtl/location_indicator.hpp
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mbgl/shaders/location_indicator_ubo.hpp>
|
||||||
|
#include <mbgl/shaders/shader_source.hpp>
|
||||||
|
#include <mbgl/shaders/mtl/shader_program.hpp>
|
||||||
|
|
||||||
|
namespace mbgl {
|
||||||
|
namespace shaders {
|
||||||
|
|
||||||
|
constexpr auto locationIndicatorShaderPrelude = R"(
|
||||||
|
|
||||||
|
enum {
|
||||||
|
idLocationIndicatorUBO = drawableReservedUBOCount,
|
||||||
|
locationIndicatorUBOCount
|
||||||
|
};
|
||||||
|
|
||||||
|
struct alignas(16) LocationIndicatorDrawableUBO {
|
||||||
|
/* 0 */ float4x4 matrix;
|
||||||
|
/* 64 */ float4 color;
|
||||||
|
/* 80 */
|
||||||
|
};
|
||||||
|
static_assert(sizeof(LocationIndicatorDrawableUBO) == 5 * 16, "wrong size");
|
||||||
|
|
||||||
|
)";
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ShaderSource<BuiltIn::LocationIndicatorShader, gfx::Backend::Type::Metal> {
|
||||||
|
static constexpr auto name = "LocationIndicatorShader";
|
||||||
|
static constexpr auto vertexMainFunction = "vertexMain";
|
||||||
|
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||||
|
|
||||||
|
static const std::array<AttributeInfo, 1> attributes;
|
||||||
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
|
static constexpr std::array<TextureInfo, 0> textures{};
|
||||||
|
|
||||||
|
static constexpr auto prelude = locationIndicatorShaderPrelude;
|
||||||
|
static constexpr auto source = R"(
|
||||||
|
|
||||||
|
struct VertexStage {
|
||||||
|
float2 position [[attribute(locationIndicatorUBOCount + 0)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FragmentStage {
|
||||||
|
float4 position [[position, invariant]];
|
||||||
|
};
|
||||||
|
|
||||||
|
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||||
|
device const LocationIndicatorDrawableUBO& drawable [[buffer(idLocationIndicatorUBO)]]) {
|
||||||
|
|
||||||
|
return {
|
||||||
|
.position = drawable.matrix * float4(vertx.position, 1.0)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||||
|
device const LocationIndicatorDrawableUBO& drawable [[buffer(idLocationIndicatorUBO)]]) {
|
||||||
|
return half4(drawable.color);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ShaderSource<BuiltIn::LocationIndicatorTexturedShader, gfx::Backend::Type::Metal> {
|
||||||
|
static constexpr auto name = "LocationIndicatorTexturedShader";
|
||||||
|
static constexpr auto vertexMainFunction = "vertexMain";
|
||||||
|
static constexpr auto fragmentMainFunction = "fragmentMain";
|
||||||
|
|
||||||
|
static const std::array<AttributeInfo, 2> attributes;
|
||||||
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
|
static constexpr auto prelude = locationIndicatorShaderPrelude;
|
||||||
|
static constexpr auto source = R"(
|
||||||
|
|
||||||
|
struct VertexStage {
|
||||||
|
float2 position [[attribute(locationIndicatorUBOCount + 0)]];
|
||||||
|
float2 uv [[attribute(locationIndicatorUBOCount + 1)]];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FragmentStage {
|
||||||
|
float4 position [[position, invariant]];
|
||||||
|
float2 uv;
|
||||||
|
};
|
||||||
|
|
||||||
|
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||||
|
device const LocationIndicatorDrawableUBO& drawable [[buffer(idLocationIndicatorUBO)]]) {
|
||||||
|
|
||||||
|
return {
|
||||||
|
.position = drawable.matrix * float4(vertx.position, 1.0),
|
||||||
|
.uv = vertx.uv
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||||
|
device const LocationIndicatorDrawableUBO& drawable [[buffer(idLocationIndicatorUBO)]],
|
||||||
|
texture2d<float, access::sample> colorTexture [[texture(0)]]) {
|
||||||
|
|
||||||
|
constexpr sampler sampler2d(coord::normalized, filter::linear);
|
||||||
|
const float4 color = colorTexture.sample(sampler2d, in.uv);
|
||||||
|
|
||||||
|
return half4(color);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace shaders
|
||||||
|
} // namespace mbgl
|
||||||
@@ -30,6 +30,11 @@ enum {
|
|||||||
collisionDrawableUBOCount
|
collisionDrawableUBOCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
idCustomGeometryDrawableUBO = drawableReservedUBOCount,
|
||||||
|
customGeometryDrawableUBOCount
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
idCustomSymbolDrawableUBO = idDrawableReservedVertexOnlyUBO,
|
idCustomSymbolDrawableUBO = idDrawableReservedVertexOnlyUBO,
|
||||||
customSymbolDrawableUBOCount = drawableReservedUBOCount
|
customSymbolDrawableUBOCount = drawableReservedUBOCount
|
||||||
@@ -101,26 +106,27 @@ enum {
|
|||||||
wideVectorDrawableUBOCount
|
wideVectorDrawableUBOCount
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr auto layerSSBOStartId = globalUBOCount;
|
static constexpr uint32_t layerSSBOStartId = globalUBOCount;
|
||||||
static constexpr auto layerUBOStartId = std::max({static_cast<size_t>(backgroundDrawableUBOCount),
|
static constexpr uint32_t layerUBOStartId = std::max({static_cast<uint32_t>(backgroundDrawableUBOCount),
|
||||||
static_cast<size_t>(circleDrawableUBOCount),
|
static_cast<uint32_t>(circleDrawableUBOCount),
|
||||||
static_cast<size_t>(clippingMaskDrawableUBOCount),
|
static_cast<uint32_t>(clippingMaskDrawableUBOCount),
|
||||||
static_cast<size_t>(collisionDrawableUBOCount),
|
static_cast<uint32_t>(collisionDrawableUBOCount),
|
||||||
static_cast<size_t>(customSymbolDrawableUBOCount),
|
static_cast<uint32_t>(customGeometryDrawableUBOCount),
|
||||||
static_cast<size_t>(debugDrawableUBOCount),
|
static_cast<uint32_t>(customSymbolDrawableUBOCount),
|
||||||
static_cast<size_t>(fillDrawableUBOCount),
|
static_cast<uint32_t>(debugDrawableUBOCount),
|
||||||
static_cast<size_t>(fillExtrusionDrawableUBOCount),
|
static_cast<uint32_t>(fillDrawableUBOCount),
|
||||||
static_cast<size_t>(heatmapDrawableUBOCount),
|
static_cast<uint32_t>(fillExtrusionDrawableUBOCount),
|
||||||
static_cast<size_t>(heatmapTextureDrawableUBOCount),
|
static_cast<uint32_t>(heatmapDrawableUBOCount),
|
||||||
static_cast<size_t>(hillshadeDrawableUBOCount),
|
static_cast<uint32_t>(heatmapTextureDrawableUBOCount),
|
||||||
static_cast<size_t>(hillshadePrepareDrawableUBOCount),
|
static_cast<uint32_t>(hillshadeDrawableUBOCount),
|
||||||
static_cast<size_t>(lineDrawableUBOCount),
|
static_cast<uint32_t>(hillshadePrepareDrawableUBOCount),
|
||||||
static_cast<size_t>(locationIndicatorDrawableUBOCount),
|
static_cast<uint32_t>(lineDrawableUBOCount),
|
||||||
static_cast<size_t>(rasterDrawableUBOCount),
|
static_cast<uint32_t>(locationIndicatorDrawableUBOCount),
|
||||||
static_cast<size_t>(symbolDrawableUBOCount),
|
static_cast<uint32_t>(rasterDrawableUBOCount),
|
||||||
static_cast<size_t>(wideVectorDrawableUBOCount)});
|
static_cast<uint32_t>(symbolDrawableUBOCount),
|
||||||
|
static_cast<uint32_t>(wideVectorDrawableUBOCount)});
|
||||||
|
|
||||||
static constexpr auto maxUBOCountPerDrawable = layerUBOStartId - globalUBOCount;
|
static constexpr uint32_t maxUBOCountPerDrawable = layerUBOStartId - globalUBOCount;
|
||||||
|
|
||||||
// layer UBOs
|
// layer UBOs
|
||||||
|
|
||||||
@@ -148,6 +154,10 @@ enum {
|
|||||||
collisionUBOCount = getLayerStartValue(collisionDrawableUBOCount)
|
collisionUBOCount = getLayerStartValue(collisionDrawableUBOCount)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
customGeometryUBOCount = getLayerStartValue(customGeometryDrawableUBOCount)
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
customSymbolUBOCount = getLayerStartValue(customSymbolDrawableUBOCount)
|
customSymbolUBOCount = getLayerStartValue(customSymbolDrawableUBOCount)
|
||||||
};
|
};
|
||||||
@@ -211,26 +221,26 @@ enum {
|
|||||||
|
|
||||||
#undef getLayerStartValue
|
#undef getLayerStartValue
|
||||||
|
|
||||||
static constexpr auto maxUBOCountPerShader = std::max({static_cast<size_t>(backgroundUBOCount),
|
static constexpr uint32_t maxUBOCountPerShader = std::max({static_cast<uint32_t>(backgroundUBOCount),
|
||||||
static_cast<size_t>(circleUBOCount),
|
static_cast<uint32_t>(circleUBOCount),
|
||||||
static_cast<size_t>(clippingMaskUBOCount),
|
static_cast<uint32_t>(clippingMaskUBOCount),
|
||||||
static_cast<size_t>(collisionUBOCount),
|
static_cast<uint32_t>(collisionUBOCount),
|
||||||
static_cast<size_t>(customSymbolUBOCount),
|
static_cast<uint32_t>(customSymbolUBOCount),
|
||||||
static_cast<size_t>(debugUBOCount),
|
static_cast<uint32_t>(debugUBOCount),
|
||||||
static_cast<size_t>(fillUBOCount),
|
static_cast<uint32_t>(fillUBOCount),
|
||||||
static_cast<size_t>(fillExtrusionUBOCount),
|
static_cast<uint32_t>(fillExtrusionUBOCount),
|
||||||
static_cast<size_t>(heatmapUBOCount),
|
static_cast<uint32_t>(heatmapUBOCount),
|
||||||
static_cast<size_t>(heatmapTextureUBOCount),
|
static_cast<uint32_t>(heatmapTextureUBOCount),
|
||||||
static_cast<size_t>(hillshadeUBOCount),
|
static_cast<uint32_t>(hillshadeUBOCount),
|
||||||
static_cast<size_t>(hillshadePrepareUBOCount),
|
static_cast<uint32_t>(hillshadePrepareUBOCount),
|
||||||
static_cast<size_t>(lineUBOCount),
|
static_cast<uint32_t>(lineUBOCount),
|
||||||
static_cast<size_t>(locationIndicatorUBOCount),
|
static_cast<uint32_t>(locationIndicatorUBOCount),
|
||||||
static_cast<size_t>(rasterUBOCount),
|
static_cast<uint32_t>(rasterUBOCount),
|
||||||
static_cast<size_t>(symbolUBOCount),
|
static_cast<uint32_t>(symbolUBOCount),
|
||||||
static_cast<size_t>(wideVectorUBOCount)});
|
static_cast<uint32_t>(wideVectorUBOCount)});
|
||||||
|
|
||||||
static constexpr auto maxSSBOCountPerLayer = maxUBOCountPerDrawable;
|
static constexpr uint32_t maxSSBOCountPerLayer = maxUBOCountPerDrawable;
|
||||||
static constexpr auto maxUBOCountPerLayer = maxUBOCountPerShader - layerUBOStartId;
|
static constexpr uint32_t maxUBOCountPerLayer = maxUBOCountPerShader - layerUBOStartId;
|
||||||
|
|
||||||
// Texture defines
|
// Texture defines
|
||||||
enum {
|
enum {
|
||||||
@@ -251,8 +261,8 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
idCommonTexture,
|
idCustomGeometryTexture,
|
||||||
commonTextureCount
|
customGeometryTextureCount
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -286,6 +296,11 @@ enum {
|
|||||||
hillshadeTextureCount
|
hillshadeTextureCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
idLocationIndicatorTexture,
|
||||||
|
locationIndicatorTextureCount
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
idLineImageTexture,
|
idLineImageTexture,
|
||||||
lineTextureCount
|
lineTextureCount
|
||||||
@@ -303,20 +318,21 @@ enum {
|
|||||||
symbolTextureCount
|
symbolTextureCount
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr auto maxTextureCountPerShader = std::max({static_cast<size_t>(backgroundTextureCount),
|
static constexpr uint32_t maxTextureCountPerShader = std::max({static_cast<uint32_t>(backgroundTextureCount),
|
||||||
static_cast<size_t>(circleTextureCount),
|
static_cast<uint32_t>(circleTextureCount),
|
||||||
static_cast<size_t>(clippingMaskTextureCount),
|
static_cast<uint32_t>(clippingMaskTextureCount),
|
||||||
static_cast<size_t>(collisionTextureCount),
|
static_cast<uint32_t>(collisionTextureCount),
|
||||||
static_cast<size_t>(commonTextureCount),
|
static_cast<uint32_t>(customGeometryTextureCount),
|
||||||
static_cast<size_t>(customSymbolTextureCount),
|
static_cast<uint32_t>(customSymbolTextureCount),
|
||||||
static_cast<size_t>(debugTextureCount),
|
static_cast<uint32_t>(debugTextureCount),
|
||||||
static_cast<size_t>(fillTextureCount),
|
static_cast<uint32_t>(fillTextureCount),
|
||||||
static_cast<size_t>(fillExtrusionTextureCount),
|
static_cast<uint32_t>(fillExtrusionTextureCount),
|
||||||
static_cast<size_t>(heatmapTextureCount),
|
static_cast<uint32_t>(heatmapTextureCount),
|
||||||
static_cast<size_t>(hillshadeTextureCount),
|
static_cast<uint32_t>(hillshadeTextureCount),
|
||||||
static_cast<size_t>(lineTextureCount),
|
static_cast<uint32_t>(lineTextureCount),
|
||||||
static_cast<size_t>(rasterTextureCount),
|
static_cast<uint32_t>(locationIndicatorTextureCount),
|
||||||
static_cast<size_t>(symbolTextureCount)});
|
static_cast<uint32_t>(rasterTextureCount),
|
||||||
|
static_cast<uint32_t>(symbolTextureCount)});
|
||||||
|
|
||||||
// Vertex attribute defines
|
// Vertex attribute defines
|
||||||
enum {
|
enum {
|
||||||
@@ -354,9 +370,9 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
idCommonPosVertexAttribute,
|
idCustomGeometryPosVertexAttribute,
|
||||||
idCommonTexVertexAttribute,
|
idCustomGeometryTexVertexAttribute,
|
||||||
commonVertexAttributeCount
|
customGeometryVertexAttributeCount
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -431,6 +447,12 @@ enum {
|
|||||||
lineVertexAttributeCount
|
lineVertexAttributeCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
idLocationIndicatorPosVertexAttribute,
|
||||||
|
idLocationIndicatorTexVertexAttribute,
|
||||||
|
locationIndicatorVertexAttributeCount
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
idRasterPosVertexAttribute,
|
idRasterPosVertexAttribute,
|
||||||
idRasterTexturePosVertexAttribute,
|
idRasterTexturePosVertexAttribute,
|
||||||
@@ -471,23 +493,24 @@ enum {
|
|||||||
wideVectorInstanceAttributeCount
|
wideVectorInstanceAttributeCount
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr auto maxVertexAttributeCountPerShader = std::max({
|
static constexpr uint32_t maxVertexAttributeCountPerShader = std::max({
|
||||||
static_cast<size_t>(backgroundVertexAttributeCount),
|
static_cast<uint32_t>(backgroundVertexAttributeCount),
|
||||||
static_cast<size_t>(circleVertexAttributeCount),
|
static_cast<uint32_t>(circleVertexAttributeCount),
|
||||||
static_cast<size_t>(clippingMaskVertexAttributeCount),
|
static_cast<uint32_t>(clippingMaskVertexAttributeCount),
|
||||||
static_cast<size_t>(collisionVertexAttributeCount),
|
static_cast<uint32_t>(collisionVertexAttributeCount),
|
||||||
static_cast<size_t>(commonVertexAttributeCount),
|
static_cast<uint32_t>(customGeometryVertexAttributeCount),
|
||||||
static_cast<size_t>(customSymbolVertexAttributeCount),
|
static_cast<uint32_t>(customSymbolVertexAttributeCount),
|
||||||
static_cast<size_t>(debugVertexAttributeCount),
|
static_cast<uint32_t>(debugVertexAttributeCount),
|
||||||
static_cast<size_t>(fillVertexAttributeCount),
|
static_cast<uint32_t>(fillVertexAttributeCount),
|
||||||
static_cast<size_t>(fillExtrusionVertexAttributeCount),
|
static_cast<uint32_t>(fillExtrusionVertexAttributeCount),
|
||||||
static_cast<size_t>(heatmapVertexAttributeCount),
|
static_cast<uint32_t>(heatmapVertexAttributeCount),
|
||||||
static_cast<size_t>(hillshadeVertexAttributeCount),
|
static_cast<uint32_t>(hillshadeVertexAttributeCount),
|
||||||
static_cast<size_t>(lineVertexAttributeCount),
|
static_cast<uint32_t>(lineVertexAttributeCount),
|
||||||
static_cast<size_t>(rasterVertexAttributeCount),
|
static_cast<uint32_t>(locationIndicatorVertexAttributeCount),
|
||||||
static_cast<size_t>(symbolVertexAttributeCount),
|
static_cast<uint32_t>(rasterVertexAttributeCount),
|
||||||
static_cast<size_t>(wideVectorAttributeCount),
|
static_cast<uint32_t>(symbolVertexAttributeCount),
|
||||||
static_cast<size_t>(wideVectorInstanceAttributeCount),
|
static_cast<uint32_t>(wideVectorAttributeCount),
|
||||||
|
static_cast<uint32_t>(wideVectorInstanceAttributeCount),
|
||||||
});
|
});
|
||||||
|
|
||||||
} // namespace shaders
|
} // namespace shaders
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <mbgl/shaders/gl/drawable_circle.hpp>
|
#include <mbgl/shaders/gl/drawable_circle.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_collision_box.hpp>
|
#include <mbgl/shaders/gl/drawable_collision_box.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_collision_circle.hpp>
|
#include <mbgl/shaders/gl/drawable_collision_circle.hpp>
|
||||||
|
#include <mbgl/shaders/gl/drawable_custom_geometry.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_custom_symbol_icon.hpp>
|
#include <mbgl/shaders/gl/drawable_custom_symbol_icon.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_debug.hpp>
|
#include <mbgl/shaders/gl/drawable_debug.hpp>
|
||||||
#include <mbgl/shaders/gl/drawable_fill.hpp>
|
#include <mbgl/shaders/gl/drawable_fill.hpp>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ enum class BuiltIn {
|
|||||||
CircleShader,
|
CircleShader,
|
||||||
CollisionBoxShader,
|
CollisionBoxShader,
|
||||||
CollisionCircleShader,
|
CollisionCircleShader,
|
||||||
|
CustomGeometryShader,
|
||||||
CustomSymbolIconShader,
|
CustomSymbolIconShader,
|
||||||
DebugShader,
|
DebugShader,
|
||||||
FillShader,
|
FillShader,
|
||||||
|
|||||||
@@ -6,13 +6,12 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define BACKGROUND_SHADER_COMMON \
|
constexpr auto backgroundShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idBackgroundDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idBackgroundDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idBackgroundPropsUBO layerUBOStartId
|
#define idBackgroundPropsUBO layerUBOStartId
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::BackgroundShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::BackgroundShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -22,7 +21,8 @@ struct ShaderSource<BuiltIn::BackgroundShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = BACKGROUND_SHADER_COMMON R"(
|
static constexpr auto prelude = backgroundShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = BACKGROUND_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|
||||||
layout(set = LAYER_SET_INDEX, binding = idBackgroundPropsUBO) uniform BackgroundPropsUBO {
|
layout(set = LAYER_SET_INDEX, binding = idBackgroundPropsUBO) uniform BackgroundPropsUBO {
|
||||||
@@ -79,7 +79,8 @@ struct ShaderSource<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::Vulkan
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = BACKGROUND_SHADER_COMMON R"(
|
static constexpr auto prelude = backgroundShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
|
|
||||||
layout(push_constant) uniform Constants {
|
layout(push_constant) uniform Constants {
|
||||||
@@ -135,7 +136,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = BACKGROUND_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
layout(location = 0) in vec2 frag_pos_a;
|
layout(location = 0) in vec2 frag_pos_a;
|
||||||
layout(location = 1) in vec2 frag_pos_b;
|
layout(location = 1) in vec2 frag_pos_b;
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,12 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define CIRCLE_SHADER_PRELUDE \
|
constexpr auto circleShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idCircleDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idCircleDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idCircleEvaluatedPropsUBO layerUBOStartId
|
#define idCircleEvaluatedPropsUBO layerUBOStartId
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -22,7 +21,8 @@ struct ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = CIRCLE_SHADER_PRELUDE R"(
|
static constexpr auto prelude = circleShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = CIRCLE_SHADER_PRELUDE R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in vec2 frag_extrude;
|
layout(location = 0) in vec2 frag_extrude;
|
||||||
layout(location = 1) in float frag_antialiasblur;
|
layout(location = 1) in float frag_antialiasblur;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ struct ShaderSource<BuiltIn::ClippingMaskProgram, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
|
static constexpr auto prelude = "";
|
||||||
static constexpr auto vertex = R"(
|
static constexpr auto vertex = R"(
|
||||||
layout(location = 0) in ivec2 position;
|
layout(location = 0) in ivec2 position;
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,12 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define COLLISION_SHADER_COMMON \
|
constexpr auto collisionShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idCollisionDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idCollisionDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idCollisionTilePropsUBO drawableReservedUBOCount
|
#define idCollisionTilePropsUBO drawableReservedUBOCount
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -22,7 +21,8 @@ struct ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = COLLISION_SHADER_COMMON R"(
|
static constexpr auto prelude = collisionShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
layout(location = 1) in ivec2 in_anchor_position;
|
layout(location = 1) in ivec2 in_anchor_position;
|
||||||
@@ -61,7 +61,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = COLLISION_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in float frag_placed;
|
layout(location = 0) in float frag_placed;
|
||||||
layout(location = 1) in float frag_notUsed;
|
layout(location = 1) in float frag_notUsed;
|
||||||
@@ -98,7 +98,8 @@ struct ShaderSource<BuiltIn::CollisionCircleShader, gfx::Backend::Type::Vulkan>
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = COLLISION_SHADER_COMMON R"(
|
static constexpr auto prelude = collisionShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
layout(location = 1) in ivec2 in_anchor_position;
|
layout(location = 1) in ivec2 in_anchor_position;
|
||||||
@@ -143,7 +144,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = COLLISION_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in float frag_placed;
|
layout(location = 0) in float frag_placed;
|
||||||
layout(location = 1) in float frag_notUsed;
|
layout(location = 1) in float frag_notUsed;
|
||||||
|
|||||||
57
include/mbgl/shaders/vulkan/custom_geometry.hpp
Normal file
57
include/mbgl/shaders/vulkan/custom_geometry.hpp
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mbgl/shaders/shader_source.hpp>
|
||||||
|
#include <mbgl/shaders/vulkan/shader_program.hpp>
|
||||||
|
|
||||||
|
namespace mbgl {
|
||||||
|
namespace shaders {
|
||||||
|
|
||||||
|
constexpr auto customGeometryShaderPrelude = R"(#define idCustomGeometryDrawableUBO drawableReservedUBOCount)";
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ShaderSource<BuiltIn::CustomGeometryShader, gfx::Backend::Type::Vulkan> {
|
||||||
|
static constexpr const char* name = "CustomGeometryShader";
|
||||||
|
|
||||||
|
static const std::array<AttributeInfo, 2> attributes;
|
||||||
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
|
static constexpr auto prelude = customGeometryShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
layout(location = 0) in vec3 in_position;
|
||||||
|
layout(location = 1) in vec2 in_texcoord;
|
||||||
|
|
||||||
|
layout(set = DRAWABLE_UBO_SET_INDEX, binding = idCustomGeometryDrawableUBO) uniform CustomDrawableDrawableUBO {
|
||||||
|
mat4 matrix;
|
||||||
|
vec4 color;
|
||||||
|
} drawable;
|
||||||
|
|
||||||
|
layout(location = 0) out vec2 frag_uv;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
frag_uv = in_texcoord;
|
||||||
|
|
||||||
|
gl_Position = drawable.matrix * vec4(in_position, 1.0);
|
||||||
|
applySurfaceTransform();
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
static constexpr auto fragment = R"(
|
||||||
|
layout(location = 0) in vec2 frag_uv;
|
||||||
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|
||||||
|
layout(set = DRAWABLE_UBO_SET_INDEX, binding = idCustomGeometryDrawableUBO) uniform CustomDrawableDrawableUBO {
|
||||||
|
mat4 matrix;
|
||||||
|
vec4 color;
|
||||||
|
} drawable;
|
||||||
|
|
||||||
|
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image_sampler;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
out_color = texture(image_sampler, frag_uv) * drawable.color;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace shaders
|
||||||
|
} // namespace mbgl
|
||||||
@@ -6,12 +6,7 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define CUSTOM_SYMBOL_ICON_SHADER_PRELUDE \
|
constexpr auto customSymbolIconShaderPrelude = R"(#define idCustomSymbolDrawableUBO idDrawableReservedVertexOnlyUBO)";
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idCustomSymbolDrawableUBO idDrawableReservedVertexOnlyUBO
|
|
||||||
|
|
||||||
)"
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -21,7 +16,8 @@ struct ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Vulkan>
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = CUSTOM_SYMBOL_ICON_SHADER_PRELUDE R"(
|
static constexpr auto prelude = customSymbolIconShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in vec2 in_position;
|
layout(location = 0) in vec2 in_position;
|
||||||
layout(location = 1) in vec2 in_tex;
|
layout(location = 1) in vec2 in_tex;
|
||||||
@@ -85,7 +81,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = CUSTOM_SYMBOL_ICON_SHADER_PRELUDE R"(
|
static constexpr auto fragment = R"(
|
||||||
layout(location = 0) in vec2 frag_tex;
|
layout(location = 0) in vec2 frag_tex;
|
||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,7 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define DEBUG_SHADER_PRELUDE \
|
constexpr auto debugShaderPrelude = R"(#define idDebugUBO drawableReservedUBOCount)";
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idDebugUBO drawableReservedUBOCount
|
|
||||||
|
|
||||||
)"
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -21,7 +16,8 @@ struct ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = DEBUG_SHADER_PRELUDE R"(
|
static constexpr auto prelude = debugShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
|
|
||||||
@@ -47,7 +43,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = DEBUG_SHADER_PRELUDE R"(
|
static constexpr auto fragment = R"(
|
||||||
layout(location = 0) in vec2 frag_uv;
|
layout(location = 0) in vec2 frag_uv;
|
||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,13 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define FILL_SHADER_COMMON \
|
constexpr auto fillShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idFillDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idFillDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idFillTilePropsUBO drawableReservedUBOCount
|
#define idFillTilePropsUBO drawableReservedUBOCount
|
||||||
#define idFillEvaluatedPropsUBO layerUBOStartId
|
#define idFillEvaluatedPropsUBO layerUBOStartId
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -23,7 +22,8 @@ struct ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = FILL_SHADER_COMMON R"(
|
static constexpr auto prelude = fillShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = FILL_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
#if !defined(HAS_UNIFORM_u_color)
|
#if !defined(HAS_UNIFORM_u_color)
|
||||||
layout(location = 0) in vec4 frag_color;
|
layout(location = 0) in vec4 frag_color;
|
||||||
@@ -125,7 +125,8 @@ struct ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = FILL_SHADER_COMMON R"(
|
static constexpr auto prelude = fillShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
|
|
||||||
@@ -183,7 +184,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = FILL_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
#if !defined(HAS_UNIFORM_u_outline_color)
|
#if !defined(HAS_UNIFORM_u_outline_color)
|
||||||
layout(location = 0) in vec4 frag_color;
|
layout(location = 0) in vec4 frag_color;
|
||||||
@@ -240,7 +241,8 @@ struct ShaderSource<BuiltIn::FillPatternShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = FILL_SHADER_COMMON R"(
|
static constexpr auto prelude = fillShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
|
|
||||||
@@ -352,7 +354,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = FILL_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in vec2 frag_pos_a;
|
layout(location = 0) in vec2 frag_pos_a;
|
||||||
layout(location = 1) in vec2 frag_pos_b;
|
layout(location = 1) in vec2 frag_pos_b;
|
||||||
@@ -451,7 +453,8 @@ struct ShaderSource<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::Vulka
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = FILL_SHADER_COMMON R"(
|
static constexpr auto prelude = fillShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
|
|
||||||
@@ -566,7 +569,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = FILL_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in vec2 frag_pos_a;
|
layout(location = 0) in vec2 frag_pos_a;
|
||||||
layout(location = 1) in vec2 frag_pos_b;
|
layout(location = 1) in vec2 frag_pos_b;
|
||||||
@@ -669,7 +672,8 @@ struct ShaderSource<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = FILL_SHADER_COMMON R"(
|
static constexpr auto prelude = fillShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_pos_normal;
|
layout(location = 0) in ivec2 in_pos_normal;
|
||||||
layout(location = 1) in uvec4 in_data;
|
layout(location = 1) in uvec4 in_data;
|
||||||
@@ -735,7 +739,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = FILL_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in float frag_width2;
|
layout(location = 0) in float frag_width2;
|
||||||
layout(location = 1) in vec2 frag_normal;
|
layout(location = 1) in vec2 frag_normal;
|
||||||
|
|||||||
@@ -6,14 +6,13 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define FILL_EXTRUSION_SHADER_COMMON \
|
constexpr auto fillExtrusionShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idFillExtrusionDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idFillExtrusionDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idFillExtrusionTilePropsUBO drawableReservedUBOCount
|
#define idFillExtrusionTilePropsUBO drawableReservedUBOCount
|
||||||
#define idFillExtrusionPropsUBO layerUBOStartId
|
#define idFillExtrusionPropsUBO layerUBOStartId
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -23,7 +22,8 @@ struct ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = FILL_EXTRUSION_SHADER_COMMON R"(
|
static constexpr auto prelude = fillExtrusionShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
layout(location = 1) in ivec4 in_normal_ed;
|
layout(location = 1) in ivec4 in_normal_ed;
|
||||||
@@ -151,7 +151,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = FILL_EXTRUSION_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in vec4 frag_color;
|
layout(location = 0) in vec4 frag_color;
|
||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
@@ -170,7 +170,8 @@ struct ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::Vul
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = FILL_EXTRUSION_SHADER_COMMON R"(
|
static constexpr auto prelude = fillExtrusionShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
layout(location = 1) in ivec4 in_normal_ed;
|
layout(location = 1) in ivec4 in_normal_ed;
|
||||||
@@ -336,7 +337,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = FILL_EXTRUSION_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in mediump vec4 frag_lighting;
|
layout(location = 0) in mediump vec4 frag_lighting;
|
||||||
layout(location = 1) in mediump vec2 frag_pos_a;
|
layout(location = 1) in mediump vec2 frag_pos_a;
|
||||||
|
|||||||
@@ -6,13 +6,12 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define HEATMAP_SHADER_PRELUDE \
|
constexpr auto heatmapShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idHeatmapDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idHeatmapDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idHeatmapEvaluatedPropsUBO layerUBOStartId
|
#define idHeatmapEvaluatedPropsUBO layerUBOStartId
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -22,7 +21,8 @@ struct ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = HEATMAP_SHADER_PRELUDE R"(
|
static constexpr auto prelude = heatmapShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
// Effective "0" in the kernel density texture to adjust the kernel size to;
|
// Effective "0" in the kernel density texture to adjust the kernel size to;
|
||||||
// this empirically chosen number minimizes artifacts on overlapping kernels
|
// this empirically chosen number minimizes artifacts on overlapping kernels
|
||||||
@@ -117,7 +117,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = HEATMAP_SHADER_PRELUDE R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
// Gaussian kernel coefficient: 1 / sqrt(2 * PI)
|
// Gaussian kernel coefficient: 1 / sqrt(2 * PI)
|
||||||
#define GAUSS_COEF 0.3989422804014327
|
#define GAUSS_COEF 0.3989422804014327
|
||||||
|
|||||||
@@ -6,12 +6,7 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define HEATMAP_TEXTURE_SHADER_PRELUDE \
|
constexpr auto heatmapTextureShaderPrelude = R"(#define idHeatmapTexturePropsUBO layerUBOStartId)";
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idHeatmapTexturePropsUBO layerUBOStartId
|
|
||||||
|
|
||||||
)"
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -21,7 +16,8 @@ struct ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 2> textures;
|
static const std::array<TextureInfo, 2> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = HEATMAP_TEXTURE_SHADER_PRELUDE R"(
|
static constexpr auto prelude = heatmapTextureShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
|
|
||||||
@@ -44,7 +40,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = HEATMAP_TEXTURE_SHADER_PRELUDE R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in vec2 frag_position;
|
layout(location = 0) in vec2 frag_position;
|
||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|||||||
@@ -6,14 +6,13 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define HILLSHADE_SHADER_PRELUDE \
|
constexpr auto hillshadeShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idHillshadeDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idHillshadeDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idHillshadeTilePropsUBO idDrawableReservedFragmentOnlyUBO
|
#define idHillshadeTilePropsUBO idDrawableReservedFragmentOnlyUBO
|
||||||
#define idHillshadeEvaluatedPropsUBO layerUBOStartId
|
#define idHillshadeEvaluatedPropsUBO layerUBOStartId
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::HillshadeShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::HillshadeShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -23,7 +22,8 @@ struct ShaderSource<BuiltIn::HillshadeShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = HILLSHADE_SHADER_PRELUDE R"(
|
static constexpr auto prelude = hillshadeShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
layout(location = 1) in ivec2 in_texture_position;
|
layout(location = 1) in ivec2 in_texture_position;
|
||||||
@@ -53,7 +53,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = HILLSHADE_SHADER_PRELUDE R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in vec2 frag_position;
|
layout(location = 0) in vec2 frag_position;
|
||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|||||||
@@ -6,13 +6,12 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define HILLSHADE_PREPARE_SHADER_PRELUDE \
|
constexpr auto hillshadePrepareShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idHillshadePrepareDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idHillshadePrepareDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idHillshadePrepareTilePropsUBO drawableReservedUBOCount
|
#define idHillshadePrepareTilePropsUBO drawableReservedUBOCount
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -22,7 +21,8 @@ struct ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::Vulkan>
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = HILLSHADE_PREPARE_SHADER_PRELUDE R"(
|
static constexpr auto prelude = hillshadePrepareShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
layout(location = 1) in ivec2 in_texture_position;
|
layout(location = 1) in ivec2 in_texture_position;
|
||||||
@@ -51,7 +51,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = HILLSHADE_PREPARE_SHADER_PRELUDE R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in vec2 frag_position;
|
layout(location = 0) in vec2 frag_position;
|
||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|||||||
@@ -6,14 +6,13 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define LINE_SHADER_COMMON \
|
constexpr auto lineShadePrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idLineDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idLineDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idLineTilePropsUBO idDrawableReservedFragmentOnlyUBO
|
#define idLineTilePropsUBO idDrawableReservedFragmentOnlyUBO
|
||||||
#define idLineEvaluatedPropsUBO layerUBOStartId
|
#define idLineEvaluatedPropsUBO layerUBOStartId
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -23,7 +22,8 @@ struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = LINE_SHADER_COMMON R"(
|
static constexpr auto prelude = lineShadePrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_pos_normal;
|
layout(location = 0) in ivec2 in_pos_normal;
|
||||||
layout(location = 1) in uvec4 in_data;
|
layout(location = 1) in uvec4 in_data;
|
||||||
@@ -182,7 +182,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = LINE_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in lowp vec2 frag_normal;
|
layout(location = 0) in lowp vec2 frag_normal;
|
||||||
layout(location = 1) in lowp vec2 frag_width2;
|
layout(location = 1) in lowp vec2 frag_width2;
|
||||||
@@ -261,7 +261,8 @@ struct ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = LINE_SHADER_COMMON R"(
|
static constexpr auto prelude = lineShadePrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_pos_normal;
|
layout(location = 0) in ivec2 in_pos_normal;
|
||||||
layout(location = 1) in uvec4 in_data;
|
layout(location = 1) in uvec4 in_data;
|
||||||
@@ -410,7 +411,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = LINE_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in lowp vec2 frag_normal;
|
layout(location = 0) in lowp vec2 frag_normal;
|
||||||
layout(location = 1) in lowp vec2 frag_width2;
|
layout(location = 1) in lowp vec2 frag_width2;
|
||||||
@@ -486,7 +487,8 @@ struct ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = LINE_SHADER_COMMON R"(
|
static constexpr auto prelude = lineShadePrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_pos_normal;
|
layout(location = 0) in ivec2 in_pos_normal;
|
||||||
layout(location = 1) in uvec4 in_data;
|
layout(location = 1) in uvec4 in_data;
|
||||||
@@ -660,7 +662,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = LINE_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in lowp vec2 frag_normal;
|
layout(location = 0) in lowp vec2 frag_normal;
|
||||||
layout(location = 1) in lowp vec2 frag_width2;
|
layout(location = 1) in lowp vec2 frag_width2;
|
||||||
@@ -802,7 +804,8 @@ struct ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = LINE_SHADER_COMMON R"(
|
static constexpr auto prelude = lineShadePrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_pos_normal;
|
layout(location = 0) in ivec2 in_pos_normal;
|
||||||
layout(location = 1) in uvec4 in_data;
|
layout(location = 1) in uvec4 in_data;
|
||||||
@@ -987,7 +990,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = LINE_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in lowp vec2 frag_normal;
|
layout(location = 0) in lowp vec2 frag_normal;
|
||||||
layout(location = 1) in lowp vec2 frag_width2;
|
layout(location = 1) in lowp vec2 frag_width2;
|
||||||
|
|||||||
@@ -6,12 +6,7 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define LOCATION_INDICATOR_SHADER_PRELUDE \
|
constexpr auto locationIndicatorShaderPrelude = R"(#define idLocationIndicatorDrawableUBO drawableReservedUBOCount)";
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idLocationIndicatorDrawableUBO drawableReservedUBOCount
|
|
||||||
|
|
||||||
)"
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::LocationIndicatorShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::LocationIndicatorShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -21,7 +16,8 @@ struct ShaderSource<BuiltIn::LocationIndicatorShader, gfx::Backend::Type::Vulkan
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = LOCATION_INDICATOR_SHADER_PRELUDE R"(
|
static constexpr auto prelude = locationIndicatorShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
layout(location = 0) in vec2 in_position;
|
layout(location = 0) in vec2 in_position;
|
||||||
|
|
||||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = idLocationIndicatorDrawableUBO) uniform LocationIndicatorDrawableUBO {
|
layout(set = DRAWABLE_UBO_SET_INDEX, binding = idLocationIndicatorDrawableUBO) uniform LocationIndicatorDrawableUBO {
|
||||||
@@ -35,7 +31,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = LOCATION_INDICATOR_SHADER_PRELUDE R"(
|
static constexpr auto fragment = R"(
|
||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|
||||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = idLocationIndicatorDrawableUBO) uniform LocationIndicatorDrawableUBO {
|
layout(set = DRAWABLE_UBO_SET_INDEX, binding = idLocationIndicatorDrawableUBO) uniform LocationIndicatorDrawableUBO {
|
||||||
@@ -57,7 +53,8 @@ struct ShaderSource<BuiltIn::LocationIndicatorTexturedShader, gfx::Backend::Type
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = LOCATION_INDICATOR_SHADER_PRELUDE R"(
|
static constexpr auto prelude = locationIndicatorShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
layout(location = 0) in vec2 in_position;
|
layout(location = 0) in vec2 in_position;
|
||||||
layout(location = 1) in vec2 in_texcoord;
|
layout(location = 1) in vec2 in_texcoord;
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,12 @@
|
|||||||
#include <mbgl/shaders/shader_source.hpp>
|
#include <mbgl/shaders/shader_source.hpp>
|
||||||
#include <mbgl/shaders/vulkan/shader_program.hpp>
|
#include <mbgl/shaders/vulkan/shader_program.hpp>
|
||||||
|
|
||||||
#define RASTER_SHADER_PRELUDE \
|
constexpr auto rasterShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idRasterDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idRasterDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idRasterEvaluatedPropsUBO layerUBOStartId
|
#define idRasterEvaluatedPropsUBO layerUBOStartId
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
@@ -22,7 +21,8 @@ struct ShaderSource<BuiltIn::RasterShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 2> textures;
|
static const std::array<TextureInfo, 2> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = RASTER_SHADER_PRELUDE R"(
|
static constexpr auto prelude = rasterShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec2 in_position;
|
layout(location = 0) in ivec2 in_position;
|
||||||
layout(location = 1) in ivec2 in_texture_position;
|
layout(location = 1) in ivec2 in_texture_position;
|
||||||
@@ -73,7 +73,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = RASTER_SHADER_PRELUDE R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in vec2 frag_position0;
|
layout(location = 0) in vec2 frag_position0;
|
||||||
layout(location = 1) in vec2 frag_position1;
|
layout(location = 1) in vec2 frag_position1;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
std::string_view /*firstAttribName*/) override {
|
std::string_view /*firstAttribName*/) override {
|
||||||
using ShaderSource = shaders::ShaderSource<ShaderID, gfx::Backend::Type::Vulkan>;
|
using ShaderSource = shaders::ShaderSource<ShaderID, gfx::Backend::Type::Vulkan>;
|
||||||
constexpr auto& name = ShaderSource::name;
|
constexpr auto& name = ShaderSource::name;
|
||||||
|
constexpr auto& prelude = ShaderSource::prelude;
|
||||||
constexpr auto& vert = ShaderSource::vertex;
|
constexpr auto& vert = ShaderSource::vertex;
|
||||||
constexpr auto& frag = ShaderSource::fragment;
|
constexpr auto& frag = ShaderSource::fragment;
|
||||||
|
|
||||||
@@ -60,8 +61,13 @@ public:
|
|||||||
DefinesMap additionalDefines;
|
DefinesMap additionalDefines;
|
||||||
addAdditionalDefines(propertiesAsUniforms, additionalDefines);
|
addAdditionalDefines(propertiesAsUniforms, additionalDefines);
|
||||||
|
|
||||||
|
const std::string preludeSource(prelude);
|
||||||
|
const std::string vertexSource = preludeSource + vert;
|
||||||
|
const std::string fragmentSource = preludeSource + frag;
|
||||||
|
|
||||||
auto& context = static_cast<Context&>(gfxContext);
|
auto& context = static_cast<Context&>(gfxContext);
|
||||||
shader = context.createProgram(ShaderID, shaderName, vert, frag, programParameters, additionalDefines);
|
shader = context.createProgram(
|
||||||
|
ShaderID, shaderName, vertexSource, fragmentSource, programParameters, additionalDefines);
|
||||||
assert(shader);
|
assert(shader);
|
||||||
if (!shader || !registerShader(shader, shaderName)) {
|
if (!shader || !registerShader(shader, shaderName)) {
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|||||||
@@ -6,14 +6,13 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define SYMBOL_SHADER_COMMON \
|
constexpr auto symbolShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idSymbolDrawableUBO idDrawableReservedVertexOnlyUBO
|
#define idSymbolDrawableUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idSymbolTilePropsUBO idDrawableReservedFragmentOnlyUBO
|
#define idSymbolTilePropsUBO idDrawableReservedFragmentOnlyUBO
|
||||||
#define idSymbolEvaluatedPropsUBO layerUBOStartId
|
#define idSymbolEvaluatedPropsUBO layerUBOStartId
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -23,7 +22,8 @@ struct ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = SYMBOL_SHADER_COMMON R"(
|
static constexpr auto prelude = symbolShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec4 in_pos_offset;
|
layout(location = 0) in ivec4 in_pos_offset;
|
||||||
layout(location = 1) in uvec4 in_data;
|
layout(location = 1) in uvec4 in_data;
|
||||||
@@ -144,7 +144,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = SYMBOL_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in mediump vec2 frag_tex;
|
layout(location = 0) in mediump vec2 frag_tex;
|
||||||
layout(location = 1) in mediump float frag_opacity;
|
layout(location = 1) in mediump float frag_opacity;
|
||||||
@@ -210,7 +210,8 @@ struct ShaderSource<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 1> textures;
|
static const std::array<TextureInfo, 1> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = SYMBOL_SHADER_COMMON R"(
|
static constexpr auto prelude = symbolShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
layout(location = 0) in ivec4 in_pos_offset;
|
layout(location = 0) in ivec4 in_pos_offset;
|
||||||
layout(location = 1) in uvec4 in_data;
|
layout(location = 1) in uvec4 in_data;
|
||||||
@@ -386,7 +387,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = SYMBOL_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in mediump vec2 frag_tex;
|
layout(location = 0) in mediump vec2 frag_tex;
|
||||||
layout(location = 1) in mediump float frag_fade_opacity;
|
layout(location = 1) in mediump float frag_fade_opacity;
|
||||||
@@ -504,7 +505,8 @@ struct ShaderSource<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::Vulkan
|
|||||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||||
static const std::array<TextureInfo, 2> textures;
|
static const std::array<TextureInfo, 2> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = SYMBOL_SHADER_COMMON R"(
|
static constexpr auto prelude = symbolShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
#define SDF 1.0
|
#define SDF 1.0
|
||||||
#define ICON 0.0
|
#define ICON 0.0
|
||||||
@@ -687,7 +689,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = SYMBOL_SHADER_COMMON R"(
|
static constexpr auto fragment = R"(
|
||||||
|
|
||||||
layout(location = 0) in mediump vec2 frag_tex;
|
layout(location = 0) in mediump vec2 frag_tex;
|
||||||
layout(location = 1) in mediump float frag_fade_opacity;
|
layout(location = 1) in mediump float frag_fade_opacity;
|
||||||
|
|||||||
@@ -6,13 +6,12 @@
|
|||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace shaders {
|
namespace shaders {
|
||||||
|
|
||||||
#define WIDEVECTOR_SHADER_PRELUDE \
|
constexpr auto wideVectorShaderPrelude = R"(
|
||||||
R"(
|
|
||||||
|
|
||||||
#define idWideVectorUniformsUBO idDrawableReservedVertexOnlyUBO
|
#define idWideVectorUniformsUBO idDrawableReservedVertexOnlyUBO
|
||||||
#define idWideVectorUniformWideVecUBO drawableReservedUBOCount
|
#define idWideVectorUniformWideVecUBO drawableReservedUBOCount
|
||||||
|
|
||||||
)"
|
)";
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct ShaderSource<BuiltIn::WideVectorShader, gfx::Backend::Type::Vulkan> {
|
struct ShaderSource<BuiltIn::WideVectorShader, gfx::Backend::Type::Vulkan> {
|
||||||
@@ -22,7 +21,8 @@ struct ShaderSource<BuiltIn::WideVectorShader, gfx::Backend::Type::Vulkan> {
|
|||||||
static const std::array<AttributeInfo, 4> instanceAttributes;
|
static const std::array<AttributeInfo, 4> instanceAttributes;
|
||||||
static const std::array<TextureInfo, 0> textures;
|
static const std::array<TextureInfo, 0> textures;
|
||||||
|
|
||||||
static constexpr auto vertex = WIDEVECTOR_SHADER_PRELUDE R"(
|
static constexpr auto prelude = wideVectorShaderPrelude;
|
||||||
|
static constexpr auto vertex = R"(
|
||||||
|
|
||||||
/** Expressions are used to change values like width and opacity over zoom levels. **/
|
/** Expressions are used to change values like width and opacity over zoom levels. **/
|
||||||
#define WKSExpStops 8
|
#define WKSExpStops 8
|
||||||
@@ -58,7 +58,7 @@ layout(set = DRAWABLE_UBO_SET_INDEX, binding = idWideVectorUniformWideVecUBO) un
|
|||||||
float offset;
|
float offset;
|
||||||
float edge;
|
float edge;
|
||||||
float texRepeat;
|
float texRepeat;
|
||||||
vec4 texOffset;
|
vec2 texOffset;
|
||||||
float miterLimit;
|
float miterLimit;
|
||||||
int join;
|
int join;
|
||||||
int cap;
|
int cap;
|
||||||
@@ -66,6 +66,17 @@ layout(set = DRAWABLE_UBO_SET_INDEX, binding = idWideVectorUniformWideVecUBO) un
|
|||||||
float interClipLimit;
|
float interClipLimit;
|
||||||
} wideVec;
|
} wideVec;
|
||||||
|
|
||||||
|
// Instance info for the wide vector (new) vertex shader
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
// Center of the point on the line
|
||||||
|
vec3 center;
|
||||||
|
// Color
|
||||||
|
vec4 color;
|
||||||
|
// Used to track loops and such
|
||||||
|
int prev,next; // set to -1 for non-loops
|
||||||
|
} VertexTriWideVecInstance;
|
||||||
|
|
||||||
struct IntersectInfo {
|
struct IntersectInfo {
|
||||||
bool valid;
|
bool valid;
|
||||||
vec2 interPt;
|
vec2 interPt;
|
||||||
@@ -110,16 +121,28 @@ IntersectInfo intersectWideLines(vec2 p0,vec2 p1,vec2 p2, vec2 n0,vec2 n1)
|
|||||||
return intersectLines(p0 + n0, p1 + n0, p1 + n1, p2 + n1);
|
return intersectLines(p0 + n0, p1 + n0, p1 + n1, p2 + n1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used to track what info we have about a center point
|
||||||
|
struct CenterInfo {
|
||||||
|
/// Screen coordinates of the line segment endpoint
|
||||||
|
vec2 screenPos;
|
||||||
|
/// Length of the segment (in screen coordinates)
|
||||||
|
float len;
|
||||||
|
/// Normalized direction of the segment
|
||||||
|
vec2 nDir;
|
||||||
|
/// Normalized plane normal, perpendicular to the segment
|
||||||
|
vec2 norm;
|
||||||
|
};
|
||||||
|
|
||||||
vec3 viewPos(const mat4 &mat, vec3 vec) {
|
vec3 viewPos(const mat4 &mat, vec3 vec) {
|
||||||
const vec4 p = mat * vec4(vec, 1.0);
|
const vec4 p = mat * vec4(vec, 1.0);
|
||||||
return p.xyz; // / p.w; ?
|
return p.xyz; // / p.w; ?
|
||||||
}
|
}
|
||||||
|
|
||||||
float2 screenPos_MVP(const Uniforms &u, float3 viewPos) {
|
vec2 screenPos_MVP(const Uniforms &u, vec3 viewPos) {
|
||||||
const float4 p4 = float4(viewPos, 1.0);
|
const vec4 p4 = vec4(viewPos, 1.0);
|
||||||
|
|
||||||
// Use the MVP matrix
|
// Use the MVP matrix
|
||||||
const float4 s = u.mvpMatrix * p4;
|
const vec4 s = u.mvpMatrix * p4;
|
||||||
|
|
||||||
return s.xy / s.w;
|
return s.xy / s.w;
|
||||||
}
|
}
|
||||||
@@ -156,7 +179,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
static constexpr auto fragment = WIDEVECTOR_SHADER_PRELUDE R"(
|
static constexpr auto fragment = R"(
|
||||||
// TODO
|
// TODO
|
||||||
)";
|
)";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,17 +35,17 @@ class CustomDrawableLayerHost::Interface {
|
|||||||
public:
|
public:
|
||||||
enum class LineShaderType {
|
enum class LineShaderType {
|
||||||
Classic,
|
Classic,
|
||||||
MetalWideVector
|
WideVector
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LineOptions {
|
struct LineOptions {
|
||||||
gfx::PolylineGeneratorOptions geometry;
|
gfx::PolylineGeneratorOptions geometry;
|
||||||
|
|
||||||
float blur = 0.f;
|
float blur = 0.f;
|
||||||
float opacity = 1.f;
|
float opacity = 1.f;
|
||||||
float gapWidth = 0.f;
|
float gapWidth = 0.f;
|
||||||
float offset = 0.f;
|
float offset = 0.f;
|
||||||
float width = 1.f;
|
float width = 1.f;
|
||||||
LineShaderType shaderType = LineShaderType::Classic;
|
|
||||||
Color color;
|
Color color;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,12 +58,30 @@ public:
|
|||||||
Size size;
|
Size size;
|
||||||
gfx::Texture2DPtr texture;
|
gfx::Texture2DPtr texture;
|
||||||
std::array<float, 2> anchor{0.5f, 0.5f};
|
std::array<float, 2> anchor{0.5f, 0.5f};
|
||||||
std::array<std::array<float, 2>, 2> textureCoordinates{{{0, 0}, {1, 1}}};
|
|
||||||
float angleDegrees{.0f};
|
float angleDegrees{.0f};
|
||||||
bool scaleWithMap{false};
|
bool scaleWithMap{false};
|
||||||
bool pitchWithMap{false};
|
bool pitchWithMap{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GeometryVertex {
|
||||||
|
std::array<float, 3> position;
|
||||||
|
std::array<float, 2> texcoords;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GeometryOptions {
|
||||||
|
mat4 matrix = matrix::identity4();
|
||||||
|
Color color = Color::white();
|
||||||
|
gfx::Texture2DPtr texture;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using TweakerCallback = std::function<void(mbgl::gfx::Drawable&, const mbgl::PaintParameters&, T&)>;
|
||||||
|
|
||||||
|
using LineTweakerCallback = TweakerCallback<LineOptions>;
|
||||||
|
using FillTweakerCallback = TweakerCallback<FillOptions>;
|
||||||
|
using SymbolTweakerCallback = TweakerCallback<SymbolOptions>;
|
||||||
|
using GeometryTweakerCallback = TweakerCallback<GeometryOptions>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @brief Construct a new Interface object (internal core use only)
|
/// @brief Construct a new Interface object (internal core use only)
|
||||||
Interface(RenderLayer& layer,
|
Interface(RenderLayer& layer,
|
||||||
@@ -109,37 +127,59 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setSymbolOptions(const SymbolOptions& options);
|
void setSymbolOptions(const SymbolOptions& options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the geometry options
|
||||||
|
*
|
||||||
|
* @param options
|
||||||
|
*/
|
||||||
|
void setGeometryOptions(const GeometryOptions& options);
|
||||||
|
|
||||||
|
void setLineTweakerCallback(LineTweakerCallback&& callback) { lineTweakerCallback = callback; }
|
||||||
|
void setFillTweakerCallback(FillTweakerCallback&& callback) { fillTweakerCallback = callback; }
|
||||||
|
void setSymbolTweakerCallback(SymbolTweakerCallback&& callback) { symbolTweakerCallback = callback; }
|
||||||
|
void setGeometryTweakerCallback(GeometryTweakerCallback&& callback) { geometryTweakerCallback = callback; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Add a polyline
|
* @brief Add a polyline
|
||||||
*
|
*
|
||||||
* @param coordinates in tile range
|
* @param coordinates in tile range
|
||||||
* @return true if the polyline was added
|
* @param shaderType
|
||||||
|
* @return a valid util::SimpleIdentity if the polyline was added
|
||||||
*/
|
*/
|
||||||
bool addPolyline(const GeometryCoordinates& coordinates);
|
util::SimpleIdentity addPolyline(const GeometryCoordinates& coordinates,
|
||||||
|
LineShaderType shaderType = LineShaderType::Classic);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Add a polyline
|
* @brief Add a polyline
|
||||||
*
|
*
|
||||||
* @param coordinates Geographic coordinates
|
* @param coordinates Geographic coordinates
|
||||||
* @return true if the polyline was added
|
* @param shaderType
|
||||||
|
* @return a valid util::SimpleIdentity if the poline was added
|
||||||
*/
|
*/
|
||||||
bool addPolyline(const LineString<double>& coordinates);
|
util::SimpleIdentity addPolyline(const LineString<double>& coordinates,
|
||||||
|
LineShaderType shaderType = LineShaderType::Classic);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Add a multipolygon area fill
|
* @brief Add a multipolygon area fill
|
||||||
*
|
*
|
||||||
* @param geometry a collection of rings with optional holes
|
* @param geometry a collection of rings with optional holes
|
||||||
* @return true if the fill was added
|
* @return a valid util::SimpleIdentity if the fill was added
|
||||||
*/
|
*/
|
||||||
bool addFill(const GeometryCollection& geometry);
|
util::SimpleIdentity addFill(const GeometryCollection& geometry);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Add a symbol
|
* @brief Add a symbol
|
||||||
*
|
*
|
||||||
* @param point
|
* @param point
|
||||||
* @return true if the symbol was added
|
* @param textureCoordinates (optional mapping)
|
||||||
|
* @return a valid util::SimpleIdentity if the symbol was added
|
||||||
*/
|
*/
|
||||||
bool addSymbol(const GeometryCoordinate& point);
|
util::SimpleIdentity addSymbol(const GeometryCoordinate& point,
|
||||||
|
const std::array<std::array<float, 2>, 2>& textureCoordinates = {{{0, 0}, {1, 1}}});
|
||||||
|
|
||||||
|
util::SimpleIdentity addGeometry(std::shared_ptr<gfx::VertexVector<GeometryVertex>> vertices,
|
||||||
|
std::shared_ptr<gfx::IndexVector<gfx::Triangles>> indices,
|
||||||
|
bool is3D);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Finish the current drawable building session
|
* @brief Finish the current drawable building session
|
||||||
@@ -147,6 +187,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
void finish();
|
void finish();
|
||||||
|
|
||||||
|
void removeDrawable(const util::SimpleIdentity& id);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RenderLayer& layer;
|
RenderLayer& layer;
|
||||||
LayerGroupBasePtr& layerGroup;
|
LayerGroupBasePtr& layerGroup;
|
||||||
@@ -162,13 +204,15 @@ private:
|
|||||||
gfx::ShaderPtr lineShaderWideVector() const;
|
gfx::ShaderPtr lineShaderWideVector() const;
|
||||||
gfx::ShaderPtr fillShaderDefault() const;
|
gfx::ShaderPtr fillShaderDefault() const;
|
||||||
gfx::ShaderPtr symbolShaderDefault() const;
|
gfx::ShaderPtr symbolShaderDefault() const;
|
||||||
|
gfx::ShaderPtr geometryShaderDefault() const;
|
||||||
|
|
||||||
enum class BuilderType {
|
enum class BuilderType {
|
||||||
None,
|
None,
|
||||||
LineClassic,
|
LineClassic,
|
||||||
LineWideVector,
|
LineWideVector,
|
||||||
Fill,
|
Fill,
|
||||||
Symbol
|
Symbol,
|
||||||
|
Geometry
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<gfx::DrawableBuilder> createBuilder(const std::string& name, gfx::ShaderPtr shader) const;
|
std::unique_ptr<gfx::DrawableBuilder> createBuilder(const std::string& name, gfx::ShaderPtr shader) const;
|
||||||
@@ -177,13 +221,15 @@ private:
|
|||||||
std::unique_ptr<gfx::DrawableBuilder> builder;
|
std::unique_ptr<gfx::DrawableBuilder> builder;
|
||||||
std::optional<OverscaledTileID> tileID;
|
std::optional<OverscaledTileID> tileID;
|
||||||
|
|
||||||
gfx::ShaderPtr lineShader;
|
|
||||||
gfx::ShaderPtr fillShader;
|
|
||||||
gfx::ShaderPtr symbolShader;
|
|
||||||
|
|
||||||
LineOptions lineOptions;
|
LineOptions lineOptions;
|
||||||
FillOptions fillOptions;
|
FillOptions fillOptions;
|
||||||
SymbolOptions symbolOptions;
|
SymbolOptions symbolOptions;
|
||||||
|
GeometryOptions geometryOptions;
|
||||||
|
|
||||||
|
LineTweakerCallback lineTweakerCallback;
|
||||||
|
FillTweakerCallback fillTweakerCallback;
|
||||||
|
SymbolTweakerCallback symbolTweakerCallback;
|
||||||
|
GeometryTweakerCallback geometryTweakerCallback;
|
||||||
|
|
||||||
BuilderType builderType{BuilderType::None};
|
BuilderType builderType{BuilderType::None};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class Texture2D;
|
|||||||
|
|
||||||
using UniqueShaderProgram = std::unique_ptr<ShaderProgram>;
|
using UniqueShaderProgram = std::unique_ptr<ShaderProgram>;
|
||||||
using UniqueVertexBufferResource = std::unique_ptr<VertexBufferResource>;
|
using UniqueVertexBufferResource = std::unique_ptr<VertexBufferResource>;
|
||||||
|
using UniqueUniformBufferArray = std::unique_ptr<gfx::UniformBufferArray>;
|
||||||
|
|
||||||
class Context final : public gfx::Context {
|
class Context final : public gfx::Context {
|
||||||
public:
|
public:
|
||||||
@@ -79,6 +80,8 @@ public:
|
|||||||
bool persistent,
|
bool persistent,
|
||||||
bool ssbo = false) override;
|
bool ssbo = false) override;
|
||||||
|
|
||||||
|
UniqueUniformBufferArray createLayerUniformBufferArray() override;
|
||||||
|
|
||||||
gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override;
|
gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override;
|
||||||
|
|
||||||
TileLayerGroupPtr createTileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) override;
|
TileLayerGroupPtr createTileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) override;
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ public:
|
|||||||
void upload(gfx::UploadPass&) override;
|
void upload(gfx::UploadPass&) override;
|
||||||
void render(RenderOrchestrator&, PaintParameters&) override;
|
void render(RenderOrchestrator&, PaintParameters&) override;
|
||||||
|
|
||||||
const gfx::UniformBufferArray& getUniformBuffers() const override { return uniformBuffers; };
|
const gfx::UniformBufferArray& getUniformBuffers() const override { return uniformBuffers; }
|
||||||
gfx::UniformBufferArray& mutableUniformBuffers() override { return uniformBuffers; };
|
gfx::UniformBufferArray& mutableUniformBuffers() override { return uniformBuffers; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UniformBufferArray uniformBuffers;
|
UniformBufferArray uniformBuffers;
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ public:
|
|||||||
void createOrUpdate(
|
void createOrUpdate(
|
||||||
const size_t id, const void* data, std::size_t size, gfx::Context& context, bool persistent = false) override;
|
const size_t id, const void* data, std::size_t size, gfx::Context& context, bool persistent = false) override;
|
||||||
|
|
||||||
|
void bind(gfx::RenderPass& renderPass) override;
|
||||||
|
|
||||||
void bindDescriptorSets(CommandEncoder& encoder);
|
void bindDescriptorSets(CommandEncoder& encoder);
|
||||||
void freeDescriptorSets() { descriptorSet.reset(); }
|
void freeDescriptorSets() { descriptorSet.reset(); }
|
||||||
|
|
||||||
|
|||||||
@@ -58,12 +58,12 @@ public:
|
|||||||
|
|
||||||
constexpr auto numLines = 6;
|
constexpr auto numLines = 6;
|
||||||
Interface::LineOptions options[numLines] {
|
Interface::LineOptions options[numLines] {
|
||||||
{/*geometry=*/{}, /*blur=*/0.0f, /*opacity=*/1.0f, /*gapWidth=*/0.0f, /*offset=*/0.0f, /*width=*/8.0f, /*shaderType=*/{}, /*color=*/Color::red() },
|
{/*geometry=*/{}, /*blur=*/0.0f, /*opacity=*/1.0f, /*gapWidth=*/0.0f, /*offset=*/0.0f, /*width=*/8.0f, /*color=*/Color::red() },
|
||||||
{/*geometry=*/{}, /*blur=*/4.0f, /*opacity=*/1.0f, /*gapWidth=*/2.0f, /*offset=*/-1.0f, /*width=*/4.0f, /*shaderType=*/{}, /*color=*/Color::blue() },
|
{/*geometry=*/{}, /*blur=*/4.0f, /*opacity=*/1.0f, /*gapWidth=*/2.0f, /*offset=*/-1.0f, /*width=*/4.0f, /*color=*/Color::blue() },
|
||||||
{/*geometry=*/{}, /*blur=*/16.0f, /*opacity=*/1.0f, /*gapWidth=*/1.0f, /*offset=*/2.0f, /*width=*/16.0f, /*shaderType=*/{}, /*color=*/Color(1.f, 0.5f, 0, 0.5f) },
|
{/*geometry=*/{}, /*blur=*/16.0f, /*opacity=*/1.0f, /*gapWidth=*/1.0f, /*offset=*/2.0f, /*width=*/16.0f, /*color=*/Color(1.f, 0.5f, 0, 0.5f) },
|
||||||
{/*geometry=*/{}, /*blur=*/2.0f, /*opacity=*/1.0f, /*gapWidth=*/1.0f, /*offset=*/-2.0f, /*width=*/2.0f, /*shaderType=*/{}, /*color=*/Color(1.f, 1.f, 0, 0.3f) },
|
{/*geometry=*/{}, /*blur=*/2.0f, /*opacity=*/1.0f, /*gapWidth=*/1.0f, /*offset=*/-2.0f, /*width=*/2.0f, /*color=*/Color(1.f, 1.f, 0, 0.3f) },
|
||||||
{/*geometry=*/{}, /*blur=*/0.5f, /*opacity=*/0.5f, /*gapWidth=*/1.0f, /*offset=*/0.5f, /*width=*/0.5f, /*shaderType=*/{}, /*color=*/Color::black() },
|
{/*geometry=*/{}, /*blur=*/0.5f, /*opacity=*/0.5f, /*gapWidth=*/1.0f, /*offset=*/0.5f, /*width=*/0.5f, /*color=*/Color::black() },
|
||||||
{/*geometry=*/{}, /*blur=*/24.0f, /*opacity=*/0.5f, /*gapWidth=*/1.0f, /*offset=*/-5.0f, /*width=*/24.0f, /*shaderType=*/{}, /*color=*/Color(1.f, 0, 1.f, 0.2f) },
|
{/*geometry=*/{}, /*blur=*/24.0f, /*opacity=*/0.5f, /*gapWidth=*/1.0f, /*offset=*/-5.0f, /*width=*/24.0f, /*color=*/Color(1.f, 0, 1.f, 0.2f) },
|
||||||
};
|
};
|
||||||
for(auto& opt: options) {
|
for(auto& opt: options) {
|
||||||
opt.geometry.beginCap = style::LineCapType::Butt;
|
opt.geometry.beginCap = style::LineCapType::Butt;
|
||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
interface.setLineOptions(options[index]);
|
interface.setLineOptions(options[index]);
|
||||||
|
|
||||||
// add polyline
|
// add polyline
|
||||||
interface.addPolyline(polyline);
|
interface.addPolyline(polyline, Interface::LineShaderType::Classic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,12 +99,12 @@ public:
|
|||||||
|
|
||||||
constexpr auto numLines = 6;
|
constexpr auto numLines = 6;
|
||||||
Interface::LineOptions options[numLines] {
|
Interface::LineOptions options[numLines] {
|
||||||
{/*geometry=*/{}, /*blur=*/0.0f, /*opacity=*/1.0f, /*gapWidth=*/0.0f, /*offset=*/0.0f, /*width=*/8.0f, /*shaderType=*/Interface::LineShaderType::MetalWideVector, /*color=*/Color::red() },
|
{/*geometry=*/{}, /*blur=*/0.0f, /*opacity=*/1.0f, /*gapWidth=*/0.0f, /*offset=*/0.0f, /*width=*/8.0f, /*color=*/Color::red() },
|
||||||
{/*geometry=*/{}, /*blur=*/4.0f, /*opacity=*/1.0f, /*gapWidth=*/2.0f, /*offset=*/-1.0f, /*width=*/4.0f, /*shaderType=*/Interface::LineShaderType::MetalWideVector, /*color=*/Color::blue() },
|
{/*geometry=*/{}, /*blur=*/4.0f, /*opacity=*/1.0f, /*gapWidth=*/2.0f, /*offset=*/-1.0f, /*width=*/4.0f, /*color=*/Color::blue() },
|
||||||
{/*geometry=*/{}, /*blur=*/16.0f, /*opacity=*/1.0f, /*gapWidth=*/1.0f, /*offset=*/2.0f, /*width=*/16.0f, /*shaderType=*/Interface::LineShaderType::MetalWideVector, /*color=*/Color(1.f, 0.5f, 0, 0.5f) },
|
{/*geometry=*/{}, /*blur=*/16.0f, /*opacity=*/1.0f, /*gapWidth=*/1.0f, /*offset=*/2.0f, /*width=*/16.0f, /*color=*/Color(1.f, 0.5f, 0, 0.5f) },
|
||||||
{/*geometry=*/{}, /*blur=*/2.0f, /*opacity=*/1.0f, /*gapWidth=*/1.0f, /*offset=*/-2.0f, /*width=*/2.0f, /*shaderType=*/Interface::LineShaderType::MetalWideVector, /*color=*/Color(1.f, 1.f, 0, 0.3f) },
|
{/*geometry=*/{}, /*blur=*/2.0f, /*opacity=*/1.0f, /*gapWidth=*/1.0f, /*offset=*/-2.0f, /*width=*/2.0f, /*color=*/Color(1.f, 1.f, 0, 0.3f) },
|
||||||
{/*geometry=*/{}, /*blur=*/0.5f, /*opacity=*/0.5f, /*gapWidth=*/1.0f, /*offset=*/0.5f, /*width=*/0.5f, /*shaderType=*/Interface::LineShaderType::MetalWideVector, /*color=*/Color::black() },
|
{/*geometry=*/{}, /*blur=*/0.5f, /*opacity=*/0.5f, /*gapWidth=*/1.0f, /*offset=*/0.5f, /*width=*/0.5f, /*color=*/Color::black() },
|
||||||
{/*geometry=*/{}, /*blur=*/24.0f, /*opacity=*/0.5f, /*gapWidth=*/1.0f, /*offset=*/-5.0f, /*width=*/24.0f, /*shaderType=*/Interface::LineShaderType::MetalWideVector, /*color=*/Color(1.f, 0, 1.f, 0.2f) },
|
{/*geometry=*/{}, /*blur=*/24.0f, /*opacity=*/0.5f, /*gapWidth=*/1.0f, /*offset=*/-5.0f, /*width=*/24.0f, /*color=*/Color(1.f, 0, 1.f, 0.2f) },
|
||||||
};
|
};
|
||||||
for(auto& opt: options) {
|
for(auto& opt: options) {
|
||||||
opt.geometry.beginCap = style::LineCapType::Butt;
|
opt.geometry.beginCap = style::LineCapType::Butt;
|
||||||
@@ -128,13 +128,13 @@ public:
|
|||||||
interface.setLineOptions(options[index]);
|
interface.setLineOptions(options[index]);
|
||||||
|
|
||||||
// add polyline
|
// add polyline
|
||||||
interface.addPolyline(polyline);
|
interface.addPolyline(polyline, Interface::LineShaderType::WideVector);
|
||||||
|
|
||||||
// add clone
|
// add clone
|
||||||
for(auto &p : polyline) {
|
for(auto &p : polyline) {
|
||||||
p.y += 0.05f * extent / numLines;
|
p.y += 0.05f * extent / numLines;
|
||||||
}
|
}
|
||||||
interface.addPolyline(polyline);
|
interface.addPolyline(polyline, Interface::LineShaderType::WideVector);
|
||||||
for(auto &p : polyline) {
|
for(auto &p : polyline) {
|
||||||
p.y -= 0.05f * extent / numLines;
|
p.y -= 0.05f * extent / numLines;
|
||||||
}
|
}
|
||||||
@@ -193,9 +193,9 @@ public:
|
|||||||
options.texture = interface.context.createTexture2D();
|
options.texture = interface.context.createTexture2D();
|
||||||
options.texture->setImage(image);
|
options.texture->setImage(image);
|
||||||
options.texture->setSamplerConfiguration({gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp});
|
options.texture->setSamplerConfiguration({gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp});
|
||||||
options.textureCoordinates = {{{0.0f, 0.08f}, {1.0f, 0.9f}}};
|
const std::array<std::array<float, 2>, 2> textureCoordinates = {{{0.0f, 0.08f}, {1.0f, 0.9f}}};
|
||||||
const float xspan = options.textureCoordinates[1][0] - options.textureCoordinates[0][0];
|
const float xspan = textureCoordinates[1][0] - textureCoordinates[0][0];
|
||||||
const float yspan = options.textureCoordinates[1][1] - options.textureCoordinates[0][1];
|
const float yspan = textureCoordinates[1][1] - textureCoordinates[0][1];
|
||||||
assert(xspan > 0.0f && yspan > 0.0f);
|
assert(xspan > 0.0f && yspan > 0.0f);
|
||||||
options.size = {static_cast<uint32_t>(image->size.width * xspan), static_cast<uint32_t>(image->size.height * yspan)};
|
options.size = {static_cast<uint32_t>(image->size.width * xspan), static_cast<uint32_t>(image->size.height * yspan)};
|
||||||
options.anchor = {0.5f, 0.95f};
|
options.anchor = {0.5f, 0.95f};
|
||||||
@@ -205,7 +205,7 @@ public:
|
|||||||
interface.setSymbolOptions(options);
|
interface.setSymbolOptions(options);
|
||||||
|
|
||||||
// add symbol
|
// add symbol
|
||||||
interface.addSymbol(position);
|
interface.addSymbol(position, textureCoordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add polylines using wide vectors using geographic coordinates
|
// add polylines using wide vectors using geographic coordinates
|
||||||
@@ -213,7 +213,7 @@ public:
|
|||||||
using namespace mbgl;
|
using namespace mbgl;
|
||||||
|
|
||||||
// add polyline with geographic coordinates
|
// add polyline with geographic coordinates
|
||||||
Interface::LineOptions options = {/*geometry=*/{}, /*blur=*/0.0f, /*opacity=*/1.0f, /*gapWidth=*/0.0f, /*offset=*/0.0f, /*width=*/12.0f, /*shaderType=*/Interface::LineShaderType::MetalWideVector, /*color=*/{.0f, .0f, .0f, .5f} };
|
Interface::LineOptions options = {/*geometry=*/{}, /*blur=*/0.0f, /*opacity=*/1.0f, /*gapWidth=*/0.0f, /*offset=*/0.0f, /*width=*/12.0f, /*color=*/{.0f, .0f, .0f, .5f} };
|
||||||
options.geometry.beginCap = style::LineCapType::Square;
|
options.geometry.beginCap = style::LineCapType::Square;
|
||||||
options.geometry.endCap = style::LineCapType::Square;
|
options.geometry.endCap = style::LineCapType::Square;
|
||||||
options.geometry.joinType = style::LineJoinType::Bevel;
|
options.geometry.joinType = style::LineJoinType::Bevel;
|
||||||
@@ -235,7 +235,7 @@ public:
|
|||||||
// New York
|
// New York
|
||||||
{-74.04454331829972, 40.6892168305434},
|
{-74.04454331829972, 40.6892168305434},
|
||||||
};
|
};
|
||||||
interface.addPolyline(polyline_geo);
|
interface.addPolyline(polyline_geo, Interface::LineShaderType::WideVector);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add polylines using wide vectors in tile coordinates
|
// add polylines using wide vectors in tile coordinates
|
||||||
@@ -246,7 +246,7 @@ public:
|
|||||||
interface.setTileID({11, 327, 790});
|
interface.setTileID({11, 327, 790});
|
||||||
|
|
||||||
Interface::LineOptions options
|
Interface::LineOptions options
|
||||||
{/*geometry=*/{}, /*blur=*/0.0f, /*opacity=*/1.0f, /*gapWidth=*/0.0f, /*offset=*/0.0f, /*width=*/7.0f, /*shaderType=*/Interface::LineShaderType::MetalWideVector, /*color=*/{1.0f, 0, 0, .5f} };
|
{/*geometry=*/{}, /*blur=*/0.0f, /*opacity=*/1.0f, /*gapWidth=*/0.0f, /*offset=*/0.0f, /*width=*/7.0f, /*color=*/{1.0f, 0, 0, .5f} };
|
||||||
options.geometry.beginCap = style::LineCapType::Round;
|
options.geometry.beginCap = style::LineCapType::Round;
|
||||||
options.geometry.endCap = style::LineCapType::Round;
|
options.geometry.endCap = style::LineCapType::Round;
|
||||||
options.geometry.joinType = style::LineJoinType::Round;
|
options.geometry.joinType = style::LineJoinType::Round;
|
||||||
@@ -271,8 +271,8 @@ public:
|
|||||||
|
|
||||||
options.geometry.type = FeatureType::Polygon;
|
options.geometry.type = FeatureType::Polygon;
|
||||||
interface.setLineOptions(options);
|
interface.setLineOptions(options);
|
||||||
interface.addPolyline(polyline_tile[0]);
|
interface.addPolyline(polyline_tile[0], Interface::LineShaderType::WideVector);
|
||||||
interface.addPolyline(polyline_tile[1]);
|
interface.addPolyline(polyline_tile[1], Interface::LineShaderType::WideVector);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,12 +70,9 @@ LayerManagerDefault::LayerManagerDefault() {
|
|||||||
addLayerType(std::make_unique<CustomLayerFactory>());
|
addLayerType(std::make_unique<CustomLayerFactory>());
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(MLN_RENDER_BACKEND_OPENGL) || MLN_RENDER_BACKEND_VULKAN
|
|
||||||
#if !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL)
|
#if !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL)
|
||||||
addLayerType(std::make_unique<LocationIndicatorLayerFactory>());
|
addLayerType(std::make_unique<LocationIndicatorLayerFactory>());
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MLN_DRAWABLE_RENDERER
|
#if MLN_DRAWABLE_RENDERER
|
||||||
#if !defined(MLN_LAYER_CUSTOM_DRAWABLE_DISABLE_ALL)
|
#if !defined(MLN_LAYER_CUSTOM_DRAWABLE_DISABLE_ALL)
|
||||||
addLayerType(std::make_unique<CustomDrawableLayerFactory>());
|
addLayerType(std::make_unique<CustomDrawableLayerFactory>());
|
||||||
|
|||||||
@@ -16,13 +16,6 @@ objc_library(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
filegroup(
|
|
||||||
name = "mapbox_puck_assets",
|
|
||||||
srcs = glob([
|
|
||||||
"assets/*.png",
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
|
|
||||||
cc_binary(
|
cc_binary(
|
||||||
name = "glfw_app",
|
name = "glfw_app",
|
||||||
srcs = glob(
|
srcs = glob(
|
||||||
@@ -43,11 +36,9 @@ cc_binary(
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
copts = CPP_FLAGS + MAPLIBRE_FLAGS,
|
copts = CPP_FLAGS + MAPLIBRE_FLAGS,
|
||||||
data = [
|
data = glob(["assets/*"]),
|
||||||
":mapbox_puck_assets",
|
|
||||||
],
|
|
||||||
defines = [
|
defines = [
|
||||||
r"MAPBOX_PUCK_ASSETS_PATH=\"./platform/glfw/assets/\"",
|
r"MLN_ASSETS_PATH=\"assets/\"",
|
||||||
],
|
],
|
||||||
linkopts = [
|
linkopts = [
|
||||||
"-lglfw",
|
"-lglfw",
|
||||||
@@ -64,6 +55,7 @@ cc_binary(
|
|||||||
deps = [
|
deps = [
|
||||||
"//:maplibre_lib",
|
"//:maplibre_lib",
|
||||||
"@glfw",
|
"@glfw",
|
||||||
|
"@tinyobjloader",
|
||||||
] + select({
|
] + select({
|
||||||
"@platforms//os:macos": ["metal_backend"],
|
"@platforms//os:macos": ["metal_backend"],
|
||||||
"@platforms//os:linux": ["//platform/linux:impl"],
|
"@platforms//os:linux": ["//platform/linux:impl"],
|
||||||
|
|||||||
@@ -22,11 +22,20 @@ add_executable(
|
|||||||
${PROJECT_SOURCE_DIR}/platform/glfw/settings_json.cpp
|
${PROJECT_SOURCE_DIR}/platform/glfw/settings_json.cpp
|
||||||
${PROJECT_SOURCE_DIR}/platform/glfw/test_writer.cpp
|
${PROJECT_SOURCE_DIR}/platform/glfw/test_writer.cpp
|
||||||
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/map/map_snapshotter.cpp
|
${PROJECT_SOURCE_DIR}/platform/default/src/mbgl/map/map_snapshotter.cpp
|
||||||
|
${PROJECT_SOURCE_DIR}/platform/glfw/example_custom_drawable_style_layer.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
include(${PROJECT_SOURCE_DIR}/vendor/tinyobjloader.cmake)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
mbgl-glfw
|
||||||
|
PRIVATE tinyobjloader
|
||||||
)
|
)
|
||||||
|
|
||||||
set_property(
|
set_property(
|
||||||
SOURCE ${PROJECT_SOURCE_DIR}/platform/glfw/glfw_view.cpp
|
SOURCE ${PROJECT_SOURCE_DIR}/platform/glfw/glfw_view.cpp
|
||||||
PROPERTY COMPILE_DEFINITIONS MAPBOX_PUCK_ASSETS_PATH=\"${PROJECT_SOURCE_DIR}/platform/glfw/assets/\"
|
PROPERTY COMPILE_DEFINITIONS MLN_ASSETS_PATH=\"${PROJECT_SOURCE_DIR}/platform/glfw/assets/\"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(MLN_WITH_OPENGL)
|
if(MLN_WITH_OPENGL)
|
||||||
@@ -87,10 +96,12 @@ target_include_directories(
|
|||||||
PRIVATE ${PROJECT_SOURCE_DIR}/src
|
PRIVATE ${PROJECT_SOURCE_DIR}/src
|
||||||
)
|
)
|
||||||
|
|
||||||
|
include(${PROJECT_SOURCE_DIR}/vendor/tinyobjloader.cmake)
|
||||||
|
|
||||||
# Use target_link_directories when we move away from CMake 3.10.
|
# Use target_link_directories when we move away from CMake 3.10.
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
mbgl-glfw
|
mbgl-glfw
|
||||||
PRIVATE $<$<BOOL:${GLFW_LIBRARY_DIRS}>:-L${GLFW_LIBRARY_DIRS}>
|
PRIVATE $<$<BOOL:${GLFW_LIBRARY_DIRS}>:-L${GLFW_LIBRARY_DIRS}> tinyobjloader
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|||||||
1851
platform/glfw/assets/sphere.obj
Normal file
1851
platform/glfw/assets/sphere.obj
Normal file
File diff suppressed because it is too large
Load Diff
606
platform/glfw/example_custom_drawable_style_layer.cpp
Normal file
606
platform/glfw/example_custom_drawable_style_layer.cpp
Normal file
@@ -0,0 +1,606 @@
|
|||||||
|
#include "example_custom_drawable_style_layer.hpp"
|
||||||
|
|
||||||
|
#if MLN_DRAWABLE_RENDERER
|
||||||
|
|
||||||
|
#include <mbgl/style/layer.hpp>
|
||||||
|
#include <mbgl/style/layers/custom_drawable_layer.hpp>
|
||||||
|
#include <mbgl/util/io.hpp>
|
||||||
|
#include <mbgl/gfx/drawable.hpp>
|
||||||
|
#include <mbgl/util/logging.hpp>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <cmath>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
#define TINYOBJLOADER_IMPLEMENTATION
|
||||||
|
#include "tiny_obj_loader.h"
|
||||||
|
|
||||||
|
ExampleCustomDrawableStyleLayerHost::ExampleCustomDrawableStyleLayerHost(const std::string& assetsPath_)
|
||||||
|
: assetsPath(assetsPath_) {}
|
||||||
|
|
||||||
|
ExampleCustomDrawableStyleLayerHost::~ExampleCustomDrawableStyleLayerHost() {}
|
||||||
|
|
||||||
|
void ExampleCustomDrawableStyleLayerHost::initialize() {}
|
||||||
|
|
||||||
|
void ExampleCustomDrawableStyleLayerHost::deinitialize() {}
|
||||||
|
|
||||||
|
void ExampleCustomDrawableStyleLayerHost::update(Interface& interface) {
|
||||||
|
// if we have built our drawable(s) already, either update or skip
|
||||||
|
if (interface.getDrawableCount() == 0) {
|
||||||
|
createDrawables(interface);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mbgl::Point<double> ExampleCustomDrawableStyleLayerHost::project(const mbgl::LatLng& c, const mbgl::TransformState& s) {
|
||||||
|
mbgl::LatLng unwrappedLatLng = c.wrapped();
|
||||||
|
unwrappedLatLng.unwrapForShortestPath(s.getLatLng(mbgl::LatLng::Wrapped));
|
||||||
|
return mbgl::Projection::project(unwrappedLatLng, s.getScale());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExampleCustomDrawableStyleLayerHost::createDrawables(Interface& interface) {
|
||||||
|
constexpr float extent = mbgl::util::EXTENT;
|
||||||
|
|
||||||
|
// add classic polylines
|
||||||
|
{
|
||||||
|
using namespace mbgl;
|
||||||
|
|
||||||
|
// set tile
|
||||||
|
interface.setTileID({11, 327, 792});
|
||||||
|
|
||||||
|
constexpr auto numLines = 6;
|
||||||
|
Interface::LineOptions options[numLines]{
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/0.0f,
|
||||||
|
/*opacity=*/1.0f,
|
||||||
|
/*gapWidth=*/0.0f,
|
||||||
|
/*offset=*/0.0f,
|
||||||
|
/*width=*/8.0f,
|
||||||
|
/*color=*/Color::red()},
|
||||||
|
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/4.0f,
|
||||||
|
/*opacity=*/1.0f,
|
||||||
|
/*gapWidth=*/2.0f,
|
||||||
|
/*offset=*/-1.0f,
|
||||||
|
/*width=*/4.0f,
|
||||||
|
/*color=*/Color::blue()},
|
||||||
|
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/16.0f,
|
||||||
|
/*opacity=*/1.0f,
|
||||||
|
/*gapWidth=*/1.0f,
|
||||||
|
/*offset=*/2.0f,
|
||||||
|
/*width=*/16.0f,
|
||||||
|
/*color=*/Color(1.f, 0.5f, 0, 0.5f)},
|
||||||
|
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/2.0f,
|
||||||
|
/*opacity=*/1.0f,
|
||||||
|
/*gapWidth=*/1.0f,
|
||||||
|
/*offset=*/-2.0f,
|
||||||
|
/*width=*/2.0f,
|
||||||
|
/*color=*/Color(1.f, 1.f, 0, 0.3f)},
|
||||||
|
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/0.5f,
|
||||||
|
/*opacity=*/0.5f,
|
||||||
|
/*gapWidth=*/1.0f,
|
||||||
|
/*offset=*/0.5f,
|
||||||
|
/*width=*/0.5f,
|
||||||
|
/*color=*/Color::black()},
|
||||||
|
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/24.0f,
|
||||||
|
/*opacity=*/0.5f,
|
||||||
|
/*gapWidth=*/1.0f,
|
||||||
|
/*offset=*/-5.0f,
|
||||||
|
/*width=*/24.0f,
|
||||||
|
/*color=*/Color(1.f, 0, 1.f, 0.2f)},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto& opt : options) {
|
||||||
|
opt.geometry.beginCap = style::LineCapType::Butt;
|
||||||
|
opt.geometry.endCap = style::LineCapType::Butt;
|
||||||
|
opt.geometry.joinType = style::LineJoinType::Miter;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr auto numPoints = 10;
|
||||||
|
GeometryCoordinates polyline;
|
||||||
|
for (auto ipoint{0}; ipoint < numPoints; ++ipoint) {
|
||||||
|
polyline.emplace_back(
|
||||||
|
static_cast<int16_t>(ipoint * extent / numPoints),
|
||||||
|
static_cast<int16_t>(std::sin(ipoint * 2 * M_PI / numPoints) * extent / numLines / 2.f));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto index{0}; index < numLines; ++index) {
|
||||||
|
for (auto& p : polyline) {
|
||||||
|
p.y += extent / numLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set property values
|
||||||
|
interface.setLineOptions(options[index]);
|
||||||
|
|
||||||
|
// add polyline
|
||||||
|
interface.addPolyline(polyline, Interface::LineShaderType::Classic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add wide vector polylines with tile coordinates
|
||||||
|
{
|
||||||
|
using namespace mbgl;
|
||||||
|
|
||||||
|
// set tile
|
||||||
|
interface.setTileID({11, 327, 792});
|
||||||
|
|
||||||
|
constexpr auto numLines = 6;
|
||||||
|
Interface::LineOptions options[numLines]{
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/0.0f,
|
||||||
|
/*opacity=*/1.0f,
|
||||||
|
/*gapWidth=*/0.0f,
|
||||||
|
/*offset=*/0.0f,
|
||||||
|
/*width=*/8.0f,
|
||||||
|
/*color=*/Color::red()},
|
||||||
|
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/4.0f,
|
||||||
|
/*opacity=*/1.0f,
|
||||||
|
/*gapWidth=*/2.0f,
|
||||||
|
/*offset=*/-1.0f,
|
||||||
|
/*width=*/4.0f,
|
||||||
|
/*color=*/Color::blue()},
|
||||||
|
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/16.0f,
|
||||||
|
/*opacity=*/1.0f,
|
||||||
|
/*gapWidth=*/1.0f,
|
||||||
|
/*offset=*/2.0f,
|
||||||
|
/*width=*/16.0f,
|
||||||
|
/*color=*/Color(1.f, 0.5f, 0, 0.5f)},
|
||||||
|
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/2.0f,
|
||||||
|
/*opacity=*/1.0f,
|
||||||
|
/*gapWidth=*/1.0f,
|
||||||
|
/*offset=*/-2.0f,
|
||||||
|
/*width=*/2.0f,
|
||||||
|
/*color=*/Color(1.f, 1.f, 0, 0.3f)},
|
||||||
|
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/0.5f,
|
||||||
|
/*opacity=*/0.5f,
|
||||||
|
/*gapWidth=*/1.0f,
|
||||||
|
/*offset=*/0.5f,
|
||||||
|
/*width=*/0.5f,
|
||||||
|
/*color=*/Color::black()},
|
||||||
|
|
||||||
|
{/*geometry=*/{},
|
||||||
|
/*blur=*/24.0f,
|
||||||
|
/*opacity=*/0.5f,
|
||||||
|
/*gapWidth=*/1.0f,
|
||||||
|
/*offset=*/-5.0f,
|
||||||
|
/*width=*/24.0f,
|
||||||
|
/*color=*/Color(1.f, 0, 1.f, 0.2f)},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto& opt : options) {
|
||||||
|
opt.geometry.beginCap = style::LineCapType::Butt;
|
||||||
|
opt.geometry.endCap = style::LineCapType::Butt;
|
||||||
|
opt.geometry.joinType = style::LineJoinType::Miter;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr auto numPoints = 10;
|
||||||
|
GeometryCoordinates polyline;
|
||||||
|
for (auto ipoint{0}; ipoint < numPoints; ++ipoint) {
|
||||||
|
polyline.emplace_back(
|
||||||
|
static_cast<int16_t>(ipoint * extent / numPoints),
|
||||||
|
static_cast<int16_t>(std::sin(ipoint * 2 * M_PI / numPoints) * extent / numLines / 2.f));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto index{0}; index < numLines; ++index) {
|
||||||
|
for (auto& p : polyline) {
|
||||||
|
if (0 == index) p.y += 0.25f * extent / numLines;
|
||||||
|
p.y += extent / numLines;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set property values
|
||||||
|
interface.setLineOptions(options[index]);
|
||||||
|
|
||||||
|
// add polyline
|
||||||
|
interface.addPolyline(polyline, Interface::LineShaderType::WideVector);
|
||||||
|
|
||||||
|
// add clone
|
||||||
|
for (auto& p : polyline) {
|
||||||
|
p.y += 0.05f * extent / numLines;
|
||||||
|
}
|
||||||
|
interface.addPolyline(polyline, Interface::LineShaderType::WideVector);
|
||||||
|
for (auto& p : polyline) {
|
||||||
|
p.y -= 0.05f * extent / numLines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add fill polygon
|
||||||
|
{
|
||||||
|
using namespace mbgl;
|
||||||
|
|
||||||
|
// set tile
|
||||||
|
interface.setTileID({11, 327, 790});
|
||||||
|
|
||||||
|
GeometryCollection geometry{
|
||||||
|
{
|
||||||
|
// ring 1
|
||||||
|
{static_cast<int16_t>(extent * 0.1f), static_cast<int16_t>(extent * 0.2f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.5f), static_cast<int16_t>(extent * 0.5f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.7f), static_cast<int16_t>(extent * 0.5f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.5f), static_cast<int16_t>(extent * 1.0f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.0f), static_cast<int16_t>(extent * 0.5f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.1f), static_cast<int16_t>(extent * 0.2f)},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// ring 2
|
||||||
|
{static_cast<int16_t>(extent * 0.1f), static_cast<int16_t>(extent * 0.25f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.15f), static_cast<int16_t>(extent * 0.5f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.25f), static_cast<int16_t>(extent * 0.45f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.1f), static_cast<int16_t>(extent * 0.25f)},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// set properties
|
||||||
|
interface.setFillOptions({/*color=*/Color::green(), /*opacity=*/0.5f});
|
||||||
|
|
||||||
|
// add fill
|
||||||
|
interface.addFill(geometry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add symbol
|
||||||
|
{
|
||||||
|
using namespace mbgl;
|
||||||
|
|
||||||
|
// set tile
|
||||||
|
interface.setTileID({11, 327, 789});
|
||||||
|
|
||||||
|
GeometryCoordinate position{static_cast<int16_t>(extent * 0.0f), static_cast<int16_t>(extent * 0.5f)};
|
||||||
|
|
||||||
|
// load image
|
||||||
|
std::shared_ptr<PremultipliedImage> image = std::make_shared<PremultipliedImage>(
|
||||||
|
mbgl::decodeImage(mbgl::util::read_file(assetsPath + "puck_hat.png")));
|
||||||
|
|
||||||
|
// set symbol options
|
||||||
|
Interface::SymbolOptions options;
|
||||||
|
options.texture = interface.context.createTexture2D();
|
||||||
|
options.texture->setImage(image);
|
||||||
|
options.texture->setSamplerConfiguration(
|
||||||
|
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Repeat, gfx::TextureWrapType::Repeat});
|
||||||
|
|
||||||
|
const std::array<std::array<float, 2>, 2> textureCoordinates = {{{0.0f, 0.0f}, {10.0f, 10.0f}}};
|
||||||
|
options.size = {static_cast<uint32_t>(image->size.width), static_cast<uint32_t>(image->size.height)};
|
||||||
|
|
||||||
|
options.anchor = {0.5f, 0.95f};
|
||||||
|
options.angleDegrees = 45.0f;
|
||||||
|
options.scaleWithMap = true;
|
||||||
|
options.pitchWithMap = false;
|
||||||
|
interface.setSymbolOptions(options);
|
||||||
|
|
||||||
|
// add symbol
|
||||||
|
interface.addSymbol(position, textureCoordinates);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
using namespace mbgl;
|
||||||
|
|
||||||
|
GeometryCoordinate position{static_cast<int16_t>(extent * 1.0f), static_cast<int16_t>(extent * 0.5f)};
|
||||||
|
|
||||||
|
// load image
|
||||||
|
std::shared_ptr<PremultipliedImage> image = std::make_shared<PremultipliedImage>(
|
||||||
|
mbgl::decodeImage(mbgl::util::read_file(assetsPath + "puck_hat.png")));
|
||||||
|
|
||||||
|
// set symbol options
|
||||||
|
Interface::SymbolOptions options;
|
||||||
|
options.texture = interface.context.createTexture2D();
|
||||||
|
options.texture->setImage(image);
|
||||||
|
options.texture->setSamplerConfiguration(
|
||||||
|
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp});
|
||||||
|
|
||||||
|
options.size = {static_cast<uint32_t>(image->size.width), static_cast<uint32_t>(image->size.height)};
|
||||||
|
|
||||||
|
options.anchor = {0.5f, 0.95f};
|
||||||
|
options.angleDegrees = 45.0f;
|
||||||
|
options.scaleWithMap = true;
|
||||||
|
options.pitchWithMap = false;
|
||||||
|
interface.setSymbolOptions(options);
|
||||||
|
|
||||||
|
// add symbol
|
||||||
|
interface.addSymbol(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add polylines using wide vectors using geographic coordinates
|
||||||
|
{
|
||||||
|
using namespace mbgl;
|
||||||
|
|
||||||
|
// add polyline with geographic coordinates
|
||||||
|
Interface::LineOptions options = {/*geometry=*/{},
|
||||||
|
/*blur=*/0.0f,
|
||||||
|
/*opacity=*/1.0f,
|
||||||
|
/*gapWidth=*/0.0f,
|
||||||
|
/*offset=*/0.0f,
|
||||||
|
/*width=*/12.0f,
|
||||||
|
/*color=*/{.0f, .0f, .0f, .5f}};
|
||||||
|
|
||||||
|
options.geometry.beginCap = style::LineCapType::Square;
|
||||||
|
options.geometry.endCap = style::LineCapType::Square;
|
||||||
|
options.geometry.joinType = style::LineJoinType::Bevel;
|
||||||
|
options.geometry.type = FeatureType::LineString;
|
||||||
|
interface.setLineOptions(options);
|
||||||
|
|
||||||
|
LineString<double> polyline_geo{
|
||||||
|
// San Francisco
|
||||||
|
{-122.38186800073211, 37.77466003457463},
|
||||||
|
{-122.3869373450997, 37.774352128895615},
|
||||||
|
{-122.38680767979824, 37.773294612880306},
|
||||||
|
{-122.38476465260224, 37.773350946288765},
|
||||||
|
{-122.38146223043374, 37.77194168964067},
|
||||||
|
{-122.6813560305925, 37.666084247570964},
|
||||||
|
{-122.26765538866474, 37.65037232584494},
|
||||||
|
{-122.42528413673159, 38.020443518012584},
|
||||||
|
// Seattle
|
||||||
|
{-122.34927775216809, 47.62050663596438},
|
||||||
|
// New York
|
||||||
|
{-74.04454331829972, 40.6892168305434},
|
||||||
|
};
|
||||||
|
interface.addPolyline(polyline_geo, Interface::LineShaderType::WideVector);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add polylines using wide vectors in tile coordinates
|
||||||
|
{
|
||||||
|
using namespace mbgl;
|
||||||
|
|
||||||
|
// set tile
|
||||||
|
interface.setTileID({11, 327, 790});
|
||||||
|
|
||||||
|
Interface::LineOptions options{/*geometry=*/{},
|
||||||
|
/*blur=*/0.0f,
|
||||||
|
/*opacity=*/1.0f,
|
||||||
|
/*gapWidth=*/0.0f,
|
||||||
|
/*offset=*/0.0f,
|
||||||
|
/*width=*/7.0f,
|
||||||
|
/*color=*/{1.0f, 0, 0, .5f}};
|
||||||
|
|
||||||
|
options.geometry.beginCap = style::LineCapType::Round;
|
||||||
|
options.geometry.endCap = style::LineCapType::Round;
|
||||||
|
options.geometry.joinType = style::LineJoinType::Round;
|
||||||
|
|
||||||
|
// add polyline with tile coordinates
|
||||||
|
GeometryCollection polyline_tile{
|
||||||
|
{
|
||||||
|
// ring 1
|
||||||
|
{static_cast<int16_t>(extent * 0.1f), static_cast<int16_t>(extent * 0.2f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.5f), static_cast<int16_t>(extent * 0.5f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.7f), static_cast<int16_t>(extent * 0.5f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.5f), static_cast<int16_t>(extent * 1.0f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.0f), static_cast<int16_t>(extent * 0.5f)},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// ring 2
|
||||||
|
{static_cast<int16_t>(extent * 0.1f), static_cast<int16_t>(extent * 0.25f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.15f), static_cast<int16_t>(extent * 0.5f)},
|
||||||
|
{static_cast<int16_t>(extent * 0.25f), static_cast<int16_t>(extent * 0.45f)},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
options.geometry.type = FeatureType::Polygon;
|
||||||
|
interface.setLineOptions(options);
|
||||||
|
interface.addPolyline(polyline_tile[0], Interface::LineShaderType::WideVector);
|
||||||
|
interface.addPolyline(polyline_tile[1], Interface::LineShaderType::WideVector);
|
||||||
|
}
|
||||||
|
|
||||||
|
generateGeometry(interface);
|
||||||
|
loadGeometry(interface);
|
||||||
|
|
||||||
|
// finish
|
||||||
|
interface.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExampleCustomDrawableStyleLayerHost::generateGeometry(Interface& interface) {
|
||||||
|
constexpr float itemScale = 10.0f;
|
||||||
|
const mbgl::LatLng location{37.78, -122.47};
|
||||||
|
|
||||||
|
Interface::GeometryOptions options;
|
||||||
|
|
||||||
|
// load image
|
||||||
|
std::shared_ptr<mbgl::PremultipliedImage> image = std::make_shared<mbgl::PremultipliedImage>(
|
||||||
|
mbgl::decodeImage(mbgl::util::read_file(assetsPath + "puck.png")));
|
||||||
|
|
||||||
|
options.texture = interface.context.createTexture2D();
|
||||||
|
options.texture->setImage(image);
|
||||||
|
options.texture->setSamplerConfiguration(
|
||||||
|
{mbgl::gfx::TextureFilterType::Linear, mbgl::gfx::TextureWrapType::Clamp, mbgl::gfx::TextureWrapType::Clamp});
|
||||||
|
|
||||||
|
const std::shared_ptr<VertexVector> sharedVertices = std::make_shared<VertexVector>();
|
||||||
|
VertexVector& vertices = *sharedVertices;
|
||||||
|
|
||||||
|
const std::shared_ptr<TriangleIndexVector> sharedIndices = std::make_shared<TriangleIndexVector>();
|
||||||
|
TriangleIndexVector& indices = *sharedIndices;
|
||||||
|
|
||||||
|
const unsigned long numVtxCircumference = 72;
|
||||||
|
const float bearingStep = 360.0f / static_cast<float>(numVtxCircumference - 1);
|
||||||
|
|
||||||
|
vertices.emplace_back(Interface::GeometryVertex{{0.0f, 0.0f, 0.0f}, {0.5f, 0.5f}});
|
||||||
|
|
||||||
|
for (unsigned long i = 1; i <= numVtxCircumference; ++i) {
|
||||||
|
const float rad = mbgl::util::deg2radf((i - 1) * bearingStep);
|
||||||
|
|
||||||
|
Interface::GeometryVertex vertex;
|
||||||
|
vertex.position = {sinf(rad) / 2.0f, cosf(rad) / 2.0f, 0.0f};
|
||||||
|
vertex.texcoords = {0.5f + vertex.position[0], 0.5f - vertex.position[1]};
|
||||||
|
|
||||||
|
vertices.emplace_back(std::move(vertex));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t i = 1; i < vertices.elements() - 1; ++i) {
|
||||||
|
indices.emplace_back(0, i, static_cast<uint16_t>(i + 1));
|
||||||
|
}
|
||||||
|
indices.emplace_back(0, static_cast<uint16_t>(vertices.elements() - 1), 1);
|
||||||
|
|
||||||
|
interface.setGeometryOptions(options);
|
||||||
|
|
||||||
|
interface.setGeometryTweakerCallback([=, frameCount = 0]([[maybe_unused]] mbgl::gfx::Drawable& drawable,
|
||||||
|
const mbgl::PaintParameters& params,
|
||||||
|
Interface::GeometryOptions& currentOptions) mutable {
|
||||||
|
frameCount++;
|
||||||
|
|
||||||
|
const mbgl::Point<double>& center = project(location, params.state);
|
||||||
|
|
||||||
|
const float scale = itemScale * static_cast<float>(std::pow(2.f, params.state.getZoom())) *
|
||||||
|
params.pixelsToGLUnits[0];
|
||||||
|
|
||||||
|
mbgl::mat4 matrix = mbgl::matrix::identity4();
|
||||||
|
mbgl::matrix::translate(matrix, matrix, center.x, center.y, 0.0);
|
||||||
|
mbgl::matrix::rotate_z(matrix, matrix, frameCount * 0.05f);
|
||||||
|
mbgl::matrix::scale(matrix, matrix, scale, scale, 1.0f);
|
||||||
|
mbgl::matrix::multiply(currentOptions.matrix, params.transformParams.nearClippedProjMatrix, matrix);
|
||||||
|
|
||||||
|
if (frameCount % 100 == 0) {
|
||||||
|
if (currentOptions.color.g > 0.0f) {
|
||||||
|
currentOptions.color = mbgl::Color::red();
|
||||||
|
} else {
|
||||||
|
currentOptions.color = mbgl::Color::white();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
interface.addGeometry(sharedVertices, sharedIndices, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExampleCustomDrawableStyleLayerHost::loadGeometry(Interface& interface) {
|
||||||
|
constexpr float itemScale = 0.1f;
|
||||||
|
constexpr std::array<float, 3> itemRotation = {90.0f, 0.0f, 0.0f};
|
||||||
|
const mbgl::LatLng location{37.76, -122.47};
|
||||||
|
|
||||||
|
Interface::GeometryOptions options;
|
||||||
|
|
||||||
|
interface.setGeometryTweakerCallback([=]([[maybe_unused]] mbgl::gfx::Drawable& drawable,
|
||||||
|
const mbgl::PaintParameters& params,
|
||||||
|
Interface::GeometryOptions& currentOptions) mutable {
|
||||||
|
const mbgl::Point<double>& center = project(location, params.state);
|
||||||
|
|
||||||
|
const float scale = itemScale * static_cast<float>(std::pow(2.f, params.state.getZoom())) *
|
||||||
|
params.pixelsToGLUnits[0];
|
||||||
|
|
||||||
|
mbgl::mat4 matrix = mbgl::matrix::identity4();
|
||||||
|
mbgl::matrix::translate(matrix, matrix, center.x, center.y, 0.0);
|
||||||
|
mbgl::matrix::rotate_x(matrix, matrix, mbgl::util::deg2radf(itemRotation[0]));
|
||||||
|
mbgl::matrix::rotate_y(matrix, matrix, mbgl::util::deg2radf(itemRotation[1]));
|
||||||
|
mbgl::matrix::rotate_z(matrix, matrix, mbgl::util::deg2radf(itemRotation[2]));
|
||||||
|
mbgl::matrix::scale(matrix, matrix, scale, scale, scale);
|
||||||
|
mbgl::matrix::multiply(currentOptions.matrix, params.transformParams.nearClippedProjMatrix, matrix);
|
||||||
|
});
|
||||||
|
|
||||||
|
const std::shared_ptr<VertexVector> sharedVertices = std::make_shared<VertexVector>();
|
||||||
|
const std::shared_ptr<TriangleIndexVector> sharedIndices = std::make_shared<TriangleIndexVector>();
|
||||||
|
|
||||||
|
// importObj(interface, "../../_deps/tinyobjloader-src/models/cube.obj", *sharedVertices, *sharedIndices, options);
|
||||||
|
importObj(interface, assetsPath + "sphere.obj", *sharedVertices, *sharedIndices, options);
|
||||||
|
|
||||||
|
interface.setGeometryOptions(options);
|
||||||
|
interface.addGeometry(sharedVertices, sharedIndices, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExampleCustomDrawableStyleLayerHost::importObj(Interface& interface,
|
||||||
|
const std::string& filename,
|
||||||
|
VertexVector& vertices,
|
||||||
|
TriangleIndexVector& indices,
|
||||||
|
Interface::GeometryOptions& options) {
|
||||||
|
tinyobj::ObjReaderConfig readerConfig;
|
||||||
|
|
||||||
|
readerConfig.triangulate = true;
|
||||||
|
readerConfig.vertex_color = false;
|
||||||
|
|
||||||
|
tinyobj::ObjReader reader;
|
||||||
|
|
||||||
|
if (!reader.ParseFromFile(filename, readerConfig)) {
|
||||||
|
if (!reader.Error().empty()) {
|
||||||
|
mbgl::Log::Error(mbgl::Event::General, reader.Error());
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(false);
|
||||||
|
throw std::runtime_error(std::string("Cannot read obj file ") + filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!reader.Warning().empty()) {
|
||||||
|
mbgl::Log::Error(mbgl::Event::General, reader.Warning());
|
||||||
|
}
|
||||||
|
|
||||||
|
const tinyobj::attrib_t& attributes = reader.GetAttrib();
|
||||||
|
const std::vector<tinyobj::shape_t>& shapes = reader.GetShapes();
|
||||||
|
|
||||||
|
if (attributes.texcoords.empty()) {
|
||||||
|
options.color = mbgl::Color::green();
|
||||||
|
} else {
|
||||||
|
// TODO parse material
|
||||||
|
|
||||||
|
options.texture = createCheckerboardTexture(interface, 32, 32, 40, {255, 255, 255, 255}, {0, 0, 0, 255});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& shape : shapes) {
|
||||||
|
const auto shapeIndexStart = static_cast<uint16_t>(indices.elements());
|
||||||
|
|
||||||
|
for (uint16_t face = 0; face < shape.mesh.indices.size(); face += 3) {
|
||||||
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
|
const tinyobj::index_t index = shape.mesh.indices[face + i];
|
||||||
|
|
||||||
|
Interface::GeometryVertex vertex = {};
|
||||||
|
|
||||||
|
std::copy(attributes.vertices.begin() + vertex.position.size() * index.vertex_index,
|
||||||
|
attributes.vertices.begin() + vertex.position.size() * (index.vertex_index + 1),
|
||||||
|
vertex.position.begin());
|
||||||
|
|
||||||
|
if (!attributes.texcoords.empty()) {
|
||||||
|
std::copy(attributes.texcoords.begin() + vertex.texcoords.size() * index.texcoord_index,
|
||||||
|
attributes.texcoords.begin() + vertex.texcoords.size() * (index.texcoord_index + 1),
|
||||||
|
vertex.texcoords.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
vertices.emplace_back(std::move(vertex));
|
||||||
|
}
|
||||||
|
|
||||||
|
indices.emplace_back(shapeIndexStart + face, shapeIndexStart + face + 1, shapeIndexStart + face + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mbgl::gfx::Texture2DPtr ExampleCustomDrawableStyleLayerHost::createCheckerboardTexture(
|
||||||
|
Interface& interface,
|
||||||
|
uint16_t wb,
|
||||||
|
uint16_t hb,
|
||||||
|
uint16_t blockSize,
|
||||||
|
const std::array<uint8_t, 4>& color1,
|
||||||
|
const std::array<uint8_t, 4>& color2) {
|
||||||
|
std::shared_ptr<mbgl::PremultipliedImage> image = std::make_shared<mbgl::PremultipliedImage>(
|
||||||
|
mbgl::Size(wb * blockSize, hb * blockSize));
|
||||||
|
|
||||||
|
constexpr uint8_t pixelSize = sizeof(uint8_t) * 4;
|
||||||
|
|
||||||
|
for (uint16_t row = 0; row < hb; ++row) {
|
||||||
|
for (uint16_t blockRow = 0; blockRow < blockSize; ++blockRow) {
|
||||||
|
for (uint16_t col = 0; col < wb; ++col) {
|
||||||
|
for (uint16_t blockCol = 0; blockCol < blockSize; ++blockCol) {
|
||||||
|
auto index = (row * blockSize + blockRow) * image->stride() +
|
||||||
|
(col * blockSize + blockCol) * pixelSize;
|
||||||
|
|
||||||
|
memcpy(image->data.get() + index, (row + col) % 2 == 0 ? color1.data() : color2.data(), pixelSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto texture = interface.context.createTexture2D();
|
||||||
|
texture->setSamplerConfiguration(
|
||||||
|
{mbgl::gfx::TextureFilterType::Linear, mbgl::gfx::TextureWrapType::Clamp, mbgl::gfx::TextureWrapType::Clamp});
|
||||||
|
texture->setImage(std::move(image));
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
43
platform/glfw/example_custom_drawable_style_layer.hpp
Normal file
43
platform/glfw/example_custom_drawable_style_layer.hpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <mbgl/style/layers/custom_drawable_layer.hpp>
|
||||||
|
|
||||||
|
#if MLN_DRAWABLE_RENDERER
|
||||||
|
|
||||||
|
class ExampleCustomDrawableStyleLayerHost : public mbgl::style::CustomDrawableLayerHost {
|
||||||
|
public:
|
||||||
|
using VertexVector = mbgl::gfx::VertexVector<Interface::GeometryVertex>;
|
||||||
|
using TriangleIndexVector = mbgl::gfx::IndexVector<mbgl::gfx::Triangles>;
|
||||||
|
|
||||||
|
ExampleCustomDrawableStyleLayerHost(const std::string& assetsPath);
|
||||||
|
~ExampleCustomDrawableStyleLayerHost();
|
||||||
|
|
||||||
|
void initialize() override;
|
||||||
|
void deinitialize() override;
|
||||||
|
|
||||||
|
void update(Interface& interface) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static mbgl::Point<double> project(const mbgl::LatLng& c, const mbgl::TransformState& s);
|
||||||
|
|
||||||
|
void createDrawables(Interface& interface);
|
||||||
|
void generateGeometry(Interface& interface);
|
||||||
|
void loadGeometry(Interface& interface);
|
||||||
|
void importObj(Interface& interface,
|
||||||
|
const std::string& filename,
|
||||||
|
VertexVector& vertices,
|
||||||
|
TriangleIndexVector& indices,
|
||||||
|
Interface::GeometryOptions& options);
|
||||||
|
|
||||||
|
mbgl::gfx::Texture2DPtr createCheckerboardTexture(Interface& interface,
|
||||||
|
uint16_t wb,
|
||||||
|
uint16_t hb,
|
||||||
|
uint16_t blockSize,
|
||||||
|
const std::array<uint8_t, 4>& color1,
|
||||||
|
const std::array<uint8_t, 4>& color2);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const std::string assetsPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <GLFW/glfw3native.h>
|
#include <GLFW/glfw3native.h>
|
||||||
|
|
||||||
GLFWMetalBackend::GLFWMetalBackend(GLFWwindow* window_, const bool capFrameRate)
|
GLFWMetalBackend::GLFWMetalBackend(GLFWwindow* window_, [[maybe_unused]] const bool capFrameRate)
|
||||||
:
|
:
|
||||||
window(glfwGetCocoaWindow(window_)),
|
window(glfwGetCocoaWindow(window_)),
|
||||||
rendererBackend(window)
|
rendererBackend(window)
|
||||||
|
|||||||
@@ -28,6 +28,10 @@
|
|||||||
#include <mbgl/util/platform.hpp>
|
#include <mbgl/util/platform.hpp>
|
||||||
#include <mbgl/util/string.hpp>
|
#include <mbgl/util/string.hpp>
|
||||||
|
|
||||||
|
#if !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) && MLN_DRAWABLE_RENDERER
|
||||||
|
#include "example_custom_drawable_style_layer.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4244)
|
#pragma warning(disable : 4244)
|
||||||
@@ -66,7 +70,7 @@ using namespace std::numbers;
|
|||||||
#ifdef ENABLE_LOCATION_INDICATOR
|
#ifdef ENABLE_LOCATION_INDICATOR
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const std::string mbglPuckAssetsPath{MAPBOX_PUCK_ASSETS_PATH};
|
const std::string mbglPuckAssetsPath{MLN_ASSETS_PATH};
|
||||||
|
|
||||||
mbgl::Color premultiply(mbgl::Color c) {
|
mbgl::Color premultiply(mbgl::Color c) {
|
||||||
c.r *= c.a;
|
c.r *= c.a;
|
||||||
@@ -366,6 +370,9 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action,
|
|||||||
case GLFW_KEY_C:
|
case GLFW_KEY_C:
|
||||||
view->clearAnnotations();
|
view->clearAnnotations();
|
||||||
break;
|
break;
|
||||||
|
case GLFW_KEY_V:
|
||||||
|
view->toggleCustomDrawableStyle();
|
||||||
|
break;
|
||||||
case GLFW_KEY_I:
|
case GLFW_KEY_I:
|
||||||
view->resetDatabaseCallback();
|
view->resetDatabaseCallback();
|
||||||
break;
|
break;
|
||||||
@@ -823,6 +830,23 @@ void GLFWView::popAnnotation() {
|
|||||||
annotationIDs.pop_back();
|
annotationIDs.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLFWView::toggleCustomDrawableStyle() {
|
||||||
|
#if !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) && MLN_DRAWABLE_RENDERER
|
||||||
|
auto &style = map->getStyle();
|
||||||
|
|
||||||
|
const std::string identifier = "ExampleCustomDrawableStyleLayer";
|
||||||
|
const auto &existingLayer = style.getLayer(identifier);
|
||||||
|
|
||||||
|
if (!existingLayer) {
|
||||||
|
style.addLayer(std::make_unique<mbgl::style::CustomDrawableLayer>(
|
||||||
|
identifier, std::make_unique<ExampleCustomDrawableStyleLayerHost>(MLN_ASSETS_PATH)));
|
||||||
|
} else {
|
||||||
|
style.removeLayer(identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void GLFWView::makeSnapshot(bool withOverlay) {
|
void GLFWView::makeSnapshot(bool withOverlay) {
|
||||||
MLN_TRACE_FUNC();
|
MLN_TRACE_FUNC();
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ private:
|
|||||||
void clearAnnotations();
|
void clearAnnotations();
|
||||||
void popAnnotation();
|
void popAnnotation();
|
||||||
|
|
||||||
|
void toggleCustomDrawableStyle();
|
||||||
void makeSnapshot(bool withOverlay = false);
|
void makeSnapshot(bool withOverlay = false);
|
||||||
|
|
||||||
mbgl::AnnotationIDs annotationIDs;
|
mbgl::AnnotationIDs annotationIDs;
|
||||||
|
|||||||
11
shaders/drawable.custom_geometry.fragment.glsl
Normal file
11
shaders/drawable.custom_geometry.fragment.glsl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
layout (std140) uniform CustomGeometryDrawableUBO {
|
||||||
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
in vec2 frag_uv;
|
||||||
|
uniform sampler2D u_image;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragColor = texture(u_image, frag_uv) * u_color;
|
||||||
|
}
|
||||||
14
shaders/drawable.custom_geometry.vertex.glsl
Normal file
14
shaders/drawable.custom_geometry.vertex.glsl
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
layout (std140) uniform CustomGeometryDrawableUBO {
|
||||||
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 a_pos;
|
||||||
|
layout(location = 1) in vec2 a_uv;
|
||||||
|
|
||||||
|
out vec2 frag_uv;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
frag_uv = a_uv;
|
||||||
|
gl_Position = u_matrix * vec4(a_pos, 1.0);
|
||||||
|
}
|
||||||
8
shaders/drawable.location_indicator.fragment.glsl
Normal file
8
shaders/drawable.location_indicator.fragment.glsl
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
layout (std140) uniform LocationIndicatorDrawableUBO {
|
||||||
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragColor = u_color;
|
||||||
|
}
|
||||||
10
shaders/drawable.location_indicator.vertex.glsl
Normal file
10
shaders/drawable.location_indicator.vertex.glsl
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
layout (std140) uniform LocationIndicatorDrawableUBO {
|
||||||
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 a_pos;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
|
||||||
|
}
|
||||||
11
shaders/drawable.location_indicator_textured.fragment.glsl
Normal file
11
shaders/drawable.location_indicator_textured.fragment.glsl
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
layout (std140) uniform LocationIndicatorDrawableUBO {
|
||||||
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
in vec2 frag_uv;
|
||||||
|
uniform sampler2D u_image;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragColor = texture(u_image, frag_uv);
|
||||||
|
}
|
||||||
14
shaders/drawable.location_indicator_textured.vertex.glsl
Normal file
14
shaders/drawable.location_indicator_textured.vertex.glsl
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
layout (std140) uniform LocationIndicatorDrawableUBO {
|
||||||
|
mat4 u_matrix;
|
||||||
|
vec4 u_color;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 a_pos;
|
||||||
|
layout(location = 1) in vec2 a_uv;
|
||||||
|
|
||||||
|
out vec2 frag_uv;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
frag_uv = a_uv;
|
||||||
|
gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
|
||||||
|
}
|
||||||
@@ -34,6 +34,13 @@
|
|||||||
"glsl_frag": "drawable.collision_circle.fragment.glsl",
|
"glsl_frag": "drawable.collision_circle.fragment.glsl",
|
||||||
"uses_ubos": true
|
"uses_ubos": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "CustomGeometryShader",
|
||||||
|
"header": "drawable_custom_geometry",
|
||||||
|
"glsl_vert": "drawable.custom_geometry.vertex.glsl",
|
||||||
|
"glsl_frag": "drawable.custom_geometry.fragment.glsl",
|
||||||
|
"uses_ubos": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "CustomSymbolIconShader",
|
"name": "CustomSymbolIconShader",
|
||||||
"header": "drawable_custom_symbol_icon",
|
"header": "drawable_custom_symbol_icon",
|
||||||
@@ -149,15 +156,15 @@
|
|||||||
{
|
{
|
||||||
"name": "LocationIndicatorShader",
|
"name": "LocationIndicatorShader",
|
||||||
"header": "drawable_location_indicator",
|
"header": "drawable_location_indicator",
|
||||||
"glsl_vert": "_empty.glsl",
|
"glsl_vert": "drawable.location_indicator.vertex.glsl",
|
||||||
"glsl_frag": "_empty.glsl",
|
"glsl_frag": "drawable.location_indicator.fragment.glsl",
|
||||||
"uses_ubos": true
|
"uses_ubos": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "LocationIndicatorTexturedShader",
|
"name": "LocationIndicatorTexturedShader",
|
||||||
"header": "drawable_location_indicator_textured",
|
"header": "drawable_location_indicator_textured",
|
||||||
"glsl_vert": "_empty.glsl",
|
"glsl_vert": "drawable.location_indicator_textured.vertex.glsl",
|
||||||
"glsl_frag": "_empty.glsl",
|
"glsl_frag": "drawable.location_indicator_textured.fragment.glsl",
|
||||||
"uses_ubos": true
|
"uses_ubos": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
#include <mbgl/gfx/drawable_impl.hpp>
|
#include <mbgl/gfx/drawable_impl.hpp>
|
||||||
#include <mbgl/gfx/index_vector.hpp>
|
#include <mbgl/gfx/index_vector.hpp>
|
||||||
#include <mbgl/gfx/types.hpp>
|
#include <mbgl/gfx/types.hpp>
|
||||||
#include <mbgl/renderer/render_pass.hpp>
|
|
||||||
#include <mbgl/renderer/render_tile.hpp>
|
#include <mbgl/renderer/render_tile.hpp>
|
||||||
|
#include <mbgl/renderer/render_pass.hpp>
|
||||||
|
|
||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
@@ -24,7 +24,7 @@ struct Drawable::Impl {
|
|||||||
|
|
||||||
Drawable::Drawable(std::string name_)
|
Drawable::Drawable(std::string name_)
|
||||||
: name(name_),
|
: name(name_),
|
||||||
renderPass(RenderPass::Opaque),
|
renderPass(mbgl::RenderPass::Opaque),
|
||||||
depthType(DepthMaskType::ReadOnly),
|
depthType(DepthMaskType::ReadOnly),
|
||||||
impl(std::make_unique<Impl>()) {}
|
impl(std::make_unique<Impl>()) {}
|
||||||
|
|
||||||
|
|||||||
@@ -620,6 +620,10 @@ gfx::UniformBufferPtr Context::createUniformBuffer(const void* data,
|
|||||||
return std::make_shared<gl::UniformBufferGL>(data, size, *uboAllocator);
|
return std::make_shared<gl::UniformBufferGL>(data, size, *uboAllocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfx::UniqueUniformBufferArray Context::createLayerUniformBufferArray() {
|
||||||
|
return std::make_unique<UniformBufferArrayGL>();
|
||||||
|
}
|
||||||
|
|
||||||
gfx::ShaderProgramBasePtr Context::getGenericShader(gfx::ShaderRegistry& shaders, const std::string& name) {
|
gfx::ShaderProgramBasePtr Context::getGenericShader(gfx::ShaderRegistry& shaders, const std::string& name) {
|
||||||
MLN_TRACE_FUNC();
|
MLN_TRACE_FUNC();
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ public:
|
|||||||
bool persistent = false,
|
bool persistent = false,
|
||||||
bool ssbo = false) override;
|
bool ssbo = false) override;
|
||||||
|
|
||||||
|
gfx::UniqueUniformBufferArray createLayerUniformBufferArray() override;
|
||||||
|
|
||||||
gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override;
|
gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override;
|
||||||
|
|
||||||
TileLayerGroupPtr createTileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) override;
|
TileLayerGroupPtr createTileLayerGroup(int32_t layerIndex, std::size_t initialCapacity, std::string name) override;
|
||||||
|
|||||||
@@ -115,6 +115,11 @@ void TileLayerGroupGL::render(RenderOrchestrator&, PaintParameters& parameters)
|
|||||||
const auto debugGroupTile = parameters.encoder->createDebugGroup(labelPtr);
|
const auto debugGroupTile = parameters.encoder->createDebugGroup(labelPtr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!bindUBOs) {
|
||||||
|
uniformBuffers.bind();
|
||||||
|
bindUBOs = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto& tweaker : drawable.getTweakers()) {
|
for (const auto& tweaker : drawable.getTweakers()) {
|
||||||
tweaker->execute(drawable, parameters);
|
tweaker->execute(drawable, parameters);
|
||||||
}
|
}
|
||||||
@@ -126,11 +131,6 @@ void TileLayerGroupGL::render(RenderOrchestrator&, PaintParameters& parameters)
|
|||||||
context.setStencilMode(drawable.getEnableStencil() ? stencilMode3d : gfx::StencilMode::disabled());
|
context.setStencilMode(drawable.getEnableStencil() ? stencilMode3d : gfx::StencilMode::disabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bindUBOs) {
|
|
||||||
uniformBuffers.bind();
|
|
||||||
bindUBOs = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawable.draw(parameters);
|
drawable.draw(parameters);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -176,16 +176,15 @@ void LayerGroupGL::render(RenderOrchestrator&, PaintParameters& parameters) {
|
|||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
const auto debugGroup = parameters.encoder->createDebugGroup(drawable.getName().c_str());
|
const auto debugGroup = parameters.encoder->createDebugGroup(drawable.getName().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (const auto& tweaker : drawable.getTweakers()) {
|
|
||||||
tweaker->execute(drawable, parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bindUBOs) {
|
if (!bindUBOs) {
|
||||||
uniformBuffers.bind();
|
uniformBuffers.bind();
|
||||||
bindUBOs = true;
|
bindUBOs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& tweaker : drawable.getTweakers()) {
|
||||||
|
tweaker->execute(drawable, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
drawable.draw(parameters);
|
drawable.draw(parameters);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramPar
|
|||||||
shaders::BuiltIn::CircleShader,
|
shaders::BuiltIn::CircleShader,
|
||||||
shaders::BuiltIn::CollisionBoxShader,
|
shaders::BuiltIn::CollisionBoxShader,
|
||||||
shaders::BuiltIn::CollisionCircleShader,
|
shaders::BuiltIn::CollisionCircleShader,
|
||||||
|
shaders::BuiltIn::CustomGeometryShader,
|
||||||
shaders::BuiltIn::CustomSymbolIconShader,
|
shaders::BuiltIn::CustomSymbolIconShader,
|
||||||
shaders::BuiltIn::DebugShader,
|
shaders::BuiltIn::DebugShader,
|
||||||
shaders::BuiltIn::FillShader,
|
shaders::BuiltIn::FillShader,
|
||||||
@@ -142,6 +143,8 @@ void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramPar
|
|||||||
shaders::BuiltIn::LineGradientShader,
|
shaders::BuiltIn::LineGradientShader,
|
||||||
shaders::BuiltIn::LinePatternShader,
|
shaders::BuiltIn::LinePatternShader,
|
||||||
shaders::BuiltIn::LineSDFShader,
|
shaders::BuiltIn::LineSDFShader,
|
||||||
|
shaders::BuiltIn::LocationIndicatorShader,
|
||||||
|
shaders::BuiltIn::LocationIndicatorTexturedShader,
|
||||||
shaders::BuiltIn::RasterShader,
|
shaders::BuiltIn::RasterShader,
|
||||||
shaders::BuiltIn::SymbolIconShader,
|
shaders::BuiltIn::SymbolIconShader,
|
||||||
shaders::BuiltIn::SymbolSDFIconShader,
|
shaders::BuiltIn::SymbolSDFIconShader,
|
||||||
|
|||||||
@@ -204,6 +204,10 @@ gfx::UniformBufferPtr Context::createUniformBuffer(const void* data, std::size_t
|
|||||||
createBuffer(data, size, gfx::BufferUsageType::StaticDraw, /*isIndexBuffer=*/false, persistent));
|
createBuffer(data, size, gfx::BufferUsageType::StaticDraw, /*isIndexBuffer=*/false, persistent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniqueUniformBufferArray Context::createLayerUniformBufferArray() {
|
||||||
|
return std::make_unique<UniformBufferArray>();
|
||||||
|
}
|
||||||
|
|
||||||
gfx::ShaderProgramBasePtr Context::getGenericShader(gfx::ShaderRegistry& shaders, const std::string& name) {
|
gfx::ShaderProgramBasePtr Context::getGenericShader(gfx::ShaderRegistry& shaders, const std::string& name) {
|
||||||
const auto shaderGroup = shaders.getShaderGroup(name);
|
const auto shaderGroup = shaders.getShaderGroup(name);
|
||||||
auto shader = shaderGroup ? shaderGroup->getOrCreateShader(*this, {}) : gfx::ShaderProgramBasePtr{};
|
auto shader = shaderGroup ? shaderGroup->getOrCreateShader(*this, {}) : gfx::ShaderProgramBasePtr{};
|
||||||
@@ -226,7 +230,7 @@ RenderTargetPtr Context::createRenderTarget(const Size size, const gfx::TextureC
|
|||||||
return std::make_shared<RenderTarget>(*this, size, type);
|
return std::make_shared<RenderTarget>(*this, size, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::resetState(gfx::DepthMode depthMode, gfx::ColorMode colorMode) {}
|
void Context::resetState(gfx::DepthMode, gfx::ColorMode) {}
|
||||||
|
|
||||||
bool Context::emplaceOrUpdateUniformBuffer(gfx::UniformBufferPtr& buffer,
|
bool Context::emplaceOrUpdateUniformBuffer(gfx::UniformBufferPtr& buffer,
|
||||||
const void* data,
|
const void* data,
|
||||||
@@ -459,7 +463,7 @@ std::unique_ptr<gfx::TextureResource> Context::createTextureResource(Size,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<gfx::RenderbufferResource> Context::createRenderbufferResource(gfx::RenderbufferPixelType, Size size) {
|
std::unique_ptr<gfx::RenderbufferResource> Context::createRenderbufferResource(gfx::RenderbufferPixelType, Size) {
|
||||||
return std::make_unique<RenderbufferResource>();
|
return std::make_unique<RenderbufferResource>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +479,7 @@ gfx::VertexAttributeArrayPtr Context::createVertexAttributeArray() const {
|
|||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
void Context::visualizeStencilBuffer() {}
|
void Context::visualizeStencilBuffer() {}
|
||||||
|
|
||||||
void Context::visualizeDepthBuffer(float depthRangeSize) {}
|
void Context::visualizeDepthBuffer(float) {}
|
||||||
#endif // !defined(NDEBUG)
|
#endif // !defined(NDEBUG)
|
||||||
|
|
||||||
void Context::clearStencilBuffer(int32_t) {
|
void Context::clearStencilBuffer(int32_t) {
|
||||||
@@ -625,7 +629,7 @@ MTLDepthStencilStatePtr Context::makeDepthStencilState(const gfx::DepthMode& dep
|
|||||||
|
|
||||||
void Context::bindGlobalUniformBuffers(gfx::RenderPass& renderPass) const noexcept {
|
void Context::bindGlobalUniformBuffers(gfx::RenderPass& renderPass) const noexcept {
|
||||||
auto& mtlRenderPass = static_cast<mtl::RenderPass&>(renderPass);
|
auto& mtlRenderPass = static_cast<mtl::RenderPass&>(renderPass);
|
||||||
globalUniformBuffers.bind(mtlRenderPass);
|
globalUniformBuffers.bindMtl(mtlRenderPass);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mtl
|
} // namespace mtl
|
||||||
|
|||||||
@@ -316,7 +316,6 @@ void Drawable::draw(PaintParameters& parameters) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->uniformBuffers.unbind(renderPass);
|
|
||||||
unbindTextures(renderPass);
|
unbindTextures(renderPass);
|
||||||
unbindAttributes(renderPass);
|
unbindAttributes(renderPass);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,21 +51,17 @@ void LayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bindUBOs) {
|
||||||
|
uniformBuffers.bindMtl(renderPass);
|
||||||
|
bindUBOs = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto& tweaker : drawable.getTweakers()) {
|
for (const auto& tweaker : drawable.getTweakers()) {
|
||||||
tweaker->execute(drawable, parameters);
|
tweaker->execute(drawable, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bindUBOs) {
|
|
||||||
uniformBuffers.bind(renderPass);
|
|
||||||
bindUBOs = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawable.draw(parameters);
|
drawable.draw(parameters);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (bindUBOs) {
|
|
||||||
uniformBuffers.unbind(renderPass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mtl
|
} // namespace mtl
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <mbgl/shaders/mtl/circle.hpp>
|
#include <mbgl/shaders/mtl/circle.hpp>
|
||||||
#include <mbgl/shaders/mtl/clipping_mask.hpp>
|
#include <mbgl/shaders/mtl/clipping_mask.hpp>
|
||||||
#include <mbgl/shaders/mtl/collision.hpp>
|
#include <mbgl/shaders/mtl/collision.hpp>
|
||||||
|
#include <mbgl/shaders/mtl/custom_geometry.hpp>
|
||||||
#include <mbgl/shaders/mtl/custom_symbol_icon.hpp>
|
#include <mbgl/shaders/mtl/custom_symbol_icon.hpp>
|
||||||
#include <mbgl/shaders/mtl/debug.hpp>
|
#include <mbgl/shaders/mtl/debug.hpp>
|
||||||
#include <mbgl/shaders/mtl/fill.hpp>
|
#include <mbgl/shaders/mtl/fill.hpp>
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
#include <mbgl/shaders/mtl/hillshade.hpp>
|
#include <mbgl/shaders/mtl/hillshade.hpp>
|
||||||
#include <mbgl/shaders/mtl/hillshade_prepare.hpp>
|
#include <mbgl/shaders/mtl/hillshade_prepare.hpp>
|
||||||
#include <mbgl/shaders/mtl/line.hpp>
|
#include <mbgl/shaders/mtl/line.hpp>
|
||||||
|
#include <mbgl/shaders/mtl/location_indicator.hpp>
|
||||||
#include <mbgl/shaders/mtl/raster.hpp>
|
#include <mbgl/shaders/mtl/raster.hpp>
|
||||||
#include <mbgl/shaders/mtl/symbol.hpp>
|
#include <mbgl/shaders/mtl/symbol.hpp>
|
||||||
#include <mbgl/shaders/mtl/widevector.hpp>
|
#include <mbgl/shaders/mtl/widevector.hpp>
|
||||||
@@ -57,21 +59,21 @@ PremultipliedImage RendererBackend::readFramebuffer(const Size& size) {
|
|||||||
return PremultipliedImage(size);
|
return PremultipliedImage(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererBackend::assumeFramebufferBinding(const mtl::FramebufferID fbo) {}
|
void RendererBackend::assumeFramebufferBinding(const mtl::FramebufferID) {}
|
||||||
|
|
||||||
void RendererBackend::assumeViewport(int32_t x, int32_t y, const Size& size) {}
|
void RendererBackend::assumeViewport(int32_t, int32_t, const Size&) {}
|
||||||
|
|
||||||
void RendererBackend::assumeScissorTest(bool enabled) {}
|
void RendererBackend::assumeScissorTest(bool) {}
|
||||||
|
|
||||||
bool RendererBackend::implicitFramebufferBound() {
|
bool RendererBackend::implicitFramebufferBound() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererBackend::setFramebufferBinding(const mtl::FramebufferID fbo) {}
|
void RendererBackend::setFramebufferBinding(const mtl::FramebufferID) {}
|
||||||
|
|
||||||
void RendererBackend::setViewport(int32_t x, int32_t y, const Size& size) {}
|
void RendererBackend::setViewport(int32_t, int32_t, const Size&) {}
|
||||||
|
|
||||||
void RendererBackend::setScissorTest(bool enabled) {}
|
void RendererBackend::setScissorTest(bool) {}
|
||||||
|
|
||||||
/// @brief Register a list of types with a shader registry instance
|
/// @brief Register a list of types with a shader registry instance
|
||||||
/// @tparam ...ShaderID Pack of BuiltIn:: shader IDs
|
/// @tparam ...ShaderID Pack of BuiltIn:: shader IDs
|
||||||
@@ -105,6 +107,7 @@ void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramPar
|
|||||||
shaders::BuiltIn::ClippingMaskProgram,
|
shaders::BuiltIn::ClippingMaskProgram,
|
||||||
shaders::BuiltIn::CollisionBoxShader,
|
shaders::BuiltIn::CollisionBoxShader,
|
||||||
shaders::BuiltIn::CollisionCircleShader,
|
shaders::BuiltIn::CollisionCircleShader,
|
||||||
|
shaders::BuiltIn::CustomGeometryShader,
|
||||||
shaders::BuiltIn::CustomSymbolIconShader,
|
shaders::BuiltIn::CustomSymbolIconShader,
|
||||||
shaders::BuiltIn::DebugShader,
|
shaders::BuiltIn::DebugShader,
|
||||||
shaders::BuiltIn::FillShader,
|
shaders::BuiltIn::FillShader,
|
||||||
@@ -122,6 +125,8 @@ void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramPar
|
|||||||
shaders::BuiltIn::LineGradientShader,
|
shaders::BuiltIn::LineGradientShader,
|
||||||
shaders::BuiltIn::LineSDFShader,
|
shaders::BuiltIn::LineSDFShader,
|
||||||
shaders::BuiltIn::LinePatternShader,
|
shaders::BuiltIn::LinePatternShader,
|
||||||
|
shaders::BuiltIn::LocationIndicatorShader,
|
||||||
|
shaders::BuiltIn::LocationIndicatorTexturedShader,
|
||||||
shaders::BuiltIn::RasterShader,
|
shaders::BuiltIn::RasterShader,
|
||||||
shaders::BuiltIn::SymbolIconShader,
|
shaders::BuiltIn::SymbolIconShader,
|
||||||
shaders::BuiltIn::SymbolSDFIconShader,
|
shaders::BuiltIn::SymbolSDFIconShader,
|
||||||
|
|||||||
@@ -125,6 +125,11 @@ void TileLayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bindUBOs) {
|
||||||
|
uniformBuffers.bindMtl(renderPass);
|
||||||
|
bindUBOs = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto& tweaker : drawable.getTweakers()) {
|
for (const auto& tweaker : drawable.getTweakers()) {
|
||||||
tweaker->execute(drawable, parameters);
|
tweaker->execute(drawable, parameters);
|
||||||
}
|
}
|
||||||
@@ -137,17 +142,8 @@ void TileLayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) {
|
|||||||
renderPass.setDepthStencilState(state);
|
renderPass.setDepthStencilState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bindUBOs) {
|
|
||||||
uniformBuffers.bind(renderPass);
|
|
||||||
bindUBOs = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawable.draw(parameters);
|
drawable.draw(parameters);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (bindUBOs) {
|
|
||||||
uniformBuffers.unbind(renderPass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mtl
|
} // namespace mtl
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void UniformBuffer::update(const void* data, std::size_t dataSize) {
|
|||||||
buffer.update(data, dataSize, /*offset=*/0);
|
buffer.update(data, dataSize, /*offset=*/0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UniformBufferArray::bind(RenderPass& renderPass) const noexcept {
|
void UniformBufferArray::bindMtl(RenderPass& renderPass) const noexcept {
|
||||||
for (size_t id = 0; id < allocatedSize(); id++) {
|
for (size_t id = 0; id < allocatedSize(); id++) {
|
||||||
const auto& uniformBuffer = get(id);
|
const auto& uniformBuffer = get(id);
|
||||||
if (!uniformBuffer) continue;
|
if (!uniformBuffer) continue;
|
||||||
@@ -54,5 +54,9 @@ void UniformBufferArray::bind(RenderPass& renderPass) const noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UniformBufferArray::bind(gfx::RenderPass& renderPass) {
|
||||||
|
bindMtl(static_cast<RenderPass&>(renderPass));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mtl
|
} // namespace mtl
|
||||||
} // namespace mbgl
|
} // namespace mbgl
|
||||||
|
|||||||
@@ -81,30 +81,27 @@ void UploadPass::updateIndexBufferResource(gfx::IndexBufferResource& resource, c
|
|||||||
static_cast<IndexBufferResource&>(resource).get().update(data, size, /*offset=*/0);
|
static_cast<IndexBufferResource&>(resource).get().update(data, size, /*offset=*/0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<gfx::TextureResource> UploadPass::createTextureResource(const Size size,
|
std::unique_ptr<gfx::TextureResource> UploadPass::createTextureResource(const Size,
|
||||||
const void* data,
|
const void*,
|
||||||
gfx::TexturePixelType format,
|
gfx::TexturePixelType,
|
||||||
gfx::TextureChannelDataType type) {
|
gfx::TextureChannelDataType) {
|
||||||
assert(false);
|
assert(false);
|
||||||
throw std::runtime_error("UploadPass::createTextureResource not implemented on Metal!");
|
throw std::runtime_error("UploadPass::createTextureResource not implemented on Metal!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploadPass::updateTextureResource(gfx::TextureResource& resource,
|
void UploadPass::updateTextureResource(
|
||||||
const Size size,
|
gfx::TextureResource&, const Size, const void*, gfx::TexturePixelType, gfx::TextureChannelDataType) {
|
||||||
const void* data,
|
|
||||||
gfx::TexturePixelType format,
|
|
||||||
gfx::TextureChannelDataType type) {
|
|
||||||
assert(false);
|
assert(false);
|
||||||
throw std::runtime_error("UploadPass::updateTextureResource not implemented on Metal!");
|
throw std::runtime_error("UploadPass::updateTextureResource not implemented on Metal!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploadPass::updateTextureResourceSub(gfx::TextureResource& resource,
|
void UploadPass::updateTextureResourceSub(gfx::TextureResource&,
|
||||||
const uint16_t xOffset,
|
const uint16_t,
|
||||||
const uint16_t yOffset,
|
const uint16_t,
|
||||||
const Size size,
|
const Size,
|
||||||
const void* data,
|
const void*,
|
||||||
gfx::TexturePixelType format,
|
gfx::TexturePixelType,
|
||||||
gfx::TextureChannelDataType type) {
|
gfx::TextureChannelDataType) {
|
||||||
assert(false);
|
assert(false);
|
||||||
throw std::runtime_error("UploadPass::updateTextureResourceSub not implemented on Metal!");
|
throw std::runtime_error("UploadPass::updateTextureResourceSub not implemented on Metal!");
|
||||||
}
|
}
|
||||||
@@ -151,10 +148,10 @@ const gfx::UniqueVertexBufferResource& UploadPass::getBuffer(const gfx::VertexVe
|
|||||||
}
|
}
|
||||||
|
|
||||||
gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
|
gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
|
||||||
const std::size_t vertexCount,
|
[[maybe_unused]] const std::size_t vertexCount,
|
||||||
const gfx::AttributeDataType vertexType,
|
[[maybe_unused]] const gfx::AttributeDataType vertexType,
|
||||||
const std::size_t vertexAttributeIndex,
|
[[maybe_unused]] const std::size_t vertexAttributeIndex,
|
||||||
const std::vector<std::uint8_t>& vertexData,
|
[[maybe_unused]] const std::vector<std::uint8_t>& vertexData,
|
||||||
const gfx::VertexAttributeArray& defaults,
|
const gfx::VertexAttributeArray& defaults,
|
||||||
const gfx::VertexAttributeArray& overrides,
|
const gfx::VertexAttributeArray& overrides,
|
||||||
const gfx::BufferUsageType usage,
|
const gfx::BufferUsageType usage,
|
||||||
@@ -166,7 +163,7 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
|
|||||||
bindings.resize(defaults.allocatedSize());
|
bindings.resize(defaults.allocatedSize());
|
||||||
|
|
||||||
// For each attribute in the program, with the corresponding default and optional override...
|
// For each attribute in the program, with the corresponding default and optional override...
|
||||||
const auto resolveAttr = [&](const size_t id, auto& default_, auto& override_) -> void {
|
const auto resolveAttr = [&]([[maybe_unused]] const size_t id, auto& default_, auto& override_) -> void {
|
||||||
auto& effectiveAttr = override_ ? *override_ : default_;
|
auto& effectiveAttr = override_ ? *override_ : default_;
|
||||||
const auto& defaultAttr = static_cast<const VertexAttribute&>(default_);
|
const auto& defaultAttr = static_cast<const VertexAttribute&>(default_);
|
||||||
const auto index = static_cast<std::size_t>(defaultAttr.getIndex());
|
const auto index = static_cast<std::size_t>(defaultAttr.getIndex());
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !MLN_RENDER_BACKEND_OPENGL
|
#ifdef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
|
|
||||||
#include <mbgl/gfx/vertex_attribute.hpp>
|
#include <mbgl/gfx/vertex_attribute.hpp>
|
||||||
#include <mbgl/renderer/render_static_data.hpp>
|
#include <mbgl/renderer/render_static_data.hpp>
|
||||||
@@ -145,7 +145,7 @@ public:
|
|||||||
friend vec2 operator-(const vec2& v1, const vec2& v2) { return {v1.x - v2.x, v1.y - v2.y}; }
|
friend vec2 operator-(const vec2& v1, const vec2& v2) { return {v1.x - v2.x, v1.y - v2.y}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#if MLN_RENDER_BACKEND_OPENGL
|
#ifndef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
struct Shader {
|
struct Shader {
|
||||||
virtual ~Shader() { release(); }
|
virtual ~Shader() { release(); }
|
||||||
void release() {
|
void release() {
|
||||||
@@ -420,7 +420,7 @@ public:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !MLN_RENDER_BACKEND_OPENGL
|
#ifdef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
struct TextureInfo {
|
struct TextureInfo {
|
||||||
std::shared_ptr<gfx::Texture2D> texture;
|
std::shared_ptr<gfx::Texture2D> texture;
|
||||||
std::optional<Immutable<style::Image::Impl>> image;
|
std::optional<Immutable<style::Image::Impl>> image;
|
||||||
@@ -485,7 +485,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void release() {
|
void release() {
|
||||||
#if MLN_RENDER_BACKEND_OPENGL
|
#ifndef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
if (!simpleShader.program) return;
|
if (!simpleShader.program) return;
|
||||||
for (const auto& t : textures) t.second->release();
|
for (const auto& t : textures) t.second->release();
|
||||||
buffer.release();
|
buffer.release();
|
||||||
@@ -515,7 +515,7 @@ public:
|
|||||||
params.puckShadowScale != oldParams.puckShadowScale)
|
params.puckShadowScale != oldParams.puckShadowScale)
|
||||||
bearingChanged = true; // changes puck geometry but not necessarily the location
|
bearingChanged = true; // changes puck geometry but not necessarily the location
|
||||||
if (params.errorRadiusMeters != oldParams.errorRadiusMeters) radiusChanged = true;
|
if (params.errorRadiusMeters != oldParams.errorRadiusMeters) radiusChanged = true;
|
||||||
#if MLN_RENDER_BACKEND_OPENGL
|
#ifndef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
bearingChanged |= setTextureFromImageID(params.puckImagePath, texPuck, params);
|
bearingChanged |= setTextureFromImageID(params.puckImagePath, texPuck, params);
|
||||||
bearingChanged |= setTextureFromImageID(params.puckShadowImagePath, texShadow, params);
|
bearingChanged |= setTextureFromImageID(params.puckShadowImagePath, texShadow, params);
|
||||||
bearingChanged |= setTextureFromImageID(params.puckHatImagePath, texPuckHat, params);
|
bearingChanged |= setTextureFromImageID(params.puckHatImagePath, texPuckHat, params);
|
||||||
@@ -551,7 +551,7 @@ public:
|
|||||||
if (!dirtyFeature) return;
|
if (!dirtyFeature) return;
|
||||||
dirtyFeature = false;
|
dirtyFeature = false;
|
||||||
featureEnvelope->clear();
|
featureEnvelope->clear();
|
||||||
#if MLN_RENDER_BACKEND_OPENGL
|
#ifndef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
if (!texPuck || !texPuck->isValid()) return;
|
if (!texPuck || !texPuck->isValid()) return;
|
||||||
#else
|
#else
|
||||||
if (!puckDrawableInfo.textureInfo.texture) return;
|
if (!puckDrawableInfo.textureInfo.texture) return;
|
||||||
@@ -593,7 +593,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateRadius(const mbgl::LocationIndicatorRenderParameters& params) {
|
void updateRadius(const mbgl::LocationIndicatorRenderParameters& params) {
|
||||||
#if !MLN_RENDER_BACKEND_OPENGL
|
#ifdef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
auto& circle = circleDrawableInfo.geometry;
|
auto& circle = circleDrawableInfo.geometry;
|
||||||
circleDrawableInfo.dirty = true;
|
circleDrawableInfo.dirty = true;
|
||||||
#endif
|
#endif
|
||||||
@@ -711,7 +711,7 @@ protected:
|
|||||||
params.perspectiveCompensation; // Compensation factor for the perspective deformation
|
params.perspectiveCompensation; // Compensation factor for the perspective deformation
|
||||||
// ^ clamping this to 0.8 to avoid growing the puck too much close to the camera.
|
// ^ clamping this to 0.8 to avoid growing the puck too much close to the camera.
|
||||||
|
|
||||||
#if MLN_RENDER_BACKEND_OPENGL
|
#ifndef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
const double shadowRadius = ((texShadow) ? texShadow->width / texShadow->pixelRatio : 0.0) *
|
const double shadowRadius = ((texShadow) ? texShadow->width / texShadow->pixelRatio : 0.0) *
|
||||||
params.puckShadowScale * M_SQRT2 * 0.5 *
|
params.puckShadowScale * M_SQRT2 * 0.5 *
|
||||||
horizontalScaleFactor; // Technically it's not the radius, but
|
horizontalScaleFactor; // Technically it's not the radius, but
|
||||||
@@ -756,7 +756,7 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MLN_RENDER_BACKEND_OPENGL
|
#ifndef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
void drawRadius(const mbgl::LocationIndicatorRenderParameters& params) {
|
void drawRadius(const mbgl::LocationIndicatorRenderParameters& params) {
|
||||||
if (!(params.errorRadiusMeters > 0.0) ||
|
if (!(params.errorRadiusMeters > 0.0) ||
|
||||||
(params.errorRadiusColor.a == 0.0 && params.errorRadiusBorderColor.a == 0.0))
|
(params.errorRadiusColor.a == 0.0 && params.errorRadiusBorderColor.a == 0.0))
|
||||||
@@ -818,7 +818,7 @@ protected:
|
|||||||
return s.screenCoordinateToLatLng(flippedPoint, wrapMode);
|
return s.screenCoordinateToLatLng(flippedPoint, wrapMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MLN_RENDER_BACKEND_OPENGL
|
#ifndef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
bool setTextureFromImageID(const std::string& imagePath,
|
bool setTextureFromImageID(const std::string& imagePath,
|
||||||
std::shared_ptr<Texture>& texture,
|
std::shared_ptr<Texture>& texture,
|
||||||
const mbgl::LocationIndicatorRenderParameters& params) {
|
const mbgl::LocationIndicatorRenderParameters& params) {
|
||||||
@@ -879,7 +879,7 @@ protected:
|
|||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
bool dirtyFeature = true;
|
bool dirtyFeature = true;
|
||||||
|
|
||||||
#if !MLN_RENDER_BACKEND_OPENGL
|
#ifdef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct QuadDrawableInfo {
|
struct QuadDrawableInfo {
|
||||||
@@ -1015,7 +1015,7 @@ void RenderLocationIndicatorLayer::populateDynamicRenderFeatureIndex(DynamicFeat
|
|||||||
if (!renderImpl->featureEnvelope->empty()) index.insert(renderImpl->feature, renderImpl->featureEnvelope);
|
if (!renderImpl->featureEnvelope->empty()) index.insert(renderImpl->feature, renderImpl->featureEnvelope);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MLN_RENDER_BACKEND_OPENGL
|
#ifndef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
void RenderLocationIndicatorLayer::render(PaintParameters& paintParameters) {
|
void RenderLocationIndicatorLayer::render(PaintParameters& paintParameters) {
|
||||||
auto& glContext = static_cast<gl::Context&>(paintParameters.context);
|
auto& glContext = static_cast<gl::Context&>(paintParameters.context);
|
||||||
|
|
||||||
@@ -1035,7 +1035,7 @@ void RenderLocationIndicatorLayer::render(PaintParameters& paintParameters) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !MLN_RENDER_BACKEND_OPENGL
|
#ifdef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
|
|
||||||
void RenderLocationIndicatorLayer::update(gfx::ShaderRegistry& shaders,
|
void RenderLocationIndicatorLayer::update(gfx::ShaderRegistry& shaders,
|
||||||
gfx::Context& context,
|
gfx::Context& context,
|
||||||
@@ -1092,8 +1092,11 @@ void RenderLocationIndicatorLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
const auto createQuadGeometry = [&](gfx::Drawable& drawable, const auto& geometry) {
|
const auto createQuadGeometry = [&](gfx::Drawable& drawable, const auto& geometry) {
|
||||||
auto vertexAttrs = context.createVertexAttributeArray();
|
auto vertexAttrs = context.createVertexAttributeArray();
|
||||||
|
|
||||||
|
drawable.setVertices({}, 4, gfx::AttributeDataType::Float2);
|
||||||
|
vertexAttrs->set(shaders::idLocationIndicatorPosVertexAttribute, 0, gfx::AttributeDataType::Float2, 4);
|
||||||
|
|
||||||
if (const auto& attr = vertexAttrs->set(
|
if (const auto& attr = vertexAttrs->set(
|
||||||
shaders::idCommonTexVertexAttribute, 0, gfx::AttributeDataType::Float2)) {
|
shaders::idLocationIndicatorTexVertexAttribute, 0, gfx::AttributeDataType::Float2, 4)) {
|
||||||
const std::array<RenderLocationIndicatorImpl::vec2, 4> texCoords = {
|
const std::array<RenderLocationIndicatorImpl::vec2, 4> texCoords = {
|
||||||
{{0.0f, 1.0f}, {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}}};
|
{{0.0f, 1.0f}, {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}}};
|
||||||
|
|
||||||
@@ -1125,7 +1128,9 @@ void RenderLocationIndicatorLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
|
|
||||||
drawable->setName(name);
|
drawable->setName(name);
|
||||||
drawable->setRenderPass(drawPasses);
|
drawable->setRenderPass(drawPasses);
|
||||||
drawable->setDepthType(gfx::DepthMaskType::ReadWrite);
|
drawable->setDepthType(gfx::DepthMaskType::ReadOnly);
|
||||||
|
drawable->setEnableDepth(false);
|
||||||
|
drawable->setEnableStencil(false);
|
||||||
drawable->setColorMode(drawPasses == RenderPass::Translucent ? gfx::ColorMode::alphaBlended()
|
drawable->setColorMode(drawPasses == RenderPass::Translucent ? gfx::ColorMode::alphaBlended()
|
||||||
: gfx::ColorMode::unblended());
|
: gfx::ColorMode::unblended());
|
||||||
|
|
||||||
@@ -1146,7 +1151,9 @@ void RenderLocationIndicatorLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
|
|
||||||
drawable->setName(name);
|
drawable->setName(name);
|
||||||
drawable->setRenderPass(drawPasses);
|
drawable->setRenderPass(drawPasses);
|
||||||
drawable->setDepthType(gfx::DepthMaskType::ReadWrite);
|
drawable->setDepthType(gfx::DepthMaskType::ReadOnly);
|
||||||
|
drawable->setEnableDepth(false);
|
||||||
|
drawable->setEnableStencil(false);
|
||||||
drawable->setColorMode(drawPasses == RenderPass::Translucent ? gfx::ColorMode::alphaBlended()
|
drawable->setColorMode(drawPasses == RenderPass::Translucent ? gfx::ColorMode::alphaBlended()
|
||||||
: gfx::ColorMode::unblended());
|
: gfx::ColorMode::unblended());
|
||||||
|
|
||||||
@@ -1240,7 +1247,7 @@ void RenderLocationIndicatorLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto& circleVertexAttrs = circleDrawable.getVertexAttributes();
|
auto& circleVertexAttrs = circleDrawable.getVertexAttributes();
|
||||||
if (const auto& attr = circleVertexAttrs->set(shaders::idCommonPosVertexAttribute)) {
|
if (const auto& attr = circleVertexAttrs->set(shaders::idLocationIndicatorPosVertexAttribute)) {
|
||||||
attr->setSharedRawData(
|
attr->setSharedRawData(
|
||||||
verts, 0, 0, sizeof(RenderLocationIndicatorImpl::vec2), gfx::AttributeDataType::Float2);
|
verts, 0, 0, sizeof(RenderLocationIndicatorImpl::vec2), gfx::AttributeDataType::Float2);
|
||||||
}
|
}
|
||||||
@@ -1254,7 +1261,7 @@ void RenderLocationIndicatorLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
auto vertexAttrs = drawable.getVertexAttributes();
|
auto vertexAttrs = drawable.getVertexAttributes();
|
||||||
|
|
||||||
if (const auto& attr = vertexAttrs->set(
|
if (const auto& attr = vertexAttrs->set(
|
||||||
shaders::idCommonPosVertexAttribute, 0, gfx::AttributeDataType::Float2)) {
|
shaders::idLocationIndicatorPosVertexAttribute, 0, gfx::AttributeDataType::Float2)) {
|
||||||
auto geoDataPtr = reinterpret_cast<const uint8_t*>(info.geometry.data());
|
auto geoDataPtr = reinterpret_cast<const uint8_t*>(info.geometry.data());
|
||||||
auto geoDataSize = info.geometry.size() * sizeof(RenderLocationIndicatorImpl::vec2);
|
auto geoDataSize = info.geometry.size() * sizeof(RenderLocationIndicatorImpl::vec2);
|
||||||
|
|
||||||
@@ -1281,7 +1288,7 @@ void RenderLocationIndicatorLayer::update(gfx::ShaderRegistry& shaders,
|
|||||||
info.textureInfo.image.reset();
|
info.textureInfo.image.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
drawable.setTexture(info.textureInfo.texture, shaders::idCommonTexture);
|
drawable.setTexture(info.textureInfo.texture, shaders::idLocationIndicatorTexture);
|
||||||
info.textureInfo.dirty = false;
|
info.textureInfo.dirty = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
#include <mbgl/style/layers/location_indicator_layer_impl.hpp>
|
#include <mbgl/style/layers/location_indicator_layer_impl.hpp>
|
||||||
#include <mbgl/style/layers/location_indicator_layer_properties.hpp>
|
#include <mbgl/style/layers/location_indicator_layer_properties.hpp>
|
||||||
|
|
||||||
|
#if !MLN_RENDER_BACKEND_OPENGL
|
||||||
|
#define MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace mbgl {
|
namespace mbgl {
|
||||||
class RenderLocationIndicatorImpl;
|
class RenderLocationIndicatorImpl;
|
||||||
class RenderLocationIndicatorLayer final : public RenderLayer {
|
class RenderLocationIndicatorLayer final : public RenderLayer {
|
||||||
@@ -21,7 +25,7 @@ public:
|
|||||||
explicit RenderLocationIndicatorLayer(Immutable<style::LocationIndicatorLayer::Impl>);
|
explicit RenderLocationIndicatorLayer(Immutable<style::LocationIndicatorLayer::Impl>);
|
||||||
~RenderLocationIndicatorLayer() override;
|
~RenderLocationIndicatorLayer() override;
|
||||||
|
|
||||||
#if !MLN_RENDER_BACKEND_OPENGL
|
#ifdef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
void update(gfx::ShaderRegistry &,
|
void update(gfx::ShaderRegistry &,
|
||||||
gfx::Context &,
|
gfx::Context &,
|
||||||
const TransformState &,
|
const TransformState &,
|
||||||
@@ -38,7 +42,7 @@ private:
|
|||||||
void markContextDestroyed() override;
|
void markContextDestroyed() override;
|
||||||
void prepare(const LayerPrepareParameters &) override;
|
void prepare(const LayerPrepareParameters &) override;
|
||||||
|
|
||||||
#if MLN_RENDER_BACKEND_OPENGL
|
#ifndef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
void render(PaintParameters &) override;
|
void render(PaintParameters &) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -49,7 +53,7 @@ private:
|
|||||||
std::unique_ptr<RenderLocationIndicatorImpl> renderImpl;
|
std::unique_ptr<RenderLocationIndicatorImpl> renderImpl;
|
||||||
style::LocationIndicatorPaintProperties::Unevaluated unevaluated;
|
style::LocationIndicatorPaintProperties::Unevaluated unevaluated;
|
||||||
|
|
||||||
#if !MLN_RENDER_BACKEND_OPENGL
|
#ifdef MLN_DRAWABLE_LOCATION_INDICATOR
|
||||||
// Drawable shaders
|
// Drawable shaders
|
||||||
gfx::ShaderProgramBasePtr quadShader;
|
gfx::ShaderProgramBasePtr quadShader;
|
||||||
gfx::ShaderProgramBasePtr circleShader;
|
gfx::ShaderProgramBasePtr circleShader;
|
||||||
|
|||||||
@@ -95,6 +95,20 @@ const std::vector<AttributeInfo> CollisionCircleShaderInfo::attributes = {
|
|||||||
};
|
};
|
||||||
const std::vector<TextureInfo> CollisionCircleShaderInfo::textures = {};
|
const std::vector<TextureInfo> CollisionCircleShaderInfo::textures = {};
|
||||||
|
|
||||||
|
// Custom Geometry
|
||||||
|
using CustomGeometryInfo = ShaderInfo<BuiltIn::CustomGeometryShader, gfx::Backend::Type::OpenGL>;
|
||||||
|
|
||||||
|
const std::vector<UniformBlockInfo> CustomGeometryInfo::uniformBlocks = {
|
||||||
|
UniformBlockInfo{"CustomGeometryDrawableUBO", idCustomGeometryDrawableUBO},
|
||||||
|
};
|
||||||
|
const std::vector<AttributeInfo> CustomGeometryInfo::attributes = {
|
||||||
|
AttributeInfo{"a_pos", idCustomGeometryPosVertexAttribute},
|
||||||
|
AttributeInfo{"a_uv", idCustomGeometryTexVertexAttribute},
|
||||||
|
};
|
||||||
|
const std::vector<TextureInfo> CustomGeometryInfo::textures = {
|
||||||
|
TextureInfo{"u_image", idCustomGeometryTexture},
|
||||||
|
};
|
||||||
|
|
||||||
// Custom Symbol Icon
|
// Custom Symbol Icon
|
||||||
using CustomSymbolIconShaderInfo = ShaderInfo<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::OpenGL>;
|
using CustomSymbolIconShaderInfo = ShaderInfo<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::OpenGL>;
|
||||||
|
|
||||||
@@ -322,6 +336,30 @@ const std::vector<AttributeInfo> LineShaderInfo::attributes = {
|
|||||||
};
|
};
|
||||||
const std::vector<TextureInfo> LineShaderInfo::textures = {};
|
const std::vector<TextureInfo> LineShaderInfo::textures = {};
|
||||||
|
|
||||||
|
// Location Indicator
|
||||||
|
using LocationIndicatorInfo = ShaderInfo<BuiltIn::LocationIndicatorShader, gfx::Backend::Type::OpenGL>;
|
||||||
|
|
||||||
|
const std::vector<UniformBlockInfo> LocationIndicatorInfo::uniformBlocks = {
|
||||||
|
UniformBlockInfo{"LocationIndicatorDrawableUBO", idLocationIndicatorDrawableUBO},
|
||||||
|
};
|
||||||
|
const std::vector<AttributeInfo> LocationIndicatorInfo::attributes = {
|
||||||
|
AttributeInfo{"a_pos", idLocationIndicatorPosVertexAttribute},
|
||||||
|
};
|
||||||
|
const std::vector<TextureInfo> LocationIndicatorInfo::textures = {};
|
||||||
|
|
||||||
|
using LocationIndicatorTexturedInfo = ShaderInfo<BuiltIn::LocationIndicatorTexturedShader, gfx::Backend::Type::OpenGL>;
|
||||||
|
|
||||||
|
const std::vector<UniformBlockInfo> LocationIndicatorTexturedInfo::uniformBlocks = {
|
||||||
|
UniformBlockInfo{"LocationIndicatorDrawableUBO", idLocationIndicatorDrawableUBO},
|
||||||
|
};
|
||||||
|
const std::vector<AttributeInfo> LocationIndicatorTexturedInfo::attributes = {
|
||||||
|
AttributeInfo{"a_pos", idLocationIndicatorPosVertexAttribute},
|
||||||
|
AttributeInfo{"a_uv", idLocationIndicatorTexVertexAttribute},
|
||||||
|
};
|
||||||
|
const std::vector<TextureInfo> LocationIndicatorTexturedInfo::textures = {
|
||||||
|
TextureInfo{"u_image", idLocationIndicatorTexture},
|
||||||
|
};
|
||||||
|
|
||||||
// Line Gradient
|
// Line Gradient
|
||||||
using LineGradientShaderInfo = ShaderInfo<BuiltIn::LineGradientShader, gfx::Backend::Type::OpenGL>;
|
using LineGradientShaderInfo = ShaderInfo<BuiltIn::LineGradientShader, gfx::Backend::Type::OpenGL>;
|
||||||
|
|
||||||
|
|||||||
17
src/mbgl/shaders/mtl/custom_geometry.cpp
Normal file
17
src/mbgl/shaders/mtl/custom_geometry.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include <mbgl/shaders/mtl/custom_geometry.hpp>
|
||||||
|
#include <mbgl/shaders/shader_defines.hpp>
|
||||||
|
|
||||||
|
namespace mbgl {
|
||||||
|
namespace shaders {
|
||||||
|
|
||||||
|
using CustomGeometryShaderSource = ShaderSource<BuiltIn::CustomGeometryShader, gfx::Backend::Type::Metal>;
|
||||||
|
|
||||||
|
const std::array<AttributeInfo, 2> CustomGeometryShaderSource::attributes = {
|
||||||
|
AttributeInfo{customGeometryUBOCount + 0, gfx::AttributeDataType::Float3, idCustomGeometryPosVertexAttribute},
|
||||||
|
AttributeInfo{customGeometryUBOCount + 1, gfx::AttributeDataType::Float2, idCustomGeometryTexVertexAttribute},
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::array<TextureInfo, 1> CustomGeometryShaderSource::textures = {TextureInfo{0, idCustomGeometryTexture}};
|
||||||
|
|
||||||
|
} // namespace shaders
|
||||||
|
} // namespace mbgl
|
||||||
25
src/mbgl/shaders/mtl/location_indicator.cpp
Normal file
25
src/mbgl/shaders/mtl/location_indicator.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include <mbgl/shaders/mtl/location_indicator.hpp>
|
||||||
|
#include <mbgl/shaders/shader_defines.hpp>
|
||||||
|
|
||||||
|
namespace mbgl {
|
||||||
|
namespace shaders {
|
||||||
|
|
||||||
|
using LocationIndicatorShaderSource = ShaderSource<BuiltIn::LocationIndicatorShader, gfx::Backend::Type::Metal>;
|
||||||
|
|
||||||
|
const std::array<AttributeInfo, 1> LocationIndicatorShaderSource::attributes = {AttributeInfo{
|
||||||
|
locationIndicatorUBOCount + 0, gfx::AttributeDataType::Float2, idLocationIndicatorPosVertexAttribute}};
|
||||||
|
|
||||||
|
using LocationIndicatorTexturedShaderSource =
|
||||||
|
ShaderSource<BuiltIn::LocationIndicatorTexturedShader, gfx::Backend::Type::Metal>;
|
||||||
|
|
||||||
|
const std::array<AttributeInfo, 2> LocationIndicatorTexturedShaderSource::attributes = {
|
||||||
|
AttributeInfo{locationIndicatorUBOCount + 0, gfx::AttributeDataType::Float2, idLocationIndicatorPosVertexAttribute},
|
||||||
|
AttributeInfo{locationIndicatorUBOCount + 1, gfx::AttributeDataType::Float2, idLocationIndicatorTexVertexAttribute},
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::array<TextureInfo, 1> LocationIndicatorTexturedShaderSource::textures = {
|
||||||
|
TextureInfo{0, idLocationIndicatorTexture},
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace shaders
|
||||||
|
} // namespace mbgl
|
||||||
20
src/mbgl/shaders/vulkan/custom_geometry.cpp
Normal file
20
src/mbgl/shaders/vulkan/custom_geometry.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include <mbgl/shaders/vulkan/custom_geometry.hpp>
|
||||||
|
#include <mbgl/shaders/shader_defines.hpp>
|
||||||
|
#include <mbgl/shaders/custom_geometry_ubo.hpp>
|
||||||
|
|
||||||
|
namespace mbgl {
|
||||||
|
namespace shaders {
|
||||||
|
|
||||||
|
using CustomGeometryShaderSource = ShaderSource<BuiltIn::CustomGeometryShader, gfx::Backend::Type::Vulkan>;
|
||||||
|
|
||||||
|
const std::array<AttributeInfo, 2> CustomGeometryShaderSource::attributes = {
|
||||||
|
AttributeInfo{0, gfx::AttributeDataType::Float3, idCustomGeometryPosVertexAttribute},
|
||||||
|
AttributeInfo{1, gfx::AttributeDataType::Float2, idCustomGeometryTexVertexAttribute},
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::array<TextureInfo, 1> CustomGeometryShaderSource::textures = {
|
||||||
|
TextureInfo{0, idCustomGeometryTexture},
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace shaders
|
||||||
|
} // namespace mbgl
|
||||||
@@ -11,7 +11,7 @@ namespace shaders {
|
|||||||
using LocationIndicatorShaderSource = ShaderSource<BuiltIn::LocationIndicatorShader, gfx::Backend::Type::Vulkan>;
|
using LocationIndicatorShaderSource = ShaderSource<BuiltIn::LocationIndicatorShader, gfx::Backend::Type::Vulkan>;
|
||||||
|
|
||||||
const std::array<AttributeInfo, 1> LocationIndicatorShaderSource::attributes = {
|
const std::array<AttributeInfo, 1> LocationIndicatorShaderSource::attributes = {
|
||||||
AttributeInfo{0, gfx::AttributeDataType::Float2, idCommonPosVertexAttribute},
|
AttributeInfo{0, gfx::AttributeDataType::Float2, idLocationIndicatorPosVertexAttribute},
|
||||||
};
|
};
|
||||||
const std::array<TextureInfo, 0> LocationIndicatorShaderSource::textures = {};
|
const std::array<TextureInfo, 0> LocationIndicatorShaderSource::textures = {};
|
||||||
|
|
||||||
@@ -22,11 +22,11 @@ using LocationIndicatorShaderTexturedSource =
|
|||||||
ShaderSource<BuiltIn::LocationIndicatorTexturedShader, gfx::Backend::Type::Vulkan>;
|
ShaderSource<BuiltIn::LocationIndicatorTexturedShader, gfx::Backend::Type::Vulkan>;
|
||||||
|
|
||||||
const std::array<AttributeInfo, 2> LocationIndicatorShaderTexturedSource::attributes = {
|
const std::array<AttributeInfo, 2> LocationIndicatorShaderTexturedSource::attributes = {
|
||||||
AttributeInfo{0, gfx::AttributeDataType::Float2, idCommonPosVertexAttribute},
|
AttributeInfo{0, gfx::AttributeDataType::Float2, idLocationIndicatorPosVertexAttribute},
|
||||||
AttributeInfo{1, gfx::AttributeDataType::Float2, idCommonTexVertexAttribute},
|
AttributeInfo{1, gfx::AttributeDataType::Float2, idLocationIndicatorTexVertexAttribute},
|
||||||
};
|
};
|
||||||
const std::array<TextureInfo, 1> LocationIndicatorShaderTexturedSource::textures = {
|
const std::array<TextureInfo, 1> LocationIndicatorShaderTexturedSource::textures = {
|
||||||
TextureInfo{0, idCommonTexture},
|
TextureInfo{0, idLocationIndicatorTexture},
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace shaders
|
} // namespace shaders
|
||||||
|
|||||||
@@ -26,9 +26,11 @@
|
|||||||
#include <mbgl/gfx/renderable.hpp>
|
#include <mbgl/gfx/renderable.hpp>
|
||||||
#include <mbgl/gfx/renderer_backend.hpp>
|
#include <mbgl/gfx/renderer_backend.hpp>
|
||||||
#include <mbgl/shaders/widevector_ubo.hpp>
|
#include <mbgl/shaders/widevector_ubo.hpp>
|
||||||
|
#include <mbgl/shaders/custom_geometry_ubo.hpp>
|
||||||
#include <mbgl/util/projection.hpp>
|
#include <mbgl/util/projection.hpp>
|
||||||
#include <mbgl/util/mat4.hpp>
|
#include <mbgl/util/mat4.hpp>
|
||||||
#include <mbgl/renderer/render_tile.hpp>
|
#include <mbgl/renderer/render_tile.hpp>
|
||||||
|
#include <mbgl/gfx/uniform_buffer.hpp>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
@@ -89,8 +91,11 @@ const LayerTypeInfo* CustomDrawableLayer::Impl::staticTypeInfo() noexcept {
|
|||||||
|
|
||||||
class LineDrawableTweaker : public gfx::DrawableTweaker {
|
class LineDrawableTweaker : public gfx::DrawableTweaker {
|
||||||
public:
|
public:
|
||||||
LineDrawableTweaker(const shaders::LineEvaluatedPropsUBO& properties)
|
LineDrawableTweaker(const CustomDrawableLayerHost::Interface::LineOptions& options_,
|
||||||
: propsUBO(properties) {}
|
CustomDrawableLayerHost::Interface::LineTweakerCallback&& callback_)
|
||||||
|
: options(options_),
|
||||||
|
callback(callback_) {}
|
||||||
|
|
||||||
~LineDrawableTweaker() override = default;
|
~LineDrawableTweaker() override = default;
|
||||||
|
|
||||||
void init(gfx::Drawable&) override {}
|
void init(gfx::Drawable&) override {}
|
||||||
@@ -100,14 +105,55 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
callback(drawable, parameters, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MLN_UBO_CONSOLIDATION
|
||||||
|
if (!layerUniforms) {
|
||||||
|
layerUniforms = parameters.context.createLayerUniformBufferArray();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
||||||
const auto zoom = parameters.state.getZoom();
|
const auto zoom = parameters.state.getZoom();
|
||||||
mat4 tileMatrix;
|
|
||||||
parameters.state.matrixFor(/*out*/ tileMatrix, tileID);
|
|
||||||
|
|
||||||
const auto matrix = LayerTweaker::getTileMatrix(
|
const auto matrix = LayerTweaker::getTileMatrix(
|
||||||
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, drawable, false);
|
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, drawable, false);
|
||||||
|
|
||||||
|
const shaders::LineEvaluatedPropsUBO propsUBO = {options.color,
|
||||||
|
options.blur,
|
||||||
|
options.opacity,
|
||||||
|
options.gapWidth,
|
||||||
|
options.offset,
|
||||||
|
options.width,
|
||||||
|
/*floorwidth=*/0.0f,
|
||||||
|
LineExpressionMask::None,
|
||||||
|
0};
|
||||||
|
|
||||||
|
// We would need to set up `idLineExpressionUBO` if the expression mask isn't empty
|
||||||
|
assert(propsUBO.expressionMask == LineExpressionMask::None);
|
||||||
|
|
||||||
|
if (!expressionUniformBuffer) {
|
||||||
|
const LineExpressionUBO exprUBO = {
|
||||||
|
/* .color = */ nullptr,
|
||||||
|
/* .blur = */ nullptr,
|
||||||
|
/* .opacity = */ nullptr,
|
||||||
|
/* .gapwidth = */ nullptr,
|
||||||
|
/* .offset = */ nullptr,
|
||||||
|
/* .width = */ nullptr,
|
||||||
|
/* .floorWidth = */ nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
|
expressionUniformBuffer = parameters.context.createUniformBuffer(&exprUBO, sizeof(exprUBO));
|
||||||
|
#if MLN_UBO_CONSOLIDATION
|
||||||
|
layerUniforms->set(idLineExpressionUBO, expressionUniformBuffer);
|
||||||
|
#else
|
||||||
|
auto& drawableUniforms = drawable.mutableUniformBuffers();
|
||||||
|
drawableUniforms.set(idLineExpressionUBO, expressionUniformBuffer);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if MLN_UBO_CONSOLIDATION
|
#if MLN_UBO_CONSOLIDATION
|
||||||
shaders::LineDrawableUnionUBO drawableUBO;
|
shaders::LineDrawableUnionUBO drawableUBO;
|
||||||
drawableUBO.lineDrawableUBO = {
|
drawableUBO.lineDrawableUBO = {
|
||||||
@@ -125,33 +171,45 @@ public:
|
|||||||
/* .width_t = */ 0.f,
|
/* .width_t = */ 0.f,
|
||||||
/* .pad1 = */ 0
|
/* .pad1 = */ 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if MLN_UBO_CONSOLIDATION
|
||||||
|
if (!drawableUniformBuffer) {
|
||||||
|
drawableUniformBuffer = parameters.context.createUniformBuffer(
|
||||||
|
&drawableUBO, sizeof(drawableUBO), false, true);
|
||||||
|
|
||||||
|
layerUniforms->set(idLineDrawableUBO, drawableUniformBuffer);
|
||||||
|
drawable.setUBOIndex(0);
|
||||||
|
} else {
|
||||||
|
drawableUniformBuffer->update(&drawableUBO, sizeof(drawableUBO));
|
||||||
|
}
|
||||||
|
|
||||||
|
layerUniforms->createOrUpdate(idLineEvaluatedPropsUBO, &propsUBO, sizeof(propsUBO), parameters.context);
|
||||||
|
layerUniforms->bind(*parameters.renderPass);
|
||||||
|
#else
|
||||||
auto& drawableUniforms = drawable.mutableUniformBuffers();
|
auto& drawableUniforms = drawable.mutableUniformBuffers();
|
||||||
drawableUniforms.createOrUpdate(idLineDrawableUBO, &drawableUBO, parameters.context, true);
|
drawableUniforms.createOrUpdate(idLineDrawableUBO, &drawableUBO, parameters.context);
|
||||||
drawableUniforms.createOrUpdate(idLineEvaluatedPropsUBO, &propsUBO, parameters.context);
|
drawableUniforms.createOrUpdate(idLineEvaluatedPropsUBO, &propsUBO, parameters.context);
|
||||||
|
#endif
|
||||||
// We would need to set up `idLineExpressionUBO` if the expression mask isn't empty
|
|
||||||
assert(propsUBO.expressionMask == LineExpressionMask::None);
|
|
||||||
|
|
||||||
const LineExpressionUBO exprUBO = {
|
|
||||||
/* .color = */ nullptr,
|
|
||||||
/* .blur = */ nullptr,
|
|
||||||
/* .opacity = */ nullptr,
|
|
||||||
/* .gapwidth = */ nullptr,
|
|
||||||
/* .offset = */ nullptr,
|
|
||||||
/* .width = */ nullptr,
|
|
||||||
/* .floorWidth = */ nullptr,
|
|
||||||
};
|
|
||||||
drawableUniforms.createOrUpdate(idLineExpressionUBO, &exprUBO, parameters.context);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
shaders::LineEvaluatedPropsUBO propsUBO;
|
CustomDrawableLayerHost::Interface::LineOptions options;
|
||||||
|
CustomDrawableLayerHost::Interface::LineTweakerCallback callback;
|
||||||
|
|
||||||
|
#if MLN_UBO_CONSOLIDATION
|
||||||
|
gfx::UniqueUniformBufferArray layerUniforms;
|
||||||
|
gfx::UniformBufferPtr drawableUniformBuffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gfx::UniformBufferPtr expressionUniformBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WideVectorDrawableTweaker : public gfx::DrawableTweaker {
|
class WideVectorDrawableTweaker : public gfx::DrawableTweaker {
|
||||||
public:
|
public:
|
||||||
WideVectorDrawableTweaker(const CustomDrawableLayerHost::Interface::LineOptions& options_)
|
WideVectorDrawableTweaker(const CustomDrawableLayerHost::Interface::LineOptions& options_,
|
||||||
: options(options_) {}
|
CustomDrawableLayerHost::Interface::LineTweakerCallback&& callback_)
|
||||||
|
: options(options_),
|
||||||
|
callback(callback_) {}
|
||||||
|
|
||||||
void init(gfx::Drawable&) override {}
|
void init(gfx::Drawable&) override {}
|
||||||
|
|
||||||
@@ -160,6 +218,10 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
callback(drawable, parameters, options);
|
||||||
|
}
|
||||||
|
|
||||||
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
||||||
|
|
||||||
mat4 tileMatrix;
|
mat4 tileMatrix;
|
||||||
@@ -211,13 +273,16 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CustomDrawableLayerHost::Interface::LineOptions options;
|
CustomDrawableLayerHost::Interface::LineOptions options;
|
||||||
|
CustomDrawableLayerHost::Interface::LineTweakerCallback callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FillDrawableTweaker : public gfx::DrawableTweaker {
|
class FillDrawableTweaker : public gfx::DrawableTweaker {
|
||||||
public:
|
public:
|
||||||
FillDrawableTweaker(const Color& color_, float opacity_)
|
FillDrawableTweaker(const CustomDrawableLayerHost::Interface::FillOptions& options_,
|
||||||
: color(color_),
|
CustomDrawableLayerHost::Interface::FillTweakerCallback&& callback_)
|
||||||
opacity(opacity_) {}
|
: options(options_),
|
||||||
|
callback(callback_) {}
|
||||||
|
|
||||||
~FillDrawableTweaker() override = default;
|
~FillDrawableTweaker() override = default;
|
||||||
|
|
||||||
void init(gfx::Drawable&) override {}
|
void init(gfx::Drawable&) override {}
|
||||||
@@ -227,15 +292,29 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
if (callback) {
|
||||||
mat4 tileMatrix;
|
callback(drawable, parameters, options);
|
||||||
parameters.state.matrixFor(/*out*/ tileMatrix, tileID);
|
}
|
||||||
|
|
||||||
|
#if MLN_UBO_CONSOLIDATION
|
||||||
|
if (!layerUniforms) {
|
||||||
|
layerUniforms = parameters.context.createLayerUniformBufferArray();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
||||||
const auto matrix = LayerTweaker::getTileMatrix(
|
const auto matrix = LayerTweaker::getTileMatrix(
|
||||||
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, drawable, false);
|
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, drawable, false);
|
||||||
|
|
||||||
|
const shaders::FillEvaluatedPropsUBO propsUBO = {/* .color = */ options.color,
|
||||||
|
/* .outline_color = */ Color::white(),
|
||||||
|
/* .opacity = */ options.opacity,
|
||||||
|
/* .fade = */ 0.f,
|
||||||
|
/* .from_scale = */ 0.f,
|
||||||
|
/* .to_scale = */ 0.f};
|
||||||
|
|
||||||
#if MLN_UBO_CONSOLIDATION
|
#if MLN_UBO_CONSOLIDATION
|
||||||
shaders::FillDrawableUnionUBO drawableUBO;
|
FillDrawableUnionUBO drawableUBO;
|
||||||
drawableUBO.fillDrawableUBO = {
|
drawableUBO.fillDrawableUBO = {
|
||||||
#else
|
#else
|
||||||
const shaders::FillDrawableUBO drawableUBO = {
|
const shaders::FillDrawableUBO drawableUBO = {
|
||||||
@@ -248,26 +327,42 @@ public:
|
|||||||
/* .pad2 = */ 0
|
/* .pad2 = */ 0
|
||||||
};
|
};
|
||||||
|
|
||||||
const shaders::FillEvaluatedPropsUBO propsUBO = {/* .color = */ color,
|
#if MLN_UBO_CONSOLIDATION
|
||||||
/* .outline_color = */ Color::white(),
|
if (!drawableUniformBuffer) {
|
||||||
/* .opacity = */ opacity,
|
drawableUniformBuffer = parameters.context.createUniformBuffer(
|
||||||
/* .fade = */ 0.f,
|
&drawableUBO, sizeof(drawableUBO), false, true);
|
||||||
/* .from_scale = */ 0.f,
|
|
||||||
/* .to_scale = */ 0.f};
|
layerUniforms->set(idFillDrawableUBO, drawableUniformBuffer);
|
||||||
|
drawable.setUBOIndex(0);
|
||||||
|
} else {
|
||||||
|
drawableUniformBuffer->update(&drawableUBO, sizeof(drawableUBO));
|
||||||
|
}
|
||||||
|
|
||||||
|
layerUniforms->createOrUpdate(idFillEvaluatedPropsUBO, &propsUBO, sizeof(propsUBO), parameters.context);
|
||||||
|
layerUniforms->bind(*parameters.renderPass);
|
||||||
|
#else
|
||||||
auto& drawableUniforms = drawable.mutableUniformBuffers();
|
auto& drawableUniforms = drawable.mutableUniformBuffers();
|
||||||
drawableUniforms.createOrUpdate(idFillDrawableUBO, &drawableUBO, parameters.context);
|
drawableUniforms.createOrUpdate(idFillDrawableUBO, &drawableUBO, parameters.context);
|
||||||
drawableUniforms.createOrUpdate(idFillEvaluatedPropsUBO, &propsUBO, parameters.context);
|
drawableUniforms.createOrUpdate(idFillEvaluatedPropsUBO, &propsUBO, parameters.context);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Color color;
|
CustomDrawableLayerHost::Interface::FillOptions options;
|
||||||
float opacity;
|
CustomDrawableLayerHost::Interface::FillTweakerCallback callback;
|
||||||
|
|
||||||
|
#if MLN_UBO_CONSOLIDATION
|
||||||
|
gfx::UniqueUniformBufferArray layerUniforms;
|
||||||
|
gfx::UniformBufferPtr drawableUniformBuffer;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class SymbolDrawableTweaker : public gfx::DrawableTweaker {
|
class SymbolDrawableTweaker : public gfx::DrawableTweaker {
|
||||||
public:
|
public:
|
||||||
SymbolDrawableTweaker(const CustomDrawableLayerHost::Interface::SymbolOptions& options_)
|
SymbolDrawableTweaker(const CustomDrawableLayerHost::Interface::SymbolOptions& options_,
|
||||||
: options(options_) {}
|
CustomDrawableLayerHost::Interface::SymbolTweakerCallback&& callback_)
|
||||||
|
: options(options_),
|
||||||
|
callback(callback_) {}
|
||||||
~SymbolDrawableTweaker() override = default;
|
~SymbolDrawableTweaker() override = default;
|
||||||
|
|
||||||
void init(gfx::Drawable&) override {}
|
void init(gfx::Drawable&) override {}
|
||||||
@@ -277,9 +372,11 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
callback(drawable, parameters, options);
|
||||||
|
}
|
||||||
|
|
||||||
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
||||||
mat4 tileMatrix;
|
|
||||||
parameters.state.matrixFor(/*out*/ tileMatrix, tileID);
|
|
||||||
|
|
||||||
const auto matrix = LayerTweaker::getTileMatrix(
|
const auto matrix = LayerTweaker::getTileMatrix(
|
||||||
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, drawable, false);
|
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, drawable, false);
|
||||||
@@ -312,6 +409,38 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CustomDrawableLayerHost::Interface::SymbolOptions options;
|
CustomDrawableLayerHost::Interface::SymbolOptions options;
|
||||||
|
CustomDrawableLayerHost::Interface::SymbolTweakerCallback callback;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GeometryDrawableTweaker : public gfx::DrawableTweaker {
|
||||||
|
public:
|
||||||
|
GeometryDrawableTweaker(const CustomDrawableLayerHost::Interface::GeometryOptions& options_,
|
||||||
|
CustomDrawableLayerHost::Interface::GeometryTweakerCallback&& callback_)
|
||||||
|
: options(options_),
|
||||||
|
callback(callback_) {}
|
||||||
|
~GeometryDrawableTweaker() override = default;
|
||||||
|
|
||||||
|
void init(gfx::Drawable&) override {}
|
||||||
|
|
||||||
|
void execute(gfx::Drawable& drawable, PaintParameters& parameters) override {
|
||||||
|
if (!drawable.getTileID().has_value()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
callback(drawable, parameters, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomGeometryDrawableUBO drawableUBO = {/* .matrix = */ util::cast<float>(options.matrix),
|
||||||
|
/* .color = */ options.color};
|
||||||
|
|
||||||
|
auto& drawableUniforms = drawable.mutableUniformBuffers();
|
||||||
|
drawableUniforms.createOrUpdate(idCustomGeometryDrawableUBO, &drawableUBO, parameters.context);
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
CustomDrawableLayerHost::Interface::GeometryOptions options;
|
||||||
|
CustomDrawableLayerHost::Interface::GeometryTweakerCallback callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
CustomDrawableLayerHost::Interface::Interface(RenderLayer& layer_,
|
CustomDrawableLayerHost::Interface::Interface(RenderLayer& layer_,
|
||||||
@@ -364,6 +493,11 @@ void CustomDrawableLayerHost::Interface::setSymbolOptions(const SymbolOptions& o
|
|||||||
symbolOptions = options;
|
symbolOptions = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CustomDrawableLayerHost::Interface::setGeometryOptions(const GeometryOptions& options) {
|
||||||
|
finish();
|
||||||
|
geometryOptions = options;
|
||||||
|
}
|
||||||
|
|
||||||
bool CustomDrawableLayerHost::Interface::updateBuilder(BuilderType type,
|
bool CustomDrawableLayerHost::Interface::updateBuilder(BuilderType type,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
gfx::ShaderPtr shader) {
|
gfx::ShaderPtr shader) {
|
||||||
@@ -378,17 +512,22 @@ bool CustomDrawableLayerHost::Interface::updateBuilder(BuilderType type,
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool CustomDrawableLayerHost::Interface::addPolyline(const LineString<double>& coordinates) {
|
util::SimpleIdentity CustomDrawableLayerHost::Interface::addPolyline(const LineString<double>& coordinates,
|
||||||
switch (lineOptions.shaderType) {
|
LineShaderType shaderType) {
|
||||||
|
#if !MLN_RENDER_BACKEND_METAL
|
||||||
|
shaderType = LineShaderType::Classic;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (shaderType) {
|
||||||
case LineShaderType::Classic: {
|
case LineShaderType::Classic: {
|
||||||
// TODO: build classic polyline with Geo coordinates
|
// TODO: build classic polyline with Geo coordinates
|
||||||
return false;
|
return util::SimpleIdentity::Empty;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case LineShaderType::MetalWideVector: {
|
case LineShaderType::WideVector: {
|
||||||
// build wide vector polyline with Geo coordinates
|
// build wide vector polyline with Geo coordinates
|
||||||
if (!updateBuilder(BuilderType::LineWideVector, "custom-lines-widevector", lineShaderWideVector()))
|
if (!updateBuilder(BuilderType::LineWideVector, "custom-lines-widevector", lineShaderWideVector()))
|
||||||
return false;
|
return util::SimpleIdentity::Empty;
|
||||||
|
|
||||||
// geographic coordinates require tile {0, 0, 0}
|
// geographic coordinates require tile {0, 0, 0}
|
||||||
setTileID({0, 0, 0});
|
setTileID({0, 0, 0});
|
||||||
@@ -397,32 +536,42 @@ bool CustomDrawableLayerHost::Interface::addPolyline(const LineString<double>& c
|
|||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return builder->getCurrentDrawable(true)->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CustomDrawableLayerHost::Interface::addPolyline(const GeometryCoordinates& coordinates) {
|
util::SimpleIdentity CustomDrawableLayerHost::Interface::addPolyline(const GeometryCoordinates& coordinates,
|
||||||
switch (lineOptions.shaderType) {
|
LineShaderType shaderType) {
|
||||||
|
#if !MLN_RENDER_BACKEND_METAL
|
||||||
|
shaderType = LineShaderType::Classic;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (shaderType) {
|
||||||
case LineShaderType::Classic: {
|
case LineShaderType::Classic: {
|
||||||
// build classic polyline with Tile coordinates
|
// build classic polyline with Tile coordinates
|
||||||
if (!updateBuilder(BuilderType::LineClassic, "custom-lines", lineShaderDefault())) return false;
|
if (!updateBuilder(BuilderType::LineClassic, "custom-lines", lineShaderDefault())) {
|
||||||
|
return util::SimpleIdentity::Empty;
|
||||||
|
}
|
||||||
|
|
||||||
builder->addPolyline(coordinates, lineOptions.geometry);
|
builder->addPolyline(coordinates, lineOptions.geometry);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case LineShaderType::MetalWideVector: {
|
case LineShaderType::WideVector: {
|
||||||
// build wide vector polyline
|
// build wide vector polyline
|
||||||
if (!updateBuilder(BuilderType::LineWideVector, "custom-lines-widevector", lineShaderWideVector()))
|
if (!updateBuilder(BuilderType::LineWideVector, "custom-lines-widevector", lineShaderWideVector()))
|
||||||
return false;
|
return util::SimpleIdentity::Empty;
|
||||||
|
|
||||||
builder->addWideVectorPolylineLocal(coordinates, lineOptions.geometry);
|
builder->addWideVectorPolylineLocal(coordinates, lineOptions.geometry);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return builder->getCurrentDrawable(true)->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CustomDrawableLayerHost::Interface::addFill(const GeometryCollection& geometry) {
|
util::SimpleIdentity CustomDrawableLayerHost::Interface::addFill(const GeometryCollection& geometry) {
|
||||||
// build fill
|
// build fill
|
||||||
if (!updateBuilder(BuilderType::Fill, "custom-fill", fillShaderDefault())) return false;
|
if (!updateBuilder(BuilderType::Fill, "custom-fill", fillShaderDefault())) {
|
||||||
|
return util::SimpleIdentity::Empty;
|
||||||
|
}
|
||||||
|
|
||||||
// provision buffers for fill vertices, indexes and segments
|
// provision buffers for fill vertices, indexes and segments
|
||||||
using VertexVector = gfx::VertexVector<FillLayoutVertex>;
|
using VertexVector = gfx::VertexVector<FillLayoutVertex>;
|
||||||
@@ -451,15 +600,20 @@ bool CustomDrawableLayerHost::Interface::addFill(const GeometryCollection& geome
|
|||||||
builder->setRawVertices({}, vertices.elements(), gfx::AttributeDataType::Short2);
|
builder->setRawVertices({}, vertices.elements(), gfx::AttributeDataType::Short2);
|
||||||
builder->setSegments(gfx::Triangles(), sharedTriangles, triangleSegments.data(), triangleSegments.size());
|
builder->setSegments(gfx::Triangles(), sharedTriangles, triangleSegments.data(), triangleSegments.size());
|
||||||
|
|
||||||
|
const auto& id = builder->getCurrentDrawable(true)->getID();
|
||||||
|
|
||||||
// flush current builder drawable
|
// flush current builder drawable
|
||||||
builder->flush(context);
|
builder->flush(context);
|
||||||
|
|
||||||
return true;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CustomDrawableLayerHost::Interface::addSymbol(const GeometryCoordinate& point) {
|
util::SimpleIdentity CustomDrawableLayerHost::Interface::addSymbol(
|
||||||
|
const GeometryCoordinate& point, const std::array<std::array<float, 2>, 2>& textureCoordinates) {
|
||||||
// build symbol
|
// build symbol
|
||||||
if (!updateBuilder(BuilderType::Symbol, "custom-symbol", symbolShaderDefault())) return false;
|
if (!updateBuilder(BuilderType::Symbol, "custom-symbol", symbolShaderDefault())) {
|
||||||
|
return util::SimpleIdentity::Empty;
|
||||||
|
}
|
||||||
|
|
||||||
// temporary: buffers
|
// temporary: buffers
|
||||||
struct CustomSymbolIcon {
|
struct CustomSymbolIcon {
|
||||||
@@ -477,7 +631,7 @@ bool CustomDrawableLayerHost::Interface::addSymbol(const GeometryCoordinate& poi
|
|||||||
for (int x = 0; x <= 1; ++x) {
|
for (int x = 0; x <= 1; ++x) {
|
||||||
vertices.emplace_back(
|
vertices.emplace_back(
|
||||||
CustomSymbolIcon{{static_cast<float>(point.x * 2 + x), static_cast<float>(point.y * 2 + y)},
|
CustomSymbolIcon{{static_cast<float>(point.x * 2 + x), static_cast<float>(point.y * 2 + y)},
|
||||||
{symbolOptions.textureCoordinates[x][0], symbolOptions.textureCoordinates[y][1]}});
|
{textureCoordinates[x][0], textureCoordinates[y][1]}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,13 +671,83 @@ bool CustomDrawableLayerHost::Interface::addSymbol(const GeometryCoordinate& poi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create symbol tweaker
|
// create symbol tweaker
|
||||||
auto tweaker = std::make_shared<SymbolDrawableTweaker>(symbolOptions);
|
auto tweaker = std::make_shared<SymbolDrawableTweaker>(symbolOptions, std::move(symbolTweakerCallback));
|
||||||
builder->addTweaker(tweaker);
|
builder->addTweaker(tweaker);
|
||||||
|
|
||||||
|
const auto& id = builder->getCurrentDrawable(true)->getID();
|
||||||
|
|
||||||
// flush current builder drawable
|
// flush current builder drawable
|
||||||
builder->flush(context);
|
builder->flush(context);
|
||||||
|
|
||||||
return true;
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
util::SimpleIdentity CustomDrawableLayerHost::Interface::addGeometry(
|
||||||
|
std::shared_ptr<gfx::VertexVector<GeometryVertex>> vertices,
|
||||||
|
std::shared_ptr<gfx::IndexVector<gfx::Triangles>> indices,
|
||||||
|
bool is3D) {
|
||||||
|
if (!vertices || !indices) {
|
||||||
|
return util::SimpleIdentity::Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!updateBuilder(BuilderType::Geometry, "custom-geometry", geometryShaderDefault())) {
|
||||||
|
return util::SimpleIdentity::Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
// geographic coordinates require tile {0, 0, 0}
|
||||||
|
setTileID({0, 0, 0});
|
||||||
|
|
||||||
|
SegmentVector<GeometryVertex> triangleSegments;
|
||||||
|
triangleSegments.emplace_back(Segment<GeometryVertex>{0, 0, vertices->elements(), indices->elements()});
|
||||||
|
|
||||||
|
// add to builder
|
||||||
|
auto attrs = context.createVertexAttributeArray();
|
||||||
|
if (const auto& attr = attrs->set(idCustomGeometryPosVertexAttribute)) {
|
||||||
|
attr->setSharedRawData(vertices,
|
||||||
|
offsetof(GeometryVertex, position),
|
||||||
|
/*vertexOffset=*/0,
|
||||||
|
sizeof(GeometryVertex),
|
||||||
|
gfx::AttributeDataType::Float3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const auto& attr = attrs->set(idCustomGeometryTexVertexAttribute)) {
|
||||||
|
attr->setSharedRawData(vertices,
|
||||||
|
offsetof(GeometryVertex, texcoords),
|
||||||
|
/*vertexOffset=*/0,
|
||||||
|
sizeof(GeometryVertex),
|
||||||
|
gfx::AttributeDataType::Float2);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder->setVertexAttributes(std::move(attrs));
|
||||||
|
builder->setRawVertices({}, vertices->elements(), gfx::AttributeDataType::Float3);
|
||||||
|
builder->setSegments(gfx::Triangles(), indices, triangleSegments.data(), triangleSegments.size());
|
||||||
|
|
||||||
|
builder->setEnableDepth(true);
|
||||||
|
|
||||||
|
if (is3D) {
|
||||||
|
builder->setDepthType(gfx::DepthMaskType::ReadWrite);
|
||||||
|
builder->setIs3D(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// white texture
|
||||||
|
if (!geometryOptions.texture) {
|
||||||
|
auto image = std::make_shared<PremultipliedImage>(mbgl::Size(2, 2));
|
||||||
|
image->fill(255);
|
||||||
|
|
||||||
|
geometryOptions.texture = context.createTexture2D();
|
||||||
|
geometryOptions.texture->setImage(std::move(image));
|
||||||
|
}
|
||||||
|
|
||||||
|
builder->setTexture(geometryOptions.texture, shaders::idCustomGeometryTexture);
|
||||||
|
|
||||||
|
builder->addTweaker(std::make_shared<GeometryDrawableTweaker>(geometryOptions, std::move(geometryTweakerCallback)));
|
||||||
|
|
||||||
|
const auto& id = builder->getCurrentDrawable(true)->getID();
|
||||||
|
|
||||||
|
// flush current builder drawable
|
||||||
|
builder->flush(context);
|
||||||
|
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomDrawableLayerHost::Interface::finish() {
|
void CustomDrawableLayerHost::Interface::finish() {
|
||||||
@@ -552,16 +776,7 @@ void CustomDrawableLayerHost::Interface::finish() {
|
|||||||
// finish building classic lines
|
// finish building classic lines
|
||||||
|
|
||||||
// create line tweaker
|
// create line tweaker
|
||||||
const shaders::LineEvaluatedPropsUBO linePropertiesUBO = {lineOptions.color,
|
auto tweaker = std::make_shared<LineDrawableTweaker>(lineOptions, std::move(lineTweakerCallback));
|
||||||
lineOptions.blur,
|
|
||||||
lineOptions.opacity,
|
|
||||||
lineOptions.gapWidth,
|
|
||||||
lineOptions.offset,
|
|
||||||
lineOptions.width,
|
|
||||||
/*floorwidth=*/0,
|
|
||||||
LineExpressionMask::None,
|
|
||||||
0};
|
|
||||||
auto tweaker = std::make_shared<LineDrawableTweaker>(linePropertiesUBO);
|
|
||||||
|
|
||||||
// finish drawables
|
// finish drawables
|
||||||
finish_(tweaker);
|
finish_(tweaker);
|
||||||
@@ -570,7 +785,7 @@ void CustomDrawableLayerHost::Interface::finish() {
|
|||||||
// finish building wide vector lines
|
// finish building wide vector lines
|
||||||
|
|
||||||
// create line tweaker
|
// create line tweaker
|
||||||
auto tweaker = std::make_shared<WideVectorDrawableTweaker>(lineOptions);
|
auto tweaker = std::make_shared<WideVectorDrawableTweaker>(lineOptions, std::move(lineTweakerCallback));
|
||||||
|
|
||||||
// finish drawables
|
// finish drawables
|
||||||
finish_(tweaker);
|
finish_(tweaker);
|
||||||
@@ -579,7 +794,7 @@ void CustomDrawableLayerHost::Interface::finish() {
|
|||||||
// finish building fills
|
// finish building fills
|
||||||
|
|
||||||
// create fill tweaker
|
// create fill tweaker
|
||||||
auto tweaker = std::make_shared<FillDrawableTweaker>(fillOptions.color, fillOptions.opacity);
|
auto tweaker = std::make_shared<FillDrawableTweaker>(fillOptions, std::move(fillTweakerCallback));
|
||||||
|
|
||||||
// finish drawables
|
// finish drawables
|
||||||
finish_(tweaker);
|
finish_(tweaker);
|
||||||
@@ -588,12 +803,21 @@ void CustomDrawableLayerHost::Interface::finish() {
|
|||||||
// finish building symbols
|
// finish building symbols
|
||||||
finish_(nullptr);
|
finish_(nullptr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BuilderType::Geometry:
|
||||||
|
finish_(nullptr);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CustomDrawableLayerHost::Interface::removeDrawable(const util::SimpleIdentity& id) {
|
||||||
|
TileLayerGroup* tileLayerGroup = static_cast<TileLayerGroup*>(layerGroup.get());
|
||||||
|
tileLayerGroup->removeDrawablesIf([&](gfx::Drawable& drawable) { return drawable.getID() == id; });
|
||||||
|
}
|
||||||
|
|
||||||
gfx::ShaderPtr CustomDrawableLayerHost::Interface::lineShaderDefault() const {
|
gfx::ShaderPtr CustomDrawableLayerHost::Interface::lineShaderDefault() const {
|
||||||
gfx::ShaderGroupPtr shaderGroup = shaders.getShaderGroup("LineShader");
|
gfx::ShaderGroupPtr shaderGroup = shaders.getShaderGroup("LineShader");
|
||||||
assert(shaderGroup);
|
assert(shaderGroup);
|
||||||
@@ -630,6 +854,10 @@ gfx::ShaderPtr CustomDrawableLayerHost::Interface::symbolShaderDefault() const {
|
|||||||
return context.getGenericShader(shaders, "CustomSymbolIconShader");
|
return context.getGenericShader(shaders, "CustomSymbolIconShader");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfx::ShaderPtr CustomDrawableLayerHost::Interface::geometryShaderDefault() const {
|
||||||
|
return context.getGenericShader(shaders, "CustomGeometryShader");
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<gfx::DrawableBuilder> CustomDrawableLayerHost::Interface::createBuilder(const std::string& name,
|
std::unique_ptr<gfx::DrawableBuilder> CustomDrawableLayerHost::Interface::createBuilder(const std::string& name,
|
||||||
gfx::ShaderPtr shader) const {
|
gfx::ShaderPtr shader) const {
|
||||||
std::unique_ptr<gfx::DrawableBuilder> builder_ = context.createDrawableBuilder(name);
|
std::unique_ptr<gfx::DrawableBuilder> builder_ = context.createDrawableBuilder(name);
|
||||||
|
|||||||
@@ -366,6 +366,11 @@ gfx::UniformBufferPtr Context::createUniformBuffer(const void* data, std::size_t
|
|||||||
data, size, ssbo ? VK_BUFFER_USAGE_STORAGE_BUFFER_BIT : VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, persistent));
|
data, size, ssbo ? VK_BUFFER_USAGE_STORAGE_BUFFER_BIT : VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, persistent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniqueUniformBufferArray Context::createLayerUniformBufferArray() {
|
||||||
|
return std::make_unique<UniformBufferArray>(
|
||||||
|
DescriptorSetType::Layer, shaders::globalUBOCount, shaders::maxSSBOCountPerLayer, shaders::maxUBOCountPerLayer);
|
||||||
|
}
|
||||||
|
|
||||||
gfx::ShaderProgramBasePtr Context::getGenericShader(gfx::ShaderRegistry& shaders, const std::string& name) {
|
gfx::ShaderProgramBasePtr Context::getGenericShader(gfx::ShaderRegistry& shaders, const std::string& name) {
|
||||||
const auto shaderGroup = shaders.getShaderGroup(name);
|
const auto shaderGroup = shaders.getShaderGroup(name);
|
||||||
auto shader = shaderGroup ? shaderGroup->getOrCreateShader(*this, {}) : gfx::ShaderProgramBasePtr{};
|
auto shader = shaderGroup ? shaderGroup->getOrCreateShader(*this, {}) : gfx::ShaderProgramBasePtr{};
|
||||||
|
|||||||
@@ -260,23 +260,30 @@ void Drawable::draw(PaintParameters& parameters) const {
|
|||||||
sizeof(uboIndex),
|
sizeof(uboIndex),
|
||||||
&uboIndex);
|
&uboIndex);
|
||||||
|
|
||||||
if (is3D) {
|
if (enableDepth) {
|
||||||
impl->pipelineInfo.setDepthMode(impl->depthFor3D);
|
if (impl->depthFor3D.has_value()) {
|
||||||
impl->pipelineInfo.setStencilMode(impl->stencilFor3D);
|
impl->pipelineInfo.setDepthMode(impl->depthFor3D.value());
|
||||||
} else {
|
} else if (is3D) {
|
||||||
if (enableDepth) {
|
impl->pipelineInfo.setDepthMode(parameters.depthModeFor3D());
|
||||||
|
} else {
|
||||||
const auto& depthMode = parameters.depthModeForSublayer(getSubLayerIndex(), getDepthType());
|
const auto& depthMode = parameters.depthModeForSublayer(getSubLayerIndex(), getDepthType());
|
||||||
impl->pipelineInfo.setDepthMode(depthMode);
|
impl->pipelineInfo.setDepthMode(depthMode);
|
||||||
} else {
|
|
||||||
impl->pipelineInfo.setDepthMode(gfx::DepthMode::disabled());
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
impl->pipelineInfo.setDepthMode(gfx::DepthMode::disabled());
|
||||||
|
}
|
||||||
|
|
||||||
if (enableStencil) {
|
if (enableStencil) {
|
||||||
|
if (impl->stencilFor3D.has_value()) {
|
||||||
|
impl->pipelineInfo.setStencilMode(impl->stencilFor3D.value());
|
||||||
|
} else if (is3D) {
|
||||||
|
impl->pipelineInfo.setStencilMode(parameters.stencilModeFor3D());
|
||||||
|
} else {
|
||||||
const auto& stencilMode = parameters.stencilModeForClipping(tileID->toUnwrapped());
|
const auto& stencilMode = parameters.stencilModeForClipping(tileID->toUnwrapped());
|
||||||
impl->pipelineInfo.setStencilMode(stencilMode);
|
impl->pipelineInfo.setStencilMode(stencilMode);
|
||||||
} else {
|
|
||||||
impl->pipelineInfo.setStencilMode(gfx::StencilMode::disabled());
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
impl->pipelineInfo.setStencilMode(gfx::StencilMode::disabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->pipelineInfo.setRenderable(renderPass_.getDescriptor().renderable);
|
impl->pipelineInfo.setRenderable(renderPass_.getDescriptor().renderable);
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ public:
|
|||||||
|
|
||||||
std::optional<gfx::RenderPassDescriptor> renderPassDescriptor;
|
std::optional<gfx::RenderPassDescriptor> renderPassDescriptor;
|
||||||
|
|
||||||
gfx::DepthMode depthFor3D = gfx::DepthMode::disabled();
|
std::optional<gfx::DepthMode> depthFor3D;
|
||||||
gfx::StencilMode stencilFor3D = gfx::StencilMode::disabled();
|
std::optional<gfx::StencilMode> stencilFor3D;
|
||||||
|
|
||||||
PipelineInfo pipelineInfo;
|
PipelineInfo pipelineInfo;
|
||||||
|
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ void LayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& tweaker : drawable.getTweakers()) {
|
|
||||||
tweaker->execute(drawable, parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bindUBOs) {
|
if (!bindUBOs) {
|
||||||
uniformBuffers.bindDescriptorSets(encoder);
|
uniformBuffers.bindDescriptorSets(encoder);
|
||||||
bindUBOs = true;
|
bindUBOs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& tweaker : drawable.getTweakers()) {
|
||||||
|
tweaker->execute(drawable, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
drawable.draw(parameters);
|
drawable.draw(parameters);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <mbgl/shaders/vulkan/circle.hpp>
|
#include <mbgl/shaders/vulkan/circle.hpp>
|
||||||
#include <mbgl/shaders/vulkan/clipping_mask.hpp>
|
#include <mbgl/shaders/vulkan/clipping_mask.hpp>
|
||||||
#include <mbgl/shaders/vulkan/collision.hpp>
|
#include <mbgl/shaders/vulkan/collision.hpp>
|
||||||
|
#include <mbgl/shaders/vulkan/custom_geometry.hpp>
|
||||||
#include <mbgl/shaders/vulkan/custom_symbol_icon.hpp>
|
#include <mbgl/shaders/vulkan/custom_symbol_icon.hpp>
|
||||||
#include <mbgl/shaders/vulkan/debug.hpp>
|
#include <mbgl/shaders/vulkan/debug.hpp>
|
||||||
#include <mbgl/shaders/vulkan/fill.hpp>
|
#include <mbgl/shaders/vulkan/fill.hpp>
|
||||||
@@ -669,6 +670,7 @@ void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramPar
|
|||||||
shaders::BuiltIn::ClippingMaskProgram,
|
shaders::BuiltIn::ClippingMaskProgram,
|
||||||
shaders::BuiltIn::CollisionBoxShader,
|
shaders::BuiltIn::CollisionBoxShader,
|
||||||
shaders::BuiltIn::CollisionCircleShader,
|
shaders::BuiltIn::CollisionCircleShader,
|
||||||
|
shaders::BuiltIn::CustomGeometryShader,
|
||||||
shaders::BuiltIn::CustomSymbolIconShader,
|
shaders::BuiltIn::CustomSymbolIconShader,
|
||||||
shaders::BuiltIn::DebugShader,
|
shaders::BuiltIn::DebugShader,
|
||||||
shaders::BuiltIn::FillShader,
|
shaders::BuiltIn::FillShader,
|
||||||
|
|||||||
@@ -92,15 +92,15 @@ void TileLayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& tweaker : drawable.getTweakers()) {
|
|
||||||
tweaker->execute(drawable, parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bindUBOs) {
|
if (!bindUBOs) {
|
||||||
uniformBuffers.bindDescriptorSets(encoder);
|
uniformBuffers.bindDescriptorSets(encoder);
|
||||||
bindUBOs = true;
|
bindUBOs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& tweaker : drawable.getTweakers()) {
|
||||||
|
tweaker->execute(drawable, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
if (features3d) {
|
if (features3d) {
|
||||||
auto& drawableImpl = static_cast<Drawable&>(drawable);
|
auto& drawableImpl = static_cast<Drawable&>(drawable);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <mbgl/vulkan/context.hpp>
|
#include <mbgl/vulkan/context.hpp>
|
||||||
#include <mbgl/util/logging.hpp>
|
#include <mbgl/util/logging.hpp>
|
||||||
#include <mbgl/vulkan/command_encoder.hpp>
|
#include <mbgl/vulkan/command_encoder.hpp>
|
||||||
|
#include <mbgl/vulkan/render_pass.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
@@ -68,6 +69,10 @@ void UniformBufferArray::createOrUpdate(
|
|||||||
gfx::UniformBufferArray::createOrUpdate(id, data, size, context, persistent);
|
gfx::UniformBufferArray::createOrUpdate(id, data, size, context, persistent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UniformBufferArray::bind(gfx::RenderPass& renderPass) {
|
||||||
|
bindDescriptorSets(static_cast<RenderPass&>(renderPass).getEncoder());
|
||||||
|
}
|
||||||
|
|
||||||
void UniformBufferArray::bindDescriptorSets(CommandEncoder& encoder) {
|
void UniformBufferArray::bindDescriptorSets(CommandEncoder& encoder) {
|
||||||
if (!descriptorSet) {
|
if (!descriptorSet) {
|
||||||
descriptorSet = std::make_unique<UniformDescriptorSet>(encoder.getContext(), descriptorSetType);
|
descriptorSet = std::make_unique<UniformDescriptorSet>(encoder.getContext(), descriptorSetType);
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ public:
|
|||||||
/*gapWidth=*/0.0f,
|
/*gapWidth=*/0.0f,
|
||||||
/*offset=*/0.0f,
|
/*offset=*/0.0f,
|
||||||
/*width=*/8.0f,
|
/*width=*/8.0f,
|
||||||
/*shaderType*/ {},
|
|
||||||
/*color=*/Color::red(),
|
/*color=*/Color::red(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -58,7 +57,6 @@ public:
|
|||||||
/*gapWidth=*/2.0f,
|
/*gapWidth=*/2.0f,
|
||||||
/*offset=*/-1.0f,
|
/*offset=*/-1.0f,
|
||||||
/*width=*/4.0f,
|
/*width=*/4.0f,
|
||||||
{},
|
|
||||||
/*color=*/Color::blue(),
|
/*color=*/Color::blue(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -68,7 +66,6 @@ public:
|
|||||||
/*gapWidth=*/1.0f,
|
/*gapWidth=*/1.0f,
|
||||||
/*offset=*/2.0f,
|
/*offset=*/2.0f,
|
||||||
/*width=*/16.0f,
|
/*width=*/16.0f,
|
||||||
{},
|
|
||||||
/*color=*/Color(1.f, 0.5f, 0, 0.5f),
|
/*color=*/Color(1.f, 0.5f, 0, 0.5f),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -78,7 +75,6 @@ public:
|
|||||||
/*gapWidth=*/1.0f,
|
/*gapWidth=*/1.0f,
|
||||||
/*offset=*/-2.0f,
|
/*offset=*/-2.0f,
|
||||||
/*width=*/2.0f,
|
/*width=*/2.0f,
|
||||||
{},
|
|
||||||
/*color=*/Color(1.f, 1.f, 0, 0.3f),
|
/*color=*/Color(1.f, 1.f, 0, 0.3f),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -88,7 +84,6 @@ public:
|
|||||||
/*gapWidth=*/1.0f,
|
/*gapWidth=*/1.0f,
|
||||||
/*offset=*/0.5f,
|
/*offset=*/0.5f,
|
||||||
/*width=*/0.5f,
|
/*width=*/0.5f,
|
||||||
{},
|
|
||||||
/*color=*/Color::black(),
|
/*color=*/Color::black(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -98,7 +93,6 @@ public:
|
|||||||
/*gapWidth=*/1.0f,
|
/*gapWidth=*/1.0f,
|
||||||
/*offset=*/-5.0f,
|
/*offset=*/-5.0f,
|
||||||
/*width=*/24.0f,
|
/*width=*/24.0f,
|
||||||
{},
|
|
||||||
/*color=*/Color(1.f, 0, 1.f, 0.2f),
|
/*color=*/Color(1.f, 0, 1.f, 0.2f),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -125,7 +119,7 @@ public:
|
|||||||
interface.setLineOptions(options[index]);
|
interface.setLineOptions(options[index]);
|
||||||
|
|
||||||
// add polyline
|
// add polyline
|
||||||
interface.addPolyline(polyline);
|
interface.addPolyline(polyline, Interface::LineShaderType::Classic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,10 +213,10 @@ public:
|
|||||||
options.texture->setImage(image);
|
options.texture->setImage(image);
|
||||||
options.texture->setSamplerConfiguration(
|
options.texture->setSamplerConfiguration(
|
||||||
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp});
|
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp});
|
||||||
options.textureCoordinates = {{{0.0f, 0.08f}, {1.0f, 0.9f}}};
|
constexpr std::array<std::array<float, 2>, 2> textureCoordinates = {{{0.0f, 0.08f}, {1.0f, 0.9f}}};
|
||||||
const float xspan = options.textureCoordinates[1][0] - options.textureCoordinates[0][0];
|
constexpr float xspan = textureCoordinates[1][0] - textureCoordinates[0][0];
|
||||||
const float yspan = options.textureCoordinates[1][1] - options.textureCoordinates[0][1];
|
constexpr float yspan = textureCoordinates[1][1] - textureCoordinates[0][1];
|
||||||
assert(xspan > 0.0f && yspan > 0.0f);
|
static_assert(xspan > 0.0f && yspan > 0.0f);
|
||||||
options.size = {static_cast<uint32_t>(image->size.width * 0.2f * xspan),
|
options.size = {static_cast<uint32_t>(image->size.width * 0.2f * xspan),
|
||||||
static_cast<uint32_t>(image->size.height * 0.2f * yspan)};
|
static_cast<uint32_t>(image->size.height * 0.2f * yspan)};
|
||||||
options.anchor = {0.5f, 0.95f};
|
options.anchor = {0.5f, 0.95f};
|
||||||
@@ -232,7 +226,7 @@ public:
|
|||||||
interface.setSymbolOptions(options);
|
interface.setSymbolOptions(options);
|
||||||
|
|
||||||
// add symbol
|
// add symbol
|
||||||
interface.addSymbol(position);
|
interface.addSymbol(position, textureCoordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finish
|
// finish
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include <mbgl/shaders/mtl/circle.hpp>
|
#include <mbgl/shaders/mtl/circle.hpp>
|
||||||
#include <mbgl/shaders/mtl/clipping_mask.hpp>
|
#include <mbgl/shaders/mtl/clipping_mask.hpp>
|
||||||
#include <mbgl/shaders/mtl/collision.hpp>
|
#include <mbgl/shaders/mtl/collision.hpp>
|
||||||
|
#include <mbgl/shaders/mtl/custom_geometry.hpp>
|
||||||
|
#include <mbgl/shaders/mtl/custom_symbol_icon.hpp>
|
||||||
#include <mbgl/shaders/mtl/debug.hpp>
|
#include <mbgl/shaders/mtl/debug.hpp>
|
||||||
#include <mbgl/shaders/mtl/fill.hpp>
|
#include <mbgl/shaders/mtl/fill.hpp>
|
||||||
#include <mbgl/shaders/mtl/fill_extrusion.hpp>
|
#include <mbgl/shaders/mtl/fill_extrusion.hpp>
|
||||||
@@ -22,6 +24,7 @@
|
|||||||
#include <mbgl/shaders/mtl/hillshade.hpp>
|
#include <mbgl/shaders/mtl/hillshade.hpp>
|
||||||
#include <mbgl/shaders/mtl/hillshade_prepare.hpp>
|
#include <mbgl/shaders/mtl/hillshade_prepare.hpp>
|
||||||
#include <mbgl/shaders/mtl/line.hpp>
|
#include <mbgl/shaders/mtl/line.hpp>
|
||||||
|
#include <mbgl/shaders/mtl/location_indicator.hpp>
|
||||||
#include <mbgl/shaders/mtl/fill.hpp>
|
#include <mbgl/shaders/mtl/fill.hpp>
|
||||||
#include <mbgl/shaders/mtl/raster.hpp>
|
#include <mbgl/shaders/mtl/raster.hpp>
|
||||||
#include <mbgl/shaders/mtl/symbol.hpp>
|
#include <mbgl/shaders/mtl/symbol.hpp>
|
||||||
@@ -128,6 +131,8 @@ TEST(OrderIndependentHash, Shaders) {
|
|||||||
BuiltIn::CircleShader,
|
BuiltIn::CircleShader,
|
||||||
BuiltIn::CollisionBoxShader,
|
BuiltIn::CollisionBoxShader,
|
||||||
BuiltIn::CollisionCircleShader,
|
BuiltIn::CollisionCircleShader,
|
||||||
|
BuiltIn::CustomGeometryShader,
|
||||||
|
BuiltIn::CustomSymbolIconShader,
|
||||||
BuiltIn::DebugShader,
|
BuiltIn::DebugShader,
|
||||||
BuiltIn::FillShader,
|
BuiltIn::FillShader,
|
||||||
BuiltIn::FillOutlineShader,
|
BuiltIn::FillOutlineShader,
|
||||||
@@ -144,6 +149,8 @@ TEST(OrderIndependentHash, Shaders) {
|
|||||||
BuiltIn::LineGradientShader,
|
BuiltIn::LineGradientShader,
|
||||||
BuiltIn::LinePatternShader,
|
BuiltIn::LinePatternShader,
|
||||||
BuiltIn::LineSDFShader,
|
BuiltIn::LineSDFShader,
|
||||||
|
BuiltIn::LocationIndicatorShader,
|
||||||
|
BuiltIn::LocationIndicatorTexturedShader,
|
||||||
BuiltIn::RasterShader,
|
BuiltIn::RasterShader,
|
||||||
BuiltIn::SymbolIconShader,
|
BuiltIn::SymbolIconShader,
|
||||||
BuiltIn::SymbolSDFIconShader,
|
BuiltIn::SymbolSDFIconShader,
|
||||||
|
|||||||
19
vendor/tinyobjloader.cmake
vendored
Normal file
19
vendor/tinyobjloader.cmake
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
tinyobjloader
|
||||||
|
GIT_REPOSITORY "https://github.com/tinyobjloader/tinyobjloader.git"
|
||||||
|
GIT_TAG release
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
GIT_PROGRESS TRUE
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(tinyobjloader)
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
tinyobjloader
|
||||||
|
PROPERTIES
|
||||||
|
INTERFACE_MAPLIBRE_NAME "tinyobjloader"
|
||||||
|
INTERFACE_MAPLIBRE_URL "https://github.com/tinyobjloader/tinyobjloader.git"
|
||||||
|
INTERFACE_MAPLIBRE_LICENSE ${CMAKE_CURRENT_LIST_DIR}/tinyobjloader/LICENSE
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user