Files
MapLibreParticleLab/include/mbgl/shaders/mtl/retained_underlay_composite.hpp
tei 8b9ab30322
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
feat: add retained underlay render cache poc
2026-09-21 22:53:00 +09:00

35 lines
1.3 KiB
C++

#pragma once
#include <mbgl/shaders/shader_source.hpp>
#include <mbgl/shaders/mtl/shader_program.hpp>
namespace mbgl::shaders {
template <>
struct ShaderSource<BuiltIn::RetainedUnderlayCompositeShader, gfx::Backend::Type::Metal> {
static constexpr auto name = "RetainedUnderlayCompositeShader";
static constexpr auto vertexMainFunction = "vertexMain";
static constexpr auto fragmentMainFunction = "fragmentMain";
static const std::array<AttributeInfo, 1> attributes;
static constexpr std::array<AttributeInfo, 0> instanceAttributes{};
static const std::array<TextureInfo, 1> textures;
static constexpr auto prelude = R"()";
static constexpr auto source = R"(
struct VertexStage { short2 pos [[attribute(0)]]; };
struct FragmentStage { float4 position [[position, invariant]]; float2 uv; };
FragmentStage vertex vertexMain(thread const VertexStage in [[stage_in]]) {
const float2 p = float2(in.pos);
return { .position = float4(p.x * 2.0 - 1.0, 1.0 - p.y * 2.0, 0.0, 1.0), .uv = p };
}
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
texture2d<float, access::sample> image [[texture(0)]],
sampler imageSampler [[sampler(0)]]) {
return half4(image.sample(imageSampler, in.uv));
}
)";
};
} // namespace mbgl::shaders