copyExternalImageToTexture()에서 HTMLImageElement 및 ImageData 지원
GPUQueue
의 copyExternalImageToTexture()
메서드를 사용하면 소스 이미지, 동영상 또는 캔버스에서 가져온 스냅샷을 지정된 GPUTexture
에 복사할 수 있습니다. 이제 HTMLImageElement
및 ImageData
객체를 소스로 전달할 수 있습니다. 다음 예와 chromium:1471372 문제를 참고하세요.
// Fetch and decode image.
const source = document.createElement("img");
source.src = "my-image.png";
await source.decode();
// Create destination texture.
const size = [source.width, source.height];
const texture = myDevice.createTexture({
size,
format: "rgba8unorm",
usage:
GPUTextureUsage.COPY_DST |
GPUTextureUsage.RENDER_ATTACHMENT |
GPUTextureUsage.TEXTURE_BINDING,
});
// Copies a snapshot taken from the source image into a texture.
myDevice.queue.copyExternalImageToTexture({ source }, { texture }, size);
읽기-쓰기 및 읽기 전용 저장소 텍스처 실험 지원
스토리지 텍스처 바인딩 유형을 사용하면 샘플링 없이 텍스처 읽기를 수행하고 셰이더의 임의의 위치에 저장할 수 있습니다. GPUAdapter
에서 "chromium-experimental-read-write-storage-texture"
기능을 사용할 수 있는 경우 이제 이 기능을 사용하여 GPUDevice
를 요청하고 바인드 그룹 레이아웃을 만들 때 GPUStorageTexture
액세스를 "read-write"
또는 "read-only"
로 설정할 수 있습니다. 이전에는 "write-only"
로 제한되었습니다.
이를 활용하려면 enable chromium_experimental_read_write_storage_texture
를 사용하여 WGSL 코드에서 이 확장 프로그램을 명시적으로 사용 설정해야 합니다. 사용 설정하면 저장소 텍스처에 read_write
및 read
액세스 한정자를 사용할 수 있고, textureLoad()
및 textureStore()
내장 함수가 적절하게 작동하며, 새로운 textureBarrier()
내장 함수를 사용하여 작업 그룹의 텍스처 메모리 액세스를 동기화할 수 있습니다. 다음 예와 issue dawn:1972를 참고하세요.
이 기능은 아직 실험 단계이며 변경될 수 있습니다. 표준화 중이지만 --enable-dawn-features=allow_unsafe_apis
플래그와 함께 Chrome을 실행하여 사용할 수 있도록 하세요.
const feature = "chromium-experimental-read-write-storage-texture";
const adapter = await navigator.gpu.requestAdapter();
if (!adapter.features.has(feature)) {
throw new Error("Read-write storage texture support is not available");
}
// Explicitly request read-write storage texture support.
const device = await adapter.requestDevice({
requiredFeatures: [feature],
});
const bindGroupLayout = device.createBindGroupLayout({
entries: [{
binding: 0,
visibility: GPUShaderStage.COMPUTE,
storageTexture: {
access: "read-write", // <-- New!
format: "r32uint",
},
}],
});
const shaderModule = device.createShaderModule({ code: `
enable chromium_experimental_read_write_storage_texture;
@group(0) @binding(0) var tex : texture_storage_2d<r32uint, read_write>;
@compute @workgroup_size(1, 1)
fn main(@builtin(local_invocation_id) local_id: vec3u) {
var data = textureLoad(tex, vec2i(local_id.xy));
data.x *= 2;
textureStore(tex, vec2i(local_id.xy), data);
}`,
});
// You can now create a compute pipeline with this shader module and
// send the appropriate commands to the GPU.
여명 업데이트
일관성을 위해 webgpu.h C API의 이름이 requiredFeaturesCount
에서 requiredFeatureCount
으로, pipelineStatisticsCount
에서 pipelineStatisticCount
로, colorFormatsCount
에서 colorFormatCount
로 이름이 변경되었습니다. 문제 dawn:146040을 참조하세요.
새 DawnInfo
프로그램 (vulkaninfo와 유사)을 사용하면 전환 스위치, 어댑터, 어댑터 기능 및 어댑터 제한을 나열할 수 있습니다. 여명 samples
빌드 시 사용할 수 있습니다. 다음은 간결성을 위해 크게 다듬은 출력입니다. change dawn:149020을 참조하세요.
./out/Debug/DawnInfo
Toggles
=======
Name: allow_unsafe_apis
Suppresses validation errors on API entry points or parameter combinations
that aren't considered secure yet.
http://crbug.com/1138528
[…]
Adapter
=======
VendorID: 0x106B
Vendor: apple
Architecture: common-3
DeviceID: 0x0000
Name: Apple M1 Pro
Driver description: Metal driver on macOS Version 13.5.1 (Build 22G90)
Adapter Type: discrete GPU
Backend Type: Metal
Power: <undefined>
Features
========
* depth_clip_control
Disable depth clipping of primitives to the clip volume
https://bugs.chromium.org/p/dawn/issues/detail?id=1178
[…]
Adapter Limits
==============
maxTextureDimension1D: 16,384
maxTextureDimension2D: 16,384
[…]
여기에서는 주요 특징 중 일부만 다루었습니다. 전체 커밋 목록을 확인하세요.
WebGPU의 새로운 기능
WebGPU의 새로운 기능 시리즈에서 다룬 모든 사항의 목록
Chrome 125
Chrome 124
Chrome 123
- WGSL에서 DP4a 내장 함수 지원
- WGSL의 제한되지 않은 포인터 매개변수
- WGSL의 복합 요소 역참조를 위한 구문 슈가
- 스텐실 부분과 깊이 측면의 별도의 읽기 전용 상태
- 새벽 업데이트
Chrome 122
Chrome 121
- Android에서 WebGPU 지원
- Windows에서 셰이더 컴파일에 FXC 대신 DXC 사용
- 컴퓨팅 및 렌더 패스의 타임스탬프 쿼리
- 셰이더 모듈의 기본 진입점
- display-p3를 GPUExternalTexture 색공간으로 지원
- 메모리 힙 정보
- 새벽 업데이트
Chrome 120
Chrome 119
Chrome 118
Chrome 117
- 꼭짓점 버퍼 설정 해제
- 바인드 그룹 설정 해제
- 기기 분실 시 비동기 파이프라인 생성에서 발생하는 오류 음소거
- SPIR-V 셰이더 모듈 생성 업데이트
- 개발자 환경 개선
- 자동으로 생성된 레이아웃으로 파이프라인 캐싱
- 새벽 업데이트
Chrome 116
- WebCodecs 통합
- GPU 어댑터에서 기기를 반환함
requestDevice()
importExternalTexture()
가 호출되어도 동영상 재생을 원활하게 유지합니다.- 사양 적합성
- 개발자 환경 개선
- 새벽 업데이트