[webkit-changes] [WebKit/WebKit] df5c53: [WGSL] Fix struct size and alignment calculation
Tadeu Zagallo
noreply at github.com
Mon Oct 30 03:49:55 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: df5c532cb405673cfeaabc482c8b79916c26057f
https://github.com/WebKit/WebKit/commit/df5c532cb405673cfeaabc482c8b79916c26057f
Author: Tadeu Zagallo <tzagallo at apple.com>
Date: 2023-10-30 (Mon, 30 Oct 2023)
Changed paths:
M Source/WebGPU/WGSL/AST/ASTStructure.h
M Source/WebGPU/WGSL/AST/ASTStructureMember.h
M Source/WebGPU/WGSL/AttributeValidator.cpp
M Source/WebGPU/WGSL/GlobalVariableRewriter.cpp
M Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp
M Source/WebGPU/WGSL/Types.cpp
Log Message:
-----------
[WGSL] Fix struct size and alignment calculation
https://bugs.webkit.org/show_bug.cgi?id=263767
rdar://117572287
Reviewed by Mike Wyrzykowski.
The computation was duplicated between the Struct type and code generation, but
the type version was incorrect since it didn't take into account @size and @align
attributes. Instead, move it into AttributeValidator, immediately after we validate
@size and @align attributes for all of the struct's members. This patch also keeps
track of whether or not the struct contains any members with size/align attributes
and uses this information when deciding if a struct needs to be packed. This fixes
a large number of CTS tests that were failing due to structs not being packed, which
caused them not respecting the size and alignment required by the attributes.
* Source/WebGPU/WGSL/AST/ASTStructure.h:
* Source/WebGPU/WGSL/AST/ASTStructureMember.h:
* Source/WebGPU/WGSL/AttributeValidator.cpp:
(WGSL::AttributeValidator::visit):
* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::packStructType):
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::FunctionDefinitionWriter::visit):
* Source/WebGPU/WGSL/Types.cpp:
(WGSL::Type::size const):
(WGSL::Type::alignment const):
Canonical link: https://commits.webkit.org/269928@main
More information about the webkit-changes
mailing list