34 const GrVkDescriptorSetManager::Handle& samplerDSHandle,
38 bool usePushConstants,
40 std::unique_ptr<GrGeometryProcessor::ProgramImpl> gpImpl,
41 std::unique_ptr<GrXferProcessor::ProgramImpl> xpImpl,
42 std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls)
43 : fPipeline(
std::move(pipeline))
44 , fSamplerDSHandle(samplerDSHandle)
45 , fBuiltinUniformHandles(builtinUniformHandles)
46 , fGPImpl(
std::move(gpImpl))
47 , fXPImpl(
std::move(xpImpl))
48 , fFPImpls(
std::move(fpImpls))
49 , fDataManager(uniforms, uniformSize, usePushConstants) {
50 fNumSamplers = samplers.
count();
51 for (
const auto& sampler : samplers.
items()) {
54 if (sampler.fImmutableSampler) {
55 sampler.fImmutableSampler->ref();
57 fImmutableSamplers.
push_back(sampler.fImmutableSampler);
69 for (
int i = 0;
i < fImmutableSamplers.
size(); ++
i) {
70 if (fImmutableSamplers[
i]) {
71 fImmutableSamplers[
i]->unref();
72 fImmutableSamplers[
i] =
nullptr;
78 SkISize colorAttachmentDimensions,
81 this->setRenderTargetState(colorAttachmentDimensions, programInfo.
origin());
85 for (
int i = 0;
i < programInfo.
pipeline().numFragmentProcessors(); ++
i) {
108 commandBuffer->
addGrBuffer(std::move(uniformBuffer));
122 struct SamplerBindings {
127 int currTextureBinding = 0;
130 SkASSERT(geomProcTextures[
i]->asTextureProxy());
133 samplerBindings[currTextureBinding++] = {sampler.samplerState(),
texture};
145 samplerBindings[currTextureBinding++] = {samplerState,
texture};
149 SkASSERT(fNumSamplers == currTextureBinding);
152 if (fNumSamplers == 1) {
153 auto texture = samplerBindings[0].fTexture;
154 auto texAttachment =
texture->textureImage();
155 const auto& samplerState = samplerBindings[0].fState;
159 commandBuffer->
addResource(texAttachment->textureView());
160 commandBuffer->
addResource(texAttachment->resource());
172 if (!descriptorSet) {
176 for (
int i = 0;
i < fNumSamplers; ++
i) {
179 auto texAttachment =
texture->textureImage();
181 const GrVkImageView* textureView = texAttachment->textureView();
183 if (fImmutableSamplers[
i]) {
184 sampler = fImmutableSamplers[
i];
187 state, texAttachment->ycbcrConversionInfo());
204 writeInfo.
pNext =
nullptr;
215 UpdateDescriptorSets(gpu->
device(), 1, &writeInfo, 0,
nullptr));
217 if (!fImmutableSamplers[
i]) {
221 commandBuffer->
addResource(texAttachment->resource());
223 if (fNumSamplers == 1) {
242 1, inputDescSet->descriptorSet(),
250void GrVkPipelineState::setRenderTargetState(
SkISize colorAttachmentDimensions,
254 if (fRenderTargetState.fRenderTargetOrigin != origin ||
255 fRenderTargetState.fRenderTargetSize != colorAttachmentDimensions) {
256 fRenderTargetState.fRenderTargetSize = colorAttachmentDimensions;
257 fRenderTargetState.fRenderTargetOrigin = origin;
266 if (fBuiltinUniformHandles.
fRTFlipUni.isValid()) {
267 std::array<float, 2>
d =
@ kBottomLeft_GrSurfaceOrigin
#define GR_VK_CALL(IFACE, X)
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 setDstTextureUniforms(const GrGLSLProgramDataManager &pdm, GrGLSLBuiltinUniformHandles *fBuiltinUniformHandles) const
const GrFragmentProcessor & getFragmentProcessor(int idx) const
void visitTextureEffects(const std::function< void(const GrTextureEffect &)> &) const
GrTexture * peekDstTexture() const
const GrXferProcessor & getXferProcessor() const
GrSurfaceOrigin origin() const
const GrPipeline & pipeline() const
const GrGeometryProcessor & geomProc() const
GrTexture * peekTexture() const
GrTexture * texture() const
GrSamplerState samplerState() const
const VkDescriptorSet * uniformDescriptorSet() const
void bindPipeline(const GrVkGpu *gpu, sk_sp< const GrVkPipeline > pipeline)
void addResource(sk_sp< const GrManagedResource > resource)
void addRecycledResource(gr_rp< const GrRecycledResource > resource)
void addGrSurface(sk_sp< const GrSurface > surface)
void addGrBuffer(sk_sp< const GrBuffer > buffer)
void bindDescriptorSets(const GrVkGpu *gpu, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet *descriptorSets, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets)
const VkDescriptorSet * descriptorSet() const
const skgpu::VulkanInterface * vkInterface() const
GrVkResourceProvider & resourceProvider()
VkImageView imageView() const
std::pair< sk_sp< GrGpuBuffer >, bool > uploadUniforms(GrVkGpu *gpu, VkPipelineLayout, GrVkCommandBuffer *commandBuffer)
void set2fv(UniformHandle, int arrayCount, const float v[]) const override
bool setAndBindTextures(GrVkGpu *, const GrGeometryProcessor &, const GrPipeline &, const GrSurfaceProxy *const geomProcTextures[], GrVkCommandBuffer *)
bool setAndBindUniforms(GrVkGpu *, SkISize colorAttachmentDimensions, const GrProgramInfo &, GrVkCommandBuffer *)
void bindPipeline(const GrVkGpu *gpu, GrVkCommandBuffer *commandBuffer)
bool setAndBindInputAttachment(GrVkGpu *, gr_rp< const GrVkDescriptorSet > inputDescSet, GrVkCommandBuffer *)
void freeGPUResources(GrVkGpu *gpu)
GrVkPipelineState(GrVkGpu *, sk_sp< const GrVkPipeline >, const GrVkDescriptorSetManager::Handle &samplerDSHandle, const GrGLSLBuiltinUniformHandles &builtinUniformHandles, const UniformInfoArray &uniforms, uint32_t uniformSize, bool usePushConstants, const UniformInfoArray &samplers, std::unique_ptr< GrGeometryProcessor::ProgramImpl >, std::unique_ptr< GrXferProcessor::ProgramImpl >, std::vector< std::unique_ptr< GrFragmentProcessor::ProgramImpl > > fpImpls)
VkPipelineLayout layout() const
GrVkSampler * findOrCreateCompatibleSampler(GrSamplerState, const skgpu::VulkanYcbcrConversionInfo &ycbcrInfo)
const GrVkDescriptorSet * getSamplerDescriptorSet(const GrVkDescriptorSetManager::Handle &)
VkSampler sampler() const
static std::array< float, 2 > GetRTFlipVector(int rtHeight, bool flipY)
static std::array< float, 4 > GetRTAdjustVector(SkISize rtDims, bool flipY)
void reset(T *ptr=nullptr)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
constexpr int32_t height() const
VkImageLayout imageLayout
const VkBufferView * pTexelBufferView
const VkDescriptorImageInfo * pImageInfo
const VkDescriptorBufferInfo * pBufferInfo
VkDescriptorType descriptorType
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
@ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
@ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET