Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
GrVkPipelineStateDataManager Class Reference

#include <GrVkPipelineStateDataManager.h>

Inheritance diagram for GrVkPipelineStateDataManager:
GrUniformDataManager GrGLSLProgramDataManager

Public Types

typedef GrVkUniformHandler::UniformInfoArray UniformInfoArray
 
- Public Types inherited from GrGLSLProgramDataManager
enum class  Specialized : bool { kNo = false , kYes = true }
 

Public Member Functions

 GrVkPipelineStateDataManager (const UniformInfoArray &, uint32_t uniformSize, bool usePushConstants)
 
std::pair< sk_sp< GrGpuBuffer >, bool > uploadUniforms (GrVkGpu *gpu, VkPipelineLayout, GrVkCommandBuffer *commandBuffer)
 
void releaseData ()
 
void set1iv (UniformHandle, int arrayCount, const int32_t v[]) const override
 
void set1fv (UniformHandle, int arrayCount, const float v[]) const override
 
void set2iv (UniformHandle, int arrayCount, const int32_t v[]) const override
 
void set2fv (UniformHandle, int arrayCount, const float v[]) const override
 
void setMatrix2fv (UniformHandle, int arrayCount, const float matrices[]) const override
 
- Public Member Functions inherited from GrUniformDataManager
 GrUniformDataManager (uint32_t uniformCount, uint32_t uniformSize)
 
void set1i (UniformHandle, int32_t) const override
 
void set1iv (UniformHandle, int arrayCount, const int32_t v[]) const override
 
void set1f (UniformHandle, float v0) const override
 
void set1fv (UniformHandle, int arrayCount, const float v[]) const override
 
void set2i (UniformHandle, int32_t, int32_t) const override
 
void set2iv (UniformHandle, int arrayCount, const int32_t v[]) const override
 
void set2f (UniformHandle, float, float) const override
 
void set2fv (UniformHandle, int arrayCount, const float v[]) const override
 
void set3i (UniformHandle, int32_t, int32_t, int32_t) const override
 
void set3iv (UniformHandle, int arrayCount, const int32_t v[]) const override
 
void set3f (UniformHandle, float, float, float) const override
 
void set3fv (UniformHandle, int arrayCount, const float v[]) const override
 
void set4i (UniformHandle, int32_t, int32_t, int32_t, int32_t) const override
 
void set4iv (UniformHandle, int arrayCount, const int32_t v[]) const override
 
void set4f (UniformHandle, float, float, float, float) const override
 
void set4fv (UniformHandle, int arrayCount, const float v[]) const override
 
void setMatrix2f (UniformHandle, const float matrix[]) const override
 
void setMatrix3f (UniformHandle, const float matrix[]) const override
 
void setMatrix4f (UniformHandle, const float matrix[]) const override
 
void setMatrix2fv (UniformHandle, int arrayCount, const float matrices[]) const override
 
void setMatrix3fv (UniformHandle, int arrayCount, const float matrices[]) const override
 
void setMatrix4fv (UniformHandle, int arrayCount, const float matrices[]) const override
 
void markDirty ()
 
- Public Member Functions inherited from GrGLSLProgramDataManager
virtual ~GrGLSLProgramDataManager ()
 
virtual void set1i (UniformHandle, int32_t) const =0
 
virtual void set1iv (UniformHandle, int arrayCount, const int v[]) const =0
 
virtual void set1f (UniformHandle, float v0) const =0
 
virtual void set1fv (UniformHandle, int arrayCount, const float v[]) const =0
 
virtual void set2i (UniformHandle, int32_t, int32_t) const =0
 
virtual void set2iv (UniformHandle, int arrayCount, const int v[]) const =0
 
virtual void set2f (UniformHandle, float, float) const =0
 
virtual void set2fv (UniformHandle, int arrayCount, const float v[]) const =0
 
virtual void set3i (UniformHandle, int32_t, int32_t, int32_t) const =0
 
virtual void set3iv (UniformHandle, int arrayCount, const int v[]) const =0
 
virtual void set3f (UniformHandle, float, float, float) const =0
 
virtual void set3fv (UniformHandle, int arrayCount, const float v[]) const =0
 
virtual void set4i (UniformHandle, int32_t, int32_t, int32_t, int32_t) const =0
 
virtual void set4iv (UniformHandle, int arrayCount, const int v[]) const =0
 
virtual void set4f (UniformHandle, float, float, float, float) const =0
 
virtual void set4fv (UniformHandle, int arrayCount, const float v[]) const =0
 
virtual void setMatrix2f (UniformHandle, const float matrix[]) const =0
 
virtual void setMatrix3f (UniformHandle, const float matrix[]) const =0
 
virtual void setMatrix4f (UniformHandle, const float matrix[]) const =0
 
virtual void setMatrix2fv (UniformHandle, int arrayCount, const float matrices[]) const =0
 
virtual void setMatrix3fv (UniformHandle, int arrayCount, const float matrices[]) const =0
 
virtual void setMatrix4fv (UniformHandle, int arrayCount, const float matrices[]) const =0
 
