Metal setup merge (#1616)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Alex Cristici <alex.cristici@gmail.com> Co-authored-by: mwilsnd <mwilsnd@gmail.com> Co-authored-by: Stefan Karschti <stefan.karschti@gmail.com> Co-authored-by: Bart Louwers <bart@emeel.net> Co-authored-by: Alex Cristici <alex@skoon.energy> Co-authored-by: Bart Louwers <bart.louwers@gmail.com> Co-authored-by: Wei Chen <alanchenboy@gmail.com> Co-authored-by: Siarhei Fedartsou <siarhei.fedartsou@gmail.com> Co-authored-by: tdcosta100 <tdcosta100@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <mbgl/renderer/layer_group.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
#include <mbgl/renderer/pattern_atlas.hpp>
|
||||
#include <mbgl/shaders/background_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/shader_program_base.hpp>
|
||||
#include <mbgl/style/layers/background_layer_properties.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
@@ -12,45 +13,9 @@
|
||||
namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
using namespace shaders;
|
||||
|
||||
struct alignas(16) BackgroundDrawableUBO {
|
||||
std::array<float, 4 * 4> matrix;
|
||||
};
|
||||
static_assert(sizeof(BackgroundDrawableUBO) % 16 == 0);
|
||||
|
||||
struct alignas(16) BackgroundLayerUBO {
|
||||
/* 0 */ Color color;
|
||||
/* 16 */ float opacity;
|
||||
/* 20 */ float pad1, pad2, pad3;
|
||||
/* 32 */
|
||||
};
|
||||
static_assert(sizeof(BackgroundLayerUBO) == 32);
|
||||
|
||||
struct alignas(16) BackgroundPatternLayerUBO {
|
||||
/* 0 */ std::array<float, 2> pattern_tl_a;
|
||||
/* 8 */ std::array<float, 2> pattern_br_a;
|
||||
/* 16 */ std::array<float, 2> pattern_tl_b;
|
||||
/* 24 */ std::array<float, 2> pattern_br_b;
|
||||
/* 32 */ std::array<float, 2> texsize;
|
||||
/* 40 */ std::array<float, 2> pattern_size_a;
|
||||
/* 48 */ std::array<float, 2> pattern_size_b;
|
||||
/* 56 */ std::array<float, 2> pixel_coord_upper;
|
||||
/* 64 */ std::array<float, 2> pixel_coord_lower;
|
||||
/* 72 */ float tile_units_to_pixels;
|
||||
/* 76 */ float scale_a;
|
||||
/* 80 */ float scale_b;
|
||||
/* 84 */ float mix;
|
||||
/* 88 */ float opacity;
|
||||
/* 92 */ float pad;
|
||||
/* 96 */
|
||||
};
|
||||
static_assert(sizeof(BackgroundPatternLayerUBO) == 96);
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
static constexpr auto BackgroundPatternShaderName = "BackgroundPatternShader";
|
||||
#endif
|
||||
static constexpr auto BackgroundDrawableUBOName = "BackgroundDrawableUBO";
|
||||
static constexpr auto BackgroundLayerUBOName = "BackgroundLayerUBO";
|
||||
static constexpr auto texUniformName = "u_image";
|
||||
|
||||
void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTree&, const PaintParameters& parameters) {
|
||||
@@ -96,7 +61,7 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTre
|
||||
const BackgroundDrawableUBO drawableUBO = {/* .matrix = */ util::cast<float>(matrix)};
|
||||
|
||||
auto& uniforms = drawable.mutableUniformBuffers();
|
||||
uniforms.createOrUpdate(BackgroundDrawableUBOName, &drawableUBO, context);
|
||||
uniforms.createOrUpdate("BackgroundDrawableUBO", &drawableUBO, context);
|
||||
|
||||
if (hasPattern) {
|
||||
if (!samplerLocation.has_value()) {
|
||||
@@ -138,7 +103,7 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTre
|
||||
/* .opacity = */ evaluated.get<BackgroundOpacity>(),
|
||||
/* .pad = */ 0,
|
||||
};
|
||||
uniforms.createOrUpdate(BackgroundLayerUBOName, &layerUBO, context);
|
||||
uniforms.createOrUpdate("BackgroundLayerUBO", &layerUBO, context);
|
||||
} else {
|
||||
// UBOs can be shared
|
||||
if (!backgroundLayerBuffer) {
|
||||
@@ -149,7 +114,7 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTre
|
||||
0};
|
||||
backgroundLayerBuffer = context.createUniformBuffer(&layerUBO, sizeof(layerUBO));
|
||||
}
|
||||
uniforms.addOrReplace(BackgroundLayerUBOName, backgroundLayerBuffer);
|
||||
uniforms.addOrReplace("BackgroundLayerUBO", backgroundLayerBuffer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user