Commit Graph

1292 Commits

Author SHA1 Message Date
Corentin Wallez ba9f3a8e11 OpenGL: Use non-filtering samplers for int/uint texture.
Using a sampler with filtering on int / uint textures makes them
incomplete, causing them to sample black on very conformant drivers.
Each opengl::Sampler is updated to create to GL sampler, a filtering one
and a non-filtering one.

PipelineGL and CommandBufferGL takes advantage of the new
BGLBinding::textureComponentType to know which of the two samplers to
use.

BUG=dawn:128

Change-Id: Idbf5668213bbe6a8639847d57e2be1244f97800c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10282
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-08-21 13:01:23 +00:00
Corentin Wallez f463a20291 Add BGLBinding::textureComponentType
This is a new compatibility constraint that the texture component type
must match between what's declared in the shader and the bind group.

 - Format is updated to include the component type of the format.
 - Validation and state tracking is updated to reflect the new
BGLBinding member.
 - TextureFormat tests are updated to pass with the added validation and
to remove a redundant enum definition.
 - BGLBinding::multisampled validation is added because it was next to
modified code for the BGLBinding::textureComponentType validation.
 - A redundant BGL caching test was removed.

BUG=dawn:128

Change-Id: I9c4ae92062769c3ecf74caf46f27415344dfad77
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10281
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-08-21 12:16:33 +00:00
Corentin Wallez 87ded961ee Remove 16 bit normalized texture formats
They were removed from the WebGPU spec because they cannot be supported
everywhere, for example on recent Qualcomm chips.

BUG=dawn:128

Change-Id: I189bd1b34105f215699ddd404341bbee964c8679
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10280
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-08-20 20:58:01 +00:00
Austin Eng 0beb43809a Validate RenderBundle texture formats
Adds validation and unittests that render bundle color attachments are
color renderable texture formats and depth/stencil attachments are
depth/stencil texture formats.

Bug: dawn:154
Change-Id: I4d062a82b32fb38820fb3ebeb4c265306aa7af24
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10261
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-08-19 22:49:08 +00:00
Austin Eng d8cdcea0ee Validate the RenderBundle debug groups must be well nested
This patch also adds unittests to check the behavior.

Bug: dawn:154
Change-Id: I49f4c0ab98cd823231a701192bdb725937960833
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10260
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-08-19 22:48:48 +00:00
Brian Ho ee3de1e1f3 Remove undefined behavior from NextPowerOfTwo
This CL removes undefined behavior from NextPowerOfTwo(0). Currently on
Linux, calling NextPowerOfTwo(0) simplifies down to:
  - 1ull << (64 - __builtin_clzll(0 - 1));
  - 1ull << (64 - __builtin_clzll(INT_MAX));
  - 1ull << (64 - 0);
  - 1ull << 64

Since 64 is the same width as the long long in our left operand, this
left shift results in undefined behavior (C++11 standard 5.8.1). For a
default Chrome compile, this does not cause any issues; 1ull << 64
results in 0.

In ChromeOS, however, we compile with ThinLTO which, among other things,
inlines various functions in the interest of performance. When
NextPowerOfTwo is inlined, the undefined behavior of our invalid left
shift borks the stack which causes the Math.NextPowerOfTwo unit test to
fail.

BUG= chromium:993457
TEST= verified that Math.NextPowerOfTwo now passes with LTO

Change-Id: I2702ba0b780203643da1d98ad0380098c7b3eab0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10180
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brian Ho <hob@chromium.org>
2019-08-16 18:44:14 +00:00
Idan Raiter 09c12ca696 Validate shared semaphore and memory handles
Checks if we support specific handles and specific usages on the
current device. If we don't, Supported() fails and we stop the import.

Bug: chromium:976495
Change-Id: Icfe044a3c4d912913823728100888ab05f22afd5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10160
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
2019-08-16 17:58:44 +00:00
Idan Raiter 786f76574a Add vulkan external memory large image test
This test catches when image layout is broken, by copying a non-trivial
image after it's imported across devices.

Bug: dawn:206
Change-Id: Ic980cfe31c0e564176c6c060f4a1fab220737938
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10162
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
2019-08-16 17:36:54 +00:00
Yunchao He 0b2599c892 Add tests for RenderPassEncoder::SetViewport
This patch adds tests for SetViewport to verify that the fractions
of parameters (x, y, w, h) in viewport are not truncated.

BUG=dawn:53, dawn:205

Change-Id: I566509234c7a208989ef7ddfc2b15203b10614a0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10120
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-08-16 04:39:53 +00:00
Austin Eng ae2415c6f5 Trace MTLCommandBuffer acquisition and submission on Metal
Bug: chromium:958013
Change-Id: I31b8934247bf43b67956f574b97fb38fa2a9753c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10161
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-16 03:02:43 +00:00
Natasha Lee 5f8a8aadb9 Vulkan: clear nonrenderable texture color formats
Clears nonrenderable color formats and adds a clearValue enum to help
share the code path between zero and nonzero clears.

Bug: dawn:145
Change-Id: I285521cae0ee71625602b949888b21481a05fb8e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10021
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-14 23:11:42 +00:00
Bryan Bernhart c072fc2653 Define OutOfMemory error
Used to replace CONTEXT_LOST when allocation fails.

BUG=dawn:152

Change-Id: I1b8d0061f2915df71f263e0712dba3d47d08e2b3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10060
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-08-14 18:52:12 +00:00
Austin Eng 40618d0b93 Implement RenderBundle in the backend
Bug: dawn:154
Change-Id: I45496fb2103150dabe32fbc7cb5856dc40c9339f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9222
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-08-14 02:01:14 +00:00
Brian Ho 0ebd54cf38 Update BUILD flags to support Chrome OS
This CL updates a few flags to support Chrome OS:

- Disables the OpenGL backend on Chrome OS builds.
- Removes the X11 dependency for Chrome OS builds because we do not
support X11.
- Removes the XCB dependency (again, no X11).

BUG=chromium:993457
TEST=e2e and unit tests build and pass on Intel Chrome OS devices

Change-Id: I1cb06453ccc94d1b68a6998ea635bddd6fb7b5ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10100
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-13 22:45:14 +00:00
Austin Eng 8a488c1574 Implement RenderBundle in the frontend
This CL implements RenderBundle and RenderBundleEncoder in the frontend
and adds unittests for validation.

Bug: dawn:154
Change-Id: Ice5ecd384cd627ad270b73052408f8139d1ea5f4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9221
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-13 22:12:54 +00:00
Brian Ho 2fb628da46 Remove GLFW dependency for non-GL tests
As part of enabling WebGPU on Chrome OS, we would like to run the Dawn
unit and e2e tests as part of the Chrome OS test suite. This CL removes
the GLFW dependency because Chrome OS does not support GLFW.

The GLFWwindow is only used to create swap chains for the various
backends, but these swap chains are not actually used in the tests
(the e2e tests render to textures instead). The swap chains are only
referenced as part of an unused debugging function:
SwapBuffersForCapture which we can safely remove as per my discussions
with kainino@ and enga@.

We still need GLFW for OpenGL, so we conditionally include it on
platforms that enable the OpenGL backend (which Chrome OS is not).

Note: enga@ suggested to create a VulkanWindowlessBinding that has an
empty GetSwapChainImplementation, but after exploring the option, it
seems like a bit too many ifdefs. In the end, I think it's cleaner to
just remove the *Binding classes entirely.

BUG=chromium:993457
TEST=tests compile and pass for all values of dawn_enable_opengl

Change-Id: I067b12a23f2c236f5506252cd7727b847e79a667
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10080
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brian Ho <hob@chromium.org>
2019-08-13 21:45:44 +00:00
Austin Eng d4ce736d18 Add dawn_platform::Platform for handling tracing events in Dawn
This patch provides Chromium TRACE_EVENT macros and hooks for
implementing the TRACE_EVENT api.

Bug: chromium:958013
Change-Id: I033b1c7ca57c550504a1bea1898a1a152831922b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7060
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-13 19:00:34 +00:00
Yan, Shaobo 35670f183a Skip InheritDynamicOffsetsComputePipeline test on Windows
This test is flaky on Windows on Intel HD 530. Skip it on Windows for now.

BUG=dawn:55

Change-Id: I537ef66ee6b0844e8b1dfd46fae47c5921451e55
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10040
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-08-13 15:47:59 +00:00
Yan, Shaobo b6d7c53708 Reland "Fix dynamic buffer offset issues on D3D12 backend"
Cannot reproduce failure on GTX1060 and GTX2080Ti with latest driver. So disable
inherit test on compute shader and reland this patch

    Original change's description:
    > Fix dynamic buffer offset issues on D3D12 backend
    >
    > This patch fixes
    > 1. Inherit dynamic buffer offsets : dawn chooses vulkan
    > like inherit behaviour, so dynamic offsets need to be inherited.
    > This patch adds inherit dynamic offsets between pipelines support and
    > adds tests to cover it.
    >
    > 2. Dynamic offsets are skipped when groups have been set : in D3D12
    > backend, when invoke SetBindGroup, dawn will check whether this group
    > has already been set and skip updating root signature if the answer is
    > yes. However, this behaviour will affect dynamic offsets update. With
    > the latest patch, we always update dynamic offsets, even if they didn't
    > change and adds tests to cover it.
    >
    > This patch also hit a dawn's issue about storage buffer validation in compute pass.
    > Currently the validation is a workaround to avoid access conflicts but will impact
    > using dynamic buffer offset in compute pipeline. Fix this issue is hard so disable
    > related test for now and will enable it after the issue been fixed. File dawn bug
    > 198 to track this
    >
    > BUG=dawn:55
BUG=dawn:55

Change-Id: Ia105786c035eafc6f68dcb54e6c1145b06c6a630
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9960
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2019-08-13 02:44:48 +00:00
Austin Eng 3318caaa51 Factor RenderPass command validation
Validation of GPURenderBundle will share code with RenderPass
validation. Factor validation of commands for GPURenderBundle
into a separate function.

Bug: dawn:154
Change-Id: I79a229592ead27d462da0dd2d12fbdb95443ff19
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9980
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-13 00:22:28 +00:00
Bryan Bernhart 9b45b5aafa Handle staging buffer map failure on Metal.
BUG=dawn:108

Change-Id: Iae1331e179d112d5b93327e7e44f6a5e870557e7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9882
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-08-12 23:16:17 +00:00
Idan Raiter 74e4834d3d Add wrapping for using external vulkan images as textures
This change adds platform-dependent services that handle creating
semaphores and importing image memory. Then, we use them to wrap a
texture from an outside source, and release a signal semaphore back
when we're done with it. This will be used to allow chrome to render
dawn on Vulkan platforms.

Bug: chromium:976495
Change-Id: I9f07eaf436e10aa6bd88cffdc74fd23834d62ee0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8340
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-10 03:17:52 +00:00
Natasha Lee 8cb23933b1 Ensure clearing attachments is done via renderpass loadop
Clear through loadop instead of standalone clear operation to optimize
efficiency on modern desktop GPUs and mobile GPUs.

Removed clear calls in TransitionForPass for render pass
to help optimize clearing using loadop instead.
Compute pass textures and sampled textures are still cleared in transition.

Bug: dawn:145
Change-Id: I84082bdea3ed7be75683389132d8b296051731b7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8641
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-08-09 17:56:30 +00:00
Austin Eng a9658d967a MemoryTransferService: Separate functions to serialize and get serialization size
Bug: dawn:156
Change-Id: I19317954c64700bdd67aa414d8eb2422d2c3544d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9860
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-09 00:03:20 +00:00
Austin Eng 42e1bba480 Revert "Fix dynamic buffer offset issues on D3D12 backend"
This reverts commit 421584173c.

Reason for revert: Some of the newly added tests are failing on Windows NVIDIA GTX 1660

https://ci.chromium.org/p/chromium/builders/ci/Win10%20FYI%20x64%20Release%20%28NVIDIA%20GeForce%20GTX%201660%29/21

Original change's description:
> Fix dynamic buffer offset issues on D3D12 backend
> 
> This patch fixes
> 1. Inherit dynamic buffer offsets : dawn chooses vulkan
> like inherit behaviour, so dynamic offsets need to be inherited.
> This patch adds inherit dynamic offsets between pipelines support and
> adds tests to cover it.
> 
> 2. Dynamic offsets are skipped when groups have been set : in D3D12
> backend, when invoke SetBindGroup, dawn will check whether this group
> has already been set and skip updating root signature if the answer is
> yes. However, this behaviour will affect dynamic offsets update. With
> the latest patch, we always update dynamic offsets, even if they didn't
> change and adds tests to cover it.
> 
> This patch also hit a dawn's issue about storage buffer validation in compute pass.
> Currently the validation is a workaround to avoid access conflicts but will impact
> using dynamic buffer offset in compute pipeline. Fix this issue is hard so disable
> related test for now and will enable it after the issue been fixed. File dawn bug
> 198 to track this
> 
> BUG=dawn:55
> 
> Change-Id: I2b0f179b3555d37d5b350292eb729767b0d60ab6
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9621
> Commit-Queue: Austin Eng <enga@chromium.org>
> Reviewed-by: Austin Eng <enga@chromium.org>
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>

TBR=kainino@chromium.org,shaobo.yan@intel.com,enga@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: dawn:55
Change-Id: I018e6fa9b4b0905de602ab4ba3294ef537c53759
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9900
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-08-08 22:41:00 +00:00
Austin Eng e9fabf5916 Factor PassResourceUsageTracker to its own file
GPURenderBundleEncoder and GPUCommandEncoder will need to share code
for tracking resource usages.

Bug: dawn:154
Change-Id: I0286f71c4c0638f89be2754c8e9691e67e5db335
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9700
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-08 17:21:39 +00:00
Austin Eng bb10a91876 Fix leak of AttachmentState
Unlike API objects, the AttachmentState object is only used internally
and should have no external references. We should not increment the
reference count on creation because it is Ref'ed internally. This patch
also adds ASSERTs that all Device caches are empty when the Device is
destroyed.

Bug: dawn:154
Change-Id: I5dd46bde03c0be920356444e6b1214ed38e833e8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9761
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-07 21:47:24 +00:00
Yan, Shaobo 421584173c Fix dynamic buffer offset issues on D3D12 backend
This patch fixes
1. Inherit dynamic buffer offsets : dawn chooses vulkan
like inherit behaviour, so dynamic offsets need to be inherited.
This patch adds inherit dynamic offsets between pipelines support and
adds tests to cover it.

2. Dynamic offsets are skipped when groups have been set : in D3D12
backend, when invoke SetBindGroup, dawn will check whether this group
has already been set and skip updating root signature if the answer is
yes. However, this behaviour will affect dynamic offsets update. With
the latest patch, we always update dynamic offsets, even if they didn't
change and adds tests to cover it.

This patch also hit a dawn's issue about storage buffer validation in compute pass.
Currently the validation is a workaround to avoid access conflicts but will impact
using dynamic buffer offset in compute pipeline. Fix this issue is hard so disable
related test for now and will enable it after the issue been fixed. File dawn bug
198 to track this

BUG=dawn:55

Change-Id: I2b0f179b3555d37d5b350292eb729767b0d60ab6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9621
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-07 18:20:33 +00:00
Jiawei Shao 1cd83ffbdd Code clean up in CompressedTextureFormatTests
This patch does some code clean-ups in CompressedTextureFormatTests as
the preparation of adding new tests in the following patches.

BUG=dawn:42
TEST=dawn_end2end_tests

Change-Id: Ie00eeca2d3a161f3673c554b91b54eebea4bf8bb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9740
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-07 07:32:47 +00:00
Jiawei Shao 6de5baa17b Skip several end2end tests
This patch skips several flaky and failed tests on the related Dawn
backends.
1. Tests on all integer/unsigned integer formats in TextureFormatTest on
   Intel OpenGL drivers.
2. All CompressedTextureBCFormatTest tests on Intel Vulkan Windows
   drivers.
3. BufferSetSubDataTests/ManySetSubData on Intel Vulkan Linux drivers.

BUG=dawn:128, dawn:199, chromium:980737

Change-Id: Ia8912804ea762b458be0b48d9df341ff7637f608
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9800
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-07 07:11:57 +00:00
Corentin Wallez ccf805046a Make Snorm formats non-renderable
They aren't guaranteed renderable in Vulkan nor core OpenGL 4.5 without
extensions. They happened to work on a lot of our CQ builders but failed
on Intel OpenGL Linux which helped understand this was an issue.

BUG=dawn:128

Change-Id: I83c4f8116c1125c3bac2f1dd6197976c9063e129
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9682
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-08-05 03:06:22 +00:00
Corentin Wallez bfc9cee5d3 Implement OpArrayLength on Metal
Metal uses a physical addressing mode and buffers are just pointers in
GPU memory that don't have a size. This prevents implementing
OpArrayLength without any additional information. When a shader uses
OpArrayLength on unsized arrays, SPIRV-Cross requires an extra buffer
argument that gets the length of the buffers.

Use that workaround mechanism in the Metal backend by keeping track of
the storage buffer sizes and applying the extra "buffer length buffer"
when a pipeline requires it.

Also adds tests that OpArraySize works in all shader stages.

BUG=dawn:195

Change-Id: I6aa6089aaea85d0589ccad1756e55dd0befefcb5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9386
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-02 18:15:08 +00:00
Idan Raiter ef4f3bd174 Add external memory and semaphore extensions
Also adds GetGlobalInfo, similar to GetDeviceInfo, but for code that wants to query instance extensions or API version.

Bug: chromium:976495
Change-Id: Ia7131aa1780737ec2691cde0007acb86a120d307
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9620
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-08-02 18:10:38 +00:00
François Beaufort 54b4df7069 s/isPIXEventRuntimeLoaded/IsPIXEventRuntimeLoaded/g
Bug: dawn:44
Change-Id: I15768299cadbd5f193ae0e878befc4f5ba5a1c58
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9681
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-08-02 09:57:28 +00:00
Corentin Wallez d64ee1a150 Implement most texture formats on OpenGL
The only missing one is BGRA8UnormSrgb because it doesn't exist in
OpenGL and will need further emulation.

Also suppress most tests on the Mesa Intel GL driver that fails tests
pending further debugging.

BUG=dawn:128

