Replace macro with run-time string concatenation (#3124)

This commit is contained in:
Alex Cristici
2025-01-10 16:41:58 +02:00
committed by GitHub
parent 57f42d9230
commit 9f02e29f5f
17 changed files with 106 additions and 85 deletions

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define BACKGROUND_SHADER_COMMON \
R"(
constexpr auto backgroundShaderPrelude = R"(
enum {
idBackgroundDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -72,7 +71,7 @@ union BackgroundDrawableUnionUBO {
BackgroundPatternDrawableUBO backgroundPatternDrawableUBO;
};
)"
)";
template <>
struct ShaderSource<BuiltIn::BackgroundShader, gfx::Backend::Type::Metal> {
@@ -84,9 +83,8 @@ struct ShaderSource<BuiltIn::BackgroundShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = BACKGROUND_SHADER_COMMON R"(
#include <metal_stdlib>
using namespace metal;
static constexpr auto prelude = backgroundShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 position [[attribute(backgroundUBOCount + 0)]];
@@ -128,9 +126,8 @@ struct ShaderSource<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::Metal>
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = BACKGROUND_SHADER_COMMON R"(
#include <metal_stdlib>
using namespace metal;
static constexpr auto prelude = backgroundShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 position [[attribute(backgroundUBOCount + 0)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define CIRCLE_SHADER_PRELUDE \
R"(
constexpr auto circleShaderPrelude = R"(
enum {
idCircleDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -51,7 +50,7 @@ struct alignas(16) CircleEvaluatedPropsUBO {
};
static_assert(sizeof(CircleEvaluatedPropsUBO) == 4 * 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Metal> {
@@ -63,7 +62,9 @@ struct ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = CIRCLE_SHADER_PRELUDE R"(
static constexpr auto prelude = circleShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 position [[attribute(circleUBOCount + 0)]];

View File

@@ -16,11 +16,7 @@ struct alignas(16) ClipUBO {
};
static_assert(sizeof(ClipUBO) == 5 * 16);
#define CLIPPING_MASK_SHADER_PRELUDE \
R"(
#include <metal_stdlib>
using namespace metal;
constexpr auto clippingMaskShaderPrelude = R"(
enum {
idClippingMaskUBO = idDrawableReservedVertexOnlyUBO,
@@ -37,7 +33,7 @@ struct alignas(16) ClipUBO {
};
static_assert(sizeof(ClipUBO) == 5 * 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::ClippingMaskProgram, gfx::Backend::Type::Metal> {
@@ -49,7 +45,9 @@ struct ShaderSource<BuiltIn::ClippingMaskProgram, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = CLIPPING_MASK_SHADER_PRELUDE R"(
static constexpr auto prelude = clippingMaskShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 position [[attribute(clippingMaskUBOCount + 0)]];
};

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define COLLISION_SHADER_COMMON \
R"(
constexpr auto collisionShaderPrelude = R"(
enum {
idCollisionDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -30,7 +29,7 @@ struct alignas(16) CollisionTilePropsUBO {
};
static_assert(sizeof(CollisionTilePropsUBO) == 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::Metal> {
@@ -42,7 +41,8 @@ struct ShaderSource<BuiltIn::CollisionBoxShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = COLLISION_SHADER_COMMON R"(
static constexpr auto prelude = collisionShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos [[attribute(collisionUBOCount + 0)]];
@@ -115,7 +115,8 @@ struct ShaderSource<BuiltIn::CollisionCircleShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = COLLISION_SHADER_COMMON R"(
static constexpr auto prelude = collisionShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos [[attribute(collisionUBOCount + 0)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define CUSTOM_SYMBOL_ICON_SHADER_PRELUDE \
R"(
constexpr auto customSymbolIconShaderPrelude = R"(
enum {
idCustomSymbolDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -31,7 +30,7 @@ struct alignas(16) CustomSymbolIconDrawableUBO {
};
static_assert(sizeof(CustomSymbolIconDrawableUBO) == 7 * 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Metal> {
@@ -43,7 +42,9 @@ struct ShaderSource<BuiltIn::CustomSymbolIconShader, gfx::Backend::Type::Metal>
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = CUSTOM_SYMBOL_ICON_SHADER_PRELUDE R"(
static constexpr auto prelude = customSymbolIconShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
float2 a_pos [[attribute(customSymbolUBOCount + 0)]];
float2 a_tex [[attribute(customSymbolUBOCount + 1)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define DEBUG_SHADER_PRELUDE \
R"(
constexpr auto debugShaderPrelude = R"(
enum {
idDebugUBO = drawableReservedUBOCount,
@@ -26,7 +25,7 @@ struct alignas(16) DebugUBO {
};
static_assert(sizeof(DebugUBO) == 6 * 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::Metal> {
@@ -38,7 +37,8 @@ struct ShaderSource<BuiltIn::DebugShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = DEBUG_SHADER_PRELUDE R"(
static constexpr auto prelude = debugShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos [[attribute(debugUBOCount + 0)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define FILL_SHADER_COMMON \
R"(
constexpr auto fillShaderPrelude = R"(
enum {
idFillDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -139,7 +138,7 @@ union FillTilePropsUnionUBO {
FillOutlinePatternTilePropsUBO fillOutlinePatternTilePropsUBO;
};
)"
)";
template <>
struct ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::Metal> {
@@ -151,7 +150,8 @@ struct ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = FILL_SHADER_COMMON R"(
static constexpr auto prelude = fillShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 position [[attribute(fillUBOCount + 0)]];
@@ -225,7 +225,9 @@ struct ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = FILL_SHADER_COMMON R"(
static constexpr auto prelude = fillShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 position [[attribute(fillUBOCount + 0)]];
float4 outline_color [[attribute(fillUBOCount + 1)]];
@@ -302,7 +304,9 @@ struct ShaderSource<BuiltIn::FillPatternShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = FILL_SHADER_COMMON R"(
static constexpr auto prelude = fillShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 position [[attribute(fillUBOCount + 0)]];
@@ -443,7 +447,8 @@ struct ShaderSource<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::Metal
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = FILL_SHADER_COMMON R"(
static constexpr auto prelude = fillShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 position [[attribute(fillUBOCount + 0)]];
@@ -597,7 +602,9 @@ struct ShaderSource<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = FILL_SHADER_COMMON R"(
static constexpr auto prelude = fillShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos_normal [[attribute(fillUBOCount + 0)]];
uchar4 data [[attribute(fillUBOCount + 1)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define FILL_EXTRUSION_SHADER_COMMON \
R"(
constexpr auto fillExtrusionShaderPrelude = R"(
enum {
idFillExtrusionDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -62,7 +61,7 @@ struct alignas(16) FillExtrusionPropsUBO {
};
static_assert(sizeof(FillExtrusionPropsUBO) == 5 * 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Metal> {
@@ -74,7 +73,9 @@ struct ShaderSource<BuiltIn::FillExtrusionShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = FILL_EXTRUSION_SHADER_COMMON R"(
static constexpr auto prelude = fillExtrusionShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos [[attribute(fillExtrusionUBOCount + 0)]];
short4 normal_ed [[attribute(fillExtrusionUBOCount + 1)]];
@@ -193,7 +194,9 @@ struct ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::Met
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = FILL_EXTRUSION_SHADER_COMMON R"(
static constexpr auto prelude = fillExtrusionShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos [[attribute(fillExtrusionUBOCount + 0)]];
short4 normal_ed [[attribute(fillExtrusionUBOCount + 1)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define HEATMAP_SHADER_PRELUDE \
R"(
constexpr auto heatmapShaderPrelude = R"(
enum {
idHeatmapDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -38,7 +37,7 @@ struct alignas(16) HeatmapEvaluatedPropsUBO {
};
static_assert(sizeof(HeatmapEvaluatedPropsUBO) == 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Metal> {
@@ -50,7 +49,8 @@ struct ShaderSource<BuiltIn::HeatmapShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = HEATMAP_SHADER_PRELUDE R"(
static constexpr auto prelude = heatmapShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos [[attribute(heatmapUBOCount + 0)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define HEATMAP_TEXTURE_SHADER_PRELUDE \
R"(
constexpr auto heatmapTextureShaderPrelude = R"(
enum {
idHeatmapTexturePropsUBO = drawableReservedUBOCount,
@@ -25,7 +24,7 @@ struct alignas(16) HeatmapTexturePropsUBO {
};
static_assert(sizeof(HeatmapTexturePropsUBO) == 5 * 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Metal> {
@@ -37,7 +36,8 @@ struct ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 2> textures;
static constexpr auto source = HEATMAP_TEXTURE_SHADER_PRELUDE R"(
static constexpr auto prelude = heatmapTextureShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos [[attribute(heatmapTextureUBOCount + 0)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define HILLSHADE_SHADER_PRELUDE \
R"(
constexpr auto hillshadeShaderPrelude = R"(
enum {
idHillshadeDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -39,7 +38,7 @@ struct alignas(16) HillshadeEvaluatedPropsUBO {
};
static_assert(sizeof(HillshadeEvaluatedPropsUBO) == 3 * 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::HillshadeShader, gfx::Backend::Type::Metal> {
@@ -51,7 +50,8 @@ struct ShaderSource<BuiltIn::HillshadeShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = HILLSHADE_SHADER_PRELUDE R"(
static constexpr auto prelude = hillshadeShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos [[attribute(hillshadeUBOCount + 0)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define HILLSHADE_PREPARE_SHADER_PRELUDE \
R"(
constexpr auto hillshadePrepareShaderPrelude = R"(
enum {
idHillshadePrepareDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -31,7 +30,7 @@ struct alignas(16) HillshadePrepareTilePropsUBO {
};
static_assert(sizeof(HillshadePrepareTilePropsUBO) == 2 * 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::Metal> {
@@ -43,7 +42,9 @@ struct ShaderSource<BuiltIn::HillshadePrepareShader, gfx::Backend::Type::Metal>
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = HILLSHADE_PREPARE_SHADER_PRELUDE R"(
static constexpr auto prelude = hillshadePrepareShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos [[attribute(hillshadePrepareUBOCount + 0)]];
short2 texture_pos [[attribute(hillshadePrepareUBOCount + 1)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define LINE_SHADER_COMMON \
R"(
constexpr auto lineShadePrelude = R"(
enum {
idLineDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -171,7 +170,7 @@ union LineTilePropsUnionUBO {
LineSDFTilePropsUBO lineSDFTilePropsUBO;
};
)"
)";
template <>
struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal> {
@@ -183,7 +182,9 @@ struct ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = LINE_SHADER_COMMON R"(
static constexpr auto prelude = lineShadePrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos_normal [[attribute(lineUBOCount + 0)]];
uchar4 data [[attribute(lineUBOCount + 1)]];
@@ -361,7 +362,9 @@ struct ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = LINE_SHADER_COMMON R"(
static constexpr auto prelude = lineShadePrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos_normal [[attribute(lineUBOCount + 0)]];
uchar4 data [[attribute(lineUBOCount + 1)]];
@@ -526,7 +529,9 @@ struct ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = LINE_SHADER_COMMON R"(
static constexpr auto prelude = lineShadePrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos_normal [[attribute(lineUBOCount + 0)]];
uchar4 data [[attribute(lineUBOCount + 1)]];
@@ -761,7 +766,9 @@ struct ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = LINE_SHADER_COMMON R"(
static constexpr auto prelude = lineShadePrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos_normal [[attribute(lineUBOCount + 0)]];
uchar4 data [[attribute(lineUBOCount + 1)]];

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define RASTER_SHADER_PRELUDE \
R"(
constexpr auto rasterShaderPrelude = R"(
enum {
idRasterDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -40,7 +39,7 @@ struct alignas(16) RasterEvaluatedPropsUBO {
};
static_assert(sizeof(RasterEvaluatedPropsUBO) == 4 * 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::RasterShader, gfx::Backend::Type::Metal> {
@@ -52,7 +51,8 @@ struct ShaderSource<BuiltIn::RasterShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 2> textures;
static constexpr auto source = RASTER_SHADER_PRELUDE R"(
static constexpr auto prelude = rasterShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
short2 pos [[attribute(rasterUBOCount + 0)]];

View File

@@ -48,6 +48,7 @@ public:
std::string_view /*firstAttribName*/) override {
using ShaderSource = shaders::ShaderSource<ShaderID, gfx::Backend::Type::Metal>;
constexpr auto& name = ShaderSource::name;
constexpr auto& prelude = ShaderSource::prelude;
constexpr auto& source = ShaderSource::source;
constexpr auto& vertMain = ShaderSource::vertexMainFunction;
constexpr auto& fragMain = ShaderSource::fragmentMainFunction;
@@ -63,7 +64,7 @@ public:
addAdditionalDefines(propertiesAsUniforms, additionalDefines);
auto& context = static_cast<Context&>(gfxContext);
const auto shaderSource = std::string(shaders::prelude) + source;
const auto shaderSource = std::string(shaders::prelude) + prelude + source;
shader = context.createProgram(
ShaderID, shaderName, shaderSource, vertMain, fragMain, programParameters, additionalDefines);
assert(shader);

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define SYMBOL_SHADER_COMMON \
R"(
constexpr auto symbolShaderPrelude = R"(
enum {
idSymbolDrawableUBO = idDrawableReservedVertexOnlyUBO,
@@ -71,7 +70,7 @@ struct alignas(16) SymbolEvaluatedPropsUBO {
};
static_assert(sizeof(SymbolEvaluatedPropsUBO) == 6 * 16, "wrong size");
)"
)";
template <>
struct ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::Metal> {
@@ -83,7 +82,9 @@ struct ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = SYMBOL_SHADER_COMMON R"(
static constexpr auto prelude = symbolShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
float4 pos_offset [[attribute(symbolUBOCount + 0)]];
float4 data [[attribute(symbolUBOCount + 1)]];
@@ -219,7 +220,9 @@ struct ShaderSource<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::Metal> {
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto source = SYMBOL_SHADER_COMMON R"(
static constexpr auto prelude = symbolShaderPrelude;
static constexpr auto source = R"(
struct VertexStage {
float4 pos_offset [[attribute(symbolUBOCount + 0)]];
float4 data [[attribute(symbolUBOCount + 1)]];
@@ -426,7 +429,9 @@ struct ShaderSource<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::Metal>
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 2> textures;
static constexpr auto source = SYMBOL_SHADER_COMMON R"(
static constexpr auto prelude = symbolShaderPrelude;
static constexpr auto source = R"(
#define SDF 1.0
#define ICON 0.0

View File

@@ -7,8 +7,7 @@
namespace mbgl {
namespace shaders {
#define WIDEVECTOR_SHADER_PRELUDE \
R"(
constexpr auto wideVectorShaderPrelude = R"(
enum {
idWideVectorUniformsUBO = idDrawableReservedVertexOnlyUBO,
@@ -16,7 +15,7 @@ enum {
wideVectorUBOCount
};
)"
)";
template <>
struct ShaderSource<BuiltIn::WideVectorShader, gfx::Backend::Type::Metal> {
@@ -28,8 +27,8 @@ struct ShaderSource<BuiltIn::WideVectorShader, gfx::Backend::Type::Metal> {
static const std::array<AttributeInfo, 4> instanceAttributes;
static const std::array<TextureInfo, 0> textures;
static constexpr auto source = WIDEVECTOR_SHADER_PRELUDE R"(
#include <metal_stdlib>
static constexpr auto prelude = wideVectorShaderPrelude;
static constexpr auto source = R"(
namespace WhirlyKitShader
{