15#if !__has_feature(objc_arc)
16#error This file must be compiled with Arc. Use -fobjc-arc flag
20#define VALIDATE() this->validate()
22#define VALIDATE() do {} while(false)
27#ifdef SK_ENABLE_MTL_DEBUG_INFO
54 if (@available(macOS 10.11, iOS 9.0, tvOS 9.0, *)) {
56#ifdef SK_BUILD_FOR_MAC
58 options |= MTLResourceStorageModeManaged;
60 options |= MTLResourceStorageModeShared;
63 options |= MTLResourceStorageModeShared;
66 options |= MTLResourceStorageModePrivate;
71 fMtlBuffer =
size == 0 ? nil :
74#ifdef SK_ENABLE_MTL_DEBUG_INFO
86bool GrMtlBuffer::onUpdateData(
const void *
src,
size_t offset,
size_t size,
bool preserve) {
101 size_t r =
offset%transferAlignment;
105 size_t transferSize =
SkAlignTo(
size + r, transferAlignment);
109 transferSize, this->mtlGpu()->mtlCaps().getMinBufferAlignment());
117 if (!blitCmdEncoder) {
121 id<MTLBuffer> transferBuffer =
mtlBuffer->mtlBuffer();
122 [blitCmdEncoder copyFromBuffer: transferBuffer
130inline GrMtlGpu* GrMtlBuffer::mtlGpu()
const {
152void GrMtlBuffer::internalMap() {
156 fMapPtr =
static_cast<char*
>(fMtlBuffer.contents);
161void GrMtlBuffer::internalUnmap(
size_t writtenOffset,
size_t writtenSize) {
167#ifdef SK_BUILD_FOR_MAC
168 if (this->mtlGpu()->mtlCaps().isMac() && writtenSize) {
171 [fMtlBuffer didModifyRange: NSMakeRange(writtenOffset, writtenSize)];
178void GrMtlBuffer::onMap(MapType) {
182void GrMtlBuffer::onUnmap(MapType
type) {
186bool GrMtlBuffer::onClearToZero() {
190 if (!blitCmdEncoder) {
194 NSRange range{0, this->
size()};
195 [blitCmdEncoder fillBuffer: fMtlBuffer range: range
value: 0];
203void GrMtlBuffer::validate()
const {
215void GrMtlBuffer::onSetLabel() {
218 NSString* labelStr = @(this->
getLabel().c_str());
219 fMtlBuffer.label = [
@"_Skia_" stringByAppendingString:labelStr];
static const constexpr int kGrGpuBufferTypeCount
@ kStatic_GrAccessPattern
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
sk_sp< T > sk_ref_sp(T *obj)
size_t transferFromBufferToBufferAlignment() const
size_t size() const final
GrGpuBufferType intendedType() const
GrAccessPattern accessPattern() const
std::string getLabel() const
bool wasDestroyed() const
void registerWithCache(skgpu::Budgeted)
const GrCaps * caps() const
GrMtlBuffer(GrMtlGpu *, size_t size, GrGpuBufferType intendedType, GrAccessPattern, std::string_view label)
void onRelease() override
static sk_sp< GrMtlBuffer > Make(GrMtlGpu *, size_t size, GrGpuBufferType intendedType, GrAccessPattern)
void onAbandon() override
id< MTLBuffer > mtlBuffer() const
size_t getMinBufferAlignment() const
void addGrBuffer(sk_sp< const GrBuffer > buffer)
id< MTLBlitCommandEncoder > getBlitCommandEncoder()
GrMtlCommandBuffer * commandBuffer()
const GrMtlCaps & mtlCaps() const
id< MTLDevice > device() const
GrStagingBufferManager * stagingBufferManager() override
Slice allocateStagingBufferSlice(size_t size, size_t requiredAlignment=1)
EMSCRIPTEN_KEEPALIVE void empty()
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size