Change-Id: Id454a89711e25b14c7de75a36c7642f2429a0e1f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8364
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-08-02 09:46:58 +00:00
François Beaufort e58fbc48b8 Handle debug markers commands for compute pass encoder
This CL makes sure debug markers commands are handled not only for
render pass encoder, but also compute pass encoder.

Bug: dawn:44
Change-Id: Iad1865d7c20e36d580e1f3f16496e4b90cc1ff34
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9680
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-08-02 09:30:28 +00:00
François Beaufort ae7e0026a5 Make fragment stage optional in RenderPipeline
This CL makes fragment stage optional but still raises a validation
error if set to null in a RenderPipeline.

Bug: dawn:136
Change-Id: Ie900d2e768d251db1e0c4a90738f80b2de15dc2f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9641
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
2019-08-02 07:46:57 +00:00
Idan Raiter c1583a558c Create CommandRecordingContext
Adds a structure that contains wait / signal semaphores and the current command buffer. Will allow us to have a list of pending semaphores after recording, either to consume or do something smarter with in the future.

Bug: chromium:976495
Change-Id: Ib61455039bd97ac8b0ff701af2b694cc8794226d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9600
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-02 05:16:42 +00:00
Jiawei Shao 574b951188 Support BC formats as the first extension in Dawn
This patch refactors the current implementation of BC formats to treat
it as the first extension in Dawn and adds all the related tests.

Note that in Dawn all the extensions are disabled unless we enable them
when we create the device, which means the BC formats can only be used
when we enable the related extension on the creation of the device, and
the creation of the device will fail if the adapter does not support the
extension

BUG=dawn:42
TEST=dawn_end2end_tests
TEST=dawn_unittests

Change-Id: I04d818b0218ebb3b1b7a70a4fea71779f308f85f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9520
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-08-02 00:06:38 +00:00
Corentin Wallez 56f3a7b90d WrapIOSurface: Add support for RGBA8
BUG=dawn:112

Change-Id: I18d2e8bc0bcca2725f2087913955c8ecadbd5852
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9642
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Idan Raiter <idanr@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-08-01 17:58:05 +00:00
Yan, Shaobo 351ea23830 Dynamic Buffer Offset : D3D Backend
In a typical graphics application it is a common usage to update some uniforms once per draw,
and such uniforms include the word positions, orientations, and so on. In the current state of
WebGPU, this means that for each draw call we have to create a new bind group to set the right
uniform values. Bind group creation is expected to be more expensive than
recording draws because a memory allocation is required.

The functionality of dynamic buffer offset is to reduce the number of bind groups that need to
be created.

The patch implements dynamic buffer offset on D3D backend using root descriptor.

Bug=dawn:55

Change-Id: Ia713a4edb3c0ab8f3bba048d7813f343e9dee166
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9040
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-31 01:29:42 +00:00
Jiawei Shao d08611b7a8 Move all the implementations of Toggle to Toggles.cpp
This patch moves all the code related to Toggle from Instance.cpp to
Toggles.cpp to make the code in Instance.cpp cleaner.

BUG=dawn:56

Change-Id: Ica2a779569478a58ddf21e632a211c0c5b889b00
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9580
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-07-30 23:58:52 +00:00
Bryan Bernhart 35ad5221fb Resource Management 3: Buddy allocator
Introduces the buddy system for fast power-of-two sub-allocation.

BUG=dawn:27

Change-Id: I56836ae317ecc5a91d8341c843fc37d4f91fb5af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9260
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-30 16:46:10 +00:00
Corentin Wallez 7b57c5bb77 Check bindgroup validity first in SetBindGroup
bindgroup->GetLayout() was called before checking the bindgroup is an
error, causing an assert to fire in Debug. Adds a regression unittest.

BUG=dawn:196

Change-Id: I58e95879a7f2a7cf5c47c7b228f7e3b5bb72d8ea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9560
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-07-30 06:49:09 +00:00
Yan, Shaobo 34f8bd8c48 Dynamic Buffer Offset : OpenGL Backend
In a typical graphics application it is a common usage to update some uniforms once per draw,
and such uniforms include the word positions, orientations, and so on. In the current state of
WebGPU, this means that for each draw call we have to create a new bind group to set the right
uniform values. Bind group creation is expected to be more expensive than
recording draws because a memory allocation is required.

The functionality of dynamic buffer offset is to reduce the number of bind groups that need to
be created.

The patch implements dynamic buffer offset on OpenGL backend using glBindBufferRange and adds
validation to check whether visibility of resources are none.

Bug=dawn:55

Change-Id: I77e10a9677d1737f377301ee89e29d904c91c298
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9540
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2019-07-30 01:21:19 +00:00
Idan Raiter 7dec2d1c56 Use Vulkan 1.1 if available
Bug: chromium:976495
Change-Id: I10940340fab44b44e26cfb025f8c932a5e62f02e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9500
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-07-29 23:31:49 +00:00
Corentin Wallez 10fe83305a Metal: Pack vertex buffers just after the pipeline layout
WebGPU have a 2D pipeline layout plus a vertex buffer table while Metal
has a single vertex buffer table that contains everything (including
uniform and storage buffers). Previously the space for vertex buffers
was statically allocated in that table which made the last vertex buffer
go out of bound of the Metal vertex buffer table.

This fixes the issue by packing all the vertex buffers that are used
right after the vertex buffers used by the bind groups. This is a
drive-by fix found while looking at reserving Metal vertex buffer 30 to
contain the shader storage buffer lengths.

BUG=dawn:195

Change-Id: If5c67bbc0d15c976793ef43889e50e4a360217d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9387
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-07-29 14:11:06 +00:00
Austin Eng b98f0faa4d Deduplicate AttachmentState shared by RenderPipeline and RenderPasses
This both deduplicates shared state by multiple passes or pipelines and
makes checking pipeline compatibility a single pointer check. It will be
useful for also checking RenderBundle compatibility.

Bug: dawn:154
Change-Id: I0fb289fab5ac76a7fbd500f64b8a6409a246ab32
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9461
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-07-26 19:08:18 +00:00
Natasha Lee e69627f35e Backdoor to get the number of texture lazy clears for testing
Bug: dawn:145
Change-Id: Ie01b21ce490832c459e74c76a7b8d9f203552bfe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9400
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-07-26 17:54:48 +00:00
Bryan Bernhart 506ce9bba4 Fix MSVC builder failure with NextPowerOfTwo.
Define behavior of n=0 when compiling on MSVC.

BUG=dawn:27

Change-Id: If9d454833f5b3d8f0183eba2bc5a54f9ca6e56a2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9440
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-26 11:20:08 +00:00
Jiawei Shao 9d2ccaf65c Vulkan: Support recreating swapchain with SwapChain.Configure()
This patch adds the support of recreating a swapchain with SwapChain.
Configure() on Vulkan backends.
1. Query the Vulkan surface information again.
2. Clean up old swapchain.

BUG=dawn:177

Change-Id: Id7e9e07e9dbbba4a71322367cae10fb179106220
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9340
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-07-25 01:08:14 +00:00
Bryan Bernhart 2718177841 Resource Management 4: Stress test buffer writes
Add test for many buffer writes.

BUG=dawn:27

Change-Id: I026c3b9a6d30c7c6634b89db9798902b036150c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9280
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-07-24 20:09:44 +00:00
Austin Eng fde94905fe Factor EncodingContext out of CommandEncoderBase.
This patch factors the CommandAllocator, CommandIterator, and error
handling out of CommandEncoderBase so it can later be used by the
RenderBundleEncoder.

Bug: dawn:154
Change-Id: Ia4f8c3ce7f432f0887b619bd8090aa9bec7330fc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9181
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-07-24 18:15:24 +00:00
Natasha Lee 8944f0205b Test that sampled textures in compute and render pass get lazy cleared
Bug: dawn:145
Change-Id: I719faf0a07a2011be0cdee3a7bead2437f524ba7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8660
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-07-23 20:30:24 +00:00
Stephen White 68d97adf88 Prefer <cstring> to <string.h>.
Change-Id: I9f862ebfc589379f27cb5e92a80080946988efcb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9360
Commit-Queue: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-23 17:04:34 +00:00
Corentin Wallez 4e3b218e96 Introduce a format table in the OpenGL
The information about formats in OpenGL will grow to include more
information than just (internalFormat, format, type) and will gain more
logic to depend on GL version and available extensions over time.

BUG=dawn:128

Change-Id: I63a6ac7d48797fb4a9f97a65871306e640cf41d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9201
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-23 06:40:54 +00:00
Jiawei Shao 722c4fa8b2 Fix missing header in OpenGLFunctions.cpp
This patch adds the missing header <tuple> in OpenGLFunctions.cpp to
fix a build error on Windows that the compiler cannot find the
definition of std::tie().

BUG=dawn:190

Change-Id: I35d1f258d3b6197187d626870f3347e195881da8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9300
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-23 06:34:14 +00:00
Bryan Bernhart 07b5be3bc5 Resource Management 2: Buffer mapping error handling
Add error handling for buffer mapping ops.

BUG=dawn:27

Change-Id: I9a66baf74c27b137990608c31cb04af8023594b0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9241
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-07-23 00:04:59 +00:00
Bryan Bernhart 40793232d8 Resource Management 1: Math ops
Support 64-bit log2 and power-of-two alignment.

BUG=dawn:27

Change-Id: I2d254e5dda9626a6e26017b0d8e33f5db4c9298d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9224
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-07-22 21:42:18 +00:00
Austin Eng 0e338ff986 Fix compilation of MemoryTransferService Read/WriteHandle on Windows
Inner classes needed the macro DAWN_WIRE_EXPORT.

Bug: dawn:156
Change-Id: If45ff9ed14623be32e7821ba3a60791a365bb0dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9240
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-22 19:09:09 +00:00
Corentin Wallez 4e9923cb96 Remove suppression fixed for Linux Intel Vulkan
This was fixed by https://dawn-review.googlesource.com/c/dawn/+/9160
that avoids doubling the size of the internal ringbuffer each
re-allocation.

BUG=chromium:980737

Change-Id: Ic8052eb4e9d2b835534aeaef4e1db43489523602
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9206
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-07-22 14:16:39 +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
Corentin Wallez fefb3ab120 OpenGL: Use the correct size to lazy-clear mips
We would incorrectly use the size of the first mip level to clear
non-zero mip levels. This was found while enabling debug output in
the OpenGL backend.

BUG=dawn:190

Change-Id: I29a87b87057d425d1c131d11afdc7ca4716607c8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9202
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-07-22 09:50:21 +00:00
Corentin Wallez 9dffe11696 OpenGL: Don't bind non-existent shader resources.
In OpenGL we have to query a resource's location or index before we can
bind it. The driver can tell us that the resource doesn't exist using
special values (-1 for locations, GL_INVALID_INDEX for indices). This
happens when Dawn compiles a pipeline that has bind group bindings that
none of the shader modules uses.

This was found while enable OpenGL debug output.

BUG=dawn:190

Change-Id: I58b3a1a65f87b4408985c1258f1a95379e6b540e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9203
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-07-22 09:24:51 +00:00
Austin Eng 69f1db7248 Add RenderEncoderBase to match WebGPU class hierarchy.
This is needed so that RenderBundleEncoder and RenderPassEncoder can
share code. This patch also moves EndPass out of ProgrammablePassEncoder
and into both RenderPassEncoder and ComputePassEncoder. Render bundles
do not have EndPass.

Bug: dawn:154
Change-Id: Ib7126b2ba718b0b93e3d6f15c429ac910c0d5d31
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9180
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-07-20 01:34:56 +00:00
Yunchao He c0b8132f55 Implement RenderPassEncoder::SetViewport: impl on backends
Implement SetViewport on the rest backends: D3D12 and Metal

BUG=dawn:53
TEST=dawn_end2end_tests

Change-Id: I2e552867080eb8c35db641d1a61b0341d2a0a048
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9020
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-07-19 21:57:39 +00:00
Stephen White 472bd1ec29 Add some missing #includes.
Skia-dawn found these; not sure why Chrome and Dawn standalone don't.

Change-Id: I43706fbaca94d1718de0be727151dd8f3a191df2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9220
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-07-19 21:51:09 +00:00
Austin Eng 72724b8d25 Add wire tests and mocks for the MemoryTransferService
This CL tests integration of the MemoryTransferService with buffer mapping.
It tests the basic success and error cases for buffer mapping, and it tests
mocked failures of each fallible MemoryTransferService method that an embedder
could implement.

Change-Id: Iece660fb49664cc6a09a0b0b8dbe59e2882a6017
Bug: dawn:156
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8841
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-19 16:16:58 +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
Jiawei Shao 49aae0f3bd Double the size of the ring buffer only when it is not big enough
Currently Dawn always doubles the size of the largest ring buffer
everytime when DynamicUploader::Allocate() is called, which is not
necessary and will cause out-of-memory errors when this function is
called for too many times. This time fixes this behaviour by only
doubling the size of the largest ring buffer when it is not big enough
for the request buffer size.

BUG=dawn:108
TEST=dawn_end2end_tests

Change-Id: I734493dbc632ca8e9a30c1ceeb0b7b9e0474656b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9160
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-07-19 00:09:28 +00:00
Yunchao He 91ec571d17 Impl RenderPassEncoder::SetViewport: add more tests
This patch meant to add tests for SetViewport to verify that the
viewport we set in one render pass will not impact the viewport(s)
in other render pass(es).

These newly added tests exposed a potential error on OpenGL backend.

This patch also implemented SetViewport and fixed the bug on OpenGL.

BUG=dawn:53, dawn:189
TEST=dawn_end2end_tests

Change-Id: Ia2e74f003c02acdcf983b24a3386efab30793652
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9140
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-07-18 16:17:34 +00:00
Corentin Wallez 1546bfbdec Precompute all the Formats at Device creation in the FormatTable
This is needed for two reasons:
 - TextureBase and TextureViewBase stored Formats by value which isn't too
much overhead at this time but will get bigger in the future.
 - The OpenGL backends needs its own GLFormat structure to store data about
each format which will eventually contain complicated logic to detect
support in the GL driver so it shouldn't be duplicated in Textures.

The computations of the information about Format is moved from being done
whenever they are needed to being precomputed at DeviceBase initialization.
This makes each format have a constant "index" in that can be used in the
backends to address their own structure, for example a GLFormat table.

Also some DeviceBase pointers were made const for validation.

BUG=dawn:128

Change-Id: I37d1e9c739b87cddcea09cb1759e175704d90f9e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9101
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-18 09:25:04 +00:00
Corentin Wallez d6cc1fe099 Add an implementation of Result<const T*, E*>
The existing implementation of Result with tagged pointers was not able
to handle constant pointers for the result. This is required in
follow-up CLs to return internal formats in a ResultOrError.

This CL extracts the tagged pointer logic out of Result<T*, E*> so it
can be shared with Result<const T*, E*>.

Tests are also added to cover Result<const T*, E*>.

BUG=dawn:128

Change-Id: Id19ae8e1153bcfcaf94d95ac314faf2b23af6f91
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9100
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-07-17 19:01:50 +00:00
Corentin Wallez 9dbb81f004 Add missing validation for unsupported texture view dims.
BUG=chromium:984809

Change-Id: Iea6bf88f79f9749237052c16e0ab2dd15d7d4308
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9081
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-17 14:49:37 +00:00
David 'Digit' Turner ee0fa175a3 Update Vulkan headers to v1.1.115
This updates the content of third_party/khronos/vulkan
to match the upstream v1.1.115 headers.

+ update third_party:vulkan_headers to define the VK_USE_PLATFORM_XXX
  macros directly, since this better matches the upstream BUILD.gn
  file behaviour.

NOTE: A better patch would use a DEPS entry to get the Vulkan
      headers. That's exactly what [1] does, but fails to
      integrate with Chromium due to its messy situation
      regarding the use of vulkan headers.

      Once the Chromium situation is fixed, it will be possible
      to remove third_party/khronos/vulkan entirely and rely
      on a DEPS entry.

[1] https://dawn-review.googlesource.com/c/dawn/+/9080

BUG=NONE

Change-Id: Id9a3be3e079119368236c0323823e36bec1a056d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9082
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-17 14:48:27 +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
David 'Digit' Turner 56a21a6151 Make GN //src/common target easier to use when Vulkan is enabled.
Ensure that //src/common exports the appropriate config settings
when vulkan is enabled. This CL tries to address several issues
at once:

- A target that depends on //src/common and wants to find
  "common/vulkan_platform.h" needs to have "${dawn_root}/src"
  in its include_dir.

- Same target needs to have DAWN_ENABLE_VULKAN macro to avoid
  a compile #error message when including "common/vulkan_platform.h"

- Same target needs to be able to find <vulkan/vulkan.h> which
  is included by "common/vulkan_platform.h".

This is achieved by ensuring that the "dawn_internal" config,
is provided as a public_config by the GN ":common" target.
And by adding third_party/vulkan_headers as a public_deps
if |dawn_enable_vulkan| is true.

Note that "dawn_internal" is used by several other targets
in Dawn BUILD.gn files, hence why it was not renamed to something
else like "dawn_common_config" here.

+ Simplify targets that currently depend on ":common" so they
  no longer need to add vulkan_headers as an explicit dependency.

Change-Id: I2030c1e209a8186c141d4c06a0d52fb21695bb51
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8962
Commit-Queue: David Turner <digit@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-07-17 08:54:18 +00:00
David 'Digit' Turner 8605d2eb86 Enable Vulkan extensions for Linux, Windows, Android and Fuchsia.
This CL ensures that when <vulkan/vulkan.h> is included, the
appropriate VK_USE_PLATFORM_XXX macro is defined to enable the
declaration of platform-specific types and extensions.

Note that for Linux, this requires an xlib_with_undefs.h header
to remove annoying macros that are defined by <X11/X.h> (i.e.
Success, Always, None) and which prevent compilation of other
Dawn sources that use the same symbols as enum value names.

Change-Id: I0c8d95fe8043d75ba3f74789e0fe2e3e4a477703
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8961
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: David Turner <digit@google.com>
2019-07-17 08:22:19 +00:00
Li, Hao 6eb681cc54 Metal: use the IORegistry to get the PCI ids
MTLDevice.registryID points to an entry in the IORegistry from which we
are able to find the entry for the actual GPU device, which contains
properties for the PCI device and vendor ids.

But MTLDevice.registryID is introduced from macOS 10.13. For macOS <=
10.12, we get the PCI ids by matching them with MTLDevice.name.

BUG=dawn:120, dawn:184

