[WebGPU] Map WebGPUBindGroupLayoutBindings from the BindGroupLayoutDescriptor for...
authorjustin_fan@apple.com <justin_fan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jan 2019 21:56:07 +0000 (21:56 +0000)
committerjustin_fan@apple.com <justin_fan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Jan 2019 21:56:07 +0000 (21:56 +0000)
commit109bb93a6c1c27d044ca15e183961e9d06587585
treeb8df8b9bd5eb7fec167f9577b3b9e2bc45f24052
parent4052d7e3ed41b8f57fc72e2b3bfa71a74def560e
[WebGPU] Map WebGPUBindGroupLayoutBindings from the BindGroupLayoutDescriptor for error checking and later referencing
https://bugs.webkit.org/show_bug.cgi?id=193405

Reviewed by Dean Jackson.

Source/WebCore:

When creating a WebGPUBindGroupLayout, cache the WebGPUBindGroupLayoutDescriptor's list of BindGroupLayoutBindings
in a HashMap, keyed by binding number, for quick reference during the WebGPUProgrammablePassEncoder::setBindGroups
implementation to follow. Also add error-checking e.g. detecting duplicate binding numbers in the same WebGPUBindGroupLayout
and non-existent binding numbers when creating the WebGPUBindGroup.

No new tests. BindGroups and BindGroupLayouts reflect the (canonical?) strategy of returning empty
objects upon creation failure and reporting errors elswhere. Since error reporting is not yet implemented,
the error checks aren't testable from LayoutTests right now. Expected behavior unchanged and covered by existing tests.

* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::WebGPUDevice::createBindGroup const):
        Number of bindings must be consistent between bindings and layout bindings.
        BindGroupBindings should only refer to existing BindGroupLayoutBindings.
* platform/graphics/gpu/GPUBindGroup.h:
* platform/graphics/gpu/GPUBindGroupLayout.h:
(WebCore::GPUBindGroupLayout::bindingsMap const): Added. Cache map of BindGroupLayoutBindings.
* platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm: Disallow duplicate binding numbers in BindGroupLayoutBindings.
(WebCore::GPUBindGroupLayout::tryCreate):
(WebCore::GPUBindGroupLayout::GPUBindGroupLayout):

LayoutTests:

Small fixes that do not alter behavior.

* webgpu/bind-groups.html:
* webgpu/pipeline-layouts.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239944 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/webgpu/bind-groups.html
LayoutTests/webgpu/pipeline-layouts.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WebGPUDevice.cpp
Source/WebCore/platform/graphics/gpu/GPUBindGroup.h
Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.h
Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm