Diff
Modified: trunk/LayoutTests/ChangeLog (239743 => 239744)
--- trunk/LayoutTests/ChangeLog 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/LayoutTests/ChangeLog 2019-01-08 21:36:18 UTC (rev 239744)
@@ -1,3 +1,17 @@
+2019-01-08 Justin Fan <justin_...@apple.com>
+
+ [WebGPU] Update createRenderPipeline for WebGPUPipelineLayout
+ https://bugs.webkit.org/show_bug.cgi?id=193247
+
+ Reviewed by Dean Jackson.
+
+ Update render-pipelines.html to WPT form and to accomodate WebGPUPipelineLayouts.
+
+ * webgpu/js/webgpu-functions.js:
+ (createBasicPipeline): Added option to include a WebGPUPipelineLayout.
+ * webgpu/render-pipelines-expected.txt:
+ * webgpu/render-pipelines.html:
+
2019-01-08 Chris Dumez <cdu...@apple.com>
Prevent cross-site top-level navigations from third-party iframes
Modified: trunk/LayoutTests/webgpu/js/webgpu-functions.js (239743 => 239744)
--- trunk/LayoutTests/webgpu/js/webgpu-functions.js 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/LayoutTests/webgpu/js/webgpu-functions.js 2019-01-08 21:36:18 UTC (rev 239744)
@@ -12,18 +12,19 @@
return context;
}
-function createBasicPipeline(shaderModule, device, inputStateDescriptor) {
- vertexStageDescriptor = {
+function createBasicPipeline(shaderModule, device, pipelineLayout, inputStateDescriptor) {
+ const vertexStageDescriptor = {
module: shaderModule,
entryPoint: "vertex_main"
};
- fragmentStageDescriptor = {
+ const fragmentStageDescriptor = {
module: shaderModule,
entryPoint: "fragment_main"
};
- pipelineDescriptor = {
+ const pipelineDescriptor = {
+ layout: pipelineLayout,
vertexStage: vertexStageDescriptor,
fragmentStage: fragmentStageDescriptor,
primitiveTopology: "triangleStrip",
Modified: trunk/LayoutTests/webgpu/render-pipelines-expected.txt (239743 => 239744)
--- trunk/LayoutTests/webgpu/render-pipelines-expected.txt 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/LayoutTests/webgpu/render-pipelines-expected.txt 2019-01-08 21:36:18 UTC (rev 239744)
@@ -1,10 +1,4 @@
-PASS [object WebGPU] is defined.
-PASS WebGPURenderPipeline with invalid WebGPURenderPipelineDescriptor was not created.
-PASS WebGPURenderPipeline with invalid shader module was not created.
-PASS WebGPURenderPipeline with invalid vertex shader stage was not created.
-PASS WebGPURenderPipeline with invalid vertex shader entry point was not created.
-All tests complete.
-PASS successfullyParsed is true
-TEST COMPLETE
+PASS Create basic WebGPURenderPipeline
+PASS Bad pipelines were not created
Modified: trunk/LayoutTests/webgpu/render-pipelines.html (239743 => 239744)
--- trunk/LayoutTests/webgpu/render-pipelines.html 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/LayoutTests/webgpu/render-pipelines.html 2019-01-08 21:36:18 UTC (rev 239744)
@@ -1,55 +1,98 @@
<!DOCTYPE html>
<html>
-<script src=""
-<script src=""
+<script src=""
+<script src=""
+<script src=""
<script>
-if (window.testRunner)
- window.testRunner.dumpAsText();
+const shaderCode = `
+#include <metal_stdlib>
+
+using namespace metal;
-function checkBadRenderPipeline(descriptor, testSubjectName) {
- let pipeline = defaultDevice.createRenderPipeline(descriptor);
+struct Vertex
+{
+ float4 position [[position]];
+};
- if (pipeline)
- testFailed(`WebGPURenderPipeline was created with an invalid ${testSubjectName}!`);
- else
- testPassed(`WebGPURenderPipeline with invalid ${testSubjectName} was not created.`);
+vertex Vertex vertex_main(uint vid [[vertex_id]])
+{
+ Vertex v;
+ switch (vid) {
+ case 0:
+ v.position = float4(-1, 1, 0, 1);
+ break;
+ case 1:
+ v.position = float4(-1, -1, 0, 1);
+ break;
+ case 2:
+ v.position = float4(1, 1, 0, 1);
+ break;
+ default:
+ v.position = float4(1, -1, 0, 1);
+ }
+ return v;
}
-function setUpBadPipelines() {
- checkBadRenderPipeline({}, "WebGPURenderPipelineDescriptor");
+fragment float4 fragment_main(Vertex vertexIn [[stage_in]])
+{
+ return float4(0.0, 1.0, 0.0, 1.0);
+}
+`
- let noModuleVertexDescriptor = {
+promise_test(async () => {
+ const device = await getBasicDevice();
+ const shaderModule = device.createShaderModule({ code: shaderCode });
+
+ const layoutBinding = { binding: 0, visibility: WebGPUShaderStageBit.VERTEX, type: "storageBuffer" };
+ const bindGroupLayout = device.createBindGroupLayout({ bindings: [layoutBinding] });
+ const pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: [bindGroupLayout] });
+
+ const pipeline = createBasicPipeline(shaderModule, device, pipelineLayout);
+ assert_true(pipeline instanceof WebGPURenderPipeline, "Successfully created WebGPURenderPipeline");
+}, "Create basic WebGPURenderPipeline");
+
+function checkBadRenderPipeline(device, descriptor, testSubjectName) {
+ assert_true(!device.createRenderPipeline(descriptor), `WebGPURenderPipeline with invalid ${testSubjectName} was not created.`);
+}
+
+promise_test(async() => {
+ const device = await getBasicDevice();
+ const shaderModule = device.createShaderModule({ code: shaderCode });
+ checkBadRenderPipeline(device, {}, "WebGPURenderPipelineDescriptor");
+
+ const noModuleVertexDescriptor = {
entryPoint: "vertex_main"
}
- let noModulePipelineDescriptor = {
+
+ const fragmentStageDescriptor = {
+ module: shaderModule,
+ entryPoint: "fragment_main"
+ };
+
+ const noModulePipelineDescriptor = {
vertexStage: noModuleVertexDescriptor,
fragmentStage: fragmentStageDescriptor,
primitiveTopology: "triangleList"
}
- checkBadRenderPipeline(noModulePipelineDescriptor, "shader module");
+ checkBadRenderPipeline(device, noModulePipelineDescriptor, "shader module");
// A (Metal) renderpipeline must have a vertex function.
- let noVertexPipelineDescriptor = {
+ const noVertexPipelineDescriptor = {
fragmentStage: fragmentStageDescriptor,
primitiveTopology: "triangleList"
}
- checkBadRenderPipeline(noVertexPipelineDescriptor, "vertex shader stage")
+ checkBadRenderPipeline(device, noVertexPipelineDescriptor, "vertex shader stage")
- let badEntryPointDescriptor = {
+ const badEntryPointDescriptor = {
module: shaderModule,
entryPoint: "Vertex_Main"
};
- let badEntryPointPipelineDescsriptor = {
+ const badEntryPointPipelineDescsriptor = {
vertexStage: badEntryPointDescriptor,
fragmentStage: fragmentStageDescriptor,
primitiveTopology: "triangleList"
}
- checkBadRenderPipeline(badEntryPointPipelineDescsriptor, "vertex shader entry point");
-}
-
-runWebGPUTests([setUpPipeline, setUpBadPipelines]);
-
-successfullyParsed = true;
+ checkBadRenderPipeline(device, badEntryPointPipelineDescsriptor, "vertex shader entry point");
+}, "Bad pipelines were not created");
</script>
-<script src=""
</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (239743 => 239744)
--- trunk/Source/WebCore/ChangeLog 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/Source/WebCore/ChangeLog 2019-01-08 21:36:18 UTC (rev 239744)
@@ -1,3 +1,27 @@
+2019-01-08 Justin Fan <justin_...@apple.com>
+
+ [WebGPU] Update createRenderPipeline for WebGPUPipelineLayout
+ https://bugs.webkit.org/show_bug.cgi?id=193247
+
+ Reviewed by Dean Jackson.
+
+ Add WebGPUPipelineLayout to WebGPURenderPipeline via WebGPUPipelineDescriptorBase.
+
+ Test: Updated render-pipelines.html to test new functionality.
+
+ * Modules/webgpu/WebGPUDevice.cpp:
+ (WebCore::WebGPUDevice::createRenderPipeline const): Convert WebGPUPipelineLayout to GPUPipelineLayout.
+ * Modules/webgpu/WebGPUPipelineDescriptorBase.h:
+ * Modules/webgpu/WebGPUPipelineDescriptorBase.idl: Add layout field.
+ * Modules/webgpu/WebGPUPipelineLayout.h:
+ (WebCore::WebGPUPipelineLayout::pipelineLayout): Added. Getter.
+ * platform/graphics/gpu/GPUPipelineDescriptorBase.h: Updated from out-of-date version.
+ * platform/graphics/gpu/GPUPipelineLayout.cpp:
+ (WebCore::GPUPipelineLayout::GPUPipelineLayout): Now retains bindGroupLayouts from descriptor.
+ * platform/graphics/gpu/GPUPipelineLayout.h:
+ * platform/graphics/gpu/GPURenderPipelineDescriptor.h: Now inherits from GPUPipelineDescriptorBase.
+ (WebCore::GPURenderPipelineDescriptor::GPURenderPipelineDescriptor): Custom constructor for non-aggregate struct.
+
2019-01-08 Chris Dumez <cdu...@apple.com>
Prevent cross-site top-level navigations from third-party iframes
Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (239743 => 239744)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp 2019-01-08 21:36:18 UTC (rev 239744)
@@ -103,6 +103,8 @@
RefPtr<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(WebGPURenderPipelineDescriptor&& descriptor) const
{
+ auto pipelineLayout = descriptor.layout ? descriptor.layout->pipelineLayout() : nullptr;
+
auto vertexStage = validateAndConvertPipelineStage(descriptor.vertexStage);
auto fragmentStage = validateAndConvertPipelineStage(descriptor.fragmentStage);
@@ -111,7 +113,7 @@
return nullptr;
}
- if (auto pipeline = m_device->createRenderPipeline(GPURenderPipelineDescriptor { WTFMove(*vertexStage), WTFMove(*fragmentStage), descriptor.primitiveTopology, descriptor.inputState }))
+ if (auto pipeline = m_device->createRenderPipeline(GPURenderPipelineDescriptor { WTFMove(pipelineLayout), WTFMove(*vertexStage), WTFMove(*fragmentStage), descriptor.primitiveTopology, WTFMove(descriptor.inputState) }))
return WebGPURenderPipeline::create(pipeline.releaseNonNull());
return nullptr;
}
Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h (239743 => 239744)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.h 2019-01-08 21:36:18 UTC (rev 239744)
@@ -27,10 +27,12 @@
#if ENABLE(WEBGPU)
+#include "WebGPUPipelineLayout.h"
+
namespace WebCore {
struct WebGPUPipelineDescriptorBase {
- // WebGPUPipelineLayout layout;
+ RefPtr<WebGPUPipelineLayout> layout;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl (239743 => 239744)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineDescriptorBase.idl 2019-01-08 21:36:18 UTC (rev 239744)
@@ -28,5 +28,5 @@
Conditional=WEBGPU,
EnabledAtRuntime=WebGPU
] dictionary WebGPUPipelineDescriptorBase {
- // WebGPUPipelineLayout layout;
+ WebGPUPipelineLayout layout;
};
Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayout.h (239743 => 239744)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayout.h 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayout.h 2019-01-08 21:36:18 UTC (rev 239744)
@@ -38,6 +38,8 @@
public:
static Ref<WebGPUPipelineLayout> create(Ref<GPUPipelineLayout>&&);
+ RefPtr<GPUPipelineLayout> pipelineLayout() { return m_pipelineLayout.copyRef(); }
+
private:
explicit WebGPUPipelineLayout(Ref<GPUPipelineLayout>&&);
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h (239743 => 239744)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h 2019-01-08 21:36:18 UTC (rev 239744)
@@ -27,6 +27,7 @@
#if ENABLE(WEBGPU)
+#include "GPUPipelineLayout.h"
#include "GPUPipelineStageDescriptor.h"
#include <wtf/Vector.h>
@@ -34,7 +35,7 @@
namespace WebCore {
struct GPUPipelineDescriptorBase {
- Vector<GPUPipelineStageDescriptor> stages;
+ RefPtr<GPUPipelineLayout> layout;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.cpp (239743 => 239744)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.cpp 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.cpp 2019-01-08 21:36:18 UTC (rev 239744)
@@ -35,9 +35,9 @@
return adoptRef(*new GPUPipelineLayout(WTFMove(descriptor)));
}
-GPUPipelineLayout::GPUPipelineLayout(GPUPipelineLayoutDescriptor&&)
+GPUPipelineLayout::GPUPipelineLayout(GPUPipelineLayoutDescriptor&& descriptor)
+ : m_bindGroupLayouts(descriptor.bindGroupLayouts)
{
- // FIXME: Stub implementation.
}
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.h (239743 => 239744)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.h 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.h 2019-01-08 21:36:18 UTC (rev 239744)
@@ -40,6 +40,8 @@
private:
explicit GPUPipelineLayout(GPUPipelineLayoutDescriptor&&);
+
+ Vector<RefPtr<const GPUBindGroupLayout>> m_bindGroupLayouts;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h (239743 => 239744)
--- trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h 2019-01-08 21:33:02 UTC (rev 239743)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipelineDescriptor.h 2019-01-08 21:36:18 UTC (rev 239744)
@@ -35,7 +35,7 @@
namespace WebCore {
-struct GPURenderPipelineDescriptor {
+struct GPURenderPipelineDescriptor : GPUPipelineDescriptorBase {
enum class PrimitiveTopology {
PointList,
LineList,
@@ -44,6 +44,15 @@
TriangleStrip
};
+ GPURenderPipelineDescriptor(RefPtr<GPUPipelineLayout>&& layout, GPUPipelineStageDescriptor&& vertex, GPUPipelineStageDescriptor&& fragment, PrimitiveTopology topology, GPUInputStateDescriptor&& input)
+ : GPUPipelineDescriptorBase { WTFMove(layout) }
+ , vertexStage(WTFMove(vertex))
+ , fragmentStage(WTFMove(fragment))
+ , primitiveTopology(topology)
+ , inputState(WTFMove(input))
+ {
+ }
+
GPUPipelineStageDescriptor vertexStage;
GPUPipelineStageDescriptor fragmentStage;
PrimitiveTopology primitiveTopology;