diff options
| -rw-r--r-- | CMakeLists.txt | 1 | ||||
| -rw-r--r-- | api-test/main.cpp | 63 | ||||
| -rw-r--r-- | api-test/vk-bindless.cpp | 4 | ||||
| -rw-r--r-- | api-test/vk-device.cpp | 118 | ||||
| -rw-r--r-- | include/api-test/freelist.hpp | 115 | ||||
| -rw-r--r-- | include/api-test/handle.hpp | 14 | ||||
| -rw-r--r-- | include/api-test/vk-device-types.hpp | 59 | ||||
| -rw-r--r-- | include/api-test/vk-device.hpp | 16 | ||||
| -rw-r--r-- | shaders/api-test-ui.frag | 3 | ||||
| -rw-r--r-- | shaders/api-test-ui.vert | 3 |
10 files changed, 238 insertions, 158 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 429fe21..c36dc38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file") -set(CMAKE_BUILD_TYPE Debug) project(path-tracer VERSION 1.0 LANGUAGES CXX) diff --git a/api-test/main.cpp b/api-test/main.cpp index 30668e2..0a2ab71 100644 --- a/api-test/main.cpp +++ b/api-test/main.cpp @@ -27,6 +27,9 @@ struct device_texture; RENDERDOC_API_1_4_1 *rdoc_api = nullptr; #endif +static constexpr size_t Kb = 1024U; +static constexpr size_t Mb = 1024U * Kb; + void ui() { ImGui::NewFrame(); bool open = true; @@ -77,8 +80,8 @@ int main() { } #endif - constexpr size_t window_width = 640U; - constexpr size_t window_height = 360U; + constexpr size_t window_width = 1280U; + constexpr size_t window_height = 720U; window wnd { window_width, window_height }; ImGui::CreateContext(); @@ -166,15 +169,16 @@ int main() { addr = static_cast<void*>(static_cast<uint8_t*>(staging_buffer.mapped_ptr) + ui_offset); memcpy(addr, pixels, size); - auto vertex_buffer = device.get_buffer(device.create_buffer({ - .size = 1024U * 1024U * sizeof(uint32_t), + auto vertex_buffer_handle = device.create_buffer({ + .size = Mb * sizeof(uint32_t), .usages = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, .memory_properties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, .memory_usage = VMA_MEMORY_USAGE_CPU_TO_GPU, - })); + }); + auto vertex_buffer = device.get_buffer(vertex_buffer_handle); auto index_buffer_handle = device.create_buffer({ - .size = 1024U * 1024U * sizeof(uint32_t), + .size = Mb * sizeof(uint32_t), .usages = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, .memory_properties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, .memory_usage = VMA_MEMORY_USAGE_CPU_TO_GPU, @@ -226,9 +230,9 @@ int main() { }; const auto& uniform_buffer = device.get_bindingmodel().get_uniform_buffer(); compute_params params { - device.get_texture(second_texture).storage_index, - device.get_texture(gpu_texture_handle).storage_index, - device.get_texture(output_texture_handle).storage_index, + device.get_texture(second_texture).get_storage_index(), + device.get_texture(gpu_texture_handle).get_storage_index(), + device.get_texture(output_texture_handle).get_storage_index(), }; memcpy(uniform_buffer.mapped_ptr, ¶ms, sizeof(params)); @@ -249,12 +253,19 @@ int main() { RD_END_CAPTURE; std::array<struct command_buffer, 1U> ui_command_buffers = {command_buffers[1]}; - // std::array<handle<device_texture>, 1U> color_attachment {gpu_texture_handle}; - surface.acquire_image_index(acquire_semaphore); - std::array<handle<device_texture>, 1U> color_attachment {surface.get_backbuffer_image()}; + std::array<handle<device_texture>, 1U> color_attachment {}; while(wnd.isOpen) { wnd.poll_events(); + for (auto& event : wnd.events) { + if (event.type == EVENT_TYPES::MOUSE_MOVE) { + io.MousePos.x = static_cast<float>(event.x); + io.MousePos.y = static_cast<float>(event.y); + } + + io.MouseDown[0] = event.type == EVENT_TYPES::BUTTON_PRESS; + } + ui(); auto* draw_data = ImGui::GetDrawData(); @@ -262,6 +273,9 @@ int main() { device.wait(semaphore); + surface.acquire_image_index(acquire_semaphore); + color_attachment[0] = surface.get_backbuffer_image(); + RD_START_CAPTURE; command_buffers[1].start(), @@ -299,7 +313,7 @@ int main() { -1.f - draw_data->DisplayPos.x * (2.f / draw_data->DisplaySize.x), -1.f - draw_data->DisplayPos.y * (2.f / draw_data->DisplaySize.y), }, - .texture_index = ui_texture.sampled_index, + .texture_index = ui_texture.get_sampled_index(), }; command_buffers[1].render({ @@ -327,9 +341,28 @@ int main() { device.wait(semaphore); device.present(surface_handle, {}); RD_END_CAPTURE; - - std::system("PAUSE"); } + device.wait(semaphore); + + device.destroy_surface(surface_handle); + + device.destroy_pipeline(compute); + device.destroy_pipeline(graphics); + + device.destroy_semaphore(semaphore); + device.destroy_semaphore(acquire_semaphore); + + device.destroy_texture(gpu_texture_handle); + device.destroy_texture(second_texture); + device.destroy_texture(output_texture_handle); + device.destroy_texture(ui_texture_handle); + + device.destroy_buffer(staging_buffer_handle); + device.destroy_buffer(vertex_buffer_handle); + device.destroy_buffer(index_buffer_handle); + + ImGui::DestroyContext(); + return 0; } diff --git a/api-test/vk-bindless.cpp b/api-test/vk-bindless.cpp index c48aea1..c27211f 100644 --- a/api-test/vk-bindless.cpp +++ b/api-test/vk-bindless.cpp @@ -118,6 +118,7 @@ bindless_model bindless_model::create_bindless_model() { } void bindless_model::destroy_bindless_model(bindless_model& bindless) { + auto& render_device = vkdevice::get_render_device(); auto* device = vkdevice::get_render_device().get_device(); vkDestroyDescriptorPool(device, bindless.descriptor_pool, nullptr); @@ -128,6 +129,9 @@ void bindless_model::destroy_bindless_model(bindless_model& bindless) { vkDestroyPipelineLayout(device, bindless.layout, nullptr); bindless.destroy_immutable_samplers(device); + + render_device.destroy_buffer(bindless.instances_uniform_buffer_handle); + render_device.destroy_buffer(bindless.draws_uniform_buffer_handle); } void bindless_model::create_layout(VkDevice device) { diff --git a/api-test/vk-device.cpp b/api-test/vk-device.cpp index 2742220..42f6269 100644 --- a/api-test/vk-device.cpp +++ b/api-test/vk-device.cpp @@ -44,26 +44,6 @@ vkdevice::~vkdevice() { bindless_model::destroy_bindless_model(bindless); - for (const auto& surface : surfaces) { - destroy_surface(surface); - } - - for (const auto& texture : textures) { - destroy_texture(texture); - } - - for (const auto& buffer : buffers) { - destroy_buffer(buffer); - } - - for (const auto& pipeline : pipelines) { - destroy_pipeline(pipeline); - } - - for (const auto& semaphore : semaphores) { - destroy_semaphore(semaphore); - } - vmaDestroyAllocator(gpu_allocator); for (auto& queue : queues) { @@ -80,13 +60,15 @@ vkdevice::~vkdevice() { } handle<device_texture> vkdevice::create_texture(const texture_desc& desc) { - device_texture device_texture { desc }; + device_texture device_texture; + device_texture.init(desc); - return { textures.add(device_texture) }; + return textures.add(device_texture); } handle<device_buffer> vkdevice::create_buffer(const buffer_desc& desc) { device_buffer device_buffer{ + .size = desc.size, }; VkBufferCreateInfo create_info{ @@ -128,7 +110,7 @@ handle<device_buffer> vkdevice::create_buffer(const buffer_desc& desc) { device_buffer.mapped_ptr = alloc_info.pMappedData; - return { buffers.add(device_buffer) }; + return buffers.add(device_buffer); } handle<device_pipeline> vkdevice::create_pipeline(const pipeline_desc& desc) { @@ -298,7 +280,7 @@ handle<device_pipeline> vkdevice::create_pipeline(const pipeline_desc& desc) { } } - return { pipelines.add(device_pipeline) }; + return pipelines.add(device_pipeline); } handle<device_surface> vkdevice::create_surface(const surface_desc& desc) { @@ -319,7 +301,7 @@ handle<device_surface> vkdevice::create_surface(const surface_desc& desc) { create_swapchain(desc, device_surface); - return { surfaces.add(device_surface) }; + return surfaces.add(device_surface); } handle<device_semaphore> vkdevice::create_semaphore(const semaphore_desc& desc) { @@ -341,58 +323,35 @@ handle<device_semaphore> vkdevice::create_semaphore(const semaphore_desc& desc) VKCHECK(vkCreateSemaphore(device, &create_info, nullptr, &semaphore.vk_semaphore)); - return { semaphores.add(semaphore) }; -} - -void vkdevice::destroy_texture(const device_texture& texture) { - destroy_texture({ .id = textures.find(texture) }); + return semaphores.add(semaphore); } void vkdevice::destroy_texture(handle<device_texture> handle) { - const auto& texture = get_texture(handle); - textures.remove(handle.id); - - vmaDestroyImage(gpu_allocator, texture.vk_image, texture.alloc); - - vkDestroyImageView(device, texture.whole_view, nullptr); - - for (const auto& mip_view : texture.mips_views) { - vkDestroyImageView(device, mip_view, nullptr); - } -} + auto& texture = get_texture(handle); -void vkdevice::destroy_buffer(const device_buffer& buffer) { - destroy_buffer({ .id = buffers.find(buffer) }); + texture.release(); + textures.remove(handle); } void vkdevice::destroy_buffer(handle<device_buffer> handle) { const auto& buffer = get_buffer(handle); vmaDestroyBuffer(gpu_allocator, buffer.vk_buffer, buffer.alloc); -} - -void vkdevice::destroy_pipeline(const device_pipeline& pipeline) { - destroy_pipeline({ .id = pipelines.find(pipeline) }); + buffers.remove(handle); } void vkdevice::destroy_pipeline(handle<device_pipeline> handle) { const auto& pipeline = vkdevice::get_pipeline(handle); vkDestroyPipeline(device, pipeline.vk_pipeline, nullptr); -} - -void vkdevice::destroy_semaphore(const device_semaphore& semaphore) { - destroy_semaphore({ .id = semaphores.find(semaphore)}); + pipelines.remove(handle); } void vkdevice::destroy_semaphore(handle<device_semaphore> handle) { auto& semaphore = vkdevice::get_semaphore(handle); vkDestroySemaphore(device, semaphore.vk_semaphore, nullptr); -} - -void vkdevice::destroy_surface(const device_surface& surface) { - destroy_surface({ .id = surfaces.find(surface)}); + semaphores.remove(handle); } void vkdevice::destroy_surface(handle<device_surface> handle) { @@ -400,13 +359,7 @@ void vkdevice::destroy_surface(handle<device_surface> handle) { for (auto texture_index{0U}; texture_index < surface.image_count; texture_index++) { auto texture_handle = surface.swapchain_images[texture_index]; - const auto& texture = get_texture(texture_handle); - - vkDestroyImageView(device, texture.whole_view, nullptr); - - for (auto mip_index{0U}; mip_index < texture.mips; mip_index++) { - vkDestroyImageView(device, texture.mips_views[mip_index], nullptr); - } + destroy_texture(texture_handle); } vkDestroySwapchainKHR(device, surface.vk_swapchain, nullptr); @@ -425,6 +378,7 @@ void vkdevice::wait(handle<device_semaphore> semaphore_handle) { .pValues = &semaphore.value, }; VKCHECK(vkWaitSemaphores(device, &wait_info, -1)); + vkDeviceWaitIdle(device); } void vkdevice::submit(std::span<command_buffer> buffers, handle<device_semaphore> wait_handle, handle<device_semaphore> signal_handle) { @@ -649,6 +603,7 @@ void vkdevice::create_swapchain(const surface_desc& desc, device_surface& surfac .width = extent.width, .height = extent.height, .depth = 1U, + .mips = 1U, .usages = desc.usages, .format = desc.surface_format.format, .type = VK_IMAGE_TYPE_2D, @@ -888,10 +843,10 @@ void vkdevice::create_debug_layer_callback() { } -freelist<device_texture*> device_texture::sampled_indices = {}; -freelist<device_texture*> device_texture::storage_indices = {}; +idlist<> device_texture::sampled_indices = {}; +idlist<> device_texture::storage_indices = {}; -device_texture::device_texture(const texture_desc& desc) { +void device_texture::init(const texture_desc& desc) { auto& render_device = vkdevice::get_render_device(); const auto& bindless = render_device.get_bindingmodel(); auto* device = render_device.get_device(); @@ -956,14 +911,14 @@ device_texture::device_texture(const texture_desc& desc) { std::vector<VkWriteDescriptorSet> write_descriptor_sets; if ((desc.usages & VK_IMAGE_USAGE_STORAGE_BIT) != 0) { - storage_index = storage_indices.add(this); + storage_index = storage_indices.add(); write_descriptor_sets.push_back({ .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .pNext = nullptr, .dstSet = bindless.sets[BindlessSetType::GLOBAL], .dstBinding = 2U, - .dstArrayElement = storage_index, + .dstArrayElement = storage_index.id, .descriptorCount = sizeof(images_info) / sizeof(VkDescriptorImageInfo), .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .pImageInfo = images_info, @@ -972,14 +927,14 @@ device_texture::device_texture(const texture_desc& desc) { }); } if ((desc.usages & VK_IMAGE_USAGE_SAMPLED_BIT) != 0) { - sampled_index = sampled_indices.add(this); + sampled_index = sampled_indices.add(); write_descriptor_sets.push_back({ .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .pNext = nullptr, .dstSet = bindless.sets[BindlessSetType::GLOBAL], .dstBinding = 1U, - .dstArrayElement = sampled_index, + .dstArrayElement = sampled_index.id, .descriptorCount = sizeof(images_info) / sizeof(VkDescriptorImageInfo), .descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, .pImageInfo = images_info, @@ -991,6 +946,31 @@ device_texture::device_texture(const texture_desc& desc) { vkUpdateDescriptorSets(device, write_descriptor_sets.size(), write_descriptor_sets.data(), 0U, nullptr); } +void device_texture::release() { + auto& render_device = vkdevice::get_render_device(); + auto* device = render_device.get_device(); + auto* gpu_allocator = render_device.get_allocator(); + + if (alloc != nullptr) { + vmaDestroyImage(gpu_allocator, vk_image, alloc); + } + + vkDestroyImageView(device, whole_view, nullptr); + + for (auto mip_index{ 0U }; mip_index < mips; mip_index++) { + const auto& mip_view = mips_views[mip_index]; + vkDestroyImageView(device, mip_view, nullptr); + } + + if (storage_index.is_valid()) { + storage_indices.remove(storage_index); + } + + if (sampled_index.is_valid()) { + sampled_indices.remove(sampled_index); + } +} + void device_texture::create_views() { auto* device = vkdevice::get_render_device().get_device(); diff --git a/include/api-test/freelist.hpp b/include/api-test/freelist.hpp index 3cdd55d..e9df734 100644 --- a/include/api-test/freelist.hpp +++ b/include/api-test/freelist.hpp @@ -3,61 +3,118 @@ #include <vector> #include <cassert> +#include "handle.hpp" + static constexpr uint32_t default_element_count = 1024U; template<typename T, const size_t initial_size = default_element_count> class freelist { public: - freelist() - : free(initial_size), - items(initial_size) { - std::iota(free.rbegin(), free.rend(), 0); + + freelist() { + auto next_free = 0U; + elements.reserve(initial_size); + for (auto id { 0U }; id < initial_size; id++) { + elements.push_back( + { + .next_free = static_cast<uint32_t>(++next_free % initial_size), + } + ); + } + + elements.back().next_free = -1U; } - uint32_t add(const T& item) { - const auto id = free.back(); - free.pop_back(); + handle<T> add(const T& item) { + auto id = elements[0U].next_free; + + if (id != -1U) { + auto& element = elements[id]; - items[id] = std::move(item); + elements[0U].next_free = element.next_free; + element.item = std::move(item); - return id; + return { id, ++element.generation }; + } + + // grow } - void remove(uint32_t item_id) { - free.push_back(item_id); + void remove(handle<T> handle) { + assert(handle.generation == elements[handle.id].generation); + elements[handle.id].next_free = elements[0U].next_free; + elements[0U].next_free = handle.id; } - T& operator[](uint32_t index) { - assert(index >= 0); - return items[index]; + T& operator[](handle<T> handle) { + assert(handle.generation == elements[handle.id].generation); + return elements[handle.id].item; } - const T& operator[](uint32_t index) const { - return items[index]; + const T& operator[](handle<T> handle) const { + assert(handle.generation == elements[handle.id].generation); + return elements[handle.id].item; } - uint32_t find(const T& seeked_item) { - for (auto index { 0U }; index < items.size(); index++) { - const auto& item = items[index]; - if (memcmp(&item, &seeked_item, sizeof(T)) == 0) { - return index; - } + static constexpr uint32_t invalid_id = -1; + +private: + struct element { + union { + T item; + uint32_t next_free = -1; + }; + uint32_t generation = 0U; + }; + + std::vector<element> elements; +}; + +template<const size_t initial_size = default_element_count> +class idlist { + public: + + idlist() { + auto next_free = 1U; + elements.reserve(initial_size); + for (auto id { 0U }; id < initial_size; id++) { + elements.push_back( + { + .next_free = static_cast<uint32_t>(++next_free % initial_size), + } + ); } - return invalid_id; + elements.back().next_free = -1U; } - auto begin() const { - return items.begin(); + handle<void> add() { + auto id = elements[0U].next_free; + + if (id != -1U) { + auto& element = elements[id]; + elements[0U].next_free = element.next_free; + element.next_free = -1; + + return { id, ++element.generation }; + } + + // grow } - auto end() const { - return items.end(); + void remove(handle<void> handle) { + assert(handle.generation == elements[handle.id].generation); + elements[handle.id].next_free = elements[0U].next_free; + elements[0U].next_free = handle.id; } static constexpr uint32_t invalid_id = -1; private: - std::vector<T> items; - std::vector<uint32_t> free; + struct element { + uint32_t next_free = -1; + uint32_t generation = 0U; + }; + + std::vector<element> elements; }; diff --git a/include/api-test/handle.hpp b/include/api-test/handle.hpp index a81480a..72c46a2 100644 --- a/include/api-test/handle.hpp +++ b/include/api-test/handle.hpp @@ -2,9 +2,19 @@ #include <cstdint> -template<typename T> +// template<typename T> +// struct handle { +// uint32_t id = handle::invalid_id; +// +// [[nodiscard]] inline bool is_valid() const { return id != handle::invalid_id; } +// +// static constexpr uint32_t invalid_id = -1U; +// }; + +template<typename U> struct handle { - uint32_t id = handle::invalid_id; + uint32_t id = invalid_id; + uint32_t generation = 0U; [[nodiscard]] inline bool is_valid() const { return id != handle::invalid_id; } diff --git a/include/api-test/vk-device-types.hpp b/include/api-test/vk-device-types.hpp index 86eb22b..3085e29 100644 --- a/include/api-test/vk-device-types.hpp +++ b/include/api-test/vk-device-types.hpp @@ -22,33 +22,42 @@ struct texture_desc { }; struct device_texture { - device_texture() = default; - device_texture(const texture_desc& desc); + void init(const texture_desc& desc); - void create_views(); + void release(); - VkImage vk_image; - VkImageView whole_view; + void create_views(); + + [[nodiscard]] uint32_t get_storage_index() const { + return storage_index.id; + } + + [[nodiscard]] uint32_t get_sampled_index() const { + return sampled_index.id; + } + + VkImage vk_image = nullptr; + VkImageView whole_view = nullptr; VkImageView mips_views[texture_desc::max_mips] = { nullptr }; - VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED; - VkPipelineStageFlags2 stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; - VkAccessFlags2 access = VK_ACCESS_2_NONE; - VkFormat format; - VkImageAspectFlags aspects; + VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED; + VkPipelineStageFlags2 stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; + VkAccessFlags2 access = VK_ACCESS_2_NONE; + VkFormat format = VK_FORMAT_UNDEFINED; + VkImageAspectFlags aspects = VK_IMAGE_ASPECT_NONE_KHR; - uint32_t width = 1U; - uint32_t height = 1U; - uint32_t depth = 1U; - uint32_t mips = 1U; + uint32_t width = 1U; + uint32_t height = 1U; + uint32_t depth = 1U; + uint32_t mips = 1U; - uint32_t storage_index = -1; - uint32_t sampled_index = -1; + private: + handle<void> storage_index; + handle<void> sampled_index; - VmaAllocation alloc; + VmaAllocation alloc = nullptr; -private: - static freelist<device_texture*> storage_indices; - static freelist<device_texture*> sampled_indices; + static idlist<> storage_indices; + static idlist<> sampled_indices; }; struct buffer_desc { @@ -66,7 +75,6 @@ struct device_buffer { size_t size; }; - struct pipeline_desc { std::span<uint8_t> cs_code; std::span<uint8_t> vs_code; @@ -81,15 +89,14 @@ struct device_pipeline { VkPipelineBindPoint bind_point; }; - struct semaphore_desc { VkSemaphoreType type; uint64_t initial_value = 0U; }; struct device_semaphore { - VkSemaphore vk_semaphore = nullptr; - uint64_t value; + VkSemaphore vk_semaphore = nullptr; + uint64_t value; }; @@ -102,7 +109,7 @@ struct surface_desc { VkImageUsageFlags usages; uint32_t image_count = surface_desc::default_image_count; - static constexpr uint32_t max_image_count = 3U; + static constexpr uint32_t max_image_count = 3U; static constexpr uint32_t default_image_count = 3U; }; @@ -115,6 +122,6 @@ struct device_surface { uint32_t image_index; uint32_t image_count; - void acquire_image_index(handle<device_semaphore> signal_handle); + void acquire_image_index(handle<device_semaphore> signal_handle); handle<device_texture> get_backbuffer_image() const; }; diff --git a/include/api-test/vk-device.hpp b/include/api-test/vk-device.hpp index 9e42b38..ca5457a 100644 --- a/include/api-test/vk-device.hpp +++ b/include/api-test/vk-device.hpp @@ -7,7 +7,6 @@ #include "command-buffer.hpp" #include "freelist.hpp" -#include "handle.hpp" #include "vk-bindless.hpp" #include "vk-device-types.hpp" @@ -40,19 +39,14 @@ class vkdevice { handle<device_semaphore> create_semaphore(const semaphore_desc& desc); - void destroy_texture(const device_texture& texture); void destroy_texture(handle<device_texture> handle); - void destroy_buffer(const device_buffer& buffer); void destroy_buffer(handle<device_buffer> handle); - void destroy_pipeline(const device_pipeline& pipeline); void destroy_pipeline(handle<device_pipeline> handle); - void destroy_semaphore(const device_semaphore& semaphore); void destroy_semaphore(handle<device_semaphore> handle); - void destroy_surface(const device_surface& surface); void destroy_surface(handle<device_surface> handle); template<typename cmd_buf_type> @@ -61,23 +55,23 @@ class vkdevice { } [[nodiscard]] inline device_texture& get_texture(handle<device_texture> handle) { - return textures[handle.id]; + return textures[handle]; } [[nodiscard]] inline const device_buffer& get_buffer(handle<device_buffer> handle) const { - return buffers[handle.id]; + return buffers[handle]; } [[nodiscard]] inline const device_pipeline& get_pipeline(handle<device_pipeline> handle) const { - return pipelines[handle.id]; + return pipelines[handle]; } [[nodiscard]] inline device_surface& get_surface(handle<device_surface> handle) { - return surfaces[handle.id]; + return surfaces[handle]; } [[nodiscard]] inline device_semaphore& get_semaphore(handle<device_semaphore> handle) { - return semaphores[handle.id]; + return semaphores[handle]; } [[nodiscard]] inline const bindless_model& get_bindingmodel() const { diff --git a/shaders/api-test-ui.frag b/shaders/api-test-ui.frag index d0e3377..57630dc 100644 --- a/shaders/api-test-ui.frag +++ b/shaders/api-test-ui.frag @@ -18,6 +18,5 @@ layout(set = 2, binding = 0) uniform parameters { } params;
void main() {
- o_Color = In.color * texture(sampler2D(textures[nonuniformEXT(params.texture_index)], samplers[nonuniformEXT(1U)]), In.uv.xy);
- // o_Color = vec4(1, 0, 0, 1);
+ o_Color = In.color * texture(sampler2D(textures[nonuniformEXT(params.texture_index)], samplers[nonuniformEXT(0U)]), In.uv.xy);
}
diff --git a/shaders/api-test-ui.vert b/shaders/api-test-ui.vert index 8dd05a8..92c1372 100644 --- a/shaders/api-test-ui.vert +++ b/shaders/api-test-ui.vert @@ -35,7 +35,4 @@ void main() { Out.uv = v.uv;
gl_Position = vec4(v.pos * params.scale + params.translate, 0.0, 1.0);
-
- // vec2 pos[3] = vec2[3]( vec2(-0.7, 0.7), vec2(0.7, 0.7), vec2(0.0, -0.7) );
- // gl_Position = vec4(pos[gl_VertexIndex], 1.0, 1.0);
}
|
