Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrVkPipelineState.h
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
9#ifndef GrVkPipelineState_DEFINED
10#define GrVkPipelineState_DEFINED
11
13#include "src/gpu/GpuRefCnt.h"
18
19class GrPipeline;
21class GrVkBuffer;
24class GrVkGpu;
25class GrVkImageView;
26class GrVkPipeline;
28class GrVkSampler;
29class GrVkTexture;
30
31/**
32 * This class holds onto a GrVkPipeline object that we use for draws. Besides storing the acutal
33 * GrVkPipeline object, this class is also responsible handling all uniforms, descriptors, samplers,
34 * and other similar objects that are used along with the VkPipeline in the draw. This includes both
35 * allocating and freeing these objects, as well as updating their values.
36 */
38public:
40 using UniformHandle = GrGLSLProgramDataManager::UniformHandle;
41
44 const GrVkDescriptorSetManager::Handle& samplerDSHandle,
45 const GrGLSLBuiltinUniformHandles& builtinUniformHandles,
46 const UniformInfoArray& uniforms,
47 uint32_t uniformSize,
48 bool usePushConstants,
49 const UniformInfoArray& samplers,
50 std::unique_ptr<GrGeometryProcessor::ProgramImpl>,
51 std::unique_ptr<GrXferProcessor::ProgramImpl>,
52 std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fpImpls);
53
55
56 bool setAndBindUniforms(GrVkGpu*, SkISize colorAttachmentDimensions, const GrProgramInfo&,
58 /**
59 * This must be called after setAndBindUniforms() since that function invalidates texture
60 * bindings.
61 */
64 const GrPipeline&,
65 const GrSurfaceProxy* const geomProcTextures[],
67
70
71 void bindPipeline(const GrVkGpu* gpu, GrVkCommandBuffer* commandBuffer);
72
73 void freeGPUResources(GrVkGpu* gpu);
74
75private:
76 /**
77 * We use the RT's size and origin to adjust from Skia device space to vulkan normalized device
78 * space and to make device space positions have the correct origin for processors that require
79 * them.
80 */
81 struct RenderTargetState {
82 SkISize fRenderTargetSize;
83 GrSurfaceOrigin fRenderTargetOrigin;
84
85 RenderTargetState() { this->invalidate(); }
86 void invalidate() {
87 fRenderTargetSize.fWidth = -1;
88 fRenderTargetSize.fHeight = -1;
89 fRenderTargetOrigin = (GrSurfaceOrigin)-1;
90 }
91 };
92
93 // Helper for setData() that sets the view matrix and loads the render target height uniform
94 void setRenderTargetState(SkISize colorAttachmentDimensions, GrSurfaceOrigin);
95
96 // GrManagedResources
98
99 const GrVkDescriptorSetManager::Handle fSamplerDSHandle;
100
102
103 // Tracks the current render target uniforms stored in the vertex buffer.
104 RenderTargetState fRenderTargetState;
105 GrGLSLBuiltinUniformHandles fBuiltinUniformHandles;
106
107 // Processors in the GrVkPipelineState
108 std::unique_ptr<GrGeometryProcessor::ProgramImpl> fGPImpl;
109 std::unique_ptr<GrXferProcessor::ProgramImpl> fXPImpl;
110 std::vector<std::unique_ptr<GrFragmentProcessor::ProgramImpl>> fFPImpls;
111
112 GrVkPipelineStateDataManager fDataManager;
113
114 int fNumSamplers;
115};
116
117#endif
GrSurfaceOrigin
Definition GrTypes.h:147
GrVkUniformHandler::UniformInfoArray UniformInfoArray
bool setAndBindTextures(GrVkGpu *, const GrGeometryProcessor &, const GrPipeline &, const GrSurfaceProxy *const geomProcTextures[], GrVkCommandBuffer *)
bool setAndBindUniforms(GrVkGpu *, SkISize colorAttachmentDimensions, const GrProgramInfo &, GrVkCommandBuffer *)
GrGLSLProgramDataManager::UniformHandle UniformHandle
void bindPipeline(const GrVkGpu *gpu, GrVkCommandBuffer *commandBuffer)
bool setAndBindInputAttachment(GrVkGpu *, gr_rp< const GrVkDescriptorSet > inputDescSet, GrVkCommandBuffer *)
void freeGPUResources(GrVkGpu *gpu)
int32_t fHeight
Definition SkSize.h:18
int32_t fWidth
Definition SkSize.h:17