Commit Graph

402 Commits

Author SHA1 Message Date
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
dan sinclair e8022eaf59 Skip None paths when looking for modules
Change-Id: I49fb38b56f868a730b622e20cf8d5781f13fe5e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30580
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-10-20 14:46:10 +00:00
Corentin Wallez e557087870 CMakeLists: make DAWN_THIRD_PARTY_DIR an option.
Also output more context when failing to run the code generator.

Bug: None
Change-Id: I6685c062a074ad11a8fd67f19b8698ce9bcf6694
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/30560
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-20 14:26:10 +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 59382b7d3f Use python3 for all of Dawn's python scripts
Bug: dawn:389
Change-Id: I5034ab2791f0cca0b7690eae5f4d7f4e6efc4bd9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19863
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-04-17 20:43:07 +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
Corentin Wallez 0ff7ed41ec Remove CreateBufferMappedAsync
The upstream WebGPU spec decided to not pursue CreateBufferMappedAsync,
and it adds some complexity to Dawn, so we remove it.

Bug: dawn:22
Change-Id: I4182a90c4a1aa0bfbaecd7d8f67d7049cf5df5d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/17321
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-04-15 13:53:15 +00:00
Austin Eng 518c8e77ab Cleanup: Rename dawn_wire Object "serial" to "generation"
This is a more accurate name and conflicts less with the callback
request serials.

Bug: none
Change-Id: I0f9660c24468064dadffb3ab9b3392d403f93c41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19260
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2020-04-13 17:50:51 +00:00
Zhenyao Mo 5b7292c8f8 Fix more compilation warnings.
Bug: chromium:1064305
Change-Id: I3aac24f8179d2c9e5206dd4542ea2506f26755e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19301
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@google.com>
2020-04-11 03:22:33 +00:00
Corentin Wallez ce100347eb Fix a -Wstrict-prototypes
Bug: chromium:1064305
Change-Id: I06c5feb2f43e00d4991a8a244175d79b8ad987d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18962
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-04-07 16:09:27 +00:00
Corentin Wallez c3c6694d8f Rename BG[L]Binding to BG[L]Entry
This is to match the WebGPU API change.

The only manual changes are in dawn.json and templates. The rest was
created with the following commands:

  git grep -l BindGroupLayoutBinding | xargs sed -i "" -e "s/BindGroupLayoutBinding/BindGroupLayoutEntry/g"
  git grep -l BindGroupBinding | xargs sed -i "" -e "s/BindGroupBinding/BindGroupEntry/g"
  git cl format

Bug: dawn:22
Change-Id: I1377eef9ea9816578441c91d167909dedc7f8e96
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18863
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-04-07 07:11:12 +00:00
Austin Eng 76a8d0b92f Support chained extension structs on the wire
This CL also adds a couple of dummy extensions in dawn.json so that
the serialization/deserialization in the wire can be tested.

Bug: dawn:369
Change-Id: I5ec3853c286f45d9b04e8bf9d04ebd9176dc917b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18520
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-04-03 17:37:48 +00:00
Corentin Wallez a0afd31585 Separate device lost from internal errors.
The effect to the user is the same, the Dawn device gets lost. However
we need to make the difference internally because when the backend
device is lost we can clean up immediately. On the contrary on internal
errors, the backend device is still alive and processing commands so we
need to gracefully shut it down.

Bug: dawn:269

Change-Id: Ie13b33a4f9ac2e1f5f98b3723d83cf1c6205c988
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/17965
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-04-01 12:07:43 +00:00
Corentin Wallez e51f8dd09a Fix compilation with stdlibc++ (instead of libc++)
Also fixes some warnings when compiling with GCC

Bug: dawn:333
Change-Id: Ib597bb3b950476279a1e20e3556765ec9f1db697
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15960
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-02-18 02:44:05 +00:00
Corentin Wallez 713d9cbf93 webgpu.h: Fix WGPU_WHOLE_SIZE causing linking errors.
The symbol was not marked as static and would cause linking errors
because it would be defined in multiple translation units. Replace it
with a more traditional C-style #define.

Bug:
Change-Id: I19151884b7e8e171f829ffa47b1d119aff12ff99
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15740
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-02-10 20:25:36 +00:00
Corentin Wallez 7fe6efba4a Add initial CMakeLists.txt files
Adds CMake support for:
 - Generating the Dawn headers and C++ wrappers
 - libdawn_wire
 - libdawn_native with the Metal backend for now
 - All the examples.

Bug: dawn:333

Change-Id: I6ffbe090b0bd21d6a805c03a507ad51fda0275ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15720
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2020-02-05 17:16:05 +00:00
Reid Kleckner 48e7da791f Use dict.items() instead of dict.iteritems() for py3 compat
iteritems() went away in Python 3.

R=kainino@chromium.org

Bug: 941669
Change-Id: I0c107aaa35bb1df7c126485c33c3d15cb77f03fe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15560
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-01-30 01:25:08 +00:00
Kai Ninomiya 7b6246a2ad Generators for Emscripten
api_struct_info.json:
//* This generator is used to produce part of Emscripten's struct_info.json,
//* which is a list of struct fields that it uses to generate field offset
//* information for its own code generators.
//* https://github.com/emscripten-core/emscripten/blob/master/src/struct_info.json

library_webgpu_enum_tables.js:
//* This generator is used to produce the number-to-string mappings for
//* Emscripten's library_webgpu.js.
//* https://github.com/emscripten-core/emscripten/blob/master/src/library_webgpu.js

Change-Id: I4704509737cde4685a093eb484dd977e5a106d19
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15240
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2020-01-28 23:54:38 +00:00
Corentin Wallez 13e2e139a5 Update WGPUChainedStruct usage to match webgpu.h
In the webgpu-headers PR it was decided that in the C header
WGPUChainedStruct would be included as a member instead of members being
inlined.

See https://github.com/webgpu-native/webgpu-headers/pull/30

Bug: dawn:160
Change-Id: I8caf91f3106578077c80778621a632411da44423
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15441
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-01-25 09:30:40 +00:00
Corentin Wallez 1bf3167ce6 Add a proper license to webgpu.h's template.
This avoids linter checks to trigger when importing updates of Dawn into
Google3.

Bug:
Change-Id: Ib038d8937cc6c294823b56d52b6f2c5e5e24ffac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15140
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2020-01-15 15:39:12 +00:00
Corentin Wallez 3a1746e71c Introduce wgpu::Surface and implement it for HWND, X11 and Metal
This is another step to implement webgpu.h swapchains, Surface is
essentially a union type of all the types of windows that can be used to
create swapchains.

Changes to allow implementing wgpu::Surface and test its creation are:

 - Add GLFWUtils.cpp/.h/_metal.mm  that contains helpers used to use
WebGPU with GLFW. This deprecates BackendBinding.h that will be removed
when the NXT swapchain is removed.
 - Add a `dawn_use_x11` GN variable to factor all the places in BUILD.gn
where we checked whether we should use X11.
 - Add a `supports_glfw_for_windowing` GN variable in the main BUILD.gn
file to control which configuration tests and samples using GLFW can be
built.
 - Add a ObjCUtils.h to contain some ObjC functionality that we'd need
in files that otherwise would be C++ (so that they can be compiled on
all platforms).

Bug: dawn:269

Change-Id: I25548142a1d1d1f05b0f4d71aa3bdc4698d19622
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15081
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-01-15 13:14:12 +00:00
Corentin Wallez 2b24c3d92d webgpu.h introduce a base struct for extension structures.
struct WGPUChainedStruct {
     WGPUChainedStruct const * nextInChain;
     WGPUSType sType;
 };

And changes all the nextInChain to point to such structures. This adds
more type safety to extension structs and requires less casting to check
sTypes and friends.

Bug: dawn:269

Change-Id: I443f363cdb55dbec7c7f6e897245d4a7ea0ebe70
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15080
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-01-15 09:54:42 +00:00
Corentin Wallez 5fc2c82c11 Add Instance and CreateInstance to webgpu.h
This is the first step in making the API before WGPUDevice creation
match webgpu.h and is necessary to implement WGPUSwapChain.

BUG=dawn:269

Change-Id: If92ced42d7683d79e67c02738949ff8b483d22c4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14061
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2020-01-10 13:06:48 +00:00
Natasha Lee 9bba4a936e Add DeviceLostCallback to dawn.json and dawn_wire
Bug: dawn:68
Change-Id: I6d8dd071be4ec612c67245bfde218e31e7a998b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14660
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-12-18 18:59:20 +00:00
Corentin Wallez 84d836295e Remove generation of proxy dawn.h and dawncpp.h
BUG=dawn:22

Change-Id: Iee8b93fddf2f4aced72bb12062ffae6dddc336ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14260
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-12-06 08:34:49 +00:00
Corentin Wallez 20c014cee7 Fix typo in the name of wgpuGetProcAddress
BUG=dawn:22

Change-Id: Id8213f1d06313d0ab1ee5845e892f88ff803fbc2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14060
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-11-26 17:28:11 +00:00
Austin Eng f6eb890f4c Implement getBindGroupLayout
This patch makes the |layout| member of the Render|ComputePipelineDescriptor
optional. If it is not provided, a default layout is created from the
ShaderModules provided and used to replace the layout in the descriptor.

Then, pipeline.GetBindGroupLayout may be called to get the existing, or
the computed bind group layout. If no bind group layout exists at the
provided index, an empty bind group layout is returned.

Bug: dawn:276
Change-Id: I276ed0296a2f1f2d8131fa906a4aefe85d75b3a7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13741
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2019-11-22 17:02:22 +00:00
Corentin Wallez aca8c4a528 Remove the concept of "native_methods" in the generators
This was used to make the distinction between native-only methods that
were those manipulating "natively defined" types, and the rest. Now that
all "natively defined" objects are "callback" instead this name didn't
make sense.

The only relevant thing is that in C there are the Reference and Release
methods that don't appear in dawn.json and shouldn't be exposed on C++
objects. Hence most of the native_methods() calls in the templates are
updated to be c_methods() calls except for the webgpu_cpp templates that
use type.methods directly.

BUG=dawn:22

Change-Id: I65c160b8b8a829e4728862c65bc67268a46f445e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13902
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2019-11-22 14:02:52 +00:00
Corentin Wallez 540ababb6b Introduce a "callback" type in dawn.json
This replaces all instances of "natively defined" with callbacks and
adds information about the callbacks arguments so that their typedefs
can be autogenerated in dawn.json.

Also adds all the methods using callbacks to the list of handwritten
client commands so that the wire templates don't try to generate code
for them.

BUG=dawn:22

Change-Id: I30ce01e3e688a16b31efa74d0c94ebafdca00985
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13901
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2019-11-22 13:18:22 +00:00
Corentin Wallez 321c12255e Remove the "Base" from pure-frontend dawn_native types
This was unnecessary verbosity. Fix this by having the ProcTable
generator using type aliases so all types appear like they have
"Base".

BUG=

Change-Id: I8c472fb924f6ce739e4e41038452381b4f727a2b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13442
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-11-13 17:00:37 +00:00
Corentin Wallez 45b51f5df7 Make unittests and fuzzers use webgpu.h
BUG=dawn:22

Change-Id: Iff5465ad7a9456f9c6b2ee380af748b3afc129b7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12741
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-28 22:15:47 +00:00
Corentin Wallez 9f90c8d3ca Make dawn_native public headers and dawn_wsi use webgpu.h
BUG=dawn:22

Change-Id: I112d71323c9305fa0997d251556fe0a41dafed29
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12701
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-24 23:55:37 +00:00
Corentin Wallez 1fdcb16b69 Make dawn_wire use the webgpu.h header
BUG=dawn:22

Change-Id: I4963aa27322086e74947a1a6265c921e2c7d3d85
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12700
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-24 22:27:27 +00:00
Corentin Wallez 1f6c8c4d54 Make dawn_native use the webgpu.h header
BUG=dawn:22

Change-Id: I66e2d998f5e09030e40ec88813cd65c492018fd0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12541
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-23 11:57:41 +00:00
Corentin Wallez 2c8b5c6370 Introduce the webgpu[_cpp].h headers.
webgpu.h is the "official" header for WebGPU in native and is being
developed in https://github.com/webgpu-native/webgpu-headers

dawn.h and dawncpp.h are changed to become webgpu.h and webgpu_cpp.h
respectively and use the new naming convention. New dawn.h and dawncpp.h
headers are created that just proxy the types, constants and functions
to their WebGPU counterpart.

Almost no naming change is done in Dawn in this commit, which help check
that the proxying headers work correctly. A couple changes were
necessary, in particular for tests of the internal of dawncpp.h, and a
workaround for a standard library bug for std::underlying_type was
removed because it is no longer needed and got in the way.

Finally since some templates were renamed to match the name of the file
they create instead of using the generic "api" name.

BUG=dawn:22

Change-Id: I12ee22d0b02ccb5b8a52ceccabb3e63ce74da007
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12480
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-21 20:04:10 +00:00
Jiawei Shao 5c2f5f3961 Implement serialization/deserialization of DawnDeviceProperties
This patch implements the serialization and deserialization of
DawnDeviceProperties in dawn_wire for the use of serializing this type
of object in Chromium.

BUG=chromium:996713
TEST=dawn_unittests

Change-Id: I1678627a017079540689d8529a1a7e1c975aae61
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12240
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-20 03:01:56 +00:00
Corentin Wallez 919812ed1c Use webgpu.h's bitmask type definitions.
BUG=dawn:22

Change-Id: Ib7cf75a1411a6ed86cc5abb1218beb924dbb9001
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12260
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-17 08:46:07 +00:00
Stephen White f104ec23bc Fix missing #include.
BUG=

Change-Id: I2e659e9f86ef4757915aeb07ec96a83ea904cb1c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12340
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-16 15:36:12 +00:00
Corentin Wallez e180b591d1 Fix compilation with shared_library components on Windows
An exported function of libdawn_native wasn't in libdawn_native_sources
instead of libdawn_native which made it not exported on Windows.

BUG=dawn:22

Change-Id: I824f1d4af18f8308b88e1650837cbe62374ace72
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12320
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-16 15:31:31 +00:00
Austin Eng cc071e45bb Split generation of dawncpp headers from libdawncpp
libdawn_native also requires the dawncpp headers. When we separated
libdawn_cpp from the dawn_headers, libdawn_native lost the cpp headers
and caused a compile failure. This patch separates the dawncpp headers
as a separate target so both libdawncpp and libdawn_native can depend
on them.

Bug: dawn:22
Change-Id: I4172f1654377afac8c4314123ee8b5b81dc7c928
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12300
Reviewed-by: David Turner <digit@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-16 10:26:01 +00:00
Corentin Wallez c57b180208 Add dawnGetProcAddress.
This will become wgpuGetProcAddress that is part of the webgpu.h and the
last gap in functionality for dawn.h to match webgpu.h.

BUG=dawn:22

