UNPKG

typegpu

Version:

A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.

106 lines (105 loc) 4.27 kB
import { $internal, $repr } from '../shared/symbols.ts'; import type { BaseData } from './wgslTypes.ts'; export interface WgslSamplerProps { addressModeU?: GPUAddressMode; addressModeV?: GPUAddressMode; /** * Specifies the address modes for the texture width, height, and depth * coordinates, respectively. */ addressModeW?: GPUAddressMode; /** * Specifies the sampling behavior when the sample footprint is smaller than or equal to one * texel. */ magFilter?: GPUFilterMode; /** * Specifies the sampling behavior when the sample footprint is larger than one texel. */ minFilter?: GPUFilterMode; /** * Specifies behavior for sampling between mipmap levels. */ mipmapFilter?: GPUMipmapFilterMode; lodMinClamp?: number; /** * Specifies the minimum and maximum levels of detail, respectively, used internally when * sampling a texture. */ lodMaxClamp?: number; /** * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is * enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it. * Anisotropic filtering improves the image quality of textures sampled at oblique viewing * angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of * anisotropy supported when filtering. * * Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy} * will be clamped to the maximum value that the platform supports. * The precise filtering behavior is implementation-dependent. */ maxAnisotropy?: number; } export interface WgslComparisonSamplerProps { compare: GPUCompareFunction; addressModeU?: GPUAddressMode; addressModeV?: GPUAddressMode; /** * Specifies the address modes for the texture width, height, and depth * coordinates, respectively. */ addressModeW?: GPUAddressMode; /** * Specifies the sampling behavior when the sample footprint is smaller than or equal to one * texel. */ magFilter?: GPUFilterMode; /** * Specifies the sampling behavior when the sample footprint is larger than one texel. */ minFilter?: GPUFilterMode; /** * Specifies behavior for sampling between mipmap levels. */ mipmapFilter?: GPUMipmapFilterMode; lodMinClamp?: number; /** * Specifies the minimum and maximum levels of detail, respectively, used internally when * sampling a texture. */ lodMaxClamp?: number; /** * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is * enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it. * Anisotropic filtering improves the image quality of textures sampled at oblique viewing * angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of * anisotropy supported when filtering. * * Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy} * will be clamped to the maximum value that the platform supports. * The precise filtering behavior is implementation-dependent. */ maxAnisotropy?: number; } export interface sampler { [$internal]: true; type: 'sampler'; } export declare function sampler(): WgslSampler; export interface comparisonSampler { [$internal]: Record<string, never>; type: 'sampler_comparison'; } export declare function comparisonSampler(): WgslComparisonSampler; export interface WgslSampler extends BaseData { readonly [$repr]: sampler; readonly type: 'sampler'; } export interface WgslComparisonSampler extends BaseData { readonly [$repr]: comparisonSampler; readonly type: 'sampler_comparison'; } export declare function isWgslSampler(value: unknown): value is WgslSampler; export declare function isWgslComparisonSampler(value: unknown): value is WgslComparisonSampler;