[WebGPU] Implement GPUErrors for and relax GPUBuffer validation rules
authorjustin_fan@apple.com <justin_fan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Aug 2019 23:39:38 +0000 (23:39 +0000)
committerjustin_fan@apple.com <justin_fan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Aug 2019 23:39:38 +0000 (23:39 +0000)
commit89825653632f2fac83453f3f547d5b9acf4eb1ce
tree426f71171912419858741dbdd6f909df8f2e9d36
parenta1ce497078bc23514b6945e512f41e98d41ab657
[WebGPU] Implement GPUErrors for and relax GPUBuffer validation rules
https://bugs.webkit.org/show_bug.cgi?id=200852

Reviewed by Dean Jackson.

Source/WebCore:

Fix incorrect usage validation during GPUBuffer creation.
Implement GPUError reporting for GPUBuffer creation and methods.

Test: webgpu/buffer-errors.html

* Modules/webgpu/WebGPUBuffer.cpp:
(WebCore::WebGPUBuffer::create):
(WebCore::WebGPUBuffer::WebGPUBuffer):
(WebCore::WebGPUBuffer::unmap):
(WebCore::WebGPUBuffer::destroy):
(WebCore::WebGPUBuffer::rejectOrRegisterPromiseCallback):
* Modules/webgpu/WebGPUBuffer.h: Now inherits from GPUObjectBase.
* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::WebGPUDevice::createBuffer const):
(WebCore::WebGPUDevice::createBufferMapped const):
* platform/graphics/gpu/GPUBuffer.h: No longer inherits from GPUObjectBase.
* platform/graphics/gpu/GPUObjectBase.h:
(WebCore::GPUObjectBase::errorScopes):
(WebCore::GPUObjectBase::generateError): Deleted.
* platform/graphics/gpu/cocoa/GPUBufferMetal.mm:
(WebCore::GPUBuffer::validateBufferUsage):
(WebCore::GPUBuffer::tryCreate): Alignment issue should be general WebGPU requirement.
(WebCore::GPUBuffer::GPUBuffer):
(WebCore::GPUBuffer::~GPUBuffer): Must do cleanup without generating errors.
(WebCore::GPUBuffer::registerMappingCallback):
(WebCore::GPUBuffer::copyStagingBufferToGPU):
(WebCore::GPUBuffer::unmap):
(WebCore::GPUBuffer::destroy):

LayoutTests:

Add a test to ensure GPUBuffer errors are generated properly.

* webgpu/buffer-errors-expected.txt: Added.
* webgpu/buffer-errors.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249183 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/webgpu/buffer-errors-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/buffer-errors.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WebGPUBuffer.cpp
Source/WebCore/Modules/webgpu/WebGPUBuffer.h
Source/WebCore/Modules/webgpu/WebGPUDevice.cpp
Source/WebCore/platform/graphics/gpu/GPUBuffer.h
Source/WebCore/platform/graphics/gpu/GPUObjectBase.h
Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm