58 GLOBAL_TRANSFORMS_INDEX_IS_ADDED_TO_FIRST_INSTANCE,
59 GLOBAL_TRANSFORMS_INDEX_OVERWRITE_FIRST_INSTANCE,
60 GLOBAL_TRANSFORMS_INDEX_IS_IGNORED,
62 DEFAULT = GLOBAL_TRANSFORMS_INDEX_OVERWRITE_FIRST_INSTANCE
68 void set(uint32_t globalTransformsIndex, Configs config = Configs::DEFAULT)
70 this->g_transform = globalTransformsIndex;
71 this->g_config = config;
75 return std::holds_alternative<fge::TransformUboData const*>(this->g_transform)
76 ? std::get<fge::TransformUboData const*>(this->g_transform)
79 [[nodiscard]] std::optional<uint32_t> getGlobalTransformsIndex()
const
81 return std::holds_alternative<uint32_t>(this->g_transform)
82 ? std::make_optional(std::get<uint32_t>(this->g_transform))
85 [[nodiscard]] Configs getConfig()
const {
return this->g_config; }
88 std::variant<fge::TransformUboData const*, uint32_t> g_transform{
nullptr};
89 Configs g_config{Configs::DEFAULT};
111 constexpr void setInstancesCount(uint32_t count,
bool uniqueDrawCall)
113 this->g_count = count;
114 this->g_uniqueDrawCall = uniqueDrawCall || (this->g_indirectBuffer != VK_NULL_HANDLE);
116 constexpr void setIndirectBuffer(VkBuffer buffer)
118 this->g_indirectBuffer = buffer;
119 this->g_uniqueDrawCall = (buffer != VK_NULL_HANDLE);
122 constexpr void setTextureIndices(uint32_t
const* textureIndices) { this->g_textureIndices = textureIndices; }
125 uint32_t
const* dynamicBufferSizes,
126 uint32_t
const* dynamicBufferOffsets,
127 uint32_t
const* dynamicSets,
130 this->g_dynamicDescriptors = dynamicDescriptors;
131 this->g_dynamicBufferSizes = dynamicBufferSizes;
132 this->g_dynamicBufferOffsets = dynamicBufferOffsets;
133 this->g_dynamicSets = dynamicSets;
134 this->g_dynamicCount = count;
136 assert(count == 0 || dynamicDescriptors !=
nullptr);
137 assert(count == 0 || dynamicBufferSizes !=
nullptr);
138 assert(count == 0 || dynamicBufferOffsets !=
nullptr);
139 assert(count == 0 || dynamicSets !=
nullptr);
142 constexpr void setVertexCount(uint32_t count) { this->g_vertexCount = count; }
143 constexpr void setVertexOffset(uint32_t offset) { this->g_vertexOffset = offset; }
153 constexpr void setFirstInstance(uint32_t firstInstance) { this->g_firstInstance = firstInstance; }
155 [[nodiscard]]
constexpr uint32_t getInstancesCount()
const {
return this->g_count; }
156 [[nodiscard]]
constexpr bool hasUniqueDrawCall()
const {
return this->g_uniqueDrawCall; }
157 [[nodiscard]]
constexpr VkBuffer getIndirectBuffer()
const {
return this->g_indirectBuffer; }
159 [[nodiscard]]
constexpr uint32_t
const* getTextureIndices()
const {
return this->g_textureIndices; }
160 [[nodiscard]]
constexpr uint32_t getTextureIndices(uint32_t index)
const {
return this->g_textureIndices[index]; }
164 return this->g_dynamicDescriptors + index;
167 [[nodiscard]]
constexpr uint32_t
const* getDynamicBufferSizes()
const {
return this->g_dynamicBufferSizes; }
168 [[nodiscard]]
constexpr uint32_t getDynamicBufferSizes(uint32_t index)
const
170 return this->g_dynamicBufferSizes[index];
173 [[nodiscard]]
constexpr uint32_t
const* getDynamicBufferOffsets()
const {
return this->g_dynamicBufferOffsets; }
174 [[nodiscard]]
constexpr uint32_t getDynamicBufferOffsets(uint32_t index)
const
176 return this->g_dynamicBufferOffsets[index];
179 [[nodiscard]]
constexpr uint32_t
const* getDynamicSets()
const {
return this->g_dynamicSets; }
180 [[nodiscard]]
constexpr uint32_t getDynamicSets(uint32_t index)
const {
return this->g_dynamicSets[index]; }
182 [[nodiscard]]
constexpr uint32_t getDynamicCount()
const {
return this->g_dynamicCount; }
184 [[nodiscard]]
constexpr uint32_t getVertexCount()
const {
return this->g_vertexCount; }
185 [[nodiscard]]
constexpr uint32_t getVertexOffset()
const {
return this->g_vertexOffset; }
187 [[nodiscard]]
constexpr uint32_t getFirstInstance()
const {
return this->g_firstInstance; }
191 uint32_t
const* g_textureIndices{
nullptr};
194 uint32_t g_dynamicCount{0};
195 uint32_t
const* g_dynamicBufferSizes{
nullptr};
196 uint32_t
const* g_dynamicBufferOffsets{
nullptr};
197 uint32_t
const* g_dynamicSets{
nullptr};
199 uint32_t g_vertexCount{0};
200 uint32_t g_vertexOffset{0};
201 uint32_t g_firstInstance{0};
202 bool g_uniqueDrawCall{
false};
203 VkBuffer g_indirectBuffer{VK_NULL_HANDLE};
231 static constexpr std::false_type always_false{};
233 constexpr RenderResourceTextures() =
default;
234 template<
class TTexture>
235 constexpr RenderResourceTextures(TTexture
const* textures, uint32_t count) :
236 g_textures(textures),
237 g_count(textures == nullptr ? 0 : count)
239 if constexpr (std::is_same_v<TTexture, fge::TextureType> || std::is_same_v<TTexture, std::nullptr_t>)
241 this->g_ptrType = PtrTypes::TEXTURE_IMAGE;
243 else if constexpr (std::is_same_v<TTexture, fge::Texture>)
245 this->g_ptrType = PtrTypes::TEXTURE;
249 static_assert(always_false<TTexture>,
"Can't set this type of texture pointer !");
253 template<
class TTexture>
254 constexpr void set(TTexture
const* textures, uint32_t count)
256 this->g_textures = textures;
257 this->g_count = textures ==
nullptr ? 0 : count;
259 if constexpr (std::is_same_v<TTexture, fge::TextureType> || std::is_same_v<TTexture, std::nullptr_t>)
261 this->g_ptrType = PtrTypes::TEXTURE_IMAGE;
263 else if constexpr (std::is_same_v<TTexture, fge::Texture>)
265 this->g_ptrType = PtrTypes::TEXTURE;
269 static_assert(always_false<TTexture>,
"Can't set this type of texture pointer !");
272 [[nodiscard]]
constexpr uint32_t getCount()
const {
return this->g_count; }
273 [[nodiscard]]
constexpr PtrTypes getPointerType()
const {
return this->g_ptrType; }
275 template<PtrTypes TTextureType>
276 constexpr auto const* get(uint32_t index)
const
278 if constexpr (TTextureType == PtrTypes::TEXTURE_IMAGE)
284 return static_cast<fge::Texture const*
>(this->g_textures) + index;
288 template<PtrTypes TTextureType>
289 [[nodiscard]]
constexpr fge::TextureType const* getTextureImage(uint32_t index)
const
291 if constexpr (TTextureType == PtrTypes::TEXTURE_IMAGE)
297#ifndef FGE_DEF_SERVER
298 return static_cast<fge::Texture const*
>(this->g_textures)[index].getSharedData().get();
306 void const* g_textures{
nullptr};
307 PtrTypes g_ptrType{PtrTypes::TEXTURE_IMAGE};
326 using ArrayVariant = std::variant<ArrayOfDescriptorSet, ArrayOfDescriptorSetPointer>;
331 g_descriptors(descriptors),
335 assert(count == 0 || sets !=
nullptr);
338 constexpr void set(ArrayVariant
const& descriptors, uint32_t
const* sets, uint32_t count)
340 this->g_descriptors = descriptors;
342 this->g_count = count;
344 assert(count == 0 || sets !=
nullptr);
347 [[nodiscard]]
constexpr uint32_t getCount()
const {
return this->g_count; }
351 if (std::holds_alternative<ArrayOfDescriptorSet>(this->g_descriptors))
353 return &std::get<ArrayOfDescriptorSet>(this->g_descriptors)[index];
355 return std::get<ArrayOfDescriptorSetPointer>(this->g_descriptors)[index];
357 [[nodiscard]]
constexpr uint32_t getSet(uint32_t index)
const {
return this->g_sets[index]; }
360 ArrayVariant g_descriptors{ArrayOfDescriptorSet{
nullptr}};
361 uint32_t
const* g_sets{
nullptr};
Resource containing textures information for rendering.
Definition C_renderStates.hpp:214
PtrTypes
The type of pointer used to store the textures.
Definition C_renderStates.hpp:225
This class is a wrapper for the texture manager to allow easy manipulation.
Definition C_texture.hpp:36
Definition C_textureImage.hpp:34