#pragma once #include #include #include #include namespace mbgl { namespace shaders { template <> struct ShaderSource { static constexpr auto name = "BackgroundShader"; static constexpr auto vertexMainFunction = "vertexMain"; static constexpr auto fragmentMainFunction = "fragmentMain"; static const std::array uniforms; static const std::array attributes; static constexpr std::array instanceAttributes{}; static const std::array textures; static constexpr auto source = R"( #include using namespace metal; struct VertexStage { short2 position [[attribute(3)]]; }; struct FragmentStage { float4 position [[position, invariant]]; }; struct alignas(16) BackgroundDrawableUBO { float4x4 matrix; }; struct alignas(16) BackgroundLayerUBO { float4 color; float opacity; float pad1, pad2, pad3; }; FragmentStage vertex vertexMain(VertexStage in [[stage_in]], device const BackgroundDrawableUBO& drawableUBO [[buffer(1)]]) { return { .position = drawableUBO.matrix * float4(float2(in.position.xy), 0, 1) }; } half4 fragment fragmentMain(FragmentStage in [[stage_in]], device const BackgroundLayerUBO& layerUBO [[buffer(2)]]) { #if defined(OVERDRAW_INSPECTOR) return half4(1.0); #endif return half4(layerUBO.color * layerUBO.opacity); } )"; }; } // namespace shaders } // namespace mbgl