@luma.gl/core
Version:
The luma.gl core Device API
150 lines • 7.35 kB
TypeScript
import { Device } from "../device.js";
import { Resource, ResourceProps } from "./resource.js";
import { QuerySet } from "./query-set.js";
import { Buffer } from "./buffer.js";
import { Texture } from "./texture.js";
import type { RenderPass, RenderPassProps } from "./render-pass.js";
import type { ComputePass, ComputePassProps } from "./compute-pass.js";
import type { CommandBuffer, CommandBufferProps } from "./command-buffer.js";
export type CopyBufferToBufferOptions = {
sourceBuffer: Buffer;
sourceOffset?: number;
destinationBuffer: Buffer;
destinationOffset?: number;
size: number;
};
export type CopyBufferToTextureOptions = {
sourceBuffer: Buffer;
byteOffset?: number;
destinationTexture: Texture;
mipLevel?: number;
origin?: [number, number, number];
aspect?: 'all' | 'stencil-only' | 'depth-only';
bytesPerRow: number;
rowsPerImage: number;
size: [number, number, number];
};
export type CopyTextureToBufferOptions = {
/** Texture to copy to/from. */
sourceTexture: Texture;
/** Mip-map level of the texture to copy to/from. (Default 0) */
mipLevel?: number;
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from.
* Together with `copySize`, defines the full copy sub-region.
*/
/** Defines which aspects of the texture to copy to/from. */
aspect?: 'all' | 'stencil-only' | 'depth-only';
/** Width to copy */
width?: number;
height?: number;
depthOrArrayLayers?: number;
origin?: [number, number, number];
/** Destination buffer */
destinationBuffer: Buffer;
/** Offset, in bytes, from the beginning of the buffer to the start of the image data (default 0) */
byteOffset?: number;
/**
* The stride, in bytes, between the beginning of each block row and the subsequent block row.
* Required if there are multiple block rows (i.e. the copy height or depth is more than one block).
*/
bytesPerRow?: number;
/**
* Number of block rows per single image of the texture.
* rowsPerImage × bytesPerRow is the stride, in bytes, between the beginning of each image of data and the subsequent image.
* Required if there are multiple images (i.e. the copy depth is more than one).
*/
rowsPerImage?: number;
};
export type CopyTextureToTextureOptions = {
/** Texture to copy to/from. */
sourceTexture: Texture;
/** Mip-map level of the texture to copy to/from. (Default 0) */
mipLevel?: number;
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy from. */
origin?: [number, number, number];
/** Defines which aspects of the {@link GPUImageCopyTexture#texture} to copy to/from. */
aspect?: 'all' | 'stencil-only' | 'depth-only';
/** Texture to copy to/from. */
destinationTexture: Texture;
/** Mip-map level of the texture to copy to/from. (Default 0) */
destinationMipLevel?: number;
/** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to. */
destinationOrigin?: [number, number, number];
/** Defines which aspects of the {@link GPUImageCopyTexture#texture} to copy to/from. */
destinationAspect?: 'all' | 'stencil-only' | 'depth-only';
/** Width to copy */
width?: number;
height?: number;
depthOrArrayLayers?: number;
};
/** Options for clearing a texture mip level */
export type ClearTextureOptions = {
/** Texture to Clear. */
texture: Texture;
/** Mip-map level of the texture clear. (Default 0) */
mipLevel?: number;
/** Defines which aspects of the Texture to clear. */
aspect?: 'all' | 'stencil-only' | 'depth-only';
};
export type CommandEncoderProps = ResourceProps & {
measureExecutionTime?: boolean;
timeProfilingQuerySet?: QuerySet | null;
};
type PassWithTimestamps = {
timestampQuerySet?: QuerySet;
beginTimestampIndex?: number;
endTimestampIndex?: number;
};
/**
* Records commands onto a single backend command encoder and can finish them into one command
* buffer. Resource helpers invoked through a CommandEncoder must record onto that encoder rather
* than allocating hidden encoders or submitting work eagerly.
*/
export declare abstract class CommandEncoder extends Resource<CommandEncoderProps> {
get [Symbol.toStringTag](): string;
protected _timeProfilingQuerySet: QuerySet | null;
protected _timeProfilingSlotCount: number;
_gpuTimeMs?: number;
constructor(device: Device, props: CommandEncoderProps);
/** Completes recording of the commands sequence */
abstract finish(props?: CommandBufferProps): CommandBuffer;
/** Create a RenderPass using the default CommandEncoder */
abstract beginRenderPass(props?: RenderPassProps): RenderPass;
/** Create a ComputePass using the default CommandEncoder*/
abstract beginComputePass(props?: ComputePassProps): ComputePass;
/** Add a command that that copies data from a sub-region of a Buffer to a sub-region of another Buffer. */
abstract copyBufferToBuffer(options: CopyBufferToBufferOptions): void;
/** Add a command that copies data from a sub-region of a GPUBuffer to a sub-region of one or multiple continuous texture subresources. */
abstract copyBufferToTexture(options: CopyBufferToTextureOptions): void;
/** Add a command that copies data from a sub-region of one or multiple continuous texture subresources to a sub-region of a Buffer. */
abstract copyTextureToBuffer(options: CopyTextureToBufferOptions): void;
/** Add a command that copies data from a sub-region of one or multiple contiguous texture subresources to another sub-region of one or multiple continuous texture subresources. */
abstract copyTextureToTexture(options: CopyTextureToTextureOptions): void;
/** Add a command that clears a texture mip level. */
/** Reads results from a query set into a GPU buffer. Values are 64 bits so byteLength must be querySet.props.count * 8 */
abstract resolveQuerySet(querySet: QuerySet, destination: Buffer, options?: {
firstQuery?: number;
queryCount?: number;
destinationOffset?: number;
}): void;
/**
* Reads all resolved timestamp pairs on the current profiler query set and caches the sum
* as milliseconds on this encoder.
*/
resolveTimeProfilingQuerySet(): Promise<void>;
/** Returns the number of query slots consumed by automatic pass profiling on this encoder. */
getTimeProfilingSlotCount(): number;
getTimeProfilingQuerySet(): QuerySet | null;
/** Internal helper for auto-assigning timestamp slots to render/compute passes on this encoder. */
protected _applyTimeProfilingToPassProps<P extends PassWithTimestamps>(props?: P): P;
protected _supportsTimestampQueries(): boolean;
/** Begins a labeled debug group containing subsequent commands */
abstract pushDebugGroup(groupLabel: string): void;
/** Ends the labeled debug group most recently started by pushDebugGroup() */
abstract popDebugGroup(): void;
/** Marks a point in a stream of commands with a label */
abstract insertDebugMarker(markerLabel: string): void;
static defaultProps: Required<CommandEncoderProps>;
}
export {};
//# sourceMappingURL=command-encoder.d.ts.map