WebGPU의 새로운 기능 (Chrome 130)

François Beaufort
François Beaufort

이중 소스 혼합

두 프래그먼트 셰이더 출력을 단일 프레임버퍼로 결합하는 것을 이중 소스 블렌딩이라고 합니다. 이 기법은 Porter-Duff 혼합 모드를 기반으로 하는 애플리케이션과 같이 복잡한 혼합 작업이 필요한 애플리케이션에 특히 유용합니다. 후속 렌더링 패스를 단일 렌더링 패스로 대체하면 이중 소스 혼합으로 성능과 유연성을 향상할 수 있습니다.

새로운 "dual-source-blending" WebGPU 기능을 사용하면 @location(0)에서 WGSL @blend_src 속성을 사용하여 혼합 소스 색인과 다음 혼합 요소("src1", "one-minus-src1", "src1-alpha", "one-minus-src1-alpha")를 나타낼 수 있습니다. 다음 스니펫, chromestatus 항목, 문제 341973423을 참고하세요.

const adapter = await navigator.gpu.requestAdapter();
if (!adapter.features.has("dual-source-blending")) {
  throw new Error("Dual source blending support is not available");
}
// Explicitly request dual source blending support.
const device = await adapter.requestDevice({
  requiredFeatures: ["dual-source-blending"],
});

const code = `
  enable dual_source_blending;

  struct FragOut {
    @location(0) @blend_src(0) color : vec4f,
    @location(0) @blend_src(1) blend : vec4f,
  }

  @fragment fn main() -> FragOut {
    var output : FragOut;
    output.color = vec4f(1.0, 1.0, 1.0, 1.0);
    output.blend = vec4f(0.5, 0.5, 0.5, 0.5);
    return output;
  }
`;

const shaderModule = device.createShaderModule({ code });
// Create a render pipeline with this shader module
// and run the shader on the GPU...

Metal의 셰이더 컴파일 시간 개선

Chrome팀은 Metal 백엔드로 WebGPU를 지원하는 기기를 위해 중간 표현 (IR)을 도입하여 WebGPU 셰이더 언어 컴파일러인 Tint를 개선하고 있습니다. Tint의 추상 구문 트리 (AST)와 Metal 백엔드 작성기 사이에 위치한 이 IR은 컴파일러의 효율성과 유지관리성을 높여 궁극적으로 개발자와 사용자 모두에게 이점을 제공합니다. 초기 테스트 결과 Unity의 WGSL 셰이더를 MSL로 변환할 때 새로운 버전의 Tint가 최대 10배 더 빠른 것으로 나타났습니다.

WGSL 셰이더 코드를 하위 수준 GPU 명령어로 변환하는 프로세스를 보여주는 순서도
macOS에서 렌더링 파이프라인 생성

Android 및 ChromeOS에서 이미 사용할 수 있는 이러한 개선사항은 Metal 백엔드로 WebGPU를 지원하는 macOS 기기로 점진적으로 확대되고 있습니다. 문제 42251016을 참고하세요.

GPUAdapter requestAdapterInfo() 지원 중단

개발자는 GPUAdapter info 속성을 사용하여 동기식으로 GPUAdapterInfo를 이미 가져올 수 있으므로 GPUAdapter requestAdapterInfo() 비동기 메서드는 중복됩니다. 따라서 비표준 GPUAdapter requestAdapterInfo() 메서드는 이제 지원 중단됩니다. 지원 중단 의도를 참고하세요.

DevTools 콘솔에 requestAdapterInfo()의 지원 중단 경고가 표시됩니다.
Chrome DevTools에서 requestAdapterInfo()의 지원 중단된 기능 경고

새벽 업데이트

webgpu.h C API는 확장 프로그램 구조체에 대해 몇 가지 이름 지정 규칙을 정의했습니다. 다음 이름 변경사항과 문제 42241174를 참고하세요.

광고 확장 WGPURenderPassDescriptor
WGPURenderPassDescriptorMaxDrawCount -> WGPURenderPassMaxDrawCount
광고 확장 WGPUShaderModuleDescriptor
WGPUShaderModuleSPIRVDescriptor -> WGPUShaderSourceSPIRV
WGPUShaderModuleWGSLDescriptor -> WGPUShaderSourceWGSL
광고 확장 WGPUSurfaceDescriptor
WGPUSurfaceDescriptorFromMetalLayer -> WGPUSurfaceSourceMetalLayer
WGPUSurfaceDescriptorFromWindowsHWND -> WGPUSurfaceSourceWindowsHWND
WGPUSurfaceDescriptorFromXlibWindow -> WGPUSurfaceSourceXlibWindow
WGPUSurfaceDescriptorFromWaylandSurface -> WGPUSurfaceSourceWaylandSurface
WGPUSurfaceDescriptorFromAndroidNativeWindow -> WGPUSurfaceSourceAndroidNativeWindow
WGPUSurfaceDescriptorFromXcbWindow -> WGPUSurfaceSourceXCBWindow
WGPUSurfaceDescriptorFromCanvasHTMLSelector -> WGPUSurfaceSourceCanvasHTMLSelector_Emscripten

WGPUDepthStencilStatedepthWriteEnabled 속성 유형이 JavaScript API와 마찬가지로 가능한 세 가지 상태 (true, false, undefined)를 더 잘 반영하도록 불리언에서 WGPUOptionalBool로 전환됩니다. 자세한 내용은 다음 코드 스니펫과 webgpu-headers PR을 참고하세요.

wgpu::DepthStencilState depthStencilState = {};
depthStencilState.depthWriteEnabled = wgpu::OptionalBool::True; // Undefined by default

여기에서는 몇 가지 주요 사항만 다룹니다. 전체 커밋 목록을 확인하세요.

WebGPU의 새로운 기능

WebGPU의 새로운 기능 시리즈에서 다룬 모든 항목의 목록입니다.

Chrome 140

Chrome 139

Chrome 138

Chrome 137

Chrome 136

Chrome 135

Chrome 134

Chrome 133

Chrome 132

Chrome 131

Chrome 130

Chrome 129

Chrome 128

Chrome 127

Chrome 126

Chrome 125

Chrome 124

Chrome 123

Chrome 122

Chrome 121

Chrome 120

Chrome 119

Chrome 118

Chrome 117

Chrome 116

Chrome 115

Chrome 114

Chrome 113