void setSkMatrix (UniformHandle, const SkMatrix &) const
 
void setSkM44 (UniformHandle, const SkM44 &) const
 
void setRuntimeEffectUniforms (SkSpan< const SkRuntimeEffect::Uniform >, SkSpan< const UniformHandle >, SkSpan< const Specialized >, const void *src) const
 
void setRuntimeEffectUniforms (SkSpan< const SkRuntimeEffect::Uniform > uniforms, SkSpan< const UniformHandle > handles, const void *src) const
 

Additional Inherited Members

- Protected Member Functions inherited from GrUniformDataManager
int copyUniforms (void *dest, const void *src, int numUniforms, SkSLType uniformType) const
 
template<int N, SkSLType kFullType, SkSLType kHalfType>
void set (UniformHandle u, const void *v) const
 
template<int N, SkSLType kFullType, SkSLType kHalfType>
void setv (UniformHandle u, int arrayCount, const void *v) const
 
template<int N, SkSLType FullType, SkSLType HalfType>
void setMatrices (UniformHandle, int arrayCount, const float matrices[]) const
 
void * getBufferPtrAndMarkDirty (const Uniform &uni) const
 
- Protected Member Functions inherited from GrGLSLProgramDataManager
 GrGLSLProgramDataManager ()
 
- Protected Attributes inherited from GrUniformDataManager
uint32_t fUniformSize
 
bool fWrite16BitUniforms = false
 
skia_private::TArray< Uniform, truefUniforms
 
SkAutoMalloc fUniformData
 
bool fUniformsDirty = false
 

Detailed Description

Definition at line 20 of file GrVkPipelineStateDataManager.h.

Member Typedef Documentation

◆ UniformInfoArray

Definition at line 22 of file GrVkPipelineStateDataManager.h.

Constructor & Destructor Documentation

◆ GrVkPipelineStateDataManager()

GrVkPipelineStateDataManager::GrVkPipelineStateDataManager ( const UniformInfoArray uniforms,
uint32_t  uniformSize,
bool  usePushConstants 
)

Definition at line 17 of file GrVkPipelineStateDataManager.cpp.

20 : INHERITED(uniforms.count(), uniformSize)
21 , fUsePushConstants(usePushConstants) {
22 // We must add uniforms in same order as the UniformInfoArray so that UniformHandles already
23 // owned by other objects will still match up here.
24 int i = 0;
27 for (const auto& uniformInfo : uniforms.items()) {
28 Uniform& uniform = fUniforms[i];
29 SkASSERT(GrShaderVar::kNonArray == uniformInfo.fVariable.getArrayCount() ||
30 uniformInfo.fVariable.getArrayCount() > 0);
32 uniform.fArrayCount = uniformInfo.fVariable.getArrayCount();
33 )
34
35 uniform.fOffset = uniformInfo.fOffsets[memLayout];
36 uniform.fType = uniformInfo.fVariable.getType();
37 ++i;
38 }
39}
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
skia_private::TArray< Uniform, true > fUniforms

Member Function Documentation

◆ releaseData()

void GrVkPipelineStateDataManager::releaseData ( )

Definition at line 161 of file GrVkPipelineStateDataManager.cpp.

161{ fUniformBuffer.reset(); }
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310

◆ set1fv()

void GrVkPipelineStateDataManager::set1fv ( UniformHandle  u,
int  arrayCount,
const float  v[] 
) const
overridevirtual

Reimplemented from GrUniformDataManager.

Definition at line 85 of file GrVkPipelineStateDataManager.cpp.

