33 usage = wgpu::BufferUsage::Index | wgpu::BufferUsage::CopyDst;
36 usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::MapWrite;
39 usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::MapRead;
45 usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopyDst |
46 wgpu::BufferUsage::CopySrc;
49 usage = wgpu::BufferUsage::Indirect | wgpu::BufferUsage::Storage |
50 wgpu::BufferUsage::CopyDst;
56 usage = wgpu::BufferUsage::Index | wgpu::BufferUsage::Storage;
66 usage |= wgpu::BufferUsage::MapWrite;
70 wgpu::BufferDescriptor
desc;
82 void* mappedAtCreationPtr =
nullptr;
83 if (
desc.mappedAtCreation) {
84 mappedAtCreationPtr =
buffer.GetMappedRange();
95 void* mappedAtCreationPtr)
103#if defined(__EMSCRIPTEN__)
112 if (!(fBuffer.GetUsage() & wgpu::BufferUsage::MapWrite)) {
118 SkASSERT(!this->debugHasCommandBufferRef());
151 SkASSERT((fBuffer.GetUsage() & wgpu::BufferUsage::MapRead) ||
152 (fBuffer.GetUsage() & wgpu::BufferUsage::MapWrite));
153 SkASSERT(fBuffer.GetMapState() == wgpu::BufferMapState::Unmapped);
154 bool isWrite = fBuffer.GetUsage() & wgpu::BufferUsage::MapWrite;
161 [](WGPUBufferMapAsyncStatus
s,
void* userData) {
162 sk_sp<DawnBuffer> buffer(static_cast<DawnBuffer*>(userData));
163 buffer->mapCallback(s);
170void DawnBuffer::onMap() {
171#if defined(__EMSCRIPTEN__)
172 SKGPU_LOG_W(
"Synchronous buffer mapping not supported in Dawn. Failing map request.");
176 SkASSERT((fBuffer.GetUsage() & wgpu::BufferUsage::MapRead) ||
177 (fBuffer.GetUsage() & wgpu::BufferUsage::MapWrite));
178 bool isWrite = fBuffer.GetUsage() & wgpu::BufferUsage::MapWrite;
183 wgpu::FutureWaitInfo mapWaitInfo{};
189 wgpu::CallbackMode::WaitAnyOnly,
190 [
this](wgpu::MapAsyncStatus
s,
const char*) {
191 this->mapCallback(static_cast<WGPUBufferMapAsyncStatus>(s));
196 [[maybe_unused]]
auto status =
instance.WaitAny(1, &mapWaitInfo, 0);
198 if (status != wgpu::WaitStatus::Success) {
220 SkASSERT(status == wgpu::WaitStatus::Success);
225void DawnBuffer::onUnmap() {
233void DawnBuffer::mapCallback(WGPUBufferMapAsyncStatus status) {
235 if (status == WGPUBufferMapAsyncStatus_Success) {
236 if (this->fBuffer.GetUsage() & wgpu::BufferUsage::MapWrite) {
237 this->
fMapPtr = this->fBuffer.GetMappedRange();
241 this->
fMapPtr =
const_cast<void*
>(this->fBuffer.GetConstMappedRange());
244 const char* statusStr;
247 case WGPUBufferMapAsyncStatus_ValidationError:
248 statusStr =
"ValidationError";
250 case WGPUBufferMapAsyncStatus_Unknown:
251 statusStr =
"Unknown";
253 case WGPUBufferMapAsyncStatus_DeviceLost:
254 statusStr =
"DeviceLost";
256 case WGPUBufferMapAsyncStatus_DestroyedBeforeCallback:
257 statusStr =
"DestroyedBeforeCallback";
260 case WGPUBufferMapAsyncStatus_UnmappedBeforeCallback:
261 statusStr =
"UnmappedBeforeCallback";
264 case WGPUBufferMapAsyncStatus_MappingAlreadyPending:
265 statusStr =
"MappingAlreadyPending";
267 case WGPUBufferMapAsyncStatus_OffsetOutOfRange:
268 statusStr =
"OffsetOutOfRange";
270 case WGPUBufferMapAsyncStatus_SizeOutOfRange:
271 statusStr =
"SizeOutOfRange";
274 statusStr =
"<Other>";
277 SKGPU_LOG(priority,
"Buffer async map failed with status %s.", statusStr);
278 for (
auto& cb : this->fAsyncMapCallbacks) {
279 cb->setFailureResult();
282 this->fAsyncMapCallbacks.clear();
286 return fBuffer.GetMapState() != wgpu::BufferMapState::Unmapped;
289void DawnBuffer::freeGpuData() {
299void DawnBuffer::setBackendLabel(
char const* label) {
302 fBuffer.SetLabel(label);
GrTriangulator::Vertex Vertex
#define SKGPU_LOG(priority, fmt,...)
#define SKGPU_LOG_W(fmt,...)
SkMeshSpecification::Uniform Uniform
sk_sp< T > sk_ref_sp(T *obj)
static constexpr bool SkToBool(const T &x)
static sk_sp< RefCntedCallback > Make(Callback proc, Context ctx)
virtual void onAsyncMap(GpuFinishedProc, GpuFinishedContext)
void asyncMap(GpuFinishedProc=nullptr, GpuFinishedContext=nullptr)
bool drawBufferCanBeMapped() const
bool isUnmappable() const override
static sk_sp< DawnBuffer > Make(const DawnSharedContext *, size_t size, BufferType type, AccessPattern)
virtual void prepareForReturnToCache(const std::function< void()> &takeRef)
const SharedContext * sharedContext() const
const Caps * caps() const
Dart_NativeFunction function
static float max(float r, float g, float b)
SK_API bool Read(SkStreamSeekable *src, SkDocumentPage *dstArray, int dstArrayCount, const SkDeserialProcs *=nullptr)
std::unique_ptr< ProgramUsage > GetUsage(const Program &program)
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
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
void * GpuFinishedContext
void(*)(GpuFinishedContext finishedContext, CallbackResult) GpuFinishedProc
VulkanMemoryAllocator::BufferUsage BufferUsage
static void usage(char *argv0)