111 size_t bytesPerComponent =
sizeof(T);
112 size_t oldPixelSizeBytes = 3 * bytesPerComponent;
113 size_t newPixelSizeBytes = 4 * bytesPerComponent;
115 std::vector<unsigned char> paddedImage;
120 if constexpr (std::is_floating_point_v<T>) {
123 alphaVal = std::numeric_limits<T>::max();
127 unsigned char alphaBytes[
sizeof(T)];
128 memcpy(alphaBytes, &alphaVal,
sizeof(T));
132 for (
size_t i = 0; i <
imageData.image.size(); i += oldPixelSizeBytes)
135 for (
size_t j = 0; j < oldPixelSizeBytes; ++j)
137 paddedImage.push_back(
imageData.image[i + j]);
140 for (
size_t j = 0; j <
sizeof(T); ++j)
142 paddedImage.push_back(alphaBytes[j]);
147 imageData.image = std::move(paddedImage);
The application context is the core class which stores the basic openxr and vulkan objects.
VmaAllocation textureAllocation_
VMA allocation for texture memory.
VkDeviceMemory getVkImageMemory() const
void setupImageFormat(const tinygltf::Image &imageData)
TextureType getTextureType() const
Get the semantic texture type.
tinygltf::Image imageData
Texture(const Texture &)=delete
Texture & operator=(const Texture &)=delete
void setDebugName(const std::string &debugName)
VkImageView vkTextureView
VkSampler getVkImageSampler() const
static std::string createTexturePath(const std::filesystem::path &assetPath, const GltfLoader::GltfMeshPrimitiveData &primitiveData)
VkSampler vkTextureSampler
bool isDescriptorIndexInitialized() const
VkImage getVkImage() const
VkImageView getVkImageView() const
void createDataUploadCommand(VkCommandBuffer commandBuffer, Renderer *renderer) const
uint32_t getDescriptorIndex() const
VkFormat getTextureFormat() const
ApplicationContext * context