• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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_VulkanTypesPriv_DEFINED
9 #define skgpu_VulkanTypesPriv_DEFINED
10 
11 #include "include/gpu/vk/VulkanTypes.h"
12 
13 #include <atomic>
14 
15 namespace skgpu {
16 
17 class VulkanMutableTextureState {
18 public:
VulkanMutableTextureState(VkImageLayout layout,uint32_t queueFamilyIndex)19     VulkanMutableTextureState(VkImageLayout layout, uint32_t queueFamilyIndex)
20             : fLayout(layout)
21             , fQueueFamilyIndex(queueFamilyIndex) {}
22 
23     VulkanMutableTextureState& operator=(const VulkanMutableTextureState& that) {
24         fLayout = that.getImageLayout();
25         fQueueFamilyIndex = that.getQueueFamilyIndex();
26         return *this;
27     }
28 
setImageLayout(VkImageLayout layout)29      void setImageLayout(VkImageLayout layout) {
30         // Defaulting to use std::memory_order_seq_cst
31         fLayout.store(layout);
32     }
33 
getImageLayout()34     VkImageLayout getImageLayout() const {
35         // Defaulting to use std::memory_order_seq_cst
36         return fLayout.load();
37     }
38 
setQueueFamilyIndex(uint32_t queueFamilyIndex)39     void setQueueFamilyIndex(uint32_t queueFamilyIndex) {
40         // Defaulting to use std::memory_order_seq_cst
41         fQueueFamilyIndex.store(queueFamilyIndex);
42     }
43 
getQueueFamilyIndex()44     uint32_t getQueueFamilyIndex() const {
45         // Defaulting to use std::memory_order_seq_cst
46         return fQueueFamilyIndex.load();
47     }
48 
49 private:
50     std::atomic<VkImageLayout> fLayout;
51     std::atomic<uint32_t> fQueueFamilyIndex;
52 };
53 
54 } // namespace skgpu
55 
56 #endif // skgpu_VulkanGraphiteTypesPriv_DEFINED
57 
58