Flutter Engine
The Flutter Engine
Static Public Member Functions | List of all members
GrMtlPipelineStateBuilder Class Reference

#include <GrMtlPipelineStateBuilder.h>

Inheritance diagram for GrMtlPipelineStateBuilder:
GrGLSLProgramBuilder

Static Public Member Functions

static GrMtlPipelineStateCreatePipelineState (GrMtlGpu *, const GrProgramDesc &, const GrProgramInfo &, const GrMtlPrecompiledLibraries *precompiledLibs=nullptr)
 
static bool PrecompileShaders (GrMtlGpu *, const SkData &, GrMtlPrecompiledLibraries *precompiledLibs)
 

Additional Inherited Members

- Public Types inherited from GrGLSLProgramBuilder
using UniformHandle = GrGLSLUniformHandler::UniformHandle
 
using SamplerHandle = GrGLSLUniformHandler::SamplerHandle
 
- Public Member Functions inherited from GrGLSLProgramBuilder
virtual ~GrGLSLProgramBuilder ()
 
virtual const GrCapscaps () const =0
 
const GrShaderCapsshaderCaps () const
 
GrSurfaceOrigin origin () const
 
const GrPipelinepipeline () const
 
const GrGeometryProcessorgeometryProcessor () const
 
bool snapVerticesToPixelCenters () const
 
bool hasPointSize () const
 
const GrProgramDescdesc () const
 
void appendUniformDecls (GrShaderFlags visibility, SkString *) const
 
const char * samplerVariable (SamplerHandle handle) const
 
skgpu::Swizzle samplerSwizzle (SamplerHandle handle) const
 
const char * inputSamplerVariable (SamplerHandle handle) const
 
skgpu::Swizzle inputSamplerSwizzle (SamplerHandle handle) const
 
void addRTFlipUniform (const char *name)
 
SkString nameVariable (char prefix, const char *name, bool mangle=true)
 
bool emitTextureSamplersForFPs (const GrFragmentProcessor &fp, GrFragmentProcessor::ProgramImpl &impl, int *samplerIndex)
 
void advanceStage ()
 
void writeFPFunction (const GrFragmentProcessor &fp, GrFragmentProcessor::ProgramImpl &impl)
 
std::string invokeFP (const GrFragmentProcessor &fp, const GrFragmentProcessor::ProgramImpl &impl, const char *inputColor, const char *destColor, const char *coords) const
 
bool fragmentProcessorHasCoordsParam (const GrFragmentProcessor *) const
 
virtual GrGLSLUniformHandleruniformHandler ()=0
 
virtual const GrGLSLUniformHandleruniformHandler () const =0
 
virtual GrGLSLVaryingHandlervaryingHandler ()=0
 
virtual void finalizeFragmentSecondaryColor (GrShaderVar &outputColor)
 
- Public Attributes inherited from GrGLSLProgramBuilder
GrGLSLVertexBuilder fVS
 
GrGLSLFragmentShaderBuilder fFS
 
const GrProgramDescfDesc
 
const GrProgramInfofProgramInfo
 
GrGLSLBuiltinUniformHandles fUniformHandles
 
std::unique_ptr< GrGeometryProcessor::ProgramImplfGPImpl
 
std::unique_ptr< GrXferProcessor::ProgramImplfXPImpl
 
std::vector< std::unique_ptr< GrFragmentProcessor::ProgramImpl > > fFPImpls
 
SamplerHandle fDstTextureSamplerHandle
 
GrSurfaceOrigin fDstTextureOrigin
 
- Static Public Attributes inherited from GrGLSLProgramBuilder
static const int kVarsPerBlock = 8
 
- Protected Member Functions inherited from GrGLSLProgramBuilder
 GrGLSLProgramBuilder (const GrProgramDesc &, const GrProgramInfo &)
 
void addFeature (GrShaderFlags shaders, uint32_t featureBit, const char *extensionName)
 
bool emitAndInstallProcs ()
 
void finalizeShaders ()
 
bool fragColorIsInOut () const
 

Detailed Description

Definition at line 36 of file GrMtlPipelineStateBuilder.h.

Member Function Documentation

◆ CreatePipelineState()

GR_NORETAIN_BEGIN GrMtlPipelineState * GrMtlPipelineStateBuilder::CreatePipelineState ( GrMtlGpu gpu,
const GrProgramDesc desc,
const GrProgramInfo programInfo,
const GrMtlPrecompiledLibraries precompiledLibs = nullptr 
)
static

Generates a pipeline state.

The returned GrMtlPipelineState implements the supplied GrProgramInfo.

Returns
the created pipeline if generation was successful; nullptr otherwise

Definition at line 36 of file GrMtlPipelineStateBuilder.mm.

38 {
39 GrAutoLocaleSetter als("C");
40 GrMtlPipelineStateBuilder builder(gpu, desc, programInfo);
41
42 if (!builder.emitAndInstallProcs()) {
43 return nullptr;
44 }
45 return builder.finalize(desc, programInfo, precompiledLibs);
46}
const GrProgramDesc & desc() const

◆ PrecompileShaders()

bool GrMtlPipelineStateBuilder::PrecompileShaders ( GrMtlGpu gpu,
const SkData cachedData,
GrMtlPrecompiledLibraries precompiledLibs 
)
static

