Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: src/gpu/vk/GrVkBuffer.h

Issue 1718693002: Add vulkan files into skia repo. (Closed) Base URL: https://skia.googlesource.com/skia.git@merge
Patch Set: fix path Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/vk/GrVkInterface.h ('k') | src/gpu/vk/GrVkBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkBuffer.h
diff --git a/src/gpu/vk/GrVkBuffer.h b/src/gpu/vk/GrVkBuffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..7dac3a1149a38d3fb1dd5e896609b4e7cbdcefdf
--- /dev/null
+++ b/src/gpu/vk/GrVkBuffer.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrVkBuffer_DEFINED
+#define GrVkBuffer_DEFINED
+
+#include "vk/GrVkInterface.h"
+#include "GrVkResource.h"
+
+class GrVkGpu;
+
+/**
+ * This class serves as the base of GrVk*Buffer classes. It was written to avoid code
+ * duplication in those classes.
+ */
+class GrVkBuffer : public SkNoncopyable {
+public:
+ ~GrVkBuffer() {
+ // either release or abandon should have been called by the owner of this object.
+ SkASSERT(!fResource);
+ }
+
+ VkBuffer buffer() const { return fResource->fBuffer; }
+ VkDeviceMemory alloc() const { return fResource->fAlloc; }
+ const GrVkResource* resource() const { return fResource; }
+ size_t size() const { return fDesc.fSizeInBytes; }
+
+ void addMemoryBarrier(const GrVkGpu* gpu,
+ VkAccessFlags srcAccessMask,
+ VkAccessFlags dstAccessMask,
+ VkPipelineStageFlags srcStageMask,
+ VkPipelineStageFlags dstStageMask,
+ bool byRegion) const;
+
+ enum Type {
+ kVertex_Type,
+ kIndex_Type,
+ kUniform_Type,
+ kCopyRead_Type,
+ kCopyWrite_Type,
+ };
+
+protected:
+ struct Desc {
+ size_t fSizeInBytes;
+ Type fType; // vertex buffer, index buffer, etc.
+ bool fDynamic;
+ };
+
+ class Resource : public GrVkResource {
+ public:
+ Resource(VkBuffer buf, VkDeviceMemory alloc) : INHERITED(), fBuffer(buf), fAlloc(alloc) {}
+
+ VkBuffer fBuffer;
+ VkDeviceMemory fAlloc;
+ private:
+ void freeGPUData(const GrVkGpu* gpu) const;
+
+ typedef GrVkResource INHERITED;
+ };
+
+ // convenience routine for raw buffer creation
+ static const Resource* Create(const GrVkGpu* gpu,
+ const Desc& descriptor);
+
+ GrVkBuffer(const Desc& desc, const GrVkBuffer::Resource* resource)
+ : fDesc(desc), fResource(resource), fMapPtr(nullptr) {
+ }
+
+ void* vkMap(const GrVkGpu* gpu);
+ void vkUnmap(const GrVkGpu* gpu);
+ bool vkUpdateData(const GrVkGpu* gpu, const void* src, size_t srcSizeInBytes);
+
+ void vkAbandon();
+ void vkRelease(const GrVkGpu* gpu);
+
+private:
+ void validate() const;
+ bool vkIsMapped() const;
+
+ Desc fDesc;
+ const Resource* fResource;
+ void* fMapPtr;
+
+ typedef SkRefCnt INHERITED;
+};
+
+#endif
« no previous file with comments | « include/gpu/vk/GrVkInterface.h ('k') | src/gpu/vk/GrVkBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698