Change-Id: If4040c623fc61115c88d453eee0f2d05ed17a546
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8920
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2019-07-17 01:04:50 +00:00
Li, Hao 1ffb0d6a02 OpenGL: use vendor name to get PCI vendor id
OpenGL doesn't allow to query PCI information, but we can get vendor name through glGetString(GL_VENDOR), then match it with vendor id.

BUG=dawn:184

Change-Id: Icdcdc6bfdb5cd561b5057e8b2eab06df2dd5cea1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8940
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2019-07-17 01:04:30 +00:00
Jiawei Shao 5580970f59 Support all BC formats on D3D12, Metal and Vulkan
This patch adds the support of all BC formats on D3D12, Metal and
Vulkan and related end2end tests.

BUG=dawn:42
TEST=dawn_end2end_tests

Change-Id: I50caf687d3cfee7df80070952f55f96dc363a830
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8900
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-07-17 00:00:10 +00:00
Yunchao He d6f13c645b Implement RenderPassEncoder::SetViewport: add end2end tests
The main aim of this CL is to add tests for SetViewport. But it
also implements the feature on Vulkan backend to verify the tests.

BUG=dawn:53
TEST=dawn_end2end_tests

Change-Id: I9578b2d9650cb952ce67cf91f79e9682c9932ee3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8820
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-07-16 19:27:09 +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 d3e7f944ab Fix double to float conversion warning on MSVC
BUG=

Change-Id: Iccae33f4c925c554e73e40a70d490a26d54949bf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9001
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-16 15:05:09 +00:00
Yan, Shaobo c8ab96cdd9 Add an end2end test to ensure dawn cache system considers dynamic attributes
Binding layout uses an attribute to mark dynamic resource. And this should be taken into
consideration when determining whether two bindingInfo are equal.

Otherwise, dawn cache system may take two different bind group layouts(they have same binding
resource type, masks and visibilities but one bind group has dynamic resource and the other
not) as the same. This will return wrong bind group layout object to user and cause validation
error when user tries to use dynamic buffer offset.

BUG=dawn:188

Change-Id: I11b158724c7592718af434b48c9e3f2f9bb72b93
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8901
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-16 08:37:49 +00:00
Corentin Wallez f07e85c604 Add missing WebGPU enums and defaulted members.
These additions to dawn.json don't require changes to users of the C++
API so they are done now to prepare for webgpu.h. Validation is added
that forbids using the new enum values and non-default values for
members until they are implemented.

BUG=dawn:22

Change-Id: Ie6f3384243d6874e7aca4b94733409755a066c93
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8862
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-07-15 20:47:56 +00:00
Corentin Wallez dd15b11b21 Add .gitattributes to normalize EOL
BUG=

Change-Id: I7b77180eaf440f9d1894216e5a1a0b56af1de2cf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8860
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-07-15 12:23:18 +00:00
Corentin Wallez d757c300a4 Validate usage of dynamic at the BGL level.
Previously validation of the combination of dynamic with the binding
type was only done when creating the bind group when it should have been
done when the bind group layout is created.

BUG=dawn:55

Change-Id: I976f7e052f9737929fc05908af50e6ad5ceef397
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8861
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-15 10:29:08 +00:00
Yunchao He 5de3e0aaa4 Fix a few more coding style issues for shader
The indentations for shader are incorrect.

BUG=dawn:186
TEST=dawn_end2end_tests

Change-Id: I6707e46f6ebbc267a6d465bb5dd94183433f3ba0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8880
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-15 07:46:31 +00:00
Corentin Wallez 2a1d8c2b1d Remove ShaderStage that doesn't exist in WebGPU.
Instead it is replaced by one enum in dawn_native and another in utils.

BUG=dawn:22

Change-Id: I094a40c8d4e22b704e59aea60cbefd1f05c5352a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8800
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-07-12 17:52:22 +00:00
Jiawei Shao 06ab6e5b13 Metal: Code clean up in copy commands
This patch cleans up the code related to both buffer-texture and
texture-texture copies on Metal backend by moving the creation of
MTLOrigin and MTLSize into helper functions.

BUG=dawn:42

Change-Id: Ia3340b9c8b0a5001d775cd391fb8301207b4d2ac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8840
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-07-12 07:18:11 +00:00
Corentin Wallez 2d8ba5fac6 Add rendering tests for all color formats
BUG=dawn:128

Change-Id: I32cab39e77847388a7736a51532a1b5c24a0fde7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8684
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-12 07:13:41 +00:00
Brandon Jones e896a0da66 Implement Implicit State Decays For D3D12
When resources are accessed on a command list, the resource will
implicitly decay in some scenarios. This commit tracks when the decay
occurs to more frequently enable implicit promotion.

Bug: dawn:167
Change-Id: Ide4c06454efe136baee0d39a3437a407a613bcc7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8243
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-07-11 22:58:55 +00:00
Yunchao He 4b24886afe Use R"(shader source)" to keep consistent
BUG=dawn:186
TEST=dawn_end2end_tests

Change-Id: I6b5b6590e917965537238ca86ec4af7ce6dc969a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8781
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-07-11 18:15:35 +00:00
Yunchao He 110700304f Culling and FrontFace: verify the framebuffer coordinate
This patch is to verify the framebuffer coordinate in Dawn (and WebGPU).
It shows that gl_FragCoord(0, 0) is at the top left.

BUG=dawn:43
TEST=dawn_end2end_tests

Change-Id: Ifd16488169c986d0c2c85eb92283c69e70ad33ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8780
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-07-11 15:55:45 +00:00
Corentin Wallez 002395300f Make RG11B10 non-renderable.
This also adds the extra validation needed to support non-renderable
formats, as well as tests for it

BUG=dawn:128

Change-Id: I3bc79b641aa0fd5e3358f89a87f2e457d0ecc58a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8760
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2019-07-11 14:57:15 +00:00
Jiawei Shao ea2d558479 Support BC5 formats on Metal
This patch adds the support of BC5 formats on Metal and the related
dawn_end2end_tests to verify Dawn works correctly when (bufferSize -
bufferOffset < bytesPerImage * copyExtent.depth), which is the special
case of buffer-to-texture and texture-to-buffer copies on Metal.

BUG=dawn:42
TEST=dawn_end2end_tests

Change-Id: I27c384d0d8d2bb908f1ad15c2451fd23c1313598
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8720
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-07-10 23:58:13 +00:00
Corentin Wallez 4b90c47ce0 Add missing descriptors that are present in WebGPU.
These are the CommandEncoder, ComputePass and CommandBuffer descriptors
that contains nothing but a debug name for now but are important for
later extensibility. Defaults are added so the C++ API doesn't require
the descriptors to be passed as arguments.

Also renames variables named "info" for RenderPassDescriptor to
"descriptor" as is now the standard in the codebase.

BUG=dawn:22

Change-Id: I9de4cfbbce952d01fb79ed1d9f34825a6fa174f9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8686
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-07-10 20:43:13 +00:00
Corentin Wallez bb218b8aea Implement WebGPU formats on D3D12
BUG=dawn:128

Change-Id: I1a71df25d9b7f003882366f052b83085ac5d1258
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8620
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-09 12:04:39 +00:00
Jiawei Shao 3e1bca702c Metal: Move all the computation in buffer-texture copies to one function
This patch refactors the code of buffer-texture copies on Metal backend
by moving all the computations on the split of one buffer-texture copy
into multiple copies into one function ComputeTextureBufferCopySplit so
that a lot of redundant code can be removed.

BUG=dawn:42

Change-Id: Ie82e34e55aad3981d7b19da786da383e0a9a985c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8700
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-07-09 08:47:07 +00:00
Yan, Shaobo f697fe3b7d Add dynamic attribute in bind group layout binding
WebGPU remove dynamic-uniform-buffer and dynamic-storage-buffer but add a new attribute in
BindgroupLayoutBinding to record whether a buffer resource is dynamic.
Dawn need to align with this change.

BUG=dawn:180

Change-Id: I873ad2ec75575e72d184f89a6e3698dff6df50d7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8520
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-09 07:58:57 +00:00
Corentin Wallez 6be313225e Invert component names in RG11B10 and RGB10A2
The CL that introduced this formats reordered their components based on
the name of the Vulkan formats, but it turns out that WebGPU lists
components from low bits to high-bits while Vulkan PACK32 formats are
listed from high to low. So the format component orders match, except
for RGB10A2 which is actually BGR10A2 in Vulkan. Instead the Vulkan
backend is updated to correctly use the RGB10A2 format.

BUG=dawn:128

Change-Id: If7f045f020429c44c84b9aed34a4a80107208d5c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8601
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
2019-07-08 10:12:16 +00:00
Corentin Wallez ec05355c72 Rename Transfer[Src|Dst] to Copy[Src|Dst]
This is to match the equivalent rename in WebGPU's IDL.

BUG=dawn:22

Change-Id: Ibdf75869e58835d984df559878b884c55310a403
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8623
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Yunchao He <yunchao.he@intel.com>
2019-07-08 10:05:46 +00:00
Corentin Wallez 3c3e2bc4d9 Use mipLevel/arrayLayer for TextureCopyView
These are the names for the level/slice concept in WebGPU and this one
occurence was forgotten in the previous rename.

BUG=dawn:22

Change-Id: I0aef05e21b2291cf02712034c6ddc3ab62ecbc33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8681
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-07-08 09:41:51 +00:00
Corentin Wallez a0491c9141 Rename AddressMode::MirroredRepeat to MirrorRepeat.
This is to match the name in the WeBGPU IDL.

BUG=dawn:22

Change-Id: I0a4a7b62afa30cfd699d90efb2dd0c085778883b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8624
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Yunchao He <yunchao.he@intel.com>
2019-07-08 09:36:31 +00:00
Corentin Wallez 7843076b01 Implement WebGPU formats on Metal.
This removes the R5G6B5 format that's only available on iOS on Metal and
leaves A2RGB10 unimplemented because it has inverted R and G channels
compared to Metal's RGB10A2 format.

BUG=dawn:128

Change-Id: I9b960d00f281b4d32318bad3360826b8db5bcb72
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8600
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-08 09:28:51 +00:00
Corentin Wallez e409acf561 Rename SamplerDescriptor::compareFunction to compare.
This is to match the WebGPU IDL.

BUG=dawn:22

Change-Id: I63e32fe980c1727562055221ea2769a670461e93
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8625
Reviewed-by: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-08 08:29:57 +00:00
Li, Hao 35716c204d Add adapter filter flag by vendor id for end2end tests
Now end2end tests always run with first adapter (the last adapter for
Metal because of dawn:29) on multi-GPU systems. Add
'--adapter-vendor-id' flag to make it run with specified adapter.

BUG=dawn:181

Change-Id: Iaff3ab92a502f88b24e4aa8a5ed3cb4d1d5925e3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8460
Commit-Queue: Hao Li <hao.x.li@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-08 03:25:54 +00:00
Corentin Wallez 769edd065b Fix compilation on MSVC
BUG=

Change-Id: Ic813917322fdec5ccd97ebedd13435ba243d1de4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8622
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-07 17:53:13 +00:00
Yunchao He d2631f86e7 Implement Culling and FrontFace
This patch implements Culling and FrontFace on backends, and add tests too.

This test also verified that we couldn't invert FrontFace on Metal backend.
Otherwise, the tests would fail on all HWs.

But we do need to invert CCW/CW on OpenGL backend. Because Y axis is up in
OpenGL while Y axis is down in WebGPU.

Bug=dawn:43

Change-Id: I7dd0922477397a13c5f7208e104ff352a673a556
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8420
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-07-06 00:11:10 +00:00
Corentin Wallez c6d2d8e8fb Suppress failure on Win NVIDIA GTX 1660
BUG=chromium:981393

Change-Id: I0b3f45ad963f62e12ec77c251a81bc0076958e12
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8621
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-05 13:16:19 +00:00
Jiawei Shao 3392b200c6 Support BC5 formats on D3D12
This patch adds the support of BC5 formats on D3D12 backend. On D3D12,
the "rowPitch" refers to the number of bytes in a row of blocks (which
covers up to 4 scanlines at once) for the textures in BC formats.

This patch also adds the related end2end tests for four typical cases of
B2T and T2B copies on D3D12:
(1) copyBytesPerRowPitch + byteOffsetPerRowPitch <= rowPitch and
    texelOffset.y == 0
(2) copyBytesPerRowPitch + byteOffsetPerRowPitch <= rowPitch and
    texelOffset.y > 0
(3) copyBytesPerRowPitch + byteOffsetPerRowPitch > rowPitch
(4) texelOffset.z > 0

BUG=dawn:42
TEST=dawn_end2end_tests

Change-Id: If27ab3e56596e25c1c5be787ca021c0748021a46
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8541
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-05 08:06:30 +00:00
Yan, Shaobo 3789858479 Fix the failures in dynamic buffer offset tests with Vulkan validation layer enabled.
The root causes of these failures are as follows:
1. 'fragmentStoresAndAtomics' feature is not enabled when we create the Vulkan device.
2. The binding value of dynamic buffer offset end2end test not set correctly.

For failure reason 1, this patch enabled fragmentStoresAndAtomics.
For failure reason 2, this patch modify dawn validation logic in SetBindGroup to check
binding size and update binding size in dynamic buffer offset end2end test.

BUG=dawn:170

Change-Id: I46f12453d4c83d9d3c7de6e183442cf516335f2f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8320
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-05 08:01:10 +00:00
Yunchao He 050ab49a23 Implement RenderPassEncoder::SetViewport - front end
This patch implements RenderPassEncoder::SetViewport. It also adds
validation code, and validation tests as well.

BUG=dawn:53
TEST=dawn_unittests

Change-Id: Idc27f4098761a57fc10e53be82bd3c4b35b53cb4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8542
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-04 15:30:59 +00:00
Jiawei Shao 72508d6d06 Support BC5 formats on Vulkan
This patch supports BC5 formats on Vulkan backends and adds related
Dawn end2end tests.

For the textures with BC formats, they could have non-multiple-of-4
sizes on the non-zero mipmap levels in sampling, but we are still
required to provide texture data in complete 4x4 blocks in texture
copies because that is the size of which they are stored in GPU memory.

In this patch, we refer the term "physical memory size" as the memory
size of the texture subresource in GPU memory, and the term "virtual
memory size" as the size used in texture sampling. As Dawn requires
the Extent3D in texture copies must fit in the physical memory size,
while Vulkan requires it must fit in the virtual memory size, this
patch recalculates the imageExtent to ensure it always follow this
Vulkan validation rules.

For Dawn end2end tests, note that we use pure green and pure red for
the textures because BC5 does not support SRGB formats. Furthermore,
"CopyPartofTextureSubResourceIntoNonZeroMipmapLevel" is skipped in
this patch because there is an issue on the T2T copies from a region
within the virtual size of one texture to another one that exceeds
the virtual size of another texture in Vulkan SPEC.

BUG=dawn:42
TEST=dawn_end2end_tests

Change-Id: I17518cd335fb13125cb753bbf879bc06eb20e426
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8260
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-07-02 23:55:55 +00:00
Austin Eng c246494dbf Skip ManySetSubData test on Linux Vulkan Intel.
This test is crashing on the bot upgrade to Ubuntu 19.04.

TBR=cwallez@chromium.org
Bug: chromium:980737
Change-Id: I3fe1860fb14ae41c19dae0b0a82db2410d505a96
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8540
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-07-02 23:40:15 +00:00
Natasha Lee 4886403b61 Clear OpenGL textures on first use if not initialized already
This prevents dirty textures to be used when memory is recycled while
destroying/creating new textures. If a texture is being used for the
first time and has not yet been initialized, it will be cleared
to zeros.

Bug: dawn:145
Change-Id: I1140ff0535241b247b855df2afefc01fbc003470
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8380
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-07-02 17:38:09 +00:00
Rafael Cintron ce32a94b37 Remove mResourcePtr member from d3d12::Texture
mResourcePtr is not necessary because mResource already contains a
pointer to the resource

mResourcePtr is initialized in the constructor that takes an
ID3D12Resource but mResource is not. This causes memory corruption
when the caller releases the resource out from under the object.

Texture::DestroyImpl was releasing mResource but leaving mResourcePtr
pointing to freed memory

Bug: dawn:62
Change-Id: Ib68786fc041e57dbf184c09c9afe4b9d8fa3241f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8500
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-07-02 07:15:17 +00:00
Jiawei Shao 521003fd4e Move all the validations on imageHeight to one function
This patch moves all the validations on imageHeight to one function so
that we no longer have two versions of ValidateImageHeight().

BUG=dawn:42

Change-Id: Ieadca2a1010b67252adb7e4f2452d9e53aebdf8b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8480
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-07-02 00:06:55 +00:00
Corentin Wallez 773a551d1a Newline fixes and tiny cleanups for lazy-0-init
BUG=

Change-Id: I1165b0d75b4e2796ff89ffabb2401c474955ee2a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8440
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-01 09:58:36 +00:00
Corentin Wallez 431d618961 Add most WebGPU texture formats on Vulkan
This adds the formats to dawn.json, implements support in the Vulkan
backend and adds tests performing basic sampling checks for all formats.

The R8UnormSrgb and RG8UnormSrgb formats skipped because they are not
required in Vulkan (and RG8UnormSrgb is in fact not supported on the
machine used for developing this CL). A PR will be sent to the WebGPU
repo to remove the from the initial list of formats.

The RG11B10Float and RGB10A2Unorm formats of WebGPU are replaced with
B10GR11Float and A2RGB10Unorm that are the formats exposed by Vulkan. It
is likely that all APIs implement them with components stored in that
order.

Each format except depth-stencil ones is tested by uploading some
interesting texel data and checking that sampling from the texture
produces correct results. The goal is to make sure that backends don't
make a mistake in the giant switch statements. There was no effort made
to check the hardware implementation of the formats.

Tests will later be extended to cover rendering and clearing operations
as well as multisample resolve.

It isn't clear if depth-stencil format will support TRANSFER operations
in WebGPU so these are left untested for now.

BUG=dawn:128

Change-Id: I78ac5bf77b57398155551e6db3de50b478d69452
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8363
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-01 09:58:07 +00:00
Corentin Wallez 293ea7746d Make RenderPipeline::ValidateCompatibleWith produce an error message
Previously it would only return a boolean which made it difficult to
know why the validation is failing.

BUG=dawn:128

