Commit Graph

1292 Commits

Author SHA1 Message Date
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
Corentin Wallez 8c88e1ddce Remove redundant BackendType enums
BUG=dawn:29

Change-Id: Iaef26ca12a7a8721de17edb76e8fd4ff66cac0bd
Reviewed-on: https://dawn-review.googlesource.com/c/4342
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-05 12:17:20 +00:00
Corentin Wallez 00976d0db1 Make setBlendColor take in a Color instead of 4 floats
BUG=

Change-Id: Ic70d5b664c0ea64c038129cdb83f4ba05fb61830
Reviewed-on: https://dawn-review.googlesource.com/c/4341
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-05 12:13:10 +00:00
Corentin Wallez d1be0e7077 Vulkan: Implement the backend connection and adapter.
This also changes VulkanInfo to gather info on backends / adapters
instead of the device, because all the info gathering can happen before
the device is created.

BUG=dawn:29

Change-Id: I9dc4412f494428f1ae589544d3adf76fe8b9a3a3
Reviewed-on: https://dawn-review.googlesource.com/c/3941
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-02-04 09:31:09 +00:00
Raul Tambre c26f6dae33 Fix missing include for std::unique_ptr in D3D12Binding.cpp
Bug: dawn:99
Change-Id: Ifeaa69b3061fe962a39f0b13bdee028dbeb2677d
Reviewed-on: https://dawn-review.googlesource.com/c/4320
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-02-04 09:04:19 +00:00
Yunchao He baa3741c9f Rename variables in DepthStencilStateDescriptor, in order to match web idl
Bug:dawn:31
Change-Id: Ie3326e13f62446bf020ae60f47c8dfa6687d7b9a
Reviewed-on: https://dawn-review.googlesource.com/c/4240
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-01-30 21:11:43 +00:00
Austin Eng 8749506bae dawn_wire: Move manual class members from ServerBase to Server
Bug: dawn:88
Change-Id: Ic216006aa52cace7aa7451b957e72119783e6d7a
Reviewed-on: https://dawn-review.googlesource.com/c/4100
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-30 17:37:28 +00:00
Raul Tambre 2427666df1 Fix missing include for std::unique_ptr in RingBuffer.h
Bug: dawn:96
Change-Id: If815bb1811eff5467039df6fdf939ef068abdb15
Reviewed-on: https://dawn-review.googlesource.com/c/4300
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-30 16:27:28 +00:00
Frank Henigman 4531bd2477 Convert spirv-cross fuzzers to use shaderc.
BUG=dawn:95

Change-Id: I0fedb7b068de39c41b1b1d8aa2b42a96fdb584fb
Reviewed-on: https://dawn-review.googlesource.com/c/4140
Commit-Queue: Frank Henigman <fjhenigman@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2019-01-30 16:12:28 +00:00
Corentin Wallez d77fd5f889 D3D12: Implement the backend connection and adapter.
BUG=dawn:29

Change-Id: Id4497b4a91ba58b79d1cd976a52df5a0fa5d60a8
Reviewed-on: https://dawn-review.googlesource.com/c/3844
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-01-30 16:07:48 +00:00
Li Hao 45da8c0115 Fix non-zero validation in Draw and DrawIndexed
Metal validation layer does not allow indexCount or instanceCount to be 0 in
drawIndexedPrimitives and drawPrimitives, otherwise we should draw nothing
with these operations.

BUG=dawn:76
TEST=dawn_end2end_tests

Change-Id: Ic22be73ac992289d4bc8d7b3d4d30d20c4488776
Reviewed-on: https://dawn-review.googlesource.com/c/3900
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-01-30 09:01:08 +00:00
Austin Eng 1139d1c12c Factor wire client handlers into proper command handlers and doers
Bug: dawn:88
Change-Id: I3ab28efad7edc7d06f11aa5abae07a1bb3d7e59e
Reviewed-on: https://dawn-review.googlesource.com/c/4003
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-30 03:00:17 +00:00
Austin Eng cd4fd8e7cd Make the wire Client own ObjectAllocators and CommandSerializer
This moves ownership of ObjectAllocators and CommandSerializers
from the Device to the Client. There may be also be multiple
Devices, so New() now takes the Device the object belongs to.
Device allocation specializes New() to take the owning Client so
that we can get a pointer to the Client from any Dawn API object.

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

Bug: dawn:88
Change-Id: I471b8c27804916257eff266a51d087ba1ddbfeb6
Reviewed-on: https://dawn-review.googlesource.com/c/4000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-01-30 02:20:58 +00:00
Bryan Bernhart 74e95fff4a Memory manager: buffer uploads (D3D) - Part 1
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: Ifc5a1b06baf8633f1e133245ac1ee76275431cc5
Reviewed-on: https://dawn-review.googlesource.com/c/3160
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-01-29 00:10:07 +00:00
Yunchao He c0f31e73e4 Use const*const* to annotate a sequence of descriptors
BUG=dawn:77

Change-Id: I2a523e54a06173c157730e043c25e9629887fd1f
Reviewed-on: https://dawn-review.googlesource.com/c/3820
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-21 08:29:01 +00:00
Jiawei Shao 850c0d9aec Fix a bug in computing bind group index in GroupsInheritUpTo()
This patch fixes a crash issue on D3D12 backends that are caused by
a bug in computing bind group index in function GroupsInheritUpTo().
The return value of this function should be kMaxBindGroups instead of
(kMaxBindGroups + 1) as the maximum number of bind group sets is
kMaxBindGroups.

This patch also adds a regression test on this bug.

BUG=dawn:78
TEST=dawn_end2end_tests

Change-Id: Ie060a52f987803ed6a325b337ff678e6b73e2897
Reviewed-on: https://dawn-review.googlesource.com/c/4080
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-01-18 04:41:20 +00:00
Brandon Jones 799cddcb83 Trigger GC Sweeps on Vulkan
Vulkan backend wasn't making a call to Tick(), meaning that
vkDestroy* operations were being enqueued, but never executed.

Change-Id: I597f59d6a17ea4247a1a042a2b5a7997d2e95612
Bug: dawn:94
Reviewed-on: https://dawn-review.googlesource.com/c/4020
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
2019-01-17 00:15:14 +00:00
Yunchao He 63b59cfdf3 Remove annoying warnings in dawn_unittests
There are a lot of annoying warnings about uninteresting mock
function calls when running dawn_unittests because object release
function calls are not included into the gtest EXPECT_CALL.

BUG=dawn:93

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

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

Bug: dawn:88
Change-Id: Ic796796ede0aafe02e14f1f96790324dad92f4c0
Reviewed-on: https://dawn-review.googlesource.com/c/3800
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-15 20:49:53 +00:00
Austin Eng a483fac90d d3d12: Lazily apply IASetVertexBuffers before draw
This fixes a bug where D3D12 SetVertexBuffers was using the input info
from the last set pipeline's InputState. IASetVertexBuffers needs to be
reapplied if the input state changes.

Bug: dawn:91
Change-Id: I7d0b308ea20cee6d595f6b29548f57d82c8e47a4
Reviewed-on: https://dawn-review.googlesource.com/c/3860
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-15 04:10:48 +00:00
Raul Tambre 392b4a95c6 Fix missing include for std::unique_ptr in NullBinding.cpp
Bug: dawn:92
Change-Id: I9e179bfc7afb92c42d4111676a1c852d6eeae5cb
Reviewed-on: https://dawn-review.googlesource.com/c/3920
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-12 17:13:45 +00:00
Corentin Wallez ec18f9683c Gather PCI device info through the adapter when possible
This will help migrate PCI info collection from the device to the
adapter where it belongs.

BUG=dawn:29

Change-Id: Ifa7d167249c97f1934f7c10d420f864f59babd37
Reviewed-on: https://dawn-review.googlesource.com/c/3843
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-10 10:50:54 +00:00
Corentin Wallez 7aae840a22 Add missing ToBackend implementation for Adapter
BUG=dawn:29

Change-Id: I00926dd201c7a8f24d769078540c75c25f210515
Reviewed-on: https://dawn-review.googlesource.com/c/3842
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-10 10:12:24 +00:00
Corentin Wallez 0d03b09623 Remove non-adapter way to create null devices
BUG=dawn:29

Change-Id: I2153aa30afd096a3f27c8b8b2ba23a10c0ade50a
Reviewed-on: https://dawn-review.googlesource.com/c/3841
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-10 10:07:04 +00:00
Corentin Wallez bd48385d50 Add static library versions of libdawn*
Chromium will want to have both static and shared library versions of
Dawn to use in non-component and component builds respectively.

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

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

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

BUG=dawn:85

Change-Id: Ib747deb9308e1165dd66002487147ba279d3eac0
Reviewed-on: https://dawn-review.googlesource.com/c/3761
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-09 09:05:18 +00:00
Corentin Wallez 97d2a71684 dawn_native: define exported functions in their own files.
This adds a new FooBackend.cpp file for each backend that defines
exactly the symbols that are exported by libdawn_native's headers. THis
will allow factoring most of the compilation of dawn_native between the
shared and static library variants.

BUG=dawn:85

