1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RENDER_BUNDLE_ENCODER_H_ 6 #define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RENDER_BUNDLE_ENCODER_H_ 7 8 #include "third_party/blink/renderer/modules/webgpu/dawn_object.h" 9 #include "third_party/blink/renderer/modules/webgpu/gpu_programmable_pass_encoder.h" 10 #include "third_party/blink/renderer/platform/bindings/exception_state.h" 11 12 namespace blink { 13 14 class GPUBindGroup; 15 class GPUBuffer; 16 class GPURenderBundle; 17 class GPURenderBundleDescriptor; 18 class GPURenderBundleEncoderDescriptor; 19 class GPURenderPipeline; 20 21 class GPURenderBundleEncoder : public DawnObject<WGPURenderBundleEncoder>, 22 public GPUProgrammablePassEncoder { 23 DEFINE_WRAPPERTYPEINFO(); 24 25 public: 26 static GPURenderBundleEncoder* Create( 27 GPUDevice* device, 28 const GPURenderBundleEncoderDescriptor* webgpu_desc); 29 explicit GPURenderBundleEncoder( 30 GPUDevice* device, 31 WGPURenderBundleEncoder render_bundle_encoder); 32 ~GPURenderBundleEncoder() override; 33 34 // gpu_render_bundle_encoder.idl 35 void setBindGroup(uint32_t index, 36 GPUBindGroup* bindGroup, 37 const Vector<uint32_t>& dynamicOffsets); 38 void setBindGroup(uint32_t index, 39 GPUBindGroup* bind_group, 40 const FlexibleUint32Array& dynamic_offsets_data, 41 uint64_t dynamic_offsets_data_start, 42 uint32_t dynamic_offsets_data_length, 43 ExceptionState& exception_state); 44 void pushDebugGroup(String groupLabel); 45 void popDebugGroup(); 46 void insertDebugMarker(String markerLabel); 47 void setPipeline(GPURenderPipeline* pipeline); 48 49 void setIndexBuffer(GPUBuffer* buffer, uint64_t offset); 50 void setVertexBuffer(uint32_t slot, const GPUBuffer* buffer, uint64_t offset); 51 void draw(uint32_t vertexCount, 52 uint32_t instanceCount, 53 uint32_t firstVertex, 54 uint32_t firstInstance); 55 void drawIndexed(uint32_t indexCount, 56 uint32_t instanceCount, 57 uint32_t firstIndex, 58 int32_t baseVertex, 59 uint32_t firstInstance); 60 void drawIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset); 61 void drawIndexedIndirect(GPUBuffer* indirectBuffer, uint64_t indirectOffset); 62 63 GPURenderBundle* finish(const GPURenderBundleDescriptor* webgpu_desc); 64 65 private: 66 DISALLOW_COPY_AND_ASSIGN(GPURenderBundleEncoder); 67 }; 68 69 } // namespace blink 70 71 #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGPU_GPU_RENDER_BUNDLE_ENCODER_H_ 72