Commit Graph

118 Commits

Author SHA1 Message Date
Austin Eng 72724b8d25 Add wire tests and mocks for the MemoryTransferService
This CL tests integration of the MemoryTransferService with buffer mapping.
It tests the basic success and error cases for buffer mapping, and it tests
mocked failures of each fallible MemoryTransferService method that an embedder
could implement.

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

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

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

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

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

Also some DeviceBase pointers were made const for validation.

BUG=dawn:128

Change-Id: I37d1e9c739b87cddcea09cb1759e175704d90f9e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9101
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-18 09:25:04 +00:00
David 'Digit' Turner 56a21a6151 Make GN //src/common target easier to use when Vulkan is enabled.
Ensure that //src/common exports the appropriate config settings
when vulkan is enabled. This CL tries to address several issues
at once:

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

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

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

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

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

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

Change-Id: I2030c1e209a8186c141d4c06a0d52fb21695bb51
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8962
Commit-Queue: David Turner <digit@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-07-17 08:54:18 +00:00
Yunchao He d6f13c645b Implement RenderPassEncoder::SetViewport: add end2end tests
The main aim of this CL is to add tests for SetViewport. But it
also implements the feature on Vulkan backend to verify the tests.

BUG=dawn:53
TEST=dawn_end2end_tests

Change-Id: I9578b2d9650cb952ce67cf91f79e9682c9932ee3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8820
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
2019-07-16 19:27:09 +00:00
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
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
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 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
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
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
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
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
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 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
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
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
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
Austin Eng f3f5bf480d Remove glTFViewer from samples
Bug: dawn:152
Change-Id: I5bd36f4ae56889bf12652f8a201a7f7be5e2d25d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7360
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-05-18 03:14:46 +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
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
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
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
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 cb2c64f7d9 Nuke Builders Part 2: remove all builder code from wire
This removes blocks of code that were obviously builder-specific but
also removes the ObjectStorage::valid member that was used to implement
the maybe monad on the wire server side. This is no longer needed since
dawn_native handles the maybe monad internally now.

BUG=dawn:125

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

BUG=dawn:125

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

BUG=dawn:61

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

BUG=dawn:61

Change-Id: I767f6c97c06ee73290d3df482880d1a2df92e187
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5301
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-03-06 23:17:39 +00:00
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
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
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 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 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