Commit Graph

144 Commits

Author SHA1 Message Date
Corentin Wallez fad96f6e59 BUILD.gn: Only expose the GLFW target on platforms that support it
Due to the way GN target discovery works, glfw would get discovered in
Fuchsia / Android / ChromeOS builds when it isn't supported causing
compilation failures. This changes third_party/BUILD.gn so that glfw
targets are only created on supported platforms. It also changes
dawn_glfw in BUILD.gn to be more robust to building on all platforms.

Bug=dawn:221
BUG=chromium:1002895

Change-Id: I8f40b06f680094406d24e9a6dea44b128e59b854
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11160
Reviewed-by: David Turner <digit@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-09-11 16:53:46 +00:00
Austin Eng f35dcfe60a Implement ErrorScopes for synchronous errors
This patch implements Push/PopErrorScope except for asynchronous
or GPU commands. These commands, such as Queue::Submit will need
to hold onto the ErrorScope until GPU execution is complete.

Bug: dawn:153
Change-Id: I2d340b8b391d117a59497f35690993a9cd7503e6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10700
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-09-10 23:19:11 +00:00
David 'Digit' Turner fa00c69506 [fuchsia] Implement external semaphore and memory support.
This CL adds Fuchsia-specific implementations to the following
classes:

  dawn_native::vulkan::external_memory::Service
  dawn_native::vulkan::external_semaphore::Service

The implementation is based on two Fuchsia Vulkan extensions
that are provides by the vulkan_fuchsia_extras.h header (i.e.
are not upstreamed to Khronos yet, but used/provided by the
Fuchsia platform):

  VK_FUCHSIA_external_memory
  VK_FUCHSIA_external_semaphore

Their details are similar to VK_KHR_external_XXXX_fd, but
uses Zircon handles instead of file decriptors.

BUG=dawn:221
Change-Id: I48238bcf3193433970cbe200a84b86a67103a2f2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10963
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: David Turner <digit@google.com>
2019-09-10 10:07:28 +00:00
David 'Digit' Turner b749d07ac9 Enable Vulkan for Chromium Fuchsia build.
Enable the Vulkan backend when building Dawn with
the Chromium build system for Fuchsia. To make this
work properly the following is required:

- Modify VulkanInfo.cpp and BackendVk.cpp to correctly probe
  the Fuchsia swapchain layer and its layer extension, as well
  as enabling them when creating a new VkInstance.

- Modify VulkanFunctions.cpp to load the Fuchsia swapchain
  related extension for this platform only.

- Provide a small mock GLFW library for Fuchsia under
  src/utils/Glfw3Fuchsia.cpp, since the upstream project
  does not support this platform at all. Its purpose is
  only to allow the creation of the right VulkanBinding
  instance, which depends on the creation of a display
  surface for latter swapchain creation.

- Add //third_party/fuchsia-sdk:vulkan_base and
  //third_party/fuchsia-sdk:vulkan_validation as
  data_deps of the libdawn_native_sources target in
  order to ensure that the Fuchsia package created by
  the build system will include the correct Vulkan
  libraries (loader and validation layers).

This builds correctly, and both dawn_unittests and
dawn_end2end_tests will run on a real Fuchsia device
or inside the Fuchsia emulator, using either GPU
virtualization or a software-based renderer.

Note: dawn_unittests will also run inside QEMU, but
not dawn_end2end_tests, since the latter requires
proper GPU emulation which is not available in this
environment.

NOTE: All end2end tests pass using a device with
      an "Intel HD Graphics 615 (Kaby Lake GT2)"
      adapter. However:

       - For some reason, a single test takes up
         to 129 seconds to pass
	 (BufferSetSubDataTests.ManySetSubData/Vulkan).

       - The test process crashes inside VkDestroyInstance(),
         apparently inside the Fuchsia-specific imagepipe
	 layer (which implements swapchain support).
	 This is likely a bug in the layer itself, and
	 not Dawn.

    Also, may end2end tests will crash when run inside
    the Fuchsia emulator (which uses GPU virtualization
    to talk to the host GPU). The crashes happen inside
    libvulkan-goldfish.so, the emulator-specific Vulkan
    ICD on this sytem. Not a Dawn bug either.

Bug=dawn:221
Change-Id: Id3598b673e8c6393f24db728b8da49fdde3cac76
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8963
Commit-Queue: David Turner <digit@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-09-09 10:52:08 +00:00
Bryan Bernhart 22c3ff73c1 Resource Management 6: VK support for resource allocation.
Refactor existing memory allocators by using a common
memory type and handle.

BUG=dawn:27

Change-Id: Ieed4fa30a0bd8fedfb3a3c580920805f40b56fae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10680
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
2019-09-05 17:36:47 +00:00
Rafael Cintron 179d7b28a3 Add WrapSharedHandle to D3D12 backend
WrapSharedHandle uses a HANDLE and an acquire key to create
a Dawn texture object.

A future change will use the acquire key to manage a keyed shared
mutex with Chromium code.

Bug: dawn:27
Change-Id: I1c0ef8d022158abf3f1c6731a37ee3f51632fcf9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10540
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2019-09-02 19:19:34 +00:00
Austin Eng 3c26e42e36 Add dawn_perf_tests as a data_dep of dawn_perf_tests_temp_group
This is needed so that the script to produce the isolate can correctly
detect the binary.

Bug: dawn:208
TBR: cwallez@chromium.org
Change-Id: I62fc4c40edfe9320d55a587d2176bbd9c93bb540
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10761
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-08-30 19:16:46 +00:00
Austin Eng ca0eac314b Add Dawn perf test harness
This patch adds a perf test harness for Dawn and a simple test of
buffer upload performance. The test harness is based off of ANGLE's
perf tests.

