[graphite] Add call to ResourceProvider to get Buffer.

Bug: skia:12466
Change-Id: I4c80d5438d95562ef42531b4f66a9eaa6ff75d1f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/459877
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2021-10-15 10:31:29 -04:00 committed by SkCQ
parent 11c4d14d89
commit 6a24fe4825
5 changed files with 22 additions and 1 deletions

View File

@ -7,6 +7,7 @@
#include "experimental/graphite/src/ResourceProvider.h"
#include "experimental/graphite/src/Buffer.h"
#include "experimental/graphite/src/CommandBuffer.h"
#include "experimental/graphite/src/RenderPipeline.h"
#include "experimental/graphite/src/Texture.h"
@ -64,4 +65,11 @@ sk_sp<Texture> ResourceProvider::findOrCreateTexture(SkISize dimensions, const T
return this->createTexture(dimensions, info);
}
sk_sp<Buffer> ResourceProvider::findOrCreateBuffer(size_t size,
BufferType type,
PrioritizeGpuReads prioritizeGpuReads) {
return this->createBuffer(size, type, prioritizeGpuReads);
}
} // namespace skgpu

View File

@ -8,6 +8,7 @@
#ifndef skgpu_ResourceProvider_DEFINED
#define skgpu_ResourceProvider_DEFINED
#include "experimental/graphite/include/private/GraphiteTypesPriv.h"
#include "experimental/graphite/src/CommandBuffer.h"
#include "experimental/graphite/src/RenderPipeline.h"
#include "experimental/graphite/src/RenderPipelineDesc.h"
@ -16,6 +17,7 @@
namespace skgpu {
class Buffer;
class CommandBuffer;
class Gpu;
class RenderPipeline;
@ -32,6 +34,8 @@ public:
sk_sp<Texture> findOrCreateTexture(SkISize, const TextureInfo&);
sk_sp<Buffer> findOrCreateBuffer(size_t size, BufferType type, PrioritizeGpuReads);
protected:
ResourceProvider(const Gpu* gpu);
@ -40,6 +44,7 @@ protected:
private:
virtual std::unique_ptr<RenderPipeline> onCreateRenderPipeline(const RenderPipelineDesc&) = 0;
virtual sk_sp<Texture> createTexture(SkISize, const TextureInfo&) = 0;
virtual sk_sp<Buffer> createBuffer(size_t size, BufferType type, PrioritizeGpuReads) = 0;
class RenderPipelineCache {
public:

View File

@ -20,7 +20,7 @@ class Gpu;
class Buffer : public skgpu::Buffer {
public:
sk_sp<Buffer> Make(const Gpu*, size_t size, BufferType type, PrioritizeGpuReads);
static sk_sp<Buffer> Make(const Gpu*, size_t size, BufferType type, PrioritizeGpuReads);
private:
Buffer(size_t size, BufferType type, PrioritizeGpuReads, sk_cfp<id<MTLBuffer>>);

View File

@ -32,6 +32,7 @@ private:
std::unique_ptr<skgpu::RenderPipeline> onCreateRenderPipeline(
const RenderPipelineDesc&) override;
sk_sp<skgpu::Texture> createTexture(SkISize, const skgpu::TextureInfo&) override;
sk_sp<skgpu::Buffer> createBuffer(size_t size, BufferType type, PrioritizeGpuReads) override;
};
} // namespace skgpu::mtl

View File

@ -7,6 +7,7 @@
#include "experimental/graphite/src/mtl/MtlResourceProvider.h"
#include "experimental/graphite/src/mtl/MtlBuffer.h"
#include "experimental/graphite/src/mtl/MtlCommandBuffer.h"
#include "experimental/graphite/src/mtl/MtlGpu.h"
#include "experimental/graphite/src/mtl/MtlTexture.h"
@ -38,4 +39,10 @@ sk_sp<skgpu::Texture> ResourceProvider::createTexture(SkISize dimensions,
return Texture::Make(this->mtlGpu(), dimensions, info);
}
sk_sp<skgpu::Buffer> ResourceProvider::createBuffer(size_t size,
BufferType type,
PrioritizeGpuReads prioritizeGpuReads) {
return Buffer::Make(this->mtlGpu(), size, type, prioritizeGpuReads);
}
} // namespace skgpu::mtl