Change-Id: Id129a84f7777ba2efc5f12292aeccb83c076b9af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8362
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-26 20:28:13 +00:00
Corentin Wallez 77aa5b59aa Add support to NaN in Float32ToFloat16
This will be used to test NaN is correctly sampled from float16
textures.

BUG=dawn:128

Change-Id: I6e3b79f438e9a48c3a167ab45baf9f9d019ce48b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8361
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-06-26 20:26:13 +00:00
Corentin Wallez ebcf0d31c0 Add missing Reference count in null Device.
The pending CopyFromStagingBuffer operation didn't keep a reference to
its Buffer causing a use-after free in some cases.

BUG=chromium:976573

Change-Id: Ib53c294874d175d2a21b65676fb71e62f42619b0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8365
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:53:34 +00:00
Rafael Cintron 751252e372 D3D12: Use D3D12_BUFFER_UAV_FLAG_RAW when creating unordered access views
Since SPIRV-Cross outputs HLSL shaders with RWByteAddressBuffer,
we must use D3D12_BUFFER_UAV_FLAG_RAW when making the
UNORDERED_ACCESS_VIEW_DESC. Using D3D12_BUFFER_UAV_FLAG_RAW requires
that we use DXGI_FORMAT_R32_TYPELESS as the format of the view.
DXGI_FORMAT_R32_TYPELESS requires that the element size be 4
byte aligned. Since binding.size and binding.offset are in bytes,
we need to divide by 4 to obtain the element size.

Bug: dawn:159
Change-Id: I52481aea1fe190d54286c099a68f3e21dbe05330
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8341
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-26 08:08:46 +00:00
Yizhou Jiang 41c24ee4eb Fix computation of mipmap sizes used in validation
The width and height of the mipmaps level > 0 weren't computed
correctly. Size of mip level of a texture should be greater than
0.

BUG=dawn:176

TEST=dawn_unittests --gtest_filter=CopyCommandTest*.CopyNonSquareTexture

Change-Id: I730aef3fd8c036567f824cd707d1ea1a69b132c0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8242
Commit-Queue: Yizhou Jiang <yizhou.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-06-25 03:09:26 +00:00
Li, Hao 6fa398e682 Supress failing end2end tests with Metal validation layer
The 3 tests run failed with Metal validation layer, which block end2end tests run with validation layer in CQ. Suppress temporarily while we're fixing.

BUG=dawn:139

Change-Id: I0b6c99ac731b90cd10b8b1f7bb5d3f5e1976fb07
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8241
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-25 00:49:56 +00:00
Natasha Lee 99b76d1b8f Clear D3D12 texture on first usage if not yet initialized
This prevents dirty textures to be used when memory is recycled while
destroying/creating new textures. If a texture is being used for the
first time and has not yet been initialized, it will be cleared
to zeros.

Bug: dawn:145
Change-Id: I8b9571c5a8fdd366717ffbd0fafca89b86653cea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8062
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-06-24 17:49:46 +00:00
Li, Hao 4ec2c1060e Init PointSize value when pipeline topology is PointList in end2end
When pipeline topology is set to Point_List, PointSize must be written
in vertex shader for Vulkan backend.

BUG=dawn:146

Change-Id: Id5aac73bb7e60646503f1ea06c2aa0d39c8384b3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7820
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-21 10:56:35 +00:00
Corentin Wallez a92f83b725 Add internal Format structure for texture formats
Texture formats have plenty of properties we'd like to query on them
like their texel size, whether they are compressend or if they are depth
stencil. Instead of making switch statements for each of these
properties, we store them in a new `Format` structure. Textures compute
their format only onces and then pass a const reference to it on
GetFormat().

This is in preparation of adding all WebGPU texture formats.

BUG=dawn:128

Change-Id: Iad2831cf16f14e1a1bfce2c10b22527fc982d1aa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8166
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-21 10:16:15 +00:00
Rafael Cintron 4729b15365 Add begin-capture-on-startup testing flag
In order to debug single frame applications such as unit tests with
with PIX, you need to call BeginCapture() at the start of your
application.

This change adds a begin-capture-on-startup flag to the Dawn test
environment. The flag, when set, will call BeginCapture() right after
the DXGI factory is created.

Bug: dawn:44
Change-Id: Ibb8f7b05707915510f9886524f0144c0576d2603
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8200
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-21 02:09:05 +00:00
Natasha Lee bfd0d94a31 Fix vulkan clear texture image layout format
Also ensure depth stencil texture is clear in begin render pass.

Bug: dawn:175, dawn:145
Change-Id: I19fc857dedf9f353a4834b8e1c9616d02c5a15ac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8140
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-20 20:05:15 +00:00
Corentin Wallez db8b3fa44c Remove unnecessary DeviceBase::GetDevice
BUG=

Change-Id: Iac73c9ffb4900961a0b47bf26dac049518021af2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8165
Reviewed-by: Idan Raiter <idanr@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-06-20 09:08:24 +00:00
Ryan Harrison 24f8d1870b Migrate to use new Shader Model API
The currently used method, SetShaderModel has been deprecated in
favour of SetHLSLShaderModel. This CL migrates Dawn, so that the
deprecated method can be removed from upstream.

BUG=chromium:976798

Change-Id: Id1e655b77291179dd6e15f1a85c8664f07cf8396
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8220
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-19 15:48:59 +00:00
Corentin Wallez 77fa31c5c6 Make Texture format names match WebGPU
BUG=dawn:128

Change-Id: I73cc77082d02941d91fab8ee578e529db979fed1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8164
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-06-19 09:26:07 +00:00
Jiawei Shao 872c1d7fe9 Add validations to the texture copies with BC formats
This patch adds the validation on the texture copies with BC formats.
1. BufferCopyView.offset in B2T and T2B copies must be a multiple of the
   compressed texel block size in bytes.
2. BufferCopyView.rowPitch in B2T and T2B copies refers to the number of
   bytes from the start of one row of blocks to the start of the next
   row of blocks.
3. BufferCopyView.imageHeight must be a multiple of the compressed texel
   block height (4 for BC formats).
4. All members in TextureCopyView.origin must be a multiple of the
   corresponding dimensions of the compressed texel block (4x4x1 for BC
   formats).
5. All the mumbers in 'copySize' must be a multiple of the corresponding
   dimensions of the compressed texel block (4x4x1 for BC formats)
   because D3D12 requires the width and height of a texture in BC
   formats must be multiples of 4.
6. Compute the texture size in non-zero mipmap levels with paddings for
   textures in BC formats when necessary.

BUG=dawn:42
TEST=dawn_unittests

Change-Id: Iac8d6c93ab8b37bb46becffd4175339722ab6016
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7860
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-18 01:06:09 +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
Corentin Wallez abdb566c30 Remove OpenGLBinding's dependency on glad
This move all the OpenGL-specific code for swapchain handling in a new
NativeSwapChainImpl in the OpenGL backend so no code outside of
dawn_native needs OpenGL.

BUG=dawn:165

Change-Id: I3c0c1055e3215a59fdc8e9550baf30762a7014b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8161
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-06-17 09:01:09 +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
Brandon Jones d1b4b5cba5 Allow D3D12 Implicit State Transitions
When transitioning from the COMMON state, an explicit ResourceBarrier
call is unnecessary and can be handled implicitly by the driver. This
acts as an optimization because no synchronization waits are required
when transitioning from the COMMON state.

Bug: dawn:167
Change-Id: Ifd45236dc51c339de8b9945e6f4e2a00934f3676
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7920
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-14 15:14:12 +00:00
Corentin Wallez e0a2ae8a0b Fix casing of includes in D3D12Info
BUG=dawn:144

Change-Id: I95fd1839247ccdf2d4e3b75e6ad84fad02c71ede
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8162
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Nico Weber <thakis@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-06-14 12:44:22 +00:00
Corentin Wallez 55ab6aacac Fix compilation of the GL backend on Windows
The generated OpenGLFunctionsBase code uses the MemoryBarrier identifier
which is a macro defined in windows.h. Undefined it in
windows_with_undefs.

BUG=dawn:165

Change-Id: I6fcfef8fa14074e946d6c13536c1ae33b38c2ac2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8160
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-06-14 08:50:42 +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
Jiawei Shao 87ab2f96d9 Vulkan: always specify TRANSFER_DST_BIT usage when creating images
This patch adds VK_IMAGE_USAGE_TRANSFER_DST_BIT usage when creating
Vulkan images because when we do resource initialization with
vkCmdClearColorImage() and vkCmdClearDepthStencilImage(), the image must
have been created with VK_IMAGE_USAGE_TRANSFER_DST_BIT usage flag
according to Vulkan SPEC.

BUG=dawn:171
TEST=dawn_end2end_tests

Change-Id: Iaba6c04c6942354cc6be502eeee04457d3f43ba7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8100
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-06-13 00:07:42 +00:00
Bryan Bernhart 970101a102 Improve D3D12 adapter initialization.
Gather device info at device initialization rather than adapter initialization.

BUG=dawn:144

Change-Id: I07e114731a37f3738daa585afa99675f2fd36289
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7700
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-12 18:54:57 +00:00
Idan Raiter 0e646e95e0 Add Vulkan / D3D12 indirect buffer flags
Adds missing flags for the indirect usage in vulkan and d3d12.

Bug: dawn:169
Change-Id: I786ea56faaefcbd10100dae40c7893bbc6d5d0ce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8061
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
2019-06-12 16:35:09 +00:00
Jiawei Shao 17738b6d8c Fix wrong computation of texture copy buffer size
This patch fixes a bug in the computation of texture copy buffer size.
As the 'width' and 'height' in copy commands are all in pixels, while
the buffer size is counted in bytes, we shoud first convert 'width' into
bytes before calculating the buffer size.

BUG=dawn:42
TEST=dawn_unittests

Change-Id: Iebd5ed07a54eea762f4a653e295ecacb845ba32f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7940
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-12 08:53:45 +00:00
Ryan Harrison 3e51fada29 Remove Full SPIRV-Cross fuzzers
BUG=chromium:972753

Change-Id: Ic61d5d0ed44b0693f4df09b1f9c34bd928609c3a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8080
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-12 08:49:15 +00:00
Idan Raiter 8f813ac8a2 Fix indirect draw test for MSVC
We need a negative number in a buffer of uint32_t, to test negative
baseVertex. MSVC requires an explicit cast here.

Bug: dawn:172
Change-Id: Iea6c609f11054ba02e5c041fff89def0557c8091
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8060
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-11 19:05:45 +00:00
Natasha Lee 28232ce9f5 Clear Vulkan Textures at first usage
This prevents dirty textures to be used when memory is recycled
while destroying/creating textures. If a texture is not cleared at load,
it will be cleared to 0 before it is used.

Bug: dawn:145
Change-Id: Ia3f02427478fb48649089829186ccb377caa1912
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6960
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-11 18:11:05 +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
Yunchao He 29f3de54a5 Update VertexInput (InputState) to match the spec - Part 4
This patch added support for null vertex buffer(s).

BUG=dawn:80, dawn:107

Change-Id: I3fb9427fcd4323c6df441be7011223088b40ec53
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7900
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-06-11 16:45:04 +00:00
Ryan Harrison 903fc2b049 Explictly set the environment for the Fast fuzzers
BUG=chromium:970300

Change-Id: Ib57a2dcd92a378412588901df9cadc271cad18d4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8001
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2019-06-11 14:38:51 +00:00
Idan Raiter 05f7ad5ac8 Reland "dawn_native: Indirect draw/dispatch"
This is a reland of 7eb6be186b
Fixes casting issue on 32 bit machines

Original change's description:
> dawn_native: Indirect draw/dispatch
>
> Adds indirect draw and dispatch for all backends (without validation).
>
> Tests for opengl negative offset are skipped since there is no easy
> way to add the index buffer offset. Current idea is to use a compute
> shader to modify the indirect draw buffer.
>
> Change-Id: I1d3eec7c699b211423f4b911769cca17bfbcd045
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7481
> Commit-Queue: Idan Raiter <idanr@google.com>
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>

Change-Id: Id28c5658ee18ec5c030f721fb44d9f11ebe21ff9
Bug:dawn:54,chromium:972358
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7961
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
2019-06-10 20:56:27 +00:00
Austin Eng 9d4d3eac14 Always back Buffers with data in the Null backend.
Now that CreateBufferMapped is implemented. Buffers of any usage may
be initialized with staging data. All buffers need to have backing data
otherwise copying from staging data to the buffer will dereference nullptr.

Bug: chromium:971542
Change-Id: I623cc236ffab918ec048cd1949520a4cb329c1b7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7980
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-06-10 20:53:57 +00:00
Austin Eng 39b8ddfbd9 Revert "dawn_native: Indirect draw/dispatch"
This reverts commit 7eb6be186b.

Reason for revert: This change is breaking Clusterfuzz bots. crbug.com/972358

Bug: chromium:972358

Original change's description:
> dawn_native: Indirect draw/dispatch
>
> Adds indirect draw and dispatch for all backends (without validation).
>
> Tests for opengl negative offset are skipped since there is no easy
> way to add the index buffer offset. Current idea is to use a compute
> shader to modify the indirect draw buffer.
>
> Change-Id: I1d3eec7c699b211423f4b911769cca17bfbcd045
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7481
> Commit-Queue: Idan Raiter <idanr@google.com>
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>

TBR=cwallez@chromium.org,kainino@chromium.org,idanr@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I9b7b63de0900e20c4da8561ceb9b2dece77c3885
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7960
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-06-10 17:15:27 +00:00
Idan Raiter 7eb6be186b dawn_native: Indirect draw/dispatch
Adds indirect draw and dispatch for all backends (without validation).

Tests for opengl negative offset are skipped since there is no easy
way to add the index buffer offset. Current idea is to use a compute
shader to modify the indirect draw buffer.

Change-Id: I1d3eec7c699b211423f4b911769cca17bfbcd045
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7481
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-07 17:32:37 +00:00
Brandon Jones de1ac9fd7b D3D12: Batch Usage Transitions For Render Pass
Instead of looping through usages and calling ResourceBarrier for
each transition, we should load all transitions into a single call.
This allows the driver to make better optimization decisions.

Bug: dawn:163
Change-Id: I4859aa2c71b60a40249df00ad67ab13eb0389cd9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7680
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
2019-06-07 17:08:47 +00:00
Corentin Wallez 2b82eb2902 Fix incorrect ASSERT in vertex validation.
Also adds a test that would have fired the ASSERT.

BUG=dawn:80
BUG=dawn:107

Change-Id: I56cdbc91956465c8941b45bb5e9da4c27da301ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7840
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-07 11:05:37 +00:00
Austin Eng 120f5d9062 Return nullptr from MakeErrorMapped if OOM allocating staging data
Bug: chromium:970305
Change-Id: If5ea037170260b8b8dddf3e3428ad2e77d4b67a4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7800
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-07 03:53:07 +00:00
Austin Eng fa7228a1fa Cleanup CopyBufferToBufferCmd
This command internally used a BufferCopy struct which is meant for
Buffer->Texture / Texture->Buffer copies. It contained unnecessary rowPitch
and imageHeight. This patch changes the members of CopyBufferToBufferCmd to
match the CopyBufferToBuffer api call.

Bug: dawn:164
Change-Id: I4737eb4ceb655e8282964c438242627070e355dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6320
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-06-07 03:06:47 +00:00
Yunchao He 2d4b529443 Update VertexInput (InputState) to match the spec - Part 3
Rename num{Attribute|Buffer}s to {Attribute|Buffer}Count for VertexInput

BUG=dawn:80, dawn:107

Change-Id: I7ad62f28449e6283d5c5788dfbd5df1d1e9c813e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7861
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-06 17:54:30 +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
Yunchao He 97c0885a4a Update VertexInput (InputState) to match the spec - Part 2
This patch changed the front end code and tests and examples.

BUG=dawn:80, dawn:107

Change-Id: Ia6c60232c04a1bfb862263766eb28e9afc3bc8db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7620
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-06 01:56:57 +00:00
Austin Eng 9cd21f1bf9 Implement CreateBufferMapped for non-mappable buffers
This uses an intermediate staging buffer to copy data into the buffer.

Bug: dawn:7
Change-Id: I3bda19a8450ef0eddc5b4382ce1b9120f074b917
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7500
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-05 18:35:31 +00:00
Austin Eng 233ce73c50 Add Create/ReleaseStagingBuffer to DynamicUploader
StagingBuffers need to be created and explicitly released outside of
the RingBuffer for CreateBufferMapped since the staging buffer must live
until the Buffer is Unmapped or Destroyed. This patch adds methods to the
DynamicUploaded for creating and tracking the release of StagingBuffers.

This patch also fixes SerialQueue for non-copy-constructible types.

Bug: dawn:7
Change-Id: I582c4d9cf452f808a8a7ab4164ff833087619a18
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7720
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-06-05 16:16:37 +00:00
Corentin Wallez b632bc58ed Vulkan: Don't enable primitiveRestart on "list" topologies
This conforms to the Vulkan usage validation rules and is otherwise a
noop because primitive restart would do nothing for "list" topologies.

BUG=dawn:162

Change-Id: Icda96b15e2f931a0abd3fba794c2aff56dccb714
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7660
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-06-03 22:53:29 +00:00
Jiawei Shao c2750abd0c Add validations on the creation of textures in BC formats
This patch adds all the BC compressed texture formats and the checks on
the creation of textures in BC formats. If a texture is in BC format,
then:
1. The width and height of the texture must be multiple of 4.
2. The usage of the texture can only be Sampled or TransferSrc or
   TransferDst.
3. The sample count of the texture can only be 1.

BUG=dawn:42
TEST=dawn_unittests

Change-Id: I0844fb6a1aadbb96d94a61fd969db07c21b6adf5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7600
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-06-01 02:30:51 +00:00
Corentin Wallez 8dfc593eb7 Remove the concept of push constants
BUG=dawn:14

Change-Id: I20587081ec806034ce4f90457c3d475a6fbe834d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7180
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-05-29 13:16:06 +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 26d3cf08c2 Fix dawn_end2end_tests with the wire
https://dawn-review.googlesource.com/c/dawn/+/7484 landed at the same
time as the change that enabled dawn_end2end_wire_tests so this bug
was not caught. An extra declaration which shadows the original
declaration was created due to a rebase error.