Change-Id: I0dcb3b5e6bd99cb10db273fc101d3ec0161b7da0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12120
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-10-15 12:08:48 +00:00
Corentin Wallez 96496828a0 Split the libdawn target in components with a single purpose.
The functionality of the dawn_headers and libdawn targets are split into
the following targets:

 - dawn_headers: the new version only exposes the "dawn.h" C API and no
   longer includes the C++ API.
 - dawncpp: the header and implementation of the C++ API that wraps the
   C API. This is unbundled from the rest so the C++ API can be used
   with libdawn_proc or other libraries implementing the C API.
 - libdawn_proc: A DawnProcTable-backend implementation of the C API.

This is needed because in follow-up commit there will be three libraries
implementing the C API: libdawn_proc that trampolines where we want, and
libdawn_native/wire that don't have trampolines for better perf.

BUG=dawn:22

Change-Id: I5d941f0d98e5a4b633e14d67eb5269f7924f0647
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12160
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-10-15 11:44:38 +00:00
Austin Eng b0cdf95213 Fix compilation with MSVC of volatile assignment operator
Bug: dawn:230
Change-Id: Ie6e4ddf52132a6980d86c9d80524385b51d9d0d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12200
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-15 07:30:35 +00:00
Corentin Wallez 97231682d0 Make dawn.h closer to webgpu.h
This includes several changes to make dawn.h closer to webgpu.h (apart
from the renames and copyright changes):

 - Make nextInChain follow the same type convention as the rest of the
   header.
 - Add defines that allow skipping the procs definition or the functions
   declaration part of the header.
 - Sort the methods by name for each object.
 - Put the callback definition inside extern "C"
 - Make the enums typedef have the name of the enum twice.

BUG=dawn:22

Change-Id: I36e4587d60ca43886636ebd19d54752004f4696d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11903
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-10-08 07:38:01 +00:00
Austin Eng 8eb8385e2e dawn_wire: Tag deserialize commands with volatile pointer
This prevents bugs where the compiler assumes a piece of memory
will be the same if read from twice.

Bug: dawn:230
Change-Id: Ib3358e56b6cf8f1fbf449c5d564ef85c969d695b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11840
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-10-07 20:38:47 +00:00
Austin Eng 4379e8f34f dawn_wire: Only generate has_member for optional members
We were generating has_member for all pointer members which meant
it was possible to incorrectly pass nullptr for required arguments.

Bug: chromium:1009166
Change-Id: I5e32bab5ccae010468e55897ae9840ab8fda684f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11760
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-10-02 06:35:08 +00:00
François Beaufort f622a44750 Fix support for optional const char*
Optional labels were added to command buffer descriptor and compute pass
descriptor in https://dawn-review.googlesource.com/c/dawn/+/11601.
Sadly, the wire was not updated. This CL fixes support for optional
const char*.

Bug: dawn:22
Change-Id: I23211456f5e3d5f3c0344d8b8cc604bab20015f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11660
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-09-27 21:25:43 +00:00
Corentin Wallez a9a84dfe1e BUILD.gn: Delete stale generated files in Dawn's gen dir.
This normalizes even more the directory structure of generated files in
Dawn and removes stale autogenerated files that could be included
wrongly using a GN action.

See comment on top of dawn_generator.gni in this commit for more
context.

BUG=dawn:22

Change-Id: I8ec038f949c048431b2b643af4462f98c4ae610b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11361
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-09-19 23:30:42 +00:00
Corentin Wallez 05623df97f BUILD.gn: Add a check generated files are in allowed dirs.
This is important so that we know that the list of allowed directories
is in sync with other parts of the build in follow-up commits.

BUG=dawn:22

Change-Id: I202bec55b510989e43acf497956e2937c9a2f60a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11360
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-09-18 23:19:31 +00:00
Corentin Wallez 897ebc7a71 Normalize generated file paths to match main tree.
Previously dawn_native files were in src/dawn_native/ while generated
files were in dawn_native/. This makes some things complicated when
integrating in other source trees so normalize all generated files to be
in paths that match the main tree.

BUG=dawn:225

Change-Id: I5b3e04d37a16251143578dfb7a31445b229fe4ac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11300
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-09-18 04:33:12 +00:00
Corentin Wallez 45f9185de5 generator_lib.py: correctly handle lack of --jinja2-path.
Python's list.index() method raises an exception when the item isn't
present in the list. Fix this check that was instead expecting a
negative index.

BUG=dawn:225

Change-Id: I8e67d71ff7384f49533a95d5cbe04da1cf7bb0bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11301
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-09-18 00:59:40 +00:00
Corentin Wallez c6c7a42e6e Remove indirection for vertexStage
This is to match the work in progress webgpu.h header.

Also contains a fix for the wire where it wouldn't GetExtraRequiredSize
for structures that are by-value members of other structures.

BUG=dawn:22

Change-Id: I3c706bf9cd7a550d40fd667877f032c860d0a032
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9382
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-09-05 09:35:07 +00:00
Austin Eng 45238d775a Add empty implementations of Push/PopErrorScope
This adds Push/PopErrorScope to the API with empty implementations which
just call the error callback. Also adds unittests that the wire callbacks
return as expected.

Bug: dawn:153
Change-Id: I63826360e39fbac4c9855d3d55a05b5ca26db450
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10543
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-09-04 22:54:03 +00:00
Austin Eng 45ea7e66bf Rename SetErrorCallback to SetUncapturedErrorCallback
This is to better match the naming of the uncapturederror event
in WebGPU.

Bug: dawn:153
Change-Id: Ic2bc1f46bf3d1f0d14cbd5cb8ea6e54d1679f987
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10542
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-08-27 21:43:56 +00:00
Austin Eng cb0cb658d4 Rename DeviceErrorCallback to ErrorCallback and add ErrorType arg
This same callback will be used for push/pop error scope.

Bug: dawn:153
Change-Id: I2771539e13f8a4e6a59f13c8082689d25ba44905
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10460
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-27 21:41:56 +00:00
Austin Eng 5603dc9044 Rename ContextLost to DeviceLost
DeviceLost is a better name because we don't have a "context" as in
OpenGL.

Bug: dawn:153
Change-Id: Idf7fcb731a0e138f46a81fb31f0d11ff58b4fa96
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10541
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-08-27 18:10:03 +00:00
Corentin Wallez 9e9e29f7a6 Remove Bit from TextureUsageBit and BufferUsageBit
This is to match the naming convention of WebGPU's WebIDL and webgpu.h

BUG=dawn:22

Change-Id: Ia91c5a018403e6a72eb0311b5f1a072d102282a2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10461
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-08-27 08:21:39 +00:00
Kai Ninomiya 93196db8ef Implement new defaults for Texture::CreateView
https://github.com/gpuweb/gpuweb/pull/389 except for removing createDefaultView
https://github.com/gpuweb/gpuweb/pull/407

This will need to slightly change again when
https://github.com/gpuweb/gpuweb/pull/424 lands.

Bug: dawn:214
Change-Id: Id904b55cea6d77fcf7d971bd743468c7d82a9aa8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10440
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-08-26 22:51:19 +00:00
Jiawei Shao 9d9d76c590 OpenGL: Support B2T and T2T copies with BC formats
This patch implements the creation, buffer-to-texture copies and
texture-to-texture copies with BC formats on OpenGL backend. Note that
OpenGL SPEC also has the same issue about texture-to-texture copies
with compressed textures as Vulkan SPEC, so we have to skip the related
case.

The texture-to-buffer copies with BC formats and related end2end tests
will be supported in the following patches.

BUG=dawn:42
TEST=dawn_end2end_tests

Change-Id: I76b16862259cb2df77f202ed7ed433d41aa3cd47
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10220
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-08-22 08:19:13 +00:00
Corentin Wallez ba84fb2977 OpenGL: Add support for backend validation
This uses the OpenGL debug ouput functionality to make the driver call
us back when an error happens so we can ASSERT and fail.

BUG=dawn:190

Change-Id: I4b6d7a860384dfeccc1c37383fd4cbdc09d7dc05
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9204
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-07-22 10:02:49 +00:00
Austin Eng 6a5418a760 Add MemoryTransfer interfaces to the wire
This patch adds MemoryTransfer client/server interfaces and
uses it to implement data transfers for buffer mapping.

This patch also provides a default "inline" implementation of
the MemoryTransfer which is used if the embedder does not
provide one on initialization.

Because implementations of MemoryTransfer perform their own
serialization, a skip_serialize option is added to WireCmd records.

Bug: dawn:156
Change-Id: I2fa035517628a3ad465b0bc18a6ffc477e2bd67f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8642
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-07-19 16:01:48 +00:00
François Beaufort 0326b8012b Use whole size of buffer if binding buffer size is UINT64_MAX
Following WebGPU spec change at https://github.com/gpuweb/gpuweb/issues/331,
bind groups in Dawn now use the whole size of the buffer if binding buffer
size is UINT64_MAX.

Bug: dawn:22
Change-Id: If28d905e634432755dad5c67c69eadedcee53dfe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8863
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
2019-07-17 08:54:19 +00:00
François Beaufort 4af9808400 Make rasterization state descriptor optional
Following WebGPU spec change at https://github.com/gpuweb/gpuweb/issues/347,
the rasterizationState from GPURenderPipelineDescriptor should not be
required anymore.

BUG=dawn:22
Change-Id: Ic458396665a7e2fbd942aa7f50138cc96497ff33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
2019-07-16 17:01:59 +00:00
Corentin Wallez 8f93871dff Add default values to dawn.json for dawncpp.h
This adds almost all default values in descriptors that are present in
WebGPU to the C++ interface for Dawn.

This also fixes the indentation of dawncpp.h both by reindenting the
template, and making the indentation counting in generator_lib.py more
precise.

BUG=dawn:22

Change-Id: I9a852d26f78a3349f3d6eee7237407d1cf8ca426
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8680
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-07-08 19:20:22 +00:00
Corentin Wallez 7ac0815347 dawn_json_generator: Assert that enum values are unique.
This will be useful when we add all texture formats because there are
more than 50 of them and we want to make sure no two enum values
collide.

BUG=dawn:128

Change-Id: I928d3311ee3f6422ea503a3fa90c5e377fe5e03d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8360
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-26 19:54:43 +00:00
David 'Digit' Turner 5dee3e826b [generator_lib]: Make generator_lib.py easier to reuse.
This CL tries to make generator_lib.py easier to reuse in
other projects (e.g. non Dawn-related), by doing the following:

- Removing dawn-specific variables from the script and
  replacing them by path-relative defaults, or through
  additional command-line parameters (e.g. --root-dir can
  now be used to pass the root source directory for Python
  dependency computations).

- Move project-agnostic processing from dawn_generator
  GN template into a new generator_lib:generator_lib_action
  template. The new generator_lib.gni file does not
  contain Dawn-specific settings and can be reused more
  easily outside of Dawn.

+ Replace --extra-python-path with --jinja2-path to be
  more explicit.

+ Add a few documentation comments in the Python scripts.

R=cwallez@chromium.org

Bug: NONE
Change-Id: I3e89f4bc32bdb6a019d251473222c6ce5cdc5f9f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8280
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-06-24 14:31:06 +00:00
Corentin Wallez 8f4046b0b6 Remove glad and replace it with our own GL header
This completely removes the dependency on glad by generating the GL
headers from gl.xml directly.

This requires adding khrplatform.h so all Khronos dependencies are
gathered in third_party/khronos.

Also removes a stray CMakeLists.txt that was still hanging out.

BUG=dawn:165

Change-Id: Ia64bc51bc8b18c6b48613918e2f309f7405ecb3b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8163
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-06-17 09:17:29 +00:00
Austin Eng 21eba761b5 Implement CreateBufferMappedAsync in dawn_wire and dawn_native
Bug: dawn:7
Change-Id: I1a4e5eece53d83a4c5395ba6b41df2e20668c5bb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8120
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-14 17:35:56 +00:00
Corentin Wallez df69f24824 OpenGL: Don't use glad to load OpenGL entrypoints
This makes the OpenGL entry points loaded at Adapter creation from the
getProcAddress passed in the DiscoveryOptions and update all GL calls in
the backend to go through the new OpenGLFunctions object.

A code generator is added that generates the function loader and list of
GL procs from Khronos' gl.xml file but we can't get rid of glad yet
because it is used to have the PROC typedefs and enum values.

BUG=dawn:165

Change-Id: I2a583d79752f55877fa4190846f5be16cf91651a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7983
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-06-13 10:22:32 +00:00
Corentin Wallez 031fbbbaa1 Generators: main.py is now dawn_json_generator.py
This merges all the files for main.py together again except
generator_lib.py because there doesn't seeem to be a good way to
separate the pure dawn.json generators and the dawn wire generator.

Also updates the GN templates to make it easier to define new generators
based on generator_lib, and move the Jinja2 template "stdlib" to
generator_lib.py

BUG=dawn:165

Change-Id: I1b5b2ef0a59cb142e214f3af9a58048a88ae949a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7880
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-11 18:03:05 +00:00
Corentin Wallez 0c38e92187 Split off the reusable part of the code generator
This is in preparation for using it to generate code for replacing glad
with our own OpenGL function pointer loading code.

BUG=dawn:165

Change-Id: Ic3e774ab207e85a1491f299ad06131c8095416ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7781
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-06-07 08:59:17 +00:00
Corentin Wallez 67ab1ea8c7 dawn.json: Use void* instead of uint8_t* for data pointers
This requires some changes in the wire because WireCmd doesn't know the
size of void. This also adds a handwritten implementation of the Wire
commands for SetSubData that internally converts to uint8_t so that
WireCmd can generate the de/serialization.

BUG=dawn:160

Change-Id: Icbf0fd7dd841639ee6f67333844e027b27a8afcc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7780
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-06 16:19:15 +00:00
Corentin Wallez 839053b90c Replace dawn::CallbackUserdata with void*
This initial reasoning for having a u64 userdata was to be able to pack
two u32s in a single userdata but that was never used, and made a bunch
of code uglier than it should.

BUG=dawn:160

Change-Id: Ia0d20bc23f09f5d8f3748ca4edd1a331604f2ba8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7561
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-05-29 13:03:50 +00:00
Austin Eng 3a8aa31d88 Rename .inl to .inc
Bug: chromium:964411
Change-Id: Iff1ff8aadccd3e6ce6abefed983f23241dc19edf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7341
Commit-Queue: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-05-17 20:42:33 +00:00
Austin Eng 740995c0b1 Implement CreateBufferMapped in dawn_native for MAP_WRITE buffers only.
This is the first command to return a struct. This patch also
updates the code generator to support structure return values.

Bug: dawn:7
Change-Id: Ie8acec895c0ec88429672138ffc900032fbbc447
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/4780
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-05-15 18:55:22 +00:00
Austin Eng cf52d711fb Change buffer-related sizes/offsets to be uint64_t
Bug: dawn:121
Change-Id: I9d88e2b2b8eff4eda98d25ae0922bc07199a69c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5720
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-04-05 20:51:29 +00:00
Corentin Wallez 4f5fc2d325 Nuke Builders part 4: headers, proctable and miscreferences
BUG=dawn:125

