aboutsummaryrefslogtreecommitdiffstats
path: root/include/vk-renderer.hpp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2023-01-12 00:47:59 +0100
committerladevieq <ladevie.quentin@gmail.com>2023-01-12 00:47:59 +0100
commit5e3bb454d50091e581d5d1d03af34e38277694b3 (patch)
tree06eada2111afb56a24d0ced89685587400041c8d /include/vk-renderer.hpp
parentb47e177898657e435cb5bc913a4a783fddbe1f3d (diff)
WIP new rendering api
Diffstat (limited to 'include/vk-renderer.hpp')
-rw-r--r--include/vk-renderer.hpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/include/vk-renderer.hpp b/include/vk-renderer.hpp
index ab15cd1..1317912 100644
--- a/include/vk-renderer.hpp
+++ b/include/vk-renderer.hpp
@@ -61,8 +61,6 @@ class vkrenderer {
static Buffer* create_staging_buffer(size_t size);
- static Texture* create_2d_texture(size_t width, size_t height, VkFormat format, Sampler *sampler = nullptr);
-
static Sampler* create_sampler(VkFilter filter, VkSamplerAddressMode address_mode);
@@ -163,67 +161,4 @@ class Sampler {
handle device_sampler;
};
-class Texture {
- public:
-
- 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
- );
- }
-
- 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;
-
- void* data = nullptr;
-
- size_t width = 0;
- size_t height = 0;
- size_t depth = 0;
-
- handle device_image;
-};
#endif // !__VK_RENDERER_HPP_