15 #include <vsg/core/Allocator.h>
16 #include <vsg/core/Object.h>
17 #include <vsg/core/compare.h>
18 #include <vsg/core/type_name.h>
19 #include <vsg/vk/vulkan.h>
32 bool operator==(
const ModifiedCount& rhs)
const {
return count == rhs.count; }
33 bool operator!=(
const ModifiedCount& rhs)
const {
return count != rhs.count; }
35 void operator++() { ++count; }
56 enum DataVariance : uint8_t
59 STATIC_DATA_UNREF_AFTER_TRANSFER = 1,
61 DYNAMIC_DATA_TRANSFER_AFTER_RECORD = 3
68 using iterator_category = std::forward_iterator_tag;
69 using difference_type = std::ptrdiff_t;
78 if constexpr (std::is_const<value_type>::value)
79 ptr =
reinterpret_cast<value_type*
>(
reinterpret_cast<const uint8_t*
>(ptr) + stride);
81 ptr =
reinterpret_cast<value_type*
>(
reinterpret_cast<uint8_t*
>(ptr) + stride);
103 value_type& operator*() {
return *
reinterpret_cast<value_type*
>(ptr); }
104 value_type* operator->() {
return reinterpret_cast<value_type*
>(ptr); }
122 VkFormat format = VK_FORMAT_UNDEFINED;
124 uint8_t maxNumMipmaps = 0;
125 uint8_t blockWidth = 1;
126 uint8_t blockHeight = 1;
127 uint8_t blockDepth = 1;
128 uint8_t origin = TOP_LEFT;
129 int8_t imageViewType = -1;
130 DataVariance dataVariance = STATIC_DATA;
131 AllocatorType allocatorType = ALLOCATOR_TYPE_VSG_ALLOCATOR;
139 explicit Data(Properties layout) :
140 properties(layout) {}
142 Data(Properties layout, uint32_t min_stride) :
145 if (properties.stride < min_stride) properties.stride = min_stride;
149 static void*
operator new(
size_t count);
150 static void operator delete(
void* ptr);
152 size_t sizeofObject() const noexcept
override {
return sizeof(
Data); }
153 bool is_compatible(
const std::type_info& type)
const noexcept
override {
return typeid(
Data) == type || Object::is_compatible(type); }
157 void read(
Input& input)
override;
158 void write(
Output& output)
const override;
163 bool dynamic()
const {
return properties.
dataVariance >= DYNAMIC_DATA; }
167 virtual size_t valueSize()
const = 0;
168 virtual size_t valueCount()
const = 0;
170 virtual bool dataAvailable()
const = 0;
171 virtual size_t dataSize()
const = 0;
173 virtual void* dataPointer() = 0;
174 virtual const void* dataPointer()
const = 0;
176 virtual void* dataPointer(
size_t index) = 0;
177 virtual const void* dataPointer(
size_t index)
const = 0;
179 virtual void* dataRelease() = 0;
181 virtual uint32_t dimensions()
const = 0;
183 virtual uint32_t width()
const = 0;
184 virtual uint32_t height()
const = 0;
185 virtual uint32_t depth()
const = 0;
187 bool contiguous()
const {
return valueSize() == properties.stride; }
189 uint32_t stride()
const {
return properties.stride ? properties.stride :
static_cast<uint32_t
>(valueSize()); }
191 using MipmapOffsets = std::vector<size_t>;
192 MipmapOffsets computeMipmapOffsets()
const;
193 static size_t computeValueCountIncludingMipmaps(
size_t w,
size_t h,
size_t d, uint32_t maxNumMipmaps);
201 if (_modifiedCount != mc)
216 ModifiedCount _modifiedCount;
226 VkFormat previous_format = properties.format;
227 uint32_t previous_stride = properties.stride;
229 if (properties.format == 0 && previous_format != 0) properties.format = previous_format;
230 if (properties.stride == 0 && previous_stride != 0) properties.stride = previous_stride;
240 using DataList = std::vector<ref_ptr<Data>>;
Properties properties
properties of the data such as format, origin, stride, dataVariance etc.
Definition: Data.h:161
bool differentModifiedCount(const ModifiedCount &mc) const
return true if Data's ModifiedCount is different from the specified ModifiedCount
Definition: Data.h:211
Layout getLayout() const
deprecated: use data->properties
Definition: Data.h:235
void setLayout(Layout layout)
deprecated: use data->properties = properties instead.
Definition: Data.h:224
void dirty()
increment the ModifiedCount to signify the data has been modified
Definition: Data.h:196
Layout & getLayout()
deprecated: use data->properties
Definition: Data.h:233
bool getModifiedCount(ModifiedCount &mc) const
get the Data's ModifiedCount and return true if this changes the specified ModifiedCount
Definition: Data.h:199
int compare(const Object &rhs_object) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
DataVariance dataVariance
-1 signifies undefined VkImageViewType, if value >=0 then value should be treated as valid VkImageVie...
Definition: Data.h:130
ModifiedCount provides a count value to keep track of modifications to data.
Definition: Data.h:29