Change-Id: If1b2feb1b0880eb8ad168cfabb9d67ece4f02190
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6220
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-04-01 21:48:38 +00:00
Corentin Wallez cb2c64f7d9 Nuke Builders Part 2: remove all builder code from wire
This removes blocks of code that were obviously builder-specific but
also removes the ObjectStorage::valid member that was used to implement
the maybe monad on the wire server side. This is no longer needed since
dawn_native handles the maybe monad internally now.

BUG=dawn:125

Change-Id: I8c30daae9fc70853bc1996d85a860b4877c5976c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6161
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-04-01 21:04:17 +00:00
Corentin Wallez 0ae00a187d Nuke Builders Part 1: remove the testing BufferBuilder.
This requires deleting wire tests for builders that were using it, and
leads to small simplifications in the WireTest harness. Also allows
removing the BuilderBase class from dawn_native.

BUG=dawn:125

Change-Id: I3cbac609207aa652cdc9d37e0b700cce3ac6e093
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6120
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-03-28 17:12:47 +00:00
Corentin Wallez d754fb2034 Make Wire tests more strict w.r.t. expectations
This changes Wire tests to produces errors on "uninteresting calls" and
flushes mock expectations on client/server flushes so that we control
100% of the order of calls.

BUG=941543

Change-Id: I6eabc79dde2abb564e54df90c5c0e615fd4496c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6040
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-28 10:44:41 +00:00
Austin Eng 45f9730855 Capitalize C types dawn -> Dawn
This is to match Chromium style.

Change-Id: Ic97cc03e2291c653ade9662ba3d5e629872b10ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5482
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-03-11 16:52:42 +00:00
Corentin Wallez 579cf621f3 Split off common and libdawn / dawn_headers from BUILD.gn
This adds an option to dawn_generator to generate files in a different
directory so the generated stay at the same place. Otherwise compilation
errors occur because of stale versions of the headers on the CQ
builders.

BUG=dawn:61

Change-Id: I71ceb3172b5a4e35911973a03be29d90fa684416
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5304
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-03-07 01:46:39 +00:00
Corentin Wallez abc753c9c9 BUILD.gn: Split dawn_component/generator in their own files
This will allow follow up commits to use them from the different parts
of the split-off BUILD.gn file.

BUG=dawn:61

Change-Id: I767f6c97c06ee73290d3df482880d1a2df92e187
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5301
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-03-06 23:17:39 +00:00
Austin Eng 1541c8ba7a Remove |start| and |size| from buffer mapping
This is part of making buffer mapping match WebGPU

Bug: dawn:7
Change-Id: Ia97c872e398112aef0f93c98618c8a7f3ff0c19a
Reviewed-on: https://dawn-review.googlesource.com/c/4580
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-14 19:31:17 +00:00
Corentin Wallez f872e6924c Wire: Add support from optional struct/integer const*
This will allow implementing the following part of the WebGPU IDL using
a nullable pointer instead of an extra hasDepthStencilState boolean:

partial interface GPURenderPipelineDescriptor {
    GPUDepthStencilStateDescriptor? depthStencilState;
};

BUG=dawn:102

Change-Id: Iae709831ad857fcef073f18753ab39567a8797da
Reviewed-on: https://dawn-review.googlesource.com/c/4500
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Yunchao He <yunchao.he@intel.com>
2019-02-13 10:15:38 +00:00
Austin Eng 62e83971ca Factor wire server handlers into proper command handlers and doers
Bug: dawn:88
Change-Id: If637e7ac694d68ad7a4a1e85fd241e8b48e62f6a
Reviewed-on: https://dawn-review.googlesource.com/c/4060
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-02-11 19:39:46 +00:00
Austin Eng 8749506bae dawn_wire: Move manual class members from ServerBase to Server
Bug: dawn:88
Change-Id: Ic216006aa52cace7aa7451b957e72119783e6d7a
Reviewed-on: https://dawn-review.googlesource.com/c/4100
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-30 17:37:28 +00:00
Austin Eng 1139d1c12c Factor wire client handlers into proper command handlers and doers
Bug: dawn:88
Change-Id: I3ab28efad7edc7d06f11aa5abae07a1bb3d7e59e
Reviewed-on: https://dawn-review.googlesource.com/c/4003
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-30 03:00:17 +00:00
Austin Eng cd4fd8e7cd Make the wire Client own ObjectAllocators and CommandSerializer
This moves ownership of ObjectAllocators and CommandSerializers
from the Device to the Client. There may be also be multiple
Devices, so New() now takes the Device the object belongs to.
Device allocation specializes New() to take the owning Client so
that we can get a pointer to the Client from any Dawn API object.

Bug: dawn:88
Change-Id: Ie4274d46313884c44a857159e95d236dc1141c0c
Reviewed-on: https://dawn-review.googlesource.com/c/4001
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-01-30 02:31:37 +00:00
Austin Eng fd4688e8d0 Separate WireServer.cpp into multiple files.
This patch copies methods and classes from WireServer.cpp and
distributes them over multiple files. Headers and forward declarations
are added as necessary, but no functional changes are made.

Bug: dawn:88
Change-Id: I471b8c27804916257eff266a51d087ba1ddbfeb6
Reviewed-on: https://dawn-review.googlesource.com/c/4000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-01-30 02:20:58 +00:00
Yunchao He c0f31e73e4 Use const*const* to annotate a sequence of descriptors
BUG=dawn:77

Change-Id: I2a523e54a06173c157730e043c25e9629887fd1f
Reviewed-on: https://dawn-review.googlesource.com/c/3820
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-21 08:29:01 +00:00
Austin Eng acd8b7d937 Separate WireClient.cpp into multiple files.
This patch copies methods and classes from WireClient.cpp and
distributes them over multiple files. Headers and forward declarations
are added as necessary, but no logical changes are made.

Bug: dawn:88
Change-Id: I9d0fcaeb67e789c3ad0597eaa3839adefc3ac5f9
Reviewed-on: https://dawn-review.googlesource.com/c/3980
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-01-16 02:18:06 +00:00
Austin Eng c7f416c0c9 Add wire_cmd.py and dawn_wire.json to autogenerate all wire commands.
Unify code generation for Client->Server and Server->Client commands.
Methods in dawn.json are converted into command records and additional
commands are specified in dawn_wire.json. This can then be used to
completely generate the command handlers and command struct definitions.

Bug: dawn:88
Change-Id: Ic796796ede0aafe02e14f1f96790324dad92f4c0
Reviewed-on: https://dawn-review.googlesource.com/c/3800
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-15 20:49:53 +00:00
Corentin Wallez 1a99f42c7d WireServer: Wrap userdata in unique_ptr in callbacks
This fixes a leak that was introduced in
https://dawn-review.googlesource.com/c/dawn/+/3622 where the early
return doesn't delete the userdata.

BUG=chromium:921360

Change-Id: I500dd2b4fa02121e5c0278c5f6f83a30861815e4
Reviewed-on: https://dawn-review.googlesource.com/c/3942
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-01-14 18:41:13 +00:00
Corentin Wallez bd48385d50 Add static library versions of libdawn*
Chromium will want to have both static and shared library versions of
Dawn to use in non-component and component builds respectively.

The *_export.h files are modified to noop when *_SHARED_LIBRARY is not
defined so that the static library doesn't export symbols that aren't
imported in dependents (this would break compilation on Windows).

