Changeset 249214 in webkit
- Timestamp:
- Aug 28, 2019 12:46:36 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r249212 r249214 1 2019-08-28 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [WHLSL] Matrices need to have correct alignment 4 https://bugs.webkit.org/show_bug.cgi?id=201212 5 6 Reviewed by Robin Morisset. 7 8 Test the alignment and size of float matrices. 9 10 Intentionally don't test bool matrices, because they can't be placed in buffers, 11 meaning their size and alignment is unobservable. 12 13 * webgpu/whlsl/matrix-alignment-expected.txt: Added. 14 * webgpu/whlsl/matrix-alignment.html: Added. 15 1 16 2019-08-28 Rob Buis <rbuis@igalia.com> 2 17 -
trunk/Source/WebCore/ChangeLog
r249212 r249214 1 2019-08-28 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [WHLSL] Matrices need to have correct alignment 4 https://bugs.webkit.org/show_bug.cgi?id=201212 5 6 Reviewed by Robin Morisset. 7 8 Matrices have particular alignment requirements and size requirements. 9 10 Type | Alignment | Size 11 --------------------------- 12 float2x2 | 8 | 16 13 float2x3 | 16 | 32 14 float2x4 | 16 | 32 15 float3x2 | 8 | 24 16 float3x3 | 16 | 48 17 float3x4 | 16 | 48 18 float4x2 | 8 | 32 19 float4x3 | 16 | 64 20 float4x4 | 16 | 64 21 22 These are important because they may be a member of a struct, and we don't want to misplace 23 every successive item in the struct. 24 25 Test: webgpu/whlsl/matrix-alignment.html 26 27 * Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp: 28 (WebCore::WHLSL::Metal::writeNativeType): 29 1 30 2019-08-28 Rob Buis <rbuis@igalia.com> 2 31 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp
r248795 r249214 38 38 39 39 namespace Metal { 40 41 enum class MatrixType : uint8_t { 42 Float, 43 Bool 44 }; 40 45 41 46 String writeNativeType(AST::NativeTypeDeclaration& nativeTypeDeclaration) … … 97 102 auto& namedType = downcast<AST::NamedType>(unifyNode); 98 103 auto& parameterType = downcast<AST::NativeTypeDeclaration>(namedType); 99 auto prefix = ([&]() -> String{104 auto matrixType = ([&]() -> MatrixType { 100 105 if (parameterType.name() == "bool") 101 return "bool";106 return MatrixType::Bool; 102 107 ASSERT(parameterType.name() == "float"); 103 return "float";108 return MatrixType::Float; 104 109 })(); 105 110 … … 115 120 unsigned columns = integerLiteral2.value(); 116 121 ASSERT(columns == 2 || columns == 3 || columns == 4); 117 return makeString("array<", prefix, ", ", columns * rows, ">"); 122 123 switch (matrixType) { 124 case MatrixType::Float: { 125 unsigned alignment = columns == 2 ? 8 : 16; 126 if (columns == 3) 127 columns = 4; 128 return makeString("array<float, ", columns * rows, "> __attribute__((aligned(", alignment, ")))"); 129 } 130 case MatrixType::Bool: 131 return makeString("array<bool, ", columns * rows, ">"); 132 } 118 133 } 119 134 ASSERT(nativeTypeDeclaration.typeArguments().size() == 1);
Note: See TracChangeset
for help on using the changeset viewer.