1 /* 2 * Copyright 2023 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_graphite_DescriptorTypes_DEFINED 9 #define skgpu_graphite_DescriptorTypes_DEFINED 10 11 #include "include/private/base/SkTArray.h" 12 #include "src/base/SkEnumBitMask.h" 13 #include "src/gpu/graphite/Sampler.h" 14 15 namespace skgpu::graphite { 16 17 /** 18 * Types of descriptors supported within graphite 19 */ 20 enum class DescriptorType : uint8_t { 21 kUniformBuffer = 0, 22 kTextureSampler, 23 kTexture, 24 kCombinedTextureSampler, 25 kStorageBuffer, 26 kInputAttachment, 27 28 kLast = kInputAttachment, 29 }; 30 static constexpr int kDescriptorTypeCount = (int)(DescriptorType::kLast) + 1; 31 32 enum class PipelineStageFlags : uint8_t { 33 kVertexShader = 0b001, 34 kFragmentShader = 0b010, 35 kCompute = 0b100, 36 }; 37 SK_MAKE_BITMASK_OPS(PipelineStageFlags); 38 39 struct DescriptorData { 40 DescriptorData(DescriptorType type, 41 uint32_t count, 42 int bindingIdx, 43 SkEnumBitMask<PipelineStageFlags> stageFlags, 44 const Sampler* immutableSampler = nullptr) fTypeDescriptorData45 : fType (type) 46 , fCount (count) 47 , fBindingIndex (bindingIdx) 48 , fPipelineStageFlags(stageFlags) 49 , fImmutableSampler(immutableSampler) {} 50 51 DescriptorType fType; 52 uint32_t fCount; 53 int fBindingIndex; 54 SkEnumBitMask<PipelineStageFlags> fPipelineStageFlags; 55 const Sampler* fImmutableSampler; 56 }; 57 58 }; // namespace skgpu::graphite 59 60 #endif // skgpu_graphite_DescriptorTypes_DEFINED 61