Group descriptor sets by binding frequency (#2892)
This commit is contained in:
@@ -1299,6 +1299,7 @@ if(MLN_WITH_VULKAN)
|
||||
${PROJECT_SOURCE_DIR}/include/mbgl/vulkan/command_encoder.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/mbgl/vulkan/context.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/mbgl/vulkan/drawable.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/mbgl/vulkan/descriptor_set.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/mbgl/vulkan/drawable_builder.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/mbgl/vulkan/index_buffer_resource.hpp
|
||||
${PROJECT_SOURCE_DIR}/include/mbgl/vulkan/layer_group.hpp
|
||||
@@ -1334,6 +1335,7 @@ if(MLN_WITH_VULKAN)
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/vulkan/buffer_resource.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/vulkan/command_encoder.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/vulkan/context.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/vulkan/descriptor_set.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/vulkan/drawable.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/vulkan/drawable_builder.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/vulkan/drawable_impl.hpp
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/util/identity.hpp>
|
||||
#include <mbgl/util/monotonic_timer.hpp>
|
||||
#include <mbgl/util/traits.hpp>
|
||||
#include <mbgl/util/immutable.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <memory>
|
||||
#include <array>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gfx {
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gfx {
|
||||
|
||||
@@ -58,11 +62,12 @@ public:
|
||||
const std::shared_ptr<UniformBuffer>& get(const size_t id) const;
|
||||
|
||||
/// Set a new uniform buffer element or replace the existing one.
|
||||
const std::shared_ptr<UniformBuffer>& set(const size_t id, std::shared_ptr<UniformBuffer> uniformBuffer);
|
||||
virtual const std::shared_ptr<UniformBuffer>& set(const size_t id, std::shared_ptr<UniformBuffer> uniformBuffer);
|
||||
|
||||
/// Create and add a new buffer or update an existing one
|
||||
void createOrUpdate(const size_t id, const std::vector<uint8_t>& data, gfx::Context&, bool persistent = false);
|
||||
void createOrUpdate(const size_t id, const void* data, std::size_t size, gfx::Context&, bool persistent = false);
|
||||
virtual void createOrUpdate(
|
||||
const size_t id, const void* data, std::size_t size, gfx::Context&, bool persistent = false);
|
||||
template <typename T>
|
||||
void createOrUpdate(const size_t id, const T* data, gfx::Context& context, bool persistent = false)
|
||||
requires(!std::is_pointer_v<T>)
|
||||
|
||||
@@ -50,11 +50,5 @@ struct alignas(16) BackgroundPatternLayerUBO {
|
||||
};
|
||||
static_assert(sizeof(BackgroundPatternLayerUBO) == 64);
|
||||
|
||||
enum {
|
||||
idBackgroundDrawableUBO = globalUBOCount,
|
||||
idBackgroundLayerUBO,
|
||||
backgroundUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -46,12 +46,5 @@ struct alignas(16) CircleInterpolateUBO {
|
||||
};
|
||||
static_assert(sizeof(CircleInterpolateUBO) % 16 == 0);
|
||||
|
||||
enum {
|
||||
idCircleDrawableUBO = globalUBOCount,
|
||||
idCircleEvaluatedPropsUBO,
|
||||
idCircleInterpolateUBO,
|
||||
circleUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -14,10 +14,5 @@ struct alignas(16) CollisionUBO {
|
||||
static_assert(sizeof(CollisionUBO) % 16 == 0);
|
||||
static_assert(sizeof(CollisionUBO) == 80);
|
||||
|
||||
enum {
|
||||
idCollisionUBO = globalUBOCount,
|
||||
collisionUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -11,10 +11,5 @@ struct alignas(16) CommonUBO {
|
||||
};
|
||||
static_assert(sizeof(CommonUBO) % 16 == 0);
|
||||
|
||||
enum {
|
||||
idCommonUBO = globalUBOCount,
|
||||
commonUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -26,11 +26,5 @@ struct alignas(16) CustomSymbolIconParametersUBO {
|
||||
};
|
||||
static_assert(sizeof(CustomSymbolIconParametersUBO) == 3 * 16);
|
||||
|
||||
enum {
|
||||
idCustomSymbolDrawableUBO = globalUBOCount,
|
||||
idCustomSymbolParametersUBO,
|
||||
customSymbolUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -13,10 +13,5 @@ struct alignas(16) DebugUBO {
|
||||
};
|
||||
static_assert(sizeof(DebugUBO) % 16 == 0);
|
||||
|
||||
enum {
|
||||
idDebugUBO = globalUBOCount,
|
||||
debugUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -57,13 +57,5 @@ struct alignas(16) FillExtrusionInterpolateUBO {
|
||||
};
|
||||
static_assert(sizeof(FillExtrusionInterpolateUBO) == 2 * 16);
|
||||
|
||||
enum {
|
||||
idFillExtrusionDrawableUBO = globalUBOCount,
|
||||
idFillExtrusionPropsUBO,
|
||||
idFillExtrusionTilePropsUBO,
|
||||
idFillExtrusionInterpolateUBO,
|
||||
fillExtrusionUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -116,13 +116,5 @@ struct alignas(16) FillEvaluatedPropsUBO {
|
||||
};
|
||||
static_assert(sizeof(FillEvaluatedPropsUBO) == 3 * 16);
|
||||
|
||||
enum {
|
||||
idFillDrawableUBO = globalUBOCount,
|
||||
idFillTilePropsUBO,
|
||||
idFillInterpolateUBO,
|
||||
idFillEvaluatedPropsUBO,
|
||||
fillUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -27,12 +27,5 @@ struct alignas(16) HeatmapInterpolateUBO {
|
||||
};
|
||||
static_assert(sizeof(HeatmapInterpolateUBO) % 16 == 0);
|
||||
|
||||
enum {
|
||||
idHeatmapDrawableUBO = globalUBOCount,
|
||||
idHeatmapEvaluatedPropsUBO,
|
||||
idHeatmapInterpolateUBO,
|
||||
heatmapUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -12,10 +12,5 @@ struct alignas(16) HeatmapTexturePropsUBO {
|
||||
};
|
||||
static_assert(sizeof(HeatmapTexturePropsUBO) % 16 == 0);
|
||||
|
||||
enum {
|
||||
idHeatmapTexturePropsUBO = globalUBOCount,
|
||||
heatmapTextureUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -19,11 +19,5 @@ struct alignas(16) HillshadeEvaluatedPropsUBO {
|
||||
};
|
||||
static_assert(sizeof(HillshadeEvaluatedPropsUBO) % 16 == 0);
|
||||
|
||||
enum {
|
||||
idHillshadeDrawableUBO = globalUBOCount,
|
||||
idHillshadeEvaluatedPropsUBO,
|
||||
hillshadeUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -14,10 +14,5 @@ struct alignas(16) HillshadePrepareDrawableUBO {
|
||||
};
|
||||
static_assert(sizeof(HillshadePrepareDrawableUBO) % 16 == 0);
|
||||
|
||||
enum {
|
||||
idHillshadePrepareDrawableUBO = globalUBOCount,
|
||||
hillshadePrepareUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -143,14 +143,5 @@ struct alignas(16) LineEvaluatedPropsUBO {
|
||||
};
|
||||
static_assert(sizeof(LineEvaluatedPropsUBO) % 16 == 0);
|
||||
|
||||
enum {
|
||||
idLineDrawableUBO = globalUBOCount,
|
||||
idLineInterpolationUBO,
|
||||
idLineTilePropertiesUBO,
|
||||
idLineEvaluatedPropsUBO,
|
||||
idLineExpressionUBO,
|
||||
lineUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -110,8 +110,8 @@ struct alignas(16) CircleInterpolateUBO {
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const GlobalPaintParamsUBO& paintParams [[buffer(0)]],
|
||||
device const CircleDrawableUBO& drawable [[buffer(1)]],
|
||||
device const CircleEvaluatedPropsUBO& props [[buffer(2)]],
|
||||
device const CircleInterpolateUBO& interp [[buffer(3)]]) {
|
||||
device const CircleInterpolateUBO& interp [[buffer(2)]],
|
||||
device const CircleEvaluatedPropsUBO& props [[buffer(3)]]) {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_radius)
|
||||
const auto radius = props.radius;
|
||||
@@ -189,7 +189,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
}
|
||||
|
||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const CircleEvaluatedPropsUBO& props [[buffer(2)]]) {
|
||||
device const CircleEvaluatedPropsUBO& props [[buffer(3)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
return half4(1.0);
|
||||
#endif
|
||||
|
||||
@@ -47,8 +47,8 @@ struct FragmentOutput {
|
||||
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const FillExtrusionDrawableUBO& drawable [[buffer(1)]],
|
||||
device const FillExtrusionPropsUBO& props [[buffer(2)]],
|
||||
device const FillExtrusionInterpolateUBO& interp [[buffer(4)]]) {
|
||||
device const FillExtrusionInterpolateUBO& interp [[buffer(3)]],
|
||||
device const FillExtrusionPropsUBO& props [[buffer(4)]]) {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_base)
|
||||
const auto base = props.light_position_base.w;
|
||||
|
||||
@@ -60,9 +60,9 @@ struct FragmentOutput {
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const GlobalPaintParamsUBO& paintParams [[buffer(0)]],
|
||||
device const FillExtrusionDrawableUBO& drawable [[buffer(1)]],
|
||||
device const FillExtrusionPropsUBO& props [[buffer(2)]],
|
||||
device const FillExtrusionTilePropsUBO& tileProps [[buffer(3)]],
|
||||
device const FillExtrusionInterpolateUBO& interp [[buffer(4)]]) {
|
||||
device const FillExtrusionTilePropsUBO& tileProps [[buffer(2)]],
|
||||
device const FillExtrusionInterpolateUBO& interp [[buffer(3)]],
|
||||
device const FillExtrusionPropsUBO& props [[buffer(4)]]) {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_base)
|
||||
const auto base = props.light_position_base.w;
|
||||
@@ -151,8 +151,8 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
|
||||
fragment FragmentOutput fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const FillExtrusionDrawableUBO& drawable [[buffer(1)]],
|
||||
device const FillExtrusionPropsUBO& props [[buffer(2)]],
|
||||
device const FillExtrusionTilePropsUBO& tileProps [[buffer(3)]],
|
||||
device const FillExtrusionTilePropsUBO& tileProps [[buffer(2)]],
|
||||
device const FillExtrusionPropsUBO& props [[buffer(4)]],
|
||||
texture2d<float, access::sample> image0 [[texture(0)]],
|
||||
sampler image0_sampler [[sampler(0)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
|
||||
@@ -68,8 +68,8 @@ constant const float ZERO = 1.0 / 255.0 / 16.0;
|
||||
|
||||
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
device const HeatmapDrawableUBO& drawable [[buffer(1)]],
|
||||
device const HeatmapEvaluatedPropsUBO& props [[buffer(2)]],
|
||||
device const HeatmapInterpolateUBO& interp [[buffer(3)]]) {
|
||||
device const HeatmapInterpolateUBO& interp [[buffer(2)]],
|
||||
device const HeatmapEvaluatedPropsUBO& props [[buffer(3)]]) {
|
||||
|
||||
#if defined(HAS_UNIFORM_u_weight)
|
||||
const auto weight = props.weight;
|
||||
@@ -117,7 +117,7 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
|
||||
}
|
||||
|
||||
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
|
||||
device const HeatmapEvaluatedPropsUBO& props [[buffer(2)]]) {
|
||||
device const HeatmapEvaluatedPropsUBO& props [[buffer(3)]]) {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
return half4(1.0);
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <mbgl/shaders/mtl/common.hpp>
|
||||
#include <mbgl/shaders/mtl/shader_program.hpp>
|
||||
#include <mbgl/shaders/widevector_ubo.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -19,14 +20,14 @@ struct ShaderSource<BuiltIn::WideVectorShader, gfx::Backend::Type::Metal> {
|
||||
UniformBlockInfo{true, false, sizeof(WideVectorUniformWideVecUBO), idWideVectorUniformWideVecUBO},
|
||||
};
|
||||
static constexpr std::array<AttributeInfo, 3> attributes{
|
||||
AttributeInfo{wideVectorUBOCount + 0, gfx::AttributeDataType::Float3, idWideVectorScreenPos},
|
||||
AttributeInfo{wideVectorUBOCount + 1, gfx::AttributeDataType::Float4, idWideVectorColor},
|
||||
AttributeInfo{wideVectorUBOCount + 2, gfx::AttributeDataType::Int, idWideVectorIndex}};
|
||||
AttributeInfo{wideVectorDrawableUBOCount + 0, gfx::AttributeDataType::Float3, idWideVectorScreenPos},
|
||||
AttributeInfo{wideVectorDrawableUBOCount + 1, gfx::AttributeDataType::Float4, idWideVectorColor},
|
||||
AttributeInfo{wideVectorDrawableUBOCount + 2, gfx::AttributeDataType::Int, idWideVectorIndex}};
|
||||
static constexpr std::array<AttributeInfo, 4> instanceAttributes{
|
||||
AttributeInfo{wideVectorUBOCount + 3, gfx::AttributeDataType::Float3, idWideVectorInstanceCenter},
|
||||
AttributeInfo{wideVectorUBOCount + 3, gfx::AttributeDataType::Float4, idWideVectorInstanceColor},
|
||||
AttributeInfo{wideVectorUBOCount + 3, gfx::AttributeDataType::Int, idWideVectorInstancePrevious},
|
||||
AttributeInfo{wideVectorUBOCount + 3, gfx::AttributeDataType::Int, idWideVectorInstanceNext}};
|
||||
AttributeInfo{wideVectorDrawableUBOCount + 3, gfx::AttributeDataType::Float3, idWideVectorInstanceCenter},
|
||||
AttributeInfo{wideVectorDrawableUBOCount + 3, gfx::AttributeDataType::Float4, idWideVectorInstanceColor},
|
||||
AttributeInfo{wideVectorDrawableUBOCount + 3, gfx::AttributeDataType::Int, idWideVectorInstancePrevious},
|
||||
AttributeInfo{wideVectorDrawableUBOCount + 3, gfx::AttributeDataType::Int, idWideVectorInstanceNext}};
|
||||
static constexpr std::array<TextureInfo, 0> textures{};
|
||||
|
||||
static constexpr auto source = R"(
|
||||
|
||||
@@ -25,11 +25,5 @@ struct alignas(16) RasterEvaluatedPropsUBO {
|
||||
};
|
||||
static_assert(sizeof(RasterEvaluatedPropsUBO) == 64);
|
||||
|
||||
enum {
|
||||
idRasterDrawableUBO = globalUBOCount,
|
||||
idRasterEvaluatedPropsUBO,
|
||||
rasterUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -1,50 +1,197 @@
|
||||
#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>
|
||||
#include <mbgl/shaders/custom_drawable_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/debug_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/fill_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/fill_extrusion_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/heatmap_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/heatmap_texture_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/hillshade_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/hillshade_prepare_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/line_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/raster_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/symbol_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/widevector_ubo.hpp>
|
||||
#include <mbgl/shaders/layer_ubo.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
// UBO defines
|
||||
// drawable UBOs
|
||||
|
||||
enum {
|
||||
idClippingMaskUBO = globalUBOCount,
|
||||
clippingMaskUBOCount
|
||||
};
|
||||
|
||||
static constexpr auto maxUBOCountPerShader = std::max({static_cast<size_t>(backgroundUBOCount),
|
||||
static_cast<size_t>(circleUBOCount),
|
||||
enum {
|
||||
idCommonUBO = globalUBOCount,
|
||||
commonDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCircleDrawableUBO = globalUBOCount,
|
||||
idCircleInterpolateUBO,
|
||||
circleDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idBackgroundDrawableUBO = globalUBOCount,
|
||||
backgroundDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCustomSymbolDrawableUBO = globalUBOCount,
|
||||
idCustomSymbolParametersUBO,
|
||||
customSymbolDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idCollisionUBO = globalUBOCount,
|
||||
collisionDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idDebugUBO = globalUBOCount,
|
||||
debugDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idFillDrawableUBO = globalUBOCount,
|
||||
idFillTilePropsUBO,
|
||||
idFillInterpolateUBO,
|
||||
fillDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idFillExtrusionDrawableUBO = globalUBOCount,
|
||||
idFillExtrusionTilePropsUBO,
|
||||
idFillExtrusionInterpolateUBO,
|
||||
fillExtrusionDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idHeatmapDrawableUBO = globalUBOCount,
|
||||
idHeatmapInterpolateUBO,
|
||||
heatmapDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idHillshadeDrawableUBO = globalUBOCount,
|
||||
hillshadeDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idHillshadePrepareDrawableUBO = globalUBOCount,
|
||||
hillshadePrepareDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idLineDrawableUBO = globalUBOCount,
|
||||
idLineInterpolationUBO,
|
||||
idLineTilePropertiesUBO,
|
||||
lineDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idRasterDrawableUBO = globalUBOCount,
|
||||
rasterDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idSymbolDrawableUBO = globalUBOCount,
|
||||
idSymbolTilePropsUBO,
|
||||
idSymbolInterpolateUBO,
|
||||
symbolDrawableUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idWideVectorUniformsUBO = globalUBOCount,
|
||||
idWideVectorUniformWideVecUBO,
|
||||
wideVectorDrawableUBOCount
|
||||
};
|
||||
|
||||
static constexpr auto layerUBOStartId = std::max({static_cast<size_t>(circleDrawableUBOCount),
|
||||
static_cast<size_t>(backgroundDrawableUBOCount),
|
||||
static_cast<size_t>(customSymbolDrawableUBOCount),
|
||||
static_cast<size_t>(collisionDrawableUBOCount),
|
||||
static_cast<size_t>(commonDrawableUBOCount),
|
||||
static_cast<size_t>(debugDrawableUBOCount),
|
||||
static_cast<size_t>(fillDrawableUBOCount),
|
||||
static_cast<size_t>(fillExtrusionDrawableUBOCount),
|
||||
static_cast<size_t>(heatmapDrawableUBOCount),
|
||||
static_cast<size_t>(hillshadeDrawableUBOCount),
|
||||
static_cast<size_t>(hillshadePrepareDrawableUBOCount),
|
||||
static_cast<size_t>(lineDrawableUBOCount),
|
||||
static_cast<size_t>(rasterDrawableUBOCount),
|
||||
static_cast<size_t>(symbolDrawableUBOCount),
|
||||
static_cast<size_t>(wideVectorDrawableUBOCount)});
|
||||
|
||||
static constexpr auto maxUBOCountPerDrawable = layerUBOStartId - globalUBOCount;
|
||||
|
||||
// layer UBOs
|
||||
|
||||
#if MLN_RENDER_BACKEND_VULKAN
|
||||
#define getLayerStartValue(packedValue) layerUBOStartId
|
||||
#else
|
||||
#define getLayerStartValue(packedValue) packedValue
|
||||
#endif
|
||||
|
||||
enum {
|
||||
idCircleEvaluatedPropsUBO = getLayerStartValue(circleDrawableUBOCount),
|
||||
circleUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idBackgroundLayerUBO = getLayerStartValue(backgroundDrawableUBOCount),
|
||||
backgroundUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idFillEvaluatedPropsUBO = getLayerStartValue(fillDrawableUBOCount),
|
||||
fillUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idFillExtrusionPropsUBO = getLayerStartValue(fillExtrusionDrawableUBOCount),
|
||||
fillExtrusionUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idHeatmapEvaluatedPropsUBO = getLayerStartValue(heatmapDrawableUBOCount),
|
||||
heatmapUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idHeatmapTexturePropsUBO = getLayerStartValue(globalUBOCount),
|
||||
heatmapTextureUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idHillshadeEvaluatedPropsUBO = getLayerStartValue(hillshadeDrawableUBOCount),
|
||||
hillshadeUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idLineEvaluatedPropsUBO = getLayerStartValue(lineDrawableUBOCount),
|
||||
idLineExpressionUBO,
|
||||
lineUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idRasterEvaluatedPropsUBO = getLayerStartValue(rasterDrawableUBOCount),
|
||||
rasterUBOCount
|
||||
};
|
||||
|
||||
enum {
|
||||
idSymbolEvaluatedPropsUBO = getLayerStartValue(symbolDrawableUBOCount),
|
||||
symbolUBOCount
|
||||
};
|
||||
|
||||
#undef getLayerStartValue
|
||||
|
||||
static constexpr auto maxUBOCountPerShader = std::max({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),
|
||||
static_cast<size_t>(fillExtrusionUBOCount),
|
||||
static_cast<size_t>(heatmapUBOCount),
|
||||
static_cast<size_t>(heatmapTextureUBOCount),
|
||||
static_cast<size_t>(hillshadeUBOCount),
|
||||
static_cast<size_t>(hillshadePrepareUBOCount),
|
||||
static_cast<size_t>(lineUBOCount),
|
||||
static_cast<size_t>(rasterUBOCount),
|
||||
static_cast<size_t>(symbolUBOCount),
|
||||
static_cast<size_t>(wideVectorUBOCount)});
|
||||
static_cast<size_t>(symbolUBOCount)});
|
||||
|
||||
static constexpr auto maxUBOCountPerLayer = maxUBOCountPerShader - layerUBOStartId;
|
||||
|
||||
// Texture defines
|
||||
enum {
|
||||
|
||||
@@ -65,13 +65,5 @@ struct alignas(16) SymbolEvaluatedPropsUBO {
|
||||
};
|
||||
static_assert(sizeof(SymbolEvaluatedPropsUBO) == 6 * 16);
|
||||
|
||||
enum {
|
||||
idSymbolDrawableUBO = globalUBOCount,
|
||||
idSymbolTilePropsUBO,
|
||||
idSymbolInterpolateUBO,
|
||||
idSymbolEvaluatedPropsUBO,
|
||||
symbolUBOCount
|
||||
};
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -19,7 +19,7 @@ struct ShaderSource<BuiltIn::BackgroundShader, gfx::Backend::Type::Vulkan> {
|
||||
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
|
||||
layout(set = 0, binding = 1) uniform BackgroundDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform BackgroundDrawableUBO {
|
||||
mat4 matrix;
|
||||
} drawable;
|
||||
|
||||
@@ -32,7 +32,7 @@ void main() {
|
||||
static constexpr auto fragment = R"(
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 2) uniform BackgroundLayerUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform BackgroundLayerUBO {
|
||||
vec4 color;
|
||||
float opacity;
|
||||
float pad1, pad2, pad3;
|
||||
@@ -63,7 +63,7 @@ struct ShaderSource<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::Vulkan
|
||||
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
|
||||
layout(set = 0, binding = 1) uniform BackgroundPatternDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform BackgroundPatternDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
@@ -71,7 +71,7 @@ layout(set = 0, binding = 1) uniform BackgroundPatternDrawableUBO {
|
||||
float pad1, pad2, pad3;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform BackgroundPatternLayerUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform BackgroundPatternLayerUBO {
|
||||
vec2 pattern_tl_a;
|
||||
vec2 pattern_br_a;
|
||||
vec2 pattern_tl_b;
|
||||
@@ -111,7 +111,7 @@ layout(location = 1) in vec2 frag_pos_b;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 2) uniform BackgroundPatternLayerUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform BackgroundPatternLayerUBO {
|
||||
vec2 pattern_tl_a;
|
||||
vec2 pattern_br_a;
|
||||
vec2 pattern_tl_b;
|
||||
@@ -124,7 +124,7 @@ layout(set = 0, binding = 2) uniform BackgroundPatternLayerUBO {
|
||||
float opacity;
|
||||
} layer;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
|
||||
@@ -47,13 +47,24 @@ layout(location = 6) in vec2 in_stroke_width;
|
||||
layout(location = 7) in vec2 in_stroke_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform CircleDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform CircleDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 extrude_scale;
|
||||
vec2 padding;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform CircleEvaluatedPropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform CircleInterpolateUBO {
|
||||
float color_t;
|
||||
float radius_t;
|
||||
float blur_t;
|
||||
float opacity_t;
|
||||
float stroke_color_t;
|
||||
float stroke_width_t;
|
||||
float stroke_opacity_t;
|
||||
float pad1_;
|
||||
} interp;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform CircleEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 stroke_color;
|
||||
float radius;
|
||||
@@ -66,17 +77,6 @@ layout(set = 0, binding = 2) uniform CircleEvaluatedPropsUBO {
|
||||
float padding;
|
||||
} props;
|
||||
|
||||
layout(set = 0, binding = 3) uniform CircleInterpolateUBO {
|
||||
float color_t;
|
||||
float radius_t;
|
||||
float blur_t;
|
||||
float opacity_t;
|
||||
float stroke_color_t;
|
||||
float stroke_width_t;
|
||||
float stroke_opacity_t;
|
||||
float pad1_;
|
||||
} interp;
|
||||
|
||||
layout(location = 0) out vec2 frag_extrude;
|
||||
layout(location = 1) out float frag_antialiasblur;
|
||||
|
||||
@@ -224,7 +224,7 @@ layout(location = 8) in lowp float frag_stroke_opacity;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 2) uniform CircleEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform CircleEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 stroke_color;
|
||||
float radius;
|
||||
|
||||
@@ -23,7 +23,7 @@ layout(location = 2) in ivec2 in_extrude;
|
||||
layout(location = 3) in uvec2 in_placed;
|
||||
layout(location = 4) in vec2 in_shift;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CollisionBoxUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform CollisionBoxUBO {
|
||||
mat4 matrix;
|
||||
vec2 extrude_scale;
|
||||
float overscale_factor;
|
||||
@@ -58,7 +58,7 @@ layout(location = 1) in float frag_notUsed;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CollisionBoxUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform CollisionBoxUBO {
|
||||
mat4 matrix;
|
||||
vec2 extrude_scale;
|
||||
float overscale_factor;
|
||||
@@ -103,7 +103,7 @@ layout(location = 1) in ivec2 in_anchor_position;
|
||||
layout(location = 2) in ivec2 in_extrude;
|
||||
layout(location = 3) in uvec2 in_placed;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CollisionCircleUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform CollisionCircleUBO {
|
||||
mat4 matrix;
|
||||
vec2 extrude_scale;
|
||||
float overscale_factor;
|
||||
@@ -148,7 +148,7 @@ layout(location = 4) in vec2 frag_extrude_scale;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CollisionCircleUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform CollisionCircleUBO {
|
||||
mat4 matrix;
|
||||
vec2 extrude_scale;
|
||||
float overscale_factor;
|
||||
|
||||
@@ -67,7 +67,12 @@ vec2 get_pattern_pos(const vec2 pixel_coord_upper, const vec2 pixel_coord_lower,
|
||||
return (tile_units_to_pixels * pos + offset) / pattern_size;
|
||||
}
|
||||
|
||||
layout(set = 0, binding = 0) uniform GlobalPaintParamsUBO {
|
||||
#define GLOBAL_SET_INDEX 0
|
||||
#define LAYER_SET_INDEX 1
|
||||
#define DRAWABLE_UBO_SET_INDEX 2
|
||||
#define DRAWABLE_IMAGE_SET_INDEX 3
|
||||
|
||||
layout(set = GLOBAL_SET_INDEX, binding = 0) uniform GlobalPaintParamsUBO {
|
||||
vec2 pattern_atlas_texsize;
|
||||
vec2 units_to_pixels;
|
||||
vec2 world_size;
|
||||
@@ -86,7 +91,12 @@ layout(set = 0, binding = 0) uniform GlobalPaintParamsUBO {
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
#define SDF_PX 8.0
|
||||
|
||||
layout(set = 0, binding = 0) uniform GlobalPaintParamsUBO {
|
||||
#define GLOBAL_SET_INDEX 0
|
||||
#define LAYER_SET_INDEX 1
|
||||
#define DRAWABLE_UBO_SET_INDEX 2
|
||||
#define DRAWABLE_IMAGE_SET_INDEX 3
|
||||
|
||||
layout(set = GLOBAL_SET_INDEX, binding = 0) uniform GlobalPaintParamsUBO {
|
||||
vec2 pattern_atlas_texsize;
|
||||
vec2 units_to_pixels;
|
||||
vec2 world_size;
|
||||
@@ -113,7 +123,7 @@ struct ShaderSource<BuiltIn::CommonShader, gfx::Backend::Type::Vulkan> {
|
||||
static constexpr auto vertex = R"(
|
||||
layout(location = 0) in vec2 in_position;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CommonUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform CommonUBO {
|
||||
mat4 matrix;
|
||||
vec4 color;
|
||||
} ubo;
|
||||
@@ -127,7 +137,7 @@ void main() {
|
||||
static constexpr auto fragment = R"(
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CommonUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform CommonUBO {
|
||||
mat4 matrix;
|
||||
vec4 color;
|
||||
} ubo;
|
||||
@@ -151,7 +161,7 @@ struct ShaderSource<BuiltIn::CommonTexturedShader, gfx::Backend::Type::Vulkan> {
|
||||
layout(location = 0) in vec2 in_position;
|
||||
layout(location = 1) in vec2 in_texcoord;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CommonUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform CommonUBO {
|
||||
mat4 matrix;
|
||||
vec4 color;
|
||||
} ubo;
|
||||
@@ -170,7 +180,7 @@ void main() {
|
||||
layout(location = 0) in vec2 frag_uv;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image_sampler;
|
||||
|
||||
void main() {
|
||||
out_color = texture(image_sampler, frag_uv);
|
||||
|
||||
@@ -19,7 +19,7 @@ struct ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::Vulkan> {
|
||||
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
|
||||
layout(set = 0, binding = 1) uniform DebugUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform DebugUBO {
|
||||
mat4 matrix;
|
||||
vec4 color;
|
||||
float overlay_scale;
|
||||
@@ -43,14 +43,14 @@ void main() {
|
||||
layout(location = 0) in vec2 frag_uv;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform DebugUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform DebugUBO {
|
||||
mat4 matrix;
|
||||
vec4 color;
|
||||
float overlay_scale;
|
||||
float pad1, pad2, pad3;
|
||||
} debug;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image_sampler;
|
||||
|
||||
void main() {
|
||||
vec4 overlay_color = texture(image_sampler, frag_uv);
|
||||
|
||||
@@ -27,11 +27,11 @@ layout(location = 1) in vec4 in_color;
|
||||
layout(location = 2) in vec2 in_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform FillDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillDrawableUBO {
|
||||
mat4 matrix;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 3) uniform FillInterpolateUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillInterpolateUBO {
|
||||
float color_t;
|
||||
float opacity_t;
|
||||
} interp;
|
||||
@@ -71,7 +71,7 @@ layout(location = 1) in lowp float frag_opacity;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 4) uniform FillEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -120,11 +120,11 @@ layout(location = 1) in vec4 in_color;
|
||||
layout(location = 2) in vec2 in_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform FillDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillDrawableUBO {
|
||||
mat4 matrix;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 3) uniform FillInterpolateUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillInterpolateUBO {
|
||||
float color_t;
|
||||
float opacity_t;
|
||||
} interp;
|
||||
@@ -170,7 +170,7 @@ layout(location = 2) in vec2 frag_position;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 4) uniform FillEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -230,7 +230,7 @@ layout(location = 2) in mediump uvec4 in_pattern_to;
|
||||
layout(location = 3) in vec2 in_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform FillPatternDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillPatternDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
@@ -239,18 +239,18 @@ layout(set = 0, binding = 1) uniform FillPatternDrawableUBO {
|
||||
float pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform FillPatternTilePropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillPatternTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 3) uniform FillPatternInterpolateUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform FillPatternInterpolateUBO {
|
||||
float pattern_from_t;
|
||||
float pattern_to_t;
|
||||
float opacity_t;
|
||||
} interp;
|
||||
|
||||
layout(set = 0, binding = 4) uniform FillEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -332,7 +332,7 @@ layout(location = 4) in lowp float frag_opacity;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform FillPatternDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillPatternDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
@@ -341,12 +341,12 @@ layout(set = 0, binding = 1) uniform FillPatternDrawableUBO {
|
||||
float pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform FillPatternTilePropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillPatternTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 4) uniform FillEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -355,7 +355,7 @@ layout(set = 0, binding = 4) uniform FillEvaluatedPropsUBO {
|
||||
float to_scale;
|
||||
} props;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image0_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image0_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -425,7 +425,7 @@ layout(location = 2) in mediump uvec4 in_pattern_to;
|
||||
layout(location = 3) in vec2 in_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform FillOutlinePatternDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillOutlinePatternDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
@@ -434,18 +434,18 @@ layout(set = 0, binding = 1) uniform FillOutlinePatternDrawableUBO {
|
||||
float pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform FillOutlinePatternTilePropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillOutlinePatternTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 3) uniform FillOutlinePatternInterpolateUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform FillOutlinePatternInterpolateUBO {
|
||||
float pattern_from_t;
|
||||
float pattern_to_t;
|
||||
float opacity_t;
|
||||
} interp;
|
||||
|
||||
layout(set = 0, binding = 4) uniform FillEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -533,7 +533,7 @@ layout(location = 5) in lowp float frag_opacity;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform FillOutlinePatternDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillOutlinePatternDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 pixel_coord_upper;
|
||||
vec2 pixel_coord_lower;
|
||||
@@ -542,12 +542,12 @@ layout(set = 0, binding = 1) uniform FillOutlinePatternDrawableUBO {
|
||||
float pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform FillOutlinePatternTilePropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillOutlinePatternTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 4) uniform FillEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -556,7 +556,7 @@ layout(set = 0, binding = 4) uniform FillEvaluatedPropsUBO {
|
||||
float to_scale;
|
||||
} props;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image0_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image0_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -618,7 +618,7 @@ struct ShaderSource<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::
|
||||
layout(location = 0) in ivec2 in_pos_normal;
|
||||
layout(location = 1) in uvec4 in_data;
|
||||
|
||||
layout(set = 0, binding = 1) uniform FillOutlineTriangulatedDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillOutlineTriangulatedDrawableUBO {
|
||||
mat4 matrix;
|
||||
float ratio;
|
||||
float pad1, pad2, pad3;
|
||||
@@ -674,7 +674,7 @@ layout(location = 2) in float frag_gamma_scale;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 4) uniform FillEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
vec4 outline_color;
|
||||
float opacity;
|
||||
@@ -729,7 +729,7 @@ layout(location = 3) in vec2 in_base;
|
||||
layout(location = 4) in vec2 in_height;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform FillExtrusionDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillExtrusionDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 texsize;
|
||||
vec2 pixel_coord_upper;
|
||||
@@ -738,7 +738,16 @@ layout(set = 0, binding = 1) uniform FillExtrusionDrawableUBO {
|
||||
float tile_ratio;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform FillExtrusionPropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform FillExtrusionInterpolateUBO {
|
||||
float base_t;
|
||||
float height_t;
|
||||
float color_t;
|
||||
float pattern_from_t;
|
||||
float pattern_to_t;
|
||||
float pad1, pad2, pad3;
|
||||
} interp;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillExtrusionPropsUBO {
|
||||
vec4 color;
|
||||
vec4 light_color_pad;
|
||||
vec4 light_position_base;
|
||||
@@ -752,15 +761,6 @@ layout(set = 0, binding = 2) uniform FillExtrusionPropsUBO {
|
||||
float pad2;
|
||||
} props;
|
||||
|
||||
layout(set = 0, binding = 4) uniform FillExtrusionInterpolateUBO {
|
||||
float base_t;
|
||||
float height_t;
|
||||
float color_t;
|
||||
float pattern_from_t;
|
||||
float pattern_to_t;
|
||||
float pad1, pad2, pad3;
|
||||
} interp;
|
||||
|
||||
layout(location = 0) out mediump vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
@@ -875,7 +875,7 @@ layout(location = 4) in uvec4 in_pattern_from;
|
||||
layout(location = 5) in uvec4 in_pattern_to;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform FillExtrusionDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillExtrusionDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 texsize;
|
||||
vec2 pixel_coord_upper;
|
||||
@@ -884,7 +884,21 @@ layout(set = 0, binding = 1) uniform FillExtrusionDrawableUBO {
|
||||
float tile_ratio;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform FillExtrusionPropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillExtrusionTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform FillExtrusionInterpolateUBO {
|
||||
float base_t;
|
||||
float height_t;
|
||||
float color_t;
|
||||
float pattern_from_t;
|
||||
float pattern_to_t;
|
||||
float pad1, pad2, pad3;
|
||||
} interp;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillExtrusionPropsUBO {
|
||||
vec4 color;
|
||||
vec4 light_color_pad;
|
||||
vec4 light_position_base;
|
||||
@@ -898,20 +912,6 @@ layout(set = 0, binding = 2) uniform FillExtrusionPropsUBO {
|
||||
float pad2;
|
||||
} props;
|
||||
|
||||
layout(set = 0, binding = 3) uniform FillExtrusionTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 4) uniform FillExtrusionInterpolateUBO {
|
||||
float base_t;
|
||||
float height_t;
|
||||
float color_t;
|
||||
float pattern_from_t;
|
||||
float pattern_to_t;
|
||||
float pad1, pad2, pad3;
|
||||
} interp;
|
||||
|
||||
layout(location = 0) out mediump vec4 frag_lighting;
|
||||
layout(location = 1) out mediump vec2 frag_pos_a;
|
||||
layout(location = 2) out mediump vec2 frag_pos_b;
|
||||
@@ -1027,7 +1027,7 @@ layout(location = 4) in mediump vec4 frag_pattern_to;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform FillExtrusionDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform FillExtrusionDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 texsize;
|
||||
vec2 pixel_coord_upper;
|
||||
@@ -1036,7 +1036,12 @@ layout(set = 0, binding = 1) uniform FillExtrusionDrawableUBO {
|
||||
float tile_ratio;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform FillExtrusionPropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform FillExtrusionTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform FillExtrusionPropsUBO {
|
||||
vec4 color;
|
||||
vec4 light_color_pad;
|
||||
vec4 light_position_base;
|
||||
@@ -1050,12 +1055,7 @@ layout(set = 0, binding = 2) uniform FillExtrusionPropsUBO {
|
||||
float pad2;
|
||||
} props;
|
||||
|
||||
layout(set = 0, binding = 3) uniform FillExtrusionTilePropsUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image0_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image0_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
|
||||
@@ -35,26 +35,26 @@ layout(location = 1) in vec2 in_weight;
|
||||
layout(location = 2) in vec2 in_radius;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform HeatmapDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform HeatmapDrawableUBO {
|
||||
mat4 matrix;
|
||||
float extrude_scale;
|
||||
float pad1;
|
||||
vec2 pad2;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform HeatmapEvaluatedPropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform HeatmapInterpolateUBO {
|
||||
float weight_t;
|
||||
float radius_t;
|
||||
vec2 pad1;
|
||||
} interp;
|
||||
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform HeatmapEvaluatedPropsUBO {
|
||||
float weight;
|
||||
float radius;
|
||||
float intensity;
|
||||
float pad1;
|
||||
} props;
|
||||
|
||||
layout(set = 0, binding = 3) uniform HeatmapInterpolateUBO {
|
||||
float weight_t;
|
||||
float radius_t;
|
||||
vec2 pad1;
|
||||
} interp;
|
||||
|
||||
layout(location = 0) out float frag_weight;
|
||||
layout(location = 1) out lowp vec2 frag_extrude;
|
||||
|
||||
@@ -115,7 +115,7 @@ layout(location = 1) in lowp vec2 frag_extrude;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 2) uniform HeatmapEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform HeatmapEvaluatedPropsUBO {
|
||||
float weight;
|
||||
float radius;
|
||||
float intensity;
|
||||
@@ -151,7 +151,7 @@ struct ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Vulkan> {
|
||||
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
|
||||
layout(set = 0, binding = 1) uniform HeatmapTexturePropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform HeatmapTexturePropsUBO {
|
||||
mat4 matrix;
|
||||
float opacity;
|
||||
float pad1, pad2, pad3;
|
||||
@@ -173,14 +173,14 @@ void main() {
|
||||
layout(location = 0) in vec2 frag_position;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform HeatmapTexturePropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform HeatmapTexturePropsUBO {
|
||||
mat4 matrix;
|
||||
float opacity;
|
||||
float pad1, pad2, pad3;
|
||||
} props;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image_sampler;
|
||||
layout(set = 1, binding = 1) uniform sampler2D color_ramp_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 1) uniform sampler2D color_ramp_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ struct ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::Vulkan>
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
layout(location = 1) in ivec2 in_texture_position;
|
||||
|
||||
layout(set = 0, binding = 1) uniform HillshadePrepareDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform HillshadePrepareDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec4 unpack;
|
||||
vec2 dimension;
|
||||
@@ -46,7 +46,7 @@ void main() {
|
||||
layout(location = 0) in vec2 frag_position;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform HillshadePrepareDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform HillshadePrepareDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec4 unpack;
|
||||
vec2 dimension;
|
||||
@@ -54,7 +54,7 @@ layout(set = 0, binding = 1) uniform HillshadePrepareDrawableUBO {
|
||||
float maxzoom;
|
||||
} drawable;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image_sampler;
|
||||
|
||||
float getElevation(vec2 coord, float bias, sampler2D image_sampler, vec4 unpack) {
|
||||
// Convert encoded elevation value to meters
|
||||
@@ -138,7 +138,7 @@ struct ShaderSource<BuiltIn::HillshadeShader, gfx::Backend::Type::Vulkan> {
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
layout(location = 1) in ivec2 in_texture_position;
|
||||
|
||||
layout(set = 0, binding = 1) uniform HillshadeDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform HillshadeDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 latrange;
|
||||
vec2 light;
|
||||
@@ -161,19 +161,19 @@ void main() {
|
||||
layout(location = 0) in vec2 frag_position;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform HillshadeDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform HillshadeDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 latrange;
|
||||
vec2 light;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform HillshadeEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform HillshadeEvaluatedPropsUBO {
|
||||
vec4 highlight;
|
||||
vec4 shadow;
|
||||
vec4 accent;
|
||||
} props;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
|
||||
@@ -44,13 +44,13 @@ layout(location = 6) in vec2 in_offset;
|
||||
layout(location = 7) in vec2 in_width;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform LineDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform LineDrawableUBO {
|
||||
mat4 matrix;
|
||||
mediump float ratio;
|
||||
float pad1, pad2, pad3;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform LineInterpolationUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform LineInterpolationUBO {
|
||||
float color_t;
|
||||
float blur_t;
|
||||
float opacity_t;
|
||||
@@ -60,7 +60,7 @@ layout(set = 0, binding = 2) uniform LineInterpolationUBO {
|
||||
float pad1, pad2;
|
||||
} interp;
|
||||
|
||||
layout(set = 0, binding = 4) uniform LineEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform LineEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
float blur;
|
||||
float opacity;
|
||||
@@ -186,7 +186,7 @@ layout(location = 5) in lowp float frag_opacity;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 4) uniform LineEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform LineEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
float blur;
|
||||
float opacity;
|
||||
@@ -271,13 +271,13 @@ layout(location = 5) in vec2 in_offset;
|
||||
layout(location = 6) in vec2 in_width;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform LineDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform LineDrawableUBO {
|
||||
mat4 matrix;
|
||||
mediump float ratio;
|
||||
float pad1, pad2, pad3;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform LineInterpolationUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform LineInterpolationUBO {
|
||||
float color_t;
|
||||
float blur_t;
|
||||
float opacity_t;
|
||||
@@ -287,7 +287,7 @@ layout(set = 0, binding = 2) uniform LineInterpolationUBO {
|
||||
float pad1, pad2;
|
||||
} interp;
|
||||
|
||||
layout(set = 0, binding = 4) uniform LineEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform LineEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
float blur;
|
||||
float opacity;
|
||||
@@ -402,11 +402,11 @@ layout(location = 4) in lowp float frag_blur;
|
||||
layout(location = 5) in lowp float frag_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image0_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image0_sampler;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 4) uniform LineEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform LineEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
float blur;
|
||||
float opacity;
|
||||
@@ -497,7 +497,7 @@ layout(location = 7) in uvec4 in_pattern_from;
|
||||
layout(location = 8) in uvec4 in_pattern_to;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform LineDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform LineDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec4 scale;
|
||||
vec2 texsize;
|
||||
@@ -505,7 +505,7 @@ layout(set = 0, binding = 1) uniform LineDrawableUBO {
|
||||
float fade;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform LineInterpolationUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform LineInterpolationUBO {
|
||||
float blur_t;
|
||||
float opacity_t;
|
||||
float offset_t;
|
||||
@@ -516,12 +516,12 @@ layout(set = 0, binding = 2) uniform LineInterpolationUBO {
|
||||
float pad1;
|
||||
} interp;
|
||||
|
||||
layout(set = 0, binding = 3) uniform LinePatternTilePropertiesUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform LinePatternTilePropertiesUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 4) uniform LineEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform LineEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
float blur;
|
||||
float opacity;
|
||||
@@ -663,7 +663,7 @@ layout(location = 7) in mediump vec4 frag_pattern_to;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform LineDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform LineDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec4 scale;
|
||||
vec2 texsize;
|
||||
@@ -671,12 +671,12 @@ layout(set = 0, binding = 1) uniform LineDrawableUBO {
|
||||
float fade;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 3) uniform LinePatternTilePropertiesUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform LinePatternTilePropertiesUBO {
|
||||
vec4 pattern_from;
|
||||
vec4 pattern_to;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 4) uniform LineEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform LineEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
float blur;
|
||||
float opacity;
|
||||
@@ -688,7 +688,7 @@ layout(set = 0, binding = 4) uniform LineEvaluatedPropsUBO {
|
||||
float pad1;
|
||||
} props;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image0_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image0_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -808,7 +808,7 @@ layout(location = 7) in vec2 in_width;
|
||||
layout(location = 8) in vec2 in_floorwidth;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform LineSDFDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform LineSDFDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 patternscale_a;
|
||||
vec2 patternscale_b;
|
||||
@@ -820,7 +820,7 @@ layout(set = 0, binding = 1) uniform LineSDFDrawableUBO {
|
||||
float pad1, pad2, pad3;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform LineSDFInterpolationUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform LineSDFInterpolationUBO {
|
||||
float color_t;
|
||||
float blur_t;
|
||||
float opacity_t;
|
||||
@@ -831,7 +831,7 @@ layout(set = 0, binding = 2) uniform LineSDFInterpolationUBO {
|
||||
float pad1;
|
||||
} interp;
|
||||
|
||||
layout(set = 0, binding = 4) uniform LineEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform LineEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
float blur;
|
||||
float opacity;
|
||||
@@ -982,7 +982,7 @@ layout(location = 8) in mediump float frag_floorwidth;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform LineSDFDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform LineSDFDrawableUBO {
|
||||
mat4 matrix;
|
||||
vec2 patternscale_a;
|
||||
vec2 patternscale_b;
|
||||
@@ -994,7 +994,7 @@ layout(set = 0, binding = 1) uniform LineSDFDrawableUBO {
|
||||
float pad1, pad2, pad3;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform LineSDFInterpolationUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform LineSDFInterpolationUBO {
|
||||
float color_t;
|
||||
float blur_t;
|
||||
float opacity_t;
|
||||
@@ -1005,7 +1005,7 @@ layout(set = 0, binding = 2) uniform LineSDFInterpolationUBO {
|
||||
float pad1;
|
||||
} interp;
|
||||
|
||||
layout(set = 0, binding = 4) uniform LineEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform LineEvaluatedPropsUBO {
|
||||
vec4 color;
|
||||
float blur;
|
||||
float opacity;
|
||||
@@ -1017,7 +1017,7 @@ layout(set = 0, binding = 4) uniform LineEvaluatedPropsUBO {
|
||||
float pad1;
|
||||
} props;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image0_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image0_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ struct ShaderSource<BuiltIn::RasterShader, gfx::Backend::Type::Vulkan> {
|
||||
layout(location = 0) in ivec2 in_position;
|
||||
layout(location = 1) in ivec2 in_texture_position;
|
||||
|
||||
layout(set = 0, binding = 1) uniform RasterDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform RasterDrawableUBO {
|
||||
mat4 matrix;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform RasterEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform RasterEvaluatedPropsUBO {
|
||||
vec4 spin_weights;
|
||||
vec2 tl_parent;
|
||||
float scale_parent;
|
||||
@@ -63,7 +63,7 @@ layout(location = 1) in vec2 frag_position1;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 2) uniform RasterEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform RasterEvaluatedPropsUBO {
|
||||
vec4 spin_weights;
|
||||
vec2 tl_parent;
|
||||
float scale_parent;
|
||||
@@ -77,8 +77,8 @@ layout(set = 0, binding = 2) uniform RasterEvaluatedPropsUBO {
|
||||
float pad1, pad2;
|
||||
} props;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image0_sampler;
|
||||
layout(set = 1, binding = 1) uniform sampler2D image1_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image0_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 1) uniform sampler2D image1_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ layout(location = 4) in float in_fade_opacity;
|
||||
layout(location = 5) in vec2 in_opacity;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform SymbolDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform SymbolDrawableUBO {
|
||||
mat4 matrix;
|
||||
mat4 label_plane_matrix;
|
||||
mat4 coord_matrix;
|
||||
@@ -38,7 +38,7 @@ layout(set = 0, binding = 1) uniform SymbolDrawableUBO {
|
||||
vec2 pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform SymbolTilePropsUBO {
|
||||
bool is_text;
|
||||
bool is_halo;
|
||||
bool pitch_with_map;
|
||||
@@ -49,7 +49,7 @@ layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
float padding;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 3) uniform SymbolInterpolateUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform SymbolInterpolateUBO {
|
||||
float fill_color_t;
|
||||
float halo_color_t;
|
||||
float opacity_t;
|
||||
@@ -140,7 +140,7 @@ layout(location = 1) in mediump float frag_opacity;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform SymbolTilePropsUBO {
|
||||
bool is_text;
|
||||
bool is_halo;
|
||||
bool pitch_with_map;
|
||||
@@ -151,7 +151,7 @@ layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
float padding;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 4) uniform SymbolEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform SymbolEvaluatedPropsUBO {
|
||||
vec4 text_fill_color;
|
||||
vec4 text_halo_color;
|
||||
float text_opacity;
|
||||
@@ -166,7 +166,7 @@ layout(set = 0, binding = 4) uniform SymbolEvaluatedPropsUBO {
|
||||
float pad2;
|
||||
} props;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image0_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image0_sampler;
|
||||
|
||||
void main() {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
@@ -222,7 +222,7 @@ layout(location = 8) in vec2 in_halo_width;
|
||||
layout(location = 9) in vec2 in_halo_blur;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform SymbolDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform SymbolDrawableUBO {
|
||||
mat4 matrix;
|
||||
mat4 label_plane_matrix;
|
||||
mat4 coord_matrix;
|
||||
@@ -233,7 +233,7 @@ layout(set = 0, binding = 1) uniform SymbolDrawableUBO {
|
||||
vec2 pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform SymbolTilePropsUBO {
|
||||
bool is_text;
|
||||
bool is_halo;
|
||||
bool pitch_with_map;
|
||||
@@ -244,7 +244,7 @@ layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
float padding;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 3) uniform SymbolInterpolateUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform SymbolInterpolateUBO {
|
||||
float fill_color_t;
|
||||
float halo_color_t;
|
||||
float opacity_t;
|
||||
@@ -396,7 +396,7 @@ layout(location = 8) in mediump float frag_halo_blur;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform SymbolDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform SymbolDrawableUBO {
|
||||
mat4 matrix;
|
||||
mat4 label_plane_matrix;
|
||||
mat4 coord_matrix;
|
||||
@@ -407,7 +407,7 @@ layout(set = 0, binding = 1) uniform SymbolDrawableUBO {
|
||||
vec2 pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform SymbolTilePropsUBO {
|
||||
bool is_text;
|
||||
bool is_halo;
|
||||
bool pitch_with_map;
|
||||
@@ -418,7 +418,7 @@ layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
float padding;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 4) uniform SymbolEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform SymbolEvaluatedPropsUBO {
|
||||
vec4 text_fill_color;
|
||||
vec4 text_halo_color;
|
||||
float text_opacity;
|
||||
@@ -433,7 +433,7 @@ layout(set = 0, binding = 4) uniform SymbolEvaluatedPropsUBO {
|
||||
float pad2;
|
||||
} props;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image0_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image0_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -521,7 +521,7 @@ layout(location = 7) in vec2 in_halo_width;
|
||||
layout(location = 8) in vec2 in_halo_blur;
|
||||
#endif
|
||||
|
||||
layout(set = 0, binding = 1) uniform SymbolDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform SymbolDrawableUBO {
|
||||
mat4 matrix;
|
||||
mat4 label_plane_matrix;
|
||||
mat4 coord_matrix;
|
||||
@@ -532,7 +532,7 @@ layout(set = 0, binding = 1) uniform SymbolDrawableUBO {
|
||||
vec2 pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform SymbolTilePropsUBO {
|
||||
bool is_text;
|
||||
bool is_halo;
|
||||
bool pitch_with_map;
|
||||
@@ -543,7 +543,7 @@ layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
float padding;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 3) uniform SymbolInterpolateUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 2) uniform SymbolInterpolateUBO {
|
||||
float fill_color_t;
|
||||
float halo_color_t;
|
||||
float opacity_t;
|
||||
@@ -702,7 +702,7 @@ layout(location = 9) flat in int frag_is_icon;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform SymbolDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform SymbolDrawableUBO {
|
||||
mat4 matrix;
|
||||
mat4 label_plane_matrix;
|
||||
mat4 coord_matrix;
|
||||
@@ -713,7 +713,7 @@ layout(set = 0, binding = 1) uniform SymbolDrawableUBO {
|
||||
vec2 pad;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform SymbolTilePropsUBO {
|
||||
bool is_text;
|
||||
bool is_halo;
|
||||
bool pitch_with_map;
|
||||
@@ -724,7 +724,7 @@ layout(set = 0, binding = 2) uniform SymbolTilePropsUBO {
|
||||
float padding;
|
||||
} tile;
|
||||
|
||||
layout(set = 0, binding = 4) uniform SymbolEvaluatedPropsUBO {
|
||||
layout(set = LAYER_SET_INDEX, binding = 0) uniform SymbolEvaluatedPropsUBO {
|
||||
vec4 text_fill_color;
|
||||
vec4 text_halo_color;
|
||||
float text_opacity;
|
||||
@@ -739,8 +739,8 @@ layout(set = 0, binding = 4) uniform SymbolEvaluatedPropsUBO {
|
||||
float pad2;
|
||||
} props;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D glyph_image;
|
||||
layout(set = 1, binding = 1) uniform sampler2D icon_image;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D glyph_image;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 1) uniform sampler2D icon_image;
|
||||
|
||||
void main() {
|
||||
#if defined(OVERDRAW_INSPECTOR)
|
||||
@@ -808,11 +808,11 @@ struct ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Vulkan>
|
||||
layout(location = 0) in vec2 in_position;
|
||||
layout(location = 1) in vec2 in_tex;
|
||||
|
||||
layout(set = 0, binding = 1) uniform CustomSymbolIconDrawableUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform CustomSymbolIconDrawableUBO {
|
||||
mat4 matrix;
|
||||
} drawable;
|
||||
|
||||
layout(set = 0, binding = 2) uniform CustomSymbolIconParametersUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform CustomSymbolIconParametersUBO {
|
||||
vec2 extrude_scale;
|
||||
vec2 anchor;
|
||||
float angle_degrees;
|
||||
@@ -872,7 +872,7 @@ void main() {
|
||||
layout(location = 0) in vec2 frag_tex;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image_sampler;
|
||||
|
||||
void main() {
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ struct ShaderSource<BuiltIn::WideVectorShader, gfx::Backend::Type::Vulkan> {
|
||||
#define WKSVertexLineCapButt 1
|
||||
#define WKSVertexLineCapSquare 2
|
||||
|
||||
layout(set = 0, binding = 1) uniform WideVectorUniformsUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform WideVectorUniformsUBO {
|
||||
mat4 mvpMatrix;
|
||||
mat4 mvpMatrixDiff;
|
||||
mat4 mvMatrix;
|
||||
@@ -45,7 +45,7 @@ layout(set = 0, binding = 1) uniform WideVectorUniformsUBO {
|
||||
vec2 frameSize;
|
||||
} uniforms;
|
||||
|
||||
layout(set = 0, binding = 2) uniform WideVectorUniformWideVecUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 1) uniform WideVectorUniformWideVecUBO {
|
||||
vec4 color;
|
||||
float w2;
|
||||
float offset;
|
||||
@@ -153,14 +153,14 @@ void main() {
|
||||
layout(location = 0) in vec2 frag_uv;
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
layout(set = 0, binding = 1) uniform DebugUBO {
|
||||
layout(set = DRAWABLE_UBO_SET_INDEX, binding = 0) uniform DebugUBO {
|
||||
mat4 matrix;
|
||||
vec4 color;
|
||||
float overlay_scale;
|
||||
float pad1, pad2, pad3;
|
||||
} debug;
|
||||
|
||||
layout(set = 1, binding = 0) uniform sampler2D image_sampler;
|
||||
layout(set = DRAWABLE_IMAGE_SET_INDEX, binding = 0) uniform sampler2D image_sampler;
|
||||
|
||||
void main() {
|
||||
vec4 overlay_color = texture(image_sampler, frag_uv);
|
||||
|
||||
@@ -31,12 +31,6 @@ struct alignas(16) WideVectorUniformWideVecUBO {
|
||||
};
|
||||
static_assert(sizeof(WideVectorUniformWideVecUBO) % 16 == 0);
|
||||
|
||||
enum {
|
||||
idWideVectorUniformsUBO = globalUBOCount,
|
||||
idWideVectorUniformWideVecUBO,
|
||||
wideVectorUBOCount
|
||||
};
|
||||
|
||||
struct VertexTriWideVecB {
|
||||
// x, y offset around the center
|
||||
std::array<float, 3> screenPos;
|
||||
|
||||
@@ -135,23 +135,28 @@ public:
|
||||
const std::unique_ptr<BufferResource>& getDummyVertexBuffer();
|
||||
const std::unique_ptr<BufferResource>& getDummyUniformBuffer();
|
||||
const std::unique_ptr<Texture2D>& getDummyTexture();
|
||||
const vk::UniqueDescriptorSetLayout& getUniformDescriptorSetLayout();
|
||||
const vk::UniqueDescriptorSetLayout& getImageDescriptorSetLayout();
|
||||
const vk::UniqueDescriptorSetLayout& buildUniformDescriptorSetLayout(vk::UniqueDescriptorSetLayout& layout,
|
||||
size_t uniformCount,
|
||||
const std::string& name);
|
||||
|
||||
const std::vector<vk::DescriptorSetLayout>& getDescriptorSetLayouts();
|
||||
const vk::DescriptorSetLayout& getDescriptorSetLayout(DescriptorSetType type);
|
||||
const vk::UniquePipelineLayout& getGeneralPipelineLayout();
|
||||
const vk::UniquePipelineLayout& getPushConstantPipelineLayout();
|
||||
|
||||
void bindDescriptorSet(DescriptorSetType type, const vk::DescriptorSet& descriptorSet);
|
||||
|
||||
uint8_t getCurrentFrameResourceIndex() const { return frameResourceIndex; }
|
||||
const vk::UniqueDescriptorPool& getCurrentDescriptorPool() const;
|
||||
const vk::UniqueDescriptorPool& getGlobalDescriptorPool() const;
|
||||
void enqueueDeletion(std::function<void(const Context&)>&& function);
|
||||
void submitOneTimeCommand(const std::function<void(const vk::UniqueCommandBuffer&)>& function);
|
||||
void submitOneTimeCommand(const std::function<void(const vk::UniqueCommandBuffer&)>& function) const;
|
||||
|
||||
void requestSurfaceUpdate() { surfaceUpdateRequested = true; }
|
||||
|
||||
private:
|
||||
struct FrameResources {
|
||||
vk::UniqueCommandBuffer commandBuffer;
|
||||
vk::UniqueDescriptorPool descriptorPool;
|
||||
|
||||
vk::UniqueSemaphore surfaceSemaphore;
|
||||
vk::UniqueSemaphore frameSemaphore;
|
||||
@@ -160,12 +165,10 @@ private:
|
||||
std::vector<std::function<void(const Context&)>> deletionQueue;
|
||||
|
||||
FrameResources(vk::UniqueCommandBuffer& cb,
|
||||
vk::UniqueDescriptorPool&& dp,
|
||||
vk::UniqueSemaphore&& surf,
|
||||
vk::UniqueSemaphore&& frame,
|
||||
vk::UniqueFence&& flight)
|
||||
: commandBuffer(std::move(cb)),
|
||||
descriptorPool(std::move(dp)),
|
||||
surfaceSemaphore(std::move(surf)),
|
||||
frameSemaphore(std::move(frame)),
|
||||
flightFrameFence(std::move(flight)) {}
|
||||
@@ -180,11 +183,14 @@ private:
|
||||
RendererBackend& backend;
|
||||
|
||||
vulkan::UniformBufferArray globalUniformBuffers;
|
||||
vk::UniqueDescriptorPool globalDescriptorPool;
|
||||
|
||||
std::unique_ptr<BufferResource> dummyVertexBuffer;
|
||||
std::unique_ptr<BufferResource> dummyUniformBuffer;
|
||||
std::unique_ptr<Texture2D> dummyTexture2D;
|
||||
vk::UniqueDescriptorSetLayout uniformDescriptorSetLayout;
|
||||
vk::UniqueDescriptorSetLayout globalUniformDescriptorSetLayout;
|
||||
vk::UniqueDescriptorSetLayout layerUniformDescriptorSetLayout;
|
||||
vk::UniqueDescriptorSetLayout drawableUniformDescriptorSetLayout;
|
||||
vk::UniqueDescriptorSetLayout imageDescriptorSetLayout;
|
||||
std::vector<vk::DescriptorSetLayout> descriptorSetLayouts;
|
||||
vk::UniquePipelineLayout generalPipelineLayout;
|
||||
|
||||
55
include/mbgl/vulkan/descriptor_set.hpp
Normal file
55
include/mbgl/vulkan/descriptor_set.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/uniform_buffer.hpp>
|
||||
#include <mbgl/vulkan/buffer_resource.hpp>
|
||||
#include <span>
|
||||
|
||||
namespace mbgl {
|
||||
namespace vulkan {
|
||||
|
||||
class CommandEncoder;
|
||||
|
||||
enum class DescriptorSetType : uint8_t {
|
||||
Global,
|
||||
Layer,
|
||||
DrawableUniform,
|
||||
DrawableImage,
|
||||
Count,
|
||||
};
|
||||
|
||||
class DescriptorSet {
|
||||
public:
|
||||
DescriptorSet(Context& context_, DescriptorSetType type_);
|
||||
virtual ~DescriptorSet();
|
||||
|
||||
void allocate();
|
||||
|
||||
void markDirty(bool value = true);
|
||||
void bind(CommandEncoder& encoder);
|
||||
|
||||
protected:
|
||||
Context& context;
|
||||
DescriptorSetType type;
|
||||
|
||||
std::vector<bool> dirty;
|
||||
std::vector<vk::DescriptorSet> descriptorSets;
|
||||
};
|
||||
|
||||
class UniformDescriptorSet : public DescriptorSet {
|
||||
public:
|
||||
UniformDescriptorSet(Context& context_, DescriptorSetType type_);
|
||||
virtual ~UniformDescriptorSet() = default;
|
||||
|
||||
void update(const gfx::UniformBufferArray& uniforms, uint32_t uniformStartIndex, uint32_t descriptorBindingCount);
|
||||
};
|
||||
|
||||
class ImageDescriptorSet : public DescriptorSet {
|
||||
public:
|
||||
ImageDescriptorSet(Context& context_);
|
||||
virtual ~ImageDescriptorSet() = default;
|
||||
|
||||
void update(const std::array<gfx::Texture2DPtr, shaders::maxTextureCountPerShader>& textures);
|
||||
};
|
||||
|
||||
} // namespace vulkan
|
||||
} // namespace mbgl
|
||||
@@ -9,7 +9,7 @@ class PaintParameters;
|
||||
|
||||
namespace vulkan {
|
||||
|
||||
class RenderPass;
|
||||
class Context;
|
||||
|
||||
/**
|
||||
A layer group for non-tile-based drawables
|
||||
@@ -23,12 +23,8 @@ public:
|
||||
void render(RenderOrchestrator&, PaintParameters&) override;
|
||||
|
||||
const gfx::UniformBufferArray& getUniformBuffers() const override { return uniformBuffers; };
|
||||
|
||||
gfx::UniformBufferArray& mutableUniformBuffers() override { return uniformBuffers; };
|
||||
|
||||
void bindUniformBuffers(RenderPass&) const noexcept;
|
||||
void unbindUniformBuffers(RenderPass&) const noexcept {}
|
||||
|
||||
protected:
|
||||
UniformBufferArray uniformBuffers;
|
||||
};
|
||||
|
||||
@@ -25,9 +25,6 @@ public:
|
||||
|
||||
void addDebugSignpost(const char* name) override;
|
||||
|
||||
void bindVertex(const BufferResource&, std::size_t offset, std::size_t index, std::size_t size = 0);
|
||||
void bindFragment(const BufferResource&, std::size_t offset, std::size_t index, std::size_t size = 0);
|
||||
|
||||
private:
|
||||
void pushDebugGroup(const char* name) override;
|
||||
void popDebugGroup() override;
|
||||
|
||||
@@ -25,12 +25,8 @@ public:
|
||||
void render(RenderOrchestrator&, PaintParameters&) override;
|
||||
|
||||
const gfx::UniformBufferArray& getUniformBuffers() const override { return uniformBuffers; };
|
||||
|
||||
gfx::UniformBufferArray& mutableUniformBuffers() override { return uniformBuffers; };
|
||||
|
||||
void bindUniformBuffers(RenderPass&) const noexcept;
|
||||
void unbindUniformBuffers(RenderPass&) const noexcept {}
|
||||
|
||||
protected:
|
||||
UniformBufferArray uniformBuffers;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/gfx/uniform_buffer.hpp>
|
||||
#include <mbgl/vulkan/buffer_resource.hpp>
|
||||
#include <mbgl/vulkan/descriptor_set.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace vulkan {
|
||||
@@ -26,7 +27,14 @@ protected:
|
||||
/// Stores a collection of uniform buffers by name
|
||||
class UniformBufferArray final : public gfx::UniformBufferArray {
|
||||
public:
|
||||
UniformBufferArray() = default;
|
||||
UniformBufferArray() = delete;
|
||||
UniformBufferArray(DescriptorSetType descriptorSetType_,
|
||||
uint32_t descriptorStartIndex_,
|
||||
uint32_t descriptorBindingCount_)
|
||||
: descriptorSetType(descriptorSetType_),
|
||||
descriptorStartIndex(descriptorStartIndex_),
|
||||
descriptorBindingCount(descriptorBindingCount_) {}
|
||||
|
||||
UniformBufferArray(UniformBufferArray&& other)
|
||||
: gfx::UniformBufferArray(std::move(other)) {}
|
||||
UniformBufferArray(const UniformBufferArray&) = delete;
|
||||
@@ -40,10 +48,27 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
~UniformBufferArray() = default;
|
||||
|
||||
const std::shared_ptr<gfx::UniformBuffer>& set(const size_t id,
|
||||
std::shared_ptr<gfx::UniformBuffer> uniformBuffer) override;
|
||||
|
||||
void createOrUpdate(
|
||||
const size_t id, const void* data, std::size_t size, gfx::Context& context, bool persistent = false) override;
|
||||
|
||||
void bindDescriptorSets(CommandEncoder& encoder);
|
||||
void freeDescriptorSets() { descriptorSet.reset(); }
|
||||
|
||||
private:
|
||||
gfx::UniqueUniformBuffer copy(const gfx::UniformBuffer& buffer) override {
|
||||
return std::make_unique<UniformBuffer>(static_cast<const UniformBuffer&>(buffer).clone());
|
||||
}
|
||||
|
||||
const DescriptorSetType descriptorSetType{DescriptorSetType::DrawableUniform};
|
||||
const uint32_t descriptorStartIndex{0};
|
||||
const uint32_t descriptorBindingCount{0};
|
||||
|
||||
std::unique_ptr<UniformDescriptorSet> descriptorSet;
|
||||
};
|
||||
|
||||
} // namespace vulkan
|
||||
|
||||
2
platform/windows/vendor/vcpkg
vendored
2
platform/windows/vendor/vcpkg
vendored
Submodule platform/windows/vendor/vcpkg updated: f176b58f35...f7423ee180
@@ -1,5 +1,7 @@
|
||||
#include <mbgl/gfx/uniform_block.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gfx {
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
#include <mbgl/renderer/layers/render_location_indicator_layer.hpp>
|
||||
#include <mbgl/style/layers/location_indicator_layer_properties.hpp>
|
||||
#include <mbgl/shaders/common_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
@@ -452,14 +452,8 @@ void Renderer::Impl::render(const RenderTree& renderTree,
|
||||
// Renders debug overlays.
|
||||
{
|
||||
const auto debugGroup(parameters.renderPass->createDebugGroup("debug"));
|
||||
orchestrator.visitDebugLayerGroups([&](LayerGroupBase& layerGroup) {
|
||||
visitLayerGroupDrawables(layerGroup, [&](gfx::Drawable& drawable) {
|
||||
for (const auto& tweaker : drawable.getTweakers()) {
|
||||
tweaker->execute(drawable, parameters);
|
||||
}
|
||||
drawable.draw(parameters);
|
||||
});
|
||||
});
|
||||
orchestrator.visitDebugLayerGroups(
|
||||
[&](LayerGroupBase& layerGroup) { layerGroup.render(orchestrator, parameters); });
|
||||
}
|
||||
};
|
||||
#endif // MLN_DRAWABLE_RENDERER
|
||||
|
||||
@@ -55,6 +55,65 @@ void TileSourceRenderItem::render(PaintParameters& parameters) const {
|
||||
}
|
||||
|
||||
#if MLN_DRAWABLE_RENDERER
|
||||
|
||||
#if MLN_RENDER_BACKEND_VULKAN
|
||||
class PolylineLayerImpl : public Layer::Impl {
|
||||
public:
|
||||
PolylineLayerImpl()
|
||||
: Layer::Impl("", "") {}
|
||||
bool hasLayoutDifference(const Layer::Impl&) const override { return false; }
|
||||
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override {}
|
||||
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept final { return staticTypeInfo(); }
|
||||
static const LayerTypeInfo* staticTypeInfo() noexcept {
|
||||
const static LayerTypeInfo typeInfo{"debugPolyline",
|
||||
LayerTypeInfo::Source::NotRequired,
|
||||
LayerTypeInfo::Pass3D::NotRequired,
|
||||
LayerTypeInfo::Layout::NotRequired,
|
||||
LayerTypeInfo::FadingTiles::NotRequired,
|
||||
LayerTypeInfo::CrossTileIndex::NotRequired,
|
||||
LayerTypeInfo::TileKind::NotRequired};
|
||||
return &typeInfo;
|
||||
}
|
||||
};
|
||||
|
||||
class PolylineLayerProperties : public style::LayerProperties {
|
||||
public:
|
||||
PolylineLayerProperties()
|
||||
: LayerProperties(makeMutable<PolylineLayerImpl>()) {}
|
||||
expression::Dependency getDependencies() const noexcept override { return expression::Dependency::None; }
|
||||
};
|
||||
|
||||
class PolylineLayerTweaker : public LayerTweaker {
|
||||
public:
|
||||
PolylineLayerTweaker(const shaders::LineEvaluatedPropsUBO& properties)
|
||||
: LayerTweaker("debug-polyline", makeMutable<PolylineLayerProperties>()),
|
||||
linePropertiesUBO(properties) {}
|
||||
|
||||
void execute(LayerGroupBase& layerGroup, const PaintParameters& parameters) override {
|
||||
auto& layerUniforms = layerGroup.mutableUniformBuffers();
|
||||
layerUniforms.createOrUpdate(idLineEvaluatedPropsUBO, &linePropertiesUBO, parameters.context);
|
||||
|
||||
// We would need to set up `idLineExpressionUBO` if the expression mask isn't empty
|
||||
assert(linePropertiesUBO.expressionMask == LineExpressionMask::None);
|
||||
|
||||
const LineExpressionUBO exprUBO = {
|
||||
/* color = */ nullptr,
|
||||
/* blur = */ nullptr,
|
||||
/* opacity = */ nullptr,
|
||||
/* gapwidth = */ nullptr,
|
||||
/* offset = */ nullptr,
|
||||
/* width = */ nullptr,
|
||||
/* floorWidth = */ nullptr,
|
||||
};
|
||||
layerUniforms.createOrUpdate(idLineExpressionUBO, &exprUBO, parameters.context);
|
||||
}
|
||||
|
||||
private:
|
||||
shaders::LineEvaluatedPropsUBO linePropertiesUBO;
|
||||
};
|
||||
#endif
|
||||
|
||||
void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGroups,
|
||||
PaintParameters& parameters) const {
|
||||
if (!(parameters.debugOptions &
|
||||
@@ -64,7 +123,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
}
|
||||
|
||||
auto& context = parameters.context;
|
||||
const auto renderPass = RenderPass::None;
|
||||
const auto renderPass = RenderPass::Translucent;
|
||||
auto& shaders = *parameters.staticData.shaders;
|
||||
|
||||
// initialize debug builder
|
||||
@@ -193,6 +252,16 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
};
|
||||
|
||||
#if MLN_ENABLE_POLYLINE_DRAWABLES
|
||||
const shaders::LineEvaluatedPropsUBO linePropertiesUBO = {/*color*/ Color::red(),
|
||||
/*blur*/ 0.f,
|
||||
/*opacity*/ 1.f,
|
||||
/*gapwidth*/ 0.f,
|
||||
/*offset*/ 0.f,
|
||||
/*width*/ 4.f,
|
||||
/*floorwidth*/ 0,
|
||||
LineExpressionMask::None,
|
||||
0};
|
||||
|
||||
// function to add polylines drawable
|
||||
const auto addPolylineDrawable = [&](TileLayerGroup* tileLayerGroup, const RenderTile& tile) {
|
||||
class PolylineDrawableTweaker : public gfx::DrawableTweaker {
|
||||
@@ -232,6 +301,8 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
auto& drawableUniforms = drawable.mutableUniformBuffers();
|
||||
drawableUniforms.createOrUpdate(idLineDrawableUBO, &drawableUBO, parameters.context);
|
||||
drawableUniforms.createOrUpdate(idLineInterpolationUBO, &lineInterpolationUBO, parameters.context);
|
||||
|
||||
#if !MLN_RENDER_BACKEND_VULKAN
|
||||
drawableUniforms.createOrUpdate(idLineEvaluatedPropsUBO, &linePropertiesUBO, parameters.context);
|
||||
|
||||
// We would need to set up `idLineExpressionUBO` if the expression mask isn't empty
|
||||
@@ -247,6 +318,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
/* floorWidth = */ nullptr,
|
||||
};
|
||||
drawableUniforms.createOrUpdate(idLineExpressionUBO, &exprUBO, parameters.context);
|
||||
#endif
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -263,16 +335,15 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
}
|
||||
polylineBuilder->addPolyline(coords, options);
|
||||
|
||||
// create line tweaker
|
||||
const shaders::LineEvaluatedPropsUBO linePropertiesUBO = {/*color*/ Color::red(),
|
||||
/*blur*/ 0.f,
|
||||
/*opacity*/ 1.f,
|
||||
/*gapwidth*/ 0.f,
|
||||
/*offset*/ 0.f,
|
||||
/*width*/ 4.f,
|
||||
/*floorwidth*/ 0,
|
||||
LineExpressionMask::None,
|
||||
0};
|
||||
#if MLN_RENDER_BACKEND_VULKAN
|
||||
if (!layerTweaker) {
|
||||
layerTweaker = std::make_shared<PolylineLayerTweaker>(linePropertiesUBO);
|
||||
layerTweaker->execute(*tileLayerGroup, parameters);
|
||||
tileLayerGroup->addLayerTweaker(layerTweaker);
|
||||
}
|
||||
#endif
|
||||
|
||||
// create line tweaker;
|
||||
auto tweaker = std::make_shared<PolylineDrawableTweaker>(linePropertiesUBO);
|
||||
|
||||
// finish
|
||||
|
||||
@@ -91,6 +91,8 @@ private:
|
||||
std::optional<Tileset> cachedTileset;
|
||||
};
|
||||
|
||||
class PolylineLayerTweaker;
|
||||
|
||||
class TileSourceRenderItem : public RenderItem {
|
||||
public:
|
||||
TileSourceRenderItem(Immutable<std::vector<RenderTile>> renderTiles_, std::string name_)
|
||||
@@ -109,6 +111,8 @@ private:
|
||||
|
||||
Immutable<std::vector<RenderTile>> renderTiles;
|
||||
std::string name;
|
||||
|
||||
mutable std::shared_ptr<PolylineLayerTweaker> layerTweaker;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -47,8 +47,8 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::BackgroundPatternShader, gfx:
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::CircleShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
|
||||
UniformBlockInfo{"CircleDrawableUBO", idCircleDrawableUBO},
|
||||
UniformBlockInfo{"CircleEvaluatedPropsUBO", idCircleEvaluatedPropsUBO},
|
||||
UniformBlockInfo{"CircleInterpolateUBO", idCircleInterpolateUBO},
|
||||
UniformBlockInfo{"CircleEvaluatedPropsUBO", idCircleEvaluatedPropsUBO},
|
||||
};
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::CircleShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idCirclePosVertexAttribute},
|
||||
@@ -200,9 +200,9 @@ const std::vector<TextureInfo>
|
||||
const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"FillExtrusionDrawableUBO", idFillExtrusionDrawableUBO},
|
||||
UniformBlockInfo{"FillExtrusionPropsUBO", idFillExtrusionPropsUBO},
|
||||
UniformBlockInfo{"FillExtrusionTilePropsUBO", idFillExtrusionTilePropsUBO},
|
||||
UniformBlockInfo{"FillExtrusionInterpolateUBO", idFillExtrusionInterpolateUBO},
|
||||
UniformBlockInfo{"FillExtrusionPropsUBO", idFillExtrusionPropsUBO},
|
||||
};
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idFillExtrusionPosVertexAttribute},
|
||||
@@ -218,9 +218,9 @@ const std::vector<UniformBlockInfo>
|
||||
ShaderInfo<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
|
||||
UniformBlockInfo{"FillExtrusionDrawableUBO", idFillExtrusionDrawableUBO},
|
||||
UniformBlockInfo{"FillExtrusionPropsUBO", idFillExtrusionPropsUBO},
|
||||
UniformBlockInfo{"FillExtrusionTilePropsUBO", idFillExtrusionTilePropsUBO},
|
||||
UniformBlockInfo{"FillExtrusionInterpolateUBO", idFillExtrusionInterpolateUBO},
|
||||
UniformBlockInfo{"FillExtrusionPropsUBO", idFillExtrusionPropsUBO},
|
||||
};
|
||||
const std::vector<AttributeInfo>
|
||||
ShaderInfo<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
@@ -238,8 +238,8 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillExtrusionPatternShader, g
|
||||
// Heatmap
|
||||
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::HeatmapShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
|
||||
UniformBlockInfo{"HeatmapDrawableUBO", idHeatmapDrawableUBO},
|
||||
UniformBlockInfo{"HeatmapEvaluatedPropsUBO", idHeatmapEvaluatedPropsUBO},
|
||||
UniformBlockInfo{"HeatmapInterpolateUBO", idHeatmapInterpolateUBO},
|
||||
UniformBlockInfo{"HeatmapEvaluatedPropsUBO", idHeatmapEvaluatedPropsUBO},
|
||||
};
|
||||
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::HeatmapShader, gfx::Backend::Type::OpenGL>::attributes = {
|
||||
AttributeInfo{"a_pos", idHeatmapPosVertexAttribute},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/background.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/background_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/background_pattern.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/background_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/circle.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -6,8 +7,8 @@ namespace shaders {
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
|
||||
UniformBlockInfo{true, false, sizeof(CircleDrawableUBO), idCircleDrawableUBO},
|
||||
UniformBlockInfo{true, true, sizeof(CircleEvaluatedPropsUBO), idCircleEvaluatedPropsUBO},
|
||||
UniformBlockInfo{true, false, sizeof(CircleInterpolateUBO), idCircleInterpolateUBO},
|
||||
UniformBlockInfo{true, true, sizeof(CircleEvaluatedPropsUBO), idCircleEvaluatedPropsUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 8> ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{circleUBOCount + 0, gfx::AttributeDataType::Short2, idCirclePosVertexAttribute},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/collision_box.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -7,11 +8,11 @@ const std::array<UniformBlockInfo, 1> ShaderSource<BuiltIn::CollisionBoxShader,
|
||||
UniformBlockInfo{true, true, sizeof(CollisionUBO), idCollisionUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 5> ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{collisionUBOCount + 0, gfx::AttributeDataType::Short2, idCollisionPosVertexAttribute},
|
||||
AttributeInfo{collisionUBOCount + 1, gfx::AttributeDataType::Short2, idCollisionAnchorPosVertexAttribute},
|
||||
AttributeInfo{collisionUBOCount + 2, gfx::AttributeDataType::Short2, idCollisionExtrudeVertexAttribute},
|
||||
AttributeInfo{collisionUBOCount + 3, gfx::AttributeDataType::UShort2, idCollisionPlacedVertexAttribute},
|
||||
AttributeInfo{collisionUBOCount + 4, gfx::AttributeDataType::Float2, idCollisionShiftVertexAttribute},
|
||||
AttributeInfo{collisionDrawableUBOCount + 0, gfx::AttributeDataType::Short2, idCollisionPosVertexAttribute},
|
||||
AttributeInfo{collisionDrawableUBOCount + 1, gfx::AttributeDataType::Short2, idCollisionAnchorPosVertexAttribute},
|
||||
AttributeInfo{collisionDrawableUBOCount + 2, gfx::AttributeDataType::Short2, idCollisionExtrudeVertexAttribute},
|
||||
AttributeInfo{collisionDrawableUBOCount + 3, gfx::AttributeDataType::UShort2, idCollisionPlacedVertexAttribute},
|
||||
AttributeInfo{collisionDrawableUBOCount + 4, gfx::AttributeDataType::Float2, idCollisionShiftVertexAttribute},
|
||||
};
|
||||
const std::array<TextureInfo, 0> ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::Metal>::textures = {};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/collision_circle.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -9,10 +10,11 @@ const std::array<UniformBlockInfo, 1>
|
||||
};
|
||||
const std::array<AttributeInfo, 4> ShaderSource<BuiltIn::CollisionCircleShader, gfx::Backend::Type::Metal>::attributes =
|
||||
{
|
||||
AttributeInfo{collisionUBOCount + 0, gfx::AttributeDataType::Short2, idCollisionPosVertexAttribute},
|
||||
AttributeInfo{collisionUBOCount + 1, gfx::AttributeDataType::Short2, idCollisionAnchorPosVertexAttribute},
|
||||
AttributeInfo{collisionUBOCount + 2, gfx::AttributeDataType::Short2, idCollisionExtrudeVertexAttribute},
|
||||
AttributeInfo{collisionUBOCount + 3, gfx::AttributeDataType::UShort2, idCollisionPlacedVertexAttribute},
|
||||
AttributeInfo{collisionDrawableUBOCount + 0, gfx::AttributeDataType::Short2, idCollisionPosVertexAttribute},
|
||||
AttributeInfo{
|
||||
collisionDrawableUBOCount + 1, gfx::AttributeDataType::Short2, idCollisionAnchorPosVertexAttribute},
|
||||
AttributeInfo{collisionDrawableUBOCount + 2, gfx::AttributeDataType::Short2, idCollisionExtrudeVertexAttribute},
|
||||
AttributeInfo{collisionDrawableUBOCount + 3, gfx::AttributeDataType::UShort2, idCollisionPlacedVertexAttribute},
|
||||
};
|
||||
const std::array<TextureInfo, 0> ShaderSource<BuiltIn::CollisionCircleShader, gfx::Backend::Type::Metal>::textures = {};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/custom_symbol_icon.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -8,11 +9,11 @@ const std::array<UniformBlockInfo, 2>
|
||||
UniformBlockInfo{true, false, sizeof(CustomSymbolIconDrawableUBO), idCustomSymbolDrawableUBO},
|
||||
UniformBlockInfo{true, false, sizeof(CustomSymbolIconParametersUBO), idCustomSymbolParametersUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 2>
|
||||
ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
// always attributes
|
||||
AttributeInfo{customSymbolUBOCount + 0, gfx::AttributeDataType::Float2, idCustomSymbolPosVertexAttribute},
|
||||
AttributeInfo{customSymbolUBOCount + 1, gfx::AttributeDataType::Float2, idCustomSymbolTexVertexAttribute},
|
||||
const std::array<AttributeInfo, 2> ShaderSource<BuiltIn::CustomSymbolIconShader,
|
||||
gfx::Backend::Type::Metal>::attributes = {
|
||||
// always attributes
|
||||
AttributeInfo{customSymbolDrawableUBOCount + 0, gfx::AttributeDataType::Float2, idCustomSymbolPosVertexAttribute},
|
||||
AttributeInfo{customSymbolDrawableUBOCount + 1, gfx::AttributeDataType::Float2, idCustomSymbolTexVertexAttribute},
|
||||
};
|
||||
const std::array<TextureInfo, 1> ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Metal>::textures = {
|
||||
TextureInfo{0, idCustomSymbolImageTexture},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/debug.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -7,7 +8,7 @@ const std::array<UniformBlockInfo, 1> ShaderSource<BuiltIn::DebugShader, gfx::Ba
|
||||
UniformBlockInfo{true, true, sizeof(DebugUBO), idDebugUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 1> ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{debugUBOCount + 0, gfx::AttributeDataType::Short2, idDebugPosVertexAttribute},
|
||||
AttributeInfo{debugDrawableUBOCount + 0, gfx::AttributeDataType::Short2, idDebugPosVertexAttribute},
|
||||
};
|
||||
const std::array<TextureInfo, 1> ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::Metal>::textures = {
|
||||
TextureInfo{0, idDebugOverlayTexture},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/fill.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/fill_extrusion.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -6,8 +7,8 @@ namespace shaders {
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Metal>::uniforms =
|
||||
{
|
||||
UniformBlockInfo{true, false, sizeof(FillExtrusionDrawableUBO), idFillExtrusionDrawableUBO},
|
||||
UniformBlockInfo{true, false, sizeof(FillExtrusionPropsUBO), idFillExtrusionPropsUBO},
|
||||
UniformBlockInfo{true, false, sizeof(FillExtrusionInterpolateUBO), idFillExtrusionInterpolateUBO},
|
||||
UniformBlockInfo{true, false, sizeof(FillExtrusionPropsUBO), idFillExtrusionPropsUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 5> ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{fillExtrusionUBOCount + 0, gfx::AttributeDataType::Short2, idFillExtrusionPosVertexAttribute},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <mbgl/shaders/mtl/fill_extrusion_pattern.hpp>
|
||||
#include <mbgl/shaders/fill_extrusion_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -8,9 +9,9 @@ const std::array<UniformBlockInfo, 5>
|
||||
ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
|
||||
UniformBlockInfo{true, true, sizeof(FillExtrusionDrawableUBO), idFillExtrusionDrawableUBO},
|
||||
UniformBlockInfo{true, true, sizeof(FillExtrusionPropsUBO), idFillExtrusionPropsUBO},
|
||||
UniformBlockInfo{true, true, sizeof(FillExtrusionTilePropsUBO), idFillExtrusionTilePropsUBO},
|
||||
UniformBlockInfo{true, false, sizeof(FillExtrusionInterpolateUBO), idFillExtrusionInterpolateUBO},
|
||||
UniformBlockInfo{true, true, sizeof(FillExtrusionPropsUBO), idFillExtrusionPropsUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 6> ShaderSource<BuiltIn::FillExtrusionPatternShader,
|
||||
gfx::Backend::Type::Metal>::attributes = {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include <mbgl/shaders/mtl/heatmap.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Metal>::uniforms = {
|
||||
UniformBlockInfo{true, false, sizeof(HeatmapDrawableUBO), idHeatmapDrawableUBO},
|
||||
UniformBlockInfo{true, true, sizeof(HeatmapEvaluatedPropsUBO), idHeatmapEvaluatedPropsUBO},
|
||||
UniformBlockInfo{true, false, sizeof(HeatmapInterpolateUBO), idHeatmapInterpolateUBO},
|
||||
UniformBlockInfo{true, true, sizeof(HeatmapEvaluatedPropsUBO), idHeatmapEvaluatedPropsUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 3> ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{heatmapUBOCount + 0, gfx::AttributeDataType::Short2, idHeatmapPosVertexAttribute},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/heatmap_texture.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/hillshade.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/hillshade_prepare.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -9,8 +10,9 @@ const std::array<UniformBlockInfo, 1>
|
||||
};
|
||||
const std::array<AttributeInfo, 2> ShaderSource<BuiltIn::HillshadePrepareShader,
|
||||
gfx::Backend::Type::Metal>::attributes = {
|
||||
AttributeInfo{hillshadePrepareUBOCount + 0, gfx::AttributeDataType::Short2, idHillshadePosVertexAttribute},
|
||||
AttributeInfo{hillshadePrepareUBOCount + 1, gfx::AttributeDataType::Short2, idHillshadeTexturePosVertexAttribute},
|
||||
AttributeInfo{hillshadePrepareDrawableUBOCount + 0, gfx::AttributeDataType::Short2, idHillshadePosVertexAttribute},
|
||||
AttributeInfo{
|
||||
hillshadePrepareDrawableUBOCount + 1, gfx::AttributeDataType::Short2, idHillshadeTexturePosVertexAttribute},
|
||||
};
|
||||
const std::array<TextureInfo, 1> ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::Metal>::textures = {
|
||||
TextureInfo{0, idHillshadeImageTexture},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/line.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/raster.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/symbol_icon.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/symbol_sdf.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <mbgl/shaders/mtl/symbol_text_and_icon.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <mbgl/shaders/vulkan/background.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/background_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <mbgl/shaders/vulkan/circle.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/circle_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -6,8 +8,8 @@ namespace shaders {
|
||||
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Vulkan>::uniforms = {
|
||||
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
|
||||
UniformBlockInfo{true, false, sizeof(CircleDrawableUBO), idCircleDrawableUBO},
|
||||
UniformBlockInfo{true, true, sizeof(CircleEvaluatedPropsUBO), idCircleEvaluatedPropsUBO},
|
||||
UniformBlockInfo{true, false, sizeof(CircleInterpolateUBO), idCircleInterpolateUBO},
|
||||
UniformBlockInfo{true, true, sizeof(CircleEvaluatedPropsUBO), idCircleEvaluatedPropsUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 8> ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Vulkan>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idCirclePosVertexAttribute},
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <mbgl/shaders/vulkan/collision.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/collision_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <mbgl/shaders/vulkan/debug.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/debug_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include <mbgl/shaders/vulkan/fill.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/fill_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/fill_extrusion_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
@@ -78,8 +81,8 @@ const std::array<AttributeInfo, 2>
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Vulkan>::uniforms =
|
||||
{
|
||||
UniformBlockInfo{true, false, sizeof(FillExtrusionDrawableUBO), idFillExtrusionDrawableUBO},
|
||||
UniformBlockInfo{true, false, sizeof(FillExtrusionPropsUBO), idFillExtrusionPropsUBO},
|
||||
UniformBlockInfo{true, false, sizeof(FillExtrusionInterpolateUBO), idFillExtrusionInterpolateUBO},
|
||||
UniformBlockInfo{true, false, sizeof(FillExtrusionPropsUBO), idFillExtrusionPropsUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 5> ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Vulkan>::attributes =
|
||||
{
|
||||
@@ -94,9 +97,9 @@ const std::array<UniformBlockInfo, 5>
|
||||
ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::Vulkan>::uniforms = {
|
||||
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
|
||||
UniformBlockInfo{true, true, sizeof(FillExtrusionDrawableUBO), idFillExtrusionDrawableUBO},
|
||||
UniformBlockInfo{true, true, sizeof(FillExtrusionPropsUBO), idFillExtrusionPropsUBO},
|
||||
UniformBlockInfo{true, true, sizeof(FillExtrusionTilePropsUBO), idFillExtrusionTilePropsUBO},
|
||||
UniformBlockInfo{true, false, sizeof(FillExtrusionInterpolateUBO), idFillExtrusionInterpolateUBO},
|
||||
UniformBlockInfo{true, true, sizeof(FillExtrusionPropsUBO), idFillExtrusionPropsUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 6>
|
||||
ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::Vulkan>::attributes = {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#include <mbgl/shaders/vulkan/heatmap.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/heatmap_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/heatmap_texture_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Vulkan>::uniforms = {
|
||||
UniformBlockInfo{true, false, sizeof(HeatmapDrawableUBO), idHeatmapDrawableUBO},
|
||||
UniformBlockInfo{true, true, sizeof(HeatmapEvaluatedPropsUBO), idHeatmapEvaluatedPropsUBO},
|
||||
UniformBlockInfo{true, false, sizeof(HeatmapInterpolateUBO), idHeatmapInterpolateUBO},
|
||||
UniformBlockInfo{true, true, sizeof(HeatmapEvaluatedPropsUBO), idHeatmapEvaluatedPropsUBO},
|
||||
};
|
||||
const std::array<AttributeInfo, 3> ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Vulkan>::attributes = {
|
||||
AttributeInfo{0, gfx::AttributeDataType::Short2, idHeatmapPosVertexAttribute},
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include <mbgl/shaders/vulkan/hillshade.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/hillshade_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/hillshade_prepare_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <mbgl/shaders/vulkan/line.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/line_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <mbgl/shaders/vulkan/raster.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/raster_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include <mbgl/shaders/vulkan/symbol.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/symbol_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/custom_drawable_layer_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <mbgl/shaders/vulkan/widevector.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/shaders/widevector_ubo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#ifndef MLN_VULKAN_DESCRIPTOR_POOL_SIZE
|
||||
#define MLN_VULKAN_DESCRIPTOR_POOL_SIZE 10000
|
||||
#define MLN_VULKAN_DESCRIPTOR_POOL_SIZE 30000
|
||||
#endif
|
||||
|
||||
namespace mbgl {
|
||||
@@ -48,7 +48,8 @@ public:
|
||||
|
||||
Context::Context(RendererBackend& backend_)
|
||||
: gfx::Context(vulkan::maximumVertexBindingCount),
|
||||
backend(backend_) {
|
||||
backend(backend_),
|
||||
globalUniformBuffers(DescriptorSetType::Global, 0, shaders::globalUBOCount) {
|
||||
if (glslangRefCount++ == 0) {
|
||||
glslang::InitializeProcess();
|
||||
}
|
||||
@@ -70,26 +71,28 @@ void Context::initFrameResources() {
|
||||
const auto& device = backend.getDevice();
|
||||
const auto frameCount = backend.getMaxFrames();
|
||||
|
||||
// command buffers
|
||||
const vk::CommandBufferAllocateInfo allocateInfo(
|
||||
backend.getCommandPool().get(), vk::CommandBufferLevel::ePrimary, frameCount);
|
||||
|
||||
auto commandBuffers = backend.getDevice()->allocateCommandBuffersUnique(allocateInfo);
|
||||
|
||||
// descriptor pool info
|
||||
const std::vector<vk::DescriptorPoolSize> poolSizes = {
|
||||
{vk::DescriptorType::eUniformBuffer, MLN_VULKAN_DESCRIPTOR_POOL_SIZE},
|
||||
{vk::DescriptorType::eCombinedImageSampler, MLN_VULKAN_DESCRIPTOR_POOL_SIZE},
|
||||
};
|
||||
|
||||
const auto descriptorPoolInfo = vk::DescriptorPoolCreateInfo().setPoolSizes(poolSizes).setMaxSets(
|
||||
MLN_VULKAN_DESCRIPTOR_POOL_SIZE);
|
||||
const auto descriptorPoolInfo = vk::DescriptorPoolCreateInfo(vk::DescriptorPoolCreateFlagBits::eFreeDescriptorSet)
|
||||
.setPoolSizes(poolSizes)
|
||||
.setMaxSets(MLN_VULKAN_DESCRIPTOR_POOL_SIZE);
|
||||
|
||||
globalDescriptorPool = device->createDescriptorPoolUnique(descriptorPoolInfo);
|
||||
|
||||
// command buffers
|
||||
const vk::CommandBufferAllocateInfo allocateInfo(
|
||||
backend.getCommandPool().get(), vk::CommandBufferLevel::ePrimary, frameCount);
|
||||
|
||||
auto commandBuffers = backend.getDevice()->allocateCommandBuffersUnique(allocateInfo);
|
||||
|
||||
frameResources.reserve(frameCount);
|
||||
|
||||
for (uint32_t index = 0; index < frameCount; ++index) {
|
||||
frameResources.emplace_back(commandBuffers[index],
|
||||
device->createDescriptorPoolUnique(descriptorPoolInfo),
|
||||
device->createSemaphoreUnique({}),
|
||||
device->createSemaphoreUnique({}),
|
||||
device->createFenceUnique(vk::FenceCreateInfo(vk::FenceCreateFlagBits::eSignaled)));
|
||||
@@ -97,7 +100,6 @@ void Context::initFrameResources() {
|
||||
const auto& frame = frameResources.back();
|
||||
|
||||
backend.setDebugName(frame.commandBuffer.get(), "FrameCommandBuffer_" + std::to_string(index));
|
||||
backend.setDebugName(frame.descriptorPool.get(), "DescriptorPool_" + std::to_string(index));
|
||||
backend.setDebugName(frame.frameSemaphore.get(), "FrameSemaphore_" + std::to_string(index));
|
||||
backend.setDebugName(frame.surfaceSemaphore.get(), "SurfaceSemaphore_" + std::to_string(index));
|
||||
backend.setDebugName(frame.flightFrameFence.get(), "FrameFence_" + std::to_string(index));
|
||||
@@ -114,12 +116,14 @@ void Context::destroyResources() {
|
||||
frame.runDeletionQueue(*this);
|
||||
}
|
||||
|
||||
globalUniformBuffers.freeDescriptorSets();
|
||||
|
||||
// all resources have unique handles
|
||||
frameResources.clear();
|
||||
}
|
||||
|
||||
const vk::UniqueDescriptorPool& Context::getCurrentDescriptorPool() const {
|
||||
return frameResources[frameResourceIndex].descriptorPool;
|
||||
const vk::UniqueDescriptorPool& Context::getGlobalDescriptorPool() const {
|
||||
return globalDescriptorPool;
|
||||
}
|
||||
|
||||
void Context::enqueueDeletion(std::function<void(const Context&)>&& function) {
|
||||
@@ -131,7 +135,7 @@ void Context::enqueueDeletion(std::function<void(const Context&)>&& function) {
|
||||
frameResources[frameResourceIndex].deletionQueue.push_back(std::move(function));
|
||||
}
|
||||
|
||||
void Context::submitOneTimeCommand(const std::function<void(const vk::UniqueCommandBuffer&)>& function) {
|
||||
void Context::submitOneTimeCommand(const std::function<void(const vk::UniqueCommandBuffer&)>& function) const {
|
||||
const vk::CommandBufferAllocateInfo allocateInfo(
|
||||
backend.getCommandPool().get(), vk::CommandBufferLevel::ePrimary, 1);
|
||||
|
||||
@@ -178,7 +182,6 @@ void Context::beginFrame() {
|
||||
// we wait for an idle device to recreate the swapchain
|
||||
// so it's a good opportunity to delete all queued items
|
||||
for (auto& frame : frameResources) {
|
||||
device->resetDescriptorPool(frame.descriptorPool.get());
|
||||
frame.runDeletionQueue(*this);
|
||||
}
|
||||
|
||||
@@ -194,7 +197,6 @@ void Context::beginFrame() {
|
||||
|
||||
waitFrame();
|
||||
|
||||
device->resetDescriptorPool(getCurrentDescriptorPool().get());
|
||||
frame.runDeletionQueue(*this);
|
||||
|
||||
if (platformSurface) {
|
||||
@@ -390,7 +392,10 @@ void Context::clearStencilBuffer(int32_t) {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void Context::bindGlobalUniformBuffers(gfx::RenderPass&) const noexcept {}
|
||||
void Context::bindGlobalUniformBuffers(gfx::RenderPass& renderPass) const noexcept {
|
||||
auto& renderPassImpl = static_cast<RenderPass&>(renderPass);
|
||||
const_cast<Context*>(this)->globalUniformBuffers.bindDescriptorSets(renderPassImpl.getEncoder());
|
||||
}
|
||||
|
||||
bool Context::renderTileClippingMasks(gfx::RenderPass& renderPass,
|
||||
RenderStaticData& staticData,
|
||||
@@ -517,27 +522,30 @@ const std::unique_ptr<Texture2D>& Context::getDummyTexture() {
|
||||
return dummyTexture2D;
|
||||
}
|
||||
|
||||
const vk::UniqueDescriptorSetLayout& Context::getUniformDescriptorSetLayout() {
|
||||
if (!uniformDescriptorSetLayout) {
|
||||
std::vector<vk::DescriptorSetLayoutBinding> bindings;
|
||||
const auto stageFlags = vk::ShaderStageFlags() | vk::ShaderStageFlagBits::eVertex |
|
||||
vk::ShaderStageFlagBits::eFragment;
|
||||
|
||||
for (size_t i = 0; i < shaders::maxUBOCountPerShader; ++i) {
|
||||
bindings.push_back(vk::DescriptorSetLayoutBinding()
|
||||
.setBinding(static_cast<uint32_t>(i))
|
||||
.setStageFlags(stageFlags)
|
||||
.setDescriptorType(vk::DescriptorType::eUniformBuffer)
|
||||
.setDescriptorCount(1));
|
||||
}
|
||||
|
||||
const auto descriptorSetLayoutCreateInfo = vk::DescriptorSetLayoutCreateInfo().setBindings(bindings);
|
||||
uniformDescriptorSetLayout = backend.getDevice()->createDescriptorSetLayoutUnique(
|
||||
descriptorSetLayoutCreateInfo);
|
||||
backend.setDebugName(uniformDescriptorSetLayout.get(), "UniformDescriptorSetLayout");
|
||||
const vk::UniqueDescriptorSetLayout& Context::buildUniformDescriptorSetLayout(vk::UniqueDescriptorSetLayout& layout,
|
||||
size_t uniformCount,
|
||||
const std::string& name) {
|
||||
if (layout) {
|
||||
return layout;
|
||||
}
|
||||
|
||||
return uniformDescriptorSetLayout;
|
||||
std::vector<vk::DescriptorSetLayoutBinding> bindings;
|
||||
const auto stageFlags = vk::ShaderStageFlags() | vk::ShaderStageFlagBits::eVertex |
|
||||
vk::ShaderStageFlagBits::eFragment;
|
||||
|
||||
for (size_t i = 0; i < uniformCount; ++i) {
|
||||
bindings.push_back(vk::DescriptorSetLayoutBinding()
|
||||
.setBinding(i)
|
||||
.setStageFlags(stageFlags)
|
||||
.setDescriptorType(vk::DescriptorType::eUniformBuffer)
|
||||
.setDescriptorCount(1));
|
||||
}
|
||||
|
||||
const auto descriptorSetLayoutCreateInfo = vk::DescriptorSetLayoutCreateInfo().setBindings(bindings);
|
||||
layout = backend.getDevice()->createDescriptorSetLayoutUnique(descriptorSetLayoutCreateInfo);
|
||||
backend.setDebugName(layout.get(), name);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
const vk::UniqueDescriptorSetLayout& Context::getImageDescriptorSetLayout() {
|
||||
@@ -562,12 +570,29 @@ const vk::UniqueDescriptorSetLayout& Context::getImageDescriptorSetLayout() {
|
||||
|
||||
const std::vector<vk::DescriptorSetLayout>& Context::getDescriptorSetLayouts() {
|
||||
if (descriptorSetLayouts.empty()) {
|
||||
descriptorSetLayouts = {getUniformDescriptorSetLayout().get(), getImageDescriptorSetLayout().get()};
|
||||
descriptorSetLayouts = {
|
||||
buildUniformDescriptorSetLayout(
|
||||
globalUniformDescriptorSetLayout, shaders::globalUBOCount, "GlobalUniformDescriptorSetLayout")
|
||||
.get(),
|
||||
buildUniformDescriptorSetLayout(
|
||||
layerUniformDescriptorSetLayout, shaders::maxUBOCountPerLayer, "LayerUniformDescriptorSetLayout")
|
||||
.get(),
|
||||
buildUniformDescriptorSetLayout(drawableUniformDescriptorSetLayout,
|
||||
shaders::maxUBOCountPerDrawable,
|
||||
"DrawableUniformDescriptorSetLayout")
|
||||
.get(),
|
||||
getImageDescriptorSetLayout().get()};
|
||||
}
|
||||
|
||||
return descriptorSetLayouts;
|
||||
}
|
||||
|
||||
const vk::DescriptorSetLayout& Context::getDescriptorSetLayout(DescriptorSetType type) {
|
||||
uint32_t index = static_cast<uint32_t>(type);
|
||||
assert(index < static_cast<uint32_t>(DescriptorSetType::Count));
|
||||
return getDescriptorSetLayouts()[index];
|
||||
}
|
||||
|
||||
const vk::UniquePipelineLayout& Context::getGeneralPipelineLayout() {
|
||||
if (generalPipelineLayout) return generalPipelineLayout;
|
||||
|
||||
|
||||
131
src/mbgl/vulkan/descriptor_set.cpp
Normal file
131
src/mbgl/vulkan/descriptor_set.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
#include <mbgl/vulkan/descriptor_set.hpp>
|
||||
|
||||
#include <mbgl/vulkan/context.hpp>
|
||||
#include <mbgl/vulkan/command_encoder.hpp>
|
||||
#include <mbgl/vulkan/texture2d.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace mbgl {
|
||||
namespace vulkan {
|
||||
|
||||
DescriptorSet::DescriptorSet(Context& context_, DescriptorSetType type_)
|
||||
: context(context_),
|
||||
type(type_) {}
|
||||
|
||||
DescriptorSet::~DescriptorSet() {
|
||||
context.enqueueDeletion([sets = std::move(descriptorSets)](const auto& context_) mutable {
|
||||
context_.getBackend().getDevice()->freeDescriptorSets(context_.getGlobalDescriptorPool().get(), sets);
|
||||
});
|
||||
}
|
||||
|
||||
void DescriptorSet::allocate() {
|
||||
if (!descriptorSets.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& device = context.getBackend().getDevice();
|
||||
const auto& descriptorPool = context.getGlobalDescriptorPool();
|
||||
const auto& descriptorSetLayout = context.getDescriptorSetLayout(type);
|
||||
const std::vector<vk::DescriptorSetLayout> layouts(context.getBackend().getMaxFrames(), descriptorSetLayout);
|
||||
|
||||
const auto descriptorAllocInfo =
|
||||
vk::DescriptorSetAllocateInfo().setDescriptorPool(*descriptorPool).setSetLayouts(layouts);
|
||||
|
||||
descriptorSets = device->allocateDescriptorSets(descriptorAllocInfo);
|
||||
|
||||
markDirty(true);
|
||||
}
|
||||
|
||||
void DescriptorSet::markDirty(bool value) {
|
||||
dirty = std::vector(descriptorSets.size(), value);
|
||||
}
|
||||
|
||||
void DescriptorSet::bind(CommandEncoder& encoder) {
|
||||
auto& commandBuffer = encoder.getCommandBuffer();
|
||||
|
||||
const uint8_t index = context.getCurrentFrameResourceIndex();
|
||||
|
||||
commandBuffer->bindDescriptorSets(vk::PipelineBindPoint::eGraphics,
|
||||
context.getGeneralPipelineLayout().get(),
|
||||
static_cast<uint32_t>(type),
|
||||
descriptorSets[index],
|
||||
nullptr);
|
||||
}
|
||||
|
||||
UniformDescriptorSet::UniformDescriptorSet(Context& context_, DescriptorSetType type_)
|
||||
: DescriptorSet(context_, type_) {}
|
||||
|
||||
void UniformDescriptorSet::update(const gfx::UniformBufferArray& uniforms,
|
||||
uint32_t uniformStartIndex,
|
||||
uint32_t descriptorBindingCount) {
|
||||
allocate();
|
||||
|
||||
const uint8_t frameIndex = context.getCurrentFrameResourceIndex();
|
||||
if (!dirty[frameIndex]) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& device = context.getBackend().getDevice();
|
||||
|
||||
for (size_t index = 0; index < descriptorBindingCount; ++index) {
|
||||
vk::DescriptorBufferInfo descriptorBufferInfo;
|
||||
|
||||
if (const auto& uniformBuffer = uniforms.get(uniformStartIndex + index)) {
|
||||
const auto& uniformBufferImpl = static_cast<const UniformBuffer&>(*uniformBuffer);
|
||||
const auto& bufferResource = uniformBufferImpl.getBufferResource();
|
||||
descriptorBufferInfo.setBuffer(bufferResource.getVulkanBuffer())
|
||||
.setOffset(bufferResource.getVulkanBufferOffset())
|
||||
.setRange(bufferResource.getSizeInBytes());
|
||||
} else {
|
||||
descriptorBufferInfo.setBuffer(context.getDummyUniformBuffer()->getVulkanBuffer())
|
||||
.setOffset(0)
|
||||
.setRange(VK_WHOLE_SIZE);
|
||||
}
|
||||
|
||||
const auto writeDescriptorSet = vk::WriteDescriptorSet()
|
||||
.setBufferInfo(descriptorBufferInfo)
|
||||
.setDescriptorCount(1)
|
||||
.setDescriptorType(vk::DescriptorType::eUniformBuffer)
|
||||
.setDstBinding(index)
|
||||
.setDstSet(descriptorSets[frameIndex]);
|
||||
|
||||
device->updateDescriptorSets(writeDescriptorSet, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
ImageDescriptorSet::ImageDescriptorSet(Context& context_)
|
||||
: DescriptorSet(context_, DescriptorSetType::DrawableImage) {}
|
||||
|
||||
void ImageDescriptorSet::update(const std::array<gfx::Texture2DPtr, shaders::maxTextureCountPerShader>& textures) {
|
||||
allocate();
|
||||
|
||||
const uint8_t frameIndex = context.getCurrentFrameResourceIndex();
|
||||
if (!dirty[frameIndex]) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& device = context.getBackend().getDevice();
|
||||
|
||||
for (size_t id = 0; id < shaders::maxTextureCountPerShader; ++id) {
|
||||
const auto& texture = id < textures.size() ? textures[id] : nullptr;
|
||||
auto& textureImpl = texture ? static_cast<Texture2D&>(*texture) : *context.getDummyTexture();
|
||||
|
||||
const auto descriptorImageInfo = vk::DescriptorImageInfo()
|
||||
.setImageLayout(textureImpl.getVulkanImageLayout())
|
||||
.setImageView(textureImpl.getVulkanImageView().get())
|
||||
.setSampler(textureImpl.getVulkanSampler());
|
||||
|
||||
const auto writeDescriptorSet = vk::WriteDescriptorSet()
|
||||
.setImageInfo(descriptorImageInfo)
|
||||
.setDescriptorCount(1)
|
||||
.setDescriptorType(vk::DescriptorType::eCombinedImageSampler)
|
||||
.setDstBinding(id)
|
||||
.setDstSet(descriptorSets[frameIndex]);
|
||||
|
||||
device->updateDescriptorSets(writeDescriptorSet, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vulkan
|
||||
} // namespace mbgl
|
||||
@@ -405,81 +405,20 @@ bool Drawable::bindAttributes(CommandEncoder& encoder) const noexcept {
|
||||
bool Drawable::bindDescriptors(CommandEncoder& encoder) const noexcept {
|
||||
if (!shader) return false;
|
||||
|
||||
auto& context = encoder.getContext();
|
||||
const auto& device = context.getBackend().getDevice();
|
||||
const auto& descriptorPool = context.getCurrentDescriptorPool();
|
||||
const auto& descriptorSetLayouts = context.getDescriptorSetLayouts();
|
||||
// bind uniforms
|
||||
impl->uniformBuffers.bindDescriptorSets(encoder);
|
||||
|
||||
const auto descriptorAllocInfo =
|
||||
vk::DescriptorSetAllocateInfo().setDescriptorPool(*descriptorPool).setSetLayouts(descriptorSetLayouts);
|
||||
|
||||
const auto& drawableDescriptorSets = device->allocateDescriptorSets(descriptorAllocInfo);
|
||||
const auto& uniformDescriptorSet = drawableDescriptorSets[0];
|
||||
|
||||
const auto updateUniformDescriptors = [&](const auto& buffer, bool fillGaps) {
|
||||
for (size_t id = 0; id < buffer.allocatedSize(); ++id) {
|
||||
vk::DescriptorBufferInfo descriptorBufferInfo;
|
||||
|
||||
if (const auto& uniformBuffer = buffer.get(id)) {
|
||||
const auto& uniformBufferImpl = static_cast<const UniformBuffer&>(*uniformBuffer);
|
||||
const auto& bufferResource = uniformBufferImpl.getBufferResource();
|
||||
descriptorBufferInfo.setBuffer(bufferResource.getVulkanBuffer())
|
||||
.setOffset(bufferResource.getVulkanBufferOffset())
|
||||
.setRange(bufferResource.getSizeInBytes());
|
||||
} else if (fillGaps) {
|
||||
descriptorBufferInfo.setBuffer(context.getDummyUniformBuffer()->getVulkanBuffer())
|
||||
.setOffset(0)
|
||||
.setRange(VK_WHOLE_SIZE);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto writeDescriptorSet = vk::WriteDescriptorSet()
|
||||
.setBufferInfo(descriptorBufferInfo)
|
||||
.setDescriptorCount(1)
|
||||
.setDescriptorType(vk::DescriptorType::eUniformBuffer)
|
||||
.setDstBinding(static_cast<uint32_t>(id))
|
||||
.setDstSet(uniformDescriptorSet);
|
||||
|
||||
device->updateDescriptorSets(writeDescriptorSet, nullptr);
|
||||
const auto& shaderImpl = static_cast<const mbgl::vulkan::ShaderProgram&>(*shader);
|
||||
if (shaderImpl.hasTextures()) {
|
||||
// update image set
|
||||
if (!impl->imageDescriptorSet) {
|
||||
impl->imageDescriptorSet = std::make_unique<ImageDescriptorSet>(encoder.getContext());
|
||||
}
|
||||
};
|
||||
const auto& globalUniforms = context.getGlobalUniformBuffers();
|
||||
for (size_t i = 0; i < globalUniforms.allocatedSize(); ++i) {
|
||||
if (globalUniforms.get(i)) impl->uniformBuffers.set(i, globalUniforms.get(i));
|
||||
|
||||
impl->imageDescriptorSet->update(textures);
|
||||
impl->imageDescriptorSet->bind(encoder);
|
||||
}
|
||||
|
||||
updateUniformDescriptors(getUniformBuffers(), true);
|
||||
|
||||
if (drawableDescriptorSets.size() >= 2) {
|
||||
const auto& imageDescriptorSet = drawableDescriptorSets[1];
|
||||
|
||||
for (size_t id = 0; id < shaders::maxTextureCountPerShader; ++id) {
|
||||
const auto& texture = id < textures.size() ? textures[id] : nullptr;
|
||||
auto& textureImpl = texture ? static_cast<Texture2D&>(*texture) : *context.getDummyTexture();
|
||||
|
||||
const auto descriptorImageInfo = vk::DescriptorImageInfo()
|
||||
.setImageLayout(textureImpl.getVulkanImageLayout())
|
||||
.setImageView(textureImpl.getVulkanImageView().get())
|
||||
.setSampler(textureImpl.getVulkanSampler());
|
||||
|
||||
const auto writeDescriptorSet = vk::WriteDescriptorSet()
|
||||
.setImageInfo(descriptorImageInfo)
|
||||
.setDescriptorCount(1)
|
||||
.setDescriptorType(vk::DescriptorType::eCombinedImageSampler)
|
||||
.setDstBinding(static_cast<uint32_t>(id))
|
||||
.setDstSet(imageDescriptorSet);
|
||||
|
||||
device->updateDescriptorSets(writeDescriptorSet, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (drawableDescriptorSets.empty()) return true;
|
||||
|
||||
const auto& commandBuffer = encoder.getCommandBuffer();
|
||||
commandBuffer->bindDescriptorSets(
|
||||
vk::PipelineBindPoint::eGraphics, context.getGeneralPipelineLayout().get(), 0, drawableDescriptorSets, nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <mbgl/vulkan/render_pass.hpp>
|
||||
#include <mbgl/vulkan/upload_pass.hpp>
|
||||
#include <mbgl/vulkan/pipeline.hpp>
|
||||
#include <mbgl/shaders/shader_defines.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
|
||||
@@ -22,7 +23,10 @@ using namespace platform;
|
||||
|
||||
class Drawable::Impl final {
|
||||
public:
|
||||
Impl() = default;
|
||||
Impl()
|
||||
: uniformBuffers(DescriptorSetType::DrawableUniform, shaders::globalUBOCount, shaders::maxUBOCountPerDrawable) {
|
||||
}
|
||||
|
||||
~Impl() = default;
|
||||
|
||||
std::vector<UniqueDrawSegment> segments;
|
||||
@@ -47,6 +51,8 @@ public:
|
||||
|
||||
std::vector<vk::Buffer> vulkanVertexBuffers;
|
||||
std::vector<vk::DeviceSize> vulkanVertexOffsets;
|
||||
|
||||
std::unique_ptr<ImageDescriptorSet> imageDescriptorSet;
|
||||
};
|
||||
|
||||
} // namespace vulkan
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <mbgl/vulkan/context.hpp>
|
||||
#include <mbgl/vulkan/drawable.hpp>
|
||||
#include <mbgl/vulkan/render_pass.hpp>
|
||||
#include <mbgl/vulkan/command_encoder.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
|
||||
@@ -14,7 +15,8 @@ namespace mbgl {
|
||||
namespace vulkan {
|
||||
|
||||
LayerGroup::LayerGroup(int32_t layerIndex_, std::size_t initialCapacity, std::string name_)
|
||||
: mbgl::LayerGroup(layerIndex_, initialCapacity, std::move(name_)) {}
|
||||
: mbgl::LayerGroup(layerIndex_, initialCapacity, std::move(name_)),
|
||||
uniformBuffers(DescriptorSetType::Layer, shaders::layerUBOStartId, shaders::maxUBOCountPerLayer) {}
|
||||
|
||||
void LayerGroup::upload(gfx::UploadPass& uploadPass) {
|
||||
if (!enabled) {
|
||||
@@ -43,6 +45,7 @@ void LayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) {
|
||||
#endif
|
||||
|
||||
auto& renderPass = static_cast<RenderPass&>(*parameters.renderPass);
|
||||
auto& encoder = renderPass.getEncoder();
|
||||
|
||||
bool bindUBOs = false;
|
||||
visitDrawables([&](gfx::Drawable& drawable) {
|
||||
@@ -55,34 +58,12 @@ void LayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) {
|
||||
}
|
||||
|
||||
if (!bindUBOs) {
|
||||
bindUniformBuffers(renderPass);
|
||||
uniformBuffers.bindDescriptorSets(encoder);
|
||||
bindUBOs = true;
|
||||
}
|
||||
|
||||
auto& drawableUniforms = drawable.mutableUniformBuffers();
|
||||
for (size_t i = 0; i < uniformBuffers.allocatedSize(); ++i) {
|
||||
if (uniformBuffers.get(i)) {
|
||||
drawableUniforms.set(i, uniformBuffers.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
drawable.draw(parameters);
|
||||
});
|
||||
|
||||
if (bindUBOs) {
|
||||
unbindUniformBuffers(renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
void LayerGroup::bindUniformBuffers(RenderPass& renderPass) const noexcept {
|
||||
for (size_t id = 0; id < uniformBuffers.allocatedSize(); id++) {
|
||||
const auto& uniformBuffer = uniformBuffers.get(id);
|
||||
if (!uniformBuffer) continue;
|
||||
const auto& buffer = static_cast<UniformBuffer&>(*uniformBuffer);
|
||||
const auto& resource = buffer.getBufferResource();
|
||||
renderPass.bindVertex(resource, 0, id);
|
||||
renderPass.bindFragment(resource, 0, id);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vulkan
|
||||
|
||||
@@ -71,15 +71,5 @@ void RenderPass::addDebugSignpost(const char* name) {
|
||||
commandEncoder.getContext().getBackend().insertDebugLabel(commandEncoder.getCommandBuffer().get(), name);
|
||||
}
|
||||
|
||||
void RenderPass::bindVertex(const BufferResource& buf, std::size_t offset, std::size_t, std::size_t size) {
|
||||
[[maybe_unused]] const auto actualSize = size ? size : buf.getSizeInBytes() - offset;
|
||||
assert(actualSize <= buf.getSizeInBytes());
|
||||
}
|
||||
|
||||
void RenderPass::bindFragment(const BufferResource& buf, std::size_t offset, std::size_t, std::size_t size) {
|
||||
[[maybe_unused]] const auto actualSize = size ? size : buf.getSizeInBytes() - offset;
|
||||
assert(actualSize <= buf.getSizeInBytes());
|
||||
}
|
||||
|
||||
} // namespace vulkan
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <mbgl/vulkan/command_encoder.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
namespace mbgl {
|
||||
namespace vulkan {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <mbgl/vulkan/context.hpp>
|
||||
#include <mbgl/vulkan/drawable.hpp>
|
||||
#include <mbgl/vulkan/render_pass.hpp>
|
||||
#include <mbgl/vulkan/command_encoder.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
@@ -15,7 +16,8 @@ namespace mbgl {
|
||||
namespace vulkan {
|
||||
|
||||
TileLayerGroup::TileLayerGroup(int32_t layerIndex_, std::size_t initialCapacity, std::string name_)
|
||||
: mbgl::TileLayerGroup(layerIndex_, initialCapacity, std::move(name_)) {}
|
||||
: mbgl::TileLayerGroup(layerIndex_, initialCapacity, std::move(name_)),
|
||||
uniformBuffers(DescriptorSetType::Layer, shaders::layerUBOStartId, shaders::maxUBOCountPerLayer) {}
|
||||
|
||||
void TileLayerGroup::upload(gfx::UploadPass& uploadPass) {
|
||||
if (!enabled || !getDrawableCount()) {
|
||||
@@ -40,6 +42,7 @@ void TileLayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) {
|
||||
}
|
||||
|
||||
auto& renderPass = static_cast<RenderPass&>(*parameters.renderPass);
|
||||
auto& encoder = renderPass.getEncoder();
|
||||
|
||||
// `stencilModeFor3D` uses a different stencil mask value each time its called, so if the
|
||||
// drawables in this layer use 3D stencil mode, we need to set it up here so that all the
|
||||
@@ -91,44 +94,23 @@ void TileLayerGroup::render(RenderOrchestrator&, PaintParameters& parameters) {
|
||||
}
|
||||
|
||||
if (!bindUBOs) {
|
||||
bindUniformBuffers(renderPass);
|
||||
uniformBuffers.bindDescriptorSets(encoder);
|
||||
bindUBOs = true;
|
||||
}
|
||||
|
||||
auto& drawableImpl = static_cast<Drawable&>(drawable);
|
||||
auto& drawableUniforms = drawable.mutableUniformBuffers();
|
||||
for (size_t id = 0; id < uniformBuffers.allocatedSize(); id++) {
|
||||
const auto& uniformBuffer = uniformBuffers.get(id);
|
||||
if (!uniformBuffer) continue;
|
||||
if (features3d) {
|
||||
auto& drawableImpl = static_cast<Drawable&>(drawable);
|
||||
|
||||
if (features3d) {
|
||||
drawableImpl.setDepthModeFor3D(drawableImpl.getEnableDepth() ? depthMode3d.value()
|
||||
: gfx::DepthMode::disabled());
|
||||
const auto& depth = drawableImpl.getEnableDepth() ? depthMode3d.value() : gfx::DepthMode::disabled();
|
||||
drawableImpl.setDepthModeFor3D(depth);
|
||||
|
||||
drawableImpl.setStencilModeFor3D(drawableImpl.getEnableStencil() ? stencilMode3d.value()
|
||||
: gfx::StencilMode::disabled());
|
||||
}
|
||||
|
||||
drawableUniforms.set(id, uniformBuffer);
|
||||
const auto& stencil = drawableImpl.getEnableStencil() ? stencilMode3d.value()
|
||||
: gfx::StencilMode::disabled();
|
||||
drawableImpl.setStencilModeFor3D(stencil);
|
||||
}
|
||||
|
||||
drawable.draw(parameters);
|
||||
});
|
||||
|
||||
if (bindUBOs) {
|
||||
unbindUniformBuffers(renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
void TileLayerGroup::bindUniformBuffers(RenderPass& renderPass) const noexcept {
|
||||
for (size_t id = 0; id < uniformBuffers.allocatedSize(); id++) {
|
||||
const auto& uniformBuffer = uniformBuffers.get(id);
|
||||
if (!uniformBuffer) continue;
|
||||
const auto& buffer = static_cast<UniformBuffer&>(*uniformBuffer);
|
||||
const auto& resource = buffer.getBufferResource();
|
||||
renderPass.bindVertex(resource, 0, id);
|
||||
renderPass.bindFragment(resource, 0, id);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vulkan
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/vulkan/context.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/vulkan/command_encoder.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@@ -38,5 +39,34 @@ void UniformBuffer::update(const void* data, std::size_t size_) {
|
||||
buffer.update(data, size, /*offset=*/0);
|
||||
}
|
||||
|
||||
const std::shared_ptr<gfx::UniformBuffer>& UniformBufferArray::set(const size_t id,
|
||||
std::shared_ptr<gfx::UniformBuffer> uniformBuffer) {
|
||||
if (descriptorSet) {
|
||||
descriptorSet->markDirty();
|
||||
}
|
||||
|
||||
return gfx::UniformBufferArray::set(id, uniformBuffer);
|
||||
}
|
||||
|
||||
void UniformBufferArray::createOrUpdate(
|
||||
const size_t id, const void* data, std::size_t size, gfx::Context& context, bool persistent) {
|
||||
if (descriptorSet) {
|
||||
if (auto& ubo = get(id); !ubo || ubo->getSize() != size) {
|
||||
descriptorSet->markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
gfx::UniformBufferArray::createOrUpdate(id, data, size, context, persistent);
|
||||
}
|
||||
|
||||
void UniformBufferArray::bindDescriptorSets(CommandEncoder& encoder) {
|
||||
if (!descriptorSet) {
|
||||
descriptorSet = std::make_unique<UniformDescriptorSet>(encoder.getContext(), descriptorSetType);
|
||||
}
|
||||
|
||||
descriptorSet->update(*this, descriptorStartIndex, descriptorBindingCount);
|
||||
descriptorSet->bind(encoder);
|
||||
}
|
||||
|
||||
} // namespace vulkan
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user