Change-Id: I69c808dac2fe5e8bb08356117e3997677787b08a
Reviewed-on: https://dawn-review.googlesource.com/c/3760
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-09 08:35:16 +00:00
Kai Ninomiya 17be9deed6 Fix samples on null backend (add swapchain impl)
BUG=
Change-Id: I96e6c58b4ec46af58f7c0a97c88308075efe68dd
Reviewed-on: https://dawn-review.googlesource.com/c/3700
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-07 19:54:36 +00:00
Austin Eng 9dc1250d3e Use single DestroyObject command in the wire
Bug: dawn:83
Change-Id: Ic875d5111f59e7166d2decb3dc6a84973d9babdf
Reviewed-on: https://dawn-review.googlesource.com/c/3680
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-07 17:52:56 +00:00
Corentin Wallez 7c0f0fbf91 Vulkan: Always request all VkSurfaceKHR-related extensions
The backend had a "requiredInstanceExtensions" parameter to device
creation so that we could request the right instance extensions to
support swapchains. When we have dawn_native::Instance we don't want to
require this information before we can use the Vulkan backend. Instead
we make the backend always require all VkSurfaceKHR extensions. This
should be safe because these extensions basically enable copying a
struct into an opaque VkSurfaceKHR object and not much else.

BUG=dawn:29

Change-Id: I7fc5426f5770b65bb35f02793a1319eb0653782c
Reviewed-on: https://dawn-review.googlesource.com/c/3662
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-07 12:04:46 +00:00
Corentin Wallez 95fd2821c2 MetalBinding: query the MTLDevice instead of creating it.
With adapters the Metal backend will be in charge of creating the
MTLDevice so we remove this responsibility from the bindings.

BUG=dawn:29

Change-Id: Id7b9e5f6249963e2b87a91242a18119ba8d11c13
Reviewed-on: https://dawn-review.googlesource.com/c/3661
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-07 10:01:11 +00:00
Corentin Wallez 9506d53938 Remove unused SwapChainImplVulkan
BUG=dawn:29

Change-Id: Ic36bdd83b2351e3ef9d6825dee64469405e840a3
Reviewed-on: https://dawn-review.googlesource.com/c/3660
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-07 09:56:51 +00:00
Corentin Wallez 90e594ee8b OpenGL: Implement the backend connection and adapter.
The OpenGL backend can't gather discover default adapters because it
needs getProc to do anything so we add DiscoverAdapters method to
Instance that takes backend-specific options.

dawn_native::opengl::CreateDevice is removed in favor of the adapter
path so OpenGLBinding is modified to create an instance locally. This is
only temporary until all backends support adapters, at which point a lot
of *Binding code will be factored.

Also contains a small fix for Result<T, E> with movable types.

BUG=dawn:29

Change-Id: I4eb3d4a14a871af73e1872132aff72b45e5fe566
Reviewed-on: https://dawn-review.googlesource.com/c/3663
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-01-07 09:48:03 +00:00
Raul Tambre ab8eb2d6ed Fix missing include for unique_ptr in BackendConnection.h
Bug: dawn:84
Change-Id: I8a878c02fdee777e6a7aeb7fabde8ffbf8eafb0e
Reviewed-on: https://dawn-review.googlesource.com/c/3740
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-07 09:34:20 +00:00
Corentin Wallez 110bc7918f Validate EndPass isn't called more than once.
BUG=chromium:918254

Change-Id: I24db2f459bae7c0644a54472e56159ff8f5ab955
Reviewed-on: https://dawn-review.googlesource.com/c/3621
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-04 12:01:44 +00:00
Corentin Wallez ac67fec1c9 dawn_native: Add Instance and Adapters
New objects are introduced to control what happens before device
creation in dawn_native:
 - Instance: a connection from the application to dawn_native that is
used for dependency injection and to discover adapters.
 - Adapters: represents the possibility of device creation for a specific
(GPU, backend) pair.
 - BackendConnection: an internal object that standardizes the interface
between the frontend and backends.

The BackendConnection interface is implemented for the Null backend and
stubbed out in other backends. This allows this change to port the
ValidationTests to use the new Instance and Adapters concept and deal
with other backends later.

BUG=dawn:29

Change-Id: I19719a9342b4af091accc0c02fb6b9697eadde7b
Reviewed-on: https://dawn-review.googlesource.com/c/3500
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-04 10:30:40 +00:00
Corentin Wallez e9212dfe30 Vulkan: Print the VkResult value on device creation failure.
This adds a CheckVkSuccess utility function that adds the VkResult value
to the context lost error message.

Also adds a small fix to dawn_native/Error.h interoperability between
MaybeError and ResultOrError<NonPointer> with tests.

BUG=chromium:917555
BUG=dawn:79

Change-Id: Icc01122d62d83693fc0ea3f26b272f2372fd3087
Reviewed-on: https://dawn-review.googlesource.com/c/3623
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-01-04 10:18:40 +00:00
Yunchao He 6e308846c2 Unify the compare function for sampler and depth stencil
Both sampler and depth stencil include compare function, and we
need to change it to appropriate functions for different backends.
In order to avoid code duplication, we put it into a util file
for every backend, then include that file and call the function
from where we need it.

We can put similar functions which can be shared among different
objects into the util file in future.

Shaobo's patch has already created such a util function for compare
function for sampler. This patch removes the duplicated compare
function in RenderPipeline for depth stencil descriptor, and call
the function in util file instead.

BUG=dawn:31, dawn:47

Change-Id: Ia645b48e026b5a372d1023aa7e8ecdf1e4ed7c6d
Reviewed-on: https://dawn-review.googlesource.com/c/3641
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-04 09:53:50 +00:00
Yan, Shaobo 93158ebede Complete the sampler object to match WebGPU
WebGPUSampler is much more complete than Dawn's Sampler.
This patch implement the missing part.

BUG=dawn:47

Change-Id: Ief45cb9710493e9d79ddab60fe3be5a123b76ebd
Reviewed-on: https://dawn-review.googlesource.com/c/3540
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-04 04:56:08 +00:00
Yunchao He ea56333c1e Replace DepthStencilState builder via DepthStencilState descriptor.
This change also removes DepthStencilState object.

Bug=dawn:31

Change-Id: I7bb54ef4da527184bb2726c77d93d411d44c3956
Reviewed-on: https://dawn-review.googlesource.com/c/3541
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-01-04 04:28:37 +00:00
Corentin Wallez 0b364067d0 MetalBackend.h: Remove dead declarations
BUG=

Change-Id: Iaa19701a9fd0299db027917f7053fc50e18c6bf8
Reviewed-on: https://dawn-review.googlesource.com/c/3340
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-01-03 17:59:08 +00:00
Yunchao He 74ec15010f Assigning nullptr to descriptor's nextInChain in C++ is unneeded
It has already been initialized to nullptr by C++ autogen code.

BUG=dawn:82

Change-Id: I2c1cad003a7a12227cb3d17a90e12c16739ee9a0
Reviewed-on: https://dawn-review.googlesource.com/c/3600
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-01-03 10:33:55 +00:00
Yunchao He 2b9d702c09 Fix a bug for depth test on Vulkan backend
The default value for maxDepthBound should be 1.0.

BUG=dawn:81

Change-Id: I337aac884456c739222bc31f8003267aa6de96af
Reviewed-on: https://dawn-review.googlesource.com/c/3580
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-01-03 09:00:34 +00:00
Jiawei Shao d238bb67a5 Support using a layer of a texture as a color attachment on OpenGL
This patch implements using a layer of a texture as a color attachment
on OpenGL by using glFramebufferTextureLayer. As WebGPU won't support
rendering into a texture view whose format is different from the
original texture, it is correct to use glFramebufferTexture on the
OpenGL backends.

BUG=dawn:16

Change-Id: Iab6d905ee119bb9bb2d1bb212134cf757483c4d4
Reviewed-on: https://dawn-review.googlesource.com/c/3560
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2019-01-03 00:07:44 +00:00
Jiawei Shao 5dee56f39c Fix crash when creating texture view on textures from Metal swap chain
For the textures got from Metal swap chain, their "framebufferOnly" may
be true, which means they can only be used as attachments in a render
pass, and they are not allowed to be used in MTLRenderCommandEncoder,
MTLBlitCommandEncoder or MTLComputeCommandEncoder. So currently Dawn
examples all crash when METAL_DEVICE_WRAPPER_TYPE = 1 is set into
environmental variables.

This patch adds checks on the situations that we do not need to create
a Metal texture view:
1. We create Metal texture only when the usage of the texture includes
   Sampled or Storage.
2. We won't create Metal texture view if the view uses the same format
   as the original texture, the whole mipmap levels and array slices.
3. We use the original MTLTexture and set the slice and level in
   MTLRenderPassDescriptor.

Furthermore, with this patch, "setFramebufferOnly" is set to true only
when the usage passed to configure is a subset of (OutputAttachment |
Present).

BUG=dawn:69

Change-Id: Ie2670f383c16eafa3b1c6f99126922e940721174
Reviewed-on: https://dawn-review.googlesource.com/c/3400
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-29 10:47:28 +00:00
Yunchao He 92700bfccd Replace BlendState builder via BlendState descriptor.
This change also removes BlendState object.