Bug: dawn:56
Change-Id: I36a1b4478a072f58f6bb6660853c3b28f7ce0467
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7580
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-05-29 01:10:47 +00:00
Jiawei Shao 93373abb2f Support force enabling multiple toggles in Dawn end2end tests
This patch adds the support of enabling multiple toggles in Dawn end2end
tests so that we can run MultisampledRenderingTests with all MSAA
related toggles enabled.

BUG=dawn:56
TEST=dawn_end2end_tests

Change-Id: Ia1a16a25261a2eddbb0e54326eebf1188dab9c10
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7484
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-05-29 00:07:37 +00:00
Corentin Wallez 8b5fc36191 Suppress failing shared memory test on GTX 1660 D3D12
BUG=dawn:159

Change-Id: I3aca2019641b0eec2a111e4a59a0d3a927f9c645
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7560
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-05-28 09:11:44 +00:00
Yan, Shaobo 3dd6153eb7 Dynamic Buffer Offset : Vulkan Backend
In a typical application, most draws will use different uniforms values for
things like the world position and orientation. In the current state of WebGPU
this means that a new bind group needs to be created for each draw to set the
right uniforms. Bind group creation is expected to be more expensive than
recording draws because they incur an allocation.

This feature is to reduce the number of bind groups that need to be
created.

The patch implements dynamic buffer offset on vulkan backend. But Vulkan
takes dynamic offset as uint32_t type, which is not the same size as the VkDeviceSize
used to create buffers so we cast them for now.

Bug=dawn:55

Change-Id: I6163866feb040d1a653f9a20d2ce22d80509968e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7461
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-05-27 04:35:03 +00:00
Kai Ninomiya 7777078fb9 Null backend: disallow more than 256M of Buffer allocations
Should prevent some uninteresting fuzzer failures.

Bug: dawn:37
Change-Id: I6b2bef01deb700239e02ef5afa9313023ec83899
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7483
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-05-24 23:29:41 +00:00
Natasha Lee 58ae08e132 Add nonzero_clear_resources_on_creation_for_testing toggle for d3d12
Forces texture to clear to non-zero on creation to test the logic of
lazy clearing.

Bug: dawn:145
Change-Id: Ia738bf03be29dc620caf5f6d04b57c29b6919e85
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7280
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-05-24 22:53:31 +00:00
Austin Eng 8aa036e9e4 Fix backend Device leak in dawn_end2end_tests harness with the wire
Bug: dawn:158
Change-Id: I248ba66864d03c3366fc077fd89824a1233a230e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7520
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-05-24 22:31:36 +00:00
Austin Eng f56efdf0d1 Skip IOSurfaceTests if UsesWire() is true
These tests cannot be run using the wire because the wire client
device is not a real Metal device.

Bug: dawn:158
Change-Id: I97dec7f10fa19d118a72a965f57ee6703cc57765
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7540
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-05-24 22:31:06 +00:00
Austin Eng c391fb7c69 Use single 64bit atomic refcount for Dawn objects
Bug: dawn:105
Change-Id: I7741d5f01579f269db272200d39088c07e2acd92
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7440
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-05-23 23:55:14 +00:00
Yan, Shaobo 34f2fe8a52 Dynamic Buffer Offset : Metal Backend
In a typical application, most draws will use different uniforms values for
things like the world position and orientation. In the current state of WebGPU
this means that a new bind group needs to be created for each draw to set the
right uniforms. Bind group creation is expected to be more expensive than
recording draws because they incur an allocation.

This feature is to reduce the number of bind groups that need to be
created.

The patch implemented dynamic buffer offset on metal backend.

Bug=dawn:55

Change-Id: I34f397ec9ec10fa5b8e8a1c029d2d6a19e8dc0ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7320
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2019-05-23 00:45:12 +00:00
Yunchao He eea2091068 Update VertexInput (InputState) to match spec - Part 1
This is only a renaming: change VertexInput to VertexBuffer, and
change InputState to VertexInput.

The next two patches will do as follows:
1) change the structure of vertex input descriptor related stuff.
2) change num to count.

BUG=dawn:80, dawn:107

Change-Id: Ie76aa653a527759a9c3b4a4792e3254689f053b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7420
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-05-22 22:46:32 +00:00
Brandon Jones 820a04b9ce Add Debug Marker Functionality for D3D12
Implemention of InsertDebugMarker, PushDebugGroup and PopDebugGroup
for D3D12 using PIX event runtime.

Bug: dawn:44
Change-Id: I488f4638777afad3420ba96b350d9f19f2cd80dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7400
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
2019-05-22 22:35:22 +00:00
Austin Eng 76e3de4b08 Implement CreateBufferMapped in dawn_wire
Bug: dawn:7
Change-Id: I7112c87c3b671cd7a7774af7f3a094a189f2b4b0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7402
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-05-22 18:49:59 +00:00
Idan Raiter 1c85976abe dawn_native: handle NaN lod values in samplers
For samplers with NaN mLodMinClamp or mLodMaxClamp, the equality
operator returned false.
Adds checks for finite values, and also early returns if two pointers
are equal.

Bug: dawn:143, chromium:965633
Change-Id: Id5998d6eec275af0fbe30e3b4fcb3eed4fe64c6a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7401
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
2019-05-22 17:18:52 +00:00
Yan, Shaobo 18672ef994 Fix MSVC compilation failure because of implicit conversions
This patch fixed compile error because of implicit conversions when is_clang = false.

BUG=dawn:151

Change-Id: Id94f3f62147962cb73be0d0688ef03b2811d863c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7380
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-05-22 02:41:49 +00:00
Jiawei Shao c0c7e2f85b Add workaround on using non-zero ResolveLevel or ResolveSlice on Metal
Current Metal drivers have a bug that doing MSAA resolve with non-zero
ResolveLevel and ResolveSlice cannot work correctly. This patch adds a
workaround for this bug that first resolving into a temporary one-level
2D texture, then copying the result into the true resolve target.

Although the end2end test ResolveIntoOneMipmapLevelOf2DTexture and
ResolveInto2DArrayTexture can pass on the try bot using AMD GPU, we
find they fail on some other AMD GPUs (Macbook Pro 2018), so currently
this workaround is enabled on all Metal backends.

BUG=dawn:56
TEST=dawn_end2end_tests

Change-Id: Ie85858e58ff486d49dc11c270d8b6d95e216fd42
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6780
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-05-22 00:05:14 +00:00
Natasha Lee 2a7b631482 Add nonzero_clear_resources_on_creation_for_testing toggle to opengl
Forces texture to clear to nonzero on creation to test the logic of
lazy clearing.

Bug: dawn:145
Change-Id: Ib1f6e8f961927008e3c09960ad0219f975d86cc6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7240
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-05-20 21:00:17 +00:00
Idan Raiter 2bc3169f0d dawn_native: deduplicate samplers
Bug:dawn:143
Change-Id: I3aee914100fed87ea98cf22a7b90070c165780a2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7361
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
2019-05-20 18:16:34 +00:00
Li Hao 027a8f6464 Enable Metal validation layers
BUG=dawn:150

Change-Id: Id3e9dd7a99e8a195fddb98026ddf256d82a4b1ba
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7300
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2019-05-20 02:35:24 +00:00
Li Hao 1458dbf518 Enable Vulkan validation layers
BUG=dawn:150

Change-Id: Ie1b252f7fecb323badb40a226e185390d0c241e4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7281
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2019-05-20 02:35:04 +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
Yan, Shaobo 1b5fb81a01 Dynamic Buffer Offset : Validation
In a typical application, most draws will use different uniforms values for
things like the world position and orientation. In the current state of WebGPU
this means that a new bind group needs to be created for each draw to set the
right uniforms. Bind group creation is expected to be more expensive than
recording draws because they incur an allocation.

This feature is to reduce the number of bind groups that need to be
created.

The patch implemented dynamic buffer offset validation logics and adding unittests.

BUG=dawn:55
Change-Id: If6200a87bfedba825abcbfe60f336eab2e27226a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7100
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-05-17 02:05:37 +00:00
Jiawei Shao e4c0a82ecf D3D12: Create descriptor heaps after computing the required size
This patch fixes a crash issue that on D3D12 backends Dawn will crash
when we create too many views from cbvSrvUav or sampler descriptor heaps
as both of the heaps have fixed sizes.

To fix this issue we count the number of views that are required
in these two heaps before allocating memory for them, so that the
memory allocation from these two heaps will always succeed.

BUG=dawn:149

Change-Id: I7d42bf2ad677c6ecfa3ce1b3e471bc0d9258f266
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7260
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-05-16 05:56:49 +00:00
Jiawei Shao 61c0db71de Refactor the emulation of store and MSAA resolve
This patch refactors the implementation of the emulation on "store and
MSAA resolve" store operation by moving all the function calls related
to this toggle into one recursive function EncoderRenderPass(). This
refactoring will also make it easier to implement more workarounds on
Metal render pass.

BUG=dawn:56

Change-Id: Ifc737407001e55863835ab994b735e088beda8c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7220
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-05-15 23:58:08 +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
Li Hao 0195dbf908 Enable D3D12 validation layers
Run end2end tests with argument '-d' or '--enable-backend-validation'

Change-Id: I34a3f453dcd3a57d76301801ae2abe42f847cb1b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7140
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2019-05-15 06:06:26 +00:00
Corentin Wallez 2e56970932 CommandAllocator: Default initalize allocated data.
BUG=dawn:21

Change-Id: I98499385d7397ab431e1bbe00add7ef01941cca6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7160
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-05-14 03:53:26 +00:00
Natasha Lee 97f08fa2e6 Create nonzero_clear_resources_on_creation_for_testing toggle
Created toggle to force texture clearing to 1 bits in order to
test the logic of lazy clearing.

Bug: dawn:145
Change-Id: I83bc32f046159c709c426b77458fbdf115f7bfd0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7120
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-05-11 00:21:50 +00:00
Bryan Bernhart efef0e4b1f Detect integrated device type on Intel iGPUs.
Fix to prevent incorrectly reporting the device type.

BUG=dawn:144

Change-Id: Ie1956d908b20649787aef785cd29f0f63f524431
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6980
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-05-10 02:18:49 +00:00
Jiawei Shao 974a150327 OpenGL: Set default values for dynamic states before clear
This patch fixes a bug on the OpenGL backend by setting default values
for dynamic states (blend color, viewport, scissor rectangle, etc) before
clearing the attachments of the render pass so that the full area of the
attachments can be cleared correctly.

BUG=dawn:126, dawn:137, dawn:141
TEST=dawn_end2end_tests

Change-Id: I9ddf74a67413ed51f83a69a3dc2c2377a0622cac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7080
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-05-08 23:59:03 +00:00
Li Hao f112ceca34 Reland "Fix zero stride in input state for Metal validation"
Update stride value to max(attribute.offset + sizeof(attribute) for
each attribute) when input stride is 0 in Metal backend

BUG=dawn:75
TEST=dawn_end2end_tests

Change-Id: I449532807f7fba1bca22106f2c38d496b8cbf01f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7020
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2019-05-07 07:06:59 +00:00
Yizhou Jiang 8804bc541e Fix validation of mip map level
Mip map level starts with the size of texture image and halves the
size until a 1x1 dimension.

BUG=chromium:954769

Change-Id: I59e51af216d65c721a3d2c2023306883e524820d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yizhou Jiang <yizhou.jiang@intel.com>
2019-05-06 01:53:16 +00:00
Jiawei Shao f8a1041e99 Check OpenGL passed fences with glClientWaitSync()
This patch fixes an issue in the check of passed OpenGL fences.
Currently Dawn checks if an OpenGL fence is passed with glGetSynciv(sync,
GL_SYNC_CONDITION, sizeof(GLint), &length, &status), which always returns
GL_SYNC_GPU_COMMANDS_COMPLETE and is meaningless. This patch uses
glClientWaitSync() to check if a fence is passed instead.

BUG=dawn:137

Change-Id: Iff6b18bcc7155b06bde98ff68c7ed104a27bfe55
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6800
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-05-06 01:10:16 +00:00
Rafael Cintron f54bb68f47 Improve usage of static_casts over reinterpret_casts
Static_casts are prefered over reinterpret_casts for better type
safety

Change-Id: I190cbee293591ebf8ab8035e900c081848eb1f30
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6921
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-05-03 00:58:27 +00:00
Corentin Wallez 94274b63fb dawn_native: deduplicate render pipelines
BUG=dawn:143

Change-Id: I2f66387f95bcb44dc20f308b4a582b878803dbe8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6864
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-05-02 15:30:56 +00:00
Corentin Wallez 00f6b1af41 dawn_native: don't uncache error objects
Error objects that are cached still have mIsBlueprint to false and would
try to uncache themselves, which isn't valid.

Also adds a regression test.

BUG=dawn:143

Change-Id: Icd8bab52982b8520519d52296fffa6ed85088b8e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6900
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-05-01 15:49:07 +00:00
Corentin Wallez 1152bbaf8e dawn_native: deduplicate compute pipelines
BUG=dawn:143

Change-Id: I64e4660de2241bb72bb7c615a0bd1e675e043295
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6863
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-05-01 13:48:47 +00:00
Corentin Wallez c535198d96 dawn_native: deduplicate shader modules
BUG=dawn:143

Change-Id: I2c0fa63e3a6d77c137418f12b9807d16a0636d57
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6862
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-05-01 13:27:07 +00:00
Corentin Wallez 0ee9859c91 dawn_native: deduplicate pipeline layouts
This is the first step to do pipeline deduplication. It also introduces
tests for deduplication.

BUG=dawn:143

Change-Id: Ib22496f543f8d1f9cfde04f725612504132c7d72
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6861
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-05-01 12:57:27 +00:00
Corentin Wallez cc141797df Fix dawn_end2end_tests -w
Code surrounding the swapchain needs to Flush the wire so that the
native swapchain implementation is initialized before GetPreferredFormat
is called. Likewise the swapchain should be destroyed before the last
FlushWire otherwise the native swapchain will still be using the window
at the beginning of the next test.

Also fixes the newly added ASSERT_DEVICE_ERROR not working with -w.

BUG=dawn:143

Change-Id: Ie3d6fa8c9236f68f5bff1ad7abd112ab25035843
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6860
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-05-01 12:07:37 +00:00
Brandon Jones 11b703904a Increase D3D12 Swap Chain Buffers to 3
Adds an additional buffer and frame to the D3D12 swap chain to
unthrottle fps in situations where we can't maintain a constant 60fps.

Bug: dawn:142
Change-Id: I06ef697ca37608dc51816dd99de5534cb8c9b843
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6840
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-04-30 08:31:38 +00:00
Brandon Jones 4baba8266b Use VK_PRESENT_MODE_FIFO_KHR for Vulkan Swap Chain
Change Vulkan Swap Chain from VK_PRESENT_MODE_IMMEDIATE_KHR to
VK_PRESENT_MODE_FIFO_KHR. Some common GPUs don't support immediate mode,
so we should default to a value that is required to be supported.

Bug: dawn:90
Change-Id: I66dec23141e69637ccfa8a2ed0ee651114b9ddcf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6820
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-04-30 08:31:08 +00:00
Corentin Wallez bbed457796 Texture: Add validation that the mip chain can't be too large
BUG=chromium:954769

Change-Id: I07a00230294cb9385b79edb6150d9f0f7b4b7284
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6760
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-04-29 09:31:06 +00:00
Yan, Shaobo 9286adcb0f Add end2end test for all vertex formats
BUG=dawn:41

Change-Id: I37bde37843522a8d7c8b3bea1cb24c0971efd8e2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6340
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2019-04-26 15:25:18 +00:00
Corentin Wallez a32e3bd014 Metal: Invert CW and CCW because we compile with flip Y
BUG=dawn:43

Change-Id: I6d09118d141046cd307604b1b4d53a82d8d15bf6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6761
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-04-26 14:14:08 +00:00
Jiawei Shao 15d4c2e63b Emulate store and multisample resolve on Metal
This patch implements "store and MSAA resolve" store operation on Metal
drivers that don't support MTLStoreActionStoreAndMultisampleResolve with
a workaround that does MSAA resolve in another render pass.

Driver workaround is one type of Dawn Toggles. Dawn Toggles will include
other optional optimizations and features that can be configured to use
or not when we create Dawn Devices.

As all Metal try bots don't need this toggle, to better test this
patch on the try bots:
1. We add the support of forcing enabling a workaround when starting an
   Dawn end2end test so that we can test the workaround on the platforms
   where the workaround is disabled.
2. We add an optional parameter DeviceDescriptor to CreateDevice() so
   that we can custom the toggles the Dawn device should use.

This patch also adds the support of querying toggle details from Instance
and the names of the toggles in use from Device. These APIs are tested in
the Dawn unittests added in this patch.

BUG=dawn:56
TEST=dawn_end2end_tests
TEST=dawn_unittests

Change-Id: Iae31d2ded6057eee638b6099d3061e9d78b04d55
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6620
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-04-26 07:52:57 +00:00
Kai Ninomiya 8e97b4c8a5 Add a basic compute shared memory test
Change-Id: I6fab17d59d58434d10def29923e71106605c4f32
Bug: None
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6580
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-04-26 02:08:12 +00:00
Corentin Wallez ef90079944 CommandEncoder: promote errors to device errors after finish()
BUG=dawn:138

Change-Id: Iddb1aab886558c706d0188adc21c7ee8f68533d4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6720
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-04-25 20:14:32 +00:00
Corentin Wallez 3826880f81 Metal: Implement Culling and FrontFace
This is implementing the feature on a single backend and without tests
so we can get it in the hands of people trying WebGPU quickly.

BUG=dawn:43

Change-Id: I4d0611efd21dd1af053288957f137febc78a74e8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6721
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-04-25 19:37:28 +00:00
Jiawei Shao 22cee9ae36 Enable MultisampledRenderingWithDepthTest on Windows Intel Vulkan
Now MultisampledRenderingWithDepthTest can pass on Windows Intel
Vulkan drivers with the fix in
https://dawn-review.googlesource.com/c/dawn/+/6640.

BUG=dawn:56
TEST=dawn_end2end_tests

Change-Id: If83d8183960960119e728d0372f5d1c5c11d849e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6680
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-04-19 05:18:20 +00:00
Austin Eng 342c6ea1a9 Fix MultisampledRenderingWithDepthTest
This test was using two separate depth-stencil textures for sequential
render passes. The second render pass is supposed to load the texture
from the first but it was instead loading a new uninitialized texture.

