Commit Graph

219 Commits

Author SHA1 Message Date
Austin Eng bd3f58612f dawn_wire: Move BufferConsumer to it's own file. Unify WIRE_TRY
Bug: dawn:680
Change-Id: I6d57280ab11381649deef51ee7babf5ca73f359b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42340
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-02-25 20:21:25 +00:00
Austin Eng 5eb496b863 Add comment that memberLength for-loop cannot overflow
Bug: dawn:680
Change-Id: I8e256fed58651ff8eb3d7a3f8b30d3b1ef0b3dcd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42400
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-02-24 18:39:31 +00:00
Austin Eng f104fea367 Remove size_t from wire transfer structs
This makes the primitives in the serialized wire protocol
the same across platforms and architectures which is better
for both fuzzing and remoting Dawn.

Commands that used size_t are updated to use uint64_t, and
the server-side implementation checks if conversion to
size_t would narrow.

Bug: dawn:680
Change-Id: Icef9dc11a72699685ed7191c34d6a922b652c887
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41582
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-02-18 22:36:19 +00:00
Austin Eng 51db53fa06 dawn_wire: Harden deserialization routines
- Encapsulate deserialize buffer and size into a DeserializeBuffer
   class. This limits the possible operations so we can be sure
   buffer/size are not manually mutated such that we consume more
   bytes than available.

 - Ensure that memberLength (on deserialization) doesn't narrow (or
   widen). Previously, values were always implicitly cast to size_t.

 - Slight optimization that removes "= nullptr" initialization for
   pointers written by DeserializeBuffer::Read. These
   are always written to on success, so we don't need to initialize
   to nullptr.

Bug: dawn:680
Change-Id: I3779a343e85ff90810707148a952c6ba27cf9d22
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41521
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-02-18 19:28:29 +00:00
Austin Eng b921b7dc9c Guard against overflow when allocating the null terminator
String deserialization requires one more byte than the length
computed from strlen. This CL guards against the case when
length+1 overflows.

Also include a slight optimization to memcpy string contents
instead of using std::copy. It's safe to cast away volatile
qualifiers here since the string data doesn't affect control flow.

Bug: dawn:680
Change-Id: Icaf319ea6c5aedcf0c33d17a0ea7c253f4f249e1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41800
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-02-18 18:45:09 +00:00
Austin Eng 1b31dc0bb2 Add a BufferConsumer primitive for wire [de]serialization
BufferConsumer wraps a buffer pointer and size and exposes a
limited number of operations to get data while decrementing
the remaining available size. This makes it so that code
reading or writing into a buffer cannot easily consume more
bytes than available.

This CL guards against serialization overflows using
BufferConsumer, and it implements GetPtrFromBuffer
(for deserialization) on top of BufferConsumer. A future patch
will make the rest of the deserialization code use BufferConsumer.

Bug: dawn:680
Change-Id: Ic2bd6e7039e83ce70307c2ff47aaca9891c16d91
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41780
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-02-17 22:14:56 +00:00
Brandon Jones 58a471ae25 Add ability to generate typedefs from dawn.json
Can be used to help with deprecation during simple struct renames.

Includes typedefs for VertexAttributeDescriptor -> VertexAttribute and
VertexBufferLayoutDescriptor -> VertexBufferLayout as specified by the
latest RenderPipelineDescriptor changes.

Bug: dawn:642
Change-Id: Iab3d74d179884499540e813b0e66859713031ccb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/40581
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-02-08 19:48:06 +00:00
Austin Eng 7fe5aa2eac Remove deprecated Wire APIs
Bug: dawn:565
Change-Id: I577532347c79e64b418a93551027e89910c3ce68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/40480
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-02-05 23:36:30 +00:00
Austin Eng 05d9e2cde2 Nuke the ClientMatches hack for same-device validation
The wire now supports more than one device, and Chrome is updated
to use the new code path. This fixes same-device validation for
createReadyPipeline.

Bug: dawn:565
Change-Id: Id05001ed1a7e535690c87f535da6f72a0e794c59
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/40460
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-02-05 21:08:44 +00:00
Austin Eng 623d80899b Add a Reserved state for dawn_wire ObjectId allocations
Functions like CreateReadyRenderPipeline reserve an
ObjectId for the pipeline created but the Id can not be
used until the callback is called successfully.

Bug: chromium:1172774, chromium:1172775
Change-Id: I145c0f033a2bde7957d15da2da8b9b19c6520ceb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/39840
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-02-03 23:29:43 +00:00
Austin Eng 9a2174a37c Pass the buffer size into DeserializeWGPUDeviceProperties
This allows deserialization to fail if the buffer is not large enough.
Before, we simply assumed the buffer was at least the size of
WGPUDeviceProperties.

Bug: none
Change-Id: I24e1f84c583f48d4e32c35276e5508e257e9f530
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/39861
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-02-02 04:20:09 +00:00
Austin Eng 65a903bf75 dawn_wire: Gracefully handle all invalid and unknown sTypes
This CL makes the wire gracefully handle all invalid and unknown
sTypes. All unknown sType structs are serialized and deserialized
as the base WGPUChainedStruct with sType Invalid.

Bug: dawn:369, dawn:654
Change-Id: Ia2571df81fc96e2c672d3ea13c03237a2d5fa5c1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/39460
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-02-01 16:48:18 +00:00
Austin Eng cef68bc8b7 dawn_wire: Fix a bug with multiple injected devices
Device child objects were storing an *unstable* pointer to device
specific tracking information. Fix this by moving the tracking
information to a stable heap allocation.

Bug: dawn:565
Change-Id: I00ad72563ac66e29314603e77698718953fcbf15
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38280
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-01-21 23:15:43 +00:00
Austin Eng 8bcde8e394 dawn_wire: Add Reserve/InjectDevice
Now that the wire does enough tracking to prevent a malicious client
from freeing a device before its child objects, and the device is no
longer a "special" object with regard to reference/release, it is
safe to support multiple devices on the wire. The simplest way to
use this in WebGPU (to fix createReadyRenderPipeline validation)
is to add a reserve/inject device API similar to the one we use for
swapchain textures.

Bug: dawn:565
Change-Id: Ie956aff528c5610c9ecc5c189dab2d22185cb572
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37800
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-01-19 19:27:52 +00:00
Austin Eng 8ba0a01d1e Ensure all wire child objects are destroyed before their device
Destroying a device will implicit destroy all its child objects.
Attempting to use a child object after results in a fatal error.

Bug: dawn:384
Change-Id: I43c27c92cacde759be83cca79ac890f41bac3927
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37002
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2021-01-13 20:58:18 +00:00
Austin Eng 5ad5557667 Remove special-casing of device reference/release in the wire
The wire's device is externally owned so reference/release were no-ops.
To unify the code paths, remove the special casing and instead
take an extra ref on the device the wire server is created with. This
is functionally equivalent and will allow both the current wire code,
and the incoming change to allow multiple device/adapter creation to
both work.

This CL also makes it possible for the client to destroy the device
before child objects.
A follow-up CL will mitigate this on the server side.

Bug: dawn:384
Change-Id: Ic5427074469012dccf8689ec95a848e6ba2c1fc2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37001
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-01-13 19:23:48 +00:00
Austin Eng f0d7cc4f5a dawn_wire: Make all objects owned by the client
This removes the logic where the Client owns the Device and the
Device owns all other objects. Ownership should be tracked in
dawn_native either with refcounting or validation to disallow
operations after an object's parent has been destroyed.

This simplifies the wire client code in that the client only
tracks allocated handles and does not manage parent/child lifetimes.
This is an important simplification so we can support multiple WebGPU
instances, adapters, and devices on a single wire.

Bug: dawn:384
Change-Id: I8ecc7c368130b8917202150c467b5f0e7d4b753e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/37000
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-01-13 18:31:47 +00:00
Austin Eng 8d38c0164c Autogenerate all of the wire callback mocks
This makes it less manual code and less error prone to
add new callbacks to the wire.

Bug: dawn:384
Change-Id: I8547af2dba8289d1badd41e53dd732c776fb5d06
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35600
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-12-17 17:59:37 +00:00
Austin Eng a7bb5a5b74 Remove the hardcoded device tick in Server::HandleCommands
This was here to ensure all callbacks return, but this can now
be done by calling device.Tick - which Chromium does
periodically. Remove it now, especially since it will be incorrect
when the wire supports more than one device.

