Changeset 247675 in webkit
- Timestamp:
- Jul 21, 2019 11:31:53 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r247674 r247675 1 2019-07-21 Saam Barati <sbarati@apple.com> 2 3 [WHLSL] Return the zero-value enum in the enum-from-integer constructor when the integer is not a valid enum value 4 https://bugs.webkit.org/show_bug.cgi?id=199853 5 6 Reviewed by Dean Jackson. 7 8 * webgpu/whlsl/enum-integer-constructor-expected.txt: Added. 9 * webgpu/whlsl/enum-integer-constructor.html: Added. 10 1 11 2019-07-21 Myles C. Maxfield <mmaxfield@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r247674 r247675 1 2019-07-21 Saam Barati <sbarati@apple.com> 2 3 [WHLSL] Return the zero-value enum in the enum-from-integer constructor when the integer is not a valid enum value 4 https://bugs.webkit.org/show_bug.cgi?id=199853 5 6 Reviewed by Dean Jackson. 7 8 Test: webgpu/whlsl/enum-integer-constructor.html 9 10 * Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp: 11 (WebCore::WHLSL::Metal::writeNativeFunction): 12 1 13 2019-07-21 Myles C. Maxfield <mmaxfield@apple.com> 2 14 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp
r247468 r247675 32 32 #include "WHLSLAddressSpace.h" 33 33 #include "WHLSLArrayType.h" 34 #include "WHLSLEnumerationDefinition.h" 34 35 #include "WHLSLInferTypes.h" 35 36 #include "WHLSLIntrinsics.h" … … 124 125 StringBuilder stringBuilder; 125 126 if (nativeFunctionDeclaration.isCast()) { 126 auto metalReturnName = typeNamer.mangledNameForType(nativeFunctionDeclaration.type()); 127 auto& returnType = nativeFunctionDeclaration.type(); 128 auto metalReturnName = typeNamer.mangledNameForType(returnType); 127 129 if (!nativeFunctionDeclaration.parameters().size()) { 128 130 stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, "() {\n")); … … 135 137 136 138 ASSERT(nativeFunctionDeclaration.parameters().size() == 1); 137 auto metalParameterName = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[0]->type()); 139 auto& parameterType = *nativeFunctionDeclaration.parameters()[0]->type(); 140 auto metalParameterName = typeNamer.mangledNameForType(parameterType); 138 141 stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, '(', metalParameterName, " x) {\n")); 142 143 { 144 auto isEnumerationDefinition = [] (auto& type) { 145 return is<AST::NamedType>(type) && is<AST::EnumerationDefinition>(downcast<AST::NamedType>(type)); 146 }; 147 auto& unifiedReturnType = returnType.unifyNode(); 148 if (isEnumerationDefinition(unifiedReturnType) && !isEnumerationDefinition(parameterType.unifyNode())) { 149 auto& enumerationDefinition = downcast<AST::EnumerationDefinition>(downcast<AST::NamedType>(unifiedReturnType)); 150 stringBuilder.append(" switch (x) {\n"); 151 bool hasZeroCase = false; 152 for (auto& member : enumerationDefinition.enumerationMembers()) { 153 hasZeroCase |= !member.get().value(); 154 stringBuilder.append(makeString(" case ", member.get().value(), ": break;\n")); 155 } 156 ASSERT_UNUSED(hasZeroCase, hasZeroCase); 157 stringBuilder.append(" default: x = 0; break; }\n"); 158 } 159 } 160 139 161 stringBuilder.append(makeString(" return static_cast<", metalReturnName, ">(x);\n")); 140 162 stringBuilder.append("}\n");
Note: See TracChangeset
for help on using the changeset viewer.