Bug: dawn:133
Change-Id: I615ec4502a6f26bd039187b0c1942ffbb806b549
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6640
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-04-18 18:28:48 +00:00
Austin Eng 0c133bbe55 Rename DawnColorStateDescriptor.colorWriteMask to writeMask
Bug: chromium:877147
Change-Id: I566cea409b89de8abd724f344f7ae83f80e56572
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6600
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-04-15 20:43:35 +00:00
Corentin Wallez 2ec74dcc3f Add Adapter::GetDeviceType() (integrate vs. discrete vs. CPU)
BUG=chromium:852089
Change-Id: Ia447448392e09c5d604ae038b4758776ed3e66ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5180
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-04-15 16:36:25 +00:00
Austin Eng bff933affc Clear glColorMask at the start of a RenderPass for LoadOp::Clear attachments
Bug: dawn:133
Change-Id: Id8c6180f7a9ef2f7901aca6690d611fad4f13beb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6560
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-04-12 17:43:05 +00:00
Yunchao He 0c227e21d1 baseVertex in drawIndexed() should be int32, not uint32
baseVertex in drawIndexed() is int32 in web idl. But it is uint32 in Dawn
project. I also checked the native Graphics API sets. baseVertex is int32
on all native APIs (D3D12, Vulkan, Metal). So this feature in web idl is
definitely correct.

This small change makes dawn match web idl for this feature. And it also
adds a couple of tests to cover negative baseVertex.

BUG=dawn:135
TEST=dawn_end2end_tests

Change-Id: I642c96faed9103c8392979f3714527ed0aac4089
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6442
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-04-12 07:58:44 +00:00
Yunchao He c33a8c1885 Implement rasterization state for render pipeline - Part 1
This change adds rasterization state into dawn.json. It includes
back face culling and depth bias. It also adds validation code
and default values for rasterization state in ComboRenderPipelineDesc
to pass dawn_unittests.

Validation for back face culling and depth bias related parameters
is quite easy, so unittests are not needed.

BUG=dawn:43

Change-Id: I332cbf3f72545cfa8e62b3534d5a6a6e8fdc6d2a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6460
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-04-11 18:46:54 +00:00
Corentin Wallez fbf7092ab3 PushConstantsTest: Don't use additive blending
One of the test was doing additive blending with a render target that
was uninitialized causing flaky failure. This additive blending was
useful when we had multi-pass render passes but isn't anymore.

BUG=dawn:133

Change-Id: I0aef3dc31e98dbc51c267dc1e481429930162a93
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6540
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-04-11 18:30:54 +00:00
Frank Henigman 9a9b837519 Roll all SPIR-V dependencies together.
Function name changed in shaderc.
SPIRV-Cross split up into additional files.

BUG=chromium:951016

Change-Id: I49abb0a163fefdd61b7d6352e57e2a10f519abd9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6440
Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-04-11 14:52:55 +00:00
Jiawei Shao 51fd66e3dd Add missing Constants.h in src/common/BUILD.gn
This patch adds the missing Constants.h in src/common/BUILD.gn so that
we can see this file under the folder "src/common" of the Visual Studio
project generated by GN.

BUG=dawn:134

Change-Id: I513315ee2adbd93cf1ff61d112e8a4f65f660bce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6520
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-04-11 07:41:38 +00:00
Corentin Wallez c005c9acf0 Metal: Fail BackendConnection creation when Metal isn't supported
Chromium still supports macOS 10.10 that doesn't have Metal support and
calling any Metal function there results in a crash. Prevent using the
backend when Metal isn't present by not creating a BackendConnection.

BUG=chromium:852089

Change-Id: I53ffe6972f7b926b6bcbe740275fcee88b9df67a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6480
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-04-11 07:14:28 +00:00
Austin Eng f4c3f4562e Disable RenderPassTest.TwoRenderPassesInOneCommandBuffer on OpenGL and Metal
This test is flaky on Metal and consistently failing on OpenGL.

TBR=cwallez@chromium.org,kainino@chromium.org
Bug: chromium:950768
Change-Id: I0e62b87053009182afef39e5ef2459b30a866418
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6500
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-04-10 20:25:57 +00:00
Austin Eng b4b3ea05eb Reland "Rename texture.createTextureView to createView to match WebGPU"
This is a reland of 6f0b021dbf.
It also renames CreateDefaultTextureView to CreateDefaultView in a test
that landed after the tryjobs for the reverted patch passed.

Original change's description:
> Rename texture.createTextureView to createView to match WebGPU
>
> Bug: chromium:877147
> Change-Id: I186fc26054cc6729c859a4161c755a1133dc0bca
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6360
> Commit-Queue: Austin Eng <enga@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>

Bug: chromium:877147
Change-Id: I8e1a1adc07ad2c78081ae3cb0fa2bdb648b39c50
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6361
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-04-09 16:57:00 +00:00
Yuly Novikov 2d4c66d2b8 Revert "Rename texture.createTextureView to createView to match WebGPU"
This reverts commit 6f0b021dbf.

Reason for revert: breaks compilation on https://ci.chromium.org/p/chromium/builders/ci/GPU%20FYI%20Linux%20Builder%20%28dbg%29/62003

Original change's description:
> Rename texture.createTextureView to createView to match WebGPU
> 
> Bug: chromium:877147
> Change-Id: I186fc26054cc6729c859a4161c755a1133dc0bca
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6360
> Commit-Queue: Austin Eng <enga@chromium.org>
> Reviewed-by: Corentin Wallez <cwallez@chromium.org>

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

Change-Id: I2d337881fc05cf8128ae7ab268514ea7ef462123
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:877147
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6420
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yuly Novikov <ynovikov@google.com>
2019-04-09 15:28:01 +00:00
Austin Eng fbe6cfdb16 Update ComputePipelineDescriptor to use PipelineStageDescriptor
The contents of PipelineStageDescriptor were inlined inside of
ComputePipelineDescriptor. This changes updates
ComputePipelineDescriptor to contain PipelineStageDescriptor to match
WebGPU.

Bug: chromium:877147
Change-Id: Ic030b7bd7a237945cbbaf4c567cc361940e1ad00
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6400
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-04-09 15:17:30 +00:00
Austin Eng 6f0b021dbf Rename texture.createTextureView to createView to match WebGPU
Bug: chromium:877147
Change-Id: I186fc26054cc6729c859a4161c755a1133dc0bca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6360
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-04-09 15:13:10 +00:00
Austin Eng 5f1d2e1c8d Remove sampler border color from Dawn to match WebGPU
Bug: chromium:877147
Change-Id: I9760b3c6cb67a3ffa08feeaff8e8b24b80ec4200
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6380
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-04-09 15:12:50 +00:00
Jiawei Shao 865cad89b9 Support multisampled rendering on Metal - Part I
This patch implements MSAA resolve on Metal backends with the store
action MTLStoreActionStoreAndMultisampleResolve. Note that this store
action is not supported on all Metal drivers. In the future we will
emulate it by doing MSAA resolve in another render pass.

The end2end tests ResolveIntoOneMipmapLevelOf2DTexture and
ResolveInto2DArrayTexture are temporarily disabled on Intel and NVidia
Metal drivers due to driver issues.

BUG=dawn:56
TEST=dawn_end2end_tests

Change-Id: I7e87aa344691c7d0a389aca80500c7b89a427ea3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5900
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-04-09 08:04:59 +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
Jiawei Shao 952860bf9f Support multisampled rendering on Vulkan
MultisampledRenderingTest/MultisampledRenderingWithDepthTest is skipped
temporarily on Intel Windows Vulkan drivers due to the failure of that
case on the try bots.

BUG=dawn:56
TEST=dawn_end2end_tests

Change-Id: Ibcf4a07198e4ebad304170e8df9778dc965349df
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6300
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-04-05 03:06:38 +00:00
Yunchao He cfea934e2b Remove unneeded TODO for SetScissorRect in unittests
This change also fixed a small style issue in dawn.json.

BUG=

Change-Id: I731aca5558ebe1eb0d6bd144a0e2a9b01963558a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6261
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-04-02 14:31:29 +00:00
Yunchao He 2a30e14074 Generate an error if scissor rect is empty
We need to change related tests in end2end_tests and unittests.

Bug=dawn:127
TEST=dawn_end2end_tests, dawn_unittests

Change-Id: I523d4eeb930990b5db381544b228d2f11912049b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6240
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-04-02 07:42:18 +00:00
Jiawei Shao 8e50ba19ba Support multisampled rendering on D3D12
This patch adds the basic support of multisampled rendering on D3D12
backends and enables the related end2end test on D3D12 backends.

D3D12 render pass is not used in this patch. We plan to make use of it
in the future.

BUG=dawn:56
TEST=dawn_end2end_tests

Change-Id: I63759431654ec0abe9d21157f679d4c971cd92a8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6200
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-04-02 07:42:09 +00:00
Corentin Wallez 941a04cd43 Remove stray include for dawncpp_traits.h
The CQ passed on the patch that removes dawncpp_traits even if we forgot
this include because the builders still had the generated header in
their build cache.

TBR=enga@chromium.org
BUG=dawn:125

Change-Id: Ie266bc32e6ebc4881f80c759435ca1e3f0d00e9c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6221
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-04-02 07:04:48 +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 c3155205fa Nuke Builders Part 3: remove validation test builder expectations
BUG=dawn:125

Change-Id: I64a0b957e39b60334916ad71fb4beee5d8baa9db
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6162
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:16:08 +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
Natasha Lee 20b0c33913 Buffer DestroyImpl check for buffer resource to avoid double free
Double free was happening if buffer.Destroy() was called right
before the buffer went out of scope since DestroyImpl wouldn't
check to see if the resource was already released.

Also refactor Destroy in Texture classes to match the pattern
of Buffer classes. Added validation of the texture object when
Destroy is called.

Bug: dawn:124, chromium:947323
Change-Id: I0e4a652ff5b86a151b4919c781c1dd385b4e3213
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6060
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-04-01 19:49:04 +00:00
Jiawei Shao 14487c34f7 Skip RenderPassLoadOpTests.ColorClearThenLoadAndDraw on Linux Intel OpenGL
RenderPassLoadOpTests.ColorClearThenLoadAndDraw is flaky on Linux Intel
drivers, so we have to skip it temporarily. As currently we cannot collect
PCI IDs on OpenGL drivers, we have to skip this test on all OpenGL
backends.

BUG=dawn:126, chromium:947246

Change-Id: Ic1b75ee70d72b8e96ac87018cfc886661e4ae3de
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6260
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-04-01 07:47:47 +00:00
Natasha Lee 10c24684ab Fix use of uninitialized value in ValidateTextureViewDescriptor
ValidateTextureViewDescriptor was running into use of uninitialized
value. Fixing this by moving the texture state check below the texture
object check. This should validate the texture object before trying to
validate it's texture state.

Bug: chromium:947150
Change-Id: I9b41791bfb960fbe4873ba5fcadf046bd32e5853
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6180
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-03-28 22:49:53 +00:00
Corentin Wallez 19179e180b Metal: avoid uses of autorelease
BUG=chromium:947089

Change-Id: I1e7ef4a91a8b1c6108485b8c99e88a53a25ebb7b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6160
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-28 18:16:04 +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
Yunchao He f856903154 Move vertex index format from RenderPipelineDesc to InputStateDesc
Bug=dawn:107

Change-Id: Ia88232848995d5c4c3ac0f3137ffa518e85aa0a0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6140
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-28 17:09:23 +00:00
Austin Eng 27a294c2e8 Fix null pointer dereference in CommandBufferStateTracker
The CommandBufferStateTracker dereferences a null pointer if there is no bind group set for an index of the layout

Change-Id: Id247f9876340d189088e8bbe8cb4d68a4d517c6e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6100
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-03-28 15:28:01 +00:00
Jiawei Shao 0bc168ed58 Support multisampled rendering on OpenGL
This patch adds the support of multisampled rendering on OpenGL backends
and the related end2end tests to test all new features implemented in
this patch.

BUG=dawn:56
TEST=dawn_end2end_tests

Change-Id: I91e462178ee39041ef591503c33c70db511775e9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5880
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-03-28 14:18:11 +00:00
Corentin Wallez 9d99f90c7d CommandEncoder: prevent calls even after a failed finish
Finish validation acquires the command allocator but didn't set the
finished state so further top-level would still try to record in the
allocator, causing an ASSERT to fire.

BUG=chromium:939969

Change-Id: I334878098e6b824c2c4cef4fccb75472d3b63bbe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6041
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-03-28 14:10:01 +00:00
Corentin Wallez 339bd9d447 Add dawn_wire entrypoints to inject texture in the wire
This allows reserving a texture ID in the client and injecting textures
in the wire, so that the WebGPU control channel can create WebGPU
textures backed by SharedImages in Chromium.

BUG=941543

Change-Id: I1efcfe3dce024bb2d3592f22225407a97b641c1f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5820
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-03-28 12:57:11 +00:00
Yunchao He e821ed6781 Vulkan: Fix layout of destination image of T2T copies
Bug=dawn:18

Change-Id: Ie218b70376b6630449764ac789c9f47c7d5fae2b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6080
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-03-28 12:07:41 +00:00
Yunchao He 494552b886 Some small optimizations and style issues for input state
Bug=dawn:107

Change-Id: I8ecfb39a2bff11b678bd8548ec0725ba061ef333
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6081
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-28 10:57:41 +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
Yunchao He 1ba2cb8589 Construct ComboInputStateDescriptor to simplify tests and examples
Bug=dawn:107

Change-Id: I900de454cacf9f62ae97213161a98ce6d4254eab
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6020
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-28 05:09:01 +00:00
Jiawei Shao 5f4bcbb946 Disallow creating multisampled 2D array textures
Currently we decide not to support multisampled 2D array textures
because on Metal they are only available on macOS version greater than
10.14.

This patch also removes the compatibility check between cube map texture
views and sample counts because currently the sample count of 2D array
textures is always equal to 1.

BUG=dawn:56
TEST=dawn_unittests

Change-Id: I9736c977192409c79572f061fa1b7681b5b3e6c8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-03-28 00:14:50 +00:00
Natasha Lee cae68ff846 Destroy frontend and backend for Textures
Same idea as for buffers, Destroy can be used to free GPU memory
associated with resources without waiting for javascript garbage
collection to occur.

Bug: dawn:46
Change-Id: Ia796b06b5228cbec4cfe8d78a500f967181d8c1f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5540
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-03-27 22:04:10 +00:00
Yunchao He 889d743baa Input State Descriptorization
This change also removes InputState object.

BUG=dawn:107

Change-Id: Ia3fd2d348658f5719de0279bfe7bb10a4f183523
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5660
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-27 18:08:50 +00:00
Jiawei Shao 5490e9aca1 Fix clip space on D3D12 and OpenGL
The range of the Z-coordinate in clipping volume is [-w, w] on OpenGL,
while it is [0, w] on D3D12, Metal and Vulkan.

In this patch, the "fixup_clipspace" flag of SPIRV-Cross is enabled on
OpenGL backend and disabled on D3D12 backend to unify the behaviour of
clip space on all Dawn backends. An end2end test is also added for this
fix.

This patch also fix a bug when clearing depth stencil attachments on
OpenGL backend. Before clearing depth stencil attachments, we should
enable depth stencil writing by properly setting depth and stencil
masks. We do not need to set the depth and stencil masks back because
they will be set again when applying the render pipeline. The newly
added test will fail without this fix when running the test together
with all the end2ends.

BUG=dawn:122
TEST=dawn_end2end_tests

Change-Id: I4f50ce3eb1f16d731ee4cffc12a56e17844b4675
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5860
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-03-27 00:01:33 +00:00
Corentin Wallez 91e949292f BUILD.gn: put public include dirs in all_dependent_configs
The public include dirs for Dawn were in the dawn_public config but it
would only be added to targets as a part of public_configs. This meant
that second-level dependencies that ended up needing to include
dawn/dawn.h wouldn't know where to find it.

Fixed this by adding include dirs in all_dependent_configs and renamed
the config to be very explicit that it is for include dirs only.

BUG=chromium:938895

Change-Id: Iad70f3ce1f8a02b96bf341e7dd7d6068ce645af7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5920
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-03-26 17:16:28 +00:00
Brandon Jones 29716a2fb5 Change Copy Validation To Allow Depth = 0 Copies
Existing validation requiring copy depth = 1 is not accurate. Copies
with a depth of 0 should be allowed.

Bug: dawn:18
Change-Id: Ib7607ee0965935127b3a8b66bc49b38ddcc56953
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5940
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
2019-03-26 17:14:55 +00:00
Brandon Jones d3d3aa03e1 Implement Texture-to-Texture Copies
Implement texture-to-texture copies for D3D12, Vulkan, and Metal.
Includes end2end and unit tests.

Bug: dawn:18
Change-Id: Ib48453704599bee43a76af21e6164aa9b8db7075
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5620
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-03-26 11:06:23 +00:00
Austin Eng 041aca1620 Fix leaking FenceCompletionUserdata in the wire
This was being leaked if the completion status was not a success.

Bug: chromium:939396
Change-Id: Ia09bcef935697b354e6e3da3c4a3d308545fec53
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5840
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-03-25 06:36:28 +00:00
Jiawei Shao 24930b382a Workaround GL error when creating texture view from external GL textures
This patch adds a workaround on the GL error when we use glTextureView()
on a GL texture which is created outside DAWN and not configured by
glTexStorage*d(). glTextureView() is only allowed to be used on the
textures configured by glTexStorage*D(). When the external GL texture
is configured by glTexImage2D() (for example, textures from GLFW),
calling glTextureView() will cause an INVALID_OPERATION error.

To workaround this issue, we refer the solution on the Metal backend
that we avoid calling glTextureView() on the following senarios:
1. We may call glTextureView() only when the usage of the texture
   includes Sampled or Storage.
2. We won't call glTextureView() if the view uses the same format as the
   original texture, the whole mipmap levels and array slices.

BUG=dawn:16

Change-Id: Ibdfaa122ac061a2e2bb47f76e0030f1d0fc548a2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5780
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-03-25 00:54:58 +00:00
Corentin Wallez 07950e80fe Metal: Expose function to wait for commands to be scheduled.
This is to allow proper synchronization with other devices and APIs on
macOS. There is a global graphics queue so we usually don't need
synchronization but on Metal, commands are inserted on this queue only
when the command buffer is scheduled.

