Hash :
4eb4165b
Author :
Date :
2025-03-07T10:24:05
Roll third_party/dawn/ 8119dbd27..7a8946456 (244 commits; 3 trivial rolls) Need https://dawn-review.googlesource.com/c/dawn/+/229494 to roll https://chromium-review.googlesource.com/c/angle/angle/+/6334483 vulkan_platform.h:152:9: error: 'VK_USE_PLATFORM_XLIB_KHR' macro redefined https://dawn.googlesource.com/dawn.git/+log/8119dbd27471..7a8946456d49 $ git log 8119dbd27..7a8946456 --date=short --no-merges --format='%ad %ae %s' 2025-03-07 cwallez [tint] Add support for binding_array to the IR validator 2025-03-07 hitawala [stream] Check for size invalidity before reserving in Stream::Read 2025-03-07 cwallez Reland "[dawn] Fix detection of __builtin_assume for DAWN_ASSERT" 2025-03-06 dawn-autoroll Roll ANGLE from 99ebd28ad246 to 0cdbc7814e59 (4 revisions) 2025-03-06 jiawei.shao Remove the redefinition of dawn::native::Vulkan::ClampFragDepthArgs 2025-03-06 jiawei.shao Vulkan: Implement PreferNotUsingMappableOrUniformBufferAsStorage() 2025-03-06 rharrison [tint][ir][fuzz] Re-enable SubgroupMatrix in IR binary 2025-03-06 shrekshao [Compat] Remove suppressions for ReadOnlyDepthStencilAttachmentTests 2025-03-06 thomasanderson [X11] Don't redefine VK_USE_PLATFORM_XLIB_KHR 2025-03-06 lokokung [dawn][emscripten] Fix Emscripten bindings for compilation messages. 2025-03-06 lokokung [dawn][native] Add validation for Infinities. 2025-03-06 lokokung [dawn][headers] Update wgpu::Surface APIs to match upstream. 2025-03-06 bsheedy [tools] Convert glob to use dependency injection 2025-03-06 cwallez [dawn][native] Track the set of BGLInternal separately from BGL. 2025-03-06 amaiorano tint: make PreventInfiniteLoops count down from uint32::highest() down to 0 2025-03-06 dsinclair Revert "Vulkan: Allow setting multiple `MemoryKind` bits" 2025-03-06 ynovikov Reland "Roll reclient, siso; update related DEPS to match Chromium" 2025-03-06 dawn-autoroll Roll ANGLE from 1a0c9db3748a to 99ebd28ad246 (8 revisions) 2025-03-06 cwallez Revert "[dawn] Fix detection of __builtin_assume for DAWN_ASSERT" 2025-03-05 zhaoming.jiang Dawn: Remove adapter from shader compilation request 2025-03-05 jiawei.shao Skip the test CreateBufferOOMWithValidationError when no validation 2025-03-05 lokokung [dawn][native] Make error scopes thread local. 2025-03-05 dawn-autoroll Roll ANGLE from 6b10ae3386b7 to 1a0c9db3748a (3 revisions) 2025-03-05 mohamedkhairy0101 tint: Improve error message for module-scope function calls 2025-03-05 mohammedashraf4599 add BOM error message 2025-03-05 cwallez [dawn] Fix detection of __builtin_assume for DAWN_ASSERT 2025-03-05 cwallez [tint] Add binding_array indexing to the resolver. 2025-03-05 kylechar Add SlabAllocator::DeleteEmptySlabs() 2025-03-05 dawn-autoroll Roll ANGLE from 73992d71f9d1 to 6b10ae3386b7 (7 revisions) 2025-03-05 shrekshao Remove enabling core-features-and-limits in backends 2025-03-04 lokokung [dawn][headers] Removes default UTF16 support. 2025-03-04 lokokung Reland "[dawn][headers] Remove obsolete ifdefs." 2025-03-04 jwata build: GN builds use Siso without Reclient in tools/setup-build script 2025-03-04 jrprice [vulkan] Fix subgroup matrix config gathering 2025-03-04 dawn-autoroll Roll ANGLE from bd8bc1055ecd to 73992d71f9d1 (1 revision) 2025-03-04 chrome-branch-day Activate dawn M135 2025-03-04 beaufort.francois Remove maxInterStageShaderComponents limit 2025-03-04 beaufort.francois Refactor Bindgroup constructors 2025-03-04 cwallez [tint] Add binding_array to the resolver 2025-03-04 cwallez Revert "[dawn][headers] Remove obsolete ifdefs." 2025-03-04 lokokung [dawn][headers] Remove obsolete ifdefs. 2025-03-03 zhaoming.jiang Dawn: Cache limits in AdapterBase 2025-03-03 dawn-autoroll Roll ANGLE from 19b35fcbff31 to bd8bc1055ecd (5 revisions) 2025-03-03 lokokung [dawn][headers] Adds extension support for UTF-16 in compilation message. 2025-03-03 jrprice [spirv] Only add explicit layout decorations on types that need them 2025-03-03 kainino [emscripten] Add emsdk to DEPS for Wasm builds 2025-03-03 lokokung [dawn][wire] Adds Dawn wire invalid extension struct and handling. 2025-03-03 jrprice [dawn] Validate workgroup size for subgroup matrix 2025-03-03 jrprice [inspector] Reflect the use of a subgroup matrix 2025-03-03 jrprice [tint] Reject non-compute shaders that use subgroup matrices (...) 2025-02-18 zhjiang Dawn: Tighten the scope of ScopedTintICEHandler 2025-02-18 dawn-autoroll Roll DirectX Shader Compiler from 6b68f3b5832c to fcbd2a184294 (2 revisions) 2025-02-18 jiawei.shao Replace `PipelineCompatibilityToken(0)` with `kExplicitPCT` 2025-02-18 yulong.fs fix memory address value passed to emwgpuDelete() 2025-02-18 dsinclair [spirv-reader][ir] Implement OpConvertFToU 2025-02-18 kainino dawn::DynamicLib: Leak all DLLs on Windows ASan builds 2025-02-18 dsinclair [spirv-reader][ir] Implement ConvertFToS 2025-02-18 petermcneeley Fix for assignment outside the range of representable type 2025-02-18 kainino Refactor TINT_ASAN_ENABLED into common DAWN_ASAN_ENABLED() 2025-02-18 gman Add a trace option to the Metal Backend 2025-02-18 dawn-autoroll Roll ANGLE from ba3dcfa4670d to 8dda514cb833 (3 revisions) 2025-02-18 dsinclair Mark function unused. 2025-02-18 dawn-autoroll Roll DirectX Shader Compiler from 20950d662f4d to 6b68f3b5832c (1 revision) 2025-02-17 dawn-autoroll Roll ANGLE from e0332c861004 to ba3dcfa4670d (1 revision) 2025-02-17 dawn-autoroll Roll vulkan-deps from 2a09ac22553e to 5d08bc0b0e23 (6 revisions) 2025-02-17 yulong.fs fix buffer destroy 2025-02-17 dawn-autoroll Roll ANGLE from 51d2561b5a6b to e0332c861004 (1 revision) 2025-02-17 lehoangquyen D3D: remove dead code used by the old external image API 2025-02-16 dawn-autoroll Roll Depot Tools from 77a800d7294d to 7a0dbd207449 (59 revisions) 2025-02-16 jiawei.shao Enable creating pipeline layout with null bind group layout by default 2025-02-16 dawn-autoroll Roll vulkan-deps from 2365826a66b2 to 2a09ac22553e (1 revision) 2025-02-15 dawn-autoroll Roll vulkan-deps from cc6490ed63e7 to 2365826a66b2 (5 revisions) 2025-02-15 dawn-autoroll Roll ANGLE from bef478f54e6e to 51d2561b5a6b (2 revisions) 2025-02-15 jie.a.chen Fix CooperativeMatrix extension index 2025-02-14 dawn-autoroll Roll ANGLE from 7afa2345f8d2 to bef478f54e6e (3 revisions) 2025-02-14 dsinclair [spirv-reader][ir] Register names instead of using new 2025-02-14 dsinclair [spirv-reader][ir] Support OpBranchConditional after OpSelectionMerge 2025-02-14 dawn-autoroll Roll vulkan-deps from 5cc3a63e8fdb to cc6490ed63e7 (5 revisions) 2025-02-14 gman Emit WGSL errors as part of GPUValidationError 2025-02-14 jimblackler [Kotlin] Update template now WGPUChainedStructOut has been removed. 2025-02-14 dawn-autoroll Roll ANGLE from cd7f92e1ed57 to 7afa2345f8d2 (6 revisions) 2025-02-13 petermcneeley Substitute overrides in IR (vk) 2025-02-13 shaoboyan [Spirv] Remove clamp_frag_depth attribute in Options 2025-02-13 dsinclair [spirv-reader][ir] Handle OpBranch instruction 2025-02-13 jrprice [ir] Add builtin struct support to the protobuf 2025-02-13 rharrison [tint][ir][val] Check Samplers & Textures address space 2025-02-13 jrprice [tint] Add flag for WGSL internal structures 2025-02-13 rharrison [tint] Replace unsafe casting with shift & mask in eval.cc 2025-02-13 rharrison [tint] Narrow warning suppression in table_data.h 2025-02-13 bajones Loosen Viewport validation requirements 2025-02-13 shrekshao [Compat] Add compat-min-es31 tags in expectations 2025-02-13 gman Remove old subgroups from dawn.node 2025-02-13 dawn-autoroll Roll ANGLE from 19c5293e1347 to cd7f92e1ed57 (9 revisions) 2025-02-13 dsinclair [spirv-reader][ir] Add names for functions and function parameters. 2025-02-13 dsinclair [spirv-reader][ir] Support names. 2025-02-13 dsinclair [spirv-reader][ir] Fixup mixed sign binary methods. 2025-02-13 dawn-autoroll Roll vulkan-deps from a88fd25a6a0d to 5cc3a63e8fdb (17 revisions) 2025-02-13 dsinclair Add suppressions for compat failures. 2025-02-13 jrprice [spirv] Emit Matrix*SignedComponents operands 2025-02-13 jrprice [tint] Subgroup matrix component types do not have to match Created with: roll-dep third_party/dawn Bug: chromium:345261080 Change-Id: I9ee360934bcbd838d682ffabe5029cc7baecec9b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6333617 Commit-Queue: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711
//
// Copyright 2024 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "libANGLE/renderer/wgpu/wgpu_utils.h"
#include "libANGLE/renderer/renderer_utils.h"
#include "libANGLE/renderer/wgpu/ContextWgpu.h"
#include "libANGLE/renderer/wgpu/DisplayWgpu.h"
#include "libANGLE/renderer/wgpu/wgpu_pipeline_state.h"
namespace rx
{
namespace webgpu
{
DisplayWgpu *GetDisplay(const gl::Context *context)
{
ContextWgpu *contextWgpu = GetImpl(context);
return contextWgpu->getDisplay();
}
wgpu::Device GetDevice(const gl::Context *context)
{
DisplayWgpu *display = GetDisplay(context);
return display->getDevice();
}
wgpu::Instance GetInstance(const gl::Context *context)
{
DisplayWgpu *display = GetDisplay(context);
return display->getInstance();
}
wgpu::RenderPassColorAttachment CreateNewClearColorAttachment(wgpu::Color clearValue,
uint32_t depthSlice,
wgpu::TextureView textureView)
{
wgpu::RenderPassColorAttachment colorAttachment;
colorAttachment.view = textureView;
colorAttachment.depthSlice = depthSlice;
colorAttachment.loadOp = wgpu::LoadOp::Clear;
colorAttachment.storeOp = wgpu::StoreOp::Store;
colorAttachment.clearValue = clearValue;
return colorAttachment;
}
wgpu::RenderPassDepthStencilAttachment CreateNewDepthStencilAttachment(
float depthClearValue,
uint32_t stencilClearValue,
wgpu::TextureView textureView,
bool hasDepthValue,
bool hasStencilValue)
{
wgpu::RenderPassDepthStencilAttachment depthStencilAttachment;
depthStencilAttachment.view = textureView;
// WebGPU requires that depth/stencil attachments have a load op if the correlated ReadOnly
// value is set to false, so we make sure to set the value here to to support cases where only a
// depth or stencil mask is set.
depthStencilAttachment.depthReadOnly = !hasDepthValue;
depthStencilAttachment.stencilReadOnly = !hasStencilValue;
if (hasDepthValue)
{
depthStencilAttachment.depthLoadOp = wgpu::LoadOp::Clear;
depthStencilAttachment.depthStoreOp = wgpu::StoreOp::Store;
depthStencilAttachment.depthClearValue = depthClearValue;
}
if (hasStencilValue)
{
depthStencilAttachment.stencilLoadOp = wgpu::LoadOp::Clear;
depthStencilAttachment.stencilStoreOp = wgpu::StoreOp::Store;
depthStencilAttachment.stencilClearValue = stencilClearValue;
}
return depthStencilAttachment;
}
bool IsWgpuError(wgpu::WaitStatus waitStatus)
{
return waitStatus != wgpu::WaitStatus::Success;
}
bool IsWgpuError(wgpu::MapAsyncStatus mapAsyncStatus)
{
return mapAsyncStatus != wgpu::MapAsyncStatus::Success;
}
ClearValuesArray::ClearValuesArray() : mValues{}, mEnabled{} {}
ClearValuesArray::~ClearValuesArray() = default;
ClearValuesArray::ClearValuesArray(const ClearValuesArray &other) = default;
ClearValuesArray &ClearValuesArray::operator=(const ClearValuesArray &rhs) = default;
void ClearValuesArray::store(uint32_t index, const ClearValues &clearValues)
{
mValues[index] = clearValues;
mEnabled.set(index);
}
gl::DrawBufferMask ClearValuesArray::getColorMask() const
{
return gl::DrawBufferMask(mEnabled.bits() & kUnpackedColorBuffersMask);
}
void GenerateCaps(const wgpu::Limits &limitsWgpu,
gl::Caps *glCaps,
gl::TextureCapsMap *glTextureCapsMap,
gl::Extensions *glExtensions,
gl::Limitations *glLimitations,
egl::Caps *eglCaps,
egl::DisplayExtensions *eglExtensions,
gl::Version *maxSupportedESVersion)
{
// WebGPU does not support separate front/back stencil masks.
glLimitations->noSeparateStencilRefsAndMasks = true;
// OpenGL ES extensions
glExtensions->debugMarkerEXT = true;
glExtensions->textureUsageANGLE = true;
glExtensions->translatedShaderSourceANGLE = true;
glExtensions->vertexArrayObjectOES = true;
glExtensions->elementIndexUintOES = true;
glExtensions->textureStorageEXT = true;
glExtensions->rgb8Rgba8OES = true;
// OpenGL ES caps
glCaps->maxElementIndex = std::numeric_limits<GLuint>::max() - 1;
glCaps->max3DTextureSize = rx::LimitToInt(limitsWgpu.maxTextureDimension3D);
glCaps->max2DTextureSize = rx::LimitToInt(limitsWgpu.maxTextureDimension2D);
glCaps->maxArrayTextureLayers = rx::LimitToInt(limitsWgpu.maxTextureArrayLayers);
glCaps->maxLODBias = 0.0f;
glCaps->maxCubeMapTextureSize = rx::LimitToInt(limitsWgpu.maxTextureDimension2D);
glCaps->maxRenderbufferSize = rx::LimitToInt(limitsWgpu.maxTextureDimension2D);
glCaps->minAliasedPointSize = 1.0f;
glCaps->maxAliasedPointSize = 1.0f;
glCaps->minAliasedLineWidth = 1.0f;
glCaps->maxAliasedLineWidth = 1.0f;
// "descriptor.sampleCount must be either 1 or 4."
constexpr uint32_t kMaxSampleCount = 4;
glCaps->maxDrawBuffers = rx::LimitToInt(limitsWgpu.maxColorAttachments);
glCaps->maxFramebufferWidth = rx::LimitToInt(limitsWgpu.maxTextureDimension2D);
glCaps->maxFramebufferHeight = rx::LimitToInt(limitsWgpu.maxTextureDimension2D);
glCaps->maxFramebufferSamples = kMaxSampleCount;
glCaps->maxColorAttachments = rx::LimitToInt(limitsWgpu.maxColorAttachments);
glCaps->maxViewportWidth = rx::LimitToInt(limitsWgpu.maxTextureDimension2D);
glCaps->maxViewportHeight = glCaps->maxViewportWidth;
glCaps->maxSampleMaskWords = 1;
glCaps->maxColorTextureSamples = kMaxSampleCount;
glCaps->maxDepthTextureSamples = kMaxSampleCount;
glCaps->maxIntegerSamples = kMaxSampleCount;
glCaps->maxServerWaitTimeout = 0;
glCaps->maxVertexAttribRelativeOffset = (1u << kAttributeOffsetMaxBits) - 1;
glCaps->maxVertexAttribBindings =
rx::LimitToInt(std::min(limitsWgpu.maxVertexBuffers, limitsWgpu.maxVertexAttributes));
glCaps->maxVertexAttribStride =
rx::LimitToInt(std::min(limitsWgpu.maxVertexBufferArrayStride,
static_cast<uint32_t>(std::numeric_limits<uint16_t>::max())));
glCaps->maxElementsIndices = std::numeric_limits<GLint>::max();
glCaps->maxElementsVertices = std::numeric_limits<GLint>::max();
glCaps->vertexHighpFloat.setIEEEFloat();
glCaps->vertexMediumpFloat.setIEEEHalfFloat();
glCaps->vertexLowpFloat.setIEEEHalfFloat();
glCaps->fragmentHighpFloat.setIEEEFloat();
glCaps->fragmentMediumpFloat.setIEEEHalfFloat();
glCaps->fragmentLowpFloat.setIEEEHalfFloat();
glCaps->vertexHighpInt.setTwosComplementInt(32);
glCaps->vertexMediumpInt.setTwosComplementInt(16);
glCaps->vertexLowpInt.setTwosComplementInt(16);
glCaps->fragmentHighpInt.setTwosComplementInt(32);
glCaps->fragmentMediumpInt.setTwosComplementInt(16);
glCaps->fragmentLowpInt.setTwosComplementInt(16);
// Clamp the maxUniformBlockSize to 64KB (majority of devices support up to this size
// currently), on AMD the maxUniformBufferRange is near uint32_t max.
GLuint maxUniformBlockSize = static_cast<GLuint>(
std::min(static_cast<uint64_t>(0x10000), limitsWgpu.maxUniformBufferBindingSize));
const GLuint maxUniformVectors = maxUniformBlockSize / (sizeof(GLfloat) * 4);
const GLuint maxUniformComponents = maxUniformVectors * 4;
const int32_t maxPerStageUniformBuffers = rx::LimitToInt(
limitsWgpu.maxUniformBuffersPerShaderStage - kReservedPerStageDefaultUniformSlotCount);
// There is no additional limit to the combined number of components. We can have up to a
// maximum number of uniform buffers, each having the maximum number of components. Note that
// this limit includes both components in and out of uniform buffers.
//
// This value is limited to INT_MAX to avoid overflow when queried from glGetIntegerv().
const uint64_t maxCombinedUniformComponents =
std::min<uint64_t>(static_cast<uint64_t>(maxPerStageUniformBuffers +
kReservedPerStageDefaultUniformSlotCount) *
maxUniformComponents,
std::numeric_limits<GLint>::max());
for (gl::ShaderType shaderType : gl::AllShaderTypes())
{
glCaps->maxShaderUniformBlocks[shaderType] = maxPerStageUniformBuffers;
glCaps->maxShaderTextureImageUnits[shaderType] =
rx::LimitToInt(limitsWgpu.maxSamplersPerShaderStage);
glCaps->maxShaderStorageBlocks[shaderType] = 0;
glCaps->maxShaderUniformComponents[shaderType] = 0;
glCaps->maxShaderAtomicCounterBuffers[shaderType] = 0;
glCaps->maxShaderAtomicCounters[shaderType] = 0;
glCaps->maxShaderImageUniforms[shaderType] = 0;
glCaps->maxCombinedShaderUniformComponents[shaderType] = maxCombinedUniformComponents;
}
const GLint maxVaryingComponents = rx::LimitToInt(limitsWgpu.maxInterStageShaderVariables * 4);
glCaps->maxVertexAttributes = rx::LimitToInt(
limitsWgpu.maxVertexBuffers); // WebGPU has maxVertexBuffers and maxVertexAttributes but
// since each vertex attribute can use a unique buffer, we
// are limited by the total number of vertex buffers
glCaps->maxVertexUniformVectors =
maxUniformVectors; // Uniforms are implemented using a uniform buffer, so the max number of
// uniforms we can support is the max buffer range divided by the size
// of a single uniform (4X float).
glCaps->maxVertexOutputComponents = maxVaryingComponents;
glCaps->maxFragmentUniformVectors = maxUniformVectors;
glCaps->maxFragmentInputComponents = maxVaryingComponents;
glCaps->minProgramTextureGatherOffset = 0;
glCaps->maxProgramTextureGatherOffset = 0;
glCaps->minProgramTexelOffset = -8;
glCaps->maxProgramTexelOffset = 7;
glCaps->maxComputeWorkGroupCount = {0, 0, 0};
glCaps->maxComputeWorkGroupSize = {0, 0, 0};
glCaps->maxComputeWorkGroupInvocations = 0;
glCaps->maxComputeSharedMemorySize = 0;
// Only 2 stages (vertex+fragment) are supported.
constexpr uint32_t kShaderStageCount = 2;
glCaps->maxUniformBufferBindings = maxPerStageUniformBuffers * kShaderStageCount;
glCaps->maxUniformBlockSize = rx::LimitToInt(limitsWgpu.maxBufferSize);
glCaps->uniformBufferOffsetAlignment =
rx::LimitToInt(limitsWgpu.minUniformBufferOffsetAlignment);
glCaps->maxCombinedUniformBlocks = glCaps->maxUniformBufferBindings;
glCaps->maxVaryingComponents = maxVaryingComponents;
glCaps->maxVaryingVectors = rx::LimitToInt(limitsWgpu.maxInterStageShaderVariables);
glCaps->maxCombinedTextureImageUnits =
rx::LimitToInt(limitsWgpu.maxSamplersPerShaderStage * kShaderStageCount);
glCaps->maxCombinedShaderOutputResources = 0;
glCaps->maxUniformLocations = maxUniformVectors;
glCaps->maxAtomicCounterBufferBindings = 0;
glCaps->maxAtomicCounterBufferSize = 0;
glCaps->maxCombinedAtomicCounterBuffers = 0;
glCaps->maxCombinedAtomicCounters = 0;
glCaps->maxImageUnits = 0;
glCaps->maxCombinedImageUniforms = 0;
glCaps->maxShaderStorageBufferBindings = 0;
glCaps->maxShaderStorageBlockSize = 0;
glCaps->maxCombinedShaderStorageBlocks = 0;
glCaps->shaderStorageBufferOffsetAlignment = 0;
glCaps->maxTransformFeedbackInterleavedComponents = 0;
glCaps->maxTransformFeedbackSeparateAttributes = 0;
glCaps->maxTransformFeedbackSeparateComponents = 0;
glCaps->lineWidthGranularity = 0.0f;
glCaps->minMultisampleLineWidth = 0.0f;
glCaps->maxMultisampleLineWidth = 0.0f;
glCaps->maxTextureBufferSize = 0;
glCaps->textureBufferOffsetAlignment = 0;
glCaps->maxSamples = kMaxSampleCount;
// Max version
*maxSupportedESVersion = gl::Version(3, 2);
// OpenGL ES texture caps
InitMinimumTextureCapsMap(*maxSupportedESVersion, *glExtensions, glTextureCapsMap);
// EGL caps
eglCaps->textureNPOT = true;
// EGL extensions
eglExtensions->createContextRobustness = true;
eglExtensions->postSubBuffer = true;
eglExtensions->createContext = true;
eglExtensions->image = true;
eglExtensions->imageBase = true;
eglExtensions->glTexture2DImage = true;
eglExtensions->glTextureCubemapImage = true;
eglExtensions->glTexture3DImage = true;
eglExtensions->glRenderbufferImage = true;
eglExtensions->getAllProcAddresses = true;
eglExtensions->noConfigContext = true;
eglExtensions->directComposition = true;
eglExtensions->createContextNoError = true;
eglExtensions->createContextWebGLCompatibility = true;
eglExtensions->createContextBindGeneratesResource = true;
eglExtensions->swapBuffersWithDamage = true;
eglExtensions->pixelFormatFloat = true;
eglExtensions->surfacelessContext = true;
eglExtensions->displayTextureShareGroup = true;
eglExtensions->displaySemaphoreShareGroup = true;
eglExtensions->createContextClientArrays = true;
eglExtensions->programCacheControlANGLE = true;
eglExtensions->robustResourceInitializationANGLE = true;
}
bool IsStripPrimitiveTopology(wgpu::PrimitiveTopology topology)
{
switch (topology)
{
case wgpu::PrimitiveTopology::LineStrip:
case wgpu::PrimitiveTopology::TriangleStrip:
return true;
default:
return false;
}
}
ErrorScope::ErrorScope(wgpu::Instance instance, wgpu::Device device, wgpu::ErrorFilter errorType)
: mInstance(instance), mDevice(device)
{
mDevice.PushErrorScope(errorType);
mActive = true;
}
ErrorScope::~ErrorScope()
{
ANGLE_UNUSED_VARIABLE(PopScope(nullptr, nullptr, nullptr, 0));
}
angle::Result ErrorScope::PopScope(ContextWgpu *context,
const char *file,
const char *function,
unsigned int line)
{
if (!mActive)
{
return angle::Result::Continue;
}
mActive = false;
bool hadError = false;
wgpu::Future f = mDevice.PopErrorScope(
wgpu::CallbackMode::WaitAnyOnly,
[context, file, function, line, &hadError](wgpu::PopErrorScopeStatus status,
wgpu::ErrorType type, char const *message) {
if (type == wgpu::ErrorType::NoError)
{
return;
}
if (context)
{
ASSERT(file);
ASSERT(function);
context->handleError(GL_INVALID_OPERATION, message, file, function, line);
}
else
{
ERR() << "Unhandled WebGPU error: " << message;
}
hadError = true;
});
mInstance.WaitAny(f, -1);
return hadError ? angle::Result::Stop : angle::Result::Continue;
}
} // namespace webgpu
namespace wgpu_gl
{
gl::LevelIndex getLevelIndex(webgpu::LevelIndex levelWgpu, gl::LevelIndex baseLevel)
{
return gl::LevelIndex(levelWgpu.get() + baseLevel.get());
}
gl::Extents getExtents(wgpu::Extent3D wgpuExtent)
{
gl::Extents glExtent;
glExtent.width = wgpuExtent.width;
glExtent.height = wgpuExtent.height;
glExtent.depth = wgpuExtent.depthOrArrayLayers;
return glExtent;
}
} // namespace wgpu_gl
namespace gl_wgpu
{
webgpu::LevelIndex getLevelIndex(gl::LevelIndex levelGl, gl::LevelIndex baseLevel)
{
ASSERT(baseLevel <= levelGl);
return webgpu::LevelIndex(levelGl.get() - baseLevel.get());
}
wgpu::Extent3D getExtent3D(const gl::Extents &glExtent)
{
wgpu::Extent3D wgpuExtent;
wgpuExtent.width = glExtent.width;
wgpuExtent.height = glExtent.height;
wgpuExtent.depthOrArrayLayers = glExtent.depth;
return wgpuExtent;
}
wgpu::PrimitiveTopology GetPrimitiveTopology(gl::PrimitiveMode mode)
{
switch (mode)
{
case gl::PrimitiveMode::Points:
return wgpu::PrimitiveTopology::PointList;
case gl::PrimitiveMode::Lines:
return wgpu::PrimitiveTopology::LineList;
case gl::PrimitiveMode::LineLoop:
return wgpu::PrimitiveTopology::LineStrip; // Emulated
case gl::PrimitiveMode::LineStrip:
return wgpu::PrimitiveTopology::LineStrip;
case gl::PrimitiveMode::Triangles:
return wgpu::PrimitiveTopology::TriangleList;
case gl::PrimitiveMode::TriangleStrip:
return wgpu::PrimitiveTopology::TriangleStrip;
case gl::PrimitiveMode::TriangleFan:
UNIMPLEMENTED();
return wgpu::PrimitiveTopology::TriangleList; // Emulated
default:
UNREACHABLE();
return wgpu::PrimitiveTopology::Undefined;
}
}
wgpu::IndexFormat GetIndexFormat(gl::DrawElementsType drawElementsType)
{
switch (drawElementsType)
{
case gl::DrawElementsType::UnsignedByte:
return wgpu::IndexFormat::Uint16; // Emulated
case gl::DrawElementsType::UnsignedShort:
return wgpu::IndexFormat::Uint16;
case gl::DrawElementsType::UnsignedInt:
return wgpu::IndexFormat::Uint32;
default:
UNREACHABLE();
return wgpu::IndexFormat::Undefined;
}
}
wgpu::FrontFace GetFrontFace(GLenum frontFace)
{
switch (frontFace)
{
case GL_CW:
return wgpu::FrontFace::CW;
case GL_CCW:
return wgpu::FrontFace::CCW;
default:
UNREACHABLE();
return wgpu::FrontFace::Undefined;
}
}
wgpu::CullMode GetCullMode(gl::CullFaceMode mode, bool cullFaceEnabled)
{
if (!cullFaceEnabled)
{
return wgpu::CullMode::None;
}
switch (mode)
{
case gl::CullFaceMode::Front:
return wgpu::CullMode::Front;
case gl::CullFaceMode::Back:
return wgpu::CullMode::Back;
case gl::CullFaceMode::FrontAndBack:
UNIMPLEMENTED();
return wgpu::CullMode::None; // Emulated
default:
UNREACHABLE();
return wgpu::CullMode::None;
}
}
wgpu::ColorWriteMask GetColorWriteMask(bool r, bool g, bool b, bool a)
{
return (r ? wgpu::ColorWriteMask::Red : wgpu::ColorWriteMask::None) |
(g ? wgpu::ColorWriteMask::Green : wgpu::ColorWriteMask::None) |
(b ? wgpu::ColorWriteMask::Blue : wgpu::ColorWriteMask::None) |
(a ? wgpu::ColorWriteMask::Alpha : wgpu::ColorWriteMask::None);
}
wgpu::BlendFactor GetBlendFactor(gl::BlendFactorType blendFactor)
{
switch (blendFactor)
{
case gl::BlendFactorType::Zero:
return wgpu::BlendFactor::Zero;
case gl::BlendFactorType::One:
return wgpu::BlendFactor::One;
case gl::BlendFactorType::SrcColor:
return wgpu::BlendFactor::Src;
case gl::BlendFactorType::OneMinusSrcColor:
return wgpu::BlendFactor::OneMinusSrc;
case gl::BlendFactorType::SrcAlpha:
return wgpu::BlendFactor::SrcAlpha;
case gl::BlendFactorType::OneMinusSrcAlpha:
return wgpu::BlendFactor::OneMinusSrcAlpha;
case gl::BlendFactorType::DstAlpha:
return wgpu::BlendFactor::DstAlpha;
case gl::BlendFactorType::OneMinusDstAlpha:
return wgpu::BlendFactor::OneMinusDstAlpha;
case gl::BlendFactorType::DstColor:
return wgpu::BlendFactor::Dst;
case gl::BlendFactorType::OneMinusDstColor:
return wgpu::BlendFactor::OneMinusDst;
case gl::BlendFactorType::SrcAlphaSaturate:
return wgpu::BlendFactor::SrcAlphaSaturated;
case gl::BlendFactorType::ConstantColor:
return wgpu::BlendFactor::Constant;
case gl::BlendFactorType::OneMinusConstantColor:
return wgpu::BlendFactor::OneMinusConstant;
case gl::BlendFactorType::ConstantAlpha:
UNIMPLEMENTED();
return wgpu::BlendFactor::Undefined;
case gl::BlendFactorType::OneMinusConstantAlpha:
UNIMPLEMENTED();
return wgpu::BlendFactor::Undefined;
case gl::BlendFactorType::Src1Alpha:
return wgpu::BlendFactor::Src1Alpha;
case gl::BlendFactorType::Src1Color:
return wgpu::BlendFactor::Src1;
case gl::BlendFactorType::OneMinusSrc1Color:
return wgpu::BlendFactor::OneMinusSrc1;
case gl::BlendFactorType::OneMinusSrc1Alpha:
return wgpu::BlendFactor::OneMinusSrc1Alpha;
default:
UNREACHABLE();
return wgpu::BlendFactor::Undefined;
}
}
wgpu::BlendOperation GetBlendEquation(gl::BlendEquationType blendEquation)
{
switch (blendEquation)
{
case gl::BlendEquationType::Add:
return wgpu::BlendOperation::Add;
case gl::BlendEquationType::Min:
return wgpu::BlendOperation::Min;
case gl::BlendEquationType::Max:
return wgpu::BlendOperation::Max;
case gl::BlendEquationType::Subtract:
return wgpu::BlendOperation::Subtract;
case gl::BlendEquationType::ReverseSubtract:
return wgpu::BlendOperation::ReverseSubtract;
case gl::BlendEquationType::Multiply:
case gl::BlendEquationType::Screen:
case gl::BlendEquationType::Overlay:
case gl::BlendEquationType::Darken:
case gl::BlendEquationType::Lighten:
case gl::BlendEquationType::Colordodge:
case gl::BlendEquationType::Colorburn:
case gl::BlendEquationType::Hardlight:
case gl::BlendEquationType::Softlight:
case gl::BlendEquationType::Unused2:
case gl::BlendEquationType::Difference:
case gl::BlendEquationType::Unused3:
case gl::BlendEquationType::Exclusion:
case gl::BlendEquationType::HslHue:
case gl::BlendEquationType::HslSaturation:
case gl::BlendEquationType::HslColor:
case gl::BlendEquationType::HslLuminosity:
// EXT_blend_equation_advanced
UNIMPLEMENTED();
return wgpu::BlendOperation::Undefined;
default:
UNREACHABLE();
return wgpu::BlendOperation::Undefined;
}
}
wgpu::TextureDimension getWgpuTextureDimension(gl::TextureType glTextureType)
{
wgpu::TextureDimension dimension = {};
switch (glTextureType)
{
case gl::TextureType::_2D:
case gl::TextureType::_2DMultisample:
case gl::TextureType::Rectangle:
case gl::TextureType::External:
case gl::TextureType::Buffer:
dimension = wgpu::TextureDimension::e2D;
break;
case gl::TextureType::_2DArray:
case gl::TextureType::_2DMultisampleArray:
case gl::TextureType::_3D:
case gl::TextureType::CubeMap:
case gl::TextureType::CubeMapArray:
case gl::TextureType::VideoImage:
dimension = wgpu::TextureDimension::e3D;
break;
default:
break;
}
return dimension;
}
wgpu::CompareFunction GetCompareFunc(const GLenum glCompareFunc, bool testEnabled)
{
if (!testEnabled)
{
return wgpu::CompareFunction::Always;
}
switch (glCompareFunc)
{
case GL_NEVER:
return wgpu::CompareFunction::Never;
case GL_LESS:
return wgpu::CompareFunction::Less;
case GL_EQUAL:
return wgpu::CompareFunction::Equal;
case GL_LEQUAL:
return wgpu::CompareFunction::LessEqual;
case GL_GREATER:
return wgpu::CompareFunction::Greater;
case GL_NOTEQUAL:
return wgpu::CompareFunction::NotEqual;
case GL_GEQUAL:
return wgpu::CompareFunction::GreaterEqual;
case GL_ALWAYS:
return wgpu::CompareFunction::Always;
default:
UNREACHABLE();
return wgpu::CompareFunction::Always;
}
}
wgpu::StencilOperation getStencilOp(const GLenum glStencilOp)
{
switch (glStencilOp)
{
case GL_KEEP:
return wgpu::StencilOperation::Keep;
case GL_ZERO:
return wgpu::StencilOperation::Zero;
case GL_REPLACE:
return wgpu::StencilOperation::Replace;
case GL_INCR:
return wgpu::StencilOperation::IncrementClamp;
case GL_DECR:
return wgpu::StencilOperation::DecrementClamp;
case GL_INCR_WRAP:
return wgpu::StencilOperation::IncrementWrap;
case GL_DECR_WRAP:
return wgpu::StencilOperation::DecrementWrap;
case GL_INVERT:
return wgpu::StencilOperation::Invert;
default:
UNREACHABLE();
return wgpu::StencilOperation::Keep;
}
}
uint32_t GetFirstIndexForDrawCall(gl::DrawElementsType indexType, const void *indices)
{
const size_t indexSize = gl::GetDrawElementsTypeSize(indexType);
const uintptr_t indexBufferByteOffset = reinterpret_cast<uintptr_t>(indices);
if (indexBufferByteOffset % indexSize != 0)
{
// WebGPU only allows offsetting index buffers by multiples of the index size
UNIMPLEMENTED();
}
return static_cast<uint32_t>(indexBufferByteOffset / indexSize);
}
} // namespace gl_wgpu
} // namespace rx