Bug: dawn:384
Change-Id: If948ffe8931be7ba989f733efd64549d0c56b382
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35841
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-12-16 09:37:40 +00:00
Kai Ninomiya cf820d79ef Rename STRIDE_UNDEFINED to COPY_STRIDE_UNDEFINED
Per https://github.com/webgpu-native/webgpu-headers/pull/71

Keeps but deprecates WGPU_STRIDE_UNDEFINED/wgpu::kStrideUndefined.

Bug: dawn:520
Change-Id: Ied162ec39454fac3d16a3782c9ed6d2f68c1d41d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/34926
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Kai Ninomiya <kainino@chromium.org>
2020-12-16 07:53:30 +00:00
Stephen White 03badec5d7 Refactor OpenGLVersion out of OpenGLFunctions.
We need the ability to parse the GL version irrespective of
GL extension handling, so pull it out into its own class.

BUG=dawn:580
Change-Id: I620267146159ba8e4fa8cba5f6ebff57e981add0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33540
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2020-11-23 18:50:42 +00:00
Ivan Murashov 75a1f5234e Remove storage class specifier for the explicit template specialization
According to the http://www.eel.is/c++draft/temp.expl.spec:
An explicit specialization shall not use a storage-class-specifier
other than thread_local.
Clang doesn't claims about it, but GCC does.
An error example for GCC 8.4.0:
gen/third_party/dawn/src/dawn_wire/client/ApiObjects_autogen.h:25:5:
error: explicit template specialization cannot have a storage class

Bug: dawn:384
Change-Id: Iaf86722a943d19c9796a7f112885666ac88f20ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33480
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-11-20 09:38:56 +00:00
Austin Eng b70a5b02e9 Reject all callbacks with DeviceLost on wire client disconnect
When the wire is disconnected, the client will not receive any
messages from the server. We need to manually reject all callbacks.

Bug: dawn:556
Change-Id: Ia03456b3209dbe0e1e54543d344180d11d4c6f1e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31162
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-11-11 21:01:18 +00:00
Austin Eng 3120d5ea0d Track and destroy all child objects on wire client destruction
This is needed so that:
 1. We can support multiple devices in the wire. The device will need
    to know how to destroy its child objects.
 2. The wire needs to be aware of all objects and their in-flight
    callbacks so that it can reject them if the wire is disconnnected.
    A future change will handle this.
 3. Fix leaks of objects on page teardown. When the page is torn down,
    the wire client is destroyed, and we skip calling release() for all
    objects since the object holding the proc table was also destroyed.

Bug: dawn:384, dawn:556

Change-Id: Ie23afe4e515b02e924fcfc2db92b749fd2257c9c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31160
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-11-11 19:46:18 +00:00
Corentin Wallez f2df66fce8 Remove deprecated names of texture formats.
Bug: dawn:22
Change-Id: I380380d3d965e603794123739392dae32b84ab9b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32021
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-11-09 21:19:25 +00:00
Kai Ninomiya 16036cf206 Add WGPU_STRIDE_UNDEFINED and update bytesPerRow/rowsPerImage validation
This makes a nearly one-to-one mapping between the JS and C APIs, which
benefits projects like Blink and Emscripten.

