54 {
55 uint64_t renderPassKey =
58 if (!pipeline) {
59 static const char* kLoadMSAAShaderText = R"(
60 #include <metal_stdlib>
61 #include <simd/simd.h>
62 using namespace metal;
63
64 typedef struct {
65 float4 position [[position]];
66 } VertexOutput;
67
68 vertex VertexOutput vertexMain(uint vertexID [[vertex_id]]) {
69 VertexOutput out;
70 float2 position = float2(float(vertexID >> 1), float(vertexID & 1));
71 out.position = float4(2.0 * position - 1.0, 0.0, 1.0);
72 return out;
73 }
74
75 fragment float4 fragmentMain(VertexOutput in [[stage_in]],
76 texture2d<half> colorMap [[texture(0)]]) {
77 uint2 coords = uint2(in.position.x, in.position.y);
78 half4 colorSample = colorMap.read(coords);
79 return float4(colorSample);
80 }
81 )";
82
84 "LoadMSAAFromResolve",
85 kLoadMSAAShaderText,
87 BlendInfo noBlend{};
88 sk_cfp<id<MTLDepthStencilState>> ignoreDS =
89 this->findOrCreateCompatibleDepthStencilState({});
90
91 std::string pipelineLabel = "LoadMSAAFromResolve + ";
92 pipelineLabel += renderPassDesc.toString().c_str();
94 pipelineLabel,
95 {mtlLibrary.get(), "vertexMain"},
96 {},
97 {},
98 {mtlLibrary.get(), "fragmentMain"},
99 std::move(ignoreDS),
100 0,
101 noBlend,
102 renderPassDesc,
103 nullptr);
104 if (pipeline) {
105 fLoadMSAAPipelines.set(renderPassKey, pipeline);
106 }
107 }
108
skgpu::ShaderErrorHandler * shaderErrorHandler() const
uint64_t getRenderPassDescKey(const RenderPassDesc &) const
static sk_sp< MtlGraphicsPipeline > Make(const MtlSharedContext *, const std::string &label, MSLFunction vertexMain, SkSpan< const Attribute > vertexAttrs, SkSpan< const Attribute > instanceAttrs, MSLFunction fragmentMain, sk_cfp< id< MTLDepthStencilState > >, uint32_t stencilRefValue, const BlendInfo &blendInfo, const RenderPassDesc &, PipelineInfo *pipelineInfo)
const MtlCaps & mtlCaps() const
SharedContext * fSharedContext
const Caps * caps() const
sk_cfp< id< MTLLibrary > > MtlCompileShaderLibrary(const MtlSharedContext *sharedContext, std::string_view label, std::string_view msl, ShaderErrorHandler *errorHandler)