Metal's schedule and completed handlers can be fired on a different
thread so this CL also makes the code there data-race free.

BUG=chromium:938895
BUG=dawn:112

Change-Id: Id45a66fb4d13216b9d01f75e0766732f6e09ddf0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5700
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-03-22 07:36:34 +00:00
Yan, Shaobo e105f962cf Match vertex format in dawn with webgpu
BUG=dawn:41

Change-Id: If16e615ccf6b9c7e85d41adcdb6d66baa07179da
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5280
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-03-21 11:18:31 +00:00
Jiawei Shao 54e4d47db4 Add check on the sample count between render pipeline and render pass
This patch adds the support of multisampling in the render pipeline and
the validations that the sample count of the render pipeline must be
equal to the ones in render pass color and depth stencil attachments.

BUG=dawn:56
TEST=dawn_unittests

Change-Id: I823c565bf9466ac6029f2797b31368bbdd6b8280
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5622
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-03-19 01:12:01 +00:00
Li Hao fef613365a Fix zero stride in input state for Metal validation
Update stride value to max(attribute.offset + sizeof(attribute) for
each attribute) when input stride is 0 in Metal backend

BUG=dawn:75
TEST=dawn_end2end_tests

Change-Id: Ic0b2bfc685b8aeb92d1d4401174a819279386ea3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5221
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-18 12:26:07 +00:00
Yan, Shaobo 991ab98f11 Make dawn idl support dynamic buffer offset
This patch simply added dynamic buffer offset in dawn idl and
modify the shape of SetBindGroup.

BUG=dawn:55

Change-Id: I516e08f3ee558ba375a87d98eaea6d60e93d4514
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5600
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-18 06:01:37 +00:00
Jiawei Shao 931311700c Add validation on the sample count of the depth stencil attachment
This patch adds a missing validation on the sample count of the depth
stencil attachment when calling CommandEncoder.BeginRenderPass().

According to D3D SPEC, when MSAA is used, all bound render targets and
depth buffers must have the same sample count and quality.

BUG=dawn:56
TEST=dawn_unittests

Change-Id: I719995b80f89e5139711c97a4bf76ba479919ad1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5621
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-15 05:16:41 +00:00
Li Hao d263d752ac Fix scissor rect larger than render pass width/height in Metal backend
BUG=dawn:116
TEST=dawn_end2end_tests

Change-Id: I3e36e19d20b271ba58652bcaea973f3999e9e7ac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5560
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
2019-03-15 01:37:21 +00:00
Stephen White 5625b63202 Fix glTexStorage2D errors.
If a GL texture is externally-managed, don't make any GL calls
during the Texture constructor.

Bug: dawn:114

Change-Id: I8ece5cde433fb036f37bda7d18ddb81d9b50a89d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5640
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-14 15:05:53 +00:00
Corentin Wallez ea2c7f20f2 TextureMTL: Use managed storage mode for IOSurfaces
BUG=dawn:117

Change-Id: Ief914b1e03397080ab501fa5f9059725f8c261b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5420
Reviewed-by: Hao Li <hao.x.li@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-03-13 09:45:18 +00:00
Jiawei Shao 1e1c13ed87 Add validations to multisampled color attachments and resolve targets
This patch adds validations to the multisampled color attachments and
resolve targets.

The resolve target must be a valid texture view, and it must follow
the following validations:

According to Vulkan SPEC:
1. If we set resolve target, the texture of the color attachment must
   be a multisampled texture, and the texture of the resolve target
   must be a non-multisampled texture.
2. The format of the resolve target must be the same as that of the
   color attachment.
3. The sample count of all the color attachments must be same.
4. The resolve target must have dawn::TextureUsage::OutputAttachment
   usage bit set when it was created.

On D3D12:
1. ID3D12GraphicsCommandList::ResolveSubresource() method only allow
   resolving in a subresource of a texture, thus the level count and
   mipmap level count of the resolve target can only be 1.
2. ID3D12GraphicsCommandList::ResolveSubresource() method requires
   the dimension of the source and destination must match.

BUG=dawn:56
TEST=dawn_unittests

Change-Id: I080415bef0d600600083a95f641815188798dca3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5340
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-03-11 18:41:02 +00:00
Austin Eng d030f64550 Reorder backend connections so that explicit APIs come first
This makes it so that default adapter discovery finds
Metal/D3D12/Vulkan first.

Change-Id: I3795bcc8a3d47eb3c53881b7fc43e8d56b4b89fd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5481
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-03-11 17:16:52 +00:00
Natasha Lee 718e1dbb89 Reland "Destroy backend implementation for Buffers"
This reverts commit 9bf529ec94.

Reason for revert:
Fixed test failure by submitting basic render pass to clear out texture
before running the tests.

The test was failing previously because the texture pixel color was not
cleared before running the tests, causing unexpected
pixel colors to be compared. Creating a basic render pass clears
the texture, but since the first test fails on submit expectedly,
the pixel is never cleared.

Bug: dawn:46
Change-Id: Ic190c2d8d6af3f9d8def3370b92c6974a82a0096
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5500
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-03-11 17:05:22 +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
Stephen White 97ffc1a8aa GL backend: fix baseVertex param to DrawIndexed.
Re-enable the appropriate test.

BUG=
Change-Id: I8b823b17259f7c588fda0be4fe86990d11a0a324
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5460
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-03-11 16:28:42 +00:00
Corentin Wallez 070052f6b7 Suppress -Wunguarded-availability in MetalBackend.h
Chromium will use this header and currently uses a minimum SDK version
without Metal, so it gets a compilation warning on MTLDevice. There is
no good way to guard availability in headers, so just suppress the
warning in the whole header and push the warning to usage of types in
client code.

BUG=chromium:938895

Change-Id: Id8ec224825c39a28a404be216556780713ecaf15
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5440
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-03-10 11:01:40 +00:00
Austin Eng 9bf529ec94 Revert "Destroy backend implementation for Buffers"
This reverts commit b6a80b321e.

Reason for revert: dawn_end2end_tests are failing on the Chromium GPU FYI bots. Example here: https://ci.chromium.org/p/chromium/builders/ci/Win10%20FYI%20Release%20%28NVIDIA%29/4226

Original change's description:
> Destroy backend implementation for Buffers
> 
> Destroy can be used to free the GPU memory associated with resources
> without waiting for javascript garbage collection to occur.
> The buffer is validated at submission to the queue.
> So any buffer that has been destroyed before submission, will then
> invalidate the submit and result in an error.
> 
> Bug: dawn:46
> Change-Id: I40df56ce97baef01deea7552d7a6d40b558fc985
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5320
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
> Commit-Queue: Natasha Lee <natlee@microsoft.com>

TBR=cwallez@chromium.org,kainino@chromium.org,enga@chromium.org,rafael.cintron@microsoft.com,natlee@microsoft.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: dawn:46
Change-Id: Iadf37a8a6675c744207ec7daaa3fd2fde7da3714
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5480
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-03-09 00:06:38 +00:00
Austin Eng 8c1a90199a Split off libdawn_wire_headers from BUILD.gn
These need to be separated from the main BUILD.gn as well.
They cannot be easily guarded behind build flags in Chromium
because the WebGPUImplementation will extend
dawn_wire::CommandSerializer.

Bug: dawn:61
Change-Id: Ic7d6bb13cc535ecddb99c832407ba1f37019ed93
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5401
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-03-08 00:51:27 +00:00
Natasha Lee b6a80b321e Destroy backend implementation for Buffers
Destroy can be used to free the GPU memory associated with resources
without waiting for javascript garbage collection to occur.
The buffer is validated at submission to the queue.
So any buffer that has been destroyed before submission, will then
invalidate the submit and result in an error.

Bug: dawn:46
Change-Id: I40df56ce97baef01deea7552d7a6d40b558fc985
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5320
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-03-07 19:56:14 +00:00
Corentin Wallez aa9d6ad09d Only build "common" on supported systems
src/common/BUILD.gn contains common dawn configs and will be discovered
by all Chromium builds. "common" doesn't build on all system, for
example Fuchsia so we only expose the target if we are on a supported
system.

BUG=dawn:61

Change-Id: Ib12b1bd3e32529e1969fdc2fc50af05f8e97e7df
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5360
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-03-07 13:39:50 +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
Austin Eng 1cc386687c Move CreateFence from Device to Queue
Bug: dawn:113
Change-Id: I5ec829d8945cdc25644f481acc07a9f6d8b13aef
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5200
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-06 22:42:22 +00:00
Jiawei Shao b47470daa7 Return an error ComputePassEncoder when error occurs in BeginComputePass
This patch is a follow-up of the descriptorization of render pass
descriptor. In this patch we changes the return value of
BeginComputePass from nullptr to an error compute pass encoder when
there is any error in BeginComputePass() to keep it consistent with what
we do in BeginRenderPass().

This patch also provides functions to create error render/compute pass
encoders. With this patch we can create a pass encoder in error by
specifying ErrorTag in the constructor, which is more staightforward
and human readable than the current implementation.

BUG=dawn:6

Change-Id: I1899ae65804f8cecd3079dc313e7e18acb88e37c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5140
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-03-05 01:02:47 +00:00
Jiawei Shao d6eb2e7501 Fix crashes when using error textures in copy commands
This patch fixes a Dawn crash issue when using textures in error state
in the copy commands of CommandEncoder.

In Dawn's copy commands (copyBufferToTexture and CopyTextureToBuffer),
we should check if the texture is in error state or not, or the assert
ASSERT(!IsError()) in texture->GetFormat() will fail and a crash will
occur.

In current Dawn code the validations on the buffer and texture objects
in the copy commands are executed in CommandEncoder::Finish(), which
is too late for textures according to the previous investigation. This
patch moves all these validations to the call of copy commands. The
checks on buffers are also moved away to keep the consistency of the
ones on textures.

BUG=chromium:937628
TEST=dawn_unittests

Change-Id: I0bc44e76262fba5927df20c6a7551b107bad5ca1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5240
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-03-05 00:03:28 +00:00
Jiawei Shao 081d5c2f64 Add validations on texture sample counts in B2T and T2B copies
This patch adds validations on the sample count of the textures used in
buffer-to-texture and texture-to-buffer copies. Vulkan SPEC requires the
textures used in vkCmdCopyBufferToImage and VkCmdCopyImageToBuffer must
have a sample count equal to VK_SAMPLE_COUNT_1_BIT.

BUG=dawn:56
TEST=dawn_unittests

Change-Id: I189923eee2d8734d5ae3b57aea1a55533e8d98b7
Reviewed-on: https://dawn-review.googlesource.com/c/5220
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-03-04 12:01:59 +00:00
Jiawei Shao a8ce0a434e Add validation on the creation of 4x Multisampled textures
This patch adds validations on the creation of the multisampled textures
with sampleCount == 4. The validations include:
1. Only accept 1 or 4 as valid value of sampleCount.
2. According to Vulkan SPEC, when sampleCount > 1:
- The value of mipLevelCount can only be 1
- We cannot create cube map or cube map array texture views on this
  texture.

BUG=dawn:56
TEST=dawn_unittests

Change-Id: Iac7cbe7cd7af16216b9185afd37a80eef0712f6b
Reviewed-on: https://dawn-review.googlesource.com/c/5160
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-03-04 01:31:38 +00:00
Corentin Wallez 1c92c159ad Fix overflow in CommandAllocator
It was essentially checking "currentPtr + commandSize <= endPtr" and
commandSize could make currentPtr overflow, making the comparison
succeed when it shouldn't have. This was caught through flakiness of the
LargeCommands allocator test.

Added a test provoking an overflow in Allocate and checking nullptr is
returned.

BUG=

Change-Id: I8ae4dad5b33c9d2005027c4d45b110ee0c65dd9a
Reviewed-on: https://dawn-review.googlesource.com/c/2841
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2019-03-01 12:04:58 +00:00
Corentin Wallez 0cdf9e09c4 Implement wrapping IOSurfaces in dawn::Texture.
This allows wrapping IOSurfaces in a dawn::Texture so a Dawn application
can sample from, or render to an IOSurface. It uses Metal's
functionality for wrapping textures in MTLTexture.

Support for single-plane BGRA8, RG8 and R8 IOSurfaces is added as well
as tests for sampling and using BeginRenderPass to clear them.

BUG=dawn:112

Change-Id: I367dbd1a75a0c7b81901fb0aae05f1cd46af3f3a
Reviewed-on: https://dawn-review.googlesource.com/c/5101
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-03-01 12:01:18 +00:00
Corentin Wallez 2dfb3f01e7 DawnTest: Allow checking for device errors.
The previous assumption is that all validation tests would be unittests
and that the end2end tests would always produce valid sequences of
commands. This not true because we can't test the validation of
backend-specific entrypoints in the unittests.

BUG=dawn:112

Change-Id: I89e2fe017bf3ecf6a83c9e8cdf4324c33f95a721
Reviewed-on: https://dawn-review.googlesource.com/c/5100
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-28 09:45:48 +00:00
Yan, Shaobo 31ac9850ad Using split copy to fix metal issue on uploading texture from an unpacked buffer
When uploading textures from an unpack buffer, some drivers count an
extra row padding when checking if the pixel unpack buffer is big
enough. This will generate error about totalUsedBytes is larger than the
buffer.

Using split copy to take care of the last row of the unpack buffer will
workaround this issue.

BUG=dawn:74

Change-Id: I9d521d65e1f9e8039ae0388092d5e650cc4e65ce
Reviewed-on: https://dawn-review.googlesource.com/c/4940
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-28 03:18:38 +00:00
Corentin Wallez af5d1865b7 DawnTest: Use last adapter on Metal
This is a temporary workaround to make sure we test the correct adapter
on the macOS builders: on multi-GPU systems the integrated is always
listed first so we would previously only test on Intel.

However we can't change the logic for D3D12 becaue the correct adapter
is the first one.

The proper fix for this is to pass the requested PCI device and vendor
ID to dawn_end2end_tests so it can select the correct adapter, but this
requires PCI IDs to be correct with Metal, which requires rolling the
macOS 10.13 SDK in Chromium.

BUG=dawn:109

Change-Id: Ice33367b0b8850306785b10a2dafc2f68d8b84d7
Reviewed-on: https://dawn-review.googlesource.com/c/5041
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-27 10:09:46 +00:00
Brandon Jones 9c061c3437 Add ValidateCanRecordCommands to Debug Marker APIs
Add ValidateCanRecordCommands to debug marker calls in ProgrammablePassEncoder.
Fixes issue found by ClusterFuzz.

Bug=chromium:935902
Bug=dawn:44

Change-Id: If1a4890a9de49a1872711a7b1a875ddc13130e88
Reviewed-on: https://dawn-review.googlesource.com/c/5080
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-27 09:25:26 +00:00
Jiawei Shao b2c5023c9c Remove RenderPassDescriptorBuilder
This patch removes RenderPassDescriptorBuilder completely from Dawn.
With this patch, RenderPassDescriptor is a structure instead of a Dawn
object, and all the checks in RenderPassDescriptorBuilder are moved into
CommandEncoder.cpp.

This patch also updates the helper functions and structures related to
RenderPassDescriptor because RenderPassDescriptor is no longer an
object but a structure with members in pointers.

BUG=dawn:6

Change-Id: Ic6d015582031891f35ffef912f0e460a9c010f81
Reviewed-on: https://dawn-review.googlesource.com/c/4902
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-27 09:21:56 +00:00
Yan, Shaobo 738567f148 Validate buffer to buffer copy size to be a multiple of 4 bytes
Metal needs buffer to buffer copy size must be a multiple of 4 bytes.
Adding validation to check this.

BUG=dawn:73

Change-Id: I9a4685d75439502017efa5455f7c2920a77f7a6d
Reviewed-on: https://dawn-review.googlesource.com/c/4900
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-27 02:46:27 +00:00
Corentin Wallez 9b8d2b0bbf Instance: Only discover default adapters once.
BUG=dawn:109

Change-Id: I9e54550dc8d3cdea289b3ad529a69a4cf3d5a35b
Reviewed-on: https://dawn-review.googlesource.com/c/5040
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-25 17:42:56 +00:00
Corentin Wallez b92fa10557 KnownObject: Make it an error to request ID 0
WebGPU error handling assumes non-optional objects point to valid
objects. The wire code wasn't updated to produce an error when ID 0 is
requested in the non-optional case.

BUG=chromium:934360

Change-Id: I203d2ec864dabe0e76109e1932fc31cbf26291d7
Reviewed-on: https://dawn-review.googlesource.com/c/4980
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-25 09:49:00 +00:00
Yunchao He 83684f9c13 Validate vertex format for Input State
BUG=chromium:935078, chromium:935026

Change-Id: I9c27cae2a0aa1ec23b8203a4d9b95e1d6d98a868
Reviewed-on: https://dawn-review.googlesource.com/c/5020
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-24 17:32:35 +00:00
Yunchao He 87bf834109 Add more validations for input state
This change sets limit for stride in VertexInputDescriptor and
offset in VertexAttributeDescriptor, and adds validation code
for them.

It also uses existing descriptors to replace redundant definitions.

BUG=dawn:107

Change-Id: Ifbb07f48ec9a5baae8ae8d21865dc384670b759a
Reviewed-on: https://dawn-review.googlesource.com/c/4901
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-22 15:08:03 +00:00
Corentin Wallez fda0617505 DawnTest: Print system configuration on env SetUp
This will help debug issues on builders.

BUG=dawn:109

Change-Id: I56d3fe391705077a95a711e7fc370459e0e70133
Reviewed-on: https://dawn-review.googlesource.com/c/4824
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-21 17:36:11 +00:00
Corentin Wallez 0b2f55257a DawnTest: add a test environment to contain global data.
This move the "use wire" option as well as instance and window creation
to the test environment. The environment will later be used to print
system information before running the tests for debugging.

BUG=dawn:109

Change-Id: Ice2f40bd5506cc69927287f9f8d51dac85f4472b
Reviewed-on: https://dawn-review.googlesource.com/c/4823
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-21 16:29:12 +00:00
Corentin Wallez e30d5e17e4 Require a semicolon at the end of DAWN_INSTANTIATE_TEST
TBR=kainino@chromium.org
BUG=chromium:926235

Change-Id: I67d8c594cd8dc060482e16de39b1996e01e9b44f
Reviewed-on: https://dawn-review.googlesource.com/c/4960
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-21 14:57:01 +00:00
Nico Weber e3b27e6661 dawn: Remove semicolons.
A cleanup needed for turning on -Wextra-semi in Chromium builds.

