diff --git a/include/mbgl/shaders/mtl/background.hpp b/include/mbgl/shaders/mtl/background.hpp index cb683aefde7..ad414accc28 100644 --- a/include/mbgl/shaders/mtl/background.hpp +++ b/include/mbgl/shaders/mtl/background.hpp @@ -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 { @@ -84,9 +83,8 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array textures; - static constexpr auto source = BACKGROUND_SHADER_COMMON R"( -#include -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 static constexpr std::array instanceAttributes{}; static const std::array textures; - static constexpr auto source = BACKGROUND_SHADER_COMMON R"( -#include -using namespace metal; + static constexpr auto prelude = backgroundShaderPrelude; + static constexpr auto source = R"( struct VertexStage { short2 position [[attribute(backgroundUBOCount + 0)]]; diff --git a/include/mbgl/shaders/mtl/circle.hpp b/include/mbgl/shaders/mtl/circle.hpp index 2a95a763fe1..7575f39bd83 100644 --- a/include/mbgl/shaders/mtl/circle.hpp +++ b/include/mbgl/shaders/mtl/circle.hpp @@ -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 { @@ -63,7 +62,9 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/clipping_mask.hpp b/include/mbgl/shaders/mtl/clipping_mask.hpp index 580c1ad9efd..e0f5d8b6173 100644 --- a/include/mbgl/shaders/mtl/clipping_mask.hpp +++ b/include/mbgl/shaders/mtl/clipping_mask.hpp @@ -16,11 +16,7 @@ struct alignas(16) ClipUBO { }; static_assert(sizeof(ClipUBO) == 5 * 16); -#define CLIPPING_MASK_SHADER_PRELUDE \ - R"( - -#include -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 { @@ -49,7 +45,9 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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)]]; }; diff --git a/include/mbgl/shaders/mtl/collision.hpp b/include/mbgl/shaders/mtl/collision.hpp index ad62b6638af..79a21da87db 100644 --- a/include/mbgl/shaders/mtl/collision.hpp +++ b/include/mbgl/shaders/mtl/collision.hpp @@ -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 { @@ -42,7 +41,8 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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 { static constexpr std::array instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/custom_symbol_icon.hpp b/include/mbgl/shaders/mtl/custom_symbol_icon.hpp index 82581e74d37..a497f9fdaa2 100644 --- a/include/mbgl/shaders/mtl/custom_symbol_icon.hpp +++ b/include/mbgl/shaders/mtl/custom_symbol_icon.hpp @@ -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 { @@ -43,7 +42,9 @@ struct ShaderSource static constexpr std::array instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/debug.hpp b/include/mbgl/shaders/mtl/debug.hpp index 633c6a0a985..e252f38636a 100644 --- a/include/mbgl/shaders/mtl/debug.hpp +++ b/include/mbgl/shaders/mtl/debug.hpp @@ -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 { @@ -38,7 +37,8 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/fill.hpp b/include/mbgl/shaders/mtl/fill.hpp index b589a8dca4d..cc908d3d8bd 100644 --- a/include/mbgl/shaders/mtl/fill.hpp +++ b/include/mbgl/shaders/mtl/fill.hpp @@ -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 { @@ -151,7 +150,8 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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 { static constexpr std::array instanceAttributes{}; static const std::array 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 { static constexpr std::array instanceAttributes{}; static const std::array 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 instanceAttributes{}; static const std::array 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 instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/fill_extrusion.hpp b/include/mbgl/shaders/mtl/fill_extrusion.hpp index 4a5e05663f3..0ac9350ebd4 100644 --- a/include/mbgl/shaders/mtl/fill_extrusion.hpp +++ b/include/mbgl/shaders/mtl/fill_extrusion.hpp @@ -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 { @@ -74,7 +73,9 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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 instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/heatmap.hpp b/include/mbgl/shaders/mtl/heatmap.hpp index 81e4c25e4ba..ead80d8ab33 100644 --- a/include/mbgl/shaders/mtl/heatmap.hpp +++ b/include/mbgl/shaders/mtl/heatmap.hpp @@ -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 { @@ -50,7 +49,8 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/heatmap_texture.hpp b/include/mbgl/shaders/mtl/heatmap_texture.hpp index e32b2fdb53d..767b77847ed 100644 --- a/include/mbgl/shaders/mtl/heatmap_texture.hpp +++ b/include/mbgl/shaders/mtl/heatmap_texture.hpp @@ -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 { @@ -37,7 +36,8 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/hillshade.hpp b/include/mbgl/shaders/mtl/hillshade.hpp index 39e5c74135e..f51f4b7a7ad 100644 --- a/include/mbgl/shaders/mtl/hillshade.hpp +++ b/include/mbgl/shaders/mtl/hillshade.hpp @@ -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 { @@ -51,7 +50,8 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/hillshade_prepare.hpp b/include/mbgl/shaders/mtl/hillshade_prepare.hpp index 8b3770b4d61..6d7ddcf01a7 100644 --- a/include/mbgl/shaders/mtl/hillshade_prepare.hpp +++ b/include/mbgl/shaders/mtl/hillshade_prepare.hpp @@ -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 { @@ -43,7 +42,9 @@ struct ShaderSource static constexpr std::array instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/line.hpp b/include/mbgl/shaders/mtl/line.hpp index b95c3d0c666..5ca7dcb78dc 100644 --- a/include/mbgl/shaders/mtl/line.hpp +++ b/include/mbgl/shaders/mtl/line.hpp @@ -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 { @@ -183,7 +182,9 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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 { static constexpr std::array instanceAttributes{}; static const std::array 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 { static constexpr std::array instanceAttributes{}; static const std::array 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 { static constexpr std::array instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/raster.hpp b/include/mbgl/shaders/mtl/raster.hpp index 22b1e995512..399d0ca0b46 100644 --- a/include/mbgl/shaders/mtl/raster.hpp +++ b/include/mbgl/shaders/mtl/raster.hpp @@ -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 { @@ -52,7 +51,8 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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)]]; diff --git a/include/mbgl/shaders/mtl/shader_group.hpp b/include/mbgl/shaders/mtl/shader_group.hpp index 111332a0ca3..4688592070f 100644 --- a/include/mbgl/shaders/mtl/shader_group.hpp +++ b/include/mbgl/shaders/mtl/shader_group.hpp @@ -48,6 +48,7 @@ class ShaderGroup final : public ShaderGroupBase { std::string_view /*firstAttribName*/) override { using ShaderSource = shaders::ShaderSource; 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,8 @@ class ShaderGroup final : public ShaderGroupBase { addAdditionalDefines(propertiesAsUniforms, additionalDefines); auto& context = static_cast(gfxContext); - const auto shaderSource = std::string(shaders::prelude) + source; + // C++26 will allow operator+ with std::string and std::string_view + const auto shaderSource = std::string(shaders::prelude) + std::string(prelude) + std::string(source); shader = context.createProgram( ShaderID, shaderName, shaderSource, vertMain, fragMain, programParameters, additionalDefines); assert(shader); diff --git a/include/mbgl/shaders/mtl/symbol.hpp b/include/mbgl/shaders/mtl/symbol.hpp index e3e9bcf9158..df3e754dc65 100644 --- a/include/mbgl/shaders/mtl/symbol.hpp +++ b/include/mbgl/shaders/mtl/symbol.hpp @@ -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 { @@ -83,7 +82,9 @@ struct ShaderSource { static constexpr std::array instanceAttributes{}; static const std::array 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 { static constexpr std::array instanceAttributes{}; static const std::array 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 static constexpr std::array instanceAttributes{}; static const std::array 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 diff --git a/include/mbgl/shaders/mtl/widevector.hpp b/include/mbgl/shaders/mtl/widevector.hpp index ba18276c5c6..f312d2dc602 100644 --- a/include/mbgl/shaders/mtl/widevector.hpp +++ b/include/mbgl/shaders/mtl/widevector.hpp @@ -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 { @@ -28,8 +27,8 @@ struct ShaderSource { static const std::array instanceAttributes; static const std::array textures; - static constexpr auto source = WIDEVECTOR_SHADER_PRELUDE R"( -#include + static constexpr auto prelude = wideVectorShaderPrelude; + static constexpr auto source = R"( namespace WhirlyKitShader {