1 /* 2 * Copyright 2021 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef skgpu_ResourceTypes_DEFINED 9 #define skgpu_ResourceTypes_DEFINED 10 11 #include "experimental/graphite/include/GraphiteTypes.h" 12 #include "experimental/graphite/src/EnumBitMask.h" 13 14 namespace skgpu { 15 16 /** 17 * Is the Texture renderable or not 18 */ 19 enum class Renderable : bool { 20 kNo = false, 21 kYes = true, 22 }; 23 24 enum class DepthStencilFlags : int { 25 kNone = 0b000, 26 kDepth = 0b001, 27 kStencil = 0b010, 28 kDepthStencil = kDepth | kStencil, 29 }; 30 SKGPU_MAKE_MASK_OPS(DepthStencilFlags); 31 32 /** 33 * What a GPU buffer will be used for 34 */ 35 enum class BufferType { 36 kVertex, 37 kIndex, 38 kXferCpuToGpu, 39 kXferGpuToCpu, 40 kUniform, 41 }; 42 static const int kBufferTypeCount = static_cast<int>(BufferType::kUniform) + 1; 43 44 /** 45 * When creating the memory for a resource should we use a memory type that prioritizes the 46 * effeciency of GPU reads even if it involves extra work to write CPU data to it. For example, we 47 * would want this for buffers that we cache to read the same data many times on the GPU. 48 */ 49 enum class PrioritizeGpuReads : bool { 50 kNo = false, 51 kYes = true, 52 }; 53 54 enum class Ownership { 55 kOwned, 56 kWrapped, 57 }; 58 59 /** Uniquely identifies the type of resource that is cached with a GraphiteResourceKey. */ 60 using ResourceType = uint32_t; 61 62 /** 63 * Can the resource be held by multiple users at the same time? 64 * For example, stencil buffers, pipelines, etc. 65 */ 66 enum class Shareable : bool { 67 kNo = false, 68 kYes = true, 69 }; 70 71 /** This enum is used to notify the ResourceCache which type of ref just dropped to zero. */ 72 enum class LastRemovedRef { 73 kUsageRef, 74 kCommandBufferRef, 75 }; 76 77 }; // namespace skgpu 78 79 #endif // skgpu_ResourceTypes_DEFINED 80