266 {
267 id<MTLLibrary> vsLibrary =
std::get<0>(vertexMain);
268 id<MTLLibrary> fsLibrary =
std::get<0>(fragmentMain);
269 if (!vsLibrary || !fsLibrary) {
270 return nullptr;
271 }
272
273 sk_cfp<MTLRenderPipelineDescriptor*> psoDescriptor([[MTLRenderPipelineDescriptor alloc]
init]);
274
275 NSString* labelName = [NSString stringWithUTF8String: label.c_str()];
276 NSString* vsFuncName = [NSString stringWithUTF8String:
std::get<1>(vertexMain).c_str()];
277 NSString* fsFuncName = [NSString stringWithUTF8String:
std::get<1>(fragmentMain).c_str()];
278
279 (*psoDescriptor).label = labelName;
280 (*psoDescriptor).vertexFunction = [vsLibrary newFunctionWithName: vsFuncName];
281 (*psoDescriptor).fragmentFunction = [fsLibrary newFunctionWithName: fsFuncName];
282
283
285
286 const MtlTextureSpec& mtlColorSpec =
287 renderPassDesc.fColorAttachment.fTextureInfo.mtlTextureSpec();
289 blendInfo);
290 (*psoDescriptor).colorAttachments[0] = mtlColorAttachment;
291
292 (*psoDescriptor).rasterSampleCount =
293 renderPassDesc.fColorAttachment.fTextureInfo.numSamples();
294
295 const MtlTextureSpec& mtlDSSpec =
296 renderPassDesc.fDepthStencilAttachment.fTextureInfo.mtlTextureSpec();
297 MTLPixelFormat depthStencilFormat = (MTLPixelFormat)mtlDSSpec.fFormat;
299 (*psoDescriptor).stencilAttachmentPixelFormat = depthStencilFormat;
300 } else {
301 (*psoDescriptor).stencilAttachmentPixelFormat = MTLPixelFormatInvalid;
302 }
304 (*psoDescriptor).depthAttachmentPixelFormat = depthStencilFormat;
305 } else {
306 (*psoDescriptor).depthAttachmentPixelFormat = MTLPixelFormatInvalid;
307 }
308
310 sk_cfp<id<MTLRenderPipelineState>> pso(
311 [
sharedContext->device() newRenderPipelineStateWithDescriptor:psoDescriptor.get()
313 if (!pso) {
314 SKGPU_LOG_E(
"Render pipeline creation failure:\n%s",
error.debugDescription.UTF8String);
315 return nullptr;
316 }
317
319 pipelineInfo,
320 std::move(pso),
321 std::move(dss),
322 stencilRefValue));
323}
static MTLRenderPipelineColorAttachmentDescriptor * create_color_attachment(MTLPixelFormat format, const GrPipeline &pipeline, SkBinaryWriteBuffer *writer)
static MTLVertexDescriptor * create_vertex_descriptor(const GrGeometryProcessor &geomProc, SkBinaryWriteBuffer *writer)
#define SKGPU_LOG_E(fmt,...)
const SharedContext * sharedContext() const
const uint8_t uint32_t uint32_t GError ** error
const myers::Point & get< 1 >(const myers::Segment &s)
const myers::Point & get< 0 >(const myers::Segment &s)
bool MtlFormatIsStencil(MTLPixelFormat format)
bool MtlFormatIsDepth(MTLPixelFormat format)