Texture2D.getSampler¶
Summary¶
Texture2D.getSampler returns the current sampler value derived from this Texture2D runtime state.
Syntax¶
Texture2D.getSampler(device: GPUDevice, fallback?: GPUSampler): GPUSampler
const result = texture.getSampler(device, fallback);
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
device |
GPUDevice |
Yes | GPUDevice used to allocate pipelines, buffers, layouts, or textures. |
fallback |
GPUSampler |
No | Fallback sampler returned when preferred sampler creation fails. |
Returns¶
GPUSampler - Result produced by this API call as GPUSampler.
Type Details¶
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const texture = wgpu.texture.create2D({ source: { kind: "url", url: "./albedo.png" }, mipmaps: true });
const device = wgpu.gpu.device;
const fallback = wgpu.gpu.device.createSampler();
const result = texture.getSampler(device, fallback);
console.log(result);