Definition at line 710 of file GrMtlPipelineStateBuilder.mm.

711 {
712 SkASSERT(precompiledLibs);
713
714 SkReadBuffer reader(cachedData.data(), cachedData.size());
716
717 auto errorHandler = gpu->getContext()->priv().getShaderErrorHandler();
718
720 settings.fSharpenTextures = true;
722 meta.fSettings = &settings;
723
724 std::string shaders[kGrShaderTypeCount];
727 &reader, shaders, interfaces, kGrShaderTypeCount, &meta)) {
728 return false;
729 }
730
731 // skip the size
732 reader.readUInt();
733 auto pipelineDescriptor = read_pipeline_data(&reader);
734 if (!reader.isValid()) {
735 return false;
736 }
737
738 switch (shaderType) {
739 case kMSL_Tag: {
740 precompiledLibs->fVertexLibrary =
741 GrCompileMtlShaderLibrary(gpu, shaders[kVertex_GrShaderType], errorHandler);
742 precompiledLibs->fFragmentLibrary =
743 GrCompileMtlShaderLibrary(gpu, shaders[kFragment_GrShaderType], errorHandler);
744 break;
745 }
746
747 case kSKSL_Tag: {
748 std::string msl[kGrShaderTypeCount];
749 if (!skgpu::SkSLToMSL(gpu->caps()->shaderCaps(),
750 shaders[kVertex_GrShaderType],
752 settings,
754 &interfaces[kVertex_GrShaderType],
755 errorHandler)) {
756 return false;
757 }
758 if (!skgpu::SkSLToMSL(gpu->caps()->shaderCaps(),
759 shaders[kFragment_GrShaderType],
761 settings,
763 &interfaces[kFragment_GrShaderType],
764 errorHandler)) {
765 return false;
766 }
767 precompiledLibs->fVertexLibrary =
768 GrCompileMtlShaderLibrary(gpu, msl[kVertex_GrShaderType], errorHandler);
769 precompiledLibs->fFragmentLibrary =
770 GrCompileMtlShaderLibrary(gpu, msl[kFragment_GrShaderType], errorHandler);
771 break;
772 }
773
774 default: {
775 return false;
776 }
777 }
778
779 pipelineDescriptor.vertexFunction =
780 [precompiledLibs->fVertexLibrary newFunctionWithName: @"vertexMain"];
781 pipelineDescriptor.fragmentFunction =
782 [precompiledLibs->fFragmentLibrary newFunctionWithName: @"fragmentMain"];
783
784 {
785 TRACE_EVENT0("skia.shaders", "newRenderPipelineStateWithDescriptor");
786 MTLNewRenderPipelineStateCompletionHandler completionHandler =
787 ^(id<MTLRenderPipelineState> state, NSError* error) {
788 if (error) {
789 SkDebugf("Error creating pipeline: %s\n",
790 [[error localizedDescription]
791 cStringUsingEncoding: NSASCIIStringEncoding]);
792 }
793 };
794
795 // kick off asynchronous pipeline build and depend on Apple's cache to manage it
796 [gpu->device() newRenderPipelineStateWithDescriptor: pipelineDescriptor
797 completionHandler: completionHandler];
798 }
799
800 precompiledLibs->fRTFlip = (interfaces[kFragment_GrShaderType].fRTFlipUniform !=
802 return true;
803}
static MTLRenderPipelineDescriptor * read_pipeline_data(SkReadBuffer *reader)
static constexpr SkFourByteTag kMSL_Tag
static constexpr SkFourByteTag kSKSL_Tag
id< MTLLibrary > GrCompileMtlShaderLibrary(const GrMtlGpu *gpu, const std::string &msl, GrContextOptions::ShaderErrorHandler *errorHandler)
Definition: GrMtlUtil.mm:52
@ kFragment_GrShaderType
Definition: GrTypesPriv.h:278
@ kVertex_GrShaderType
Definition: GrTypesPriv.h:277
static const int kGrShaderTypeCount
Definition: GrTypesPriv.h:282
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
uint32_t SkFourByteTag
Definition: SkTypes.h:166
GrContextOptions::ShaderErrorHandler * getShaderErrorHandler() const
const GrShaderCaps * shaderCaps() const
Definition: GrCaps.h:63
GrDirectContextPriv priv()
const GrCaps * caps() const
Definition: GrGpu.h:73
GrDirectContext * getContext()
Definition: GrGpu.h:67
id< MTLDevice > device() const
Definition: GrMtlGpu.h:49
const void * data() const
Definition: SkData.h:37
size_t size() const
Definition: SkData.h:30
AtkStateType state
const uint8_t uint32_t uint32_t GError ** error
bool UnpackCachedShaders(SkReadBuffer *reader, std::string shaders[], SkSL::Program::Interface interfaces[], int numInterfaces, ShaderMetadata *meta)
SkFourByteTag GetType(SkReadBuffer *reader)
bool SkSLToMSL(const SkSL::ShaderCaps *caps, const std::string &sksl, SkSL::ProgramKind programKind, const SkSL::ProgramSettings &settings, std::string *msl, SkSL::ProgramInterface *outInterface, ShaderErrorHandler *errorHandler)
Definition: MtlUtilsPriv.h:30
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

The documentation for this class was generated from the following files: