blob: 6ac47dd50fd5a81d4496fadb16552cd75af90fe7 [file] [log] [blame]
/*
* Copyright 2019 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrDawnRingBuffer_DEFINED
#define GrDawnRingBuffer_DEFINED
#include "src/gpu/GrBuffer.h"
#include "src/gpu/dawn/GrDawnBuffer.h"
#include "dawn/webgpu_cpp.h"
class GrDawnGpu;
class GrDawnRingBuffer : public SkRefCnt {
public:
GrDawnRingBuffer(GrDawnGpu* gpu, wgpu::BufferUsage usage);
~GrDawnRingBuffer() override;
struct Slice {
Slice(wgpu::Buffer buffer, int offset, void* data)
: fBuffer(buffer), fOffset(offset), fData(data) {}
Slice()
: fBuffer(nullptr), fOffset(0), fData(nullptr) {}
Slice(const Slice& other)
: fBuffer(other.fBuffer), fOffset(other.fOffset), fData(other.fData) {}
Slice& operator=(const Slice& other) {
fBuffer = other.fBuffer;
fOffset = other.fOffset;
fData = other.fData;
return *this;
}
wgpu::Buffer fBuffer;
int fOffset;
void* fData;
};
Slice allocate(int size);
private:
GrDawnGpu* fGpu;
wgpu::BufferUsage fUsage;
wgpu::Buffer fBuffer;
int fOffset = 0;
};
#endif