Bug: chromium:926235
Change-Id: I3d2b517ad21dfae9e7dc06613a7fe3e98d783b2a
Reviewed-on: https://dawn-review.googlesource.com/c/4841
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-21 14:39:01 +00:00
Victor Costan 56006dcf65 test: Replace _TEST_CASE_ with _TEST_SUITE_.
Googletest is (at last) converging with industry-standard terminology
[1]. We previously called test suites "test cases", which was rather
confusing for folks coming from any other testing framework.

Chrome now has a googletest version that supports _TEST_SUITE_ macros
instead of _TEST_CASE_, so this CL cleans up some of the outdated usage.

[1] https://github.com/google/googletest/blob/master/googletest/docs/primer.md#beware-of-the-nomenclature

Bug: chromium:925652
Change-Id: I86067e8846e31adedcf139f9650ac4e0ed5fbb19
Reviewed-on: https://dawn-review.googlesource.com/c/4921
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-21 09:43:40 +00:00
Jiawei Shao 2030166137 Rename several parameters to match WebGPU IDL
This patch renames the following parameters to match the latest WebGPU
IDL:
- BindGroupDescriptor.numBindings -> bindingCount
- BindGroupLayoutDescriptor.numBindings -> bindingCount
- BindGroupDescriptor.numBindings -> bindingCount
- queue.submit(numCommands, ..) -> commandCount
- RenderPipelineDescriptor.numColorStates -> colorStateCount
- TextureDescriptor:
  arraySize -> arrayLayerCount
  levelCount -> mipLevelCount
- TextureViewDescriptor:
  levelCount -> mipLevelCount
  layerCount -> arrayLayerCount

BUG=dawn:80

Change-Id: I615842dd5754d1ae1ddff31e25403bb3161f0201
Reviewed-on: https://dawn-review.googlesource.com/c/4881
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-21 00:45:19 +00:00
Brandon Jones 11d32c8095 Implementation of Debug Marker APIs
Introduces pushDebugGroup, popDebugGroup, and insertDebugMarker implementations
for Vulkan and Metal using VK_EXT_debug_marker and XCode, respectively.

Bug: dawn:44
Change-Id: I0ae56c4d67aa832123f27a1fcdddf65746261e57
Reviewed-on: https://dawn-review.googlesource.com/c/4241
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-20 20:21:00 +00:00
Yunchao He 938811eef9 Use const*const* to annotate color state descriptors
Color state descriptors are a sequence of descriptors embedded
in RenderPipeline descriptor. We should use const*const* to
annotate them for supporting potential extended features added
in color state descriptors in future.

BUG=dawn:77

Change-Id: Id755569fa5076668c3db7b219b699845bc2a1d69
Reviewed-on: https://dawn-review.googlesource.com/c/4880
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-02-20 13:00:36 +00:00
Corentin Wallez f20f5b9493 WebGPU error handling 5: Move CmdBufBuilder logic to CmdEncoder
This removes the CommandBufferBuilder and copies all the logic into
CommandEncoderBase instead. No changes were done to the logic except for
the implementation of CommandEncoderBase::HandleError and Finish.

BUG=dawn:8

Change-Id: I7b6f44c3cf501477422f067bd277cef470073860
Reviewed-on: https://dawn-review.googlesource.com/c/4820
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-20 11:46:16 +00:00
Corentin Wallez 3499d3ee97 DawnTest: Add function to init test environment.
This function is currently empty and added on its own so that it can be
rolled and a called in Chromium's dawn_end2end_tests_main.cc before
functional changes. Otherwise follow-up DawnTest changes wouldn't work
running dawn_end2end_tests built in Chromium.

BUG=dawn:109

Change-Id: Ieb191c415ee6720cab8330d3c2b05f76d263adfc
Reviewed-on: https://dawn-review.googlesource.com/c/4822
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-18 15:07:44 +00:00
Tom Anderson c1d15b1dbf Fix build error with use_custom_libcxx=true on Windows
std::codecvt has a protected destructor, so it needs some extra boilerplate to
be used with std::wstring_convert.  This CL follows the example from [1].

This was working before because MSVC is nonstandard and std::codecvt::~codecvt
is public.

[1] https://en.cppreference.com/w/cpp/locale/codecvt

BUG=chromium:801780

Change-Id: Ic4b5baabcd9bfc9f60231204f050e369e79b4579
Reviewed-on: https://dawn-review.googlesource.com/c/4840
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-18 10:48:53 +00:00
Corentin Wallez 37b715deec WebGPU error handling 4: CommandEncoder for wire tests
These were the last use of CommandBufferBuilder in Dawn except for its
implementation in dawn_native so it is removed from dawn.json.

Also removes an already disabled test that's obsoleted by the error
handling rework.

BUG=dawn:8

Change-Id: Id2b8a3d5afcd73cc77cfcb09c6a3f851b9483aea
Reviewed-on: https://dawn-review.googlesource.com/c/4761
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-02-18 09:42:03 +00:00
Corentin Wallez 2f321dd4ab Suppress BufferSetSubDataTests.ManySetSubData on Mac Intel
This test started failing on the macOS 10.14 builders as soon as it was
re-enabled. Suppress them while we investigate.

TBR=kainino@chromium.org
BUG=dawn:108

Change-Id: I7470a751d74c97558128cbbc90574b3d05629a3e
Reviewed-on: https://dawn-review.googlesource.com/c/4821
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-18 09:37:53 +00:00
Jiawei Shao 81da14f45c Remove RenderPassDescriptor from BeginRenderPassCmd
This patch removes RenderPassDescriptor from BeginRenderPassCmd so that
all the backends can get the data of render pass from the non-pointer
field of BeginRenderPassCmd instead. In this patch, RenderPassDescriptor
has been removed from all Dawn backends other than the virtual function
DeviceBase::CreateRenderPassDescriptor().

This patch is one of the preparations on completely removing
RenderPassDescriptorBuilder from Dawn.

BUG=dawn:6

Change-Id: I3a78f0b2d5318c2bf85858d6fbe939b7861a2cf8
Reviewed-on: https://dawn-review.googlesource.com/c/4800
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-18 08:56:03 +00:00
Yunchao He 7775258f98 Rename BlendState to ColorState, in order to match web idl
BUG=dawn:106

Change-Id: Id2cb1788becfacd09bd7f420d6525d22f96d1fe2
Reviewed-on: https://dawn-review.googlesource.com/c/4781
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-16 02:27:30 +00:00
Bryan Bernhart 67a73bd9fa Memory manager: buffer uploads (Metal+refactor) - Part 3
Manages a single persistently mapped GPU heap which is sub-allocated
inside of ring-buffer for uploads. To handle larger buffers without additional
unused heaps, ring buffers are created on-demand.

BUG=dawn:28
TEST=dawn_unittests

Change-Id: If4d3e717186895b1409502c1dea5ab751a4776b2
Reviewed-on: https://dawn-review.googlesource.com/c/4440
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-02-15 21:18:40 +00:00
Corentin Wallez 695b68d100 WebGPU error handling 3: CommandEncoder for validation tests
BUG=dawn:8

Change-Id: I16ad900387adcbaf793177e97a96a5f19dcc47a0
Reviewed-on: https://dawn-review.googlesource.com/c/4760
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-15 13:10:38 +00:00
Corentin Wallez e1f0d4e639 WebGPU error handling 2: CommandEncoder for samples and end2end tests
CommandEncoder is the replacement for CommandBufferBuilder. This commit
adds the dawn.json definition for it and an initial implementation that
wraps CommandBufferBuilder. This is done so that the code can be ported
to CommandEncoder gradually, otherwise the commit would be too big and
would risk many merge conflicts.

This converts all samples and end2end tests to use CommandEncoder.

BUG=dawn:8

Change-Id: If4ce86e6fb39ba4e0c2af6328d40e63be17d18c1
Reviewed-on: https://dawn-review.googlesource.com/c/4741
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-15 12:54:08 +00:00
Corentin Wallez 7be2a71f2b Descriptorize SwapChain.
This also makes SwapChain support WebGPU-style error handling.

BUG=dawn:8

Change-Id: I5a142ae58600445f0f44f6dbe419cb7c3cdc9464
Reviewed-on: https://dawn-review.googlesource.com/c/4660
Reviewed-by: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-15 11:15:58 +00:00
Jiawei Shao c8b067d2df D3D12: Remove RenderPassDescriptorD3D12
This patch removes RenderPassDescriptorD3D12 completely and moves the
creation of RTVs and DSVs to CommandBufferD3D12::RecordCommands(), where
we allocate all RTVs and DSVs used in the current command buffer in one
RTV heap and one DSV heap. Note that the method to allocate RTVs and
DSVs are too simple in this patch, and we will optimize it later.

This patch also adds a test to make sure Dawn works correctly when we
use two different render passes in one command buffer.

This patch is one of the preparations on completely removing
RenderPassDescriptorBuilder from Dawn.

BUG=dawn:6

Change-Id: I02e30c007fb8668a7474a3caf7a858782d0c92df
Reviewed-on: https://dawn-review.googlesource.com/c/4520
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-15 10:55:08 +00:00
Yunchao He 108bcbd5c9 Split AttachmentStateDescriptor, in order to match web idl
AttachmentStateDescriptor was removed in web idl. Its format info
for color attachment and depth/stencil attachment were split and
added into BlendStateDescriptor (renamed to ColorStateDescriptor)
and DepthStencilStateDescriptor (became optional) respectively.

This change makes dawn project match the revision in web idl.

BUG=dawn:106, dawn:102

Change-Id: If57b060db7b4b5d1124b4a79a3b92a3880047722
Reviewed-on: https://dawn-review.googlesource.com/c/4561
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-15 02:20:57 +00:00
Yunchao He 4dec7371a2 Construct VertexInputDescriptor, in order to match web idl
BUG=dawn:107

Change-Id: Ic219fb98a88a7ac597fbdc592f604f27b76d756b
Reviewed-on: https://dawn-review.googlesource.com/c/4721
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-02-14 23:56:07 +00:00
Jiawei Shao e7bb3fd119 Remove redundant RenderPass in Dawn unittests
This patch removes all the redundant creations of RenderPass in Dawn
unittests. In these tests render passes are actually never used.

BUG=dawn:6

Change-Id: I6301a150ea21af1a7ccc3b7ce2dd78351eb7e179
Reviewed-on: https://dawn-review.googlesource.com/c/4720
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-02-14 23:51:18 +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
Austin Eng 1198270483 Split wire tests into multiple test files
Bug: dawn:104
Change-Id: I0dc46dabc92c98df13dbf596dea63aeaaea85d3d
Reviewed-on: https://dawn-review.googlesource.com/c/4562
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-14 18:47:07 +00:00
Corentin Wallez 0f0c40de68 QueueSumit: Validate commands != nullptr before checking they are valid
device->ValidateObject dereferences the object and would crash when
the command buffers are nullptr. This issue would have disappeared when
WebGPU error handling is implemented for command buffers. We still fix
it now to please fuzzers.

BUG=dawn:8
BUG=chromium:931880

Change-Id: Ia9d89ebdde9e2ac93de58da2201708c400a712c7
Reviewed-on: https://dawn-review.googlesource.com/c/4740
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-14 18:13:47 +00:00
Yunchao He b2207737ab Construct VertexAttributeDescriptor, in order to match web idl
The parameters about vertex attribute were encapsulated in
VertexAttributeDescriptor in web idl. This change construct
this descriptor accordingly.

BUG=dawn:107

Change-Id: Ia1c6e53af951d8f2a0c0b69bdca09291c2661e50
Reviewed-on: https://dawn-review.googlesource.com/c/4620
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-02-14 00:35:39 +00:00
Corentin Wallez 445869d2b0 Fix extra semicolon in DAWN_UNUSED_FUNC
This is fixes the soon to be added -Wc++98-compat-extra-semi wraning.

TBR=kainino@chromium.org
BUG=

Change-Id: I26abb54c821a9ad0893af37b626c44d8271c216c
Reviewed-on: https://dawn-review.googlesource.com/c/4661
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-13 22:11:48 +00:00
Austin Eng 446ab44ddb Add Buffer Destroyed state and validation tests
Adds Destroy() to the Buffer frontend but doesn't implement
it in the backend yet.

Bug: dawn:46, dawn:7
Change-Id: I2e6bdba1484fc5f49599801b4ffe3e9a6aaf60a5
Reviewed-on: https://dawn-review.googlesource.com/c/3720
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-02-13 21:26:48 +00:00
Jiawei Shao 1809ff7423 Vulkan: Remove RenderPassDescriptorVk
This patch removes RenderPassDescriptorVk completely and move the
function RecordBeginRenderPass to CommandBufferVk.cpp, which is
a part of preparation of removing RenderPassDescriptorBuilder from
Dawn.

BUG=dawn:6

Change-Id: Id666ef2f998fa65de93deb16afedb1d53d6b8bc0
Reviewed-on: https://dawn-review.googlesource.com/c/4540
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-02-13 19:53:58 +00:00
Corentin Wallez a594f8fdb4 WebGPU error handling 1: Return error objects on errors.
Dawn used to return "nullptr" when an error happened while creating an
object. To match WebGPU we want to return valid pointers but to "error"
objects.

This commit implements WebGPU error handling for all "descriptorized"
objects and changes the nullptr error checks into "ValidateObject"
checks. This method is used both to check that the object isn't an
error, but also that all objects in a function call are from the same
device.

New validation is added to objects with methods (apart from Device) so
they check they aren't error objects.

A large number of ASSERTs were added to check that frontend objects
aren't accessed when they are errors, so that missing validation would
hit the asserts instead of crashing randomly.

The bind group validation tests were modified to test the behavior with
both nullptrs and error objects.

Future commits will change the CommandBufferBuilder to not be a builder
anymore but an "Encoder" instead with special-cased error handling. Then
once all objects are descriptorized, the notion of builders will be
removed from the code.

BUG=dawn:8

Change-Id: I8647712d5de3deb0e99e3bc58f34496f67710edd
Reviewed-on: https://dawn-review.googlesource.com/c/4360
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-13 13:09:18 +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
Corentin Wallez bb5696bcd3 Simplify BackendBinding following adapters.
It doesn't need to care about device creation anymore, except for the
GLFW window hints and creating a GL context to discover the adapter.

Also remove the non-adapter GetPCIInfo.

BUG=dawn:29

Change-Id: I9bc8232536a55d2f973463ae0f2e0548dfc35456
Reviewed-on: https://dawn-review.googlesource.com/c/4381
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-02-12 15:48:15 +00:00
Yunchao He 5987c4e839 Remove blendEnabled in BlendStateDescriptor, in order to match web idl
BUG=dawn:32

Change-Id: I7225d919ca1a9c1c848050ad3b9e8832725f0af6
Reviewed-on: https://dawn-review.googlesource.com/c/4460
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-12 00:32:13 +00:00
Corentin Wallez 393d555a0e PipelineLayout: Only allow accessing defined BGLs.
Undefined BGLs are stored as nullptr in the pipeline layout, so to be
defensive we assert clients of PipelineLayout can't request undefined
BGLs (which forces iteration on the BGLMask).

Also fix two cases where the BGLs were iterated on incorrectly.

BUG=dawn:8

Change-Id: I3c084125b93d6684b4c79a56745632874079ebec
Reviewed-on: https://dawn-review.googlesource.com/c/4480
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-02-11 23:35:33 +00:00
Corentin Wallez 6be3b97ff5 End2EndTests: Fix -w runs without ASSERTs enabled.
The flushing of command buffers was in an ASSERT which made them skipped
on release builds.

BUG=

Change-Id: I07bf558d1689f4bea0047a80ab3c8b04938f04a0
Reviewed-on: https://dawn-review.googlesource.com/c/4501
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-11 23:34:52 +00:00
Austin Eng e2c851372a Create wire Client and Server classes with private impl
This creates proper Client and Server interfaces which will be necessary
for adding additional features to the Wire for chrome integration

Bug: dawn:103
Change-Id: I181e95079b0bac85c2c6152ad8066a94b80c8d28
Reviewed-on: https://dawn-review.googlesource.com/c/4002
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-11 21:50:16 +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
Corentin Wallez 3b71e65658 Make CopyTests_T2B.Texture2DArrayMip suppression more precise
BUG=dawn:101

Change-Id: I35b0980126e546e9846938475496ab20b5f06254
Reviewed-on: https://dawn-review.googlesource.com/c/4420
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-07 13:54:55 +00:00
Bryan Bernhart 01a3e9b638 Disable copy test failing on Intel Linux.
BUG=dawn:101
TEST=dawn_end2end_tests

Change-Id: Ib2eefeabc1a4e5326dcf7e1ba085e8cf979f4d3a
Reviewed-on: https://dawn-review.googlesource.com/c/4400
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2019-02-07 00:42:41 +00:00
Bryan Bernhart 96e1911b0b Memory manager: buffer uploads (Vulkan) - Part 2
Manages a single persistently mapped GPU heap which is sub-allocated
inside of ring-buffer for uploads. To handle larger buffers without additional
unused heaps, ring buffers are created on-demand.

BUG=dawn:28
TEST=dawn_unittests

Change-Id: Ic2a5df3142fc24fa772b9a85b38248eea8c7e003
Reviewed-on: https://dawn-review.googlesource.com/c/4260
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-02-06 18:10:12 +00:00
Raul Tambre 7771f58c7f Fix missing include for std::unique_ptr in VulkanBinding.cpp
Bug: dawn:100
Change-Id: Ied470aca31dba15e704ec6c737b01e3ff344b240
Reviewed-on: https://dawn-review.googlesource.com/c/4380
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-06 17:35:41 +00:00
Corentin Wallez 978fa65a2c Metal: Implement the backend connection and adapter.
BUG=dawn:29

Change-Id: Idaca7d2f8ac52d5f46d8030571b5e2da3a573a97
Reviewed-on: https://dawn-review.googlesource.com/c/3940
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-05 13:02:30 +00:00
Corentin Wallez a27bdb4a5e Vulkan: Fix finding of the largest candidate heap.
BUG=dawn:98

Change-Id: Ibcae3a760b9feb2cbba47d40c3eeea9e63481682
Reviewed-on: https://dawn-review.googlesource.com/c/4340
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-05 12:52:50 +00:00