A dawn_library_combo is introduced in BUILD.gn that factors out all the
logic needed to produce shared libraries and handle the _EXPORT macros.

Also contains a fix to dawncpp to export only the methods that aren't
defined in the header (otherwise they get defined multiple times)

BUG=dawn:85

Change-Id: Ib747deb9308e1165dd66002487147ba279d3eac0
Reviewed-on: https://dawn-review.googlesource.com/c/3761
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-09 09:05:18 +00:00
Austin Eng 5236eb2057 Specialize WireServer objects
This removes unnecessary builder and buffer info from server objects that
do not need them.

Bug: dawn:86
Change-Id: I97b11615da763725281495f05c70a4ee7a9c9e5a
Reviewed-on: https://dawn-review.googlesource.com/c/3780
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-08 17:58:38 +00:00
Austin Eng 9dc1250d3e Use single DestroyObject command in the wire
Bug: dawn:83
Change-Id: Ic875d5111f59e7166d2decb3dc6a84973d9babdf
Reviewed-on: https://dawn-review.googlesource.com/c/3680
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-07 17:52:56 +00:00
Corentin Wallez 1e37db5350 WireServer: check buffer exists before sending the map callback
The client might have asked for the buffer to be destroyed, but the
reference to the buffer is still alive because it is internally
referenced by Dawn.

BUG=chromium:918254

Change-Id: Id7d2de891eba98e3cf15e77730f66f64d9a3b9f9
Reviewed-on: https://dawn-review.googlesource.com/c/3622
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-04 09:54:40 +00:00
Corentin Wallez a19c759bc4 WireCmd: guard against overflows when computing array sizes
BUG=chromium:918094
BUG=chromium:918348
BUG=chromium:918260

Change-Id: Ia2ee8930592e436e8d0d76837b70e726e8d87ea7
Reviewed-on: https://dawn-review.googlesource.com/c/3620
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-04 09:54:10 +00:00
Corentin Wallez 0d95887dbc WireServer: don't skip destroy on error objects.
An old-style builder might become an error object when a
validation error occurs on one of its methods. It still has
to be freed, so the correct check for "destroy" is to check
that the handle is not null.

BUG=chromium:914819
BUG=chromium:914867
BUG=chromium:914964
BUG=chromium:915083

Change-Id: I349faffa48f369b72c603d47dd23ffae7d86891e
Reviewed-on: https://dawn-review.googlesource.com/c/3323
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-17 10:55:25 +00:00
Austin Eng 08aa58f8d6 Check if fence is nullptr in PostHandleQueueSignal
PostHandleQueueSignal assumed that fence was not null because QueueSignal
generates an error if it is. The errors are not surfaced immediately so
this additional check is needed before doing the post-handler.

Bug: chromium:914808
Change-Id: I2a99f5229712d49d3c9a2d1f3f2dd1009247a24c
Reviewed-on: https://dawn-review.googlesource.com/c/3280
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-14 08:29:38 +00:00
Corentin Wallez 48a1923afb Revert "Create new src/tests BUILD.gn file."
This reverts commit 672d29d14c.

Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=913171

Original change's description:
> Create new src/tests BUILD.gn file.
> 
> Move all test-related build stuff into its own BUILD.gn file. This
> required moving the dawn_generator template into a common file, so it
> can be called by both BUILD.gn and src/tests/BUILD.gn.
> 
> [This is a reland of https://dawn-review.googlesource.com/c/dawn/+/2940
> with a fix for mock_dawn.]
> 
> Bug: dawn:61
> Change-Id: Id1e6d0c2b07caa2610cebe206511e972ac18fe8d
> Reviewed-on: https://dawn-review.googlesource.com/c/3020
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
> Commit-Queue: Stephen White <senorblanco@chromium.org>

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

Change-Id: I54cdc558b128935dc8a8d22ec2b5e879271c35ae
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:61
Reviewed-on: https://dawn-review.googlesource.com/c/3080
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-08 10:35:53 +00:00
Stephen White 672d29d14c Create new src/tests BUILD.gn file.
Move all test-related build stuff into its own BUILD.gn file. This
required moving the dawn_generator template into a common file, so it
can be called by both BUILD.gn and src/tests/BUILD.gn.

[This is a reland of https://dawn-review.googlesource.com/c/dawn/+/2940
with a fix for mock_dawn.]

Bug: dawn:61
Change-Id: Id1e6d0c2b07caa2610cebe206511e972ac18fe8d
Reviewed-on: https://dawn-review.googlesource.com/c/3020
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2018-12-07 21:54:48 +00:00
Corentin Wallez 67737f1d4a WireServer: Don't allow freeing the Device
BUG=chromium:907278
BUG=chromium:911155

Change-Id: I6ec721b34b214bb242ac0d217e6ab12832c7323a
Reviewed-on: https://dawn-review.googlesource.com/c/2842
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-07 16:25:36 +00:00
Corentin Wallez 1d2850a129 WireServer: on destruction, free all objects.
The fuzzer is correctly detecting leaks when an object is created but
not freed through the wire. It isn't clear yet if we want leftover
objects to be freed by the wire of by the Device itself, but in the
meantime we make the wire free them to fix the fuzzer issues.

BUG=dawn:59

Change-Id: Id7bff93e60a52e1f833f31b1eb3bfd30f8fe4215
Reviewed-on: https://dawn-review.googlesource.com/c/2566
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2018-12-07 16:13:36 +00:00
Corentin Wallez 6f0e1f9d82 Remove BufferView and inline offset/size in BindGroup
BUG=dawn:2

Change-Id: I811024c4ac3a6167dd0caff05eca3fbb2640e862
Reviewed-on: https://dawn-review.googlesource.com/c/2941
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-07 12:31:53 +00:00
Stephen White 0f50114b3c Disable/avoid some warnings.
Implement DAWN_DECLARE_UNUSED macro to avoid -Wunneeded-internal-declaration
warning.

Change-Id: I4d087d2b09b74e35ba7ea69533df2c5adef4ef82
Reviewed-on: https://dawn-review.googlesource.com/c/2943
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2018-12-06 19:01:22 +00:00
Corentin Wallez 5aacd29d5e ProcTable: only cast the return value if needed.
Fence::GetCompletedValue introduced the first return value that's not an
object which reinterpret_cast to its own type. MSVC complains about it,
so instead we reinterpret_cast only if the value is an object.

BUG=

Change-Id: I35225cd1ff47a91868572a45a67ebe979e4b064f
Reviewed-on: https://dawn-review.googlesource.com/c/2942
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-06 10:43:33 +00:00
Kai Ninomiya bdd887fce7 Revert "Create new src/tests BUILD.gn file."
This reverts commit 0a7ddd43d7.

Reason for revert: Broke compile in https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/linux-rel/12314
See also: https://chromium-review.googlesource.com/c/chromium/src/+/1364694

Original change's description:
> Create new src/tests BUILD.gn file.
> 
> Move all test-related build stuff into its own BUILD.gn file. This
> required moving the dawn_generator template into a common file, so it
> can be called by both BUILD.gn and src/tests/BUILD.gn.
> 
> Bug: dawn:61
> 
> Change-Id: Icaa459270bdaa60306e053b93835812e70dba6f5
> Reviewed-on: https://dawn-review.googlesource.com/c/2940
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
> Reviewed-by: Stephen White <senorblanco@chromium.org>

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