Bug=dawn:32

Change-Id: I8bf4ff7531e7504efb17b6bae3ca01f1f2b4131e
Reviewed-on: https://dawn-review.googlesource.com/c/3042
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2018-12-27 06:32:31 +00:00
Kai Ninomiya cb71ba7b3a Don't use ConsumedError on device initialization errors
If there's an error during device initialization, it's too early to use
ConsumedError (SetErrorCallback can't possibly have been called).
In this case, manually handle the error from initialization.

This will help us diagnose issue chromium:917555, where device
initialization is failing but the error is not printed.

TBR: cwallez@chromium.org
Bug: chromium:917555
Change-Id: I63ba3983688f508550afe2815ca1dda36130fed1
Reviewed-on: https://dawn-review.googlesource.com/c/3520
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2018-12-22 05:40:11 +00:00
Yan, Shaobo 300eec0f82 Rename SetRenderPipeline and SetComputePipeline to SetPipeline
To match the WebGPU idl, SetRenderPipeline and SetComputePipeline need to change
the name to SetPipeline.

This patch just rename these two APIs

BUG=dawn:52

Change-Id: I2545c94158ebd051027a018650bf760a25845d73
Reviewed-on: https://dawn-review.googlesource.com/c/3480
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
2018-12-21 10:40:26 +00:00
Yan, Shaobo 21ed12045b Guard header files in utils with #ifdef and #endif
Some header files in utils missing #ifdef and #endif and this caused including
header files multiple times.

This patch fix it.

BUG=dawn:72

Change-Id: Ib28b1a1cef91e49a5754ec6b3d66327076070d99
Reviewed-on: https://dawn-review.googlesource.com/c/3461
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-20 11:21:04 +00:00
Yan, Shaobo c8bf89ddf0 Remove "Builders" related with pipeline
RenderPipeline and ComputePipeline has been created with descriptors and PipelineBuilder
is not needed anymore.

This patch remove these remain "Builders" in dawn.

BUG=dawn:52

Change-Id: I8b119c540952beb3386913197f25b9c441f53ba4
Reviewed-on: https://dawn-review.googlesource.com/c/3460
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-20 11:00:32 +00:00
Corentin Wallez 2745f37875 Suppress more failure on GPU FYI Linux AMD Release (R7 240)
Tests are run in this order: 1, 2, 3

After suppressing test 2, test 3 started failing on the builder, this
seems to point out that test 1 is leaving the driver in a bad state.

We add suppressions both 1 and 3 just to be safe.

TBR=senorblanco@chromium.org
BUG=chromium:915430

Change-Id: Ie601b03f9e5038c623d8b7e009d2a9fb8086d181
Reviewed-on: https://dawn-review.googlesource.com/c/3420
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-19 13:36:53 +00:00
Jiawei Shao 5e811aeee5 Add render pass color and depth stencil attachment descriptor
This patch is the first one of the descriptorization of render pass. In
this patch we add support of RenderPassColorAttachmentDescriptor
and RenderPassDepthStencilAttachmentDescriptor to
RenderPassDescriptorBuilder.

This patch also adds StoreOp to render pass color and depth stencil
attachment descriptor.

RenderPassDescriptorBuilder will be completely removed in the next
patch.

BUG=dawn:6, dawn:49
TEST=dawn_end2end_tests, dawn_unittests

Change-Id: If623b41d04016425efa53932ae1648daf2263675
Reviewed-on: https://dawn-review.googlesource.com/c/3300
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-12-19 08:21:13 +00:00
Brandon Jones 292c0c31f2 Add D3D12 Functionality For Multiple Bind Groups
SPIRV-Cross outputs HLSL utilizing register spaces for seperate bind groups.
This changes the D3D12 backend to also use them.

Bug: dawn:66
Change-Id: I0590ae59fa3d369b57cdb32e4c9808c137fa88dc
Reviewed-on: https://dawn-review.googlesource.com/c/3360
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <brandon1.jones@intel.com>
2018-12-18 19:59:59 +00:00
Corentin Wallez d23fdd3624 Fix the suppression on OpenGL to not specify the GPU
The OpenGL backend doesn't expose PCI device and vendor IDs yet which
means that IsAMD() is always false, making the test not skipped.

TBR=senorblanco@chromium.org
BUG=chromium:915430

Change-Id: Ic630080df442826b572cbd294978820109424229
Reviewed-on: https://dawn-review.googlesource.com/c/3381
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-18 18:04:42 +00:00
Corentin Wallez 12a2f65c43 Suppress failure on GPU FYI Linux AMD Release (R7 240)
TBR=senorblanco@chromium.org
BUG=chromium:915430

Change-Id: I57cc253eda45faa4c68a2cc012f594bc3514ae42
Reviewed-on: https://dawn-review.googlesource.com/c/3380
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-18 12:57:10 +00:00
Corentin Wallez 6322010014 Buffer: fix overflows in SetSubData and mapping validation
Also adds tests for overflows.

BUG=chromium:914240

Change-Id: Ibb4f86c04ffab1f1d834b8a439ba542a5291441f
Reviewed-on: https://dawn-review.googlesource.com/c/3320
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-17 17:08:41 +00:00
Corentin Wallez 28c1fba1c0 Validate CommmandBuffers aren't ended mid pass.
Also adds regression tests.

BUG=chromium:914566
BUG=chromium:914641

Change-Id: Ic1f9f2440580c3598831c8b2d1310e81aa944133
Reviewed-on: https://dawn-review.googlesource.com/c/3321
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-15 10:34:42 +00:00
Corentin Wallez e018292bed WireAndFrontendFuzzer "wait" for all commands before freeing
Otherwise the Device might fire callbacks when it is destroyed,
causing use-after-frees on the wire server.

BUG=chromium:914620
BUG=chromium:914615

Change-Id: Ic47b219b4ebe2eb5abd525741c0ff1180282c87d
Reviewed-on: https://dawn-review.googlesource.com/c/3322
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-15 10:34:02 +00:00
Yunchao He 48485e36a8 Add StencilStateFaceDescriptor, in order to match web idl
BUG=dawn:31

Change-Id: I52f95ed134ae5afdf4fc872d5cfc5f36ec1a7a69
Reviewed-on: https://dawn-review.googlesource.com/c/3302
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2018-12-15 02:32:34 +00:00
Austin Eng 08aa58f8d6 Check if fence is nullptr in PostHandleQueueSignal
PostHandleQueueSignal assumed that fence was not null because QueueSignal
generates an error if it is. The errors are not surfaced immediately so
this additional check is needed before doing the post-handler.

Bug: chromium:914808
Change-Id: I2a99f5229712d49d3c9a2d1f3f2dd1009247a24c
Reviewed-on: https://dawn-review.googlesource.com/c/3280
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-14 08:29:38 +00:00
Corentin Wallez fd3717fa7c Fix the build with only the OpenGL and Null backends enabled
BUG=chromium:914375

Change-Id: I07dbdbdb7518ac6b9800483f570fe97c16f08ee1
Reviewed-on: https://dawn-review.googlesource.com/c/3243
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-14 08:28:55 +00:00
Jiawei Shao ff9562f792 Implement 'baseVertex' in drawIndexed() on D3D12, Metal and Vulkan
This patch adds the support of the parameter 'baseVertex' of drawIndexed
on D3D12, Metal and Vulkan back-ends.

BUG=dawn:51
TEST=dawn_end2end_tests

Change-Id: Ibd25884ad2abceaaed744d74c4ee6b0ae6b3fa1b
Reviewed-on: https://dawn-review.googlesource.com/c/3221
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-12-13 01:05:26 +00:00
Brandon Jones 069664e58b Remove textureAspect from TextureCopyView
Delete all references to textureAspect inside of TextureCopyView to
reflect WebGPU IDL change.

Bug: dawn:17
Change-Id: Ib849f07bed6aff93e2759739e5c7a92367658df4
Reviewed-on: https://dawn-review.googlesource.com/c/3200
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-12-12 09:27:46 +00:00
Jiawei Shao 8bff3b22be Make TextureDescriptor match WebGPU IDL
This patch updates the definition of TextureDescriptor to make it match
WebGPU IDL:
1. Rename 'arrayLayer' to 'arraySize'
2. Add the missing member "sampleCount" and check that currently
   sampleCount can only be 1.

BUG=dawn:56
TEST=dawn_unittests

Change-Id: I642186529f045865ae344cb5545ac80e14445c59
Reviewed-on: https://dawn-review.googlesource.com/c/3180
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-12 09:27:16 +00:00
Brandon Jones d86edb310a Implement BufferCopyView.imageHeight Parameter
Implement BufferCopyView.imageHeight Parameter. Adds validation tests.
Adequate functional testing not possible without 3D texture support.

Bug: dawn:48
Change-Id: I00e4464eb451c948dee2890a11fb0984eff681a0
Reviewed-on: https://dawn-review.googlesource.com/c/2980
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-12-11 09:48:36 +00:00
Yan, Shaobo a49242766a Render Pipeline Descriptorization -- Part I
This patch remove render pipeline builder and use descriptor to create render pipeline.
Sub-objects in descriptor will be removed in future.

Bug: dawn:4
Change-Id: I58dd569c7be42c2648311847b939c681189c2854
Reviewed-on: https://dawn-review.googlesource.com/c/2180
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
2018-12-10 19:47:22 +00:00
Corentin Wallez c3ecb5a77c Temporarily add nullptr checks in frontend
The fuzzer is able to trigger nullptr reads by failing to create objects
and then using the resulting nullptr in other operations. The proper fix
is to implement WebGPU error handling where creation failure returns a
valid but "error" object.

However implementing this error handling is a lot of work, so in the
meantime we use nullptr checks in relevant places to fix the fuzzer
issue. These checks will be removed once the error handling is changed.

BUG=dawn:8

Change-Id: I6777a7fa40383b3d2235e071c3f0109de7605a22
Reviewed-on: https://dawn-review.googlesource.com/c/2565
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-10 10:03:08 +00:00
Jiawei Shao c789b84d8d Rename draw commands to match WebGPU IDL
BUG=dawn:51

Change-Id: I2a78f4e77c54aeae48d3fb78bf4701352ff40529
Reviewed-on: https://dawn-review.googlesource.com/c/3040
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2018-12-10 05:20:19 +00:00
Corentin Wallez 48a1923afb Revert "Create new src/tests BUILD.gn file."
This reverts commit 672d29d14c.

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

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

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

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

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

Bug: dawn:61
Change-Id: Id1e6d0c2b07caa2610cebe206511e972ac18fe8d
Reviewed-on: https://dawn-review.googlesource.com/c/3020
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2018-12-07 21:54:48 +00:00
Corentin Wallez 6f0e1f9d82 Remove BufferView and inline offset/size in BindGroup
BUG=dawn:2

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

Change-Id: I4d087d2b09b74e35ba7ea69533df2c5adef4ef82
Reviewed-on: https://dawn-review.googlesource.com/c/2943
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2018-12-06 19:01:22 +00:00
Kai Ninomiya bdd887fce7 Revert "Create new src/tests BUILD.gn file."
This reverts commit 0a7ddd43d7.

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

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

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

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

Bug: dawn:61

Change-Id: Icaa459270bdaa60306e053b93835812e70dba6f5
Reviewed-on: https://dawn-review.googlesource.com/c/2940
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
2018-12-05 22:42:23 +00:00
Corentin Wallez 6f9d21e805 Descriptorize BindGroups.
This commit adds utils::MakeBindGroup to make code craeting bind groups
nicer to read. Additional tests are added that give 100% coverage of
ValidateBindGroupDescriptor.

BUG=dawn:3

Change-Id: I56e1da8c2952306ad233845b0ec3ec32aef793d9
Reviewed-on: https://dawn-review.googlesource.com/c/2802
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-05 07:18:30 +00:00
Jiawei Shao 33af94fd8d Implement using a layer of a texture as color attachment - Part I
This patch implements using a layer of a texture as a color
attachment on D3D12, Metal and Vulkan.

This feature is not implemented on OpenGL back-ends in this patch.

BUG=dawn:16
TEST=dawn_unittests

Change-Id: Iffc194c6117f6e3e6506c6fcbfd51ca2fbe9ede8
Reviewed-on: https://dawn-review.googlesource.com/c/2660
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-12-05 03:22:04 +00:00
Austin Eng 66b024e499 Vulkan: Explicitly wait for all fences to complete on Device destruction
This ensures that all fences are complete. Flaky failures on Windows
showed some fence statuses were NOT_READY despite having been checked
after calling vkQueueWaitIdle.

Bug: dawn:60
Change-Id: Id4fa18c8842daf75faa9df6fcba8afdca43623c9
Reviewed-on: https://dawn-review.googlesource.com/c/2920
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2018-12-04 23:55:01 +00:00
Corentin Wallez f48e6b74b7 dawncpp.h: Add nullptr ObjectBase constructor and assignment
BUG=dawn:3

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

Bug: dawn:26
Change-Id: I81d5fee6acef402fe099227a034d9669a89ab6c3
Reviewed-on: https://dawn-review.googlesource.com/c/2460
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-12-03 16:57:34 +00:00
Stephen White d758e32610 Add some missing #includes.
MSC needs <string.h> for memcpy().

Change-Id: I1987ae29af32abe3d9e23a0a3cfd373aca22095d
Reviewed-on: https://dawn-review.googlesource.com/c/2820
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2018-12-03 14:28:04 +00:00
Corentin Wallez 85df07a1e5 Vulkan: Handle errors on device creation.
This is both something we should strive for for robustness of the
backends and in this case helped debug what the issue was on the
linux-dawn-rel builder that was failing all Vulkan tests.

BUG=dawn:19

Change-Id: Ibe9f5ad76b7766575bb74fe4993625cf82cdf13f
Reviewed-on: https://dawn-review.googlesource.com/c/2702
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-12-03 12:49:56 +00:00
Corentin Wallez 0f8b507888 Suppress tests failing on GPU FYI Mac Pro (AMD)
TBR=kainino@chromium.org
BUG=dawn:58

Change-Id: Ibd71a4a7cbc559b868ea8fd801d51ad4b3d7f6fd
Reviewed-on: https://dawn-review.googlesource.com/c/2803
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-03 12:22:06 +00:00
Corentin Wallez 9ca9435087 Rename BindGroupBinding -> BindGroupLayoutBinding
This makes the name match WebGPU's IDL

BUG=dawn:3

Change-Id: I1338fa07580ba8c0f6700b7765fb7389018a4126
Reviewed-on: https://dawn-review.googlesource.com/c/2801
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-12-03 09:58:09 +00:00
Austin Eng 8b07e43dad Let DeviceBase know about Completed and LastSubmitted command Serials
This is needed to implement the timeline fence signal tracker in the frontend

Bug: dawn:26
Change-Id: Id6eb2afb81385de5093b57c5cb23ace93c8aab1b
Reviewed-on: https://dawn-review.googlesource.com/c/2741
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2018-12-01 03:20:19 +00:00
Brandon Jones 179db44c25 Refactor Internal Command Buffer Copy APIs
Modify internal command buffer types to reflect the front end APIs for
copyTextureToBuffer and copyBufferToTexture.

Bug: dawn:17

Change-Id: I088a167ee7145d741e70ed28c1df7a12d24b72fc
Reviewed-on: https://dawn-review.googlesource.com/c/2740
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-11-30 17:39:24 +00:00
Corentin Wallez df72914a60 Result: Add default template for Result<T, E>
It currently is a tagged pair instead of a tagged union because it was
much easier to write and the optimization can come later.

BUG=dawn:19

Change-Id: Idbfd86d559655b38871c2d1768bdd758e797dfbd
Reviewed-on: https://dawn-review.googlesource.com/c/2701
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-11-29 12:40:26 +00:00
Li Hao 813bfbd061 Collect device information on Metal
Becuase CGDisplayIOServicePort is deprecated in OSX >= 10.9, we create
an alternative function which manually finding a service port with
matching vendor and product IDs.

BUG=dawn:10
TEST=dawn_end2end_tests

Change-Id: I94ff65911e159c2b7075209d8902c1551560ed47
Reviewed-on: https://dawn-review.googlesource.com/c/2541
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-11-29 10:54:03 +00:00
Brandon Jones ac71e34d4a Change Copy Operation Interfaces to Match WebGPU IDL
Cosmetic changes to copyBufferToTexture and copyTextureToBuffer to
match WebGPU IDL. Introduces BufferCopyView, TextureCopyView,
TextureAspect, and Origin3D types.

Bug: dawn:17
Change-Id: Ic0e7f472a9dc1353d3fc3839ff02f348bb6067e8
Reviewed-on: https://dawn-review.googlesource.com/c/2520
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-11-28 17:54:13 +00:00
Austin Eng e06d57d338 Factor SerialQueue into SerialQueue and SerialMap
This change moves most of SerialQueue into SerialStorage
and factors it to make SerialMap and SerialQueue. SerialMap
does not enforce that items are Enqueue'd in monotonically
increasing order. This is useful for implement timeline fences
because OnCompletion callbacks may be added in an arbitrary order.

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

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

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

Change-Id: If9a3c4857db43ca26a90abff2437e1cebb0ab79b
Reviewed-on: https://dawn-review.googlesource.com/c/2704
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-28 17:00:33 +00:00
Corentin Wallez 32abaffa73 Roll SPIRV-Tools and temporarily use Vulkan SPIRV validation
New additions to the validation for the WebGPU execution environment
broke all the tests that use shaders because tests don't produce valid
SPIR-V for WebGPU and also backends don't know how to lower
WebGPU-flavored SPIR-V to target languages.

Also rolls SPIRV-Headers to a version compatible with SPIRV-Tools

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

Change-Id: Icd9a199efc39cf143e38d64841eb4b122c9f54a9
Reviewed-on: https://dawn-review.googlesource.com/c/2706
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-28 16:54:31 +00:00
Corentin Wallez 596d6fe00d Result: Fix documentation and a typo
BUG=

Change-Id: I42425a1ee0a4e62a7c1e090878a9d61534eaf784
Reviewed-on: https://dawn-review.googlesource.com/c/2700
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-11-28 11:30:43 +00:00
Jiawei Shao cf714a81c8 Add checks on the texture view used as color or depth stencil attachment
This patch adds checks when we set a texture view as color or depth
stencil attachments:
1. The mipmap level of the texture view must be 1 as it is limited in
   D3D12, Metal and Vulkan.
2. The array layer count of the texture view must be 1 as currently we
   do not plan to support layered rendering in WebGPU.
3. The format of the texture view must be color renderable when it is
   used as a color attachment.
4. The format of the texture view must be a depth stencil format when it
   is used as a depth stencil attachment.

BUG=dawn:16
TEST=dawn_unittests

Change-Id: Ibce3bda20d49a725c26796aa627c5067532761ad
Reviewed-on: https://dawn-review.googlesource.com/c/2661
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-11-28 02:44:17 +00:00
Corentin Wallez 316243288c Suppress failing tests on Metal Intel.
Currently this suppresses them for all GPUs on Metal because
we there are no facilities to get the GPU vendor ID yet.

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

Change-Id: I8377016466da765a18f20ade5b277fa9cf1305c5
Reviewed-on: https://dawn-review.googlesource.com/c/2600
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-21 13:22:41 +00:00
Corentin Wallez a14a070de0 CommandBuffer/PassEncoders: Correctly validate we can record
BUG=

Change-Id: I2e2567942544d6c28ad5d948f5f7c5962790341e
Reviewed-on: https://dawn-review.googlesource.com/c/2564
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-11-21 11:19:36 +00:00
Corentin Wallez 3a5e765f23 BindGroupLayout: Fix off-by-one kMaxBindingsPerGroup validation
BUG=chromium:906370

Change-Id: I95659856398523931b8aacf1e9a9239ac85f1156
Reviewed-on: https://dawn-review.googlesource.com/c/2567
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Shaobo Yan <shaobo.yan@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-21 09:47:19 +00:00
Jiawei Shao ad3d9bafbc Fix missing validations and Vulkan flags on cube map texture views
This patch adds checks that we can only create cube map and cube
map array texture views on textures with width == height as is
required in Vulkan.

This patch enables the imageCubeArray feature on Vulkan back-ends
to ensure we can create cube map array image views on all Vulkan
back-ends.

This patch also adds a missing VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
flag when creating Vulkan images with arrayLayer >= 6. Without this
flag we cannot create cube map or cube map array views.

This patch fixes all the cube map end2end tests on Linux using
Vulkan back-ends.

BUG=dawn:16
TEST=dawn_end2end_tests

Change-Id: Id9386b9ee509d18a5ba8ae1ca085134486b242d7
Reviewed-on: https://dawn-review.googlesource.com/c/2522
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-11-21 01:00:20 +00:00
Corentin Wallez 63997221d7 Fix #include casing breaking linux->windows cross compilation
TBR=kainino@chromium.org
BUG=chromium:907093

Change-Id: I616f774e70871bf3e728178d8d41c18a488b6901
Reviewed-on: https://dawn-review.googlesource.com/c/2580
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-20 15:40:04 +00:00
Corentin Wallez ece004fd69 DawnWireAndFrontendFuzzer: skip SwapChainBuilderSetImplementation
SetImplementation takes a pointer and would be shimmed by browsers so we
skip the call in the fuzzer, otherwise we'd dereference arbitrary
pointers.

BUG=chromium:906391

Change-Id: I61d8d729d3fb242e8ddf7452a88a653e05a82cc2
Reviewed-on: https://dawn-review.googlesource.com/c/2562
Reviewed-by: Dan Sinclair <dsinclair@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-20 09:30:15 +00:00
Corentin Wallez c1bb72c5d2 DawnWireAndFrontendFuzzer: don't leak the device.
The dawn::Device(dawnDevice) constructor was adding a reference which
caused the device to leak. Fix this by using dawn::Device::Acquire
instead.

BUG=chromium:904734

Change-Id: Id641459f9285c9da51a0d2a1f88126197bfd79a5
Reviewed-on: https://dawn-review.googlesource.com/c/2561
Reviewed-by: Dan Sinclair <dsinclair@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-20 09:14:40 +00:00
Ryan Harrison fbeca676d4 Tighten when signal trap is used in SPIRV-Cross fuzzers
Due the jump within the signal trap used in these fuzzers, local scope
allocations cannot occur while the signal trap is on, otherwise there
is a possibility of leaks. This CL rewrites how the code under test is
run, so that the potentially aborting code is tightly wrapped by
signal trap without any local scope allocations.

BUG=chromium:906416

Change-Id: Ie52647433dcac57e3ea065d5bdcb6e14c5929494
Reviewed-on: https://dawn-review.googlesource.com/c/2521
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-11-19 19:20:08 +00:00
Jiawei Shao 5ab84ec0a6 Support cube map and cube map array
This patch implements cube map and cube map array texture views on
all back-ends and adds related end2end tests.

BUG=dawn:16
TEST=dawn_end2end_tests

Change-Id: I3ac3f493eb92ac551371041039bd5cf39df53050
Reviewed-on: https://dawn-review.googlesource.com/c/2220
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-11-16 12:11:20 +00:00
Corentin Wallez 2ec59d9fcc Don't use shared libraries in the wire fuzzer.
Otherwise UBSan complains that C++ types are different between the
shared libraries because libc++ is linked statically.

BUG=chromium:904736

Change-Id: I51ef40d1f7910fd693a4585c74ff404812472d2e
Reviewed-on: https://dawn-review.googlesource.com/c/2380
Reviewed-by: Dan Sinclair <dsinclair@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-14 21:04:26 +00:00
Ryan Harrison 499bc0318d Set correct ASAN flags for SPIRV-cross fuzzers
These fuzzers currently depend on being able to change the signal
handler at runtime, but the default flags being used forbid this. This
CL overrides the upstream default to allow changing the handler.

BUG=chromium:904725,chromium:904712

Change-Id: I68423564981b7f2e39f7c00744b92da982cf19e9
Reviewed-on: https://dawn-review.googlesource.com/c/2361
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Max Moroz <mmoroz@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-11-14 21:04:16 +00:00
Corentin Wallez 597e1587b4 Build fuzzer tests in standalone builds too.
This will avoid compilation to break, and adds standalone reproducers
for the fuzzer_tests.

BUG=chromium:903380
BUG=dawn:34

Change-Id: I9995a852076d9f6d1ebdee5b999989c2d74d4709
Reviewed-on: https://dawn-review.googlesource.com/c/2321
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@google.com>
2018-11-12 18:09:56 +00:00
Corentin Wallez 45ee4c88c4 Add a fuzzer for the wire server and Dawn frontend
BUG=dawn:34

Change-Id: Ia82b52276c91ed3bd1a246548115e75ba0ede7f2
Reviewed-on: https://dawn-review.googlesource.com/c/2302
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-12 18:04:55 +00:00
Ryan Harrison 9854295ff6 Add fuzzers for SPIRV-Cross
This CL adds in fuzzers for SPIRV-Cross for HLSL, GLSL, and MSL
outputs. These fuzzers live in Dawn because there is not appropriate
location in the Chromium source repo for them and it is unlikely they
would be land-able in the SPIRV-Cross repo, because it is not coupled
with Chromium's build system and thus Clusterfuzz so would be
effectively dead code. Dawn depends on this code, but it is also
integrated into the Chromium build system, so this was the best place
I could find for them

The code under fuzz unfortunately uses exceptions/aborting as its
error reporting mechanism. This is an acknowledge short coming and
there are efforts to remove this behaviour. To work around this and
reduce the number of false positives found by the fuzzers, a signal
trap has been implemented which will be removed once the code under
fuzz has been updated.

The trap replaces the existing signal handler and silencing signals
while running the code under test. This allows the code under test to
call abort() and not crash the fuzzing process. Theoretically, only
SIGABRT should need to be trapped, but something is causing the signal
from abort() to be converted to SIGSEGV when running under ASAN.

This signal trap has been tested with the fuzzing/sanitizers by
intentionally inserting bad calls that will occur after a few thousand
test cases. It was confirmed that the fuzzer detected the issue and
stops fuzzing.

The alternate to implementing this signal trap would be to turn on
exceptions for the fuzzer. This was attempted, but proved to be
fruitless due to what was reported as an ODR issue, but couldn't
couldn't be silenced. The likely underlying issue was a pre-built
library or other object being built without exceptions was causing
different versions of symbols or the exception version of the standard
library not being instrumented by ASAN. Given the majority of Chromium
eco-system turns off exceptions, fixing this issue would not be
helpful to the larger community and was looking like it would require
significant effort.

BUG=chromium:903380

Change-Id: I63a5595383f99b7a0e150d72bb04c89b8d722631
Reviewed-on: https://dawn-review.googlesource.com/c/2260
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Max Moroz <mmoroz@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-11-12 12:20:21 +00:00
Corentin Wallez 6f86f176a9 Suppress tests failing on D3D12
BUG=chromium:901830
TBR=kainino@chromium.org

Change-Id: Ic70a9257433445eca6ac1fd650efdd51fcbe6174
Reviewed-on: https://dawn-review.googlesource.com/c/2280
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-12 09:04:58 +00:00
Jiawei Shao 284f334398 Skip BindGroupTests.ReusedUBO and UBOSamplerAndTexture on Metal
BindGroupTests.ReusedUBO and BindGroupTests.UBOSamplerAndTexture fail on
Metal so we have to skip them temporarily.

BUG=dawn:33

Change-Id: I2875dab6d856eb207ee5b785ddf160df2cb9fd5b
Reviewed-on: https://dawn-review.googlesource.com/c/2240
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-11-09 00:48:43 +00:00
Corentin Wallez 679ff4ea86 Validate that mapped buffers aren't used in submits.
Likewise "presented" textures won't be available for use in submits so
this sets up state-tracking and validation for textures too.

Command buffer resource usage is now stored in the frontend instead of
done per-backend because it is used to validate resources are allowed in
the submits.

Also adds a test.

BUG=dawn:9

Change-Id: I0537c5113bb33a089509b4f2af4ddf4eff8051ea
Reviewed-on: https://dawn-review.googlesource.com/c/2142
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-07 10:02:43 +00:00
Corentin Wallez b04c728d54 Add tests for pass resource usage validation
BUG=dawn:9

Change-Id: I0ac62730bfe9ec521fa6da081ca50977c9fe4432
Reviewed-on: https://dawn-review.googlesource.com/c/2141
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-07 09:59:43 +00:00
Jiawei Shao db3b893675 Add entry points for creating a cube map/cube map array texture view
This patch adds the entry points for creating cube map and cube map
array texture views. This patch also adds validations that the array
layer in the texture view descriptor must be 6 when the texture view
dimension is cube map, and a multiple of 6 when the texture view
dimension is cube map array.

BUG=dawn:16
TEST=dawn_unittests

Change-Id: I86a66c3753a7678351f65b43f6cd54b96d1b762c
Reviewed-on: https://dawn-review.googlesource.com/c/2200
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-11-07 09:52:33 +00:00
Stephen White 6686fc8245 MSC build fix.
MSC doesn't like the use of sizeof(member) inside the same struct.
So hardcode the padding, and assert that the offset is 256.

Change-Id: I78bbca6871cf8227c90d00a03ccf8e3d955b7d21
Reviewed-on: https://dawn-review.googlesource.com/c/2160
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2018-11-04 00:53:18 +00:00
Corentin Wallez 2960ec3366 Add support for all of Chromium's CPU architectures.
BUG=chromium:870747

Change-Id: I421819871f5c45ac07850585e5dcc600d1ff8086
Reviewed-on: https://dawn-review.googlesource.com/c/2140
Reviewed-by: Stephen White <senorblanco@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-11-01 14:30:24 +00:00
Stephen White 4408b7f20c D3D12 fix for register binding offsets.
When both the vert and frag shaders have a UBO binding, the D3D12
backend was using register offset 0 for both, causing a collision,
and the wrong constant value used in one of the shaders.

The fix is to use the binding offsets computed by the BindGroupLayout,
since they know about all of the bindings, not just the ones computed
for each shader. This made it necessary to defer shader compilation
until pipeline layout creation time (as is done in the Metal backend
for similar reasons).

Finally, those bindings offsets computed by the BGL include an offset
for the CBV, UAV and SRV subgroups, so we must add the same register
offset when assigning the BaseShaderRegister to the descriptor ranges
in the PipelineLayout constructor so that they match.

Bug: dawn:20

Change-Id: I18287bf1c06f06dd61288e12da64752f54634466
Reviewed-on: https://dawn-review.googlesource.com/c/1960
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2018-11-01 13:59:19 +00:00
Corentin Wallez 146edf5bec Remove support for CMake builds
This also removes support for Travis and AppVeyor, as well as git
submodules for dependencies.

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

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

BUG=

Change-Id: I4ebc04e530a574b412ef0ca81e4672db01f0ed92
Reviewed-on: https://dawn-review.googlesource.com/c/2040
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-10-31 10:53:11 +00:00
Jiawei Shao 84cde51741 Rename mipLevel to levelCount in TextureDescriptor
This patch renames the field "mipLevel" of TextureDescriptor to
"levelCount" to align with the WebGPU idl.

BUG=dawn:16

Change-Id: I36b30d78831786e4c21ffd641f820375e95a1be5
Reviewed-on: https://dawn-review.googlesource.com/c/2100
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-10-31 10:51:11 +00:00
Yunchao He be948aa8e0 Initialize BlendDescriptor with default values.
BUG=dawn:32
TEST=dawn_end2end_tests

Change-Id: Ic5ae03e06e3cc620d0fefd3858206276c3fe9980
Reviewed-on: https://dawn-review.googlesource.com/c/2061
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-10-30 10:03:47 +00:00
Jiawei Shao c72ab8ce84 Support creating texture view with descriptor on OpenGL version >= 4.3
This patch implements creating texture view with texture view descriptor
with glTextureView, which is supported on OpenGL version >= 4.3. As is
required by glTextureView, we allocate storage for a texture by
glTexStorage*D instead of glTexImage*D.

BUG=dawn:16
TEST=dawn_end2end_tests

Change-Id: I29bcf6d538a70b4d6d1e5a21276b9e8d6e93ca51
Reviewed-on: https://dawn-review.googlesource.com/c/1980
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-10-29 09:07:25 +00:00
Yunchao He c35103dc19 Use blend descriptor to replace a blend struct.
Bug=dawn:32

Change-Id: I74db6c1e9cf57a168967131ea2c9e1d802853ab4
Reviewed-on: https://dawn-review.googlesource.com/c/2020
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-10-29 09:06:55 +00:00
Stephen White 3f06587542 Fix D3D12 Buffer::UnmapImpl() for MapWriteAsync().
d3d12::Buffer::UnmapImpl() was passing an empty range to
ID3D12Resource::Unmap().  This causes it to be a no-op when writing a
buffer.  The fix is to store the entire mapped range in the Buffer,
and use it during Unmap().

Note: this doesn't seem to actually cause an issue on the D3D12 drivers I
have, so I have been unable to write a test for it. However, it does cause
an issue in RenderDoc: the buffer data appears unmodifed after the
Map/memcpy/Unmap calls. The hypothesis is that RenderDoc notices the empty
range at the API level, and leaves its shadow buffer contents unmodified.

Because I feel this change is correct regardless, I'm landing it without
a test.

Bug: dawn:25
Change-Id: Ie5dd5fcfedbe1d80c75a3d8094c97af27653ee00
Reviewed-on: https://dawn-review.googlesource.com/c/1920
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2018-10-26 11:49:12 +00:00
Jiawei Shao e8d12b44b6 Create texture view with descriptor on D3D12 and Metal - Part I
This patch is the first part to implement creating a texture view
with a texture view descriptor on D3D12 and Metal back-ends. With
this patch the texture views created with descriptor can be bound
as sampledTextures on D3D12 and Metal back-ends.

Note that the support of rendering into a layer or a mipmap level of
a texture on D3D12 and Metal back-ends is not included in this patch.

BUG=dawn:16
TEST=dawn_end2end_tests

Change-Id: I62473ec5a4bb6b84d797ef7fd9cb98689ff763f4
Reviewed-on: https://dawn-review.googlesource.com/c/1940
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-10-26 06:29:38 +00:00
Corentin Wallez aa7109c148 Add copy constructors to the C++ Dawn interface
This removes the need for Clone() so it is removed and also adds tests
for the new constructors.

BUG=dawn:11

Change-Id: Ia45c765c2d30e40b0e036427793a62327b2008fc
Reviewed-on: https://dawn-review.googlesource.com/c/1901
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-10-25 10:42:49 +00:00
Jiawei Shao f9d217b0e9 Implement creating texture view with descriptor on Vulkan
This patch implements creating a texture view with given texture
view descriptor on Vulkan back-ends.

This patch also updates TextureViewTests to test various mipmap
levels and adds several tests to cover all added features.

BUG=dawn:16
TEST=dawn_end2end_tests

Change-Id: I602e5a076e4f717f555cb9a9ef98d5dfceadbe81
Reviewed-on: https://dawn-review.googlesource.com/c/1880
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-10-23 11:08:20 +00:00
Jiawei Shao aef480bcfe Implement CreateDefaultTextureView by CreateTextureView
This patch removes CreateDefaultTextureView in all the back-ends of
class Device and implements this function by CreateTextureView using
a TextureViewDescriptor created from the original texture.

Note that this patch only refactors the original implementation of
creating default texture. The support of creating texture views from
a texture view descriptor will be added in the next several patches.

BUG=dawn:16

Change-Id: Iadfc1e17e1cf23a4c1fa8ff44b1fb1a765d21e3f
Reviewed-on: https://dawn-review.googlesource.com/c/1840
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2018-10-18 06:00:09 +00:00
Corentin Wallez 79aee9c56d Suppress test failure on Vulkan
BUG=dawn:16

Change-Id: I8d0ae82d379ff092e1d585f2b69dd6226aa55c39
Reviewed-on: https://dawn-review.googlesource.com/c/1820
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-10-16 09:16:15 +00:00
Corentin Wallez 9e4518b57e Put the reference to DeviceBase in a new ObjectBase
ObjectBase will contain data that all WebGPU objects have such as a
pointer back to the device, a refcount (via inheriting from RefCounted),
a name, an error status etc.

BUG=dawn:24

Change-Id: I919e1a6d4a68811ceb6e503b2a793815c92f2528
Reviewed-on: https://dawn-review.googlesource.com/c/1620
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-10-15 12:54:30 +00:00
Jiawei Shao 6329e5ad47 Add entry point of creating texture view by TextureViewDescriptor
This patch adds the entry point creating texture view with a
TextureViewDescriptor and all the validations on the parameters
according to https://github.com/gpuweb/gpuweb/issues/79.

BUG=dawn:16
TEST=dawn_unittests

Change-Id: Ibc04a0f7b9f334c57da191606313ab156e18af1f
Reviewed-on: https://dawn-review.googlesource.com/c/1800
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-10-12 08:32:58 +00:00
Jiawei Shao c35be1a4dd Support creating default texture view on 2D array textures
This patch intends to implement creating default texture view on
2D array textures.

BUG=dawn:16

Change-Id: I4321c9506b2e875146645ad60291196dcfcc8ea0
Reviewed-on: https://dawn-review.googlesource.com/c/1660
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2018-10-09 00:31:58 +00:00
Stephen White d380fdda08 Fix for D3D12 re-used bindgroup bug.
If a bindgroup was re-used in multiple command buffers in a single call
to queue.Submit(), it was skipping the creation of the corresponding
descriptor heap for that bind group in the second command buffer.

The fix is to use the command buffer's index into the submit command as
part of the key for the bind group's descriptor heap.

Change-Id: Ie66a0e772b10cc72bf040f090dac4c4a10f24266
Reviewed-on: https://dawn-review.googlesource.com/c/1740
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2018-10-04 16:59:05 +00:00
Corentin Wallez 386b8889bd Wire: Add support for nullptr objects as arguments
BUG=dawn:5

Change-Id: I84c80796e9bdfbcf59fafdd38d33ab2101a1d795
Reviewed-on: https://dawn-review.googlesource.com/1541
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-09-21 00:28:33 +00:00
Corentin Wallez 82fbccbd78 Introduce [Render|Compute]PassEncoder.
This splits off part of CommandBufferBuilder in separate
RenderPassEncoder and ComputePassEncoder objects. To match the WebGPU
IDL and factor some code, both these encoders inherit from
ProgrammablePassEncoder.

These encoders are pure frontend objects and record into the
CommandBufferBuilder command allocator objects, so no changes to the
backends were needed.

Error handling is still ew, because the "builder" mechanism we had
doesn't allow for "split builders". Nicer error handling will have to
wait on Dawn matching WebGPU.

All the tests and samples were updated to the new structure.

BUG=dawn:5

Change-Id: I5f5d4ad866e2c07fedd1ba7a122258c6610941f1
Reviewed-on: https://dawn-review.googlesource.com/1543
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-09-21 00:24:37 +00:00
Jiawei Shao 58809d413b Collect GPU device information for end2end tests - Part I
This patch is the first one to support inspecting GPU information for
dawn_end2end_tests.

In this patch, we support collecting the device name, device id and
vendor id on D3D12 and Vulkan. We also support collecting the device
name on OpenGL. The collection on Metal will be supported in the next
patch. Using this information we implement a series of APIs to inspect
the information of both OS and GPU vendor.

We also skip two failed tests on Windows Intel Vulkan backends.

BUG=dawn:10

Change-Id: If52a960c0bae3922a0b5650500218eff1400d77a
Reviewed-on: https://dawn-review.googlesource.com/1460
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2018-09-19 00:32:52 +00:00
Corentin Wallez cd5e5756fd TextureBase: return size as an Extent3D to match dawn.json
BUG=dawn:13

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

BUG=dawn:13

Change-Id: Ibd5ea1340338e5aa16069499c498ac5a455fc2cd
Reviewed-on: https://dawn-review.googlesource.com/1500
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2018-09-18 12:49:22 +00:00
Jiawei Shao 3d670506e3 Remove TextureViewBuilder and add CreateDefaultTextureView entry point
This patch is the first one to descriptorze texture view. In this
patch, we completely remove TextureViewBuilder and add the entry
point CreateDefaultTextureView for creating a texture view on a
non-array 2D texture using the same type and format.

Texture view descriptors and 2D array texture views will be supported
in the next patch.

BUG=dawn:1, dawn:16

Change-Id: Ibd2a0bcf02cbb567a98d2faaaaa897eff2c062e5
Reviewed-on: https://dawn-review.googlesource.com/1440
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
2018-09-18 00:31:57 +00:00
Corentin Wallez 03e1813fd2 Add DAWN_UNUSED_FUNC to ignore unused functions in generated code
BUG=dawn:13

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

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

Change-Id: Icbce16b0c8d8eb084b0af2fc132acee776909a36
2018-09-11 07:55:27 -04:00
Corentin Wallez cca9c698a0 Use unique_ptr where applicable.
Change-Id: Icb29f6f9760f0ea36528e8ea6890713c2fb3b965
2018-09-07 07:22:04 -04:00
Corentin Wallez 21d8438ad6 Validate SPIR-V code when creating ShaderModules
This integrates spirv-val in dawn_native so that regular and
WebGPU-specific validation of shaders is done.

Also adds tests to check OpUndef is correctly rejected so we know
WebGPU-specific validation is working.

Change-Id: If49d276c98bca8cd3c6c1a420903fe34923a2942
2018-09-07 05:41:25 -04:00
Corentin Wallez 8e335a5585 Descriptorize ComputePipeline
Change-Id: Ic9d7014ba44d927d7f9ddf81a8870432c68941e8
2018-09-05 08:32:53 -04:00
Corentin Wallez eb7d64a17f D3D12: Destroy all COM objects before the DLLs are unloaded
Change-Id: I00109460fa83110bd9af6d6b8ff2b5022ed580f3
2018-09-05 08:32:53 -04:00
Corentin Wallez 98ca29b582 Fix VkNonDispatchableHandle alignment on Linux x86
There alignof(uint64_t) is 8 but it is aligned to 4 inside structures.

Change-Id: Ia94e9e5c962e9f5898a8f39977b83a9e10cbf454
2018-09-05 08:01:24 -04:00
Li Hao 3cc58af801 Update reason for hiding vktrace layer 2018-09-03 05:45:37 -04:00
Li Hao 92bddc47c9 Vulkan: add macro for vktrace
Hide vktrace layout behide a marco 'DAWN_USE_VKTRACE' and enable it in
build if need.
2018-09-03 05:45:37 -04:00
Jiawei Shao 9daa4ad1c8 Fix the barrier in vulkan::Texture::TransitionUsageNow to make the
barrier cover all the slices in a 2D array texture.
2018-09-03 05:43:49 -04:00
Jiawei Shao 4ccf4e3fdd Support 2D array texture copying on D3D12, Metal and OpenGL
This patch implements the creation of 2D array textures and copying
between a buffer and a layer of a 2D array texture on D3D12, Metal
and OpenGL back-ends.

TEST=dawn_end2end_tests
2018-09-03 05:43:49 -04:00
Corentin Wallez d8597b2e1f D3D12: Dynamically load D3D12, DXGI and D3DCompiler
Linking against their .lib makes loading Dawn fail on systems that don't
have the DLLs. This happens for example on Windows7 that doesn't have
d3d12.dll. Instead we dynamically load functions pointers from these
DLLs at d3d12::Device startup.

Change-Id: I4d01a12d0f91bec45bf125450d2c08aaa9ff9fac
2018-08-31 09:13:35 -04:00
Jiawei Shao 748a5d5b28 Implement DAWN_SKIP_TEST_IF for dawn_end2end_tests
This patch implements a micro DAWN_SKIP_TEST_IF in DawnTest.h which
can be used to skip running a test in dawn_end2end_tests when the
given condition is satisfied.
2018-08-31 03:29:11 -04:00
Jiawei Shao 4b74dbef7b Implement copying between a buffer and a texture 2D array on Vulkan (#257)
Implement copying between a buffer and a texture 2D array on Vulkan

This patch implements the creation of a 2D array texture and data
copying between a buffer and a layer of a 2D array texture on
Vulkan back-ends.

TEST=dawn_end2end_tests
2018-08-30 04:27:38 -04:00
Jiawei Shao 425428f97b Descriptorize Texture
This patch introduces texture descriptor for texture creation instead
of texture builders.

This patch also adds "arrayLayer" to texture descriptor and removes
mDevice in TextureD3D12.
2018-08-28 03:00:48 -04:00
Stephen White 75559bf1be
Change WIN32 to _WIN32. (#260)
WIN32 is defined by the SDK, but _WIN32 is defined by the compiler.
Since Dawn doesn't necessarily include <windows.h> everywhere dawn.h is
included, we should use _WIN32 (which will always be defined).
2018-08-27 10:13:34 -04:00
Corentin Wallez 0fa2feb96a Roll SPIRV-Cross and use upstream repo.
In the DEPS file we are going to use Chromium's mirror of
github.com/KhronosGroup/SPIRV-Cross so we need to adjust .gitmodules to
point to it instead of Kangz/SPIRV-Cross. Also take that opportunity to
roll SPIRV-Cross.

Change-Id: I4f53a4fc54f5b1b9a754ac55e976c81e5eeabeb2
2018-08-24 12:28:28 -04:00
Corentin Wallez d90748b256 Fix VkNonDispatchableHandle's alignment on 32bit platforms
On 32bit platforms, even if it contains a uint64_t the handle wrapper
will align to 4 bytes because the assembly load operations can't take
advantage of 64bit aligned loads.

Fix this by forcing the alignment to the alignment of what would be the
native Vulkan handle type.

Also use macros with defined()

Change-Id: I0de9b4a77e648c416b04311b854c956762248868
2018-08-24 05:47:57 -04:00
Corentin Wallez 82b6573d54 Descriptorize Buffer
We still keep a dummy BufferBuilder object around so that it can be used
for the builder error callback tests of the wire.

Change-Id: If0c502bb8b62ee3ed61815e34e9b6ee6c03a65ef
2018-08-23 08:23:06 -04:00
Corentin Wallez 0202250464 Check ShaderModuleDescriptor->nextInChain
Change-Id: Iffa7485b3a2dc43911c86ac614e7d99d737aaf6f
2018-08-23 08:23:06 -04:00
Corentin Wallez 62c774391b Rename GetAllowedUsage to GetUsage.
Resources used to have both a current and an allowed usage but the
concept of current usage has been removed so we can rename "allowed
usage" to "usage" to make the name match WebGPU's
WebGPUBufferDescriptor::usage and WebGPUTextureDescriptor::usage

Change-Id: I5190950bf7f7f5b86c92247ef0240fead9886268
2018-08-23 08:23:06 -04:00
Corentin Wallez 5800712897 Workaround a _GLIBCXX_DEBUG bug for std::hash<std::bitset>
This fixes the GN debug build on Linux.

Change-Id: I847a8c67eda1f9069477de0af910f0cd520ccc2c
2018-08-21 02:28:16 -04:00
Corentin Wallez f35eff3fde Remove BindGroupBuilder::SetUsage
BindGroup usage isn't something that's part of WebGPU's sketch.idl and
it might never exist. Remove it to simplify the migration of bindgroup
to descriptor.

Change-Id: I21e0a98eb60434d4009e748cd9afcbf89edd7e6a
2018-08-21 02:27:12 -04:00
Corentin Wallez df6710358b Descriptorize ShaderModule
Change-Id: Ic79d00380f583485de0fb05bd47b1f869919ebe6
2018-08-21 02:26:24 -04:00
Jiawei Shao 94c92fa5e7 Enable RenderPassLoadOpTests on Vulkan back-ends
RenderPassLoadOpTests can pass on Vulkan back-ends now.
2018-08-17 09:53:15 +02:00
Corentin Wallez 5b61abce09 Fix Windows compilation using GN and clang-cl.
This includes a bunch of fixes for clang warnings in Windows specific
code that was only compiled by MSVC previously. This also tidies up some
BUILD.gn issues on Windows.
2018-08-14 21:42:32 +02:00
Corentin Wallez d2969a7d3d Make Dawn "gn check" by default (except SPIRV-Tools)
This required adding some missing dependencies, splitting public headers
of libdawn_[native|wire] so they aren't hidden in the
libdawn_[native|wire]_sources targets, and making unittests depend on
sources directly instead of static libraries (which is almost equivalent).

As a byproduct, Empty.cpp is no longer needed and is removed.
2018-08-14 14:33:19 +02:00
Corentin Wallez c978fe8d15 Fix D3D12Binding crach after the GetProc refactor 2018-08-09 20:54:43 +02:00
Corentin Wallez de4dbc3cf7 Fix VulkanBindings crash 2018-08-06 21:39:17 +02:00
Corentin Wallez e046e6b2ab Fix -Wsign-compare warnings in unittests 2018-08-06 21:39:17 +02:00
Corentin Wallez 21a23857dc Add initial BUILD.gn files for libdawn[|_native|_wire] 2018-08-06 16:38:33 +02:00
Corentin Wallez dcb71a131c dawn_native: Factor getting procs into a single function.
Now the backends only expose the creation of devices. Getting the procs
is moved to DawnNative that will over time more backend-agnostic APIs.
2018-08-06 16:38:33 +02:00
Corentin Wallez fe253f135b Generate a single ProcTable instead of one per backend.
This required putting Queue::Submit on QueueBase which is something we
would want to do anyway, and removes the need for Queue::ValidateSubmit
being called in the ProcTable.

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

Finally this was done in order to simplify the writing of BUILD.gn
files.
2018-08-02 13:39:07 +02:00
Corentin Wallez 1ac25e850a Fix the utils copy of glad not being initialized 2018-08-02 13:39:07 +02:00
Corentin Wallez 1a796039d9 Make shared library dependencies private.
By default CMake makes dependencies public, which is not what we want
for libdawn, libdawn_native and libdawn_wire
2018-07-30 17:22:45 +02:00
Corentin Wallez bdc867713a Make dawn_wire a shared library
Also moves the TerribleCommandBuffer to utils:: because it isn't part of
the implementation of the wire, renames dawn::wire to dawn_wire, moves
src/wire to src/dawn_wire and puts the interface of dawn_wire in
src/include/dawn_wire.
2018-07-30 17:22:45 +02:00
Corentin Wallez 012c149fd9 Build with nortti/exceptions and fvisibility=hidden
This both makes the CMake build closer to the Chromium build, and
reduces the binary size heavily.
2018-07-30 17:22:45 +02:00
Corentin Wallez 196ade667f Make libdawn_native a shared library.
The interface exposed by libdawn_native is declared in the new headers
living in src/include/dawn_native so that they both the users and the
libraries use the DAWN_NATIVE_EXPORT macros.
2018-07-27 12:56:26 +02:00
Corentin Wallez 36afbb6a0d Make dawn_native use its own header for Dawn datatypes
The dawn.h and dawncpp.h structure definitions references dawnFoo or
dawn::Foo respectively when it should reference dawn_native::FooBase* in
dawn_native. Autogenerate files to declare the dawn_native version of
the structs and change the ProcTable generation to use it instead.

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

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

Also has a small fix for setting compile flags only for C++ files.
2018-07-25 21:03:49 +02:00
Corentin Wallez 49a65d0c0c dawn_native: Fixup namespace from backend:: to dawn_native:: 2018-07-25 11:27:55 +02:00
Corentin Wallez 30965a7729 dawn_native: Fixup header guards from BACKEND_ to DAWNNATIVE_ 2018-07-25 11:27:55 +02:00
Corentin Wallez d37523fbde Move src/backend to src/dawn_native 2018-07-25 11:27:55 +02:00
Corentin Wallez 7914958034 BufferBase: Split validation in helper methods 2018-07-20 21:37:44 +02:00
Corentin Wallez 1ea205fb12 CommandBuffer: have a state tracker per-pass
Also perform small code simplifications of the CommandBufferStateTracker
now that it only tracks aspects.
2018-07-20 21:37:34 +02:00
Stephen White 1184e46f87
Fix bind group binding ID validation. (#227)
* Fix bind group binding ID validation.

Use the binding, not the iterator index.
2018-07-19 09:52:31 -04:00
Corentin Wallez 6ed9cbf894 Rename last references of NXT to Dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez 9fc65344f4 Rename NXT -> Dawn in the comments 2018-07-18 22:54:06 +02:00
Corentin Wallez 923574eed5 Rename IsNXTBitMask and NxtReference/Release to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez a5ee52d33e Rename NXT -> DAWN in header guards 2018-07-18 22:54:06 +02:00
Corentin Wallez 0927ea549c Rename // NXT API to // Dawn API 2018-07-18 22:54:06 +02:00
Corentin Wallez a4da03249c Rename NXTTest to DawnTest
Also formats the whole file for the first time.
2018-07-18 22:54:06 +02:00
Corentin Wallez ae187efc80 Rename NXT_INSTANTIATE_TEST to DAWN_INSTANTIATE_TEST 2018-07-18 22:54:06 +02:00
Corentin Wallez be5ca38351 Rename nxtProcTable and nxtSetProcs to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez b1669e3fa4 Change the API prefix in generators from nxt to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez ae79c03d45 Rename the nxt namespace to dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez 05c90ee4cb Rename nxt -> dawn for dawn_wsi.h declarations
Also does the initial complete formatting of files in src/include
2018-07-18 22:54:06 +02:00
Corentin Wallez 3e371b146d Rename files in src/include nxt -> dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez 046cb46bee Rename generated files nxt -> dawn 2018-07-18 22:54:06 +02:00
Corentin Wallez fde3f2b5e0 Rename NXT -> Dawn in the rest of CMakeLists 2018-07-18 22:54:06 +02:00
Corentin Wallez f684040e0a Rename NXTHelpers to DawnHelpers 2018-07-18 22:54:06 +02:00