1 // 2 // Copyright 2024 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // VertexArrayWgpu.h: 7 // Defines the class interface for VertexArrayWgpu, implementing VertexArrayImpl. 8 // 9 10 #ifndef LIBANGLE_RENDERER_WGPU_VERTEXARRAYWGPU_H_ 11 #define LIBANGLE_RENDERER_WGPU_VERTEXARRAYWGPU_H_ 12 13 #include "libANGLE/renderer/VertexArrayImpl.h" 14 #include "libANGLE/renderer/wgpu/BufferWgpu.h" 15 #include "libANGLE/renderer/wgpu/wgpu_pipeline_state.h" 16 17 namespace rx 18 { 19 20 class VertexArrayWgpu : public VertexArrayImpl 21 { 22 public: 23 VertexArrayWgpu(const gl::VertexArrayState &data); 24 25 angle::Result syncState(const gl::Context *context, 26 const gl::VertexArray::DirtyBits &dirtyBits, 27 gl::VertexArray::DirtyAttribBitsArray *attribBits, 28 gl::VertexArray::DirtyBindingBitsArray *bindingBits) override; 29 getVertexBuffer(size_t slot)30 webgpu::BufferHelper *getVertexBuffer(size_t slot) const { return mCurrentArrayBuffers[slot]; } getIndexBuffer()31 webgpu::BufferHelper *getIndexBuffer() const { return mCurrentIndexBuffer; } 32 33 angle::Result syncClientArrays(const gl::Context *context, 34 const gl::AttributesMask &activeAttributesMask, 35 GLint first, 36 GLsizei count, 37 GLsizei instanceCount, 38 gl::DrawElementsType drawElementsTypeOrInvalid, 39 const void *indices, 40 GLint baseVertex, 41 bool primitiveRestartEnabled, 42 const void **adjustedIndicesPtr); 43 44 private: 45 angle::Result syncDirtyAttrib(ContextWgpu *contextWgpu, 46 const gl::VertexAttribute &attrib, 47 const gl::VertexBinding &binding, 48 size_t attribIndex); 49 angle::Result syncDirtyElementArrayBuffer(ContextWgpu *contextWgpu); 50 51 gl::AttribArray<webgpu::PackedVertexAttribute> mCurrentAttribs; 52 gl::AttribArray<webgpu::BufferHelper> mStreamingArrayBuffers; 53 gl::AttribArray<webgpu::BufferHelper *> mCurrentArrayBuffers; 54 55 webgpu::BufferHelper mStreamingIndexBuffer; 56 webgpu::BufferHelper *mCurrentIndexBuffer = nullptr; 57 }; 58 59 } // namespace rx 60 61 #endif // LIBANGLE_RENDERER_WGPU_VERTEXARRAYWGPU_H_ 62