Change-Id: If6d8c759f63c12b244471016f10e92c07299303f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:61
Reviewed-on: https://dawn-review.googlesource.com/c/3000
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2018-12-06 06:41:59 +00:00
Stephen White 0a7ddd43d7 Create new src/tests BUILD.gn file.
Move all test-related build stuff into its own BUILD.gn file. This
required moving the dawn_generator template into a common file, so it
can be called by both BUILD.gn and src/tests/BUILD.gn.

Bug: dawn:61

Change-Id: Icaa459270bdaa60306e053b93835812e70dba6f5
Reviewed-on: https://dawn-review.googlesource.com/c/2940
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2018-12-05 22:42:23 +00:00
Corentin Wallez e2f948469c generator: Unify handling of argument and member parsing
This completes the handling of "length" for structure members which were
missing const* structures defaulting to being of length one.

Also renames "record" to json_data to more precisely describe what it
is.

BUG=dawn:4

Change-Id: Ia53e4fcec15ebc9f9dae58ddba5b460d1f2eeebd
Reviewed-on: https://dawn-review.googlesource.com/c/2881
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-05 17:49:04 +00:00
Corentin Wallez 7b3ea34b6b WireCmd: Update buffer pointer when serializing sub elements
Without this the serialize step failed to increment the pointer to
the buffer to account for the recording of "main" in the render
pipeline descriptor:

  descriptor->vertexStage->entryPoint = "main";

BUG=dawn:4

Change-Id: Ic3829787af2213577ac67ee93625679afdae1cc9
Reviewed-on: https://dawn-review.googlesource.com/c/2880
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-05 10:13:52 +00:00
Stephen White 006f218392 Use std::nullptr_t in place of nullptr_t.
(It's not clear to me why only some projects/compilers are complaining
but other parts of the code are using the explicit namespace.)

Change-Id: I24b0c3b8104932b4ec82a25f5eb96c08abff87b5
Reviewed-on: https://dawn-review.googlesource.com/c/2901
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-12-05 04:10:52 +00:00
Corentin Wallez f48e6b74b7 dawncpp.h: Add nullptr ObjectBase constructor and assignment
BUG=dawn:3

Change-Id: I9f7ec0ae1c7885809888a603ed056c6565751bec
Reviewed-on: https://dawn-review.googlesource.com/c/2840
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-12-04 12:13:03 +00:00
Austin Eng f0b761f116 Implement timeline fences in Dawn
This change implements timeline fences in Dawn.
It includes methods and descriptor members to eventually
support multi-queue, but does not implement them.

Bug: dawn:26
Change-Id: I81d5fee6acef402fe099227a034d9669a89ab6c3
Reviewed-on: https://dawn-review.googlesource.com/c/2460
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-12-03 16:57:34 +00:00
Corentin Wallez d8c1a48fc4 WireCmd: require opt-in to treat ID 0 as nullptr instead of error.
In preparation for the descriptorization of BindGroup, support was added
to treat wire ID 0 as nullptr for a bunch of objects. Now that we have a
fuzzer for the wire+frontend, we need to validate when we have a 0 id.
Either the wire needs to reject the ID or the frontend needs to validate
against nullptrs. Since only few entrypoints will have a use for
nullptrs (bind groups, render pass resolve textures), we require an
opt-in in the JSON file for a structure member or an argument to be
optional.

This disables the tests related to ID 0 = nullptr, because we don't yet
have optional argument/members in dawn.json.

BUG=chromium:905273
BUG=chromium:906418
BUG=chromium:908678

Change-Id: If9a3c4857db43ca26a90abff2437e1cebb0ab79b
Reviewed-on: https://dawn-review.googlesource.com/c/2704
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-28 17:00:33 +00:00
Corentin Wallez c7d78088cd Make codegen not cast between fnptrs.
When generating the proc tables for dawn_native and dawn_wire (for the
client), we were casting between function pointers with the C types and
function pointers with the internal types. This is UB and was caught by
UBSan.

Replace casts between function pointers by casts between types inside
the functions themselves.

BUG=chromium:906349

Change-Id: Icd8f6eedfa729e767ae3bacb2d6951f5ad5c4c82
Reviewed-on: https://dawn-review.googlesource.com/c/2400
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-20 09:33:35 +00:00
Corentin Wallez c56860e27f WireServer: Check for ID 0 in hand-written handlers.
BUG=chromium:905272

Change-Id: Ib8efb307dbdd6fc57d2cc75366f238c4dfb2beea
Reviewed-on: https://dawn-review.googlesource.com/c/2563
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-20 09:31:45 +00:00
Corentin Wallez dcc488aa7c WireCmd: error out if "self" is null.
BUG=dawn:34

Change-Id: Ic77a6a1b2145ad9572abd6e2f3cd422d8c87f3eb
Reviewed-on: https://dawn-review.googlesource.com/c/2301
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-12 09:01:36 +00:00
Corentin Wallez 146edf5bec Remove support for CMake builds
This also removes support for Travis and AppVeyor, as well as git
submodules for dependencies.

It also adjusts .gitignore to include dependencies (submodules are
implicitly ignored but are removed in this commit).

Finally, removes some CMake-specific code from the code generator.

BUG=

Change-Id: I4ebc04e530a574b412ef0ca81e4672db01f0ed92
Reviewed-on: https://dawn-review.googlesource.com/c/2040
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-10-31 10:53:11 +00:00
Corentin Wallez aa7109c148 Add copy constructors to the C++ Dawn interface
This removes the need for Clone() so it is removed and also adds tests
for the new constructors.

BUG=dawn:11

Change-Id: Ia45c765c2d30e40b0e036427793a62327b2008fc
Reviewed-on: https://dawn-review.googlesource.com/c/1901
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-10-25 10:42:49 +00:00
Jiawei Shao c2283ed1b2 Fix a typo in main.py
This patch fixes a typo "false" in main.py. The right token should
be "False".

Change-Id: Ic56f6f3290b30ce2dd56dbe1ce4c31821b981723
Reviewed-on: https://dawn-review.googlesource.com/1560
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-09-21 06:55:25 +00:00
Corentin Wallez 386b8889bd Wire: Add support for nullptr objects as arguments
BUG=dawn:5

Change-Id: I84c80796e9bdfbcf59fafdd38d33ab2101a1d795
Reviewed-on: https://dawn-review.googlesource.com/1541
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-09-21 00:28:33 +00:00
Corentin Wallez fdccb54de5 dawncpp.h: Don't expose the fluent syntax for non-builders
At this point this change is a noop, however encoders introduced in
follow-up patches aren't builders and thus won't have the fluent syntax.

BUG=dawn:5

Change-Id: Idc5f327a1a7788c3ba16a50491aefb054700f257
Reviewed-on: https://dawn-review.googlesource.com/1540
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-09-20 20:05:21 +00:00
Corentin Wallez 29353d6ee3 dawn.json: Make textureDescriptor use Extent3D
This matches WebGPU and is a good test of having structures include
other structures by value.

BUG=dawn:13

Change-Id: Ibd5ea1340338e5aa16069499c498ac5a455fc2cd
Reviewed-on: https://dawn-review.googlesource.com/1500
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-09-18 12:49:22 +00:00
Corentin Wallez 1e68479cd6 dawn.h: Don't use anonymous structures
Instead make them have the same name as their typedef. This is because
anonymous structures is considered bad practice in C because it prevents
forward declaring them.

BUG=

Change-Id: I2d7a788a0d807a2689567d0bb220adaf5335e07a
Reviewed-on: https://dawn-review.googlesource.com/1521
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-09-18 12:09:55 +00:00
Corentin Wallez 03e1813fd2 Add DAWN_UNUSED_FUNC to ignore unused functions in generated code
BUG=dawn:13

