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

#include <GrMtlPipelineStateDataManager.h>

Inheritance diagram for GrMtlPipelineStateDataManager:
GrUniformDataManager GrGLSLProgramDataManager

Public Types

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

Public Member Functions

 GrMtlPipelineStateDataManager (const UniformInfoArray &, uint32_t uniformSize)
 
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 setMatrix2f (UniformHandle, const float matrix[]) const override
 
void setMatrix2fv (UniformHandle, int arrayCount, const float matrices[]) const override
 
void uploadAndBindUniformBuffers (GrMtlGpu *gpu, GrMtlRenderCommandEncoder *renderCmdEncoder) const
 
void resetDirtyBits ()
 
- 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 21 of file GrMtlPipelineStateDataManager.h.

Member Typedef Documentation

◆ UniformInfoArray

Definition at line 23 of file GrMtlPipelineStateDataManager.h.

Constructor & Destructor Documentation

◆ GrMtlPipelineStateDataManager()

GR_NORETAIN_BEGIN GrMtlPipelineStateDataManager::GrMtlPipelineStateDataManager ( const UniformInfoArray uniforms,
uint32_t  uniformSize 
)

Definition at line 20 of file GrMtlPipelineStateDataManager.mm.

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

Member Function Documentation

◆ resetDirtyBits()

void GrMtlPipelineStateDataManager::resetDirtyBits ( )

Definition at line 138 of file GrMtlPipelineStateDataManager.mm.

138 {
139 fUniformsDirty = true;
140}

◆ set1fv()

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

Reimplemented from GrUniformDataManager.

Definition at line 54 of file GrMtlPipelineStateDataManager.mm.

56 {
57 const Uniform& uni = fUniforms[u.toIndex()];
58 SkASSERT(uni.fType == SkSLType::kFloat || uni.fType == SkSLType::kHalf);
59 SkASSERT(arrayCount > 0);
60 SkASSERT(arrayCount <= uni.fArrayCount ||
61 (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
62
63 void* buffer = this->getBufferPtrAndMarkDirty(uni);
64 this->copyUniforms(buffer, v, arrayCount, uni.fType);
65}
void * getBufferPtrAndMarkDirty(const Uniform &uni) const
int copyUniforms(void *dest, const void *src, int numUniforms, SkSLType uniformType) 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 GrMtlPipelineStateDataManager::set1iv ( UniformHandle  u,
int  arrayCount,
const int32_t  v[] 
) const
override

Definition at line 41 of file GrMtlPipelineStateDataManager.mm.

43 {
44 const Uniform& uni = fUniforms[u.toIndex()];
45 SkASSERT(uni.fType == SkSLType::kInt || uni.fType == SkSLType::kShort);
46 SkASSERT(arrayCount > 0);
47 SkASSERT(arrayCount <= uni.fArrayCount ||
48 (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
49
50 void* buffer = this->getBufferPtrAndMarkDirty(uni);
51 this->copyUniforms(buffer, v, arrayCount, uni.fType);
52}

◆ set2fv()

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

Reimplemented from GrUniformDataManager.

Definition at line 80 of file GrMtlPipelineStateDataManager.mm.

82 {
83 const Uniform& uni = fUniforms[u.toIndex()];
84 SkASSERT(uni.fType == SkSLType::kFloat2 || uni.fType == SkSLType::kHalf2);
85 SkASSERT(arrayCount > 0);
86 SkASSERT(arrayCount <= uni.fArrayCount ||
87 (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
88
89 void* buffer = this->getBufferPtrAndMarkDirty(uni);
90 this->copyUniforms(buffer, v, arrayCount * 2, uni.fType);
91}

◆ set2iv()

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

Definition at line 67 of file GrMtlPipelineStateDataManager.mm.

69 {
70 const Uniform& uni = fUniforms[u.toIndex()];
71 SkASSERT(uni.fType == SkSLType::kInt2 || uni.fType == SkSLType::kShort2);
72 SkASSERT(arrayCount > 0);
73 SkASSERT(arrayCount <= uni.fArrayCount ||
74 (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
75
76 void* buffer = this->getBufferPtrAndMarkDirty(uni);
77 this->copyUniforms(buffer, v, arrayCount * 2, uni.fType);
78}

◆ setMatrix2f()

void GrMtlPipelineStateDataManager::setMatrix2f ( UniformHandle  u,
const float  matrix[] 
) const
overridevirtual

Reimplemented from GrUniformDataManager.

Definition at line 93 of file GrMtlPipelineStateDataManager.mm.

93 {
94 this->setMatrix2fv(u, 1, matrix);
95}
void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const override
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ setMatrix2fv()

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

Reimplemented from GrUniformDataManager.

Definition at line 97 of file GrMtlPipelineStateDataManager.mm.

99 {
100 const Uniform& uni = fUniforms[u.toIndex()];
101 SkASSERT(uni.fType == SkSLType::kFloat2x2 || uni.fType == SkSLType::kHalf2x2);
102 SkASSERT(arrayCount > 0);
103 SkASSERT(arrayCount <= uni.fArrayCount ||
104 (1 == arrayCount && GrShaderVar::kNonArray == uni.fArrayCount));
105
106 void* buffer = this->getBufferPtrAndMarkDirty(uni);
107 this->copyUniforms(buffer, m, arrayCount * 4, uni.fType);
108}

◆ uploadAndBindUniformBuffers()

void GrMtlPipelineStateDataManager::uploadAndBindUniformBuffers ( GrMtlGpu gpu,
GrMtlRenderCommandEncoder renderCmdEncoder 
) const

Definition at line 110 of file GrMtlPipelineStateDataManager.mm.

112 {
114 fUniformsDirty = false;
115 if (@available(macOS 10.11, iOS 8.3, tvOS 9.0, *)) {
116 if (fUniformSize <= gpu->caps()->maxPushConstantsSize()) {
117 renderCmdEncoder->setVertexBytes(fUniformData.get(), fUniformSize,
119 renderCmdEncoder->setFragmentBytes(fUniformData.get(), fUniformSize,
121 return;
122 }
123 }
124
125 // upload the data
128 char* destPtr = static_cast<char*>(slice.fBuffer->map()) + slice.fOffset;
129 memcpy(destPtr, fUniformData.get(), fUniformSize);
130
131 renderCmdEncoder->setVertexBuffer(buffer->mtlBuffer(), slice.fOffset,
133 renderCmdEncoder->setFragmentBuffer(buffer->mtlBuffer(), slice.fOffset,
135 }
136}
void * map()
Definition: GrGpuBuffer.cpp:28
GrRingBuffer * uniformsRingBuffer() override
Definition: GrMtlGpu.h:118
void setFragmentBuffer(id< MTLBuffer > buffer, NSUInteger offset, NSUInteger index)
void setFragmentBytes(const void *bytes, NSUInteger length, NSUInteger index) SK_API_AVAILABLE(macos(10.11)
void setVertexBytes(const void *bytes, NSUInteger length, NSUInteger index) SK_API_AVAILABLE(macos(10.11)
void setVertexBuffer(id< MTLBuffer > buffer, NSUInteger offset, NSUInteger index)
Slice suballocate(size_t size)
void * get()
Definition: SkAutoMalloc.h:64
GrGpuBuffer * fBuffer
Definition: GrRingBuffer.h:40

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