Bug 1691712 - WebGPU bindings for RenderPassEncoder rasterization state r=kvark,webidl,smaug
authorAlexander Meißner <AlexanderMeissner@gmx.net>
Wed, 10 Feb 2021 16:25:39 +0000
changeset 566883 d691d9c9366a712cf114c728f6a01475430c960d
parent 566882 52e0bdf9460f27b865cbea2e2959869b52ccce90
child 566884 d553759a32e24d179a11ecee590e0e9ca7e13597
push id38191
push userbtara@mozilla.com
push dateThu, 11 Feb 2021 05:02:45 +0000
treeherdermozilla-central@5cbcb80f72bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark, webidl, smaug
bugs1691712
milestone87.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1691712 - WebGPU bindings for RenderPassEncoder rasterization state r=kvark,webidl,smaug Differential Revision: https://phabricator.services.mozilla.com/D104591
dom/webgpu/RenderPassEncoder.cpp
dom/webgpu/RenderPassEncoder.h
dom/webidl/WebGPU.webidl
--- a/dom/webgpu/RenderPassEncoder.cpp
+++ b/dom/webgpu/RenderPassEncoder.cpp
@@ -209,16 +209,47 @@ void RenderPassEncoder::DrawIndirect(con
 void RenderPassEncoder::DrawIndexedIndirect(const Buffer& aIndirectBuffer,
                                             uint64_t aIndirectOffset) {
   if (mValid) {
     ffi::wgpu_render_pass_draw_indexed_indirect(mPass, aIndirectBuffer.mId,
                                                 aIndirectOffset);
   }
 }
 
+void RenderPassEncoder::SetViewport(float x, float y,
+                                    float width, float height,
+                                    float minDepth, float maxDepth) {
+  if (mValid) {
+    ffi::wgpu_render_pass_set_viewport(mPass,
+                                       x, y,
+                                       width, height,
+                                       minDepth, maxDepth);
+  }
+}
+
+void RenderPassEncoder::SetScissorRect(uint32_t x, uint32_t y,
+                                       uint32_t width, uint32_t height) {
+  if (mValid) {
+    ffi::wgpu_render_pass_set_scissor_rect(mPass, x, y, width, height);
+  }
+}
+
+void RenderPassEncoder::SetBlendColor(const dom::DoubleSequenceOrGPUColorDict& color) {
+  if (mValid) {
+    ffi::WGPUColor aColor = ConvertColor(color.GetAsGPUColorDict());
+    ffi::wgpu_render_pass_set_blend_color(mPass, &aColor);
+  }
+}
+
+void RenderPassEncoder::SetStencilReference(uint32_t reference) {
+  if (mValid) {
+    ffi::wgpu_render_pass_set_stencil_reference(mPass, reference);
+  }
+}
+
 void RenderPassEncoder::EndPass(ErrorResult& aRv) {
   if (mValid) {
     mValid = false;
     auto* pass = mPass.forget();
     MOZ_ASSERT(pass);
     mParent->EndRenderPass(*pass, aRv);
   }
 }
--- a/dom/webgpu/RenderPassEncoder.h
+++ b/dom/webgpu/RenderPassEncoder.h
@@ -65,15 +65,21 @@ class RenderPassEncoder final : public O
   void Draw(uint32_t aVertexCount, uint32_t aInstanceCount,
             uint32_t aFirstVertex, uint32_t aFirstInstance);
   void DrawIndexed(uint32_t aIndexCount, uint32_t aInstanceCount,
                    uint32_t aFirstIndex, int32_t aBaseVertex,
                    uint32_t aFirstInstance);
   void DrawIndirect(const Buffer& aIndirectBuffer, uint64_t aIndirectOffset);
   void DrawIndexedIndirect(const Buffer& aIndirectBuffer,
                            uint64_t aIndirectOffset);
+  void SetViewport(float x, float y,
+                   float width, float height,
+                   float minDepth, float maxDepth);
+  void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
+  void SetBlendColor(const dom::DoubleSequenceOrGPUColorDict& color);
+  void SetStencilReference(uint32_t reference);
   void EndPass(ErrorResult& aRv);
 };
 
 }  // namespace webgpu
 }  // namespace mozilla
 
 #endif  // GPU_RenderPassEncoder_H_
--- a/dom/webidl/WebGPU.webidl
+++ b/dom/webidl/WebGPU.webidl
@@ -868,26 +868,36 @@ interface mixin GPURenderEncoderBase {
 
     void drawIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
     void drawIndexedIndirect(GPUBuffer indirectBuffer, GPUSize64 indirectOffset);
 };
 
 [Pref="dom.webgpu.enabled",
  Exposed=Window]
 interface GPURenderPassEncoder {
-    //void setViewport(float x, float y,
-    //                 float width, float height,
-    //                 float minDepth, float maxDepth);
+    void setViewport(float x, float y,
+                     float width, float height,
+                     float minDepth, float maxDepth);
+
+    void setScissorRect(GPUIntegerCoordinate x, GPUIntegerCoordinate y,
+                        GPUIntegerCoordinate width, GPUIntegerCoordinate height);
 
-    //void setScissorRect(u32 x, u32 y, u32 width, u32 height);
+    void setBlendColor(GPUColor color);
+    void setStencilReference(GPUStencilValue reference);
 
-    //void setBlendColor(GPUColor color);
-    //void setStencilReference(u32 reference);
+    //void beginOcclusionQuery(GPUSize32 queryIndex);
+    //void endOcclusionQuery();
+
+    //void beginPipelineStatisticsQuery(GPUQuerySet querySet, GPUSize32 queryIndex);
+    //void endPipelineStatisticsQuery();
+
+    //void writeTimestamp(GPUQuerySet querySet, GPUSize32 queryIndex);
 
     //void executeBundles(sequence<GPURenderBundle> bundles);
+
     [Throws]
     void endPass();
 };
 GPURenderPassEncoder includes GPUObjectBase;
 GPURenderPassEncoder includes GPUProgrammablePassEncoder;
 GPURenderPassEncoder includes GPURenderEncoderBase;
 
 // Compute Pass