import { type VertexFormat } from "./VertexFormat";
import { type TextureBinding } from "./TextureBinding";
import { Texture, type TextureFormat } from "./Texture";
import { type ShaderReflection } from "./ShaderReflection";
import type { RendererPostprocessPlanDiagnostics } from "./RendererPostprocessPlan";
export type { ShaderAttributeReflection, ShaderReflection, ShaderUniformReflection } from "./ShaderReflection";
export type RenderBackendKind = "mock" | "webgl2" | "webgpu";
export type BufferUsage = "vertex" | "index" | "uniform" | "readback";
export type IndexType = "uint16" | "uint32";
export type PrimitiveTopology = "triangles" | "lines" | "points";
export interface DisposableResource {
    readonly disposed: boolean;
    dispose(): void;
}
export interface RenderBuffer extends DisposableResource {
    readonly id: number;
    readonly usage: BufferUsage;
    readonly byteLength: number;
}
export interface ShaderSources {
    readonly label: string;
    readonly vertex: string;
    readonly fragment: string;
    readonly marker: string;
}
export interface RenderShaderProgram extends DisposableResource {
    readonly id: number;
    readonly label: string;
    readonly marker: string;
    readonly reflection: ShaderReflection;
}
export interface RenderTargetDescriptor {
    readonly width: number;
    readonly height: number;
    readonly label?: string;
    readonly format?: Extract<TextureFormat, "rgba8" | "rgba16f" | "rgba32f">;
    readonly depth?: boolean | "renderbuffer" | "texture";
}
export interface RenderTarget extends DisposableResource {
    readonly id: number;
    readonly width: number;
    readonly height: number;
    readonly label: string;
    readonly colorTexture: Texture;
    readonly depthTexture?: Texture;
}
export type LdrPostprocessPassName = "tone-mapping" | "color-grade" | "fxaa";
export interface LdrPostprocessPassDescriptor {
    readonly name: LdrPostprocessPassName;
    readonly options: Readonly<Record<string, unknown>>;
}
export interface LdrPostprocessPresentationOptions {
    readonly passes: readonly LdrPostprocessPassDescriptor[];
    readonly outputTarget?: RenderTarget;
    readonly toneMappingDefaults?: Readonly<Record<string, unknown>>;
}
export interface DrawCommand {
    readonly label?: string;
    readonly topology: PrimitiveTopology;
    readonly renderState?: RenderCommandState;
    readonly vertexBuffer: RenderBuffer;
    readonly vertexFormat?: VertexFormat;
    readonly vertexCount: number;
    readonly firstVertex?: number;
    readonly instanceCount?: number;
    readonly instanceAttributes?: readonly InstanceVertexAttribute[];
    readonly indexBuffer?: RenderBuffer;
    readonly indexType?: IndexType;
    readonly indexCount?: number;
    readonly firstIndex?: number;
    readonly shader?: RenderShaderProgram;
    readonly uniforms?: ReadonlyMap<string, UniformValue>;
}
export interface InstanceVertexAttribute {
    readonly buffer: RenderBuffer;
    readonly shaderName: string;
    readonly components: 1 | 2 | 3 | 4;
    readonly offset: number;
    readonly stride: number;
    readonly normalized?: boolean;
    readonly divisor?: number;
}
export type UniformValue = number | readonly number[] | Float32Array | Int32Array | Uint32Array | TextureBinding;
export interface RenderCommandState {
    readonly depthTest: boolean;
    readonly depthWrite: boolean;
    readonly cullMode: "none" | "back" | "front";
    readonly blend: boolean;
    readonly depthCompare: "always" | "less-equal";
    readonly colorWrite?: readonly [boolean, boolean, boolean, boolean];
    readonly scissor?: {
        readonly x: number;
        readonly y: number;
        readonly width: number;
        readonly height: number;
    } | null;
    readonly polygonOffset?: {
        readonly factor: number;
        readonly units: number;
    } | null;
    readonly stencil?: {
        readonly compare?: "never" | "less" | "less-equal" | "greater" | "greater-equal" | "equal" | "not-equal" | "always";
        readonly reference?: number;
        readonly readMask?: number;
        readonly writeMask?: number;
        readonly fail?: "keep" | "zero" | "replace" | "increment" | "decrement" | "invert" | "increment-wrap" | "decrement-wrap";
        readonly depthFail?: "keep" | "zero" | "replace" | "increment" | "decrement" | "invert" | "increment-wrap" | "decrement-wrap";
        readonly depthPass?: "keep" | "zero" | "replace" | "increment" | "decrement" | "invert" | "increment-wrap" | "decrement-wrap";
    } | null;
}
export type RenderDeviceCapability = "buffers" | "buffer-readback" | "shader-validation" | "render-targets" | "pixel-readback" | "postprocess-presentation" | "draw-validation" | "rasterization" | "native-render-pipeline" | "native-sampled-textures" | "native-texture-readback" | "canvas-surface" | "hdr-render-targets" | "float-readback" | "depth-render-targets" | "depth-textures" | "contact-shadows" | "spot-shadow-maps" | "point-shadow-maps" | "hdr-image-based-lighting" | "anisotropic-texture-filtering" | "production-pbr-parity" | "gpu-timing" | "webgpu-compute";
export interface RenderDeviceInfo {
    readonly backend: RenderBackendKind;
    readonly vendor: string;
    readonly renderer: string;
    readonly capabilities?: readonly RenderDeviceCapability[];
    readonly limitations?: readonly string[];
}
export interface RenderDeviceDiagnostics {
    readonly drawCalls: number;
    readonly buffers: number;
    readonly shaders: number;
    readonly renderTargets?: number;
    readonly textures?: number;
    readonly bufferBytes?: number;
    readonly textureBytes?: number;
    readonly approximateGpuMemoryBytes?: number;
    readonly disposedBuffers?: number;
    readonly disposedShaders?: number;
    readonly disposedRenderTargets?: number;
    readonly disposedTextures?: number;
    readonly compressedTextures?: number;
    readonly compressedTextureBytes?: number;
    readonly textureFallbacks?: number;
    readonly textureFallbackBytes?: number;
    readonly nativeSubmissions?: number;
    readonly nativeTextureBindings?: number;
    readonly nativeGeneratedBasicSubmissions?: number;
    readonly nativeGeneratedTextureSubmissions?: number;
    readonly nativePassthroughSubmissions?: number;
    readonly nativePbrSubmissions?: number;
    readonly nativeInstancedSubmissions?: number;
    readonly nativeSkinnedSubmissions?: number;
    readonly nativeMorphSubmissions?: number;
    readonly nativeEnvironmentBindings?: number;
    readonly nativeShadowMapBindings?: number;
    readonly samplerAnisotropyUploads?: number;
    readonly maxTextureAnisotropy?: number;
    readonly stateCacheIssued?: number;
    readonly stateCacheSkipped?: number;
    readonly stateCacheProgramSwitches?: number;
    readonly stateCacheTextureBinds?: number;
    readonly stateCacheBufferBinds?: number;
    readonly stateCacheVertexArrayBinds?: number;
    readonly stateCacheSamplerBinds?: number;
    readonly submittedObjects?: number;
    readonly visibleObjects?: number;
    readonly culledObjects?: number;
    readonly frustumTestedObjects?: number;
    readonly postprocessPasses?: number;
    readonly postprocessPassNames?: readonly string[];
    readonly postprocessTargetFormat?: "rgba8" | "rgba16f" | "rgba32f";
    readonly postprocessRenderTargets?: number;
    readonly postprocessTextures?: number;
    readonly postprocessTargetWidth?: number;
    readonly postprocessTargetHeight?: number;
    readonly postprocessPlan?: RendererPostprocessPlanDiagnostics;
    readonly lastError: string | null;
    readonly contextLost: boolean;
}
export interface RenderDevice {
    readonly kind: RenderBackendKind;
    readonly info: RenderDeviceInfo;
    readonly disposed: boolean;
    readonly contextLost: boolean;
    createBuffer(usage: BufferUsage, byteLength: number, initialData?: ArrayBufferView): RenderBuffer;
    updateBuffer(buffer: RenderBuffer, byteOffset: number, data: ArrayBufferView): void;
    readBuffer(buffer: RenderBuffer, byteOffset?: number, byteLength?: number): Uint8Array;
    createShaderProgram(sources: ShaderSources): RenderShaderProgram;
    createRenderTarget(descriptor: RenderTargetDescriptor): RenderTarget;
    setRenderTarget(target: RenderTarget | null): void;
    writeRenderTargetPixels?(target: RenderTarget, pixels: Uint8Array): void;
    presentRenderTarget?(source: RenderTarget): void;
    presentLdrPostprocess?(source: RenderTarget, options: LdrPostprocessPresentationOptions): void;
    readPixels(x: number, y: number, width: number, height: number): Uint8Array;
    readPixelsAsync?(x: number, y: number, width: number, height: number): Promise<Uint8Array>;
    readFloatPixels(x: number, y: number, width: number, height: number): Float32Array;
    readFloatPixelsAsync?(x: number, y: number, width: number, height: number): Promise<Float32Array>;
    readDepthPixels?(x: number, y: number, width: number, height: number): Float32Array;
    beginFrame(width: number, height: number): void;
    clear(color: readonly [number, number, number, number]): void;
    clearRenderTarget?(color: readonly [number, number, number, number]): void;
    draw(command: DrawCommand): void;
    endFrame(): void;
    captureState(): ReadonlyMap<string, string | number | boolean | null>;
    getDiagnostics(): RenderDeviceDiagnostics;
    dispose(): void;
}
export declare class RenderDeviceError extends Error {
    readonly code: string;
    readonly details: Readonly<Record<string, unknown>>;
    constructor(message: string, code: string, details?: Readonly<Record<string, unknown>>);
}
export declare class MockRenderBuffer implements RenderBuffer {
    readonly id: number;
    readonly usage: BufferUsage;
    readonly byteLength: number;
    disposed: boolean;
    readonly bytes: Uint8Array;
    constructor(id: number, usage: BufferUsage, byteLength: number, initialData?: ArrayBufferView);
    dispose(): void;
}
export declare class MockShaderProgram implements RenderShaderProgram {
    readonly id: number;
    readonly label: string;
    readonly marker: string;
    readonly reflection: ShaderReflection;
    disposed: boolean;
    constructor(id: number, label: string, marker: string, reflection: ShaderReflection);
    dispose(): void;
}
export declare class MockRenderTarget implements RenderTarget {
    readonly id: number;
    readonly width: number;
    readonly height: number;
    readonly label: string;
    readonly colorTexture: Texture;
    readonly depthTexture?: Texture | undefined;
    disposed: boolean;
    readonly colorPixels: Uint8Array;
    readonly colorFloatPixels: Float32Array | null;
    readonly depthPixels: Float32Array | null;
    constructor(id: number, width: number, height: number, label: string, colorTexture: Texture, depthTexture?: Texture | undefined);
    dispose(): void;
}
export declare class MockRenderDevice implements RenderDevice {
    readonly kind = "mock";
    readonly info: RenderDeviceInfo;
    disposed: boolean;
    contextLost: boolean;
    readonly drawCommands: DrawCommand[];
    private nextId;
    private buffers;
    private shaders;
    private renderTargets;
    private activeRenderTarget;
    private backbufferPixels;
    private backbufferWidth;
    private backbufferHeight;
    private lastError;
    private frameActive;
    private viewportWidth;
    private viewportHeight;
    private clearColor;
    createBuffer(usage: BufferUsage, byteLength: number, initialData?: ArrayBufferView): RenderBuffer;
    updateBuffer(buffer: RenderBuffer, byteOffset: number, data: ArrayBufferView): void;
    readBuffer(buffer: RenderBuffer, byteOffset?: number, byteLength?: number): Uint8Array;
    createShaderProgram(sources: ShaderSources): RenderShaderProgram;
    createRenderTarget(descriptor: RenderTargetDescriptor): RenderTarget;
    setRenderTarget(target: RenderTarget | null): void;
    writeRenderTargetPixels(target: RenderTarget, pixels: Uint8Array): void;
    presentRenderTarget(source: RenderTarget): void;
    readPixels(x: number, y: number, width: number, height: number): Uint8Array;
    readFloatPixels(x: number, y: number, width: number, height: number): Float32Array;
    readDepthPixels(x: number, y: number, width: number, height: number): Float32Array;
    beginFrame(width: number, height: number): void;
    clear(color: readonly [number, number, number, number]): void;
    clearRenderTarget(color: readonly [number, number, number, number]): void;
    draw(command: DrawCommand): void;
    endFrame(): void;
    captureState(): ReadonlyMap<string, string | number | boolean | null>;
    getDiagnostics(): RenderDeviceDiagnostics;
    dispose(): void;
    private assertAlive;
    private assertFrame;
    private requireMockBuffer;
    private requireMockRenderTarget;
}
export declare function viewBytes(view: ArrayBufferView): Uint8Array;
//# sourceMappingURL=RenderDevice.d.ts.map