├── README.md ├── LICENSE └── 0001-RT-WIP.patch /README.md: -------------------------------------------------------------------------------- 1 | # chromium-ray-tracing 2 | 3 | This patch adds hardware accelerated Ray tracing to WebGPU in Chromium using [Dawn RT](https://github.com/maierfelix/dawn-ray-tracing), which is a Fork of Chromium's WebGPU implementation. Both Windows and Linux are supported. 4 | 5 | ## Preview 6 | 7 | 8 | 9 | ## Demo 10 | 11 | When using the Chromium RT build, you can browse [this](https://maierfelix.github.io/chromium-ray-tracing-demo/) online demo, which is an interactive path tracer. 12 | 13 | ## Binaries 14 | - [Windows](https://github.com/maierfelix/chromium-ray-tracing/releases/download/0.0.1/Chromium-RT-win64.zip) 15 | - [Linux](#) (*in progress*) 16 | 17 | To enable WebGPU, go to `chrome://flags/` and set `Unsafe WebGPU` to *enabled*.
18 | On Windows, if you get warnings that DXC/DXIL isn't available, run chromium with `--disable-gpu-sandbox`. 19 | 20 | ## Building 21 | 22 | Clone Chromium (revision: *b4332347b130a3c912aa0eba1583cb7db071b1e6*).
23 | 24 | Run: 25 | ```` 26 | fetch chromium 27 | gclient sync 28 | gn gen out/Default --args="is_component_build=true is_debug=false use_dawn=true symbol_level=1 blink_symbol_level=1" 29 | autoninja -C out/Default chrome 30 | ```` 31 | 32 | ### On Windows: 33 | After building, download [DXC](https://github.com/microsoft/DirectXShaderCompiler/releases) and place *dxcompiler.dll* and *dxil.dll* along *chrome.exe*.
34 | 35 | ### On Linux: 36 | Make sure you have the latest [Vulkan beta driver](https://developer.nvidia.com/vulkan-driver) installed. 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Felix Maier 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /0001-RT-WIP.patch: -------------------------------------------------------------------------------- 1 | From 622b83474902dbba3b36e460da0d600a511b8ad8 Mon Sep 17 00:00:00 2001 2 | From: Felix Maier 3 | Date: Mon, 11 May 2020 12:33:24 +0200 4 | Subject: [PATCH] RT WIP 5 | 6 | Add missing RT extension, Roll dawn 7 | 8 | Roll dawn, add acceleration destroy, add acceleration instances, updateInstance, build/update acceleration container passes 9 | 10 | Roll Dawn 11 | 12 | Add SBT, Add GPUResource alias, add copyRayTracingAccelerationContainer, fix some stuff 13 | 14 | Add RT pipeline, RT pass encoder, fix some stuff 15 | 16 | Fix transform3D Z property, use transformMatrixSize 17 | 18 | Add transformMatrixSize default, fix defaults 19 | 20 | RT spec update WIP 21 | 22 | RT spec update WIP 23 | 24 | Update DEPS 25 | 26 | WGPUTransform3D->WGPUTransform3DDescriptor 27 | 28 | Update DEPS 29 | 30 | Roll dawn 31 | 32 | RT spec changes 33 | 34 | Roll dawn 35 | 36 | Load DXC/DXIL 37 | --- 38 | DEPS | 10 +- 39 | devenv | 0 40 | .../service/webgpu_decoder_impl.cc | 4 +- 41 | .../bindings/generated_in_modules.gni | 14 ++ 42 | .../renderer/bindings/idl_in_modules.gni | 21 ++ 43 | .../bindings/modules/v8/generated.gni | 4 +- 44 | .../bindings/scripts/bind_gen/path_manager.py | 3 + 45 | .../renderer/bindings/scripts/utilities.py | 3 + 46 | .../blink/renderer/modules/webgpu/BUILD.gn | 11 + 47 | .../modules/webgpu/client_validation.cc | 7 + 48 | .../modules/webgpu/client_validation.h | 4 + 49 | .../modules/webgpu/dawn_conversions.cc | 45 ++++ 50 | .../renderer/modules/webgpu/gpu_adapter.cc | 4 + 51 | .../renderer/modules/webgpu/gpu_adapter.idl | 1 + 52 | .../renderer/modules/webgpu/gpu_bind_group.cc | 6 + 53 | .../modules/webgpu/gpu_bind_group_entry.idl | 2 +- 54 | .../webgpu/gpu_bind_group_layout_entry.idl | 1 + 55 | .../modules/webgpu/gpu_buffer_usage.h | 1 + 56 | .../modules/webgpu/gpu_buffer_usage.idl | 1 + 57 | .../modules/webgpu/gpu_command_encoder.cc | 59 +++++ 58 | .../modules/webgpu/gpu_command_encoder.h | 15 ++ 59 | .../modules/webgpu/gpu_command_encoder.idl | 11 + 60 | .../renderer/modules/webgpu/gpu_device.cc | 16 ++ 61 | .../renderer/modules/webgpu/gpu_device.h | 13 + 62 | .../renderer/modules/webgpu/gpu_device.idl | 5 + 63 | .../gpu_ray_tracing_acceleration_container.cc | 224 ++++++++++++++++++ 64 | .../gpu_ray_tracing_acceleration_container.h | 36 +++ 65 | ...gpu_ray_tracing_acceleration_container.idl | 14 ++ 66 | ...cing_acceleration_container_descriptor.idl | 17 ++ 67 | ...ray_tracing_acceleration_container_usage.h | 30 +++ 68 | ...y_tracing_acceleration_container_usage.idl | 16 ++ 69 | ..._acceleration_geometry_aabb_descriptor.idl | 12 + 70 | ...acing_acceleration_geometry_descriptor.idl | 18 ++ 71 | ...acceleration_geometry_index_descriptor.idl | 12 + 72 | ..._ray_tracing_acceleration_geometry_usage.h | 28 +++ 73 | ...ay_tracing_acceleration_geometry_usage.idl | 14 ++ 74 | ...cceleration_geometry_vertex_descriptor.idl | 13 + 75 | ...acing_acceleration_instance_descriptor.idl | 16 ++ 76 | ...leration_instance_transform_descriptor.idl | 11 + 77 | ..._ray_tracing_acceleration_instance_usage.h | 30 +++ 78 | ...ay_tracing_acceleration_instance_usage.idl | 16 ++ 79 | .../gpu_ray_tracing_pass_descriptor.idl | 8 + 80 | .../webgpu/gpu_ray_tracing_pass_encoder.cc | 93 ++++++++ 81 | .../webgpu/gpu_ray_tracing_pass_encoder.h | 57 +++++ 82 | .../webgpu/gpu_ray_tracing_pass_encoder.idl | 20 ++ 83 | .../webgpu/gpu_ray_tracing_pipeline.cc | 67 ++++++ 84 | .../modules/webgpu/gpu_ray_tracing_pipeline.h | 34 +++ 85 | .../webgpu/gpu_ray_tracing_pipeline.idl | 11 + 86 | .../gpu_ray_tracing_pipeline_descriptor.idl | 9 + 87 | .../gpu_ray_tracing_shader_binding_table.cc | 79 ++++++ 88 | .../gpu_ray_tracing_shader_binding_table.h | 34 +++ 89 | .../gpu_ray_tracing_shader_binding_table.idl | 11 + 90 | ...racing_shader_binding_table_descriptor.idl | 10 + 91 | ..._shader_binding_table_group_descriptor.idl | 19 ++ 92 | ..._shader_binding_table_stage_descriptor.idl | 10 + 93 | .../gpu_ray_tracing_state_descriptor.idl | 11 + 94 | .../modules/webgpu/gpu_shader_stage.h | 5 + 95 | .../modules/webgpu/gpu_shader_stage.idl | 5 + 96 | .../webgpu/gpu_transform_3d_descriptor.idl | 11 + 97 | .../blink/renderer/modules/webgpu/idls.gni | 21 ++ 98 | ui/gl/init/gl_initializer_win.cc | 10 +- 99 | 61 files changed, 1283 insertions(+), 10 deletions(-) 100 | create mode 100644 devenv 101 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.cc 102 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.h 103 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.idl 104 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_descriptor.idl 105 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_usage.h 106 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_usage.idl 107 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_aabb_descriptor.idl 108 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_descriptor.idl 109 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_index_descriptor.idl 110 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_usage.h 111 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_usage.idl 112 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_vertex_descriptor.idl 113 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_descriptor.idl 114 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_transform_descriptor.idl 115 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_usage.h 116 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_usage.idl 117 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_descriptor.idl 118 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.cc 119 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.h 120 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.idl 121 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.cc 122 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.h 123 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.idl 124 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline_descriptor.idl 125 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.cc 126 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.h 127 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.idl 128 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_descriptor.idl 129 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_group_descriptor.idl 130 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_stage_descriptor.idl 131 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_state_descriptor.idl 132 | create mode 100644 third_party/blink/renderer/modules/webgpu/gpu_transform_3d_descriptor.idl 133 | 134 | diff --git a/DEPS b/DEPS 135 | index 02de83bf7517..398de8ef0dbf 100644 136 | --- a/DEPS 137 | +++ b/DEPS 138 | @@ -170,6 +170,7 @@ vars = { 139 | 'boringssl_git': 'https://boringssl.googlesource.com', 140 | 'chromium_git': 'https://chromium.googlesource.com', 141 | 'dawn_git': 'https://dawn.googlesource.com', 142 | + 'github_git': 'https://github.com', 143 | 'pdfium_git': 'https://pdfium.googlesource.com', 144 | 'quiche_git': 'https://quiche.googlesource.com', 145 | 'skia_git': 'https://skia.googlesource.com', 146 | @@ -293,7 +294,7 @@ vars = { 147 | # Three lines of non-changing comments so that 148 | # the commit queue can handle CLs rolling feed 149 | # and whatever else without interference from each other. 150 | - 'spirv_cross_revision': '7e0295abf81cc939ecb2644c88592d77407d18d3', 151 | + 'spirv_cross_revision': '1d629fcb2e56dd286d0291351ebc7c72d4d86ee0', 152 | # Three lines of non-changing comments so that 153 | # the commit queue can handle CLs rolling feed 154 | # and whatever else without interference from each other. 155 | @@ -301,7 +302,7 @@ vars = { 156 | # Three lines of non-changing comments so that 157 | # the commit queue can handle CLs rolling feed 158 | # and whatever else without interference from each other. 159 | - 'dawn_revision': '562255a94346d1121c433abfa2abe39aee135804', 160 | + 'dawn_revision': '4d00c624611c96695a4831c96b93316625e87682', 161 | # Three lines of non-changing comments so that 162 | # the commit queue can handle CLs rolling feed 163 | # and whatever else without interference from each other. 164 | @@ -356,6 +357,7 @@ allowed_hosts = [ 165 | 'chrome-internal.googlesource.com', 166 | 'chromium.googlesource.com', 167 | 'dawn.googlesource.com', 168 | + 'github.com', 169 | 'pdfium.googlesource.com', 170 | 'quiche.googlesource.com', 171 | 'skia.googlesource.com', 172 | @@ -613,7 +615,7 @@ deps = { 173 | # the repository and dependencies include them like so: 174 | # #include "spirv-cross/spirv_glsl.hpp" 175 | 'src/third_party/spirv-cross/spirv-cross': 176 | - Var('chromium_git') + '/external/github.com/KhronosGroup/SPIRV-Cross.git@' + 177 | + Var('github_git') + '/maierfelix/SPIRV-Cross.git@' + 178 | Var('spirv_cross_revision'), 179 | 180 | 'src/third_party/spirv-headers/src': 181 | @@ -766,7 +768,7 @@ deps = { 182 | Var('chromium_git') + '/external/github.com/videolan/dav1d.git' + '@' + '114e8f0ee53ba34d22452dc4bdc0e9ec263189c8', 183 | 184 | 'src/third_party/dawn': 185 | - Var('dawn_git') + '/dawn.git' + '@' + Var('dawn_revision'), 186 | + Var('github_git') + '/maierfelix/dawn-ray-tracing.git' + '@' + Var('dawn_revision'), 187 | 188 | 'src/third_party/glfw/src': 189 | Var('chromium_git') + '/external/github.com/glfw/glfw.git@' + '2de2589f910b1a85905f425be4d32f33cec092df', 190 | diff --git a/devenv b/devenv 191 | new file mode 100644 192 | index 000000000000..e69de29bb2d1 193 | diff --git a/gpu/command_buffer/service/webgpu_decoder_impl.cc b/gpu/command_buffer/service/webgpu_decoder_impl.cc 194 | index a4c8530dfd81..a8f90e6ad3d3 100644 195 | --- a/gpu/command_buffer/service/webgpu_decoder_impl.cc 196 | +++ b/gpu/command_buffer/service/webgpu_decoder_impl.cc 197 | @@ -651,6 +651,9 @@ error::Error WebGPUDecoderImpl::InitDawnDeviceAndSetWireServer( 198 | if (request_device_properties.textureCompressionBC) { 199 | device_descriptor.requiredExtensions.push_back("texture_compression_bc"); 200 | } 201 | + if (request_device_properties.rayTracing) { 202 | + device_descriptor.requiredExtensions.push_back("ray_tracing"); 203 | + } 204 | 205 | WGPUDevice wgpu_device = 206 | dawn_adapters_[requested_adapter_index].CreateDevice(&device_descriptor); 207 | @@ -662,7 +665,6 @@ error::Error WebGPUDecoderImpl::InitDawnDeviceAndSetWireServer( 208 | std::make_unique(client(), wgpu_device, 209 | device_client_id, 210 | memory_transfer_service_.get()); 211 | - 212 | return error::kNoError; 213 | } 214 | 215 | diff --git a/third_party/blink/renderer/bindings/generated_in_modules.gni b/third_party/blink/renderer/bindings/generated_in_modules.gni 216 | index 99a6057cb6ee..b06b02aa104d 100644 217 | --- a/third_party/blink/renderer/bindings/generated_in_modules.gni 218 | +++ b/third_party/blink/renderer/bindings/generated_in_modules.gni 219 | @@ -672,6 +672,20 @@ generated_interface_sources_in_modules = [ 220 | "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_pipeline_layout.h", 221 | "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_queue.cc", 222 | "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_queue.h", 223 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_container.cc", 224 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_container.h", 225 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_container_usage.h", 226 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_container_usage.cc", 227 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_geometry_usage.h", 228 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_geometry_usage.cc", 229 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_instance_usage.h", 230 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_instance_usage.cc", 231 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_pass_encoder.cc", 232 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_pass_encoder.h", 233 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_pipeline.cc", 234 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_pipeline.h", 235 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_shader_binding_table.cc", 236 | + "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_shader_binding_table.h", 237 | "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_render_bundle.cc", 238 | "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_render_bundle.h", 239 | "$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_gpu_render_bundle_encoder.cc", 240 | diff --git a/third_party/blink/renderer/bindings/idl_in_modules.gni b/third_party/blink/renderer/bindings/idl_in_modules.gni 241 | index e0618d49fd06..1acb5a7f52d3 100644 242 | --- a/third_party/blink/renderer/bindings/idl_in_modules.gni 243 | +++ b/third_party/blink/renderer/bindings/idl_in_modules.gni 244 | @@ -854,6 +854,26 @@ static_idl_files_in_modules = get_path_info( 245 | "//third_party/blink/renderer/modules/webgpu/gpu_programmable_stage_descriptor.idl", 246 | "//third_party/blink/renderer/modules/webgpu/gpu_queue.idl", 247 | "//third_party/blink/renderer/modules/webgpu/gpu_rasterization_state_descriptor.idl", 248 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.idl", 249 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_descriptor.idl", 250 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_usage.idl", 251 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_aabb_descriptor.idl", 252 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_descriptor.idl", 253 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_usage.idl", 254 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_index_descriptor.idl", 255 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_vertex_descriptor.idl", 256 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_descriptor.idl", 257 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_usage.idl", 258 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_transform_descriptor.idl", 259 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_descriptor.idl", 260 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.idl", 261 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.idl", 262 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline_descriptor.idl", 263 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.idl", 264 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_descriptor.idl", 265 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_group_descriptor.idl", 266 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_stage_descriptor.idl", 267 | + "//third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_state_descriptor.idl", 268 | "//third_party/blink/renderer/modules/webgpu/gpu_render_bundle.idl", 269 | "//third_party/blink/renderer/modules/webgpu/gpu_render_bundle_descriptor.idl", 270 | "//third_party/blink/renderer/modules/webgpu/gpu_render_bundle_encoder.idl", 271 | @@ -880,6 +900,7 @@ static_idl_files_in_modules = get_path_info( 272 | "//third_party/blink/renderer/modules/webgpu/gpu_texture_usage.idl", 273 | "//third_party/blink/renderer/modules/webgpu/gpu_texture_view.idl", 274 | "//third_party/blink/renderer/modules/webgpu/gpu_texture_view_descriptor.idl", 275 | + "//third_party/blink/renderer/modules/webgpu/gpu_transform_3d_descriptor.idl", 276 | "//third_party/blink/renderer/modules/webgpu/gpu_uncaptured_error_event.idl", 277 | "//third_party/blink/renderer/modules/webgpu/gpu_uncaptured_error_event_init.idl", 278 | "//third_party/blink/renderer/modules/webgpu/gpu_validation_error.idl", 279 | diff --git a/third_party/blink/renderer/bindings/modules/v8/generated.gni b/third_party/blink/renderer/bindings/modules/v8/generated.gni 280 | index d715d4d0684b..94434450d119 100644 281 | --- a/third_party/blink/renderer/bindings/modules/v8/generated.gni 282 | +++ b/third_party/blink/renderer/bindings/modules/v8/generated.gni 283 | @@ -49,6 +49,8 @@ bindings_modules_generated_union_type_files = [ 284 | "$bindings_modules_v8_output_dir/double_sequence_or_gpu_color_dict.h", 285 | "$bindings_modules_v8_output_dir/float32_array_or_float64_array_or_dom_matrix.cc", 286 | "$bindings_modules_v8_output_dir/float32_array_or_float64_array_or_dom_matrix.h", 287 | + "$bindings_modules_v8_output_dir/gpu_binding_resource.cc", 288 | + "$bindings_modules_v8_output_dir/gpu_binding_resource.h", 289 | "$bindings_modules_v8_output_dir/gpu_buffer_or_array_buffer.cc", 290 | "$bindings_modules_v8_output_dir/gpu_buffer_or_array_buffer.h", 291 | "$bindings_modules_v8_output_dir/gpu_load_op_or_double_sequence_or_gpu_color_dict.cc", 292 | @@ -59,8 +61,6 @@ bindings_modules_generated_union_type_files = [ 293 | "$bindings_modules_v8_output_dir/gpu_load_op_or_unsigned_long_enforce_range.h", 294 | "$bindings_modules_v8_output_dir/gpu_out_of_memory_error_or_gpu_validation_error.cc", 295 | "$bindings_modules_v8_output_dir/gpu_out_of_memory_error_or_gpu_validation_error.h", 296 | - "$bindings_modules_v8_output_dir/gpu_sampler_or_gpu_texture_view_or_gpu_buffer_binding.cc", 297 | - "$bindings_modules_v8_output_dir/gpu_sampler_or_gpu_texture_view_or_gpu_buffer_binding.h", 298 | "$bindings_modules_v8_output_dir/html_canvas_element_or_offscreen_canvas.cc", 299 | "$bindings_modules_v8_output_dir/html_canvas_element_or_offscreen_canvas.h", 300 | "$bindings_modules_v8_output_dir/idb_object_store_or_idb_index.cc", 301 | diff --git a/third_party/blink/renderer/bindings/scripts/bind_gen/path_manager.py b/third_party/blink/renderer/bindings/scripts/bind_gen/path_manager.py 302 | index 47d6c08b8ee0..0aeb25a585dc 100644 303 | --- a/third_party/blink/renderer/bindings/scripts/bind_gen/path_manager.py 304 | +++ b/third_party/blink/renderer/bindings/scripts/bind_gen/path_manager.py 305 | @@ -218,4 +218,7 @@ _BACKWARD_COMPATIBLE_UNION_FILEPATHS = { 306 | # modules/canvas/offscreencanvas/offscreen_canvas_module.idl 307 | "OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrImageBitmapRenderingContext": 308 | "OffscreenRenderingContext", 309 | + # modules/webgpu/gpu_bind_group_entry.idl 310 | + 'GPUSamplerOrGPUTextureViewOrGPUBufferBindingOrGPURayTracingAccelerationContainer': 311 | + 'GPUBindingResource', 312 | } 313 | diff --git a/third_party/blink/renderer/bindings/scripts/utilities.py b/third_party/blink/renderer/bindings/scripts/utilities.py 314 | index 1dc06544585c..b13d15841845 100644 315 | --- a/third_party/blink/renderer/bindings/scripts/utilities.py 316 | +++ b/third_party/blink/renderer/bindings/scripts/utilities.py 317 | @@ -499,6 +499,9 @@ def shorten_union_name(union_type): 318 | # modules/canvas/offscreencanvas/offscreen_canvas_module.idl 319 | 'OffscreenCanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContextOrImageBitmapRenderingContext': 320 | 'OffscreenRenderingContext', 321 | + # modules/webgpu/gpu_bind_group_entry.idl 322 | + 'GPUSamplerOrGPUTextureViewOrGPUBufferBindingOrGPURayTracingAccelerationContainer': 323 | + 'GPUBindingResource' 324 | } 325 | 326 | idl_type = union_type 327 | diff --git a/third_party/blink/renderer/modules/webgpu/BUILD.gn b/third_party/blink/renderer/modules/webgpu/BUILD.gn 328 | index 01c03224f93f..cd6a52e9a3fe 100644 329 | --- a/third_party/blink/renderer/modules/webgpu/BUILD.gn 330 | +++ b/third_party/blink/renderer/modules/webgpu/BUILD.gn 331 | @@ -49,6 +49,17 @@ blink_modules_sources("webgpu") { 332 | "gpu_programmable_pass_encoder.h", 333 | "gpu_queue.cc", 334 | "gpu_queue.h", 335 | + "gpu_ray_tracing_acceleration_container.cc", 336 | + "gpu_ray_tracing_acceleration_container.h", 337 | + "gpu_ray_tracing_acceleration_container_usage.h", 338 | + "gpu_ray_tracing_acceleration_geometry_usage.h", 339 | + "gpu_ray_tracing_acceleration_instance_usage.h", 340 | + "gpu_ray_tracing_pass_encoder.cc", 341 | + "gpu_ray_tracing_pass_encoder.h", 342 | + "gpu_ray_tracing_pipeline.cc", 343 | + "gpu_ray_tracing_pipeline.h", 344 | + "gpu_ray_tracing_shader_binding_table.cc", 345 | + "gpu_ray_tracing_shader_binding_table.h", 346 | "gpu_render_bundle.cc", 347 | "gpu_render_bundle.h", 348 | "gpu_render_bundle_encoder.cc", 349 | diff --git a/third_party/blink/renderer/modules/webgpu/client_validation.cc b/third_party/blink/renderer/modules/webgpu/client_validation.cc 350 | index 6a8ffb2fe1a4..312cc9c8e231 100644 351 | --- a/third_party/blink/renderer/modules/webgpu/client_validation.cc 352 | +++ b/third_party/blink/renderer/modules/webgpu/client_validation.cc 353 | @@ -10,6 +10,7 @@ 354 | #include "third_party/blink/renderer/bindings/modules/v8/unsigned_long_enforce_range_sequence_or_gpu_origin_2d_dict.h" 355 | #include "third_party/blink/renderer/bindings/modules/v8/unsigned_long_enforce_range_sequence_or_gpu_origin_3d_dict.h" 356 | #include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_texture_copy_view.h" 357 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_container.h" 358 | #include "third_party/blink/renderer/platform/bindings/exception_state.h" 359 | 360 | namespace blink { 361 | @@ -40,4 +41,10 @@ bool ValidateTextureCopyView(GPUTextureCopyView* texture_copy_view, 362 | return true; 363 | } 364 | 365 | +bool ValidateRayTracingAccelerationContainer(GPURayTracingAccelerationContainer* container, 366 | + ExceptionState& exception_state) { 367 | + DCHECK(container); 368 | + return true; 369 | +} 370 | + 371 | } // namespace blink 372 | diff --git a/third_party/blink/renderer/modules/webgpu/client_validation.h b/third_party/blink/renderer/modules/webgpu/client_validation.h 373 | index 47179e4b2a18..f16d63cd2fc2 100644 374 | --- a/third_party/blink/renderer/modules/webgpu/client_validation.h 375 | +++ b/third_party/blink/renderer/modules/webgpu/client_validation.h 376 | @@ -13,6 +13,7 @@ namespace blink { 377 | 378 | class ExceptionState; 379 | class GPUTextureCopyView; 380 | +class GPURayTracingAccelerationContainer; 381 | class UnsignedLongEnforceRangeSequenceOrGPUExtent3DDict; 382 | 383 | bool ValidateCopySize( 384 | @@ -20,6 +21,9 @@ bool ValidateCopySize( 385 | ExceptionState& exception_state); 386 | bool ValidateTextureCopyView(GPUTextureCopyView* texture_copy_view, 387 | ExceptionState& exception_state); 388 | +bool ValidateRayTracingAccelerationContainer( 389 | + GPURayTracingAccelerationContainer* container, 390 | + ExceptionState& exception_state); 391 | } // namespace blink 392 | 393 | #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_CLIENT_VALIDATION_H_ 394 | diff --git a/third_party/blink/renderer/modules/webgpu/dawn_conversions.cc b/third_party/blink/renderer/modules/webgpu/dawn_conversions.cc 395 | index a668a87edc7d..3f8314bd5737 100644 396 | --- a/third_party/blink/renderer/modules/webgpu/dawn_conversions.cc 397 | +++ b/third_party/blink/renderer/modules/webgpu/dawn_conversions.cc 398 | @@ -43,6 +43,9 @@ WGPUBindingType AsDawnEnum(const WTF::String& webgpu_enum) { 399 | if (webgpu_enum == "writeonly-storage-texture") { 400 | return WGPUBindingType_WriteonlyStorageTexture; 401 | } 402 | + if (webgpu_enum == "acceleration-container") { 403 | + return WGPUBindingType_AccelerationContainer; 404 | + } 405 | NOTREACHED(); 406 | return WGPUBindingType_Force32; 407 | } 408 | @@ -370,6 +373,9 @@ WGPUIndexFormat AsDawnEnum(const WTF::String& webgpu_enum) { 409 | if (webgpu_enum == "uint32") { 410 | return WGPUIndexFormat_Uint32; 411 | } 412 | + if (webgpu_enum == "none") { 413 | + return WGPUIndexFormat_None; 414 | + } 415 | NOTREACHED(); 416 | return WGPUIndexFormat_Force32; 417 | } 418 | @@ -657,6 +663,45 @@ WGPUErrorFilter AsDawnEnum(const WTF::String& webgpu_enum) { 419 | return WGPUErrorFilter_Force32; 420 | } 421 | 422 | +template <> 423 | +WGPURayTracingAccelerationContainerLevel AsDawnEnum(const WTF::String& webgpu_enum) { 424 | + if (webgpu_enum == "bottom") { 425 | + return WGPURayTracingAccelerationContainerLevel_Bottom; 426 | + } 427 | + if (webgpu_enum == "top") { 428 | + return WGPURayTracingAccelerationContainerLevel_Top; 429 | + } 430 | + NOTREACHED(); 431 | + return WGPURayTracingAccelerationContainerLevel_Force32; 432 | +} 433 | + 434 | +template <> 435 | +WGPURayTracingAccelerationGeometryType AsDawnEnum(const WTF::String& webgpu_enum) { 436 | + if (webgpu_enum == "triangles") { 437 | + return WGPURayTracingAccelerationGeometryType_Triangles; 438 | + } 439 | + if (webgpu_enum == "aabbs") { 440 | + return WGPURayTracingAccelerationGeometryType_Aabbs; 441 | + } 442 | + NOTREACHED(); 443 | + return WGPURayTracingAccelerationGeometryType_Force32; 444 | +} 445 | + 446 | +template <> 447 | +WGPURayTracingShaderBindingTableGroupType AsDawnEnum(const WTF::String& webgpu_enum) { 448 | + if (webgpu_enum == "general") { 449 | + return WGPURayTracingShaderBindingTableGroupType_General; 450 | + } 451 | + if (webgpu_enum == "triangles-hit-group") { 452 | + return WGPURayTracingShaderBindingTableGroupType_TrianglesHitGroup; 453 | + } 454 | + if (webgpu_enum == "procedural-hit-group") { 455 | + return WGPURayTracingShaderBindingTableGroupType_ProceduralHitGroup; 456 | + } 457 | + NOTREACHED(); 458 | + return WGPURayTracingShaderBindingTableGroupType_Force32; 459 | +} 460 | + 461 | WGPUColor AsDawnColor(const Vector& webgpu_color) { 462 | DCHECK_EQ(webgpu_color.size(), 4UL); 463 | 464 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc b/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc 465 | index 16697b5c677e..d904c71d376a 100644 466 | --- a/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc 467 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_adapter.cc 468 | @@ -27,6 +27,7 @@ WGPUDeviceProperties AsDawnType(const GPUDeviceDescriptor* descriptor) { 469 | // subset of the adapter's extension set. 470 | requested_device_properties.textureCompressionBC = 471 | extension_set.Contains("textureCompressionBC"); 472 | + requested_device_properties.rayTracing = extension_set.Contains("rayTracing"); 473 | 474 | return requested_device_properties; 475 | } 476 | @@ -74,6 +75,9 @@ void GPUAdapter::InitializeExtensionNameList() { 477 | if (adapter_properties_.textureCompressionBC) { 478 | extension_name_list_.emplace_back("textureCompressionBC"); 479 | } 480 | + if (adapter_properties_.rayTracing) { 481 | + extension_name_list_.emplace_back("rayTracing"); 482 | + } 483 | } 484 | 485 | ScriptPromise GPUAdapter::requestDevice(ScriptState* script_state, 486 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_adapter.idl b/third_party/blink/renderer/modules/webgpu/gpu_adapter.idl 487 | index 735742c66bba..22e7f92e6887 100644 488 | --- a/third_party/blink/renderer/modules/webgpu/gpu_adapter.idl 489 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_adapter.idl 490 | @@ -6,6 +6,7 @@ 491 | 492 | enum GPUExtensionName { 493 | "textureCompressionBC", 494 | + "rayTracing", 495 | }; 496 | 497 | [ 498 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_bind_group.cc b/third_party/blink/renderer/modules/webgpu/gpu_bind_group.cc 499 | index 4933688c357b..c1765b3b7629 100644 500 | --- a/third_party/blink/renderer/modules/webgpu/gpu_bind_group.cc 501 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_bind_group.cc 502 | @@ -10,6 +10,7 @@ 503 | #include "third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout.h" 504 | #include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h" 505 | #include "third_party/blink/renderer/modules/webgpu/gpu_device.h" 506 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.h" 507 | #include "third_party/blink/renderer/modules/webgpu/gpu_sampler.h" 508 | #include "third_party/blink/renderer/modules/webgpu/gpu_texture_view.h" 509 | #include "third_party/blink/renderer/platform/bindings/exception_state.h" 510 | @@ -37,6 +38,11 @@ WGPUBindGroupEntry AsDawnType(const GPUBindGroupEntry* webgpu_binding) { 511 | webgpu_binding->resource().GetAsGPUTextureView(); 512 | dawn_binding.textureView = AsDawnType(texture_view); 513 | 514 | + } else if (webgpu_binding->resource().IsGPURayTracingAccelerationContainer()) { 515 | + GPURayTracingAccelerationContainer* acceleration_container = 516 | + webgpu_binding->resource().GetAsGPURayTracingAccelerationContainer(); 517 | + dawn_binding.accelerationContainer = AsDawnType(acceleration_container); 518 | + 519 | } else { 520 | NOTREACHED(); 521 | } 522 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_bind_group_entry.idl b/third_party/blink/renderer/modules/webgpu/gpu_bind_group_entry.idl 523 | index c71a9ff2aece..820f0e995913 100644 524 | --- a/third_party/blink/renderer/modules/webgpu/gpu_bind_group_entry.idl 525 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_bind_group_entry.idl 526 | @@ -4,7 +4,7 @@ 527 | 528 | // https://gpuweb.github.io/gpuweb/ 529 | 530 | -typedef (GPUSampler or GPUTextureView or GPUBufferBinding) GPUBindingResource; 531 | +typedef (GPUSampler or GPUTextureView or GPUBufferBinding or GPURayTracingAccelerationContainer) GPUBindingResource; 532 | 533 | dictionary GPUBindGroupEntry { 534 | required GPUIndex32 binding; 535 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout_entry.idl b/third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout_entry.idl 536 | index a4084166bb0c..c544faba9bde 100644 537 | --- a/third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout_entry.idl 538 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout_entry.idl 539 | @@ -26,6 +26,7 @@ enum GPUBindingType { 540 | "sampled-texture", 541 | "readonly-storage-texture", 542 | "writeonly-storage-texture", 543 | + "acceleration-container" 544 | }; 545 | 546 | enum GPUTextureComponentType { 547 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_buffer_usage.h b/third_party/blink/renderer/modules/webgpu/gpu_buffer_usage.h 548 | index 5c922e7e4133..e40aef98a10f 100644 549 | --- a/third_party/blink/renderer/modules/webgpu/gpu_buffer_usage.h 550 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_buffer_usage.h 551 | @@ -23,6 +23,7 @@ class GPUBufferUsage : public ScriptWrappable { 552 | static constexpr uint32_t kUniform = 64; 553 | static constexpr uint32_t kStorage = 128; 554 | static constexpr uint32_t kIndirect = 256; 555 | + static constexpr uint32_t kRayTracing = 512; 556 | 557 | private: 558 | DISALLOW_COPY_AND_ASSIGN(GPUBufferUsage); 559 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_buffer_usage.idl b/third_party/blink/renderer/modules/webgpu/gpu_buffer_usage.idl 560 | index 061bfa159510..9c50ca249d9a 100644 561 | --- a/third_party/blink/renderer/modules/webgpu/gpu_buffer_usage.idl 562 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_buffer_usage.idl 563 | @@ -17,4 +17,5 @@ typedef [EnforceRange] unsigned long GPUBufferUsageFlags; 564 | const unsigned long UNIFORM = 64; 565 | const unsigned long STORAGE = 128; 566 | const unsigned long INDIRECT = 256; 567 | + const unsigned long RAY_TRACING = 512; 568 | }; 569 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.cc b/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.cc 570 | index 6969bc8f4ec9..a938bbd8ccee 100644 571 | --- a/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.cc 572 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.cc 573 | @@ -11,6 +11,7 @@ 574 | #include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_command_buffer_descriptor.h" 575 | #include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_command_encoder_descriptor.h" 576 | #include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_compute_pass_descriptor.h" 577 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_pass_descriptor.h" 578 | #include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_render_pass_color_attachment_descriptor.h" 579 | #include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_render_pass_depth_stencil_attachment_descriptor.h" 580 | #include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_render_pass_descriptor.h" 581 | @@ -21,6 +22,8 @@ 582 | #include "third_party/blink/renderer/modules/webgpu/gpu_command_buffer.h" 583 | #include "third_party/blink/renderer/modules/webgpu/gpu_compute_pass_encoder.h" 584 | #include "third_party/blink/renderer/modules/webgpu/gpu_device.h" 585 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.h" 586 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.h" 587 | #include "third_party/blink/renderer/modules/webgpu/gpu_render_pass_encoder.h" 588 | #include "third_party/blink/renderer/modules/webgpu/gpu_texture.h" 589 | #include "third_party/blink/renderer/modules/webgpu/gpu_texture_view.h" 590 | @@ -255,6 +258,18 @@ GPUComputePassEncoder* GPUCommandEncoder::beginComputePass( 591 | GetProcs().commandEncoderBeginComputePass(GetHandle(), &dawn_desc)); 592 | } 593 | 594 | +GPURayTracingPassEncoder* GPUCommandEncoder::beginRayTracingPass( 595 | + const GPURayTracingPassDescriptor* descriptor) { 596 | + WGPURayTracingPassDescriptor dawn_desc = {}; 597 | + if (descriptor->hasLabel()) { 598 | + dawn_desc.label = descriptor->label().Utf8().data(); 599 | + } 600 | + 601 | + return MakeGarbageCollected( 602 | + device_, 603 | + GetProcs().commandEncoderBeginRayTracingPass(GetHandle(), &dawn_desc)); 604 | +} 605 | + 606 | void GPUCommandEncoder::copyBufferToBuffer(GPUBuffer* src, 607 | uint64_t src_offset, 608 | GPUBuffer* dst, 609 | @@ -330,6 +345,50 @@ void GPUCommandEncoder::copyTextureToTexture( 610 | GetHandle(), &dawn_source, &dawn_destination, &dawn_copy_size); 611 | } 612 | 613 | +void GPUCommandEncoder::buildRayTracingAccelerationContainer( 614 | + GPURayTracingAccelerationContainer* container, 615 | + ExceptionState& exception_state) { 616 | + if (!ValidateRayTracingAccelerationContainer(container, exception_state)) { 617 | + return; 618 | + } 619 | + 620 | + WGPURayTracingAccelerationContainer dawn_container = AsDawnType(container); 621 | + 622 | + GetProcs().commandEncoderBuildRayTracingAccelerationContainer( 623 | + GetHandle(), dawn_container); 624 | +} 625 | + 626 | +void GPUCommandEncoder::updateRayTracingAccelerationContainer( 627 | + GPURayTracingAccelerationContainer* container, 628 | + ExceptionState& exception_state) { 629 | + if (!ValidateRayTracingAccelerationContainer(container, exception_state)) { 630 | + return; 631 | + } 632 | + 633 | + WGPURayTracingAccelerationContainer dawn_container = AsDawnType(container); 634 | + 635 | + GetProcs().commandEncoderUpdateRayTracingAccelerationContainer( 636 | + GetHandle(), dawn_container); 637 | +} 638 | + 639 | +void GPUCommandEncoder::copyRayTracingAccelerationContainer( 640 | + GPURayTracingAccelerationContainer* src_container, 641 | + GPURayTracingAccelerationContainer* dst_container, 642 | + ExceptionState& exception_state) { 643 | + if (!ValidateRayTracingAccelerationContainer(src_container, exception_state)) { 644 | + return; 645 | + } 646 | + if (!ValidateRayTracingAccelerationContainer(dst_container, exception_state)) { 647 | + return; 648 | + } 649 | + 650 | + WGPURayTracingAccelerationContainer dawn_src_container = AsDawnType(src_container); 651 | + WGPURayTracingAccelerationContainer dawn_dst_container = AsDawnType(dst_container); 652 | + 653 | + GetProcs().commandEncoderCopyRayTracingAccelerationContainer( 654 | + GetHandle(), dawn_src_container, dawn_dst_container); 655 | +} 656 | + 657 | void GPUCommandEncoder::pushDebugGroup(String groupLabel) { 658 | GetProcs().commandEncoderPushDebugGroup(GetHandle(), 659 | groupLabel.Utf8().data()); 660 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.h b/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.h 661 | index 04b36eba8501..164e05260150 100644 662 | --- a/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.h 663 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.h 664 | @@ -18,6 +18,9 @@ class GPUCommandBufferDescriptor; 665 | class GPUCommandEncoderDescriptor; 666 | class GPUComputePassDescriptor; 667 | class GPUComputePassEncoder; 668 | +class GPURayTracingAccelerationContainer; 669 | +class GPURayTracingPassDescriptor; 670 | +class GPURayTracingPassEncoder; 671 | class GPURenderPassDescriptor; 672 | class GPURenderPassEncoder; 673 | class GPUTextureCopyView; 674 | @@ -40,6 +43,8 @@ class GPUCommandEncoder : public DawnObject { 675 | ExceptionState& exception_state); 676 | GPUComputePassEncoder* beginComputePass( 677 | const GPUComputePassDescriptor* descriptor); 678 | + GPURayTracingPassEncoder* beginRayTracingPass( 679 | + const GPURayTracingPassDescriptor* descriptor); 680 | void copyBufferToBuffer(GPUBuffer* src, 681 | uint64_t src_offset, 682 | GPUBuffer* dst, 683 | @@ -60,6 +65,16 @@ class GPUCommandEncoder : public DawnObject { 684 | GPUTextureCopyView* destination, 685 | UnsignedLongEnforceRangeSequenceOrGPUExtent3DDict& copy_size, 686 | ExceptionState& exception_state); 687 | + void buildRayTracingAccelerationContainer( 688 | + GPURayTracingAccelerationContainer* container, 689 | + ExceptionState& exception_state); 690 | + void updateRayTracingAccelerationContainer( 691 | + GPURayTracingAccelerationContainer* container, 692 | + ExceptionState& exception_state); 693 | + void copyRayTracingAccelerationContainer( 694 | + GPURayTracingAccelerationContainer* src_container, 695 | + GPURayTracingAccelerationContainer* dst_container, 696 | + ExceptionState& exception_state); 697 | void pushDebugGroup(String groupLabel); 698 | void popDebugGroup(); 699 | void insertDebugMarker(String markerLabel); 700 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.idl b/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.idl 701 | index 3e9897a5e81a..b0ff59a04897 100644 702 | --- a/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.idl 703 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_command_encoder.idl 704 | @@ -9,6 +9,7 @@ 705 | ] interface GPUCommandEncoder { 706 | [RaisesException] GPURenderPassEncoder beginRenderPass(GPURenderPassDescriptor descriptor); 707 | GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {}); 708 | + GPURayTracingPassEncoder beginRayTracingPass(optional GPURayTracingPassDescriptor descriptor = {}); 709 | 710 | void copyBufferToBuffer( 711 | GPUBuffer src, 712 | @@ -32,6 +33,16 @@ 713 | GPUTextureCopyView destination, 714 | GPUExtent3D copySize); 715 | 716 | + [RaisesException] void buildRayTracingAccelerationContainer( 717 | + GPURayTracingAccelerationContainer container); 718 | + 719 | + [RaisesException] void updateRayTracingAccelerationContainer( 720 | + GPURayTracingAccelerationContainer container); 721 | + 722 | + [RaisesException] void copyRayTracingAccelerationContainer( 723 | + GPURayTracingAccelerationContainer src_container, 724 | + GPURayTracingAccelerationContainer dst_container); 725 | + 726 | void pushDebugGroup(DOMString groupLabel); 727 | void popDebugGroup(); 728 | void insertDebugMarker(DOMString markerLabel); 729 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_device.cc b/third_party/blink/renderer/modules/webgpu/gpu_device.cc 730 | index f8f37f782489..c71dd8458c44 100644 731 | --- a/third_party/blink/renderer/modules/webgpu/gpu_device.cc 732 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_device.cc 733 | @@ -22,6 +22,9 @@ 734 | #include "third_party/blink/renderer/modules/webgpu/gpu_device_lost_info.h" 735 | #include "third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.h" 736 | #include "third_party/blink/renderer/modules/webgpu/gpu_queue.h" 737 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.h" 738 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.h" 739 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.h" 740 | #include "third_party/blink/renderer/modules/webgpu/gpu_render_bundle_encoder.h" 741 | #include "third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.h" 742 | #include "third_party/blink/renderer/modules/webgpu/gpu_sampler.h" 743 | @@ -155,6 +158,14 @@ GPUSampler* GPUDevice::createSampler(const GPUSamplerDescriptor* descriptor) { 744 | return GPUSampler::Create(this, descriptor); 745 | } 746 | 747 | +GPURayTracingAccelerationContainer* GPUDevice::createRayTracingAccelerationContainer(const GPURayTracingAccelerationContainerDescriptor* descriptor) { 748 | + return GPURayTracingAccelerationContainer::Create(this, descriptor); 749 | +} 750 | + 751 | +GPURayTracingShaderBindingTable* GPUDevice::createRayTracingShaderBindingTable(const GPURayTracingShaderBindingTableDescriptor* descriptor) { 752 | + return GPURayTracingShaderBindingTable::Create(this, descriptor); 753 | +} 754 | + 755 | GPUBindGroup* GPUDevice::createBindGroup( 756 | const GPUBindGroupDescriptor* descriptor, 757 | ExceptionState& exception_state) { 758 | @@ -189,6 +200,11 @@ GPUComputePipeline* GPUDevice::createComputePipeline( 759 | return GPUComputePipeline::Create(this, descriptor); 760 | } 761 | 762 | +GPURayTracingPipeline* GPUDevice::createRayTracingPipeline( 763 | + const GPURayTracingPipelineDescriptor* descriptor) { 764 | + return GPURayTracingPipeline::Create(this, descriptor); 765 | +} 766 | + 767 | GPUCommandEncoder* GPUDevice::createCommandEncoder( 768 | const GPUCommandEncoderDescriptor* descriptor) { 769 | return GPUCommandEncoder::Create(this, descriptor); 770 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_device.h b/third_party/blink/renderer/modules/webgpu/gpu_device.h 771 | index e27314bfa106..ce4fbd132c79 100644 772 | --- a/third_party/blink/renderer/modules/webgpu/gpu_device.h 773 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_device.h 774 | @@ -34,6 +34,12 @@ class GPUDeviceLostInfo; 775 | class GPUPipelineLayout; 776 | class GPUPipelineLayoutDescriptor; 777 | class GPUQueue; 778 | +class GPURayTracingAccelerationContainer; 779 | +class GPURayTracingAccelerationContainerDescriptor; 780 | +class GPURayTracingShaderBindingTable; 781 | +class GPURayTracingShaderBindingTableDescriptor; 782 | +class GPURayTracingPipeline; 783 | +class GPURayTracingPipelineDescriptor; 784 | class GPURenderBundleEncoder; 785 | class GPURenderBundleEncoderDescriptor; 786 | class GPURenderPipeline; 787 | @@ -79,6 +85,11 @@ class GPUDevice final : public EventTargetWithInlineData, 788 | ExceptionState& exception_state); 789 | GPUSampler* createSampler(const GPUSamplerDescriptor* descriptor); 790 | 791 | + GPURayTracingAccelerationContainer* createRayTracingAccelerationContainer( 792 | + const GPURayTracingAccelerationContainerDescriptor* descriptor); 793 | + GPURayTracingShaderBindingTable* createRayTracingShaderBindingTable( 794 | + const GPURayTracingShaderBindingTableDescriptor* descriptor); 795 | + 796 | GPUBindGroup* createBindGroup(const GPUBindGroupDescriptor* descriptor, 797 | ExceptionState& exception_state); 798 | GPUBindGroupLayout* createBindGroupLayout( 799 | @@ -95,6 +106,8 @@ class GPUDevice final : public EventTargetWithInlineData, 800 | const GPURenderPipelineDescriptor* descriptor); 801 | GPUComputePipeline* createComputePipeline( 802 | const GPUComputePipelineDescriptor* descriptor); 803 | + GPURayTracingPipeline* createRayTracingPipeline( 804 | + const GPURayTracingPipelineDescriptor* descriptor); 805 | 806 | GPUCommandEncoder* createCommandEncoder( 807 | const GPUCommandEncoderDescriptor* descriptor); 808 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_device.idl b/third_party/blink/renderer/modules/webgpu/gpu_device.idl 809 | index 1f694b8ef81a..a32e560b9b5f 100644 810 | --- a/third_party/blink/renderer/modules/webgpu/gpu_device.idl 811 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_device.idl 812 | @@ -17,6 +17,9 @@ 813 | [RaisesException] GPUTexture createTexture(GPUTextureDescriptor descriptor); 814 | GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {}); 815 | 816 | + GPURayTracingAccelerationContainer createRayTracingAccelerationContainer(GPURayTracingAccelerationContainerDescriptor descriptor); 817 | + GPURayTracingShaderBindingTable createRayTracingShaderBindingTable(GPURayTracingShaderBindingTableDescriptor descriptor); 818 | + 819 | [RaisesException] GPUBindGroup createBindGroup(GPUBindGroupDescriptor descriptor); 820 | [RaisesException] GPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor); 821 | GPUPipelineLayout createPipelineLayout(GPUPipelineLayoutDescriptor descriptor); 822 | @@ -25,6 +28,8 @@ 823 | [CallWith=ScriptState] GPURenderPipeline createRenderPipeline(GPURenderPipelineDescriptor descriptor); 824 | GPUComputePipeline createComputePipeline(GPUComputePipelineDescriptor descriptor); 825 | 826 | + GPURayTracingPipeline createRayTracingPipeline(GPURayTracingPipelineDescriptor descriptor); 827 | + 828 | GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {}); 829 | GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor); 830 | 831 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.cc b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.cc 832 | new file mode 100644 833 | index 000000000000..250a57d1a4d0 834 | --- /dev/null 835 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.cc 836 | @@ -0,0 +1,224 @@ 837 | +// Copyright 2020 The Chromium Authors. All rights reserved. 838 | +// Use of this source code is governed by a BSD-style license that can be 839 | +// found in the LICENSE file. 840 | + 841 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.h" 842 | + 843 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_container_descriptor.h" 844 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_geometry_descriptor.h" 845 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_instance_descriptor.h" 846 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_geometry_vertex_descriptor.h" 847 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_geometry_index_descriptor.h" 848 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_geometry_aabb_descriptor.h" 849 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_acceleration_instance_transform_descriptor.h" 850 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_transform_3d_descriptor.h" 851 | +#include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h" 852 | +#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h" 853 | +#include "third_party/blink/renderer/modules/webgpu/gpu_device.h" 854 | + 855 | +namespace blink { 856 | + 857 | + namespace { 858 | + 859 | + } // anonymous namespace 860 | + 861 | + // static 862 | + GPURayTracingAccelerationContainer* GPURayTracingAccelerationContainer::Create(GPUDevice* device, 863 | + const GPURayTracingAccelerationContainerDescriptor* webgpu_desc) { 864 | + DCHECK(device); 865 | + DCHECK(webgpu_desc); 866 | + 867 | + WGPURayTracingAccelerationContainerDescriptor dawn_desc = {}; 868 | + dawn_desc.usage = static_cast(webgpu_desc->usage()); 869 | + if (webgpu_desc->hasLevel()) 870 | + dawn_desc.level = AsDawnEnum(webgpu_desc->level()); 871 | + else 872 | + dawn_desc.level = WGPURayTracingAccelerationContainerLevel_Force32; 873 | + 874 | + uint32_t geometry_count = webgpu_desc->hasGeometries() ? static_cast(webgpu_desc->geometries().size()) : 0; 875 | + std::unique_ptr vertex_entries(new WGPURayTracingAccelerationGeometryVertexDescriptor[geometry_count]()); 876 | + std::unique_ptr index_entries(new WGPURayTracingAccelerationGeometryIndexDescriptor[geometry_count]()); 877 | + std::unique_ptr aabb_entries(new WGPURayTracingAccelerationGeometryAabbDescriptor[geometry_count]()); 878 | + 879 | + std::unique_ptr geometries(new WGPURayTracingAccelerationGeometryDescriptor[geometry_count]()); 880 | + for (wtf_size_t i = 0; i < geometry_count; ++i) { 881 | + const GPURayTracingAccelerationGeometryDescriptor* geometry_desc = webgpu_desc->geometries()[i].Get(); 882 | + 883 | + WGPURayTracingAccelerationGeometryDescriptor entry_desc = {}; 884 | + // usage 885 | + if (geometry_desc->hasUsage()) 886 | + entry_desc.usage = static_cast(geometry_desc->usage()); 887 | + else 888 | + entry_desc.usage = WGPURayTracingAccelerationGeometryUsage_None; 889 | + // type 890 | + if (geometry_desc->hasType()) 891 | + entry_desc.type = AsDawnEnum(geometry_desc->type()); 892 | + else 893 | + entry_desc.type = WGPURayTracingAccelerationGeometryType_Force32; 894 | + 895 | + if (geometry_desc->hasVertex()) { 896 | + if (geometry_desc->vertex()->hasBuffer()) { 897 | + vertex_entries[i].buffer = AsDawnType(geometry_desc->vertex()->buffer()); 898 | + } 899 | + vertex_entries[i].format = AsDawnEnum(geometry_desc->vertex()->format()); 900 | + vertex_entries[i].stride = geometry_desc->vertex()->stride(); 901 | + vertex_entries[i].offset = geometry_desc->vertex()->hasOffset() ? geometry_desc->vertex()->offset() : 0; 902 | + vertex_entries[i].count = geometry_desc->vertex()->count(); 903 | + entry_desc.vertex = &vertex_entries[i]; 904 | + } 905 | + 906 | + if (geometry_desc->hasIndex()) { 907 | + if (geometry_desc->index()->hasBuffer()) { 908 | + index_entries[i].buffer = AsDawnType(geometry_desc->index()->buffer()); 909 | + } 910 | + index_entries[i].format = AsDawnEnum(geometry_desc->index()->format()); 911 | + index_entries[i].offset = geometry_desc->index()->hasOffset() ? geometry_desc->index()->offset() : 0; 912 | + index_entries[i].count = geometry_desc->index()->count(); 913 | + entry_desc.index = &index_entries[i]; 914 | + } 915 | + 916 | + if (geometry_desc->hasAabb()) { 917 | + if (geometry_desc->aabb()->hasBuffer()) { 918 | + aabb_entries[i].buffer = AsDawnType(geometry_desc->aabb()->buffer()); 919 | + } 920 | + aabb_entries[i].stride = geometry_desc->aabb()->stride(); 921 | + aabb_entries[i].offset = geometry_desc->aabb()->hasOffset() ? geometry_desc->aabb()->offset() : 0; 922 | + aabb_entries[i].count = geometry_desc->aabb()->count(); 923 | + entry_desc.aabb = &aabb_entries[i]; 924 | + } 925 | + 926 | + geometries[i] = entry_desc; 927 | + } 928 | + dawn_desc.geometryCount = geometry_count; 929 | + dawn_desc.geometries = geometry_count > 0 ? geometries.get() : nullptr; 930 | + 931 | + uint32_t instance_count = webgpu_desc->hasInstances() ? static_cast(webgpu_desc->instances().size()) : 0; 932 | + std::unique_ptr translation_entries(new WGPUTransform3DDescriptor[instance_count]()); 933 | + std::unique_ptr rotation_entries(new WGPUTransform3DDescriptor[instance_count]()); 934 | + std::unique_ptr scale_entries(new WGPUTransform3DDescriptor[instance_count]()); 935 | + std::unique_ptr transform_entries(new WGPURayTracingAccelerationInstanceTransformDescriptor[instance_count]()); 936 | + 937 | + std::unique_ptr instances(new WGPURayTracingAccelerationInstanceDescriptor[instance_count]()); 938 | + for (wtf_size_t i = 0; i < instance_count; ++i) { 939 | + const GPURayTracingAccelerationInstanceDescriptor* instance_desc = webgpu_desc->instances()[i].Get(); 940 | + 941 | + WGPURayTracingAccelerationInstanceDescriptor entry_desc = {}; 942 | + // usage 943 | + if (instance_desc->hasUsage()) 944 | + entry_desc.usage = static_cast(instance_desc->usage()); 945 | + // mask 946 | + if (instance_desc->hasMask()) 947 | + entry_desc.mask = instance_desc->mask(); 948 | + // instanceId 949 | + if (instance_desc->hasInstanceId()) 950 | + entry_desc.instanceId = instance_desc->instanceId(); 951 | + // instanceOffset 952 | + if (instance_desc->hasInstanceOffset()) 953 | + entry_desc.instanceOffset = instance_desc->instanceOffset(); 954 | + // transform 955 | + if (instance_desc->hasTransform()) { 956 | + if (instance_desc->transform()->hasTranslation()) { 957 | + translation_entries[i].x = instance_desc->transform()->translation()->hasX() ? instance_desc->transform()->translation()->x() : 0; 958 | + translation_entries[i].y = instance_desc->transform()->translation()->hasY() ? instance_desc->transform()->translation()->y() : 0; 959 | + translation_entries[i].z = instance_desc->transform()->translation()->hasZ() ? instance_desc->transform()->translation()->z() : 0; 960 | + } 961 | + if (instance_desc->transform()->hasRotation()) { 962 | + rotation_entries[i].x = instance_desc->transform()->rotation()->hasX() ? instance_desc->transform()->rotation()->x() : 0; 963 | + rotation_entries[i].y = instance_desc->transform()->rotation()->hasY() ? instance_desc->transform()->rotation()->y() : 0; 964 | + rotation_entries[i].z = instance_desc->transform()->rotation()->hasZ() ? instance_desc->transform()->rotation()->z() : 0; 965 | + } 966 | + if (instance_desc->transform()->hasScale()) { 967 | + scale_entries[i].x = instance_desc->transform()->scale()->hasX() ? instance_desc->transform()->scale()->x() : 0; 968 | + scale_entries[i].y = instance_desc->transform()->scale()->hasY() ? instance_desc->transform()->scale()->y() : 0; 969 | + scale_entries[i].z = instance_desc->transform()->scale()->hasZ() ? instance_desc->transform()->scale()->z() : 0; 970 | + } 971 | + transform_entries[i].translation = &translation_entries[i]; 972 | + transform_entries[i].rotation = &rotation_entries[i]; 973 | + transform_entries[i].scale = &scale_entries[i]; 974 | + entry_desc.transform = &transform_entries[i]; 975 | + } 976 | + // transform matrix 977 | + entry_desc.transformMatrix = instance_desc->hasTransformMatrix() ? instance_desc->transformMatrix()->Data() : nullptr; 978 | + if (instance_desc->hasTransformMatrixSize()) 979 | + entry_desc.transformMatrixSize = instance_desc->transformMatrixSize(); 980 | + // geometry container 981 | + entry_desc.geometryContainer = AsDawnType(instance_desc->geometryContainer()); 982 | + 983 | + instances[i] = entry_desc; 984 | + } 985 | + dawn_desc.instanceCount = instance_count; 986 | + dawn_desc.instances = instance_count > 0 ? instances.get() : nullptr; 987 | + 988 | + return MakeGarbageCollected( 989 | + device, 990 | + device->GetProcs().deviceCreateRayTracingAccelerationContainer(device->GetHandle(), &dawn_desc)); 991 | + } 992 | + 993 | + GPURayTracingAccelerationContainer::GPURayTracingAccelerationContainer(GPUDevice* device, WGPURayTracingAccelerationContainer acceleration_container) 994 | + : DawnObject(device, acceleration_container) {} 995 | + 996 | + GPURayTracingAccelerationContainer::~GPURayTracingAccelerationContainer() { 997 | + if (IsDawnControlClientDestroyed()) { 998 | + return; 999 | + } 1000 | + GetProcs().rayTracingAccelerationContainerRelease(GetHandle()); 1001 | + } 1002 | + 1003 | + void GPURayTracingAccelerationContainer::updateInstance( 1004 | + uint32_t instance_index, const GPURayTracingAccelerationInstanceDescriptor* webgpu_desc) { 1005 | + 1006 | + std::unique_ptr translation_entries(new WGPUTransform3DDescriptor[1]()); 1007 | + std::unique_ptr rotation_entries(new WGPUTransform3DDescriptor[1]()); 1008 | + std::unique_ptr scale_entries(new WGPUTransform3DDescriptor[1]()); 1009 | + std::unique_ptr transform_entries(new WGPURayTracingAccelerationInstanceTransformDescriptor[1]()); 1010 | + 1011 | + WGPURayTracingAccelerationInstanceDescriptor dawn_desc = {}; 1012 | + // usage 1013 | + if (webgpu_desc->hasUsage()) 1014 | + dawn_desc.usage = static_cast(webgpu_desc->usage()); 1015 | + // mask 1016 | + if (webgpu_desc->hasMask()) 1017 | + dawn_desc.mask = webgpu_desc->mask(); 1018 | + // instanceId 1019 | + if (webgpu_desc->hasInstanceId()) 1020 | + dawn_desc.instanceId = webgpu_desc->instanceId(); 1021 | + // instanceOffset 1022 | + if (webgpu_desc->hasInstanceOffset()) 1023 | + dawn_desc.instanceOffset = webgpu_desc->instanceOffset(); 1024 | + // transform 1025 | + if (webgpu_desc->hasTransform()) { 1026 | + if (webgpu_desc->transform()->hasTranslation()) { 1027 | + translation_entries[0].x = webgpu_desc->transform()->translation()->hasX() ? webgpu_desc->transform()->translation()->x() : 0; 1028 | + translation_entries[0].y = webgpu_desc->transform()->translation()->hasY() ? webgpu_desc->transform()->translation()->y() : 0; 1029 | + translation_entries[0].z = webgpu_desc->transform()->translation()->hasZ() ? webgpu_desc->transform()->translation()->z() : 0; 1030 | + } 1031 | + if (webgpu_desc->transform()->hasRotation()) { 1032 | + rotation_entries[0].x = webgpu_desc->transform()->rotation()->hasX() ? webgpu_desc->transform()->rotation()->x() : 0; 1033 | + rotation_entries[0].y = webgpu_desc->transform()->rotation()->hasY() ? webgpu_desc->transform()->rotation()->y() : 0; 1034 | + rotation_entries[0].z = webgpu_desc->transform()->rotation()->hasZ() ? webgpu_desc->transform()->rotation()->z() : 0; 1035 | + } 1036 | + if (webgpu_desc->transform()->hasScale()) { 1037 | + scale_entries[0].x = webgpu_desc->transform()->scale()->hasX() ? webgpu_desc->transform()->scale()->x() : 0; 1038 | + scale_entries[0].y = webgpu_desc->transform()->scale()->hasY() ? webgpu_desc->transform()->scale()->y() : 0; 1039 | + scale_entries[0].z = webgpu_desc->transform()->scale()->hasZ() ? webgpu_desc->transform()->scale()->z() : 0; 1040 | + } 1041 | + transform_entries[0].translation = &translation_entries[0]; 1042 | + transform_entries[0].rotation = &rotation_entries[0]; 1043 | + transform_entries[0].scale = &scale_entries[0]; 1044 | + dawn_desc.transform = &transform_entries[0]; 1045 | + } 1046 | + // transform matrix 1047 | + dawn_desc.transformMatrix = webgpu_desc->hasTransformMatrix() ? webgpu_desc->transformMatrix()->Data() : nullptr; 1048 | + if (webgpu_desc->hasTransformMatrixSize()) 1049 | + dawn_desc.transformMatrixSize = webgpu_desc->transformMatrixSize(); 1050 | + // geometry container 1051 | + dawn_desc.geometryContainer = AsDawnType(webgpu_desc->geometryContainer()); 1052 | + 1053 | + GetProcs().rayTracingAccelerationContainerUpdateInstance(GetHandle(), instance_index, &dawn_desc); 1054 | + } 1055 | + 1056 | + void GPURayTracingAccelerationContainer::destroy() { 1057 | + GetProcs().rayTracingAccelerationContainerDestroy(GetHandle()); 1058 | + } 1059 | + 1060 | +} // namespace blink 1061 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.h b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.h 1062 | new file mode 100644 1063 | index 000000000000..4ff91f85afbc 1064 | --- /dev/null 1065 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.h 1066 | @@ -0,0 +1,36 @@ 1067 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1068 | +// Use of this source code is governed by a BSD-style license that can be 1069 | +// found in the LICENSE file. 1070 | + 1071 | +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_CONTAINER_H_ 1072 | +#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_CONTAINER_H_ 1073 | + 1074 | +#include "third_party/blink/renderer/modules/webgpu/dawn_object.h" 1075 | + 1076 | +namespace blink { 1077 | + 1078 | +class ExceptionState; 1079 | +class GPURayTracingAccelerationInstanceDescriptor; 1080 | +class GPURayTracingAccelerationContainerDescriptor; 1081 | + 1082 | +class GPURayTracingAccelerationContainer : public DawnObject { 1083 | + DEFINE_WRAPPERTYPEINFO(); 1084 | + 1085 | + public: 1086 | + static GPURayTracingAccelerationContainer* Create(GPUDevice* device, 1087 | + const GPURayTracingAccelerationContainerDescriptor* webgpu_desc); 1088 | + 1089 | + explicit GPURayTracingAccelerationContainer(GPUDevice* device, WGPURayTracingAccelerationContainer acceleration_container); 1090 | + ~GPURayTracingAccelerationContainer() override; 1091 | + 1092 | + // gpu_ray_tracing_acceleration_container.idl 1093 | + void updateInstance(uint32_t instance_index, const GPURayTracingAccelerationInstanceDescriptor* webgpu_desc); 1094 | + void destroy(); 1095 | + 1096 | + private: 1097 | + DISALLOW_COPY_AND_ASSIGN(GPURayTracingAccelerationContainer); 1098 | +}; 1099 | + 1100 | +} // namespace blink 1101 | + 1102 | +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_CONTAINER_H_ 1103 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.idl 1104 | new file mode 100644 1105 | index 000000000000..3a1fdfd4e519 1106 | --- /dev/null 1107 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container.idl 1108 | @@ -0,0 +1,14 @@ 1109 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1110 | +// Use of this source code is governed by a BSD-style license that can be 1111 | +// found in the LICENSE file. 1112 | + 1113 | +// https://gpuweb.github.io/gpuweb/ 1114 | + 1115 | +[ 1116 | + Exposed(Window WebGPU, Worker WebGPU) 1117 | +] interface GPURayTracingAccelerationContainer { 1118 | + void updateInstance( 1119 | + GPUSize32 instanceOffset, 1120 | + GPURayTracingAccelerationInstanceDescriptor descriptor); 1121 | + void destroy(); 1122 | +}; 1123 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_descriptor.idl 1124 | new file mode 100644 1125 | index 000000000000..b2c0710242c2 1126 | --- /dev/null 1127 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_descriptor.idl 1128 | @@ -0,0 +1,17 @@ 1129 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1130 | +// Use of this source code is governed by a BSD-style license that can be 1131 | +// found in the LICENSE file. 1132 | + 1133 | +// https://gpuweb.github.io/gpuweb/ 1134 | + 1135 | +dictionary GPURayTracingAccelerationContainerDescriptor : GPUObjectDescriptorBase { 1136 | + GPURayTracingAccelerationContainerUsageFlags usage = 0; // GPURayTracingAccelerationContainerUsageFlags.NONE 1137 | + GPURayTracingAccelerationContainerLevel level; 1138 | + sequence geometries; 1139 | + sequence instances; 1140 | +}; 1141 | + 1142 | +enum GPURayTracingAccelerationContainerLevel { 1143 | + "bottom", 1144 | + "top" 1145 | +}; 1146 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_usage.h b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_usage.h 1147 | new file mode 100644 1148 | index 000000000000..67af6ad1fe07 1149 | --- /dev/null 1150 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_usage.h 1151 | @@ -0,0 +1,30 @@ 1152 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1153 | +// Use of this source code is governed by a BSD-style license that can be 1154 | +// found in the LICENSE file. 1155 | + 1156 | +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_CONTAINER_USAGE_H_ 1157 | +#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_CONTAINER_USAGE_H_ 1158 | + 1159 | +#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" 1160 | + 1161 | +namespace blink { 1162 | + 1163 | +class GPURayTracingAccelerationContainerUsage : public ScriptWrappable { 1164 | + DEFINE_WRAPPERTYPEINFO(); 1165 | + 1166 | + public: 1167 | + // gpu_ray_tracing_acceleration_container_usage.idl 1168 | + static constexpr uint32_t kNone = 0; 1169 | + static constexpr uint32_t kAllowUpdate = 1; 1170 | + static constexpr uint32_t kPreferFastTrace = 2; 1171 | + static constexpr uint32_t kPreferFastBuild = 4; 1172 | + static constexpr uint32_t kLowMemory = 8; 1173 | + 1174 | + private: 1175 | + DISALLOW_COPY_AND_ASSIGN(GPURayTracingAccelerationContainerUsage); 1176 | +}; 1177 | + 1178 | +} // namespace blink 1179 | + 1180 | +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_CONTAINER_USAGE_H_ 1181 | + 1182 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_usage.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_usage.idl 1183 | new file mode 100644 1184 | index 000000000000..64ef41b44b77 1185 | --- /dev/null 1186 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_container_usage.idl 1187 | @@ -0,0 +1,16 @@ 1188 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1189 | +// Use of this source code is governed by a BSD-style license that can be 1190 | +// found in the LICENSE file. 1191 | + 1192 | +// https://gpuweb.github.io/gpuweb/ 1193 | + 1194 | +typedef [EnforceRange] unsigned long GPURayTracingAccelerationContainerUsageFlags; 1195 | +[ 1196 | + Exposed(Window WebGPU, Worker WebGPU) 1197 | +] interface GPURayTracingAccelerationContainerUsage { 1198 | + const unsigned long NONE = 0; 1199 | + const unsigned long ALLOW_UPDATE = 1; 1200 | + const unsigned long PREFER_FAST_TRACE = 2; 1201 | + const unsigned long PREFER_FAST_BUILD = 4; 1202 | + const unsigned long LOW_MEMORY = 8; 1203 | +}; 1204 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_aabb_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_aabb_descriptor.idl 1205 | new file mode 100644 1206 | index 000000000000..3f9ab7c75189 1207 | --- /dev/null 1208 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_aabb_descriptor.idl 1209 | @@ -0,0 +1,12 @@ 1210 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1211 | +// Use of this source code is governed by a BSD-style license that can be 1212 | +// found in the LICENSE file. 1213 | + 1214 | +// https://gpuweb.github.io/gpuweb/ 1215 | + 1216 | +dictionary GPURayTracingAccelerationGeometryAABBDescriptor { 1217 | + required GPUBuffer buffer; 1218 | + required GPUSize32 stride; 1219 | + GPUSize32 offset = 0; 1220 | + required GPUSize32 count; 1221 | +}; 1222 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_descriptor.idl 1223 | new file mode 100644 1224 | index 000000000000..d88266c37acc 1225 | --- /dev/null 1226 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_descriptor.idl 1227 | @@ -0,0 +1,18 @@ 1228 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1229 | +// Use of this source code is governed by a BSD-style license that can be 1230 | +// found in the LICENSE file. 1231 | + 1232 | +// https://gpuweb.github.io/gpuweb/ 1233 | + 1234 | +dictionary GPURayTracingAccelerationGeometryDescriptor { 1235 | + GPURayTracingAccelerationGeometryUsageFlags usage = 0; // GPURayTracingAccelerationGeometryUsageFlags.NONE 1236 | + GPURayTracingAccelerationGeometryType type; 1237 | + GPURayTracingAccelerationGeometryVertexDescriptor vertex; 1238 | + GPURayTracingAccelerationGeometryIndexDescriptor index; 1239 | + GPURayTracingAccelerationGeometryAABBDescriptor aabb; 1240 | +}; 1241 | + 1242 | +enum GPURayTracingAccelerationGeometryType { 1243 | + "triangles", 1244 | + "aabbs" 1245 | +}; 1246 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_index_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_index_descriptor.idl 1247 | new file mode 100644 1248 | index 000000000000..5457eb668baf 1249 | --- /dev/null 1250 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_index_descriptor.idl 1251 | @@ -0,0 +1,12 @@ 1252 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1253 | +// Use of this source code is governed by a BSD-style license that can be 1254 | +// found in the LICENSE file. 1255 | + 1256 | +// https://gpuweb.github.io/gpuweb/ 1257 | + 1258 | +dictionary GPURayTracingAccelerationGeometryIndexDescriptor { 1259 | + required GPUBuffer buffer; 1260 | + required GPUIndexFormat format; 1261 | + GPUSize32 offset = 0; 1262 | + required GPUSize32 count; 1263 | +}; 1264 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_usage.h b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_usage.h 1265 | new file mode 100644 1266 | index 000000000000..6b0f5c7f59bc 1267 | --- /dev/null 1268 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_usage.h 1269 | @@ -0,0 +1,28 @@ 1270 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1271 | +// Use of this source code is governed by a BSD-style license that can be 1272 | +// found in the LICENSE file. 1273 | + 1274 | +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_GEOMETRY_USAGE_H_ 1275 | +#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_GEOMETRY_USAGE_H_ 1276 | + 1277 | +#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" 1278 | + 1279 | +namespace blink { 1280 | + 1281 | +class GPURayTracingAccelerationGeometryUsage : public ScriptWrappable { 1282 | + DEFINE_WRAPPERTYPEINFO(); 1283 | + 1284 | + public: 1285 | + // gpu_ray_tracing_acceleration_geometry_usage.idl 1286 | + static constexpr uint32_t kNone = 0; 1287 | + static constexpr uint32_t kOpaque = 1; 1288 | + static constexpr uint32_t kAllowAnyHit = 2; 1289 | + 1290 | + private: 1291 | + DISALLOW_COPY_AND_ASSIGN(GPURayTracingAccelerationGeometryUsage); 1292 | +}; 1293 | + 1294 | +} // namespace blink 1295 | + 1296 | +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_GEOMETRY_USAGE_H_ 1297 | + 1298 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_usage.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_usage.idl 1299 | new file mode 100644 1300 | index 000000000000..f8f0caafb3fe 1301 | --- /dev/null 1302 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_usage.idl 1303 | @@ -0,0 +1,14 @@ 1304 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1305 | +// Use of this source code is governed by a BSD-style license that can be 1306 | +// found in the LICENSE file. 1307 | + 1308 | +// https://gpuweb.github.io/gpuweb/ 1309 | + 1310 | +typedef [EnforceRange] unsigned long GPURayTracingAccelerationGeometryUsageFlags; 1311 | +[ 1312 | + Exposed(Window WebGPU, Worker WebGPU) 1313 | +] interface GPURayTracingAccelerationGeometryUsage { 1314 | + const unsigned long NONE = 0; 1315 | + const unsigned long OPAQUE = 1; 1316 | + const unsigned long ALLOW_ANY_HIT = 2; 1317 | +}; 1318 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_vertex_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_vertex_descriptor.idl 1319 | new file mode 100644 1320 | index 000000000000..630dc67b1ff4 1321 | --- /dev/null 1322 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_geometry_vertex_descriptor.idl 1323 | @@ -0,0 +1,13 @@ 1324 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1325 | +// Use of this source code is governed by a BSD-style license that can be 1326 | +// found in the LICENSE file. 1327 | + 1328 | +// https://gpuweb.github.io/gpuweb/ 1329 | + 1330 | +dictionary GPURayTracingAccelerationGeometryVertexDescriptor { 1331 | + required GPUBuffer buffer; 1332 | + required GPUVertexFormat format; 1333 | + required GPUSize32 stride; 1334 | + GPUSize32 offset = 0; 1335 | + required GPUSize32 count; 1336 | +}; 1337 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_descriptor.idl 1338 | new file mode 100644 1339 | index 000000000000..c2763bbc5d05 1340 | --- /dev/null 1341 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_descriptor.idl 1342 | @@ -0,0 +1,16 @@ 1343 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1344 | +// Use of this source code is governed by a BSD-style license that can be 1345 | +// found in the LICENSE file. 1346 | + 1347 | +// https://gpuweb.github.io/gpuweb/ 1348 | + 1349 | +dictionary GPURayTracingAccelerationInstanceDescriptor { 1350 | + GPURayTracingAccelerationInstanceUsageFlags usage = 0; // GPURayTracingAccelerationInstanceUsageFlags.NONE 1351 | + GPUSize32 mask = 0xFF; 1352 | + GPUSize32 instanceId = 0; 1353 | + GPUSize32 instanceOffset = 0; 1354 | + GPURayTracingAccelerationInstanceTransformDescriptor transform; 1355 | + Float32Array transformMatrix; 1356 | + GPUSize32 transformMatrixSize = 12; 1357 | + required GPURayTracingAccelerationContainer geometryContainer; 1358 | +}; 1359 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_transform_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_transform_descriptor.idl 1360 | new file mode 100644 1361 | index 000000000000..90cfd4266990 1362 | --- /dev/null 1363 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_transform_descriptor.idl 1364 | @@ -0,0 +1,11 @@ 1365 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1366 | +// Use of this source code is governed by a BSD-style license that can be 1367 | +// found in the LICENSE file. 1368 | + 1369 | +// https://gpuweb.github.io/gpuweb/ 1370 | + 1371 | +dictionary GPURayTracingAccelerationInstanceTransformDescriptor { 1372 | + GPUTransform3DDescriptor translation; 1373 | + GPUTransform3DDescriptor rotation; 1374 | + GPUTransform3DDescriptor scale; 1375 | +}; 1376 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_usage.h b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_usage.h 1377 | new file mode 100644 1378 | index 000000000000..0a16e3ee3b45 1379 | --- /dev/null 1380 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_usage.h 1381 | @@ -0,0 +1,30 @@ 1382 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1383 | +// Use of this source code is governed by a BSD-style license that can be 1384 | +// found in the LICENSE file. 1385 | + 1386 | +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_INSTANCE_USAGE_H_ 1387 | +#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_INSTANCE_USAGE_H_ 1388 | + 1389 | +#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" 1390 | + 1391 | +namespace blink { 1392 | + 1393 | +class GPURayTracingAccelerationInstanceUsage : public ScriptWrappable { 1394 | + DEFINE_WRAPPERTYPEINFO(); 1395 | + 1396 | + public: 1397 | + // gpu_ray_tracing_acceleration_instance_usage.idl 1398 | + static constexpr uint32_t kNone = 0; 1399 | + static constexpr uint32_t kTriangleCullDisable = 1; 1400 | + static constexpr uint32_t kTriangleFrontCounterclockwise = 2; 1401 | + static constexpr uint32_t kForceOpaque = 4; 1402 | + static constexpr uint32_t kForceNoOpaque = 8; 1403 | + 1404 | + private: 1405 | + DISALLOW_COPY_AND_ASSIGN(GPURayTracingAccelerationInstanceUsage); 1406 | +}; 1407 | + 1408 | +} // namespace blink 1409 | + 1410 | +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_ACCELERATION_INSTANCE_USAGE_H_ 1411 | + 1412 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_usage.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_usage.idl 1413 | new file mode 100644 1414 | index 000000000000..6ccbde18fcb7 1415 | --- /dev/null 1416 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_acceleration_instance_usage.idl 1417 | @@ -0,0 +1,16 @@ 1418 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1419 | +// Use of this source code is governed by a BSD-style license that can be 1420 | +// found in the LICENSE file. 1421 | + 1422 | +// https://gpuweb.github.io/gpuweb/ 1423 | + 1424 | +typedef [EnforceRange] unsigned long GPURayTracingAccelerationInstanceUsageFlags; 1425 | +[ 1426 | + Exposed(Window WebGPU, Worker WebGPU) 1427 | +] interface GPURayTracingAccelerationInstanceUsage { 1428 | + const unsigned long NONE = 0; 1429 | + const unsigned long TRIANGLE_CULL_DISABLE = 1; 1430 | + const unsigned long TRIANGLE_FRONT_COUNTERCLOCKWISE = 2; 1431 | + const unsigned long FORCE_OPAQUE = 4; 1432 | + const unsigned long FORCE_NO_OPAQUE = 8; 1433 | +}; 1434 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_descriptor.idl 1435 | new file mode 100644 1436 | index 000000000000..e449bc46bdb0 1437 | --- /dev/null 1438 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_descriptor.idl 1439 | @@ -0,0 +1,8 @@ 1440 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1441 | +// Use of this source code is governed by a BSD-style license that can be 1442 | +// found in the LICENSE file. 1443 | + 1444 | +// https://gpuweb.github.io/gpuweb/ 1445 | + 1446 | +dictionary GPURayTracingPassDescriptor : GPUObjectDescriptorBase { 1447 | +}; 1448 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.cc b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.cc 1449 | new file mode 100644 1450 | index 000000000000..3a53b400996e 1451 | --- /dev/null 1452 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.cc 1453 | @@ -0,0 +1,93 @@ 1454 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1455 | +// Use of this source code is governed by a BSD-style license that can be 1456 | +// found in the LICENSE file. 1457 | + 1458 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.h" 1459 | + 1460 | +#include "third_party/blink/renderer/modules/webgpu/gpu_bind_group.h" 1461 | +#include "third_party/blink/renderer/modules/webgpu/gpu_buffer.h" 1462 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.h" 1463 | +#include "third_party/blink/renderer/modules/webgpu/gpu_device.h" 1464 | + 1465 | +namespace blink { 1466 | + 1467 | +GPURayTracingPassEncoder::GPURayTracingPassEncoder( 1468 | + GPUDevice* device, 1469 | + WGPURayTracingPassEncoder ray_tracing_pass_encoder) 1470 | + : DawnObject(device, ray_tracing_pass_encoder) {} 1471 | + 1472 | +GPURayTracingPassEncoder::~GPURayTracingPassEncoder() { 1473 | + if (IsDawnControlClientDestroyed()) { 1474 | + return; 1475 | + } 1476 | + GetProcs().rayTracingPassEncoderRelease(GetHandle()); 1477 | +} 1478 | + 1479 | +void GPURayTracingPassEncoder::setBindGroup( 1480 | + uint32_t index, 1481 | + GPUBindGroup* bindGroup, 1482 | + const Vector& dynamicOffsets) { 1483 | + GetProcs().rayTracingPassEncoderSetBindGroup( 1484 | + GetHandle(), index, bindGroup->GetHandle(), dynamicOffsets.size(), 1485 | + dynamicOffsets.data()); 1486 | +} 1487 | + 1488 | +void GPURayTracingPassEncoder::setBindGroup( 1489 | + uint32_t index, 1490 | + GPUBindGroup* bind_group, 1491 | + const FlexibleUint32Array& dynamic_offsets_data, 1492 | + uint64_t dynamic_offsets_data_start, 1493 | + uint32_t dynamic_offsets_data_length, 1494 | + ExceptionState& exception_state) { 1495 | + if (!ValidateSetBindGroupDynamicOffsets( 1496 | + dynamic_offsets_data, dynamic_offsets_data_start, 1497 | + dynamic_offsets_data_length, exception_state)) { 1498 | + return; 1499 | + } 1500 | + 1501 | + const uint32_t* data = 1502 | + dynamic_offsets_data.DataMaybeOnStack() + dynamic_offsets_data_start; 1503 | + 1504 | + GetProcs().rayTracingPassEncoderSetBindGroup(GetHandle(), index, 1505 | + bind_group->GetHandle(), 1506 | + dynamic_offsets_data_length, data); 1507 | +} 1508 | + 1509 | +void GPURayTracingPassEncoder::pushDebugGroup(String groupLabel) { 1510 | + GetProcs().rayTracingPassEncoderPushDebugGroup(GetHandle(), 1511 | + groupLabel.Utf8().data()); 1512 | +} 1513 | + 1514 | +void GPURayTracingPassEncoder::popDebugGroup() { 1515 | + GetProcs().rayTracingPassEncoderPopDebugGroup(GetHandle()); 1516 | +} 1517 | + 1518 | +void GPURayTracingPassEncoder::insertDebugMarker(String markerLabel) { 1519 | + GetProcs().rayTracingPassEncoderInsertDebugMarker(GetHandle(), 1520 | + markerLabel.Utf8().data()); 1521 | +} 1522 | + 1523 | +void GPURayTracingPassEncoder::setPipeline(GPURayTracingPipeline* pipeline) { 1524 | + GetProcs().rayTracingPassEncoderSetPipeline(GetHandle(), pipeline->GetHandle()); 1525 | +} 1526 | + 1527 | +void GPURayTracingPassEncoder::traceRays(uint32_t ray_generation_offset, 1528 | + uint32_t ray_hit_offset, 1529 | + uint32_t ray_miss_offset, 1530 | + uint32_t width, 1531 | + uint32_t height, 1532 | + uint32_t depth) { 1533 | + GetProcs().rayTracingPassEncoderTraceRays(GetHandle(), 1534 | + ray_generation_offset, 1535 | + ray_hit_offset, 1536 | + ray_miss_offset, 1537 | + width, 1538 | + height, 1539 | + depth); 1540 | +} 1541 | + 1542 | +void GPURayTracingPassEncoder::endPass() { 1543 | + GetProcs().rayTracingPassEncoderEndPass(GetHandle()); 1544 | +} 1545 | + 1546 | +} // namespace blink 1547 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.h b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.h 1548 | new file mode 100644 1549 | index 000000000000..0e22b16cad53 1550 | --- /dev/null 1551 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.h 1552 | @@ -0,0 +1,57 @@ 1553 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1554 | +// Use of this source code is governed by a BSD-style license that can be 1555 | +// found in the LICENSE file. 1556 | + 1557 | +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_PASS_ENCODER_H_ 1558 | +#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_PASS_ENCODER_H_ 1559 | + 1560 | +#include "third_party/blink/renderer/modules/webgpu/dawn_object.h" 1561 | +#include "third_party/blink/renderer/modules/webgpu/gpu_programmable_pass_encoder.h" 1562 | +#include "third_party/blink/renderer/platform/bindings/exception_state.h" 1563 | + 1564 | +namespace blink { 1565 | + 1566 | +class GPUBindGroup; 1567 | +class GPUBuffer; 1568 | +class GPURayTracingPipeline; 1569 | + 1570 | +class GPURayTracingPassEncoder : public DawnObject, 1571 | + public GPUProgrammablePassEncoder { 1572 | + DEFINE_WRAPPERTYPEINFO(); 1573 | + 1574 | + public: 1575 | + explicit GPURayTracingPassEncoder(GPUDevice* device, 1576 | + WGPURayTracingPassEncoder rt_pass_encoder); 1577 | + ~GPURayTracingPassEncoder() override; 1578 | + 1579 | + // gpu_ray_tracing_pass_encoder.idl 1580 | + void setBindGroup(uint32_t index, 1581 | + GPUBindGroup* bindGroup, 1582 | + const Vector& dynamicOffsets); 1583 | + void setBindGroup(uint32_t index, 1584 | + GPUBindGroup* bind_group, 1585 | + const FlexibleUint32Array& dynamic_offsets_data, 1586 | + uint64_t dynamic_offsets_data_start, 1587 | + uint32_t dynamic_offsets_data_length, 1588 | + ExceptionState& exception_state); 1589 | + void pushDebugGroup(String groupLabel); 1590 | + void popDebugGroup(); 1591 | + void insertDebugMarker(String markerLabel); 1592 | + void setPipeline(GPURayTracingPipeline* pipeline); 1593 | + 1594 | + void traceRays(uint32_t ray_generation_offset, 1595 | + uint32_t ray_hit_offset, 1596 | + uint32_t ray_miss_offset, 1597 | + uint32_t width, 1598 | + uint32_t height, 1599 | + uint32_t depth); 1600 | + 1601 | + void endPass(); 1602 | + 1603 | + private: 1604 | + DISALLOW_COPY_AND_ASSIGN(GPURayTracingPassEncoder); 1605 | +}; 1606 | + 1607 | +} // namespace blink 1608 | + 1609 | +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_PASS_ENCODER_H_ 1610 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.idl 1611 | new file mode 100644 1612 | index 000000000000..9f35b5f5d1db 1613 | --- /dev/null 1614 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pass_encoder.idl 1615 | @@ -0,0 +1,20 @@ 1616 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1617 | +// Use of this source code is governed by a BSD-style license that can be 1618 | +// found in the LICENSE file. 1619 | + 1620 | +// https://gpuweb.github.io/gpuweb/ 1621 | + 1622 | +[ 1623 | + Exposed(Window WebGPU, Worker WebGPU) 1624 | +] interface GPURayTracingPassEncoder { 1625 | + void setPipeline(GPURayTracingPipeline pipeline); 1626 | + void traceRays(GPUSize32 ray_generation_offset, 1627 | + GPUSize32 ray_hit_offset, 1628 | + GPUSize32 ray_miss_offset, 1629 | + GPUSize32 width, 1630 | + GPUSize32 height, 1631 | + optional GPUSize32 depth = 1); 1632 | + 1633 | + void endPass(); 1634 | +}; 1635 | +GPURayTracingPassEncoder includes GPUProgrammablePassEncoder; 1636 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.cc b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.cc 1637 | new file mode 100644 1638 | index 000000000000..81e17492413f 1639 | --- /dev/null 1640 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.cc 1641 | @@ -0,0 +1,67 @@ 1642 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1643 | +// Use of this source code is governed by a BSD-style license that can be 1644 | +// found in the LICENSE file. 1645 | + 1646 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.h" 1647 | + 1648 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_programmable_stage_descriptor.h" 1649 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_pipeline_descriptor.h" 1650 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_state_descriptor.h" 1651 | +#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h" 1652 | +#include "third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout.h" 1653 | +#include "third_party/blink/renderer/modules/webgpu/gpu_device.h" 1654 | +#include "third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.h" 1655 | +#include "third_party/blink/renderer/modules/webgpu/gpu_shader_module.h" 1656 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.h" 1657 | + 1658 | +namespace blink { 1659 | + 1660 | +// static 1661 | +GPURayTracingPipeline* GPURayTracingPipeline::Create( 1662 | + GPUDevice* device, 1663 | + const GPURayTracingPipelineDescriptor* webgpu_desc) { 1664 | + DCHECK(device); 1665 | + DCHECK(webgpu_desc); 1666 | + 1667 | + WGPURayTracingPipelineDescriptor dawn_desc = {}; 1668 | + if (webgpu_desc->hasLayout()) { 1669 | + dawn_desc.layout = AsDawnType(webgpu_desc->layout()); 1670 | + } 1671 | + if (webgpu_desc->hasLabel()) { 1672 | + dawn_desc.label = webgpu_desc->label().Utf8().data(); 1673 | + } 1674 | + 1675 | + WGPURayTracingStateDescriptor rt_state_desc = {}; 1676 | + rt_state_desc.shaderBindingTable = AsDawnType(webgpu_desc->rayTracingState()->shaderBindingTable()); 1677 | + if (webgpu_desc->rayTracingState()->hasMaxRecursionDepth()) 1678 | + rt_state_desc.maxRecursionDepth = webgpu_desc->rayTracingState()->maxRecursionDepth(); 1679 | + if (webgpu_desc->rayTracingState()->hasMaxPayloadSize()) 1680 | + rt_state_desc.maxPayloadSize = webgpu_desc->rayTracingState()->maxPayloadSize(); 1681 | + else 1682 | + rt_state_desc.maxPayloadSize = 0; 1683 | + 1684 | + dawn_desc.rayTracingState = &rt_state_desc; 1685 | + 1686 | + return MakeGarbageCollected( 1687 | + device, device->GetProcs().deviceCreateRayTracingPipeline( 1688 | + device->GetHandle(), &dawn_desc)); 1689 | +} 1690 | + 1691 | +GPURayTracingPipeline::GPURayTracingPipeline(GPUDevice* device, 1692 | + WGPURayTracingPipeline rt_pipeline) 1693 | + : DawnObject(device, rt_pipeline) {} 1694 | + 1695 | +GPURayTracingPipeline::~GPURayTracingPipeline() { 1696 | + if (IsDawnControlClientDestroyed()) { 1697 | + return; 1698 | + } 1699 | + GetProcs().rayTracingPipelineRelease(GetHandle()); 1700 | +} 1701 | + 1702 | +GPUBindGroupLayout* GPURayTracingPipeline::getBindGroupLayout(uint32_t index) { 1703 | + return MakeGarbageCollected( 1704 | + device_, 1705 | + GetProcs().rayTracingPipelineGetBindGroupLayout(GetHandle(), index)); 1706 | +} 1707 | + 1708 | +} // namespace blink 1709 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.h b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.h 1710 | new file mode 100644 1711 | index 000000000000..3aeb976f3e4e 1712 | --- /dev/null 1713 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.h 1714 | @@ -0,0 +1,34 @@ 1715 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1716 | +// Use of this source code is governed by a BSD-style license that can be 1717 | +// found in the LICENSE file. 1718 | + 1719 | +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_PIPELINE_H_ 1720 | +#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_PIPELINE_H_ 1721 | + 1722 | +#include "third_party/blink/renderer/modules/webgpu/dawn_object.h" 1723 | + 1724 | +namespace blink { 1725 | + 1726 | +class GPUBindGroupLayout; 1727 | +class GPURayTracingPipelineDescriptor; 1728 | + 1729 | +class GPURayTracingPipeline : public DawnObject { 1730 | + DEFINE_WRAPPERTYPEINFO(); 1731 | + 1732 | + public: 1733 | + static GPURayTracingPipeline* Create( 1734 | + GPUDevice* device, 1735 | + const GPURayTracingPipelineDescriptor* webgpu_desc); 1736 | + explicit GPURayTracingPipeline(GPUDevice* device, 1737 | + WGPURayTracingPipeline rt_pipeline); 1738 | + ~GPURayTracingPipeline() override; 1739 | + 1740 | + GPUBindGroupLayout* getBindGroupLayout(uint32_t index); 1741 | + 1742 | + private: 1743 | + DISALLOW_COPY_AND_ASSIGN(GPURayTracingPipeline); 1744 | +}; 1745 | + 1746 | +} // namespace blink 1747 | + 1748 | +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_PIPELINE_H_ 1749 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.idl 1750 | new file mode 100644 1751 | index 000000000000..273a62c592e9 1752 | --- /dev/null 1753 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline.idl 1754 | @@ -0,0 +1,11 @@ 1755 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1756 | +// Use of this source code is governed by a BSD-style license that can be 1757 | +// found in the LICENSE file. 1758 | + 1759 | +// https://gpuweb.github.io/gpuweb/ 1760 | + 1761 | +[ 1762 | + Exposed(Window WebGPU, Worker WebGPU) 1763 | +] interface GPURayTracingPipeline { 1764 | + GPUBindGroupLayout getBindGroupLayout(GPUIndex32 index); 1765 | +}; 1766 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline_descriptor.idl 1767 | new file mode 100644 1768 | index 000000000000..b1de9b95c445 1769 | --- /dev/null 1770 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_pipeline_descriptor.idl 1771 | @@ -0,0 +1,9 @@ 1772 | +// Copyright 2019 The Chromium Authors. All rights reserved. 1773 | +// Use of this source code is governed by a BSD-style license that can be 1774 | +// found in the LICENSE file. 1775 | + 1776 | +// https://gpuweb.github.io/gpuweb/ 1777 | + 1778 | +dictionary GPURayTracingPipelineDescriptor : GPUPipelineDescriptorBase { 1779 | + required GPURayTracingStateDescriptor rayTracingState; 1780 | +}; 1781 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.cc b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.cc 1782 | new file mode 100644 1783 | index 000000000000..ea092e674f35 1784 | --- /dev/null 1785 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.cc 1786 | @@ -0,0 +1,79 @@ 1787 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1788 | +// Use of this source code is governed by a BSD-style license that can be 1789 | +// found in the LICENSE file. 1790 | + 1791 | +#include "third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.h" 1792 | + 1793 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_shader_binding_table_descriptor.h" 1794 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_shader_binding_table_group_descriptor.h" 1795 | +#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_ray_tracing_shader_binding_table_stage_descriptor.h" 1796 | + 1797 | +#include "third_party/blink/renderer/modules/webgpu/gpu_shader_module.h" 1798 | +#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h" 1799 | +#include "third_party/blink/renderer/modules/webgpu/gpu_device.h" 1800 | + 1801 | +namespace blink { 1802 | + 1803 | + namespace { 1804 | + 1805 | + } // anonymous namespace 1806 | + 1807 | + // static 1808 | + GPURayTracingShaderBindingTable* GPURayTracingShaderBindingTable::Create(GPUDevice* device, 1809 | + const GPURayTracingShaderBindingTableDescriptor* webgpu_desc) { 1810 | + DCHECK(device); 1811 | + DCHECK(webgpu_desc); 1812 | + 1813 | + WGPURayTracingShaderBindingTableDescriptor dawn_desc = {}; 1814 | + 1815 | + uint32_t stage_count = webgpu_desc->hasStages() ? static_cast(webgpu_desc->stages().size()) : 0; 1816 | + std::unique_ptr stages(new WGPURayTracingShaderBindingTableStageDescriptor[stage_count]()); 1817 | + for (wtf_size_t i = 0; i < stage_count; ++i) { 1818 | + const GPURayTracingShaderBindingTableStageDescriptor* stage_desc = webgpu_desc->stages()[i].Get(); 1819 | + 1820 | + WGPURayTracingShaderBindingTableStageDescriptor entry_desc = {}; 1821 | + entry_desc.stage = static_cast(stage_desc->stage()); 1822 | + entry_desc.module = AsDawnType(stage_desc->module()); 1823 | + 1824 | + stages[i] = entry_desc; 1825 | + } 1826 | + dawn_desc.stageCount = stage_count; 1827 | + dawn_desc.stages = stage_count > 0 ? stages.get() : nullptr; 1828 | + 1829 | + uint32_t group_count = webgpu_desc->hasGroups() ? static_cast(webgpu_desc->groups().size()) : 0; 1830 | + std::unique_ptr groups(new WGPURayTracingShaderBindingTableGroupDescriptor[group_count]()); 1831 | + for (wtf_size_t i = 0; i < group_count; ++i) { 1832 | + const GPURayTracingShaderBindingTableGroupDescriptor* groups_desc = webgpu_desc->groups()[i].Get(); 1833 | + 1834 | + WGPURayTracingShaderBindingTableGroupDescriptor entry_desc = {}; 1835 | + if (groups_desc->hasType()) entry_desc.type = AsDawnEnum(groups_desc->type()); 1836 | + if (groups_desc->hasGeneralIndex()) entry_desc.generalIndex = groups_desc->generalIndex(); 1837 | + if (groups_desc->hasClosestHitIndex()) entry_desc.closestHitIndex = groups_desc->closestHitIndex(); 1838 | + if (groups_desc->hasAnyHitIndex()) entry_desc.anyHitIndex = groups_desc->anyHitIndex(); 1839 | + if (groups_desc->hasIntersectionIndex()) entry_desc.intersectionIndex = groups_desc->intersectionIndex(); 1840 | + 1841 | + groups[i] = entry_desc; 1842 | + } 1843 | + dawn_desc.groupCount = group_count; 1844 | + dawn_desc.groups = group_count > 0 ? groups.get() : nullptr; 1845 | + 1846 | + return MakeGarbageCollected( 1847 | + device, 1848 | + device->GetProcs().deviceCreateRayTracingShaderBindingTable(device->GetHandle(), &dawn_desc)); 1849 | + } 1850 | + 1851 | + GPURayTracingShaderBindingTable::GPURayTracingShaderBindingTable(GPUDevice* device, WGPURayTracingShaderBindingTable sbt) 1852 | + : DawnObject(device, sbt) {} 1853 | + 1854 | + GPURayTracingShaderBindingTable::~GPURayTracingShaderBindingTable() { 1855 | + if (IsDawnControlClientDestroyed()) { 1856 | + return; 1857 | + } 1858 | + GetProcs().rayTracingShaderBindingTableRelease(GetHandle()); 1859 | + } 1860 | + 1861 | + void GPURayTracingShaderBindingTable::destroy() { 1862 | + GetProcs().rayTracingShaderBindingTableDestroy(GetHandle()); 1863 | + } 1864 | + 1865 | +} // namespace blink 1866 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.h b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.h 1867 | new file mode 100644 1868 | index 000000000000..488d746cbc5f 1869 | --- /dev/null 1870 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.h 1871 | @@ -0,0 +1,34 @@ 1872 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1873 | +// Use of this source code is governed by a BSD-style license that can be 1874 | +// found in the LICENSE file. 1875 | + 1876 | +#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_SHADER_BINDING_TABLE_H_ 1877 | +#define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_SHADER_BINDING_TABLE_H_ 1878 | + 1879 | +#include "third_party/blink/renderer/modules/webgpu/dawn_object.h" 1880 | + 1881 | +namespace blink { 1882 | + 1883 | +class ExceptionState; 1884 | +class GPURayTracingShaderBindingTableDescriptor; 1885 | + 1886 | +class GPURayTracingShaderBindingTable : public DawnObject { 1887 | + DEFINE_WRAPPERTYPEINFO(); 1888 | + 1889 | + public: 1890 | + static GPURayTracingShaderBindingTable* Create(GPUDevice* device, 1891 | + const GPURayTracingShaderBindingTableDescriptor* webgpu_desc); 1892 | + 1893 | + explicit GPURayTracingShaderBindingTable(GPUDevice* device, WGPURayTracingShaderBindingTable sbt); 1894 | + ~GPURayTracingShaderBindingTable() override; 1895 | + 1896 | + // gpu_ray_tracing_shader_binding_table.idl 1897 | + void destroy(); 1898 | + 1899 | + private: 1900 | + DISALLOW_COPY_AND_ASSIGN(GPURayTracingShaderBindingTable); 1901 | +}; 1902 | + 1903 | +} // namespace blink 1904 | + 1905 | +#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RAY_TRACING_SHADER_BINDING_TABLE_H_ 1906 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.idl 1907 | new file mode 100644 1908 | index 000000000000..f310c59daa93 1909 | --- /dev/null 1910 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table.idl 1911 | @@ -0,0 +1,11 @@ 1912 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1913 | +// Use of this source code is governed by a BSD-style license that can be 1914 | +// found in the LICENSE file. 1915 | + 1916 | +// https://gpuweb.github.io/gpuweb/ 1917 | + 1918 | +[ 1919 | + Exposed(Window WebGPU, Worker WebGPU) 1920 | +] interface GPURayTracingShaderBindingTable { 1921 | + void destroy(); 1922 | +}; 1923 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_descriptor.idl 1924 | new file mode 100644 1925 | index 000000000000..9e3f62d3326a 1926 | --- /dev/null 1927 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_descriptor.idl 1928 | @@ -0,0 +1,10 @@ 1929 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1930 | +// Use of this source code is governed by a BSD-style license that can be 1931 | +// found in the LICENSE file. 1932 | + 1933 | +// https://gpuweb.github.io/gpuweb/ 1934 | + 1935 | +dictionary GPURayTracingShaderBindingTableDescriptor { 1936 | + required sequence stages; 1937 | + required sequence groups; 1938 | +}; 1939 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_group_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_group_descriptor.idl 1940 | new file mode 100644 1941 | index 000000000000..e5f226a1e327 1942 | --- /dev/null 1943 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_group_descriptor.idl 1944 | @@ -0,0 +1,19 @@ 1945 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1946 | +// Use of this source code is governed by a BSD-style license that can be 1947 | +// found in the LICENSE file. 1948 | + 1949 | +// https://gpuweb.github.io/gpuweb/ 1950 | + 1951 | +dictionary GPURayTracingShaderBindingTableGroupDescriptor { 1952 | + GPURayTracingShaderBindingTableGroupType type = "general"; 1953 | + long generalIndex = -1; 1954 | + long closestHitIndex = -1; 1955 | + long anyHitIndex = -1; 1956 | + long intersectionIndex = -1; 1957 | +}; 1958 | + 1959 | +enum GPURayTracingShaderBindingTableGroupType { 1960 | + "general", 1961 | + "triangles-hit-group", 1962 | + "procedural-hit-group" 1963 | +}; 1964 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_stage_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_stage_descriptor.idl 1965 | new file mode 100644 1966 | index 000000000000..c3a0508a6ef5 1967 | --- /dev/null 1968 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_shader_binding_table_stage_descriptor.idl 1969 | @@ -0,0 +1,10 @@ 1970 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1971 | +// Use of this source code is governed by a BSD-style license that can be 1972 | +// found in the LICENSE file. 1973 | + 1974 | +// https://gpuweb.github.io/gpuweb/ 1975 | + 1976 | +dictionary GPURayTracingShaderBindingTableStageDescriptor { 1977 | + required GPUShaderStageFlags stage; 1978 | + required GPUShaderModule module; 1979 | +}; 1980 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_state_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_state_descriptor.idl 1981 | new file mode 100644 1982 | index 000000000000..1934e6fbd871 1983 | --- /dev/null 1984 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_ray_tracing_state_descriptor.idl 1985 | @@ -0,0 +1,11 @@ 1986 | +// Copyright 2020 The Chromium Authors. All rights reserved. 1987 | +// Use of this source code is governed by a BSD-style license that can be 1988 | +// found in the LICENSE file. 1989 | + 1990 | +// https://gpuweb.github.io/gpuweb/ 1991 | + 1992 | +dictionary GPURayTracingStateDescriptor { 1993 | + required GPURayTracingShaderBindingTable shaderBindingTable; 1994 | + GPUSize32 maxRecursionDepth = 1; 1995 | + GPUSize32 maxPayloadSize; 1996 | +}; 1997 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_shader_stage.h b/third_party/blink/renderer/modules/webgpu/gpu_shader_stage.h 1998 | index 07b664900f55..cdfb0c07b287 100644 1999 | --- a/third_party/blink/renderer/modules/webgpu/gpu_shader_stage.h 2000 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_shader_stage.h 2001 | @@ -17,6 +17,11 @@ class GPUShaderStage : public ScriptWrappable { 2002 | static constexpr uint32_t kVertex = 1; 2003 | static constexpr uint32_t kFragment = 2; 2004 | static constexpr uint32_t kCompute = 4; 2005 | + static constexpr uint32_t kRayGeneration = 8; 2006 | + static constexpr uint32_t kRayAnyHit = 16; 2007 | + static constexpr uint32_t kRayClosestHit = 32; 2008 | + static constexpr uint32_t kRayMiss = 64; 2009 | + static constexpr uint32_t kRayIntersection = 128; 2010 | 2011 | private: 2012 | DISALLOW_COPY_AND_ASSIGN(GPUShaderStage); 2013 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_shader_stage.idl b/third_party/blink/renderer/modules/webgpu/gpu_shader_stage.idl 2014 | index b250a67d525b..cd2d18157f19 100644 2015 | --- a/third_party/blink/renderer/modules/webgpu/gpu_shader_stage.idl 2016 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_shader_stage.idl 2017 | @@ -11,4 +11,9 @@ typedef [EnforceRange] unsigned long GPUShaderStageFlags; 2018 | const unsigned long VERTEX = 1; 2019 | const unsigned long FRAGMENT = 2; 2020 | const unsigned long COMPUTE = 4; 2021 | + const unsigned long RAY_GENERATION = 8; 2022 | + const unsigned long RAY_ANY_HIT = 16; 2023 | + const unsigned long RAY_CLOSEST_HIT = 32; 2024 | + const unsigned long RAY_MISS = 64; 2025 | + const unsigned long RAY_INTERSECTION = 128; 2026 | }; 2027 | diff --git a/third_party/blink/renderer/modules/webgpu/gpu_transform_3d_descriptor.idl b/third_party/blink/renderer/modules/webgpu/gpu_transform_3d_descriptor.idl 2028 | new file mode 100644 2029 | index 000000000000..8a9ce2e9a185 2030 | --- /dev/null 2031 | +++ b/third_party/blink/renderer/modules/webgpu/gpu_transform_3d_descriptor.idl 2032 | @@ -0,0 +1,11 @@ 2033 | +// Copyright 2020 The Chromium Authors. All rights reserved. 2034 | +// Use of this source code is governed by a BSD-style license that can be 2035 | +// found in the LICENSE file. 2036 | + 2037 | +// https://gpuweb.github.io/gpuweb/ 2038 | + 2039 | +dictionary GPUTransform3DDescriptor { 2040 | + double x = 0; 2041 | + double y = 0; 2042 | + double z = 0; 2043 | +}; 2044 | diff --git a/third_party/blink/renderer/modules/webgpu/idls.gni b/third_party/blink/renderer/modules/webgpu/idls.gni 2045 | index 04e12c9fc189..494b81db3401 100644 2046 | --- a/third_party/blink/renderer/modules/webgpu/idls.gni 2047 | +++ b/third_party/blink/renderer/modules/webgpu/idls.gni 2048 | @@ -21,6 +21,13 @@ modules_idl_files = [ 2049 | "gpu_out_of_memory_error.idl", 2050 | "gpu_pipeline_layout.idl", 2051 | "gpu_queue.idl", 2052 | + "gpu_ray_tracing_acceleration_container.idl", 2053 | + "gpu_ray_tracing_acceleration_container_usage.idl", 2054 | + "gpu_ray_tracing_acceleration_geometry_usage.idl", 2055 | + "gpu_ray_tracing_acceleration_instance_usage.idl", 2056 | + "gpu_ray_tracing_pass_encoder.idl", 2057 | + "gpu_ray_tracing_pipeline.idl", 2058 | + "gpu_ray_tracing_shader_binding_table.idl", 2059 | "gpu_render_bundle.idl", 2060 | "gpu_render_bundle_encoder.idl", 2061 | "gpu_render_pass_encoder.idl", 2062 | @@ -64,6 +71,19 @@ modules_dictionary_idl_files = [ 2063 | "gpu_pipeline_layout_descriptor.idl", 2064 | "gpu_programmable_stage_descriptor.idl", 2065 | "gpu_rasterization_state_descriptor.idl", 2066 | + "gpu_ray_tracing_acceleration_container_descriptor.idl", 2067 | + "gpu_ray_tracing_acceleration_geometry_aabb_descriptor.idl", 2068 | + "gpu_ray_tracing_acceleration_geometry_descriptor.idl", 2069 | + "gpu_ray_tracing_acceleration_geometry_index_descriptor.idl", 2070 | + "gpu_ray_tracing_acceleration_geometry_vertex_descriptor.idl", 2071 | + "gpu_ray_tracing_acceleration_instance_descriptor.idl", 2072 | + "gpu_ray_tracing_acceleration_instance_transform_descriptor.idl", 2073 | + "gpu_ray_tracing_pipeline_descriptor.idl", 2074 | + "gpu_ray_tracing_pass_descriptor.idl", 2075 | + "gpu_ray_tracing_shader_binding_table_descriptor.idl", 2076 | + "gpu_ray_tracing_shader_binding_table_group_descriptor.idl", 2077 | + "gpu_ray_tracing_shader_binding_table_stage_descriptor.idl", 2078 | + "gpu_ray_tracing_state_descriptor.idl", 2079 | "gpu_render_bundle_descriptor.idl", 2080 | "gpu_render_bundle_encoder_descriptor.idl", 2081 | "gpu_render_pass_color_attachment_descriptor.idl", 2082 | @@ -78,6 +98,7 @@ modules_dictionary_idl_files = [ 2083 | "gpu_texture_copy_view.idl", 2084 | "gpu_texture_descriptor.idl", 2085 | "gpu_texture_view_descriptor.idl", 2086 | + "gpu_transform_3d_descriptor.idl", 2087 | "gpu_uncaptured_error_event_init.idl", 2088 | "gpu_vertex_attribute_descriptor.idl", 2089 | "gpu_vertex_buffer_layout_descriptor.idl", 2090 | diff --git a/ui/gl/init/gl_initializer_win.cc b/ui/gl/init/gl_initializer_win.cc 2091 | index c62800c9973c..13eb7221264d 100644 2092 | --- a/ui/gl/init/gl_initializer_win.cc 2093 | +++ b/ui/gl/init/gl_initializer_win.cc 2094 | @@ -32,8 +32,10 @@ namespace init { 2095 | namespace { 2096 | 2097 | const wchar_t kD3DCompiler[] = L"D3DCompiler_47.dll"; 2098 | +const wchar_t kDXCompiler[] = L"dxcompiler.dll"; 2099 | +const wchar_t kDXIL[] = L"dxil.dll"; 2100 | 2101 | -bool LoadD3DXLibrary(const base::FilePath& module_path, 2102 | +bool LoadNativeLibrary(const base::FilePath& module_path, 2103 | const base::FilePath::StringType& name) { 2104 | base::NativeLibrary library = 2105 | base::LoadNativeLibrary(base::FilePath(name), nullptr); 2106 | @@ -56,7 +58,11 @@ bool InitializeStaticEGLInternal(GLImplementation implementation) { 2107 | // and if that fails, using an absolute path. This is to ensure these DLLs 2108 | // are loaded before ANGLE is loaded in case they are not in the default 2109 | // search path. 2110 | - LoadD3DXLibrary(module_path, kD3DCompiler); 2111 | + LoadNativeLibrary(module_path, kD3DCompiler); 2112 | + 2113 | + // Load DXC/DXIL 2114 | + LoadNativeLibrary(module_path, kDXCompiler); 2115 | + LoadNativeLibrary(module_path, kDXIL); 2116 | 2117 | base::FilePath gles_path; 2118 | if (implementation == kGLImplementationSwiftShaderGL) { 2119 | -- 2120 | 2.24.1.windows.2 2121 | 2122 | --------------------------------------------------------------------------------