Use drawables for location indicator layer (#2836)
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
This commit is contained in:
@@ -24,6 +24,9 @@ public:
|
||||
TextureWrapType wrapU{TextureWrapType::Clamp};
|
||||
/// Wrapping behavior along V coordinate
|
||||
TextureWrapType wrapV{TextureWrapType::Clamp};
|
||||
|
||||
uint8_t maxAnisotropy{1};
|
||||
bool mipmapped{false};
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
20
include/mbgl/shaders/common_ubo.hpp
Normal file
20
include/mbgl/shaders/common_ubo.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/shaders/layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
struct alignas(16) CommonUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
Color color;
|
||||
};
|
||||
static_assert(sizeof(CommonUBO) % 16 == 0);
|
||||
|
||||
enum {
|
||||
idCommonUBO = globalUBOCount,
|
||||
commonUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/shaders/common_ubo.hpp>
|
||||
#include <mbgl/shaders/background_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/circle_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/collision_layer_ubo.hpp>
|
||||
@@ -31,6 +32,7 @@ static constexpr auto maxUBOCountPerShader = std::max({static_cast<size_t>(backg
|
||||
static_cast<size_t>(circleUBOCount),
|
||||
static_cast<size_t>(clippingMaskUBOCount),
|
||||
static_cast<size_t>(collisionUBOCount),
|
||||
static_cast<size_t>(commonUBOCount),
|
||||
static_cast<size_t>(customSymbolUBOCount),
|
||||
static_cast<size_t>(debugUBOCount),
|
||||
static_cast<size_t>(fillUBOCount),
|
||||
@@ -62,6 +64,11 @@ enum {
|
||||
collisionTextureCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCommonTexture,
|
||||
commonTextureCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCustomSymbolImageTexture,
|
||||
customSymbolTextureCount
|
||||
@@ -114,6 +121,7 @@ static constexpr auto maxTextureCountPerShader = std::max({static_cast<size_t>(b
|
||||
static_cast<size_t>(circleTextureCount),
|
||||
static_cast<size_t>(clippingMaskTextureCount),
|
||||
static_cast<size_t>(collisionTextureCount),
|
||||
static_cast<size_t>(commonTextureCount),
|
||||
static_cast<size_t>(customSymbolTextureCount),
|
||||
static_cast<size_t>(debugTextureCount),
|
||||
static_cast<size_t>(fillTextureCount),
|
||||
@@ -159,6 +167,12 @@ enum {
|
||||
collisionVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCommonPosVertexAttribute,
|
||||
idCommonTexVertexAttribute,
|
||||
commonVertexAttributeCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCustomSymbolPosVertexAttribute,
|
||||
idCustomSymbolTexVertexAttribute,
|
||||
@@ -276,6 +290,7 @@ static constexpr auto maxVertexAttributeCountPerShader = std::max({
|
||||
static_cast<size_t>(circleVertexAttributeCount),
|
||||
static_cast<size_t>(clippingMaskVertexAttributeCount),
|
||||
static_cast<size_t>(collisionVertexAttributeCount),
|
||||
static_cast<size_t>(commonVertexAttributeCount),
|
||||
static_cast<size_t>(customSymbolVertexAttributeCount),
|
||||
static_cast<size_t>(debugVertexAttributeCount),
|
||||
static_cast<size_t>(fillVertexAttributeCount),
|
||||
|
||||
@@ -14,6 +14,8 @@ enum class BuiltIn {
|
||||
CircleShader,
|
||||
CollisionBoxShader,
|
||||
CollisionCircleShader,
|
||||
CommonShader,
|
||||
CommonTexturedShader,
|
||||
DebugShader,
|
||||
FillShader,
|
||||
FillOutlineShader,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
#include <mbgl/shaders/vulkan/shader_program.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -100,5 +101,82 @@ layout(set = 0, binding = 0) uniform GlobalPaintParamsUBO {
|
||||
)";
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CommonShader, gfx::Backend::Type::Vulkan> {
|
||||
static constexpr const char* name = "CommonShader";
|
||||
|
||||
static const std::array<UniformBlockInfo, 1> uniforms;
|
||||
static const std::array<AttributeInfo, 1> attributes;
|
||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||
static constexpr std::array<TextureInfo, 0> textures{};
|
||||
|
||||
static constexpr auto vertex = R"(
|
||||
layout(location = 0) in vec2 in_position;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CommonUBO {
|
||||
mat4 matrix;
|
||||
vec4 color;
|
||||
} ubo;
|
||||
|
||||
void main() {
|
||||
gl_Position = ubo.matrix * vec4(in_position, 0, 1);
|
||||
gl_Position.y *= -1.0;
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr auto fragment = R"(
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CommonUBO {
|
||||
mat4 matrix;
|
||||
vec4 color;
|
||||
} ubo;
|
||||
|
||||
void main() {
|
||||
out_color = ubo.color;
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ShaderSource<BuiltIn::CommonTexturedShader, gfx::Backend::Type::Vulkan> {
|
||||
static constexpr const char* name = "CommonTexturedShader";
|
||||
|
||||
static const std::array<UniformBlockInfo, 1> uniforms;
|
||||
static const std::array<AttributeInfo, 2> attributes;
|
||||
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
|
||||
static const std::array<TextureInfo, 1> textures;
|
||||
|
||||
static constexpr auto vertex = R"(
|
||||
layout(location = 0) in vec2 in_position;
|
||||
layout(location = 1) in vec2 in_texcoord;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CommonUBO {
|
||||
mat4 matrix;
|
||||
vec4 color;
|
||||
} ubo;
|
||||
|
||||
layout(location = 0) out vec2 frag_uv;
|
||||
|
||||
void main() {
|
||||
gl_Position = ubo.matrix * vec4(in_position, 0, 1);
|
||||
gl_Position.y *= -1.0;
|
||||
|
||||
frag_uv = in_texcoord;
|
||||
}
|
||||
)";
|
||||
|
||||
static constexpr auto fragment = R"(
|
||||
layout(location = 0) in vec2 frag_uv;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image_sampler;
|
||||
|
||||
void main() {
|
||||
out_color = texture(image_sampler, frag_uv);
|
||||
}
|
||||
)";
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -96,6 +96,9 @@ private:
|
||||
void transitionToShaderReadLayout(const vk::UniqueCommandBuffer&);
|
||||
void transitionToGeneralLayout(const vk::UniqueCommandBuffer&);
|
||||
|
||||
uint32_t getMipLevels() const;
|
||||
void generateMips(const vk::UniqueCommandBuffer& buffer);
|
||||
|
||||
private:
|
||||
Context& context;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user