Change-Id: I7a224503d0a33ef148e63b8327a6a53df1b3868a
Reviewed-on: https://dawn-review.googlesource.com/1520
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-09-17 22:59:08 +00:00
Corentin Wallez 6fee61ca9c Make Dawn error macro more explicit and have an "error type"
The error type will help distinguish between validation errors, context
losts and others which should be handled differently.

Take advantage of advantage of this to change DAWN_RETURN_ERROR to
"return DAWN_FOO_ERROR" to have the return be more explicit. Also
removes usage of DAWN_TRY_ASSERT for more explicit checks.

Change-Id: Icbce16b0c8d8eb084b0af2fc132acee776909a36
2018-09-11 07:55:27 -04:00
Corentin Wallez 8e335a5585 Descriptorize ComputePipeline
Change-Id: Ic9d7014ba44d927d7f9ddf81a8870432c68941e8
2018-09-05 08:32:53 -04:00
Corentin Wallez 82b6573d54 Descriptorize Buffer
We still keep a dummy BufferBuilder object around so that it can be used
for the builder error callback tests of the wire.

Change-Id: If0c502bb8b62ee3ed61815e34e9b6ee6c03a65ef
2018-08-23 08:23:06 -04:00
Corentin Wallez 59e7fad99b BUILD.gn: Remove use of exec_script
Chromium's BUILD files try to avoid uses of exec_script when possible
because they slow down every GN invocation. In preparation for building
Dawn inside Chromium, the calls to exec_script for the code generator
are removed.

In GN, the generator now outputs a "JSON tarball", a dictionnary mapping
filenames to content. This allows us to use the "depfile" feature of GN
to avoid the exec_script call to gather the script's inputs.

Outputs of the generator are now listed in the BUILD.gn files. To keep
it in sync with the generator, GN outputs a file containing "expected
outputs" that is checked by the code generator.

Finally the dawn_generator GN template doesn't create a target anymore,
but users are expected to gather outputs using get_target_outputs.
2018-08-20 07:24:55 -04:00
Corentin Wallez 3bb0bb940e Generator,BUILD.gn: add optional python path, use it for Jinja2
This makes the Jinja2 (and MarkupSafe) installation hermetic by
adding it to the DEPS and making the code generator add them in the
first spot of the python path.
2018-08-14 21:42:32 +02:00
Corentin Wallez c0494762b7 Speed up the code generator for exec_script.
The code generator doesn't need to load the JSON file to compute the
dependencies our outputs for a codegen target. To better integrate in
noop builds, the lazy-write of generated file is removed because it led
to the code generator running even in noop build (the timestamp of
generated file not being updated).

Also document what could be done to avoid exec_script calls for the Dawn
code generator.
2018-08-06 16:38:33 +02:00
Corentin Wallez 21a23857dc Add initial BUILD.gn files for libdawn[|_native|_wire] 2018-08-06 16:38:33 +02:00
Corentin Wallez dcb71a131c dawn_native: Factor getting procs into a single function.
Now the backends only expose the creation of devices. Getting the procs
is moved to DawnNative that will over time more backend-agnostic APIs.
2018-08-06 16:38:33 +02:00
Corentin Wallez fe253f135b Generate a single ProcTable instead of one per backend.
This required putting Queue::Submit on QueueBase which is something we
would want to do anyway, and removes the need for Queue::ValidateSubmit
being called in the ProcTable.

This removes the need for all the "GeneratedCodeIncludes" files and
leads to a bunch of simplifications in BindGroup as well as the
dawn_native CMakeLists.txt.

Finally this was done in order to simplify the writing of BUILD.gn
files.
2018-08-02 13:39:07 +02:00
Corentin Wallez bdc867713a Make dawn_wire a shared library
Also moves the TerribleCommandBuffer to utils:: because it isn't part of
the implementation of the wire, renames dawn::wire to dawn_wire, moves
src/wire to src/dawn_wire and puts the interface of dawn_wire in
src/include/dawn_wire.
2018-07-30 17:22:45 +02:00
Jimmy Casey 1dd8b12823 Fixed Spelling. 2018-07-30 15:01:15 +02:00
Corentin Wallez 36afbb6a0d Make dawn_native use its own header for Dawn datatypes
The dawn.h and dawncpp.h structure definitions references dawnFoo or
dawn::Foo respectively when it should reference dawn_native::FooBase* in
dawn_native. Autogenerate files to declare the dawn_native version of
the structs and change the ProcTable generation to use it instead.

This is important to make libdawn_native a shared library because
currently it was depending on dawncpp's definition of .Get().
2018-07-27 12:56:26 +02:00
Corentin Wallez 5dcaadb0f9 Make libdawn a shared library, add a DAWN_EXPORT macro 2018-07-25 21:03:49 +02:00
Corentin Wallez e37234cd22 Standardize header guards for libdawn headers 2018-07-25 21:03:49 +02:00
Corentin Wallez 6c27fd9c94 CMakeLists: Generate Dawn headers separately from libdawn
libdawn will be one of the libraries produced but other libraries like
libdawn_native don't need to link against it. However they do need the
Dawn headers so we generate them separately.

This also makes all internal targets depend on the header generation and
have the include directories necessary for those headers.

Also has a small fix for setting compile flags only for C++ files.
2018-07-25 21:03:49 +02:00
Corentin Wallez 49a65d0c0c dawn_native: Fixup namespace from backend:: to dawn_native:: 2018-07-25 11:27:55 +02:00
Corentin Wallez d37523fbde Move src/backend to src/dawn_native 2018-07-25 11:27:55 +02:00
Corentin Wallez 846cfe3421 Remove prototype Blink codegen support 2018-07-18 22:54:06 +02:00
Corentin Wallez 9fc65344f4 Rename NXT -> Dawn in the comments 2018-07-18 22:54:06 +02:00
Corentin Wallez 923574eed5 Rename IsNXTBitMask and NxtReference/Release to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez a5ee52d33e Rename NXT -> DAWN in header guards 2018-07-18 22:54:06 +02:00
Corentin Wallez be5ca38351 Rename nxtProcTable and nxtSetProcs to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez b1669e3fa4 Change the API prefix in generators from nxt to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez ae79c03d45 Rename the nxt namespace to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez 3e371b146d Rename files in src/include nxt -> dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez 046cb46bee Rename generated files nxt -> dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez fde3f2b5e0 Rename NXT -> Dawn in the rest of CMakeLists 2018-07-18 22:54:06 +02:00
Corentin Wallez d148aebf3f Rename CMakeLists targets nxt -> dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez f1ded9bea2 Rename CMakeLists variables NXT_* to DAWN_* 2018-07-18 22:54:06 +02:00
Corentin Wallez 83a9c9d6d9 Rename src/common macros NXT_* to DAWN_* 2018-07-18 22:54:06 +02:00
Corentin Wallez 33ca49614d Rename Error.h macros from NXT to DAWN 2018-07-18 22:54:06 +02:00
Corentin Wallez 141c0be317 Add a temporary define to help rename nxt:: to dawn:: 2018-07-18 22:54:06 +02:00
Corentin Wallez a22335c2b7 Rename next.json to dawn.json 2018-07-18 22:54:06 +02:00
Corentin Wallez 4a9ef4ee21 Rename the copyright authors from NXT to Dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez 021c9504d0 Make CommandBufferValidation use Error.h 2018-07-17 22:34:10 +02:00
Kai Ninomiya 21006bbe6f Assert HandleCommands succeeds 2018-07-10 14:00:52 -07:00