aboutsummaryrefslogtreecommitdiffstats
path: root/include/texture.hpp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2026-05-05 00:43:54 +0200
committerladevieq <ladevie.quentin@gmail.com>2026-05-05 00:49:12 +0200
commitc3aac9026951e2a6e35e76b9c7d36e114a281453 (patch)
treebdfc2ab5d5f1d196ba8c7a76371a29911f75913e /include/texture.hpp
parent754249d9c652ef941e6b082d2e86538d15ba9434 (diff)
Remove old api and move api-test content to src and include dirs
Diffstat (limited to 'include/texture.hpp')
-rw-r--r--include/texture.hpp86
1 files changed, 10 insertions, 76 deletions
diff --git a/include/texture.hpp b/include/texture.hpp
index aac7b69..59bfec1 100644
--- a/include/texture.hpp
+++ b/include/texture.hpp
@@ -1,83 +1,17 @@
-#include <cstdint>
-
-using VkImage = struct VkImage_T*;
-
-struct TextureDesc {
- VkImageType type;
- VkFormat format;
- VkExtent size;
- VkImageUsageFlags usages;
-};
-
-class Texture {
- public:
- Texture(const TextureDesc desc)
- : description(desc) {
- create_device_image();
- }
-
- // Texture(handle image_handle) {
- // const auto& image = vkrenderer::api.get_image(image_handle);
- // width = image.size.width;
- // height = image.size.height;
- // depth = image.size.depth;
-
- // device_image = image_handle;
- // }
-
- // Texture(size_t width, size_t height, size_t depth, VkFormat format = VK_FORMAT_R8G8B8A8_UNORM, Sampler* texture_sampler = nullptr)
- // : width(width), height(height), depth(depth) {
- // sampler = texture_sampler;
- // device_image = vkrenderer::api.create_image(
- // { .width = (uint32_t)width, .height = (uint32_t)height, .depth = 1 },
- // format,
- // VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT);
- // }
+#pragma once
- void update(void* new_data) {
- if (data == nullptr) {
- free(data);
- }
- data = new_data;
-
- vkrenderer::queue_image_update(this);
- }
-
- ~Texture() {
- vkrenderer::api.destroy_image(device_image);
-
- if (data == nullptr) {
- free(data);
- }
- }
-
- [[nodiscard]] size_t size() const {
- const auto& image = vkrenderer::api.get_image(device_image);
- return width * height * depth * pixel_size(image.format);
- }
-
- static size_t pixel_size(VkFormat format) {
- switch (format) {
- case VK_FORMAT_R8G8B8A8_UNORM:
- return 4;
- default:
- return 0;
- }
- }
-
- // Sampler* sampler = nullptr;
+#include <cstdint>
- private:
- void create_device_image();
+#include <vulkan/vulkan_core.h>
- void* data = nullptr;
+#include "handle.hpp"
- size_t width = 0;
- size_t height = 0;
- size_t depth = 0;
+struct device_texture;
- TextureDesc description;
+class texture {
+public:
+ texture(handle<device_texture> handle);
- VmaAllocationInfo alloc_info;
- VkImage device_image;
+private:
+ handle<device_texture> handle;
};