- JavaScript's `undefined` is equivalent to C `WGPU_STRIDE_UNDEFINED`.
- JavaScript's `0` is equivalent to C `0`.
- To implement the API correctly, Blink must special-case an actual
  value coming in from JS that is equal to WGPU_STRIDE_UNDEFINED
  (0xFFFF'FFFF), and inject an error.

Keeps but deprecates a reasonable approximation of the old behavior.

Bug: dawn:520
Change-Id: Ie9c992ffab82830090d0dfc3120731e89cd9691c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31140
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-11-06 13:41:50 +00:00
Corentin Wallez 9d6265bc07 Fix examples when using the wire.
Previously the surface argument of CreateSwapChain was made un-optional
to prevent a compilation error. This broke examples because the
device-compatibility part of the wire would start dereferencing a null
pointer.

Instead of making the surface non-optional, make optional objects not
produce = nullptr for method calls in webgpu_cpp.h.

Bug: dawn:22
Change-Id: Icef357cc2b11ed452c78431dde514e4d497ae159
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31565
Reviewed-by: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-11-04 10:04:17 +00:00
Corentin Wallez b0789fde61 Fix RPDesc::occlusionQuerySet not defaulting to nullptr
The default value for optional object structure members wasn't set
correctly for C++ structures.

Bug: dawn:22
Change-Id: I09e7f3675f6e0b5990ddcf03601b3b91cd25f553
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31200
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-10-29 13:09:12 +00:00
Jiawei Shao 03e1400fce Add the entry point of CreateReadyRenderPipeline
BUG=dawn:529
TEST=dawn_end2end_tests

Change-Id: I42ac0edc77e5b6119eb374da72698fca14596f7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30540
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-10-21 04:37:41 +00:00
Jiawei Shao ae5f950444 Add the entry point of CreateReadyComputePipeline
This patch adds the entry point of CreateReadyComputePipeline in both
dawn_native and dawn_wire.

TODOs:
1. Add more tests in dawn_unittests and dawn_end2end_tests.
2. Put the main logic of creating a pipeline into a separate thread.

BUG=dawn:529
TEST=dawn_end2end_tests

Change-Id: I7edd269a5422a8b85320a7f9173df925decba633
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30060
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-10-19 01:56:08 +00:00
Austin Eng cac0442277 dawn_wire: Support chunked commands
This CL adds support for chunking large commands by first serializing
large commands first into a separate buffer, and then sending the
buffer data chunk by chunk.

This code path is used for large writeBuffer and writeTexture, as well
as the inline memory transfer service for buffer mapping. The transfer
for writeBuffer and writeTexture will be optimized further in Chrome,
and the inline memory transfer service is currently used only in tests.

Bug: chromium:1123861, chromium:951558
Change-Id: I02491a44e653e2383174958d9c3d4a4db6fd7bde
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/28882
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-10-13 22:35:34 +00:00
Austin Eng 16e01affcb Reland "Add a per-thread proc table using thread local storage"
This is a reland of b04a92f01b
with the deletion of a duplicate exported function in dawn_wire that
was causing a compilation failure on Windows.

Original change's description:
> Add a per-thread proc table using thread local storage
>
> In situations where both dawn_wire and dawn_native are used on separate
> threads (Chrome with --single-process or --in-process-gpu), it's
> desirable to have a per-thread proc table so that the WebGPU C++ API can
> still be used. This eliminates classes of bugs with manual
> reference/release errors.
>
> This also changes many of the GetProcs functions to return const
> references to the static proc tables known at compile time, instead of a
> copy.
>
> Bug: none
> Change-Id: I8775bb715b312dd9476a1903fbd797d4b1302614
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/29240
> Reviewed-by: Stephen White <senorblanco@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Commit-Queue: Austin Eng <enga@chromium.org>

Bug: none
Change-Id: Id90e5372132cd93a2f8631c8185d0e71b01bc1af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/29443
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-10-06 16:13:42 +00:00
Kai Ninomiya 326e14f34b Revert "Add a per-thread proc table using thread local storage"
This reverts commit b04a92f01b.

Reason for revert: Build failed on win-archive-dbg; see:
https://chromium-review.googlesource.com/c/chromium/src/+/2450792

Original change's description:
> Add a per-thread proc table using thread local storage
>
> In situations where both dawn_wire and dawn_native are used on separate
> threads (Chrome with --single-process or --in-process-gpu), it's
> desirable to have a per-thread proc table so that the WebGPU C++ API can
> still be used. This eliminates classes of bugs with manual
> reference/release errors.
>
> This also changes many of the GetProcs functions to return const
> references to the static proc tables known at compile time, instead of a
> copy.
>
> Bug: none
> Change-Id: I8775bb715b312dd9476a1903fbd797d4b1302614
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/29240
> Reviewed-by: Stephen White <senorblanco@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Commit-Queue: Austin Eng <enga@chromium.org>

TBR=cwallez@chromium.org,senorblanco@chromium.org,enga@chromium.org

Change-Id: I4587b457b7b2dd5d3c7457065bf4e77b95af59d7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: none
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/29442
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-10-05 22:35:40 +00:00
Austin Eng b04a92f01b Add a per-thread proc table using thread local storage
In situations where both dawn_wire and dawn_native are used on separate
threads (Chrome with --single-process or --in-process-gpu), it's
desirable to have a per-thread proc table so that the WebGPU C++ API can
still be used. This eliminates classes of bugs with manual
reference/release errors.

This also changes many of the GetProcs functions to return const
references to the static proc tables known at compile time, instead of a
copy.

Bug: none
Change-Id: I8775bb715b312dd9476a1903fbd797d4b1302614
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/29240
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-10-05 19:53:58 +00:00
Corentin Wallez 498d5ea20a Rename BC6HRGBSfloat to BC6HRGBFloat
Bug: dawn:22
Change-Id: Ib579e15ff923cbd7c4f523a58c2ef582d39ba7c4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/27200
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-09-10 08:48:57 +00:00
Corentin Wallez f7123d7463 Remove MapRead/WriteAsync and CreateBufferMapped
Bug: dawn:445

Change-Id: I0b0755b6bb754d1fff99aa59b08362f89950e300
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26301
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-08-20 14:22:29 +00:00
Corentin Wallez 2f6e4ec6c0 Add wgpu::TextureFormat::RGB9E5Ufloat
Also update RG11B10Float to be name RG11B10Ufloat

Bug: dawn:22

Change-Id: I0ea76dc25c37ebaeb4c2c2c2a119d00940acc145
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25760
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-08-19 21:51:20 +00:00
Kai Ninomiya 05863e62f3 Niceify formatting in webgpu_cpp
Since now there's a copy (slightly hand-modified) saved into
Emscripten: https://github.com/emscripten-core/emscripten/pull/11737

Bug: None
Change-Id: I2677400f9e69a7fcd71f89bdaa04c642be357151
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26005
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-07-30 19:02:43 +00:00
Kai Ninomiya 01aeca22a9 Add .clang-format files and format more files
The .clang-format files tell clang-format to ignore certain directories
(replacing code in lint_clang_format.sh which will be removed).

$ git ls-tree -r master --name-only | grep '\.\(c\|h\|cpp\|gn\|gni\|mm\|m\|py\)$' | xargs ./append-space-to-files
$ git checkout -- generator/templates third_party/khronos/{KHR,vulkan}
$ git cl format --full --python

Followed by manual reformatting of a few things in Python for
readability.

Bug: none
Change-Id: I4c9e472cc9a5cd80c07286e808f4e597cfef5428
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24785
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-07-15 19:51:17 +00:00
Kai Ninomiya 9da11c990f Fixes for Emscripten generators
Bug: none
Change-Id: I9b4f7843e2b401776a868d33335a9df027c13511
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24881
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-07-15 08:57:49 +00:00
Corentin Wallez 0d52f800a1 Implement Buffer::MapAsync
MapAsync in dawn_native is fully implemented and only missing
a couple cleanups that can be done once MapRead/WriteAsync are
removed.

MapAsync in dawn_wire is left as a pure shim on top of
MapRead/WriteAsync and will be transitioned to its own commands
in follow-ups.

All MapRead/WriteAsync end2end and validation tests are duplicated
for MapAsync.

Bug: dawn:445

Change-Id: Ib1430b9257149917be19a84f13e0ddd2a8eccc32
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24260
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2020-07-14 12:30:14 +00:00
Corentin Wallez 00d6215be9 dawn_wire/client: Add ToAPI and FromAPI helpers.
In the client code, we often need to translate between WGPUObject (the
API type) to Object* (the internal client type). This added a bunch of
reinterpret_casts that make the code less readable and more fragile.

This CL adds FromAPI and ToAPI helpers in the autogenerated
ApiObjects_autogen.h header, that convert between API and internal types
in a type-safe way.

Bug: dawn:445

Change-Id: Ia1bf624f0315ced496b95cb660adf88abd916d71
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24063
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-30 18:39:50 +00:00
Corentin Wallez 2f616dd108 dawn_wire: Remove client/ApiProcs_autogen.h
This header was only used to call DeviceCreateErrorBuffer and
DeviceInjectError that are used in some handwritten client commands.
We remove the need for the header by making these two commands
handwritten.

This also improves readability, previously injecting errors read:

  ClientDeviceInjectError(reinterpret_cast<WGPUDevice>(device),
                           WGPUErrorType_Validation,
                           "Some validation message");

And now reads:

  device->InjectError(WGPUErrorType_Validation, "Some validation message");

Bug: dawn:445

Change-Id: Ie11570aacf3036e13abd174d91670ecb84661226
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24080
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-30 18:26:30 +00:00
Corentin Wallez d411726003 dawn_wire: Make ApiProcs call into objects directly.
This CL modifies code generation so that the generated client procs call
the handwritten methods on client objects directly.

Previously the flow was:
  - wgpuBarDoStuff
  - ClientBarDoStuff
  - ClientHandwrittenBarDoStuff
  - client::Bar::DoStuff

With this CL the flow is:
  - wgpuBarDoStuff
  - ClientBarDoStuff
  - client::Bar::DoStuff

This required adding Buffer creation methods on client::Device instead
of calling client::Buffer static methods directly.

Bug: dawn:445

Change-Id: I1b332b71ac7a03685afcf8fd0617d3d27da468cf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24062
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-06-30 18:01:50 +00:00
Corentin Wallez 90abd47a28 dawn_wire: Factor the common command serialization pattern.
Bug: dawn:445

Change-Id: I15a99a126c0494fd06dd727ff5c9008cde675d76
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23560
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-06-19 16:49:43 +00:00
Corentin Wallez 84ae2bfe3b Remove deprecated "Binding" types and members
This removes the following types and members as well as fixup code
and depraction tests for them:

 - wgpu::BindGroupLayoutBinding
 - wgpu::BindGroupLayoutDescriptor::bindingCount
 - wgpu::BindGroupLayoutDescriptor::bindings
 - wgpu::BindGroupBinding
 - wgpu::BindGroupDescriptor::bindingCount
 - wgpu::BindGroupDescriptor::bindings

Bug: dawn:22
Change-Id: Ifc0e25107f3dcfbb850624cb362909f38c90bec2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/21680
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-05-13 17:05:55 +00:00
Corentin Wallez 00b90ea832 Enable more warning needed for Skia to build with Dawn on Linux
The new warnings are:

 - -Wdeprecated-copy
 - -Winvalid-offsetof
 - -Wpessimizing-move

And the list of warnings was sorted alphabetically.

Bug: chromium:1072449
Change-Id: I9f3eecae645455c481ecc2e0be4df350e1453907
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/20381
Reviewed-by: Zhenyao Mo <zmo@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-04-24 17:02:53 +00:00
Corentin Wallez 3741f7373c Factor compilation of ~MockProcTable in mock_webgpu.cpp
GMock generates a lot of code in the destuctor of mock classes, so
factor that in mock_webgpu.cpp instead of compiling the code once for
each file including mock_webgpu.h.

Bug: None
Change-Id: I2b5984e911020eb33457bde9c6a45beaa93b3071
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19725
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-04-16 18:08:23 +00:00
Corentin Wallez f941205370 Use new gmock MOCK_FUNCTION macro.
Bug: None
Change-Id: If436fbf5c2392051caeadfc4a7482544d565b597
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19720
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-04-16 16:39:06 +00:00
Austin Eng ba72944d3d dawn_wire: Validate all objects are from the same device in the client
This is a temporary fix until dawn_wire can support multiple devices.
When using objects from different devices, the wire will inject an
error into the receiver object's device. Methods that return objects
will return a dummy object. Using the dummy object will cause a fatal
error on the server.

Without this fix, the server would blindly lookup an ObjectId which
could point to some other object. This would bypass same-device
validation and have incorrect results.

Bug: dawn:383
Change-Id: I898f07d4b26f2a97ef952b82af488e7f807c36f0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19261
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-04-15 17:58:25 +00:00