Commit Graph

231 Commits

Author SHA1 Message Date
jchen10 4935c14eec Use WGPU_MIP_LEVEL_COUNT_UNDEFINED instead of 0
The follow up CL will remove 0.

Bug: dawn:1026
Change-Id: Ida62f8d8b0dd8f9722e40f3f95366d3db0c7ab52
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/64164
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2021-09-15 06:27:25 +00:00
jchen10 96ac969a33 Use WGPU_ARRAY_LAYER_COUNT_UNDEFINED instead of 0
This seperates the undefined 'arrayLayerCount' from 0 to
WGPU_ARRAY_LAYER_COUNT_UNDEFINED. So 0 arrayLayerCount is treated
as a validation error.

Bug: dawn:1026
Change-Id: I7b4ae024b02ac0d2aa260b2a8c64b09bd967db87
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63660
Reviewed-by: Jie A Chen <jie.a.chen@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
2021-09-14 02:41:49 +00:00
Austin Eng 02fbf168e0 Add validation, storage, and querying of limits
Adds a way to store the limits on the Adapter and the
Device. For now, adapter limits are always the default
limits, and device limits are stored but not used.

This CL also adds usage of an ErrorObjectIdResolver and
Provider in the WGPUDeviceProperties serialization and
deserialization helpers. Serializing/deserializing this
struct should never have objects.

Bug: dawn:685
Change-Id: I1479b4407b0f9ec9f9b2bff62cad7caa693c99d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63983
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-09-13 18:49:09 +00:00
Austin Eng dc7971ce58 dawn_wire: Support deserializing s->c chained structs
Chained structs *may* contain objects which means
deserialization may need an ObjectIdResolver.
However, in practice, we never need to send chained
structs from the server to the client that contain objects for
a valid command.

The one upcoming need for chained server->client structs is to
serialize limit structs.

Because limit structs never need objects, we provide a dummy
implementation of the ObjectIdResolver which always yields an error.
An analogous change is done for ObjectIdProvider.
These classes will be used in a follow-up CL.

Bug: dawn:685
Change-Id: I1c0f3f2d080377f2e1a77bc6e896f24d3d9ab931
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63981
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-09-10 20:36:20 +00:00
Corentin Wallez ff6c9ca6f0 wgpu::InputStepMode -> VertexStepMode
See https://github.com/gpuweb/gpuweb/pull/1927

Adds a typedef to make a gradual deprecation.

Bug: dawn:1023
Change-Id: Ic81a933a95556fbf5726056530788dde017a1449
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59442
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-07-25 18:40:19 +00:00
Peter Kasting 1ce20bf5cf Fix -Wunreachable-code-aggressive.
Bug: chromium:1066980
Change-Id: I9e00d3707972307e1c5395156c39aa153d5e170e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56522
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Peter Kasting <pkasting@google.com>
Commit-Queue: Peter Kasting <pkasting@google.com>
Auto-Submit: Peter Kasting <pkasting@google.com>
2021-06-30 11:17:16 +00:00
Corentin Wallez 75f554d973 WireCmd: disallow optional members with length="otherMember"
This didn't make sense since these members can be specified to have no
data by setting the length to 0.

 - Prevent uses of this patten by adding an assert in WireCmd.cpp's
   generator.
 - Fix SetBindGroup dynamicOffset to not be optional but default to
   nullptr instead.

This issues would cause a read of uninitialized pointers becaus the
generator code looked like this:

  SetBindGroupCmd cmd;
  cmd.dynamicOffsetCount = record.dynamicOffsetCount; // 1
  bool has_dynamicOffset = record.has_dynamicOffsetl // false
  if (has_dynamicOffset) {
    cmd.dynamicOffsets = ...;
  }
  // Oh no! dynamicOffsets contains garbage even if dynamicOffsetCount
  // is set to 1. dawn_native will happily read it.

Bug: chromium:1220036
Change-Id: I5c468b639f671cef3be2fa64667a0bf114fc902b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/54643
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2021-06-17 16:04:29 +00:00
Stephen White b5652c75d2 Implement EGLImage external texture API for GL.
Tests are based on the IOSurfaceWrappingTests.
Sampling tests are not implemented, since they would require
support for the samplerExternalOES sampler type in WGSL.

Bug: chromium:1205155
Change-Id: Icc114eaf6efaee93f1b8486e615f0fd307f23080
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/50201
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-06-03 16:19:16 +00:00
Austin Eng a9e39e11a8 Add utilities for printing Dawn enums and bitmasks
This is a header-only utility so it can be easily included and
used anyhere. Include it in DawnTest.h to automatically pick up
definitions to print test parameters.

Also, work around bot limitations for very-long test names.

Bug: none
Change-Id: I940263ab0a4cc415b06fa04749694f16ff08335c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/51841
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2021-06-01 18:49:12 +00:00
Stephen White d0ebcbac7a Fixes for OpenGL loader generator.
Add extensions to the appropriate (desktop or ES) LoadProc generation.
Extensions have no removed_procs, so don't check for them.

Bug: chromium:1205155
Change-Id: I705ef3fb700318f59fdbc6415fcf3909c62e39f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/50180
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2021-05-06 18:34:14 +00:00
Brian Ho 5346e770c9 Add helper functions to iterate over ChainedStructs
This CL adds two helpers for more ergonomic processing of
ChainedStructs.

1. FindInChain(): Iterates through the chain and automatically
   casts the ChainedStruct into the appropriate child type before
   returning.
2. ValidateSTypes(): Verifies that the chain only contains structs
   with sTypes from a pre-defined set. This also allows the caller
   to specify one-of constraints.
3. ValidateSingleSType(): Verifies that the chain contains a
   single struct with a specific sType or is an empty chain. This
   is a common case of |ValidateSTypes()| and is separated out as
   a fast-path.

Change-Id: I938df0bf2a9b1800b1105fb7f80fbde20bef8ec8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47680
Commit-Queue: Brian Ho <hob@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-04-22 17:49:42 +00:00
Corentin Wallez 2ce4b905b2 dawn_native: Prefix all API methods with API
This means that calling wgpu::Object::DoStuff will translate to a call
to dawn_native::ObjectBase::APIDoStuff. This will clarify the
difference between reentrant calls and internal calls in dawn_native.
Avoiding issues in the future.

This CL only changes the code generator to prefix with "API", performs
renames needed to make the code compile, and adds TODOs for things that
should be fixed in follow-up CLs.

Bug: dawn:723

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Keeps but deprecates WGPU_STRIDE_UNDEFINED/wgpu::kStrideUndefined.

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

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

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

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

Bug: dawn:384, dawn:556

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

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

Keeps but deprecates a reasonable approximation of the old behavior.

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

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

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

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

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

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

BUG=dawn:529
TEST=dawn_end2end_tests

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

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

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

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

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

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

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

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

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

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

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

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

Bug: dawn:22

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

Bug: None
Change-Id: I2677400f9e69a7fcd71f89bdaa04c642be357151
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26005
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2020-07-30 19:02:43 +00:00