WebKit Bugzilla
Attachment 372235 Details for
Bug 198704
: [WHLSL] Hook up common texture functions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
bug-198704-20190617004542.patch (text/plain), 99.53 KB, created by
Myles C. Maxfield
on 2019-06-17 00:45:43 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2019-06-17 00:45:43 PDT
Size:
99.53 KB
patch
obsolete
>Subversion Revision: 246464 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 69ba7907a865ec3c60c3949481a99cba6b3a9ec0..9d68a33afe7f59d424257e2b68ef31df57a17f2a 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,50 @@ >+2019-06-15 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Hook up common texture functions >+ https://bugs.webkit.org/show_bug.cgi?id=198704 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests: webgpu/whlsl-textures-load.html >+ webgpu/whlsl-textures-sample.html >+ webgpu/whlsl-textures-store.html >+ >+ * Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h: >+ (WebCore::WHLSL::AST::NativeTypeDeclaration::isTextureArray const): >+ (WebCore::WHLSL::AST::NativeTypeDeclaration::isDepthTexture const): >+ (WebCore::WHLSL::AST::NativeTypeDeclaration::isWritableTexture const): >+ (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsTextureArray): >+ (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsDepthTexture): >+ (WebCore::WHLSL::AST::NativeTypeDeclaration::setIsWritableTexture): >+ * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp: >+ (WebCore::WHLSL::Metal::EntryPointScaffolding::resourceHelperTypes): >+ * Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp: >+ (WebCore::WHLSL::Metal::FunctionDefinitionWriter::visit): >+ * Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp: >+ (WebCore::WHLSL::Metal::vectorLength): >+ (WebCore::WHLSL::Metal::vectorInnerType): >+ (WebCore::WHLSL::Metal::vectorSuffix): >+ (WebCore::WHLSL::Metal::writeNativeFunction): >+ * Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp: >+ (WebCore::WHLSL::Metal::writeNativeType): >+ * Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp: >+ (WebCore::WHLSL::Intrinsics::addFullTexture): >+ (WebCore::WHLSL::Intrinsics::addDepthTexture): >+ * Modules/webgpu/WHLSL/WHLSLIntrinsics.h: >+ (WebCore::WHLSL::Intrinsics::WTF_ARRAY_LENGTH): >+ * Modules/webgpu/WHLSL/WHLSLNameResolver.cpp: >+ (WebCore::WHLSL::NameResolver::visit): >+ * Modules/webgpu/WHLSL/WHLSLNameResolver.h: >+ * Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt: >+ * platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm: >+ (WebCore::GPUBindGroup::tryCreate): >+ * platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm: >+ (WebCore::trySetFunctions): >+ * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm: >+ (WebCore::trySetFunctions): >+ * platform/graphics/gpu/cocoa/GPUTextureMetal.mm: >+ (WebCore::mtlTextureUsageForGPUTextureUsageFlags): >+ > 2019-06-15 Zalan Bujtas <zalan@apple.com> > > [LFC][MarginCollapsing] Remove redundant checks in MarginCollapse::marginBefore/AfterCollapsesWith* >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >index 3ae6ed6475b6c24880844bbfcbc26b59657d6248..75237226ed4d6312e87ff7acab3b9a18175bac36 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h >@@ -63,6 +63,9 @@ public: > bool isVector() const { return m_isVector; } > bool isMatrix() const { return m_isMatrix; } > bool isTexture() const { return m_isTexture; } >+ bool isTextureArray() const { return m_isTextureArray; } >+ bool isDepthTexture() const { return m_isDepthTexture; } >+ bool isWritableTexture() const { return m_isWritableTexture; } > bool isSigned() const { return m_isSigned; } > const std::function<bool(int)>& canRepresentInteger() const { return m_canRepresentInteger; } > const std::function<bool(unsigned)>& canRepresentUnsignedInteger() const { return m_canRepresentUnsignedInteger; } >@@ -79,6 +82,9 @@ public: > void setIsVector() { m_isVector = true; } > void setIsMatrix() { m_isMatrix = true; } > void setIsTexture() { m_isTexture = true; } >+ void setIsTextureArray() { m_isTextureArray = true; } >+ void setIsDepthTexture() { m_isDepthTexture = true; } >+ void setIsWritableTexture() { m_isWritableTexture = true; } > void setIsSigned() { m_isSigned = true; } > void setCanRepresentInteger(std::function<bool(int)>&& canRepresent) { m_canRepresentInteger = WTFMove(canRepresent); } > void setCanRepresentUnsignedInteger(std::function<bool(unsigned)>&& canRepresent) { m_canRepresentUnsignedInteger = WTFMove(canRepresent); } >@@ -104,6 +110,9 @@ private: > bool m_isVector { false }; > bool m_isMatrix { false }; > bool m_isTexture { false }; >+ bool m_isTextureArray { false }; >+ bool m_isDepthTexture { false }; >+ bool m_isWritableTexture { false }; > bool m_isSigned { false }; > }; > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp >index 01fb71e240bfa295d5486357b340959d68b9d0e9..d4de95c57dfe490ab021d8cdfa42a28eb7da4f60 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp >@@ -147,15 +147,23 @@ String EntryPointScaffolding::resourceHelperTypes() > auto iterator = m_resourceMap.find(&m_layout[i].bindings[j]); > if (iterator == m_resourceMap.end()) > continue; >- auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType; >- auto& referenceType = downcast<AST::ReferenceType>(unnamedType); >- auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType()); >- auto addressSpace = toString(referenceType.addressSpace()); >- auto elementName = m_namedBindGroups[i].namedBindings[j].elementName; >- auto index = m_namedBindGroups[i].namedBindings[j].index; >- stringBuilder.append(makeString(" ", addressSpace, " ", mangledTypeName, "* ", elementName, " [[id(", index, ")]];\n")); >- if (auto lengthInformation = m_namedBindGroups[i].namedBindings[j].lengthInformation) >- stringBuilder.append(makeString(" uint2 ", lengthInformation->elementName, " [[id(", lengthInformation->index, ")]];\n")); >+ auto& type = m_entryPointItems.inputs[iterator->value].unnamedType->unifyNode(); >+ if (is<AST::UnnamedType>(type) && is<AST::ReferenceType>(downcast<AST::UnnamedType>(type))) { >+ auto& referenceType = downcast<AST::ReferenceType>(downcast<AST::UnnamedType>(type)); >+ auto mangledTypeName = m_typeNamer.mangledNameForType(referenceType.elementType()); >+ auto addressSpace = toString(referenceType.addressSpace()); >+ auto elementName = m_namedBindGroups[i].namedBindings[j].elementName; >+ auto index = m_namedBindGroups[i].namedBindings[j].index; >+ stringBuilder.append(makeString(" ", addressSpace, " ", mangledTypeName, "* ", elementName, " [[id(", index, ")]];\n")); >+ if (auto lengthInformation = m_namedBindGroups[i].namedBindings[j].lengthInformation) >+ stringBuilder.append(makeString(" uint2 ", lengthInformation->elementName, " [[id(", lengthInformation->index, ")]];\n")); >+ } else if (is<AST::NamedType>(type) && is<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(type))) { >+ auto& namedType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(type)); >+ auto mangledTypeName = m_typeNamer.mangledNameForType(namedType); >+ auto elementName = m_namedBindGroups[i].namedBindings[j].elementName; >+ auto index = m_namedBindGroups[i].namedBindings[j].index; >+ stringBuilder.append(makeString(" ", mangledTypeName, ' ', elementName, " [[id(", index, ")]];\n")); >+ } > } > stringBuilder.append("};\n\n"); > } >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >index a416001298d5b9b9743931577c4b53dbe7fb800e..e5bc3666cb9518b588c1679a6031e42c54da2484 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp >@@ -542,7 +542,9 @@ void FunctionDefinitionWriter::visit(AST::CallExpression& callExpression) > auto iterator = m_functionMapping.find(callExpression.function()); > ASSERT(iterator != m_functionMapping.end()); > auto variableName = generateNextVariableName(); >- m_stringBuilder.append(makeString(m_typeNamer.mangledNameForType(callExpression.resolvedType()), ' ', variableName, " = ", iterator->value, '(')); >+ if (!matches(callExpression.resolvedType(), m_intrinsics.voidType())) >+ m_stringBuilder.append(makeString(m_typeNamer.mangledNameForType(callExpression.resolvedType()), ' ', variableName, " = ")); >+ m_stringBuilder.append(makeString(iterator->value, '(')); > for (size_t i = 0; i < argumentNames.size(); ++i) { > if (i) > m_stringBuilder.append(", "); >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >index aba39d5e998dc77efb86bd2e05f9c259e1a26ab9..695865856ef3df9d3f33e3b3742b11b6e96c30c9 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp >@@ -81,6 +81,42 @@ static String atomicName(String input) > return "fetch_xor"_str; > } > >+static int vectorLength(AST::NativeTypeDeclaration& nativeTypeDeclaration) >+{ >+ int vectorLength = 1; >+ if (!nativeTypeDeclaration.typeArguments().isEmpty()) { >+ ASSERT(nativeTypeDeclaration.typeArguments().size() == 2); >+ ASSERT(WTF::holds_alternative<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1])); >+ vectorLength = WTF::get<AST::ConstantExpression>(nativeTypeDeclaration.typeArguments()[1]).integerLiteral().value(); >+ } >+ return vectorLength; >+} >+ >+static AST::NamedType& vectorInnerType(AST::NativeTypeDeclaration& nativeTypeDeclaration) >+{ >+ if (nativeTypeDeclaration.typeArguments().isEmpty()) >+ return nativeTypeDeclaration; >+ >+ ASSERT(nativeTypeDeclaration.typeArguments().size() == 2); >+ ASSERT(WTF::holds_alternative<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])); >+ return WTF::get<UniqueRef<AST::TypeReference>>(nativeTypeDeclaration.typeArguments()[0])->resolvedType(); >+} >+ >+static const char* vectorSuffix(int vectorLength) >+{ >+ switch (vectorLength) { >+ case 1: >+ return ""; >+ case 2: >+ return "2"; >+ case 3: >+ return "3"; >+ default: >+ ASSERT(vectorLength == 4); >+ return "4"; >+ } >+} >+ > String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclaration, String& outputFunctionName, Intrinsics& intrinsics, TypeNamer& typeNamer, const char* memsetZeroFunctionName) > { > StringBuilder stringBuilder; >@@ -356,13 +392,67 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > } > > if (nativeFunctionDeclaration.name() == "Sample") { >- // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this >- notImplemented(); >+ ASSERT(nativeFunctionDeclaration.parameters().size() == 3 || nativeFunctionDeclaration.parameters().size() == 4); >+ >+ auto& textureType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[0]->type()->unifyNode())); >+ auto& locationType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[2]->type()->unifyNode())); >+ auto locationVectorLength = vectorLength(locationType); >+ auto& returnType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.type().unifyNode())); >+ auto returnVectorLength = vectorLength(returnType); >+ >+ auto metalParameter1Name = typeNamer.mangledNameForType(textureType); >+ auto metalParameter2Name = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[1]->type()); >+ auto metalParameter3Name = typeNamer.mangledNameForType(locationType); >+ String metalParameter4Name; >+ if (nativeFunctionDeclaration.parameters().size() == 4) >+ metalParameter4Name = typeNamer.mangledNameForType(*nativeFunctionDeclaration.parameters()[3]->type()); >+ auto metalReturnName = typeNamer.mangledNameForType(returnType); >+ stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, '(', metalParameter1Name, " theTexture, ", metalParameter2Name, " theSampler, ", metalParameter3Name, " location")); >+ if (!metalParameter4Name.isNull()) >+ stringBuilder.append(makeString(", ", metalParameter4Name, " offset")); >+ stringBuilder.append(") {\n"); >+ stringBuilder.append(" return theTexture.sample(theSampler, "); >+ if (textureType.isTextureArray()) { >+ ASSERT(locationVectorLength > 1); >+ stringBuilder.append(makeString("location.", "xyzw"_str.substring(0, locationVectorLength - 1), ", location.", "xyzw"_str.substring(locationVectorLength - 1, 1))); >+ } else >+ stringBuilder.append("location"); >+ if (!metalParameter4Name.isNull()) >+ stringBuilder.append(", offset"); >+ stringBuilder.append(")"); >+ if (!textureType.isDepthTexture()) >+ stringBuilder.append(makeString(".", "xyzw"_str.substring(0, returnVectorLength))); >+ stringBuilder.append(";\n"); >+ stringBuilder.append("}\n"); >+ return stringBuilder.toString(); > } > > if (nativeFunctionDeclaration.name() == "Load") { >- // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this >- notImplemented(); >+ ASSERT(nativeFunctionDeclaration.parameters().size() == 2); >+ >+ auto& textureType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[0]->type()->unifyNode())); >+ auto& locationType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[1]->type()->unifyNode())); >+ auto locationVectorLength = vectorLength(locationType); >+ auto& returnType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.type().unifyNode())); >+ auto returnVectorLength = vectorLength(returnType); >+ >+ auto metalParameter1Name = typeNamer.mangledNameForType(textureType); >+ auto metalParameter2Name = typeNamer.mangledNameForType(locationType); >+ auto metalReturnName = typeNamer.mangledNameForType(returnType); >+ stringBuilder.append(makeString(metalReturnName, ' ', outputFunctionName, '(', metalParameter1Name, " theTexture, ", metalParameter2Name, " location) {\n")); >+ stringBuilder.append(" return theTexture.read("); >+ // FIXME: Bounds checks >+ if (textureType.isTextureArray()) { >+ ASSERT(locationVectorLength > 1); >+ stringBuilder.append(makeString("uint", vectorSuffix(locationVectorLength - 1), "(location.", "xyzw"_str.substring(0, locationVectorLength - 1), "), uint(location.", "xyzw"_str.substring(locationVectorLength - 1, 1), ")")); >+ } else >+ stringBuilder.append(makeString("uint", vectorSuffix(locationVectorLength), "(location)")); >+ stringBuilder.append(")"); >+ if (!textureType.isDepthTexture()) >+ stringBuilder.append(makeString(".", "xyzw"_str.substring(0, returnVectorLength))); >+ stringBuilder.append(";\n"); >+ stringBuilder.append("}\n"); >+ return stringBuilder.toString(); > } > > if (nativeFunctionDeclaration.name() == "GetDimensions") { >@@ -406,8 +496,33 @@ String writeNativeFunction(AST::NativeFunctionDeclaration& nativeFunctionDeclara > } > > if (nativeFunctionDeclaration.name() == "Store") { >- // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this >- notImplemented(); >+ ASSERT(nativeFunctionDeclaration.parameters().size() == 3); >+ >+ auto& textureType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[0]->type()->unifyNode())); >+ auto& itemType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[1]->type()->unifyNode())); >+ auto& itemVectorInnerType = vectorInnerType(itemType); >+ auto itemVectorLength = vectorLength(itemType); >+ auto& locationType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[2]->type()->unifyNode())); >+ auto locationVectorLength = vectorLength(locationType); >+ >+ auto metalParameter1Name = typeNamer.mangledNameForType(textureType); >+ auto metalParameter2Name = typeNamer.mangledNameForType(itemType); >+ auto metalParameter3Name = typeNamer.mangledNameForType(locationType); >+ auto metalInnerTypeName = typeNamer.mangledNameForType(itemVectorInnerType); >+ stringBuilder.append(makeString("void ", outputFunctionName, '(', metalParameter1Name, " theTexture, ", metalParameter2Name, " item, ", metalParameter3Name, " location) {\n")); >+ // FIXME: Bounds checks >+ stringBuilder.append(makeString(" theTexture.write(vec<", metalInnerTypeName, ", 4>(item")); >+ for (int i = 0; i < 4 - itemVectorLength; ++i) >+ stringBuilder.append(", 0"); >+ stringBuilder.append("), "); >+ if (textureType.isTextureArray()) { >+ ASSERT(locationVectorLength > 1); >+ stringBuilder.append(makeString("uint", vectorSuffix(locationVectorLength - 1), "(location.", "xyzw"_str.substring(0, locationVectorLength - 1), "), uint(location.", "xyzw"_str.substring(locationVectorLength - 1, 1), ")")); >+ } else >+ stringBuilder.append(makeString("uint", vectorSuffix(locationVectorLength), "(location)")); >+ stringBuilder.append(");\n"); >+ stringBuilder.append("}\n"); >+ return stringBuilder.toString(); > } > > if (nativeFunctionDeclaration.name() == "GatherAlpha") { >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp >index f57d5c077cc4d2fd99ad1204c147c1a8d41945d3..202c1540f393546a63b3eb123c6c2cf4183dbe76 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeTypeWriter.cpp >@@ -180,12 +180,8 @@ String writeNativeType(AST::NativeTypeDeclaration& nativeTypeDeclaration) > return "texturecube"_str; > if (nativeTypeDeclaration.name() == "TextureDepth2D") > return "depth2d"_str; >- if (nativeTypeDeclaration.name() == "RWTextureDepth2D") >- return "depth2d"_str; > if (nativeTypeDeclaration.name() == "TextureDepth2DArray") > return "depth2d_array"_str; >- if (nativeTypeDeclaration.name() == "RWTextureDepth2DArray") >- return "depth2d_array"_str; > ASSERT(nativeTypeDeclaration.name() == "TextureDepthCube"); > return "depthcube"_str; > })(); >@@ -239,8 +235,13 @@ String writeNativeType(AST::NativeTypeDeclaration& nativeTypeDeclaration) > ASSERT(typeReference->name() == "float4"); > return "float"_str; > })(); >+ auto isReadWrite = nativeTypeDeclaration.name() == "RWTexture1D" >+ || nativeTypeDeclaration.name() == "RWTexture1DArray" >+ || nativeTypeDeclaration.name() == "RWTexture2D" >+ || nativeTypeDeclaration.name() == "RWTexture2DArray" >+ || nativeTypeDeclaration.name() == "RWTexture3D"; > // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Specify the second template argument to Metal texture types. >- return makeString(prefix, '<', innerType, '>'); >+ return makeString(prefix, '<', innerType, ", ", isReadWrite ? "access::read_write" : "access::sample", '>'); > } > > } // namespace Metal >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >index c8bffb82caecfe98fb252f98ff28ffb8a35e6a7a..11ddc9c83efc50a565c04fdc1d0f238f1a905c9c 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp >@@ -369,6 +369,10 @@ bool Intrinsics::addFullTexture(AST::NativeTypeDeclaration& nativeTypeDeclaratio > } > ASSERT(innerTypeIndex != WTF_ARRAY_LENGTH(m_textureInnerTypeNames)); > nativeTypeDeclaration.setIsTexture(); >+ if (textureTypeIndex >= indexOfFirstArrayType) >+ nativeTypeDeclaration.setIsTextureArray(); >+ if (nativeTypeDeclaration.name() == "RWTexture1D" || nativeTypeDeclaration.name() == "RWTexture2D" || nativeTypeDeclaration.name() == "RWTexture3D" || nativeTypeDeclaration.name() == "RWTexture1DArray" || nativeTypeDeclaration.name() == "RWTexture2DArray") >+ nativeTypeDeclaration.setIsWritableTexture(); > m_fullTextures[textureTypeIndex][innerTypeIndex][vectorLength - 1] = &nativeTypeDeclaration; > return true; > } >@@ -378,12 +382,8 @@ void Intrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclarati > AST::NativeTypeDeclaration** texture = nullptr; > if (nativeTypeDeclaration.name() == "TextureDepth2D") > texture = m_textureDepth2D; >- else if (nativeTypeDeclaration.name() == "RWTextureDepth2D") >- texture = m_rwTextureDepth2D; > else if (nativeTypeDeclaration.name() == "TextureDepth2DArray") > texture = m_textureDepth2DArray; >- else if (nativeTypeDeclaration.name() == "RWTextureDepth2DArray") >- texture = m_rwTextureDepth2DArray; > else { > ASSERT(nativeTypeDeclaration.name() == "TextureDepthCube"); > texture = m_textureDepthCube; >@@ -391,6 +391,9 @@ void Intrinsics::addDepthTexture(AST::NativeTypeDeclaration& nativeTypeDeclarati > auto innerTypeIndex = std::find(m_depthTextureInnerTypes, m_depthTextureInnerTypes + WTF_ARRAY_LENGTH(m_depthTextureInnerTypes), innerType.name()) - m_depthTextureInnerTypes; > ASSERT(innerTypeIndex != WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)); > nativeTypeDeclaration.setIsTexture(); >+ if (texture == m_textureDepth2DArray) >+ nativeTypeDeclaration.setIsTextureArray(); >+ nativeTypeDeclaration.setIsDepthTexture(); > texture[innerTypeIndex] = &nativeTypeDeclaration; > } > >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >index ad857c5f94eaf1352a31537154347d062ed0bba2..b4c7ef53dabbbedf46bd1fc661303c8031329b21 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.h >@@ -263,7 +263,10 @@ private: > AST::NativeTypeDeclaration* m_matrixHalf[3][3] {{ 0 }}; > AST::NativeTypeDeclaration* m_matrixFloat[3][3] {{ 0 }}; > >- static constexpr const char* m_textureTypeNames[] = { "Texture1D", "RWTexture1D", "Texture1DArray", "RWTexture1DArray", "Texture2D", "RWTexture2D", "Texture2DArray", "RWTexture2DArray", "Texture3D", "RWTexture3D", "TextureCube" }; >+ // Keep the array types partitioned from the non-array types. >+ // This is how we retain what's an array and what isn't. >+ static constexpr const char* m_textureTypeNames[] = { "Texture1D", "RWTexture1D", "Texture2D", "RWTexture2D", "Texture3D", "RWTexture3D", "TextureCube", "Texture1DArray", "RWTexture1DArray", "Texture2DArray", "RWTexture2DArray" }; >+ static constexpr unsigned indexOfFirstArrayType = 7; > > static constexpr const char* m_textureInnerTypeNames[] = { "uchar", "ushort", "uint", "char", "short", "int", "half", "float" }; > >@@ -272,9 +275,7 @@ private: > static constexpr const char* m_depthTextureInnerTypes[] = { "half", "float" }; > > AST::NativeTypeDeclaration* m_textureDepth2D[WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)] { 0 }; >- AST::NativeTypeDeclaration* m_rwTextureDepth2D[WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)] { 0 }; > AST::NativeTypeDeclaration* m_textureDepth2DArray[WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)] { 0 }; >- AST::NativeTypeDeclaration* m_rwTextureDepth2DArray[WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)] { 0 }; > AST::NativeTypeDeclaration* m_textureDepthCube[WTF_ARRAY_LENGTH(m_depthTextureInnerTypes)] { 0 }; > > AST::NativeFunctionDeclaration* m_ddx { nullptr }; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >index 21ca18dcfa3001ea5455a37a194701830cc775fc..44a319559acd970d1ec9b99ce6f261a5b22480a2 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp >@@ -56,6 +56,15 @@ NameResolver::NameResolver(NameContext& nameContext) > { > } > >+void NameResolver::visit(AST::NativeFunctionDeclaration& nativeFunctionDeclaration) >+{ >+ NameContext newNameContext(&m_nameContext); >+ NameResolver newNameResolver(newNameContext); >+ newNameResolver.Visitor::visit(nativeFunctionDeclaration); >+ if (newNameResolver.error()) >+ setError(); >+} >+ > void NameResolver::visit(AST::TypeReference& typeReference) > { > ScopedSetAdder<AST::TypeReference*> adder(m_typeReferences, &typeReference); >@@ -92,6 +101,8 @@ void NameResolver::visit(AST::FunctionDefinition& functionDefinition) > for (auto& parameter : functionDefinition.parameters()) > newNameResolver.checkErrorAndVisit(parameter); > newNameResolver.checkErrorAndVisit(functionDefinition.block()); >+ if (newNameResolver.error()) >+ setError(); > } > > void NameResolver::visit(AST::Block& block) >@@ -100,6 +111,8 @@ void NameResolver::visit(AST::Block& block) > NameResolver newNameResolver(nameContext); > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.Visitor::visit(block); >+ if (newNameResolver.error()) >+ setError(); > } > > void NameResolver::visit(AST::IfStatement& ifStatement) >@@ -109,11 +122,15 @@ void NameResolver::visit(AST::IfStatement& ifStatement) > NameResolver newNameResolver(nameContext); > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.checkErrorAndVisit(ifStatement.body()); >- if (ifStatement.elseBody()) { >+ if (newNameResolver.error()) >+ setError(); >+ else if (ifStatement.elseBody()) { > NameContext nameContext(&m_nameContext); > NameResolver newNameResolver(nameContext); > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.checkErrorAndVisit(*ifStatement.elseBody()); >+ if (newNameResolver.error()) >+ setError(); > } > } > >@@ -124,6 +141,8 @@ void NameResolver::visit(AST::WhileLoop& whileLoop) > NameResolver newNameResolver(nameContext); > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.checkErrorAndVisit(whileLoop.body()); >+ if (newNameResolver.error()) >+ setError(); > } > > void NameResolver::visit(AST::DoWhileLoop& whileLoop) >@@ -133,6 +152,8 @@ void NameResolver::visit(AST::DoWhileLoop& whileLoop) > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.checkErrorAndVisit(whileLoop.body()); > checkErrorAndVisit(whileLoop.conditional()); >+ if (newNameResolver.error()) >+ setError(); > } > > void NameResolver::visit(AST::ForLoop& forLoop) >@@ -141,6 +162,8 @@ void NameResolver::visit(AST::ForLoop& forLoop) > NameResolver newNameResolver(nameContext); > newNameResolver.setCurrentFunctionDefinition(m_currentFunction); > newNameResolver.Visitor::visit(forLoop); >+ if (newNameResolver.error()) >+ setError(); > } > > void NameResolver::visit(AST::VariableDeclaration& variableDeclaration) >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h >index 8fb4a34fbd49d1a983b5c6e714e0f69a7557c306..b9ae0d7dca7f8616f8e8121c54ff9315e524b1ef 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h >@@ -64,6 +64,7 @@ private: > void visit(AST::DotExpression&) override; > void visit(AST::CallExpression&) override; > void visit(AST::EnumerationMemberLiteral&) override; >+ void visit(AST::NativeFunctionDeclaration&) override; > > NameContext& m_nameContext; > HashSet<AST::TypeReference*> m_typeReferences; >diff --git a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt >index 07494815df4263223d3bfc4a9d04412c323bf84b..0794dcbe209c3b7c972d67044f404399a629c1e0 100644 >--- a/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt >+++ b/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt >@@ -370,9 +370,7 @@ native typedef TextureCube<float2>; > native typedef TextureCube<float3>; > native typedef TextureCube<float4>; > native typedef TextureDepth2D<float>; >-native typedef RWTextureDepth2D<float>; > native typedef TextureDepth2DArray<float>; >-native typedef RWTextureDepth2DArray<float>; > native typedef TextureDepthCube<float>; > > native operator uchar(ushort); >@@ -625,4 +623,619 @@ operator float4(float x, float y, float z, float w) { > return result; > } > >+operator float2(float x, float y) { >+ float2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+ >+operator int3(int x, int y, int z) { >+ int3 result; >+ result.x = x; >+ result.y = y; >+ result.z = z; >+ return result; >+} >+ >+operator int2(int x, int y) { >+ int2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+ >+operator uint2(uint x, uint y) { >+ uint2 result; >+ result.x = x; >+ result.y = y; >+ return result; >+} >+ >+native ushort Sample(Texture1D<ushort>, sampler, float location); >+native ushort Sample(Texture1DArray<ushort>, sampler, float2 location); >+native ushort Sample(Texture2D<ushort>, sampler, float2 location); >+native ushort Sample(Texture2D<ushort>, sampler, float2 location, int2 offset); >+native ushort Sample(Texture2DArray<ushort>, sampler, float3 location); >+native ushort Sample(Texture2DArray<ushort>, sampler, float3 location, int2 offset); >+native ushort Sample(Texture3D<ushort>, sampler, float3 location); >+native ushort Sample(Texture3D<ushort>, sampler, float3 location, int3 offset); >+native ushort Sample(TextureCube<ushort>, sampler, float3 location); >+native ushort2 Sample(Texture1D<ushort2>, sampler, float location); >+native ushort2 Sample(Texture1DArray<ushort2>, sampler, float2 location); >+native ushort2 Sample(Texture2D<ushort2>, sampler, float2 location); >+native ushort2 Sample(Texture2D<ushort2>, sampler, float2 location, int2 offset); >+native ushort2 Sample(Texture2DArray<ushort2>, sampler, float3 location); >+native ushort2 Sample(Texture2DArray<ushort2>, sampler, float3 location, int2 offset); >+native ushort2 Sample(Texture3D<ushort2>, sampler, float3 location); >+native ushort2 Sample(Texture3D<ushort2>, sampler, float3 location, int3 offset); >+native ushort2 Sample(TextureCube<ushort2>, sampler, float3 location); >+native ushort3 Sample(Texture1D<ushort3>, sampler, float location); >+native ushort3 Sample(Texture1DArray<ushort3>, sampler, float2 location); >+native ushort3 Sample(Texture2D<ushort3>, sampler, float2 location); >+native ushort3 Sample(Texture2D<ushort3>, sampler, float2 location, int2 offset); >+native ushort3 Sample(Texture2DArray<ushort3>, sampler, float3 location); >+native ushort3 Sample(Texture2DArray<ushort3>, sampler, float3 location, int2 offset); >+native ushort3 Sample(Texture3D<ushort3>, sampler, float3 location); >+native ushort3 Sample(Texture3D<ushort3>, sampler, float3 location, int3 offset); >+native ushort3 Sample(TextureCube<ushort3>, sampler, float3 location); >+native ushort4 Sample(Texture1D<ushort4>, sampler, float location); >+native ushort4 Sample(Texture1DArray<ushort4>, sampler, float2 location); >+native ushort4 Sample(Texture2D<ushort4>, sampler, float2 location); >+native ushort4 Sample(Texture2D<ushort4>, sampler, float2 location, int2 offset); >+native ushort4 Sample(Texture2DArray<ushort4>, sampler, float3 location); >+native ushort4 Sample(Texture2DArray<ushort4>, sampler, float3 location, int2 offset); >+native ushort4 Sample(Texture3D<ushort4>, sampler, float3 location); >+native ushort4 Sample(Texture3D<ushort4>, sampler, float3 location, int3 offset); >+native ushort4 Sample(TextureCube<ushort4>, sampler, float3 location); >+native uint Sample(Texture1D<uint>, sampler, float location); >+native uint Sample(Texture1DArray<uint>, sampler, float2 location); >+native uint Sample(Texture2D<uint>, sampler, float2 location); >+native uint Sample(Texture2D<uint>, sampler, float2 location, int2 offset); >+native uint Sample(Texture2DArray<uint>, sampler, float3 location); >+native uint Sample(Texture2DArray<uint>, sampler, float3 location, int2 offset); >+native uint Sample(Texture3D<uint>, sampler, float3 location); >+native uint Sample(Texture3D<uint>, sampler, float3 location, int3 offset); >+native uint Sample(TextureCube<uint>, sampler, float3 location); >+native uint2 Sample(Texture1D<uint2>, sampler, float location); >+native uint2 Sample(Texture1DArray<uint2>, sampler, float2 location); >+native uint2 Sample(Texture2D<uint2>, sampler, float2 location); >+native uint2 Sample(Texture2D<uint2>, sampler, float2 location, int2 offset); >+native uint2 Sample(Texture2DArray<uint2>, sampler, float3 location); >+native uint2 Sample(Texture2DArray<uint2>, sampler, float3 location, int2 offset); >+native uint2 Sample(Texture3D<uint2>, sampler, float3 location); >+native uint2 Sample(Texture3D<uint2>, sampler, float3 location, int3 offset); >+native uint2 Sample(TextureCube<uint2>, sampler, float3 location); >+native uint3 Sample(Texture1D<uint3>, sampler, float location); >+native uint3 Sample(Texture1DArray<uint3>, sampler, float2 location); >+native uint3 Sample(Texture2D<uint3>, sampler, float2 location); >+native uint3 Sample(Texture2D<uint3>, sampler, float2 location, int2 offset); >+native uint3 Sample(Texture2DArray<uint3>, sampler, float3 location); >+native uint3 Sample(Texture2DArray<uint3>, sampler, float3 location, int2 offset); >+native uint3 Sample(Texture3D<uint3>, sampler, float3 location); >+native uint3 Sample(Texture3D<uint3>, sampler, float3 location, int3 offset); >+native uint3 Sample(TextureCube<uint3>, sampler, float3 location); >+native uint4 Sample(Texture1D<uint4>, sampler, float location); >+native uint4 Sample(Texture1DArray<uint4>, sampler, float2 location); >+native uint4 Sample(Texture2D<uint4>, sampler, float2 location); >+native uint4 Sample(Texture2D<uint4>, sampler, float2 location, int2 offset); >+native uint4 Sample(Texture2DArray<uint4>, sampler, float3 location); >+native uint4 Sample(Texture2DArray<uint4>, sampler, float3 location, int2 offset); >+native uint4 Sample(Texture3D<uint4>, sampler, float3 location); >+native uint4 Sample(Texture3D<uint4>, sampler, float3 location, int3 offset); >+native uint4 Sample(TextureCube<uint4>, sampler, float3 location); >+native short Sample(Texture1D<short>, sampler, float location); >+native short Sample(Texture1DArray<short>, sampler, float2 location); >+native short Sample(Texture2D<short>, sampler, float2 location); >+native short Sample(Texture2D<short>, sampler, float2 location, int2 offset); >+native short Sample(Texture2DArray<short>, sampler, float3 location); >+native short Sample(Texture2DArray<short>, sampler, float3 location, int2 offset); >+native short Sample(Texture3D<short>, sampler, float3 location); >+native short Sample(Texture3D<short>, sampler, float3 location, int3 offset); >+native short Sample(TextureCube<short>, sampler, float3 location); >+native short2 Sample(Texture1D<short2>, sampler, float location); >+native short2 Sample(Texture1DArray<short2>, sampler, float2 location); >+native short2 Sample(Texture2D<short2>, sampler, float2 location); >+native short2 Sample(Texture2D<short2>, sampler, float2 location, int2 offset); >+native short2 Sample(Texture2DArray<short2>, sampler, float3 location); >+native short2 Sample(Texture2DArray<short2>, sampler, float3 location, int2 offset); >+native short2 Sample(Texture3D<short2>, sampler, float3 location); >+native short2 Sample(Texture3D<short2>, sampler, float3 location, int3 offset); >+native short2 Sample(TextureCube<short2>, sampler, float3 location); >+native short3 Sample(Texture1D<short3>, sampler, float location); >+native short3 Sample(Texture1DArray<short3>, sampler, float2 location); >+native short3 Sample(Texture2D<short3>, sampler, float2 location); >+native short3 Sample(Texture2D<short3>, sampler, float2 location, int2 offset); >+native short3 Sample(Texture2DArray<short3>, sampler, float3 location); >+native short3 Sample(Texture2DArray<short3>, sampler, float3 location, int2 offset); >+native short3 Sample(Texture3D<short3>, sampler, float3 location); >+native short3 Sample(Texture3D<short3>, sampler, float3 location, int3 offset); >+native short3 Sample(TextureCube<short3>, sampler, float3 location); >+native short4 Sample(Texture1D<short4>, sampler, float location); >+native short4 Sample(Texture1DArray<short4>, sampler, float2 location); >+native short4 Sample(Texture2D<short4>, sampler, float2 location); >+native short4 Sample(Texture2D<short4>, sampler, float2 location, int2 offset); >+native short4 Sample(Texture2DArray<short4>, sampler, float3 location); >+native short4 Sample(Texture2DArray<short4>, sampler, float3 location, int2 offset); >+native short4 Sample(Texture3D<short4>, sampler, float3 location); >+native short4 Sample(Texture3D<short4>, sampler, float3 location, int3 offset); >+native short4 Sample(TextureCube<short4>, sampler, float3 location); >+native int Sample(Texture1D<int>, sampler, float location); >+native int Sample(Texture1DArray<int>, sampler, float2 location); >+native int Sample(Texture2D<int>, sampler, float2 location); >+native int Sample(Texture2D<int>, sampler, float2 location, int2 offset); >+native int Sample(Texture2DArray<int>, sampler, float3 location); >+native int Sample(Texture2DArray<int>, sampler, float3 location, int2 offset); >+native int Sample(Texture3D<int>, sampler, float3 location); >+native int Sample(Texture3D<int>, sampler, float3 location, int3 offset); >+native int Sample(TextureCube<int>, sampler, float3 location); >+native int2 Sample(Texture1D<int2>, sampler, float location); >+native int2 Sample(Texture1DArray<int2>, sampler, float2 location); >+native int2 Sample(Texture2D<int2>, sampler, float2 location); >+native int2 Sample(Texture2D<int2>, sampler, float2 location, int2 offset); >+native int2 Sample(Texture2DArray<int2>, sampler, float3 location); >+native int2 Sample(Texture2DArray<int2>, sampler, float3 location, int2 offset); >+native int2 Sample(Texture3D<int2>, sampler, float3 location); >+native int2 Sample(Texture3D<int2>, sampler, float3 location, int3 offset); >+native int2 Sample(TextureCube<int2>, sampler, float3 location); >+native int3 Sample(Texture1D<int3>, sampler, float location); >+native int3 Sample(Texture1DArray<int3>, sampler, float2 location); >+native int3 Sample(Texture2D<int3>, sampler, float2 location); >+native int3 Sample(Texture2D<int3>, sampler, float2 location, int2 offset); >+native int3 Sample(Texture2DArray<int3>, sampler, float3 location); >+native int3 Sample(Texture2DArray<int3>, sampler, float3 location, int2 offset); >+native int3 Sample(Texture3D<int3>, sampler, float3 location); >+native int3 Sample(Texture3D<int3>, sampler, float3 location, int3 offset); >+native int3 Sample(TextureCube<int3>, sampler, float3 location); >+native int4 Sample(Texture1D<int4>, sampler, float location); >+native int4 Sample(Texture1DArray<int4>, sampler, float2 location); >+native int4 Sample(Texture2D<int4>, sampler, float2 location); >+native int4 Sample(Texture2D<int4>, sampler, float2 location, int2 offset); >+native int4 Sample(Texture2DArray<int4>, sampler, float3 location); >+native int4 Sample(Texture2DArray<int4>, sampler, float3 location, int2 offset); >+native int4 Sample(Texture3D<int4>, sampler, float3 location); >+native int4 Sample(Texture3D<int4>, sampler, float3 location, int3 offset); >+native int4 Sample(TextureCube<int4>, sampler, float3 location); >+native half Sample(Texture1D<half>, sampler, float location); >+native half Sample(Texture1DArray<half>, sampler, float2 location); >+native half Sample(Texture2D<half>, sampler, float2 location); >+native half Sample(Texture2D<half>, sampler, float2 location, int2 offset); >+native half Sample(Texture2DArray<half>, sampler, float3 location); >+native half Sample(Texture2DArray<half>, sampler, float3 location, int2 offset); >+native half Sample(Texture3D<half>, sampler, float3 location); >+native half Sample(Texture3D<half>, sampler, float3 location, int3 offset); >+native half Sample(TextureCube<half>, sampler, float3 location); >+native half2 Sample(Texture1D<half2>, sampler, float location); >+native half2 Sample(Texture1DArray<half2>, sampler, float2 location); >+native half2 Sample(Texture2D<half2>, sampler, float2 location); >+native half2 Sample(Texture2D<half2>, sampler, float2 location, int2 offset); >+native half2 Sample(Texture2DArray<half2>, sampler, float3 location); >+native half2 Sample(Texture2DArray<half2>, sampler, float3 location, int2 offset); >+native half2 Sample(Texture3D<half2>, sampler, float3 location); >+native half2 Sample(Texture3D<half2>, sampler, float3 location, int3 offset); >+native half2 Sample(TextureCube<half2>, sampler, float3 location); >+native half3 Sample(Texture1D<half3>, sampler, float location); >+native half3 Sample(Texture1DArray<half3>, sampler, float2 location); >+native half3 Sample(Texture2D<half3>, sampler, float2 location); >+native half3 Sample(Texture2D<half3>, sampler, float2 location, int2 offset); >+native half3 Sample(Texture2DArray<half3>, sampler, float3 location); >+native half3 Sample(Texture2DArray<half3>, sampler, float3 location, int2 offset); >+native half3 Sample(Texture3D<half3>, sampler, float3 location); >+native half3 Sample(Texture3D<half3>, sampler, float3 location, int3 offset); >+native half3 Sample(TextureCube<half3>, sampler, float3 location); >+native half4 Sample(Texture1D<half4>, sampler, float location); >+native half4 Sample(Texture1DArray<half4>, sampler, float2 location); >+native half4 Sample(Texture2D<half4>, sampler, float2 location); >+native half4 Sample(Texture2D<half4>, sampler, float2 location, int2 offset); >+native half4 Sample(Texture2DArray<half4>, sampler, float3 location); >+native half4 Sample(Texture2DArray<half4>, sampler, float3 location, int2 offset); >+native half4 Sample(Texture3D<half4>, sampler, float3 location); >+native half4 Sample(Texture3D<half4>, sampler, float3 location, int3 offset); >+native half4 Sample(TextureCube<half4>, sampler, float3 location); >+native float Sample(Texture1D<float>, sampler, float location); >+native float Sample(Texture1DArray<float>, sampler, float2 location); >+native float Sample(Texture2D<float>, sampler, float2 location); >+native float Sample(Texture2D<float>, sampler, float2 location, int2 offset); >+native float Sample(Texture2DArray<float>, sampler, float3 location); >+native float Sample(Texture2DArray<float>, sampler, float3 location, int2 offset); >+native float Sample(Texture3D<float>, sampler, float3 location); >+native float Sample(Texture3D<float>, sampler, float3 location, int3 offset); >+native float Sample(TextureCube<float>, sampler, float3 location); >+native float2 Sample(Texture1D<float2>, sampler, float location); >+native float2 Sample(Texture1DArray<float2>, sampler, float2 location); >+native float2 Sample(Texture2D<float2>, sampler, float2 location); >+native float2 Sample(Texture2D<float2>, sampler, float2 location, int2 offset); >+native float2 Sample(Texture2DArray<float2>, sampler, float3 location); >+native float2 Sample(Texture2DArray<float2>, sampler, float3 location, int2 offset); >+native float2 Sample(Texture3D<float2>, sampler, float3 location); >+native float2 Sample(Texture3D<float2>, sampler, float3 location, int3 offset); >+native float2 Sample(TextureCube<float2>, sampler, float3 location); >+native float3 Sample(Texture1D<float3>, sampler, float location); >+native float3 Sample(Texture1DArray<float3>, sampler, float2 location); >+native float3 Sample(Texture2D<float3>, sampler, float2 location); >+native float3 Sample(Texture2D<float3>, sampler, float2 location, int2 offset); >+native float3 Sample(Texture2DArray<float3>, sampler, float3 location); >+native float3 Sample(Texture2DArray<float3>, sampler, float3 location, int2 offset); >+native float3 Sample(Texture3D<float3>, sampler, float3 location); >+native float3 Sample(Texture3D<float3>, sampler, float3 location, int3 offset); >+native float3 Sample(TextureCube<float3>, sampler, float3 location); >+native float4 Sample(Texture1D<float4>, sampler, float location); >+native float4 Sample(Texture1DArray<float4>, sampler, float2 location); >+native float4 Sample(Texture2D<float4>, sampler, float2 location); >+native float4 Sample(Texture2D<float4>, sampler, float2 location, int2 offset); >+native float4 Sample(Texture2DArray<float4>, sampler, float3 location); >+native float4 Sample(Texture2DArray<float4>, sampler, float3 location, int2 offset); >+native float4 Sample(Texture3D<float4>, sampler, float3 location); >+native float4 Sample(Texture3D<float4>, sampler, float3 location, int3 offset); >+native float4 Sample(TextureCube<float4>, sampler, float3 location); >+native float Sample(TextureDepth2D<float>, sampler, float2 location); >+native float Sample(TextureDepth2D<float>, sampler, float2 location, int2 offset); >+native float Sample(TextureDepth2DArray<float>, sampler, float3 location); >+native float Sample(TextureDepth2DArray<float>, sampler, float3 location, int2 offset); >+native float Sample(TextureDepthCube<float>, sampler, float3 location); >+ >+native ushort Load(Texture1D<ushort>, int location); >+native ushort Load(Texture1DArray<ushort>, int2 location); >+native ushort Load(Texture2D<ushort>, int2 location); >+native ushort Load(Texture2DArray<ushort>, int3 location); >+native ushort Load(Texture3D<ushort>, int3 location); >+native ushort Load(RWTexture1D<ushort>, int location); >+native ushort Load(RWTexture1DArray<ushort>, int2 location); >+native ushort Load(RWTexture2D<ushort>, int2 location); >+native ushort Load(RWTexture2DArray<ushort>, int3 location); >+native ushort Load(RWTexture3D<ushort>, int3 location); >+native ushort2 Load(Texture1D<ushort2>, int location); >+native ushort2 Load(Texture1DArray<ushort2>, int2 location); >+native ushort2 Load(Texture2D<ushort2>, int2 location); >+native ushort2 Load(Texture2DArray<ushort2>, int3 location); >+native ushort2 Load(Texture3D<ushort2>, int3 location); >+native ushort2 Load(RWTexture1D<ushort2>, int location); >+native ushort2 Load(RWTexture1DArray<ushort2>, int2 location); >+native ushort2 Load(RWTexture2D<ushort2>, int2 location); >+native ushort2 Load(RWTexture2DArray<ushort2>, int3 location); >+native ushort2 Load(RWTexture3D<ushort2>, int3 location); >+native ushort3 Load(Texture1D<ushort3>, int location); >+native ushort3 Load(Texture1DArray<ushort3>, int2 location); >+native ushort3 Load(Texture2D<ushort3>, int2 location); >+native ushort3 Load(Texture2DArray<ushort3>, int3 location); >+native ushort3 Load(Texture3D<ushort3>, int3 location); >+native ushort3 Load(RWTexture1D<ushort3>, int location); >+native ushort3 Load(RWTexture1DArray<ushort3>, int2 location); >+native ushort3 Load(RWTexture2D<ushort3>, int2 location); >+native ushort3 Load(RWTexture2DArray<ushort3>, int3 location); >+native ushort3 Load(RWTexture3D<ushort3>, int3 location); >+native ushort4 Load(Texture1D<ushort4>, int location); >+native ushort4 Load(Texture1DArray<ushort4>, int2 location); >+native ushort4 Load(Texture2D<ushort4>, int2 location); >+native ushort4 Load(Texture2DArray<ushort4>, int3 location); >+native ushort4 Load(Texture3D<ushort4>, int3 location); >+native ushort4 Load(RWTexture1D<ushort4>, int location); >+native ushort4 Load(RWTexture1DArray<ushort4>, int2 location); >+native ushort4 Load(RWTexture2D<ushort4>, int2 location); >+native ushort4 Load(RWTexture2DArray<ushort4>, int3 location); >+native ushort4 Load(RWTexture3D<ushort4>, int3 location); >+native uint Load(Texture1D<uint>, int location); >+native uint Load(Texture1DArray<uint>, int2 location); >+native uint Load(Texture2D<uint>, int2 location); >+native uint Load(Texture2DArray<uint>, int3 location); >+native uint Load(Texture3D<uint>, int3 location); >+native uint Load(RWTexture1D<uint>, int location); >+native uint Load(RWTexture1DArray<uint>, int2 location); >+native uint Load(RWTexture2D<uint>, int2 location); >+native uint Load(RWTexture2DArray<uint>, int3 location); >+native uint Load(RWTexture3D<uint>, int3 location); >+native uint2 Load(Texture1D<uint2>, int location); >+native uint2 Load(Texture1DArray<uint2>, int2 location); >+native uint2 Load(Texture2D<uint2>, int2 location); >+native uint2 Load(Texture2DArray<uint2>, int3 location); >+native uint2 Load(Texture3D<uint2>, int3 location); >+native uint2 Load(RWTexture1D<uint2>, int location); >+native uint2 Load(RWTexture1DArray<uint2>, int2 location); >+native uint2 Load(RWTexture2D<uint2>, int2 location); >+native uint2 Load(RWTexture2DArray<uint2>, int3 location); >+native uint2 Load(RWTexture3D<uint2>, int3 location); >+native uint3 Load(Texture1D<uint3>, int location); >+native uint3 Load(Texture1DArray<uint3>, int2 location); >+native uint3 Load(Texture2D<uint3>, int2 location); >+native uint3 Load(Texture2DArray<uint3>, int3 location); >+native uint3 Load(Texture3D<uint3>, int3 location); >+native uint3 Load(RWTexture1D<uint3>, int location); >+native uint3 Load(RWTexture1DArray<uint3>, int2 location); >+native uint3 Load(RWTexture2D<uint3>, int2 location); >+native uint3 Load(RWTexture2DArray<uint3>, int3 location); >+native uint3 Load(RWTexture3D<uint3>, int3 location); >+native uint4 Load(Texture1D<uint4>, int location); >+native uint4 Load(Texture1DArray<uint4>, int2 location); >+native uint4 Load(Texture2D<uint4>, int2 location); >+native uint4 Load(Texture2DArray<uint4>, int3 location); >+native uint4 Load(Texture3D<uint4>, int3 location); >+native uint4 Load(RWTexture1D<uint4>, int location); >+native uint4 Load(RWTexture1DArray<uint4>, int2 location); >+native uint4 Load(RWTexture2D<uint4>, int2 location); >+native uint4 Load(RWTexture2DArray<uint4>, int3 location); >+native uint4 Load(RWTexture3D<uint4>, int3 location); >+native short Load(Texture1D<short>, int location); >+native short Load(Texture1DArray<short>, int2 location); >+native short Load(Texture2D<short>, int2 location); >+native short Load(Texture2DArray<short>, int3 location); >+native short Load(Texture3D<short>, int3 location); >+native short Load(RWTexture1D<short>, int location); >+native short Load(RWTexture1DArray<short>, int2 location); >+native short Load(RWTexture2D<short>, int2 location); >+native short Load(RWTexture2DArray<short>, int3 location); >+native short Load(RWTexture3D<short>, int3 location); >+native short2 Load(Texture1D<short2>, int location); >+native short2 Load(Texture1DArray<short2>, int2 location); >+native short2 Load(Texture2D<short2>, int2 location); >+native short2 Load(Texture2DArray<short2>, int3 location); >+native short2 Load(Texture3D<short2>, int3 location); >+native short2 Load(RWTexture1D<short2>, int location); >+native short2 Load(RWTexture1DArray<short2>, int2 location); >+native short2 Load(RWTexture2D<short2>, int2 location); >+native short2 Load(RWTexture2DArray<short2>, int3 location); >+native short2 Load(RWTexture3D<short2>, int3 location); >+native short3 Load(Texture1D<short3>, int location); >+native short3 Load(Texture1DArray<short3>, int2 location); >+native short3 Load(Texture2D<short3>, int2 location); >+native short3 Load(Texture2DArray<short3>, int3 location); >+native short3 Load(Texture3D<short3>, int3 location); >+native short3 Load(RWTexture1D<short3>, int location); >+native short3 Load(RWTexture1DArray<short3>, int2 location); >+native short3 Load(RWTexture2D<short3>, int2 location); >+native short3 Load(RWTexture2DArray<short3>, int3 location); >+native short3 Load(RWTexture3D<short3>, int3 location); >+native short4 Load(Texture1D<short4>, int location); >+native short4 Load(Texture1DArray<short4>, int2 location); >+native short4 Load(Texture2D<short4>, int2 location); >+native short4 Load(Texture2DArray<short4>, int3 location); >+native short4 Load(Texture3D<short4>, int3 location); >+native short4 Load(RWTexture1D<short4>, int location); >+native short4 Load(RWTexture1DArray<short4>, int2 location); >+native short4 Load(RWTexture2D<short4>, int2 location); >+native short4 Load(RWTexture2DArray<short4>, int3 location); >+native short4 Load(RWTexture3D<short4>, int3 location); >+native int Load(Texture1D<int>, int location); >+native int Load(Texture1DArray<int>, int2 location); >+native int Load(Texture2D<int>, int2 location); >+native int Load(Texture2DArray<int>, int3 location); >+native int Load(Texture3D<int>, int3 location); >+native int Load(RWTexture1D<int>, int location); >+native int Load(RWTexture1DArray<int>, int2 location); >+native int Load(RWTexture2D<int>, int2 location); >+native int Load(RWTexture2DArray<int>, int3 location); >+native int Load(RWTexture3D<int>, int3 location); >+native int2 Load(Texture1D<int2>, int location); >+native int2 Load(Texture1DArray<int2>, int2 location); >+native int2 Load(Texture2D<int2>, int2 location); >+native int2 Load(Texture2DArray<int2>, int3 location); >+native int2 Load(Texture3D<int2>, int3 location); >+native int2 Load(RWTexture1D<int2>, int location); >+native int2 Load(RWTexture1DArray<int2>, int2 location); >+native int2 Load(RWTexture2D<int2>, int2 location); >+native int2 Load(RWTexture2DArray<int2>, int3 location); >+native int2 Load(RWTexture3D<int2>, int3 location); >+native int3 Load(Texture1D<int3>, int location); >+native int3 Load(Texture1DArray<int3>, int2 location); >+native int3 Load(Texture2D<int3>, int2 location); >+native int3 Load(Texture2DArray<int3>, int3 location); >+native int3 Load(Texture3D<int3>, int3 location); >+native int3 Load(RWTexture1D<int3>, int location); >+native int3 Load(RWTexture1DArray<int3>, int2 location); >+native int3 Load(RWTexture2D<int3>, int2 location); >+native int3 Load(RWTexture2DArray<int3>, int3 location); >+native int3 Load(RWTexture3D<int3>, int3 location); >+native int4 Load(Texture1D<int4>, int location); >+native int4 Load(Texture1DArray<int4>, int2 location); >+native int4 Load(Texture2D<int4>, int2 location); >+native int4 Load(Texture2DArray<int4>, int3 location); >+native int4 Load(Texture3D<int4>, int3 location); >+native int4 Load(RWTexture1D<int4>, int location); >+native int4 Load(RWTexture1DArray<int4>, int2 location); >+native int4 Load(RWTexture2D<int4>, int2 location); >+native int4 Load(RWTexture2DArray<int4>, int3 location); >+native int4 Load(RWTexture3D<int4>, int3 location); >+native half Load(Texture1D<half>, int location); >+native half Load(Texture1DArray<half>, int2 location); >+native half Load(Texture2D<half>, int2 location); >+native half Load(Texture2DArray<half>, int3 location); >+native half Load(Texture3D<half>, int3 location); >+native half Load(RWTexture1D<half>, int location); >+native half Load(RWTexture1DArray<half>, int2 location); >+native half Load(RWTexture2D<half>, int2 location); >+native half Load(RWTexture2DArray<half>, int3 location); >+native half Load(RWTexture3D<half>, int3 location); >+native half2 Load(Texture1D<half2>, int location); >+native half2 Load(Texture1DArray<half2>, int2 location); >+native half2 Load(Texture2D<half2>, int2 location); >+native half2 Load(Texture2DArray<half2>, int3 location); >+native half2 Load(Texture3D<half2>, int3 location); >+native half2 Load(RWTexture1D<half2>, int location); >+native half2 Load(RWTexture1DArray<half2>, int2 location); >+native half2 Load(RWTexture2D<half2>, int2 location); >+native half2 Load(RWTexture2DArray<half2>, int3 location); >+native half2 Load(RWTexture3D<half2>, int3 location); >+native half3 Load(Texture1D<half3>, int location); >+native half3 Load(Texture1DArray<half3>, int2 location); >+native half3 Load(Texture2D<half3>, int2 location); >+native half3 Load(Texture2DArray<half3>, int3 location); >+native half3 Load(Texture3D<half3>, int3 location); >+native half3 Load(RWTexture1D<half3>, int location); >+native half3 Load(RWTexture1DArray<half3>, int2 location); >+native half3 Load(RWTexture2D<half3>, int2 location); >+native half3 Load(RWTexture2DArray<half3>, int3 location); >+native half3 Load(RWTexture3D<half3>, int3 location); >+native half4 Load(Texture1D<half4>, int location); >+native half4 Load(Texture1DArray<half4>, int2 location); >+native half4 Load(Texture2D<half4>, int2 location); >+native half4 Load(Texture2DArray<half4>, int3 location); >+native half4 Load(Texture3D<half4>, int3 location); >+native half4 Load(RWTexture1D<half4>, int location); >+native half4 Load(RWTexture1DArray<half4>, int2 location); >+native half4 Load(RWTexture2D<half4>, int2 location); >+native half4 Load(RWTexture2DArray<half4>, int3 location); >+native half4 Load(RWTexture3D<half4>, int3 location); >+native float Load(Texture1D<float>, int location); >+native float Load(Texture1DArray<float>, int2 location); >+native float Load(Texture2D<float>, int2 location); >+native float Load(Texture2DArray<float>, int3 location); >+native float Load(Texture3D<float>, int3 location); >+native float Load(RWTexture1D<float>, int location); >+native float Load(RWTexture1DArray<float>, int2 location); >+native float Load(RWTexture2D<float>, int2 location); >+native float Load(RWTexture2DArray<float>, int3 location); >+native float Load(RWTexture3D<float>, int3 location); >+native float2 Load(Texture1D<float2>, int location); >+native float2 Load(Texture1DArray<float2>, int2 location); >+native float2 Load(Texture2D<float2>, int2 location); >+native float2 Load(Texture2DArray<float2>, int3 location); >+native float2 Load(Texture3D<float2>, int3 location); >+native float2 Load(RWTexture1D<float2>, int location); >+native float2 Load(RWTexture1DArray<float2>, int2 location); >+native float2 Load(RWTexture2D<float2>, int2 location); >+native float2 Load(RWTexture2DArray<float2>, int3 location); >+native float2 Load(RWTexture3D<float2>, int3 location); >+native float3 Load(Texture1D<float3>, int location); >+native float3 Load(Texture1DArray<float3>, int2 location); >+native float3 Load(Texture2D<float3>, int2 location); >+native float3 Load(Texture2DArray<float3>, int3 location); >+native float3 Load(Texture3D<float3>, int3 location); >+native float3 Load(RWTexture1D<float3>, int location); >+native float3 Load(RWTexture1DArray<float3>, int2 location); >+native float3 Load(RWTexture2D<float3>, int2 location); >+native float3 Load(RWTexture2DArray<float3>, int3 location); >+native float3 Load(RWTexture3D<float3>, int3 location); >+native float4 Load(Texture1D<float4>, int location); >+native float4 Load(Texture1DArray<float4>, int2 location); >+native float4 Load(Texture2D<float4>, int2 location); >+native float4 Load(Texture2DArray<float4>, int3 location); >+native float4 Load(Texture3D<float4>, int3 location); >+native float4 Load(RWTexture1D<float4>, int location); >+native float4 Load(RWTexture1DArray<float4>, int2 location); >+native float4 Load(RWTexture2D<float4>, int2 location); >+native float4 Load(RWTexture2DArray<float4>, int3 location); >+native float4 Load(RWTexture3D<float4>, int3 location); >+native float Load(TextureDepth2D<float>, int2 location); >+native float Load(TextureDepth2DArray<float>, int3 location); >+ >+native void Store(RWTexture1D<ushort>, ushort, uint location); >+native void Store(RWTexture1DArray<ushort>, ushort, uint2 location); >+native void Store(RWTexture2D<ushort>, ushort, uint2 location); >+native void Store(RWTexture2DArray<ushort>, ushort, uint3 location); >+native void Store(RWTexture3D<ushort>, ushort, uint3 location); >+native void Store(RWTexture1D<ushort2>, ushort2, uint location); >+native void Store(RWTexture1DArray<ushort2>, ushort2, uint2 location); >+native void Store(RWTexture2D<ushort2>, ushort2, uint2 location); >+native void Store(RWTexture2DArray<ushort2>, ushort2, uint3 location); >+native void Store(RWTexture3D<ushort2>, ushort2, uint3 location); >+native void Store(RWTexture1D<ushort3>, ushort3, uint location); >+native void Store(RWTexture1DArray<ushort3>, ushort3, uint2 location); >+native void Store(RWTexture2D<ushort3>, ushort3, uint2 location); >+native void Store(RWTexture2DArray<ushort3>, ushort3, uint3 location); >+native void Store(RWTexture3D<ushort3>, ushort3, uint3 location); >+native void Store(RWTexture1D<ushort4>, ushort4, uint location); >+native void Store(RWTexture1DArray<ushort4>, ushort4, uint2 location); >+native void Store(RWTexture2D<ushort4>, ushort4, uint2 location); >+native void Store(RWTexture2DArray<ushort4>, ushort4, uint3 location); >+native void Store(RWTexture3D<ushort4>, ushort4, uint3 location); >+native void Store(RWTexture1D<uint>, uint, uint location); >+native void Store(RWTexture1DArray<uint>, uint, uint2 location); >+native void Store(RWTexture2D<uint>, uint, uint2 location); >+native void Store(RWTexture2DArray<uint>, uint, uint3 location); >+native void Store(RWTexture3D<uint>, uint, uint3 location); >+native void Store(RWTexture1D<uint2>, uint2, uint location); >+native void Store(RWTexture1DArray<uint2>, uint2, uint2 location); >+native void Store(RWTexture2D<uint2>, uint2, uint2 location); >+native void Store(RWTexture2DArray<uint2>, uint2, uint3 location); >+native void Store(RWTexture3D<uint2>, uint2, uint3 location); >+native void Store(RWTexture1D<uint3>, uint3, uint location); >+native void Store(RWTexture1DArray<uint3>, uint3, uint2 location); >+native void Store(RWTexture2D<uint3>, uint3, uint2 location); >+native void Store(RWTexture2DArray<uint3>, uint3, uint3 location); >+native void Store(RWTexture3D<uint3>, uint3, uint3 location); >+native void Store(RWTexture1D<uint4>, uint4, uint location); >+native void Store(RWTexture1DArray<uint4>, uint4, uint2 location); >+native void Store(RWTexture2D<uint4>, uint4, uint2 location); >+native void Store(RWTexture2DArray<uint4>, uint4, uint3 location); >+native void Store(RWTexture3D<uint4>, uint4, uint3 location); >+native void Store(RWTexture1D<short>, short, uint location); >+native void Store(RWTexture1DArray<short>, short, uint2 location); >+native void Store(RWTexture2D<short>, short, uint2 location); >+native void Store(RWTexture2DArray<short>, short, uint3 location); >+native void Store(RWTexture3D<short>, short, uint3 location); >+native void Store(RWTexture1D<short2>, short2, uint location); >+native void Store(RWTexture1DArray<short2>, short2, uint2 location); >+native void Store(RWTexture2D<short2>, short2, uint2 location); >+native void Store(RWTexture2DArray<short2>, short2, uint3 location); >+native void Store(RWTexture3D<short2>, short2, uint3 location); >+native void Store(RWTexture1D<short3>, short3, uint location); >+native void Store(RWTexture1DArray<short3>, short3, uint2 location); >+native void Store(RWTexture2D<short3>, short3, uint2 location); >+native void Store(RWTexture2DArray<short3>, short3, uint3 location); >+native void Store(RWTexture3D<short3>, short3, uint3 location); >+native void Store(RWTexture1D<short4>, short4, uint location); >+native void Store(RWTexture1DArray<short4>, short4, uint2 location); >+native void Store(RWTexture2D<short4>, short4, uint2 location); >+native void Store(RWTexture2DArray<short4>, short4, uint3 location); >+native void Store(RWTexture3D<short4>, short4, uint3 location); >+native void Store(RWTexture1D<int>, int, uint location); >+native void Store(RWTexture1DArray<int>, int, uint2 location); >+native void Store(RWTexture2D<int>, int, uint2 location); >+native void Store(RWTexture2DArray<int>, int, uint3 location); >+native void Store(RWTexture3D<int>, int, uint3 location); >+native void Store(RWTexture1D<int2>, int2, uint location); >+native void Store(RWTexture1DArray<int2>, int2, uint2 location); >+native void Store(RWTexture2D<int2>, int2, uint2 location); >+native void Store(RWTexture2DArray<int2>, int2, uint3 location); >+native void Store(RWTexture3D<int2>, int2, uint3 location); >+native void Store(RWTexture1D<int3>, int3, uint location); >+native void Store(RWTexture1DArray<int3>, int3, uint2 location); >+native void Store(RWTexture2D<int3>, int3, uint2 location); >+native void Store(RWTexture2DArray<int3>, int3, uint3 location); >+native void Store(RWTexture3D<int3>, int3, uint3 location); >+native void Store(RWTexture1D<int4>, int4, uint location); >+native void Store(RWTexture1DArray<int4>, int4, uint2 location); >+native void Store(RWTexture2D<int4>, int4, uint2 location); >+native void Store(RWTexture2DArray<int4>, int4, uint3 location); >+native void Store(RWTexture3D<int4>, int4, uint3 location); >+native void Store(RWTexture1D<half>, half, uint location); >+native void Store(RWTexture1DArray<half>, half, uint2 location); >+native void Store(RWTexture2D<half>, half, uint2 location); >+native void Store(RWTexture2DArray<half>, half, uint3 location); >+native void Store(RWTexture3D<half>, half, uint3 location); >+native void Store(RWTexture1D<half2>, half2, uint location); >+native void Store(RWTexture1DArray<half2>, half2, uint2 location); >+native void Store(RWTexture2D<half2>, half2, uint2 location); >+native void Store(RWTexture2DArray<half2>, half2, uint3 location); >+native void Store(RWTexture3D<half2>, half2, uint3 location); >+native void Store(RWTexture1D<half3>, half3, uint location); >+native void Store(RWTexture1DArray<half3>, half3, uint2 location); >+native void Store(RWTexture2D<half3>, half3, uint2 location); >+native void Store(RWTexture2DArray<half3>, half3, uint3 location); >+native void Store(RWTexture3D<half3>, half3, uint3 location); >+native void Store(RWTexture1D<half4>, half4, uint location); >+native void Store(RWTexture1DArray<half4>, half4, uint2 location); >+native void Store(RWTexture2D<half4>, half4, uint2 location); >+native void Store(RWTexture2DArray<half4>, half4, uint3 location); >+native void Store(RWTexture3D<half4>, half4, uint3 location); >+native void Store(RWTexture1D<float>, float, uint location); >+native void Store(RWTexture1DArray<float>, float, uint2 location); >+native void Store(RWTexture2D<float>, float, uint2 location); >+native void Store(RWTexture2DArray<float>, float, uint3 location); >+native void Store(RWTexture3D<float>, float, uint3 location); >+native void Store(RWTexture1D<float2>, float2, uint location); >+native void Store(RWTexture1DArray<float2>, float2, uint2 location); >+native void Store(RWTexture2D<float2>, float2, uint2 location); >+native void Store(RWTexture2DArray<float2>, float2, uint3 location); >+native void Store(RWTexture3D<float2>, float2, uint3 location); >+native void Store(RWTexture1D<float3>, float3, uint location); >+native void Store(RWTexture1DArray<float3>, float3, uint2 location); >+native void Store(RWTexture2D<float3>, float3, uint2 location); >+native void Store(RWTexture2DArray<float3>, float3, uint3 location); >+native void Store(RWTexture3D<float3>, float3, uint3 location); >+native void Store(RWTexture1D<float4>, float4, uint location); >+native void Store(RWTexture1DArray<float4>, float4, uint2 location); >+native void Store(RWTexture2D<float4>, float4, uint2 location); >+native void Store(RWTexture2DArray<float4>, float4, uint3 location); >+native void Store(RWTexture3D<float4>, float4, uint3 location); >+ > // FIXME: https://bugs.webkit.org/show_bug.cgi?id=192890 Insert the rest of the standard library once the parser is fast enough >diff --git a/Source/WebCore/platform/graphics/gpu/GPUTexture.h b/Source/WebCore/platform/graphics/gpu/GPUTexture.h >index d11bfcc4ab0cc24fa91bdc68272d14aafc4003fa..61912af0be1126e2a7a07cfc29236947ef3c70fd 100644 >--- a/Source/WebCore/platform/graphics/gpu/GPUTexture.h >+++ b/Source/WebCore/platform/graphics/gpu/GPUTexture.h >@@ -54,6 +54,8 @@ public: > bool isTransferDestination() const { return m_usage.contains(GPUTextureUsage::Flags::TransferDestination); } > bool isOutputAttachment() const { return m_usage.contains(GPUTextureUsage::Flags::OutputAttachment); } > bool isReadOnly() const { return m_usage.containsAny({ GPUTextureUsage::Flags::TransferSource, GPUTextureUsage::Flags::Sampled }); } >+ bool isSampled() const { return m_usage.contains(GPUTextureUsage::Flags::Sampled); } >+ bool isStorage() const { return m_usage.contains(GPUTextureUsage::Flags::Storage); } > > RefPtr<GPUTexture> tryCreateDefaultTextureView(); > void destroy() { m_platformTexture = nullptr; } >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm >index 6262e5f6d4156cd55ec0edabdc5a5c764d42ae48..3e0c7d38ae1690b9631f43e0a76c48e648b83aed 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm >@@ -216,22 +216,22 @@ RefPtr<GPUBindGroup> GPUBindGroup::tryCreate(const GPUBindGroupDescriptor& descr > if (!samplerState) > return false; > if (isForVertex) >- setSamplerOnEncoder(vertexEncoder, samplerState, index); >+ setSamplerOnEncoder(vertexEncoder, samplerState, layoutBinding.internalName); > if (isForFragment) >- setSamplerOnEncoder(fragmentEncoder, samplerState, index); >+ setSamplerOnEncoder(fragmentEncoder, samplerState, layoutBinding.internalName); > if (isForCompute) >- setSamplerOnEncoder(computeEncoder, samplerState, index); >+ setSamplerOnEncoder(computeEncoder, samplerState, layoutBinding.internalName); > return true; > }, [&](GPUBindGroupLayout::SampledTexture&) -> bool { > auto textureResource = tryGetResourceAsTexture(resourceBinding.resource, functionName); > if (!textureResource) > return false; > if (isForVertex) >- setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), index); >+ setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), layoutBinding.internalName); > if (isForFragment) >- setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), index); >+ setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), layoutBinding.internalName); > if (isForCompute) >- setTextureOnEncoder(computeEncoder, textureResource->platformTexture(), index); >+ setTextureOnEncoder(computeEncoder, textureResource->platformTexture(), layoutBinding.internalName); > boundTextures.append(textureResource.releaseNonNull()); > return true; > }, [&](GPUBindGroupLayout::StorageBuffer& storageBuffer) -> bool { >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm >index e81f7cadd2708c6cdfaa3fdf9b1eff72eba7ef79..7ba25aa8f020af5da191322322e674eecd25a322 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm >@@ -85,6 +85,9 @@ static Optional<WHLSL::ComputeDimensions> trySetFunctions(const char* const func > auto whlslCompileResult = WHLSL::prepare(whlslSource, *whlslDescriptor); > if (!whlslCompileResult) > return WTF::nullopt; >+ >+ WTFLogAlways("%s", whlslCompileResult->metalSource.utf8().data()); >+ > computeDimensions = whlslCompileResult->computeDimensions; > > NSError *error = nil; >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm >index 2e9871802588bae3c97fecd56f9e4062623d5ef6..62e1158e02e1408c931d482b21b702566dfcc3f1 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm >@@ -63,11 +63,27 @@ void GPUProgrammablePassEncoder::setBindGroup(unsigned index, GPUBindGroup& bind > setComputeBuffer(bindGroup.computeArgsBuffer(), 0, index); > > for (auto& bufferRef : bindGroup.boundBuffers()) { >- useResource(bufferRef->platformBuffer(), bufferRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite); >+ MTLResourceUsage usage = 0; >+ if (bufferRef->isUniform()) { >+ ASSERT(!bufferRef->isStorage()); >+ usage = MTLResourceUsageRead; >+ } else if (bufferRef->isStorage()) { >+ ASSERT(!bufferRef->isUniform()); >+ usage = MTLResourceUsageRead | MTLResourceUsageWrite; >+ } >+ useResource(bufferRef->platformBuffer(), usage); > m_commandBuffer->useBuffer(bufferRef.copyRef()); > } > for (auto& textureRef : bindGroup.boundTextures()) { >- useResource(textureRef->platformTexture(), textureRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite); >+ MTLResourceUsage usage = 0; >+ if (textureRef->isSampled()) { >+ ASSERT(!textureRef->isStorage()); >+ usage = MTLResourceUsageRead | MTLResourceUsageSample; >+ } else if (textureRef->isStorage()) { >+ ASSERT(!textureRef->isSampled()); >+ usage = MTLResourceUsageRead | MTLResourceUsageWrite; >+ } >+ useResource(textureRef->platformTexture(), usage); > m_commandBuffer->useTexture(textureRef.copyRef()); > } > } >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >index f56661d6c280c031cff02a664e865dbd8117f05f..dcdac99c44514f282fad5e834f957ecd05e1b102 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm >@@ -410,6 +410,8 @@ static bool trySetFunctions(const char* const functionName, const GPUPipelineSta > if (!whlslCompileResult) > return false; > >+ WTFLogAlways("%s", whlslCompileResult->metalSource.utf8().data()); >+ > NSError *error = nil; > > BEGIN_BLOCK_OBJC_EXCEPTIONS; >diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPUTextureMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPUTextureMetal.mm >index 783c0130ba69b24387cd817eee2c85cc306389a7..ee48928618db282590a894240648abc88ceda0b3 100644 >--- a/Source/WebCore/platform/graphics/gpu/cocoa/GPUTextureMetal.mm >+++ b/Source/WebCore/platform/graphics/gpu/cocoa/GPUTextureMetal.mm >@@ -59,27 +59,26 @@ static Optional<MTLTextureUsage> mtlTextureUsageForGPUTextureUsageFlags(OptionSe > #if LOG_DISABLED > UNUSED_PARAM(functionName); > #endif >+ > if (flags.containsAny({ GPUTextureUsage::Flags::TransferSource, GPUTextureUsage::Flags::Sampled }) && (flags & GPUTextureUsage::Flags::Storage)) { > LOG(WebGPU, "%s: Texture cannot have both STORAGE and a read-only usage!", functionName); > return WTF::nullopt; > } > >- if (flags & GPUTextureUsage::Flags::OutputAttachment) { >- if (flags.containsAny({ GPUTextureUsage::Flags::Storage, GPUTextureUsage::Flags::Sampled })) { >- LOG(WebGPU, "%s: Texture cannot have OUTPUT_ATTACHMENT usage with STORAGE or SAMPLED usages!", functionName); >- return WTF::nullopt; >- } >- >- return MTLTextureUsageRenderTarget | MTLTextureUsagePixelFormatView; >+ if (flags & GPUTextureUsage::Flags::OutputAttachment && flags.containsAny({ GPUTextureUsage::Flags::Storage, GPUTextureUsage::Flags::Sampled })) { >+ LOG(WebGPU, "%s: Texture cannot have OUTPUT_ATTACHMENT usage with STORAGE or SAMPLED usages!", functionName); >+ return WTF::nullopt; > } > >- if (flags & GPUTextureUsage::Flags::Storage) >- return MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead | MTLTextureUsagePixelFormatView; >- >- if (flags & GPUTextureUsage::Flags::Sampled) >- return MTLTextureUsageShaderRead | MTLTextureUsagePixelFormatView; >+ MTLTextureUsage result = MTLTextureUsagePixelFormatView; >+ if (flags.contains(GPUTextureUsage::Flags::OutputAttachment)) >+ result |= MTLTextureUsageRenderTarget; >+ if (flags.containsAny({ GPUTextureUsage::Flags::Storage, GPUTextureUsage::Flags::Sampled })) >+ result |= MTLTextureUsageShaderRead; >+ if (flags.contains(GPUTextureUsage::Flags::Storage)) >+ result |= MTLTextureUsageShaderWrite; > >- return MTLTextureUsageUnknown; >+ return result; > } > > #if !PLATFORM(MAC) >diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp >index f158268b3bb959de918e06734687862b0f79ce91..0bd0c5ffec5fb2da593d745d29cb0b6af414fde9 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.cpp >+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp >@@ -2559,7 +2559,7 @@ void WebProcessPool::clearWebProcessHasUploads(ProcessIdentifier processID) > { > ASSERT(processID); > auto result = m_processesWithUploads.take(processID); >- ASSERT(result); >+ //ASSERT(result); > if (!result) > return; > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index d8a8d9b40cba2f8b31429215824330f07aee4ead..c3db3dfb3062e843e716c7d84958441cd37bd1df 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2019-06-15 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [WHLSL] Hook up common texture functions >+ https://bugs.webkit.org/show_bug.cgi?id=198704 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * webgpu/whlsl-textures-load-expected.html: Added. >+ * webgpu/whlsl-textures-load.html: Added. >+ * webgpu/whlsl-textures-sample-expected.html: Added. >+ * webgpu/whlsl-textures-sample.html: Added. >+ * webgpu/whlsl-textures-store.html: Added. >+ > 2019-06-14 Devin Rousso <drousso@apple.com> > > Web Inspector: rework http/tests/inspector/network/resource-sizes-network.html to print the actual values so other platforms don't FAIL >diff --git a/LayoutTests/webgpu/whlsl-textures-load-expected.html b/LayoutTests/webgpu/whlsl-textures-load-expected.html >new file mode 100644 >index 0000000000000000000000000000000000000000..f417050f9a743f05e9006fc91ac64d502dadd633 >--- /dev/null >+++ b/LayoutTests/webgpu/whlsl-textures-load-expected.html >@@ -0,0 +1,19 @@ >+<!DOCTYPE html> >+<html> >+<head> >+</head> >+<body> >+<canvas id="canvas" width="400" height="400"></canvas> >+<script> >+async function start() { >+ const canvas = document.getElementById("canvas"); >+ const context = canvas.getContext("2d"); >+ context.fillStyle = "blue"; >+ context.fillRect(0, 0, 400, 400); >+ context.fillStyle = "white"; >+ context.fillRect(100, 100, 200, 200); >+} >+window.addEventListener("load", start); >+</script> >+</body> >+</html> >diff --git a/LayoutTests/webgpu/whlsl-textures-load.html b/LayoutTests/webgpu/whlsl-textures-load.html >new file mode 100644 >index 0000000000000000000000000000000000000000..edcd4e2015c86eb53466e255a4f08754ae0983f7 >--- /dev/null >+++ b/LayoutTests/webgpu/whlsl-textures-load.html >@@ -0,0 +1,131 @@ >+<!DOCTYPE html> >+<html> >+<head> >+</head> >+<body> >+<canvas id="canvas" width="400" height="400"></canvas> >+<script> >+const shaderSource = ` >+vertex float4 vertexShader(float4 position : attribute(0)) : SV_Position { >+ return position; >+} >+ >+fragment float4 fragmentShader(Texture2D<float4> theTexture : register(t0)) : SV_Target 0 { >+ return Load(theTexture, int2(0, 0)); >+} >+`; >+async function start() { >+ const adapter = await navigator.gpu.requestAdapter(); >+ const device = await adapter.requestDevice(); >+ >+ const shaderModule = device.createShaderModule({code: shaderSource, isWHLSL: true}); >+ const vertexStage = {module: shaderModule, entryPoint: "vertexShader"}; >+ const fragmentStage = {module: shaderModule, entryPoint: "fragmentShader"}; >+ const primitiveTopology = "triangle-strip"; >+ const rasterizationState = {frontFace: "cw", cullMode: "none"}; >+ const alphaBlend = {}; >+ const colorBlend = {}; >+ const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL >+ const depthStencilState = null; >+ >+ const attribute0 = {shaderLocation: 0, format: "float4"}; >+ const input0 = {stride: 16, attributeSet: [attribute0]}; >+ const inputs = [input0]; >+ const vertexInput = {vertexBuffers: inputs}; >+ >+ const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "sampled-texture"}]}; >+ const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor); >+ const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]}; >+ const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor); >+ >+ const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout}; >+ const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor); >+ >+ const vertexBuffer0Descriptor = {size: Float32Array.BYTES_PER_ELEMENT * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.MAP_WRITE}; >+ const vertexBuffer0 = device.createBuffer(vertexBuffer0Descriptor); >+ const vertexBuffer0ArrayBuffer = await vertexBuffer0.mapWriteAsync(); >+ const vertexBuffer0Float32Array = new Float32Array(vertexBuffer0ArrayBuffer); >+ vertexBuffer0Float32Array[0] = -0.5; >+ vertexBuffer0Float32Array[1] = -0.5; >+ vertexBuffer0Float32Array[2] = 1.0; >+ vertexBuffer0Float32Array[3] = 1; >+ vertexBuffer0Float32Array[4] = -0.5; >+ vertexBuffer0Float32Array[5] = 0.5; >+ vertexBuffer0Float32Array[6] = 1.0; >+ vertexBuffer0Float32Array[7] = 1; >+ vertexBuffer0Float32Array[8] = 0.5; >+ vertexBuffer0Float32Array[9] = -0.5; >+ vertexBuffer0Float32Array[10] = 1.0; >+ vertexBuffer0Float32Array[11] = 1; >+ vertexBuffer0Float32Array[12] = 0.5; >+ vertexBuffer0Float32Array[13] = 0.5; >+ vertexBuffer0Float32Array[14] = 1.0; >+ vertexBuffer0Float32Array[15] = 1; >+ vertexBuffer0.unmap(); >+ >+ const textureDataBufferDescriptor = {size: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2, usage: GPUBufferUsage.TRANSFER_SRC | GPUBufferUsage.MAP_WRITE}; >+ const textureDataBuffer = device.createBuffer(textureDataBufferDescriptor); >+ const textureDataBufferArrayBuffer = await textureDataBuffer.mapWriteAsync(); >+ const textureDataBufferUint8Array = new Uint8Array(textureDataBufferArrayBuffer); >+ textureDataBufferUint8Array[0] = 255; >+ textureDataBufferUint8Array[1] = 255; >+ textureDataBufferUint8Array[2] = 255; >+ textureDataBufferUint8Array[3] = 255; >+ textureDataBufferUint8Array[4] = 128; >+ textureDataBufferUint8Array[5] = 128; >+ textureDataBufferUint8Array[6] = 128; >+ textureDataBufferUint8Array[7] = 255; >+ textureDataBufferUint8Array[8] = 128; >+ textureDataBufferUint8Array[9] = 128; >+ textureDataBufferUint8Array[10] = 128; >+ textureDataBufferUint8Array[11] = 255; >+ textureDataBufferUint8Array[12] = 128; >+ textureDataBufferUint8Array[13] = 128; >+ textureDataBufferUint8Array[14] = 128; >+ textureDataBufferUint8Array[15] = 255; >+ textureDataBuffer.unmap(); >+ >+ const textureDescriptor = {size: {width: 2, height: 2, depth: 1}, format: "rgba8unorm", usage: GPUTextureUsage.SAMPLED | GPUTextureUsage.TRANSFER_DST}; >+ const texture = device.createTexture(textureDescriptor); >+ const textureView = texture.createDefaultView(); >+ >+ const bindGroupBindings = [{binding: 0, resource: textureView}]; >+ const bindGroupDescriptor = {layout: bindGroupLayout, bindings: bindGroupBindings}; >+ const bindGroup = device.createBindGroup(bindGroupDescriptor); >+ >+ const canvas = document.getElementById("canvas"); >+ const context = canvas.getContext("gpu"); >+ const swapChainDescriptor = {device, format: "bgra8unorm"}; >+ const swapChain = context.configureSwapChain(swapChainDescriptor); >+ const outputTexture = swapChain.getCurrentTexture(); >+ const outputTextureView = outputTexture.createDefaultView(); >+ >+ const commandEncoder = device.createCommandEncoder(); // {} >+ >+ const bufferCopyView = {buffer: textureDataBuffer, rowPitch: Uint8Array.BYTES_PER_ELEMENT * 4 * 2, imageHeight: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2}; >+ const textureCopyView = {texture: texture}; >+ const copySize = {width: 2, height: 2, depth: 1}; >+ commandEncoder.copyBufferToTexture(bufferCopyView, textureCopyView, copySize); >+ >+ const clearColor = {r: 0, g: 0, b: 1, a: 1}; >+ const colorAttachments = [{attachment: outputTextureView, resolveTarget: null, loadOp: "clear", storeOp: "store", clearColor}]; >+ const depthStencilAttachment = null; >+ const renderPassDescriptor = {colorAttachments, depthStencilAttachment}; >+ const renderPassEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); >+ renderPassEncoder.setPipeline(renderPipeline); >+ renderPassEncoder.setBindGroup(0, bindGroup); >+ renderPassEncoder.setVertexBuffers(0, [vertexBuffer0], [0]); >+ renderPassEncoder.draw(4, 1, 0, 0); >+ renderPassEncoder.endPass(); >+ const commandBuffer = commandEncoder.finish(); >+ device.getQueue().submit([commandBuffer]); >+ >+ if (window.testRunner) >+ testRunner.notifyDone(); >+} >+if (window.testRunner) >+ testRunner.waitUntilDone(); >+window.addEventListener("load", start); >+</script> >+</body> >+</html> >diff --git a/LayoutTests/webgpu/whlsl-textures-sample-expected.html b/LayoutTests/webgpu/whlsl-textures-sample-expected.html >new file mode 100644 >index 0000000000000000000000000000000000000000..f417050f9a743f05e9006fc91ac64d502dadd633 >--- /dev/null >+++ b/LayoutTests/webgpu/whlsl-textures-sample-expected.html >@@ -0,0 +1,19 @@ >+<!DOCTYPE html> >+<html> >+<head> >+</head> >+<body> >+<canvas id="canvas" width="400" height="400"></canvas> >+<script> >+async function start() { >+ const canvas = document.getElementById("canvas"); >+ const context = canvas.getContext("2d"); >+ context.fillStyle = "blue"; >+ context.fillRect(0, 0, 400, 400); >+ context.fillStyle = "white"; >+ context.fillRect(100, 100, 200, 200); >+} >+window.addEventListener("load", start); >+</script> >+</body> >+</html> >diff --git a/LayoutTests/webgpu/whlsl-textures-sample.html b/LayoutTests/webgpu/whlsl-textures-sample.html >new file mode 100644 >index 0000000000000000000000000000000000000000..2dffb00d41d06d05b7efd73f6ec75851c06c48f1 >--- /dev/null >+++ b/LayoutTests/webgpu/whlsl-textures-sample.html >@@ -0,0 +1,134 @@ >+<!DOCTYPE html> >+<html> >+<head> >+</head> >+<body> >+<canvas id="canvas" width="400" height="400"></canvas> >+<script> >+const shaderSource = ` >+vertex float4 vertexShader(float4 position : attribute(0)) : SV_Position { >+ return position; >+} >+ >+fragment float4 fragmentShader(Texture2D<float4> theTexture : register(t0), sampler theSampler : register(s1)) : SV_Target 0 { >+ return Sample(theTexture, theSampler, float2(0.5, 0.5)); >+} >+`; >+async function start() { >+ const adapter = await navigator.gpu.requestAdapter(); >+ const device = await adapter.requestDevice(); >+ >+ const shaderModule = device.createShaderModule({code: shaderSource, isWHLSL: true}); >+ const vertexStage = {module: shaderModule, entryPoint: "vertexShader"}; >+ const fragmentStage = {module: shaderModule, entryPoint: "fragmentShader"}; >+ const primitiveTopology = "triangle-strip"; >+ const rasterizationState = {frontFace: "cw", cullMode: "none"}; >+ const alphaBlend = {}; >+ const colorBlend = {}; >+ const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL >+ const depthStencilState = null; >+ >+ const attribute0 = {shaderLocation: 0, format: "float4"}; >+ const input0 = {stride: 16, attributeSet: [attribute0]}; >+ const inputs = [input0]; >+ const vertexInput = {vertexBuffers: inputs}; >+ >+ const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "sampled-texture"}, {binding: 1, visibility: 7, type: "sampler"}]}; >+ const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor); >+ const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]}; >+ const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor); >+ >+ const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout}; >+ const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor); >+ >+ const vertexBuffer0Descriptor = {size: Float32Array.BYTES_PER_ELEMENT * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.MAP_WRITE}; >+ const vertexBuffer0 = device.createBuffer(vertexBuffer0Descriptor); >+ const vertexBuffer0ArrayBuffer = await vertexBuffer0.mapWriteAsync(); >+ const vertexBuffer0Float32Array = new Float32Array(vertexBuffer0ArrayBuffer); >+ vertexBuffer0Float32Array[0] = -0.5; >+ vertexBuffer0Float32Array[1] = -0.5; >+ vertexBuffer0Float32Array[2] = 1.0; >+ vertexBuffer0Float32Array[3] = 1; >+ vertexBuffer0Float32Array[4] = -0.5; >+ vertexBuffer0Float32Array[5] = 0.5; >+ vertexBuffer0Float32Array[6] = 1.0; >+ vertexBuffer0Float32Array[7] = 1; >+ vertexBuffer0Float32Array[8] = 0.5; >+ vertexBuffer0Float32Array[9] = -0.5; >+ vertexBuffer0Float32Array[10] = 1.0; >+ vertexBuffer0Float32Array[11] = 1; >+ vertexBuffer0Float32Array[12] = 0.5; >+ vertexBuffer0Float32Array[13] = 0.5; >+ vertexBuffer0Float32Array[14] = 1.0; >+ vertexBuffer0Float32Array[15] = 1; >+ vertexBuffer0.unmap(); >+ >+ const textureDataBufferDescriptor = {size: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2, usage: GPUBufferUsage.TRANSFER_SRC | GPUBufferUsage.MAP_WRITE}; >+ const textureDataBuffer = device.createBuffer(textureDataBufferDescriptor); >+ const textureDataBufferArrayBuffer = await textureDataBuffer.mapWriteAsync(); >+ const textureDataBufferUint8Array = new Uint8Array(textureDataBufferArrayBuffer); >+ textureDataBufferUint8Array[0] = 255; >+ textureDataBufferUint8Array[1] = 255; >+ textureDataBufferUint8Array[2] = 255; >+ textureDataBufferUint8Array[3] = 255; >+ textureDataBufferUint8Array[4] = 255; >+ textureDataBufferUint8Array[5] = 255; >+ textureDataBufferUint8Array[6] = 255; >+ textureDataBufferUint8Array[7] = 255; >+ textureDataBufferUint8Array[8] = 255; >+ textureDataBufferUint8Array[9] = 255; >+ textureDataBufferUint8Array[10] = 255; >+ textureDataBufferUint8Array[11] = 255; >+ textureDataBufferUint8Array[12] = 255; >+ textureDataBufferUint8Array[13] = 255; >+ textureDataBufferUint8Array[14] = 255; >+ textureDataBufferUint8Array[15] = 255; >+ textureDataBuffer.unmap(); >+ >+ const textureDescriptor = {size: {width: 2, height: 2, depth: 1}, format: "rgba8unorm", usage: GPUTextureUsage.SAMPLED | GPUTextureUsage.TRANSFER_DST}; >+ const texture = device.createTexture(textureDescriptor); >+ const textureView = texture.createDefaultView(); >+ >+ const samplerDescriptor = {magFilter: "linear", minFilter: "linear"}; >+ const sampler = device.createSampler(samplerDescriptor); >+ >+ const bindGroupBindings = [{binding: 0, resource: textureView}, {binding: 1, resource: sampler}]; >+ const bindGroupDescriptor = {layout: bindGroupLayout, bindings: bindGroupBindings}; >+ const bindGroup = device.createBindGroup(bindGroupDescriptor); >+ >+ const canvas = document.getElementById("canvas"); >+ const context = canvas.getContext("gpu"); >+ const swapChainDescriptor = {device, format: "bgra8unorm"}; >+ const swapChain = context.configureSwapChain(swapChainDescriptor); >+ const outputTexture = swapChain.getCurrentTexture(); >+ const outputTextureView = outputTexture.createDefaultView(); >+ >+ const commandEncoder = device.createCommandEncoder(); // {} >+ >+ const bufferCopyView = {buffer: textureDataBuffer, rowPitch: Uint8Array.BYTES_PER_ELEMENT * 4 * 2, imageHeight: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2}; >+ const textureCopyView = {texture: texture}; >+ const copySize = {width: 2, height: 2, depth: 1}; >+ commandEncoder.copyBufferToTexture(bufferCopyView, textureCopyView, copySize); >+ >+ const clearColor = {r: 0, g: 0, b: 1, a: 1}; >+ const colorAttachments = [{attachment: outputTextureView, resolveTarget: null, loadOp: "clear", storeOp: "store", clearColor}]; >+ const depthStencilAttachment = null; >+ const renderPassDescriptor = {colorAttachments, depthStencilAttachment}; >+ const renderPassEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); >+ renderPassEncoder.setPipeline(renderPipeline); >+ renderPassEncoder.setBindGroup(0, bindGroup); >+ renderPassEncoder.setVertexBuffers(0, [vertexBuffer0], [0]); >+ renderPassEncoder.draw(4, 1, 0, 0); >+ renderPassEncoder.endPass(); >+ const commandBuffer = commandEncoder.finish(); >+ device.getQueue().submit([commandBuffer]); >+ >+ if (window.testRunner) >+ testRunner.notifyDone(); >+} >+if (window.testRunner) >+ testRunner.waitUntilDone(); >+window.addEventListener("load", start); >+</script> >+</body> >+</html> >diff --git a/LayoutTests/webgpu/whlsl-textures-store-expected.html b/LayoutTests/webgpu/whlsl-textures-store-expected.html >new file mode 100644 >index 0000000000000000000000000000000000000000..f417050f9a743f05e9006fc91ac64d502dadd633 >--- /dev/null >+++ b/LayoutTests/webgpu/whlsl-textures-store-expected.html >@@ -0,0 +1,19 @@ >+<!DOCTYPE html> >+<html> >+<head> >+</head> >+<body> >+<canvas id="canvas" width="400" height="400"></canvas> >+<script> >+async function start() { >+ const canvas = document.getElementById("canvas"); >+ const context = canvas.getContext("2d"); >+ context.fillStyle = "blue"; >+ context.fillRect(0, 0, 400, 400); >+ context.fillStyle = "white"; >+ context.fillRect(100, 100, 200, 200); >+} >+window.addEventListener("load", start); >+</script> >+</body> >+</html> >diff --git a/LayoutTests/webgpu/whlsl-textures-store.html b/LayoutTests/webgpu/whlsl-textures-store.html >new file mode 100644 >index 0000000000000000000000000000000000000000..1c5a2ebcb22bddace1c1759339ac20bbd867c9c1 >--- /dev/null >+++ b/LayoutTests/webgpu/whlsl-textures-store.html >@@ -0,0 +1,149 @@ >+<!DOCTYPE html> >+<html> >+<head> >+</head> >+<body> >+<canvas id="canvas" width="400" height="400"></canvas> >+<script> >+const shaderSource = ` >+[numthreads(1, 1, 1)] >+compute void computeShader(RWTexture2D<float4> theTexture : register(t0)) { >+ Store(theTexture, float4(1.0, 1.0, 1.0, 1.0), uint2(0, 0)); >+} >+vertex float4 vertexShader(float4 position : attribute(0)) : SV_Position { >+ return position; >+} >+ >+fragment float4 fragmentShader(RWTexture2D<float4> theTexture : register(t0)) : SV_Target 0 { >+ return Load(theTexture, int2(0, 0)); >+} >+`; >+let resultsUint8Array; >+async function start() { >+ const adapter = await navigator.gpu.requestAdapter(); >+ const device = await adapter.requestDevice(); >+ >+ const shaderModule = device.createShaderModule({code: shaderSource, isWHLSL: true}); >+ const computeStage = {module: shaderModule, entryPoint: "computeShader"}; >+ const vertexStage = {module: shaderModule, entryPoint: "vertexShader"}; >+ const fragmentStage = {module: shaderModule, entryPoint: "fragmentShader"}; >+ >+ const attribute = {shaderLocation: 0, format: "float4"}; >+ const input = {stride: 16, attributeSet: [attribute]}; >+ const vertexInput = {vertexBuffers: [input]}; >+ >+ const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "sampled-texture"}]}; >+ const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor); >+ const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]}; >+ const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor); >+ >+ const computePipelineDescriptor = {computeStage, layout: pipelineLayout}; >+ const computePipeline = device.createComputePipeline(computePipelineDescriptor); >+ >+ const primitiveTopology = "triangle-strip"; >+ const rasterizationState = {frontFace: "cw", cullMode: "none"}; >+ const alphaBlend = {}; >+ const colorBlend = {}; >+ const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL >+ const depthStencilState = null; >+ const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout}; >+ const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor); >+ >+ const vertexBufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.MAP_WRITE}; >+ const vertexBuffer = device.createBuffer(vertexBufferDescriptor); >+ const vertexBufferArrayBuffer = await vertexBuffer.mapWriteAsync(); >+ const vertexBufferFloat32Array = new Float32Array(vertexBufferArrayBuffer); >+ vertexBufferFloat32Array[0] = -0.5; >+ vertexBufferFloat32Array[1] = -0.5; >+ vertexBufferFloat32Array[2] = 1.0; >+ vertexBufferFloat32Array[3] = 1; >+ vertexBufferFloat32Array[4] = -0.5; >+ vertexBufferFloat32Array[5] = 0.5; >+ vertexBufferFloat32Array[6] = 1.0; >+ vertexBufferFloat32Array[7] = 1; >+ vertexBufferFloat32Array[8] = 0.5; >+ vertexBufferFloat32Array[9] = -0.5; >+ vertexBufferFloat32Array[10] = 1.0; >+ vertexBufferFloat32Array[11] = 1; >+ vertexBufferFloat32Array[12] = 0.5; >+ vertexBufferFloat32Array[13] = 0.5; >+ vertexBufferFloat32Array[14] = 1.0; >+ vertexBufferFloat32Array[15] = 1; >+ vertexBuffer.unmap(); >+ >+ const textureDataBufferDescriptor = {size: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2, usage: GPUBufferUsage.TRANSFER_SRC | GPUBufferUsage.MAP_WRITE}; >+ const textureDataBuffer = device.createBuffer(textureDataBufferDescriptor); >+ const textureDataBufferArrayBuffer = await textureDataBuffer.mapWriteAsync(); >+ const textureDataBufferUint8Array = new Uint8Array(textureDataBufferArrayBuffer); >+ textureDataBufferUint8Array[0] = 0; >+ textureDataBufferUint8Array[1] = 0; >+ textureDataBufferUint8Array[2] = 0; >+ textureDataBufferUint8Array[3] = 0; >+ textureDataBufferUint8Array[4] = 0; >+ textureDataBufferUint8Array[5] = 0; >+ textureDataBufferUint8Array[6] = 0; >+ textureDataBufferUint8Array[7] = 0; >+ textureDataBufferUint8Array[8] = 0; >+ textureDataBufferUint8Array[9] = 0; >+ textureDataBufferUint8Array[10] = 0; >+ textureDataBufferUint8Array[11] = 0; >+ textureDataBufferUint8Array[12] = 0; >+ textureDataBufferUint8Array[13] = 0; >+ textureDataBufferUint8Array[14] = 0; >+ textureDataBufferUint8Array[15] = 0; >+ textureDataBuffer.unmap(); >+ >+ const textureDescriptor = {size: {width: 2, height: 2, depth: 1}, format: "rgba8unorm", usage: GPUTextureUsage.STORAGE | GPUTextureUsage.TRANSFER_DST}; >+ const texture = device.createTexture(textureDescriptor); >+ const textureView = texture.createDefaultView(); >+ >+ const bindGroupBinding = {binding: 0, resource: textureView}; >+ const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]}; >+ const bindGroup = device.createBindGroup(bindGroupDescriptor); >+ >+ const canvas = document.getElementById("canvas"); >+ const context = canvas.getContext("gpu"); >+ const swapChainDescriptor = {device, format: "bgra8unorm"}; >+ const swapChain = context.configureSwapChain(swapChainDescriptor); >+ const outputTexture = swapChain.getCurrentTexture(); >+ const outputTextureView = outputTexture.createDefaultView(); >+ >+ const bufferCopyView = {buffer: textureDataBuffer, rowPitch: Uint8Array.BYTES_PER_ELEMENT * 4 * 2, imageHeight: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2}; >+ const textureCopyView = {texture}; >+ const copySize = {width: 2, height: 2, depth: 1}; >+ >+ const commandEncoder = device.createCommandEncoder(); // {} >+ commandEncoder.copyBufferToTexture(bufferCopyView, textureCopyView, copySize); >+ const computePassEncoder = commandEncoder.beginComputePass(); >+ computePassEncoder.setPipeline(computePipeline); >+ computePassEncoder.setBindGroup(0, bindGroup); >+ computePassEncoder.dispatch(1, 1, 1); >+ computePassEncoder.endPass(); >+ const red = {r: 0, g: 0, b: 1, a: 1}; >+ const colorAttachments = [{attachment: outputTextureView, resolveTarget: null, loadOp: "clear", storeOp: "store", clearColor: red}]; >+ const depthStencilAttachment = null; >+ const renderPassDescriptor = {colorAttachments, depthStencilAttachment}; >+ const renderPassEncoder = commandEncoder.beginRenderPass(renderPassDescriptor); >+ renderPassEncoder.setPipeline(renderPipeline); >+ renderPassEncoder.setBindGroup(0, bindGroup); >+ renderPassEncoder.setVertexBuffers(0, [vertexBuffer], [0]); >+ renderPassEncoder.draw(4, 1, 0, 0); >+ renderPassEncoder.endPass(); >+ const commandBuffer = commandEncoder.finish(); >+ device.getQueue().submit([commandBuffer]); >+} >+if (window.testRunner) >+ testRunner.waitUntilDone(); >+window.addEventListener("load", function() { >+ start().then(function() { >+ if (window.testRunner) >+ testRunner.notifyDone(); >+ }, function(e) { >+ alert(e); >+ if (window.testRunner) >+ testRunner.notifyDone(); >+ }); >+}); >+</script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198704
:
371723
|
371725
|
372024
|
372027
|
372105
|
372109
|
372115
|
372195
|
372234
|
372235
|
372238
|
372239
|
372316
|
372378
|
372421
|
372423
|
372470