WebKit Bugzilla
Attachment 372267 Details for
Bug 198890
: [WHLSL] Make .length work
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
b-backup.diff (text/plain), 24.18 KB, created by
Saam Barati
on 2019-06-17 13:21:43 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Saam Barati
Created:
2019-06-17 13:21:43 PDT
Size:
24.18 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 246511) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,41 @@ >+2019-06-17 Saam Barati <sbarati@apple.com> >+ >+ [WHLSL] Make .length work >+ https://bugs.webkit.org/show_bug.cgi?id=198890 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch makes accessing .length on buffers work. To make this work as >+ expected, I've fixed a handful of small bugs: >+ >+ - The checker was not calling resolveByInstantiation for getters. This patch >+ modifies the checker to do that, so we can now resolve a getter to >+ "operator.length". I also refactored the checker to have a helper method >+ that both does overload resolution and resolveByInstantiation to make it >+ difficult to forget to call resolveByInstantiation. >+ - The property resolver had a bug where it would return a non-null value >+ in anderCallArgument for array references even when there was no ander and >+ no thread ander function. This patch makes it now return null if there is >+ neither an ander nor a thread ander. >+ - The metal codegen incorrectly unpacked the length of buffers. It swapped the >+ bottom four bytes and the top four bytes of the size_t value. This patch >+ corrects that. This was also a cause of flakiness in various tests since >+ we ended up with a length much larger than expected, leading to bounds >+ checks always passing in our tests. >+ - This patch also fixes our tests to specify the output buffer length >+ properly for various programs. >+ >+ Test: webgpu/whlsl-buffer-length.html >+ >+ * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp: >+ (WebCore::WHLSL::Metal::EntryPointScaffolding::unpackResourcesAndNamedBuiltIns): >+ * Modules/webgpu/WHLSL/WHLSLChecker.cpp: >+ (WebCore::WHLSL::resolveFunction): >+ (WebCore::WHLSL::Checker::finishVisiting): >+ (WebCore::WHLSL::Checker::visit): >+ * Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp: >+ (WebCore::WHLSL::anderCallArgument): >+ > 2019-06-17 Kenneth Russell <kbr@chromium.org> > > Support using ANGLE as the backend for the WebGL implementation >Index: Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp >=================================================================== >--- Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp (revision 246503) >+++ Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp (working copy) >@@ -215,6 +215,19 @@ static Optional<AST::NativeFunctionDecla > return WTF::nullopt; > } > >+static AST::FunctionDeclaration* resolveFunction(Program& program, Vector<std::reference_wrapper<AST::FunctionDeclaration>, 1>& possibleOverloads, Vector<std::reference_wrapper<ResolvingType>>& types, const String& name, Lexer::Token origin, const Intrinsics& intrinsics, AST::NamedType* castReturnType = nullptr) >+{ >+ if (AST::FunctionDeclaration* function = resolveFunctionOverload(possibleOverloads, types, castReturnType)) >+ return function; >+ >+ if (auto newFunction = resolveByInstantiation(name, origin, types, intrinsics)) { >+ program.append(WTFMove(*newFunction)); >+ return &program.nativeFunctionDeclarations().last(); >+ } >+ >+ return nullptr; >+} >+ > static bool checkSemantics(Vector<EntryPointItem>& inputItems, Vector<EntryPointItem>& outputItems, const Optional<AST::EntryPointType>& entryPointType, const Intrinsics& intrinsics) > { > { >@@ -1004,7 +1017,7 @@ void Checker::finishVisiting(AST::Proper > Vector<std::reference_wrapper<ResolvingType>> getterArgumentTypes { baseInfo->resolvingType }; > if (additionalArgumentType) > getterArgumentTypes.append(*additionalArgumentType); >- if ((getterFunction = resolveFunctionOverload(propertyAccessExpression.possibleGetterOverloads(), getterArgumentTypes))) >+ if ((getterFunction = resolveFunction(m_program, propertyAccessExpression.possibleGetterOverloads(), getterArgumentTypes, propertyAccessExpression.getterFunctionName(), propertyAccessExpression.origin(), m_intrinsics))) > getterReturnType = &getterFunction->type(); > } > >@@ -1017,13 +1030,8 @@ void Checker::finishVisiting(AST::Proper > Vector<std::reference_wrapper<ResolvingType>> anderArgumentTypes { argumentType }; > if (additionalArgumentType) > anderArgumentTypes.append(*additionalArgumentType); >- if ((anderFunction = resolveFunctionOverload(propertyAccessExpression.possibleAnderOverloads(), anderArgumentTypes))) >- anderReturnType = &downcast<AST::PointerType>(anderFunction->type()).elementType(); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198164 Enforce the return of anders will always be a pointer >- else if (auto newFunction = resolveByInstantiation(propertyAccessExpression.anderFunctionName(), propertyAccessExpression.origin(), anderArgumentTypes, m_intrinsics)) { >- m_program.append(WTFMove(*newFunction)); >- anderFunction = &m_program.nativeFunctionDeclarations().last(); >+ if ((anderFunction = resolveFunction(m_program, propertyAccessExpression.possibleAnderOverloads(), anderArgumentTypes, propertyAccessExpression.anderFunctionName(), propertyAccessExpression.origin(), m_intrinsics))) > anderReturnType = &downcast<AST::PointerType>(anderFunction->type()).elementType(); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198164 Enforce the return of anders will always be a pointer >- } > } > } > >@@ -1034,13 +1042,8 @@ void Checker::finishVisiting(AST::Proper > Vector<std::reference_wrapper<ResolvingType>> threadAnderArgumentTypes { argumentType }; > if (additionalArgumentType) > threadAnderArgumentTypes.append(*additionalArgumentType); >- if ((threadAnderFunction = resolveFunctionOverload(propertyAccessExpression.possibleAnderOverloads(), threadAnderArgumentTypes))) >+ if ((threadAnderFunction = resolveFunction(m_program, propertyAccessExpression.possibleAnderOverloads(), threadAnderArgumentTypes, propertyAccessExpression.anderFunctionName(), propertyAccessExpression.origin(), m_intrinsics))) > threadAnderReturnType = &downcast<AST::PointerType>(threadAnderFunction->type()).elementType(); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198164 Enforce the return of anders will always be a pointer >- else if (auto newFunction = resolveByInstantiation(propertyAccessExpression.anderFunctionName(), propertyAccessExpression.origin(), threadAnderArgumentTypes, m_intrinsics)) { >- m_program.append(WTFMove(*newFunction)); >- threadAnderFunction = &m_program.nativeFunctionDeclarations().last(); >- threadAnderReturnType = &downcast<AST::PointerType>(anderFunction->type()).elementType(); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198164 Enforce the return of anders will always be a pointer >- } > } > > if (leftAddressSpace && !anderFunction && !getterFunction) { >@@ -1083,7 +1086,7 @@ void Checker::finishVisiting(AST::Proper > if (additionalArgumentType) > setterArgumentTypes.append(*additionalArgumentType); > setterArgumentTypes.append(fieldResolvingType); >- setterFunction = resolveFunctionOverload(propertyAccessExpression.possibleSetterOverloads(), setterArgumentTypes); >+ setterFunction = resolveFunction(m_program, propertyAccessExpression.possibleSetterOverloads(), setterArgumentTypes, propertyAccessExpression.setterFunctionName(), propertyAccessExpression.origin(), m_intrinsics); > if (setterFunction) > setterReturnType = &setterFunction->type(); > } >@@ -1468,14 +1471,7 @@ void Checker::visit(AST::CallExpression& > // We don't want to recurse to the same node twice. > > ASSERT(callExpression.hasOverloads()); >- auto* function = resolveFunctionOverload(*callExpression.overloads(), types, callExpression.castReturnType()); >- if (!function) { >- if (auto newFunction = resolveByInstantiation(callExpression.name(), callExpression.origin(), types, m_intrinsics)) { >- m_program.append(WTFMove(*newFunction)); >- function = &m_program.nativeFunctionDeclarations().last(); >- } >- } >- >+ auto* function = resolveFunction(m_program, *callExpression.overloads(), types, callExpression.name(), callExpression.origin(), m_intrinsics, callExpression.castReturnType()); > if (!function) { > setError(); > return; >Index: Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp >=================================================================== >--- Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp (revision 246503) >+++ Source/WebCore/Modules/webgpu/WHLSL/WHLSLPropertyResolver.cpp (working copy) >@@ -142,6 +142,8 @@ static Optional<AnderCallArgumentResult> > > static Optional<AnderCallArgumentResult> anderCallArgument(UniqueRef<AST::Expression>& expression, bool anderFunction, bool threadAnderFunction) > { >+ if (!anderFunction && !threadAnderFunction) >+ return WTF::nullopt; > auto& unifyNode = expression->resolvedType().unifyNode(); > if (is<AST::UnnamedType>(unifyNode)) { > auto& unnamedType = downcast<AST::UnnamedType>(unifyNode); >Index: Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp >=================================================================== >--- Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp (revision 246503) >+++ Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp (working copy) >@@ -315,9 +315,9 @@ String EntryPointScaffolding::unpackReso > auto& unnamedType = *m_entryPointItems.inputs[iterator->value].unnamedType; > auto mangledTypeName = m_typeNamer.mangledNameForType(downcast<AST::ReferenceType>(unnamedType).elementType()); > >- stringBuilder.append(makeString("size_t ", lengthTemporaryName, " = ", variableName, '.', lengthElementName, ".x;\n")); >+ stringBuilder.append(makeString("size_t ", lengthTemporaryName, " = ", variableName, '.', lengthElementName, ".y;\n")); > stringBuilder.append(makeString(lengthTemporaryName, " = ", lengthTemporaryName, " << 32;\n")); >- stringBuilder.append(makeString(lengthTemporaryName, " = ", lengthTemporaryName, " | ", variableName, '.', lengthElementName, ".y;\n")); >+ stringBuilder.append(makeString(lengthTemporaryName, " = ", lengthTemporaryName, " | ", variableName, '.', lengthElementName, ".x;\n")); > stringBuilder.append(makeString(lengthTemporaryName, " = ", lengthTemporaryName, " / sizeof(", mangledTypeName, ");\n")); > stringBuilder.append(makeString("if (", lengthTemporaryName, " > 0xFFFFFFFF) ", lengthTemporaryName, " = 0xFFFFFFFF;\n")); > stringBuilder.append(makeString(mangledInputPath(path), " = { ", variableName, '.', elementName, ", static_cast<uint32_t>(", lengthTemporaryName, ") };\n")); >Index: LayoutTests/ChangeLog >=================================================================== >--- LayoutTests/ChangeLog (revision 246503) >+++ LayoutTests/ChangeLog (working copy) >@@ -1,3 +1,18 @@ >+2019-06-17 Saam Barati <sbarati@apple.com> >+ >+ [WHLSL] Make .length work >+ https://bugs.webkit.org/show_bug.cgi?id=198890 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestExpectations: >+ * webgpu/whlsl-buffer-length-expected.txt: Added. >+ * webgpu/whlsl-buffer-length.html: Added. >+ * webgpu/whlsl-buffer-vertex.html: >+ * webgpu/whlsl-compute.html: >+ * webgpu/whlsl-null-dereference.html: >+ * webgpu/whlsl-oob-access.html: >+ > 2019-06-17 Simon Fraser <simon.fraser@apple.com> > > Add missing test result after r246471. EWS didn't show any failure when it was missing. >Index: LayoutTests/TestExpectations >=================================================================== >--- LayoutTests/TestExpectations (revision 246503) >+++ LayoutTests/TestExpectations (working copy) >@@ -3413,6 +3413,3 @@ imported/w3c/web-platform-tests/websocke > > # iOS only > fast/dom/linkify-phone-numbers.html [ ImageOnlyFailure ] >- >-# FIXME: Should be fixed by: https://bugs.webkit.org/show_bug.cgi?id=198890 >-webgpu/whlsl-oob-access.html [ Pass Failure ] >Index: LayoutTests/webgpu/whlsl-buffer-length-expected.txt >=================================================================== >--- LayoutTests/webgpu/whlsl-buffer-length-expected.txt (nonexistent) >+++ LayoutTests/webgpu/whlsl-buffer-length-expected.txt (working copy) >@@ -0,0 +1,6 @@ >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+PASS allGood is true >+PASS resultsFloat32Array[0] is 1337 >+ >Index: LayoutTests/webgpu/whlsl-buffer-length.html >=================================================================== >--- LayoutTests/webgpu/whlsl-buffer-length.html (nonexistent) >+++ LayoutTests/webgpu/whlsl-buffer-length.html (working copy) >@@ -0,0 +1,85 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../resources/js-test-pre.js"></script> >+</head> >+<body> >+<script> >+const shaderSource = ` >+[numthreads(1337, 1, 1)] >+compute void computeShader(device float[] buffer : register(u0), float3 threadID : SV_DispatchThreadID) { >+ buffer[uint(threadID.x)] = buffer[uint(threadID.x)] * 2.0; >+ buffer[0] = float(buffer.length); >+} >+`; >+let resultsFloat32Array; >+let allGood = true; >+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 bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "storage-buffer"}]}; >+ 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 size = Float32Array.BYTES_PER_ELEMENT * 1337; >+ >+ const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC}; >+ const buffer = device.createBuffer(bufferDescriptor); >+ const bufferArrayBuffer = await buffer.mapWriteAsync(); >+ const bufferFloat32Array = new Float32Array(bufferArrayBuffer); >+ for (let i = 0; i < 1337; ++i) { >+ bufferFloat32Array[i] = i + 1; >+ } >+ buffer.unmap(); >+ >+ const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ}; >+ const resultsBuffer = device.createBuffer(resultsBufferDescriptor); >+ >+ const bufferBinding = {buffer: resultsBuffer, size}; >+ const bindGroupBinding = {binding: 0, resource: bufferBinding}; >+ const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]}; >+ const bindGroup = device.createBindGroup(bindGroupDescriptor); >+ >+ const commandEncoder = device.createCommandEncoder(); // {} >+ commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, size); >+ const computePassEncoder = commandEncoder.beginComputePass(); >+ computePassEncoder.setPipeline(computePipeline); >+ computePassEncoder.setBindGroup(0, bindGroup); >+ computePassEncoder.dispatch(2, 1, 1); >+ computePassEncoder.endPass(); >+ const commandBuffer = commandEncoder.finish(); >+ device.getQueue().submit([commandBuffer]); >+ >+ const resultsArrayBuffer = await resultsBuffer.mapReadAsync(); >+ resultsFloat32Array = new Float32Array(resultsArrayBuffer); >+ for (let i = 1; i < 1337; ++i) { >+ if (resultsFloat32Array[i] !== (i + 1) * 2) >+ allGood = false; >+ } >+ shouldBe("allGood", "true"); >+ shouldBe("resultsFloat32Array[0]", "1337"); >+ resultsBuffer.unmap(); >+} >+if (window.testRunner) >+ testRunner.waitUntilDone(); >+window.addEventListener("load", function() { >+ start().then(function() { >+ if (window.testRunner) >+ testRunner.notifyDone(); >+ }, function() { >+ if (window.testRunner) >+ testRunner.notifyDone(); >+ }); >+}); >+</script> >+<script src="../resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/webgpu/whlsl-buffer-vertex.html >=================================================================== >--- LayoutTests/webgpu/whlsl-buffer-vertex.html (revision 246503) >+++ LayoutTests/webgpu/whlsl-buffer-vertex.html (working copy) >@@ -38,7 +38,9 @@ async function start() { > const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout}; > const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor); > >- const resourceBufferDescriptor = {size: 4 * 4 * Float32Array.BYTES_PER_ELEMENT, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.MAP_WRITE}; >+ const size = 4 * 4 * Float32Array.BYTES_PER_ELEMENT; >+ >+ const resourceBufferDescriptor = {size, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.MAP_WRITE}; > const resourceBuffer = device.createBuffer(resourceBufferDescriptor); > const resourceBufferArrayBuffer = await resourceBuffer.mapWriteAsync(); > const resourceBufferFloat32Array = new Float32Array(resourceBufferArrayBuffer); >@@ -60,7 +62,7 @@ async function start() { > resourceBufferFloat32Array[15] = 1; > resourceBuffer.unmap(); > >- const bufferBinding = {buffer: resourceBuffer, size: 4}; >+ const bufferBinding = {buffer: resourceBuffer, size}; > const bindGroupBinding = {binding: 0, resource: bufferBinding}; > const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]}; > const bindGroup = device.createBindGroup(bindGroupDescriptor); >Index: LayoutTests/webgpu/whlsl-compute.html >=================================================================== >--- LayoutTests/webgpu/whlsl-compute.html (revision 246503) >+++ LayoutTests/webgpu/whlsl-compute.html (working copy) >@@ -27,7 +27,9 @@ async function start() { > const computePipelineDescriptor = {computeStage, layout: pipelineLayout}; > const computePipeline = device.createComputePipeline(computePipelineDescriptor); > >- const bufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC}; >+ const size = Float32Array.BYTES_PER_ELEMENT * 8; >+ >+ const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC}; > const buffer = device.createBuffer(bufferDescriptor); > const bufferArrayBuffer = await buffer.mapWriteAsync(); > const bufferFloat32Array = new Float32Array(bufferArrayBuffer); >@@ -41,16 +43,16 @@ async function start() { > bufferFloat32Array[7] = 8; > buffer.unmap(); > >- const resultsBufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ}; >+ const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ}; > const resultsBuffer = device.createBuffer(resultsBufferDescriptor); > >- const bufferBinding = {buffer: resultsBuffer, size: 4}; >+ const bufferBinding = {buffer: resultsBuffer, size}; > const bindGroupBinding = {binding: 0, resource: bufferBinding}; > const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]}; > const bindGroup = device.createBindGroup(bindGroupDescriptor); > > const commandEncoder = device.createCommandEncoder(); // {} >- commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, Float32Array.BYTES_PER_ELEMENT * 8); >+ commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, size); > const computePassEncoder = commandEncoder.beginComputePass(); > computePassEncoder.setPipeline(computePipeline); > computePassEncoder.setBindGroup(0, bindGroup); >Index: LayoutTests/webgpu/whlsl-null-dereference.html >=================================================================== >--- LayoutTests/webgpu/whlsl-null-dereference.html (revision 246503) >+++ LayoutTests/webgpu/whlsl-null-dereference.html (working copy) >@@ -63,7 +63,9 @@ async function start() { > const computePipelineDescriptor = {computeStage, layout: pipelineLayout}; > const computePipeline = device.createComputePipeline(computePipelineDescriptor); > >- const bufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC}; >+ const size = Float32Array.BYTES_PER_ELEMENT * 8; >+ >+ const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC}; > const buffer = device.createBuffer(bufferDescriptor); > const bufferArrayBuffer = await buffer.mapWriteAsync(); > const bufferFloat32Array = new Float32Array(bufferArrayBuffer); >@@ -77,16 +79,16 @@ async function start() { > bufferFloat32Array[7] = 8; > buffer.unmap(); > >- const resultsBufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ}; >+ const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ}; > const resultsBuffer = device.createBuffer(resultsBufferDescriptor); > >- const bufferBinding = {buffer: resultsBuffer, size: 4}; >+ const bufferBinding = {buffer: resultsBuffer, size}; > const bindGroupBinding = {binding: 0, resource: bufferBinding}; > const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]}; > const bindGroup = device.createBindGroup(bindGroupDescriptor); > > const commandEncoder = device.createCommandEncoder(); // {} >- commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, Float32Array.BYTES_PER_ELEMENT * 8); >+ commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, size); > const computePassEncoder = commandEncoder.beginComputePass(); > computePassEncoder.setPipeline(computePipeline); > computePassEncoder.setBindGroup(0, bindGroup); >Index: LayoutTests/webgpu/whlsl-oob-access.html >=================================================================== >--- LayoutTests/webgpu/whlsl-oob-access.html (revision 246503) >+++ LayoutTests/webgpu/whlsl-oob-access.html (working copy) >@@ -30,7 +30,9 @@ async function start() { > const computePipelineDescriptor = {computeStage, layout: pipelineLayout}; > const computePipeline = device.createComputePipeline(computePipelineDescriptor); > >- const bufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC}; >+ const size = Float32Array.BYTES_PER_ELEMENT * 8; >+ >+ const bufferDescriptor = {size, usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC}; > const buffer = device.createBuffer(bufferDescriptor); > const bufferArrayBuffer = await buffer.mapWriteAsync(); > const bufferFloat32Array = new Float32Array(bufferArrayBuffer); >@@ -44,16 +46,16 @@ async function start() { > bufferFloat32Array[7] = 8; > buffer.unmap(); > >- const resultsBufferDescriptor = {size: Float32Array.BYTES_PER_ELEMENT * 8, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ}; >+ const resultsBufferDescriptor = {size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ}; > const resultsBuffer = device.createBuffer(resultsBufferDescriptor); > >- const bufferBinding = {buffer: resultsBuffer, size: 4}; >+ const bufferBinding = {buffer: resultsBuffer, size}; > const bindGroupBinding = {binding: 0, resource: bufferBinding}; > const bindGroupDescriptor = {layout: bindGroupLayout, bindings: [bindGroupBinding]}; > const bindGroup = device.createBindGroup(bindGroupDescriptor); > > const commandEncoder = device.createCommandEncoder(); // {} >- commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, Float32Array.BYTES_PER_ELEMENT * 8); >+ commandEncoder.copyBufferToBuffer(buffer, 0, resultsBuffer, 0, size); > const computePassEncoder = commandEncoder.beginComputePass(); > computePassEncoder.setPipeline(computePipeline); > computePassEncoder.setBindGroup(0, bindGroup);
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
Flags:
mmaxfield
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198890
: 372267