24#if !__has_feature(objc_arc)
25#error This file must be compiled with Arc. Use -fobjc-arc flag
43 MTLPixelFormat pixelFormat,
46 uint32_t uniformBufferSize,
48 std::unique_ptr<GrGeometryProcessor::ProgramImpl> gpImpl,
49 std::unique_ptr<GrXferProcessor::ProgramImpl> xpImpl,
50 std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls)
52 , fPipeline(
std::move(pipeline))
53 , fPixelFormat(pixelFormat)
54 , fBuiltinUniformHandles(builtinUniformHandles)
55 , fNumSamplers(numSamplers)
56 , fGPImpl(
std::move(gpImpl))
57 , fXPImpl(
std::move(xpImpl))
58 , fFPImpls(
std::move(fpImpls))
59 , fDataManager(uniforms, uniformBufferSize) {
67 this->setRenderTargetState(colorAttachmentDimensions, programInfo.
origin());
70 for (
int i = 0;
i < programInfo.
pipeline().numFragmentProcessors(); ++
i) {
98 fSamplerBindings.
clear();
100 SkASSERT(geomProcTextures[
i]->asTextureProxy());
121 this->bindUniforms(renderCmdEncoder);
122 this->setBlendConstants(renderCmdEncoder, writeSwizzle, xferProcessor);
123 this->setDepthStencilState(renderCmdEncoder);
132 for (
int index = 0; index < fNumSamplers; ++index) {
138void GrMtlPipelineState::setRenderTargetState(
SkISize colorAttachmentDimensions,
141 if (fRenderTargetState.fRenderTargetOrigin != origin ||
142 fRenderTargetState.fRenderTargetSize != colorAttachmentDimensions) {
143 fRenderTargetState.fRenderTargetSize = colorAttachmentDimensions;
144 fRenderTargetState.fRenderTargetOrigin = origin;
152 if (fBuiltinUniformHandles.
fRTFlipUni.isValid()) {
154 std::array<float, 2>
d =
164 if (!renderCmdEncoder) {
180 const GrSurfaceOrigin& origin = fRenderTargetState.fRenderTargetOrigin;
185 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
203 SkISize colorAttachmentDimensions,
207 colorAttachmentDimensions.
height()))) {
211 MTLScissorRect scissor;
212 scissor.x = scissorRect.
fLeft;
213 scissor.width = scissorRect.
width();
215 scissor.y = scissorRect.
fTop;
218 scissor.y = colorAttachmentDimensions.
height() - scissorRect.
fBottom;
220 scissor.height = scissorRect.
height();
229 const MTLRenderPassAttachmentDescriptor* attachment)
const {
230 for (
int i = 0;
i < fSamplerBindings.
size(); ++
i) {
231 if (attachment.texture == fSamplerBindings[
i].fTexture ||
232 attachment.resolveTexture == fSamplerBindings[
i].fTexture) {
int GrBackendFormatStencilBits(const GrBackendFormat &format)
@ kBottomLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
const GrShaderCaps * shaderCaps() const
void setData(const GrGLSLProgramDataManager &pdman, const GrFragmentProcessor &processor)
const TextureSampler & textureSampler(int index) const
int numTextureSamplers() const
const GrCaps * caps() const
void addResource(const sk_sp< const GrManagedResource > &resource)
void addGrSurface(sk_sp< const GrSurface > surface)
GrMtlAttachment * stencilAttachment()
GrMtlAttachment * colorAttachment()
GrMtlCommandBuffer * commandBuffer()
GrMtlResourceProvider & resourceProvider()
void set2fv(UniformHandle, int arrayCount, const float v[]) const override
void uploadAndBindUniformBuffers(GrMtlGpu *gpu, GrMtlRenderCommandEncoder *renderCmdEncoder) const
void setDrawState(GrMtlRenderCommandEncoder *, const skgpu::Swizzle &writeSwizzle, const GrXferProcessor &)
GrMtlPipelineState(GrMtlGpu *, sk_sp< GrMtlRenderPipeline > pipeline, MTLPixelFormat, const GrGLSLBuiltinUniformHandles &builtinUniformHandles, const UniformInfoArray &uniforms, uint32_t uniformBufferSize, uint32_t numSamplers, std::unique_ptr< GrGeometryProcessor::ProgramImpl >, std::unique_ptr< GrXferProcessor::ProgramImpl >, std::vector< std::unique_ptr< GrFragmentProcessor::ProgramImpl > > fpImpls)
static void SetDynamicScissorRectState(GrMtlRenderCommandEncoder *renderCmdEncoder, SkISize colorAttachmentDimensions, GrSurfaceOrigin rtOrigin, SkIRect scissorRect)
bool doesntSampleAttachment(const MTLRenderPassAttachmentDescriptor *) const
void bindTextures(GrMtlRenderCommandEncoder *renderCmdEncoder)
void setTextures(const GrGeometryProcessor &, const GrPipeline &, const GrSurfaceProxy *const geomProcTextures[])
void setData(GrMtlFramebuffer *, const GrProgramInfo &)
const sk_sp< GrMtlRenderPipeline > & pipeline() const
void setDepthStencilState(id< MTLDepthStencilState > depthStencilState)
void setBlendColor(SkPMColor4f blendConst)
void setFragmentTexture(id< MTLTexture > texture, NSUInteger index)
void setScissorRect(const MTLScissorRect &scissorRect)
void setFragmentSamplerState(GrMtlSampler *sampler, NSUInteger index)
void setStencilReferenceValue(uint32_t referenceValue)
void setStencilFrontBackReferenceValues(uint32_t frontReferenceValue, uint32_t backReferenceValue) SK_API_AVAILABLE(macos(10.11)
GrMtlDepthStencil * findOrCreateCompatibleDepthStencilState(const GrStencilSettings &, GrSurfaceOrigin)
GrMtlSampler * findOrCreateCompatibleSampler(GrSamplerState)
void setDstTextureUniforms(const GrGLSLProgramDataManager &pdm, GrGLSLBuiltinUniformHandles *fBuiltinUniformHandles) const
const GrFragmentProcessor & getFragmentProcessor(int idx) const
const GrXferProcessor & getXferProcessor() const
GrSurfaceOrigin origin() const
const GrPipeline & pipeline() const
const GrGeometryProcessor & geomProc() const
bool isStencilEnabled() const
GrStencilSettings nonGLStencilSettings() const
const Face & postOriginCCWFace(GrSurfaceOrigin origin) const
const Face & singleSidedFace() const
const Face & postOriginCWFace(GrSurfaceOrigin origin) const
GrTexture * peekTexture() const
SkISize dimensions() const
GrTexture * texture() const
GrSamplerState samplerState() const
skgpu::BlendInfo getBlendInfo() const
static std::array< float, 2 > GetRTFlipVector(int rtHeight, bool flipY)
static std::array< float, 4 > GetRTAdjustVector(SkISize rtDims, bool flipY)
constexpr std::array< float, 4 > applyTo(std::array< float, 4 > color) const
T & emplace_back(Args &&... args)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
static constexpr bool BlendCoeffRefsConstant(const BlendCoeff coeff)
bool intersect(const SkIRect &r)
int32_t fBottom
larger y-axis bounds
constexpr int32_t height() const
int32_t fTop
smaller y-axis bounds
constexpr int32_t width() const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
int32_t fLeft
smaller x-axis bounds
constexpr int32_t width() const
constexpr int32_t height() const
skgpu::BlendCoeff fDstBlend
SkPMColor4f fBlendConstant
skgpu::BlendCoeff fSrcBlend