Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
Device.h File Reference

donner::gpu::Device - the abstract GPU device with shared fail-closed validation. More...

#include <chrono>
#include <cstdint>
#include <format>
#include <functional>
#include <memory>
#include <optional>
#include <span>
#include <string_view>
#include <utility>
#include <vector>
#include "donner/gpu/Commands.h"
#include "donner/gpu/Descriptors.h"
#include "donner/gpu/GpuResult.h"
#include "donner/gpu/Handles.h"
Include dependency graph for Device.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::gpu::SurfaceTexture
 A texture acquired from a surface for one frame, with the state the surface reported while handing it over. More...
class  donner::gpu::Device
 Abstract GPU device: resource creation, queue writes, and submission with shared fail-closed validation. More...
struct  donner::gpu::Device::MapWaitTestHooks
 Waits for a pending mapping in slices, until it completes, the caller stops it, the budget runs out, or the device is lost. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Functions

Result< uint64_t > donner::gpu::ValidateTexelCopyInternal (const TexelCopyBufferLayout &layout, const Extent2d &copySize, TextureFormat format, std::string_view context)
 Internal: validates a texel copy layout against a copy extent and format, and returns the exclusive end byte offset the copy requires in the buffer or host memory it describes.

Detailed Description

donner::gpu::Device - the abstract GPU device with shared fail-closed validation.


Class Documentation

◆ donner::gpu::Device::MapWaitTestHooks

struct donner::gpu::Device::MapWaitTestHooks

Waits for a pending mapping in slices, until it completes, the caller stops it, the budget runs out, or the device is lost.

shouldCancel is consulted before each slice, so a caller that changes its mind stops within one slice rather than at the end of the budget. Device loss ends the wait immediately: the mapping can never complete afterwards, and reporting it as a timeout would describe a permanent failure as a slow one.

Parameters
mappingLive mapping of this device.
paramsSlice length and total budget; both must be greater than zero.
shouldCancelConsulted before each slice; may be empty for an uncancellable wait. Test seam for waitForMapping. Production callers pass none; a test injects a clock and a rest so a budget is verified deterministically and without spending it.
Class Members
function< time_point()> now Clock the budget is measured against. Defaults to std::chrono::steady_clock::now.
function< void(microseconds)> rest Rests for the given duration. Defaults to std::this_thread::sleep_for.

Function Documentation

◆ ValidateTexelCopyInternal()

Result< uint64_t > donner::gpu::ValidateTexelCopyInternal ( const TexelCopyBufferLayout & layout,
const Extent2d & copySize,
TextureFormat format,
std::string_view context )

Internal: validates a texel copy layout against a copy extent and format, and returns the exclusive end byte offset the copy requires in the buffer or host memory it describes.

Shared by Device::writeTexture and CommandEncoder::copyTextureToBuffer; not part of the public API.

Parameters
layoutRow layout to validate (256-aligned bytesPerRow covering one row, and rowsPerImage covering the copy height).
copySizeCopy extent in texels.
formatTexel format of the texture side of the copy.
contextOperation name for diagnostics.