87 {
88 if (fUsePushConstants) {
89 const Uniform& uni = fUniforms[u.toIndex()];
90 SkASSERT(uni.fType == SkSLType::kFloat || uni.fType == SkSLType::kHalf);
91 SkASSERT(arrayCount > 0);
92 SkASSERT(arrayCount <= uni.fArrayCount ||
93 (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
94
95 void* buffer = this->getBufferPtrAndMarkDirty(uni);
96 SkASSERT(sizeof(float) == 4);
97 memcpy(buffer, v, arrayCount * sizeof(float));
98 } else {
99 return this->INHERITED::set1fv(u, arrayCount, v);
100 }
101}
void set1fv(UniformHandle, int arrayCount, const float v[]) const override
void * getBufferPtrAndMarkDirty(const Uniform &uni) const
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ set1iv()

void GrVkPipelineStateDataManager::set1iv ( UniformHandle  u,
int  arrayCount,
const int32_t  v[] 
) const
override

Definition at line 67 of file GrVkPipelineStateDataManager.cpp.

69 {
70 if (fUsePushConstants) {
71 const Uniform& uni = fUniforms[u.toIndex()];
72 SkASSERT(uni.fType == SkSLType::kInt || uni.fType == SkSLType::kShort);
73 SkASSERT(arrayCount > 0);
74 SkASSERT(arrayCount <= uni.fArrayCount ||
75 (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
76
77 void* buffer = this->getBufferPtrAndMarkDirty(uni);
78 SkASSERT(sizeof(int32_t) == 4);
79 memcpy(buffer, v, arrayCount * sizeof(int32_t));
80 } else {
81 return this->INHERITED::set1iv(u, arrayCount, v);
82 }
83}
void set1iv(UniformHandle, int arrayCount, const int32_t v[]) const override

◆ set2fv()

void GrVkPipelineStateDataManager::set2fv ( UniformHandle  u,
int  arrayCount,
const float  v[] 
) const
overridevirtual

Reimplemented from GrUniformDataManager.

Definition at line 121 of file GrVkPipelineStateDataManager.cpp.

123 {
124 if (fUsePushConstants) {
125 const Uniform& uni = fUniforms[u.toIndex()];
126 SkASSERT(uni.fType == SkSLType::kFloat2 || uni.fType == SkSLType::kHalf2);
127 SkASSERT(arrayCount > 0);
128 SkASSERT(arrayCount <= uni.fArrayCount ||
129 (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
130
131 void* buffer = this->getBufferPtrAndMarkDirty(uni);
132 SkASSERT(sizeof(float) == 4);
133 memcpy(buffer, v, arrayCount * 2 * sizeof(float));
134 } else {
135 return this->INHERITED::set2fv(u, arrayCount, v);
136 }
137}
void set2fv(UniformHandle, int arrayCount, const float v[]) const override

◆ set2iv()

void GrVkPipelineStateDataManager::set2iv ( UniformHandle  u,
int  arrayCount,
const int32_t  v[] 
) const
override

Definition at line 103 of file GrVkPipelineStateDataManager.cpp.

105 {
106 if (fUsePushConstants) {
107 const Uniform& uni = fUniforms[u.toIndex()];
108 SkASSERT(uni.fType == SkSLType::kInt2 || uni.fType == SkSLType::kShort2);
109 SkASSERT(arrayCount > 0);
110 SkASSERT(arrayCount <= uni.fArrayCount ||
111 (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
112
113 void* buffer = this->getBufferPtrAndMarkDirty(uni);
114 SkASSERT(sizeof(int32_t) == 4);
115 memcpy(buffer, v, arrayCount * 2 * sizeof(int32_t));
116 } else {
117 return this->INHERITED::set2iv(u, arrayCount, v);
118 }
119}
void set2iv(UniformHandle, int arrayCount, const int32_t v[]) const override

◆ setMatrix2fv()

void GrVkPipelineStateDataManager::setMatrix2fv ( UniformHandle  u,
int  arrayCount,
const float  matrices[] 
) const
overridevirtual

Reimplemented from GrUniformDataManager.

Definition at line 139 of file GrVkPipelineStateDataManager.cpp.

141 {
142 if (fUsePushConstants) {
143 // upload as std430
144 const Uniform& uni = fUniforms[u.toIndex()];
145 SkASSERT(uni.fType == SkSLType::kFloat2x2 || uni.fType == SkSLType::kHalf2x2);
146 SkASSERT(arrayCount > 0);
147 SkASSERT(arrayCount <= uni.fArrayCount ||
148 (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
149
150 void* buffer = fUniformData.get();
151 fUniformsDirty = true;
152
153 static_assert(sizeof(float) == 4);
154 buffer = static_cast<char*>(buffer) + uni.fOffset;
155 memcpy(buffer, m, arrayCount * 2 * 2 * sizeof(float));
156 } else {
157 this->INHERITED::setMatrix2fv(u, arrayCount, m);
158 }
159}
void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const override
void * get()
Definition: SkAutoMalloc.h:64

◆ uploadUniforms()

std::pair< sk_sp< GrGpuBuffer >, bool > GrVkPipelineStateDataManager::uploadUniforms ( GrVkGpu gpu,
VkPipelineLayout  layout,
GrVkCommandBuffer commandBuffer 
)

Definition at line 41 of file GrVkPipelineStateDataManager.cpp.

42 {
43 if (fUniformSize == 0) {
44 return std::make_pair(nullptr, true);
45 }
46 if (fUsePushConstants) {
47 commandBuffer->pushConstants(gpu, layout, gpu->vkCaps().getPushConstantStageFlags(),
49 fUniformBuffer = nullptr;
50 } else {
51 if (fUniformsDirty) {
52 GrResourceProvider* resourceProvider = gpu->getContext()->priv().resourceProvider();
53 fUniformBuffer = resourceProvider->createBuffer(fUniformData.get(),
57 if (!fUniformBuffer) {
58 return std::make_pair(nullptr, false);
59 }
60 fUniformsDirty = false;
61 }
62 }
63
64 return std::make_pair(fUniformBuffer, true);
65}
@ kDynamic_GrAccessPattern
Definition: GrTypesPriv.h:426
GrResourceProvider * resourceProvider()
GrDirectContextPriv priv()
GrDirectContext * getContext()
Definition: GrGpu.h:67
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType, GrAccessPattern, ZeroInit)
VkShaderStageFlags getPushConstantStageFlags() const
Definition: GrVkCaps.cpp:2060
void pushConstants(const GrVkGpu *gpu, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void *values)
const GrVkCaps & vkCaps() const
Definition: GrVkGpu.h:61

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