Hash :
91deaea3
Author :
Date :
2025-02-13T13:57:37
Roll third_party/dawn/ 1eca38fa5..8119dbd27 (1982 commits; 30 trivial rolls) https://dawn.googlesource.com/dawn.git/+log/1eca38fa5236..8119dbd27471 $ git log 1eca38fa5..8119dbd27 --date=short --no-merges --format='%ad %ae %s' 2025-02-12 zhuangxu Set MacOS deployment target to 11.0 when building with CMake 2025-02-12 dsinclair Revert "Remove stale WebGPU Compat CTS expectations" 2025-02-12 rharrison [tint][ir][fuzz] Add missing capability to tint::hlsl::writer::IRFuzzer 2025-02-11 shrekshao [Compat] Remove gles min31 end2end suppressions 2025-02-11 shrekshao [Compat] Fix toggle string for UseBlitForRG11B10UfloatTextureCopy 2025-02-11 rharrison [tint][ir][val] Add operand and result checks for MemberBuiltinCall 2025-02-11 rharrison [tint][ir][val] Check InstructionResult->Instruction is inst 2025-02-11 jrprice [node] Support subgroupMatrixConfigs query in dawn.node 2025-02-11 jrprice [vulkan] Enable subgroup matrix feature 2025-02-11 ynovikov Remove stale WebGPU Compat CTS expectations 2025-02-11 ynovikov Remove stale WebGPU CTS expectations 2025-02-11 dawn-autoroll Roll ANGLE from e746fb068fd3 to 19c5293e1347 (5 revisions) 2025-02-11 jrprice [metal] Enable subgroup matrix feature 2025-02-11 jrprice [dawn] Add SubgroupMatrixConfigs to adapter info 2025-02-11 kylechar Skip setting Vulkan object labels 2025-02-11 dsinclair [spirv-reader][ir] Add derivative operations. 2025-02-11 lehoangquyen D3D11: skip waiting on the fence that is owned by the same queue. 2025-02-11 dawn-autoroll Roll vulkan-deps from cd5e835851d1 to a88fd25a6a0d (8 revisions) 2025-02-11 dsinclair [spirv-reader][ir] Cleanup duplicate argument code. 2025-02-11 jrprice [dawn] Add feature for subgroup matrix extension 2025-02-11 dsinclair [spirv-reader][ir] Add support for `OpAny`. 2025-02-11 dsinclair [spirv-reader][ir] Add support for `OpAll` 2025-02-11 dsinclair [spirv-reader][ir] Add support for `OpBitReverse`. 2025-02-11 cwallez [tint] Make type::BindingArray use ArrayCount 2025-02-11 rharrison [tint][ir][val] Add additional checking to builtin calls 2025-02-11 dsinclair [spirv-reader][ir] Support `OpBitFieldUExtract`. 2025-02-11 lehoangquyen D3D11: return error if D3D feature level < 11.0 2025-02-11 shaoboyan Dawn Native: Setup ClampFragDepth offset in Vulkan Backend 2025-02-10 dawn-autoroll Roll ANGLE from c4caed5f649d to e746fb068fd3 (8 revisions) 2025-02-10 gman Compat: Fixup Device Limits 2025-02-10 dsinclair [spirv-reader][ir] Support `OpBitFieldSExtract`. 2025-02-10 dsinclair [spirv-reader][ir] Support `OpBitFieldInsert`. 2025-02-10 brandon1.jones Add Missing Synchronization For D3D12 Shared Buffers 2025-02-10 ynovikov Skip more textureSample tests on WebGPU CTS compat Android 2025-02-10 cwallez [dawn][frontend] Fix error message when @group > maxBindGroups 2025-02-10 dawn-autoroll Roll SwiftShader from 5017ce3c800e to 720189cae847 (1 revision) 2025-02-10 titouan Include tint fuzzers in high-end fuzzer build. 2025-02-10 dsinclair [spirv-reader][ir] Support `OpBitCount`. 2025-02-10 dawn-autoroll Roll ANGLE from 38aa0780bb36 to c4caed5f649d (28 revisions) 2025-02-10 jrprice [spirv] Require Vulkan Memory Model when fuzzing subgroup matrices 2025-02-10 jwata infra: Add project property to $build/siso 2025-02-10 dawn-autoroll Roll vulkan-deps from b4c8dd090b72 to cd5e835851d1 (1 revision) 2025-02-09 ynovikov Skip textureSample tests on WebGPU CTS compat Android 2025-02-09 dawn-autoroll Roll vulkan-deps from dbe0a14ab512 to b4c8dd090b72 (1 revision) 2025-02-08 ynovikov Remove stale WebGPU Compat CTS expectations 2025-02-08 ynovikov Remove stale WebGPU CTS expectations 2025-02-08 ynovikov Generalize Linux NVIDIA WebGPU CTS expectation 2025-02-07 dawn-autoroll Roll vulkan-deps from c32804ca5a39 to dbe0a14ab512 (9 revisions) 2025-02-07 shrekshao [Compat] fix glsl name collisions between stages for handle 2025-02-07 shrekshao Compat suppress min es31 failure tests (...) 2024-08-15 rharrison [tint][ir][val] Improve checks on Returns 2024-08-15 petermcneeley [tint] Minor follow-up fix for insert before 2024-08-15 dawn-autoroll Roll ANGLE from 2003e06230b1 to 83ca89e58cef (6 revisions) 2024-08-15 dsinclair Allow marking expectations as INVALID. 2024-08-15 bsheedy Suppress additional Linux/NVIDIA failures 2024-08-15 chouinard Generate missing hlsl e2e tests 2024-08-15 petermcneeley [tint] MSL texture array negative integer clamp 2024-08-15 dsinclair Remove the CTS cache code 2024-08-15 amaiorano Generated missing tint e2e tests for ir.dxc.hlsl 2024-08-15 jiawei.shao Tint: Add validations on the type of `clip_distances` 2024-08-15 dawn-autoroll Roll ANGLE from 6fddb18d77a3 to 2003e06230b1 (6 revisions) 2024-08-15 jiawei.shao Tint: Add WGSL extension and built-in variable `clip_distances` 2024-08-15 jiawei.shao Remove `DeviceBase::ForceSetToggleForTesting` 2024-08-15 jiawei.shao Rename `BufferBase::GetUsage` and `BufferBase::GetUsageExternalOnly` 2024-08-15 bsheedy Suppress 16" Macbook failures 2024-08-14 rharrison [tint][ir][val] Check swizzles are well formed 2024-08-14 chouinard [tint] Implement quadSwapX, Y and Diagonal 2024-08-14 amaiorano [hlsl] Emit mip level 0 for storage textures 2024-08-14 amaiorano Regen ir.fxc.hlsl files 2024-08-14 jrprice [benchmark] Add --check-stale option 2024-08-14 dawn-autoroll Roll vulkan-deps from c297ee8a1d20 to 7660e21e64db (3 revisions) 2024-08-14 amaiorano Fix DXC roll 2024-08-14 dawn-autoroll Roll ANGLE from 5967afe70699 to 6fddb18d77a3 (3 revisions) 2024-08-14 dneto [tint] validate clamp const low <= const high when first arg is runtime-eval 2024-08-14 chouinard [tint] Implement quadBroadcast 2024-08-14 dawn-autoroll Roll ANGLE from fdd26da99a12 to 5967afe70699 (6 revisions) 2024-08-14 jrprice [benchmark][msl] Flatten bindings 2024-08-14 jrprice [benchmark] Split generated shaders into multiple lines 2024-08-14 jiawei.shao Don't check adapter nullability in the constructor of DeviceBase 2024-08-14 jrprice [benchmark] Generate map directly 2024-08-14 jrprice [benchmark] Convert SPIR-V when generating header 2024-08-14 jrprice [benchmark] Check in the generated header 2024-08-14 jrprice [benchmark] Remove spv_reader and wgsl_writer deps 2024-08-13 enga Add DeviceGetAdapter and AdapterGetInstance to client_side_commands 2024-08-13 jrprice [benchmark] Don't convert SPIR-V to WGSL at init 2024-08-13 rharrison [tint][ir][val] Check disards in validator 2024-08-13 chouinard [tint] Implement subgroupShuffleXor, Up and Down 2024-08-13 senorblanco Fix texture-only arg in combine samplers transform. 2024-08-13 jrprice [spirv] Remove ast_generate_bindings 2024-08-13 dawn-autoroll Roll vulkan-deps from 77d583f37170 to c297ee8a1d20 (3 revisions) 2024-08-13 jrprice [tint] Remove the quantizeToF16 AST polyfill 2024-08-13 jrprice [spirv] Remove AST backend 2024-08-13 jrprice [loopy] Switch to IR version of SPIR-V backend 2024-08-13 shrekshao [Compat] Use @size attribute for glsl pad struct 2024-08-13 jrprice Reland "[tint][benchmark] Generate depfile for inputs" 2024-08-13 jrprice [spirv] Move E2E expectations to default paths 2024-08-13 jrprice [spirv] Remove AST E2E expectations 2024-08-13 jrprice [tint] Only allow --use-ir with WIP IR backends 2024-08-13 dawn-autoroll Roll ANGLE from f8fc8ac36280 to fdd26da99a12 (4 revisions) 2024-08-13 dawn-autoroll Manual roll vulkan-deps from a5d4d42457c3 to 77d583f37170 (8 revisions) Created with: roll-dep third_party/dawn Bug: angleproject:396213611 Change-Id: I124bbd59dccd14d8609c37ef62ccdd4455897b2c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6270256 Auto-Submit: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Geoff Lang <geofflang@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
//
// 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_pipeline_state.h"
#include "common/aligned_memory.h"
#include "common/hash_utils.h"
#include "libANGLE/Error.h"
#include "libANGLE/renderer/wgpu/ContextWgpu.h"
#include "libANGLE/renderer/wgpu/wgpu_utils.h"
namespace rx
{
namespace webgpu
{
// Can pack the index format into 1 bit since it has 2 values and Undefined is not used.
static_assert(static_cast<uint32_t>(wgpu::IndexFormat::Uint32) == 2U,
"Max wgpu::IndexFormat is not 2");
static_assert(static_cast<uint32_t>(wgpu::IndexFormat::Undefined) == 0,
"wgpu::IndexFormat::Undefined unexpected value");
constexpr uint32_t PackIndexFormat(wgpu::IndexFormat unpackedFormat)
{
ASSERT(static_cast<uint32_t>(unpackedFormat) > 0);
return static_cast<uint32_t>(unpackedFormat) - 1;
}
constexpr wgpu::IndexFormat UnpackIndexFormat(uint32_t packedIndexFormat)
{
return static_cast<wgpu::IndexFormat>(packedIndexFormat + 1);
}
// Can pack the front face into 1 bit since it has 2 values and Undefined is not used.
static_assert(static_cast<uint32_t>(wgpu::FrontFace::CW) == 2U, "Max wgpu::FrontFace is not 2");
static_assert(static_cast<uint32_t>(wgpu::FrontFace::Undefined) == 0,
"wgpu::FrontFace::Undefined unexpected value");
constexpr uint32_t PackFrontFace(wgpu::FrontFace unpackedFrontFace)
{
ASSERT(static_cast<uint32_t>(unpackedFrontFace) > 0);
return static_cast<uint32_t>(unpackedFrontFace) - 1;
}
constexpr wgpu::FrontFace UnpackFrontFace(uint32_t packedFrontFace)
{
return static_cast<wgpu::FrontFace>(packedFrontFace + 1);
}
PackedVertexAttribute::PackedVertexAttribute()
{
memset(this, 0, sizeof(PackedVertexAttribute));
}
// GraphicsPipelineDesc implementation.
RenderPipelineDesc::RenderPipelineDesc()
{
(void)mPad0;
memset(this, 0, sizeof(RenderPipelineDesc));
}
RenderPipelineDesc::~RenderPipelineDesc() = default;
RenderPipelineDesc::RenderPipelineDesc(const RenderPipelineDesc &other)
{
*this = other;
}
RenderPipelineDesc &RenderPipelineDesc::operator=(const RenderPipelineDesc &other)
{
memcpy(this, &other, sizeof(*this));
return *this;
}
bool RenderPipelineDesc::setPrimitiveMode(gl::PrimitiveMode primitiveMode,
gl::DrawElementsType indexTypeOrInvalid)
{
bool changed = false;
wgpu::PrimitiveTopology topology = gl_wgpu::GetPrimitiveTopology(primitiveMode);
if (mPrimitiveState.topology != static_cast<uint8_t>(topology))
{
SetBitField(mPrimitiveState.topology, topology);
changed = true;
}
uint32_t indexFormat = webgpu::IsStripPrimitiveTopology(topology) &&
indexTypeOrInvalid != gl::DrawElementsType::InvalidEnum
? PackIndexFormat(gl_wgpu::GetIndexFormat(indexTypeOrInvalid))
: 0;
if (mPrimitiveState.stripIndexFormat != static_cast<uint8_t>(indexFormat))
{
SetBitField(mPrimitiveState.stripIndexFormat, indexFormat);
changed = true;
}
return changed;
}
bool RenderPipelineDesc::setBlendEnabled(size_t colorIndex, bool enabled)
{
PackedColorTargetState &colorTarget = mColorTargetStates[colorIndex];
if (colorTarget.blendEnabled == enabled)
{
return false;
}
SetBitField(colorTarget.blendEnabled, enabled);
return true;
}
bool RenderPipelineDesc::setBlendFuncs(size_t colorIndex,
wgpu::BlendFactor srcRGB,
wgpu::BlendFactor dstRGB,
wgpu::BlendFactor srcAlpha,
wgpu::BlendFactor dstAlpha)
{
bool changed = false;
PackedColorTargetState &colorTarget = mColorTargetStates[colorIndex];
if (colorTarget.colorBlendSrcFactor != static_cast<uint32_t>(srcRGB))
{
SetBitField(colorTarget.colorBlendSrcFactor, srcRGB);
changed = true;
}
if (colorTarget.colorBlendDstFactor != static_cast<uint32_t>(dstRGB))
{
SetBitField(colorTarget.colorBlendDstFactor, dstRGB);
changed = true;
}
if (colorTarget.alphaBlendSrcFactor != static_cast<uint32_t>(srcAlpha))
{
SetBitField(colorTarget.alphaBlendSrcFactor, srcAlpha);
changed = true;
}
if (colorTarget.alphaBlendDstFactor != static_cast<uint32_t>(dstAlpha))
{
SetBitField(colorTarget.alphaBlendDstFactor, dstAlpha);
changed = true;
}
return changed;
}
bool RenderPipelineDesc::setBlendEquations(size_t colorIndex,
wgpu::BlendOperation rgb,
wgpu::BlendOperation alpha)
{
bool changed = false;
PackedColorTargetState &colorTarget = mColorTargetStates[colorIndex];
if (colorTarget.colorBlendOp != static_cast<uint32_t>(rgb))
{
SetBitField(colorTarget.colorBlendOp, rgb);
changed = true;
}
if (colorTarget.alphaBlendOp != static_cast<uint32_t>(alpha))
{
SetBitField(colorTarget.alphaBlendOp, alpha);
changed = true;
}
return changed;
}
void RenderPipelineDesc::setFrontFace(GLenum frontFace)
{
SetBitField(mPrimitiveState.frontFace, PackFrontFace(gl_wgpu::GetFrontFace(frontFace)));
}
void RenderPipelineDesc::setCullMode(gl::CullFaceMode cullMode, bool cullFaceEnabled)
{
SetBitField(mPrimitiveState.cullMode, gl_wgpu::GetCullMode(cullMode, cullFaceEnabled));
}
void RenderPipelineDesc::setColorWriteMask(size_t colorIndex, bool r, bool g, bool b, bool a)
{
PackedColorTargetState &colorTarget = mColorTargetStates[colorIndex];
SetBitField(colorTarget.writeMask, gl_wgpu::GetColorWriteMask(r, g, b, a));
}
bool RenderPipelineDesc::setVertexAttribute(size_t attribIndex, PackedVertexAttribute &newAttrib)
{
PackedVertexAttribute ¤tAttrib = mVertexAttributes[attribIndex];
if (memcmp(¤tAttrib, &newAttrib, sizeof(PackedVertexAttribute)) == 0)
{
return false;
}
memcpy(¤tAttrib, &newAttrib, sizeof(PackedVertexAttribute));
return true;
}
bool RenderPipelineDesc::setColorAttachmentFormat(size_t colorIndex, wgpu::TextureFormat format)
{
if (mColorTargetStates[colorIndex].format == static_cast<uint8_t>(format))
{
return false;
}
SetBitField(mColorTargetStates[colorIndex].format, format);
return true;
}
bool RenderPipelineDesc::setDepthStencilAttachmentFormat(wgpu::TextureFormat format)
{
if (mDepthStencilState.format == static_cast<uint8_t>(format))
{
return false;
}
SetBitField(mDepthStencilState.format, format);
return true;
}
bool RenderPipelineDesc::setDepthFunc(wgpu::CompareFunction compareFunc)
{
if (mDepthStencilState.depthCompare == static_cast<uint8_t>(compareFunc))
{
return false;
}
SetBitField(mDepthStencilState.depthCompare, compareFunc);
return true;
}
bool RenderPipelineDesc::setStencilFrontFunc(wgpu::CompareFunction compareFunc)
{
if (mDepthStencilState.stencilFrontCompare == static_cast<uint8_t>(compareFunc))
{
return false;
}
SetBitField(mDepthStencilState.stencilFrontCompare, compareFunc);
return true;
}
bool RenderPipelineDesc::setStencilFrontOps(wgpu::StencilOperation failOp,
wgpu::StencilOperation depthFailOp,
wgpu::StencilOperation passOp)
{
if (mDepthStencilState.stencilFrontFailOp == static_cast<uint8_t>(failOp) &&
mDepthStencilState.stencilFrontDepthFailOp == static_cast<uint8_t>(depthFailOp) &&
mDepthStencilState.stencilFrontPassOp == static_cast<uint8_t>(passOp))
{
return false;
}
SetBitField(mDepthStencilState.stencilFrontFailOp, failOp);
SetBitField(mDepthStencilState.stencilFrontDepthFailOp, depthFailOp);
SetBitField(mDepthStencilState.stencilFrontPassOp, passOp);
return true;
}
bool RenderPipelineDesc::setStencilBackFunc(wgpu::CompareFunction compareFunc)
{
if (mDepthStencilState.stencilBackCompare == static_cast<uint8_t>(compareFunc))
{
return false;
}
SetBitField(mDepthStencilState.stencilBackCompare, compareFunc);
return true;
}
bool RenderPipelineDesc::setStencilBackOps(wgpu::StencilOperation failOp,
wgpu::StencilOperation depthFailOp,
wgpu::StencilOperation passOp)
{
if (mDepthStencilState.stencilBackFailOp == static_cast<uint8_t>(failOp) &&
mDepthStencilState.stencilBackDepthFailOp == static_cast<uint8_t>(depthFailOp) &&
mDepthStencilState.stencilBackPassOp == static_cast<uint8_t>(passOp))
{
return false;
}
SetBitField(mDepthStencilState.stencilBackFailOp, failOp);
SetBitField(mDepthStencilState.stencilBackDepthFailOp, depthFailOp);
SetBitField(mDepthStencilState.stencilBackPassOp, passOp);
return true;
}
bool RenderPipelineDesc::setStencilReadMask(uint8_t readMask)
{
if (mDepthStencilState.stencilReadMask == readMask)
{
return false;
}
mDepthStencilState.stencilReadMask = readMask;
return true;
}
bool RenderPipelineDesc::setStencilWriteMask(uint8_t writeMask)
{
if (mDepthStencilState.stencilWriteMask == writeMask)
{
return false;
}
mDepthStencilState.stencilWriteMask = writeMask;
return true;
}
size_t RenderPipelineDesc::hash() const
{
return angle::ComputeGenericHash(this, sizeof(*this));
}
angle::Result RenderPipelineDesc::createPipeline(ContextWgpu *context,
const wgpu::PipelineLayout &pipelineLayout,
const gl::ShaderMap<wgpu::ShaderModule> &shaders,
wgpu::RenderPipeline *pipelineOut) const
{
wgpu::RenderPipelineDescriptor pipelineDesc;
pipelineDesc.layout = pipelineLayout;
pipelineDesc.vertex.module = shaders[gl::ShaderType::Vertex];
pipelineDesc.vertex.entryPoint = "wgslMain";
pipelineDesc.vertex.constantCount = 0;
pipelineDesc.vertex.constants = nullptr;
pipelineDesc.vertex.bufferCount = 0;
pipelineDesc.vertex.buffers = nullptr;
pipelineDesc.primitive.topology =
static_cast<wgpu::PrimitiveTopology>(mPrimitiveState.topology);
if (webgpu::IsStripPrimitiveTopology(pipelineDesc.primitive.topology))
{
pipelineDesc.primitive.stripIndexFormat =
UnpackIndexFormat(mPrimitiveState.stripIndexFormat);
}
else
{
pipelineDesc.primitive.stripIndexFormat = wgpu::IndexFormat::Undefined;
}
pipelineDesc.primitive.frontFace = UnpackFrontFace(mPrimitiveState.frontFace);
pipelineDesc.primitive.cullMode = static_cast<wgpu::CullMode>(mPrimitiveState.cullMode);
size_t attribCount = 0;
gl::AttribArray<wgpu::VertexBufferLayout> vertexBuffers;
gl::AttribArray<wgpu::VertexAttribute> vertexAttribs;
for (PackedVertexAttribute packedAttrib : mVertexAttributes)
{
if (!packedAttrib.enabled)
{
continue;
}
wgpu::VertexAttribute &newAttribute = vertexAttribs[attribCount];
newAttribute.format = static_cast<wgpu::VertexFormat>(packedAttrib.format);
newAttribute.offset = packedAttrib.offset;
newAttribute.shaderLocation = packedAttrib.shaderLocation;
wgpu::VertexBufferLayout &newBufferLayout = vertexBuffers[attribCount];
newBufferLayout.arrayStride = packedAttrib.stride;
newBufferLayout.stepMode = wgpu::VertexStepMode::Undefined;
newBufferLayout.attributeCount = 1;
newBufferLayout.attributes = &newAttribute;
attribCount++;
}
pipelineDesc.vertex.bufferCount = attribCount;
pipelineDesc.vertex.buffers = vertexBuffers.data();
wgpu::FragmentState fragmentState;
std::array<wgpu::ColorTargetState, gl::IMPLEMENTATION_MAX_DRAW_BUFFERS> colorTargets;
std::array<wgpu::BlendState, gl::IMPLEMENTATION_MAX_DRAW_BUFFERS> blendStates;
if (shaders[gl::ShaderType::Fragment])
{
fragmentState.module = shaders[gl::ShaderType::Fragment];
fragmentState.entryPoint = "wgslMain";
fragmentState.constantCount = 0;
fragmentState.constants = nullptr;
size_t colorTargetCount = 0;
for (size_t colorTargetIndex = 0; colorTargetIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS;
++colorTargetIndex)
{
const webgpu::PackedColorTargetState &packedColorTarget =
mColorTargetStates[colorTargetIndex];
wgpu::ColorTargetState &outputColorTarget = colorTargets[colorTargetIndex];
outputColorTarget.format = static_cast<wgpu::TextureFormat>(packedColorTarget.format);
if (packedColorTarget.blendEnabled)
{
blendStates[colorTargetIndex].color.srcFactor =
static_cast<wgpu::BlendFactor>(packedColorTarget.colorBlendSrcFactor);
blendStates[colorTargetIndex].color.dstFactor =
static_cast<wgpu::BlendFactor>(packedColorTarget.colorBlendDstFactor);
blendStates[colorTargetIndex].color.operation =
static_cast<wgpu::BlendOperation>(packedColorTarget.colorBlendOp);
blendStates[colorTargetIndex].alpha.srcFactor =
static_cast<wgpu::BlendFactor>(packedColorTarget.alphaBlendSrcFactor);
blendStates[colorTargetIndex].alpha.dstFactor =
static_cast<wgpu::BlendFactor>(packedColorTarget.alphaBlendDstFactor);
blendStates[colorTargetIndex].alpha.operation =
static_cast<wgpu::BlendOperation>(packedColorTarget.alphaBlendOp);
outputColorTarget.blend = &blendStates[colorTargetIndex];
}
outputColorTarget.writeMask =
static_cast<wgpu::ColorWriteMask>(packedColorTarget.writeMask);
if (outputColorTarget.format != wgpu::TextureFormat::Undefined)
{
colorTargetCount = colorTargetIndex + 1;
}
}
fragmentState.targetCount = colorTargetCount;
fragmentState.targets = colorTargets.data();
pipelineDesc.fragment = &fragmentState;
}
wgpu::DepthStencilState depthStencilState;
if (static_cast<wgpu::TextureFormat>(mDepthStencilState.format) !=
wgpu::TextureFormat::Undefined)
{
const webgpu::PackedDepthStencilState &packedDepthStencilState = mDepthStencilState;
depthStencilState.format = static_cast<wgpu::TextureFormat>(packedDepthStencilState.format);
depthStencilState.depthWriteEnabled =
static_cast<bool>(packedDepthStencilState.depthWriteEnabled);
depthStencilState.depthCompare =
static_cast<wgpu::CompareFunction>(packedDepthStencilState.depthCompare);
depthStencilState.stencilFront.compare =
static_cast<wgpu::CompareFunction>(packedDepthStencilState.stencilFrontCompare);
depthStencilState.stencilFront.failOp =
static_cast<wgpu::StencilOperation>(packedDepthStencilState.stencilFrontFailOp);
depthStencilState.stencilFront.depthFailOp =
static_cast<wgpu::StencilOperation>(packedDepthStencilState.stencilFrontDepthFailOp);
depthStencilState.stencilFront.passOp =
static_cast<wgpu::StencilOperation>(packedDepthStencilState.stencilFrontPassOp);
depthStencilState.stencilBack.compare =
static_cast<wgpu::CompareFunction>(packedDepthStencilState.stencilBackCompare);
depthStencilState.stencilBack.failOp =
static_cast<wgpu::StencilOperation>(packedDepthStencilState.stencilBackFailOp);
depthStencilState.stencilBack.depthFailOp =
static_cast<wgpu::StencilOperation>(packedDepthStencilState.stencilBackDepthFailOp);
depthStencilState.stencilBack.passOp =
static_cast<wgpu::StencilOperation>(packedDepthStencilState.stencilBackPassOp);
depthStencilState.stencilReadMask = packedDepthStencilState.stencilReadMask;
depthStencilState.stencilWriteMask = packedDepthStencilState.stencilWriteMask;
depthStencilState.depthBias = packedDepthStencilState.depthBias;
depthStencilState.depthBiasSlopeScale = packedDepthStencilState.depthBiasSlopeScalef;
depthStencilState.depthBiasClamp = packedDepthStencilState.depthBiasClamp;
pipelineDesc.depthStencil = &depthStencilState;
}
wgpu::Device device = context->getDevice();
ANGLE_WGPU_SCOPED_DEBUG_TRY(context, *pipelineOut = device.CreateRenderPipeline(&pipelineDesc));
return angle::Result::Continue;
}
bool operator==(const RenderPipelineDesc &lhs, const RenderPipelineDesc &rhs)
{
return memcmp(&lhs, &rhs, sizeof(RenderPipelineDesc)) == 0;
}
// PipelineCache implementation.
PipelineCache::PipelineCache() = default;
PipelineCache::~PipelineCache() = default;
angle::Result PipelineCache::getRenderPipeline(ContextWgpu *context,
const RenderPipelineDesc &desc,
const wgpu::PipelineLayout &pipelineLayout,
const gl::ShaderMap<wgpu::ShaderModule> &shaders,
wgpu::RenderPipeline *pipelineOut)
{
auto iter = mRenderPipelines.find(desc);
if (iter != mRenderPipelines.end())
{
*pipelineOut = iter->second;
return angle::Result::Continue;
}
ANGLE_TRY(desc.createPipeline(context, pipelineLayout, shaders, pipelineOut));
mRenderPipelines.insert(std::make_pair(desc, *pipelineOut));
return angle::Result::Continue;
}
} // namespace webgpu
} // namespace rx