Because perf tests are parameterized to support multiple test
variants, this patch also adds DawnTestWithParams and ParamGenerator
to support instantiating tests with additional parameters.

Bug: dawn:208
Change-Id: I60df730e9f9f21a4c29fc21ea1a8315e4fff1aa6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10340
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-08-28 23:18:10 +00:00
Bryan Bernhart 7ffd2346f8 Resource Management 5: D3D support for resource allocation.
Refactor existing resource allocators by adding a memory type
and memory handle.

BUG=dawn:27, dawn:153

Change-Id: I090b6ab40e7eaa0d7ea5ce1e8b760e961be9b559
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9420
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-27 23:36:26 +00:00
Jiawei Shao 9d9d76c590 OpenGL: Support B2T and T2T copies with BC formats
This patch implements the creation, buffer-to-texture copies and
texture-to-texture copies with BC formats on OpenGL backend. Note that
OpenGL SPEC also has the same issue about texture-to-texture copies
with compressed textures as Vulkan SPEC, so we have to skip the related
case.

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

BUG=dawn:42
TEST=dawn_end2end_tests

Change-Id: I76b16862259cb2df77f202ed7ed433d41aa3cd47
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10220
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-08-22 08:19:13 +00:00
Austin Eng 40618d0b93 Implement RenderBundle in the backend
Bug: dawn:154
Change-Id: I45496fb2103150dabe32fbc7cb5856dc40c9339f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9222
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-08-14 02:01:14 +00:00
Austin Eng 8a488c1574 Implement RenderBundle in the frontend
This CL implements RenderBundle and RenderBundleEncoder in the frontend
and adds unittests for validation.

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

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

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

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

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

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

Bug: chromium:958013
Change-Id: I033b1c7ca57c550504a1bea1898a1a152831922b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7060
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-13 19:00:34 +00:00
Austin Eng 3318caaa51 Factor RenderPass command validation
Validation of GPURenderBundle will share code with RenderPass
validation. Factor validation of commands for GPURenderBundle
into a separate function.

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

Bug: chromium:976495
Change-Id: I9f07eaf436e10aa6bd88cffdc74fd23834d62ee0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8340
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-10 03:17:52 +00:00
Austin Eng e9fabf5916 Factor PassResourceUsageTracker to its own file
GPURenderBundleEncoder and GPUCommandEncoder will need to share code
for tracking resource usages.

Bug: dawn:154
Change-Id: I0286f71c4c0638f89be2754c8e9691e67e5db335
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9700
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-08-08 17:21:39 +00:00
Corentin Wallez bfc9cee5d3 Implement OpArrayLength on Metal
Metal uses a physical addressing mode and buffers are just pointers in
GPU memory that don't have a size. This prevents implementing
OpArrayLength without any additional information. When a shader uses
OpArrayLength on unsized arrays, SPIRV-Cross requires an extra buffer
argument that gets the length of the buffers.

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

Also adds tests that OpArraySize works in all shader stages.

BUG=dawn:195

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

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

BUG=dawn:42
TEST=dawn_end2end_tests
TEST=dawn_unittests

Change-Id: I04d818b0218ebb3b1b7a70a4fea71779f308f85f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9520
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-08-02 00:06:38 +00:00
Jiawei Shao d08611b7a8 Move all the implementations of Toggle to Toggles.cpp
This patch moves all the code related to Toggle from Instance.cpp to
Toggles.cpp to make the code in Instance.cpp cleaner.

BUG=dawn:56

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

BUG=dawn:27

Change-Id: I56836ae317ecc5a91d8341c843fc37d4f91fb5af
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9260
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-30 16:46:10 +00:00
Austin Eng b98f0faa4d Deduplicate AttachmentState shared by RenderPipeline and RenderPasses
This both deduplicates shared state by multiple passes or pipelines and
makes checking pipeline compatibility a single pointer check. It will be
useful for also checking RenderBundle compatibility.

Bug: dawn:154
Change-Id: I0fb289fab5ac76a7fbd500f64b8a6409a246ab32
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9461
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-07-26 19:08:18 +00:00
Austin Eng fde94905fe Factor EncodingContext out of CommandEncoderBase.
This patch factors the CommandAllocator, CommandIterator, and error
handling out of CommandEncoderBase so it can later be used by the
RenderBundleEncoder.

Bug: dawn:154
Change-Id: Ia4f8c3ce7f432f0887b619bd8090aa9bec7330fc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9181
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2019-07-24 18:15:24 +00:00
Corentin Wallez 4e3b218e96 Introduce a format table in the OpenGL
The information about formats in OpenGL will grow to include more
information than just (internalFormat, format, type) and will gain more
logic to depend on GL version and available extensions over time.

BUG=dawn:128

Change-Id: I63a6ac7d48797fb4a9f97a65871306e640cf41d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9201
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2019-07-23 06:40:54 +00:00
Corentin Wallez 23dd12459c Fix compilation of the OpenGL backend on Mac
OpenGLBackend.cpp would end up including KHR/khrplatform.h when the
libdawn_native target that contains it doesn't have a dependency on the
khr_platform target. Fix this by making libdawn_native_sources expose
some of its dependencies as public_deps.

BUG=

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

Bug: dawn:154
Change-Id: Ib7126b2ba718b0b93e3d6f15c429ac910c0d5d31
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9180
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2019-07-20 01:34:56 +00:00
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