aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api-test/main.cpp63
-rw-r--r--api-test/vk-device.cpp3
-rw-r--r--include/api-test/vk-device-types.hpp15
-rw-r--r--include/api-test/vk-device.hpp8
-rw-r--r--shaders/api-test-ui.frag2
5 files changed, 49 insertions, 42 deletions
diff --git a/api-test/main.cpp b/api-test/main.cpp
index 2f973ff..7f30fda 100644
--- a/api-test/main.cpp
+++ b/api-test/main.cpp
@@ -34,6 +34,36 @@ void ui() {
ImGui::Render();
}
+void update_buffers(ImDrawData* draw_data, const device_buffer& vertex_buffer, const device_buffer& index_buffer) {
+ struct vertex {
+ ImVec2 pos;
+ ImVec2 uv;
+ uint32_t color;
+ uint32_t padding;
+ };
+
+ off_t vertex_offset = 0;
+ off_t index_offset = 0;
+ for (auto index {0U} ; index < draw_data->CmdListsCount; index++) {
+ auto* cmd_list = draw_data->CmdLists[index];
+
+ size_t vertex_bytes_size = sizeof(ImDrawVert) * cmd_list->VtxBuffer.size();
+ auto* vtx_ptr = static_cast<vertex*>(vertex_buffer.mapped_ptr) + vertex_offset;
+ for (auto vtx_index{0}; vtx_index < cmd_list->VtxBuffer.size(); vtx_index++, vtx_ptr++) {
+ auto& vtx = cmd_list->VtxBuffer[vtx_index];
+ vtx_ptr->pos = vtx.pos;
+ vtx_ptr->uv = vtx.uv;
+ vtx_ptr->color = vtx.col;
+ }
+ // memcpy(static_cast<uint8_t*>(vertex_buffer.mapped_ptr) + vertex_offset, cmd_list->VtxBuffer.Data, vertex_bytes_size);
+ vertex_offset += static_cast<off_t>(vertex_bytes_size);
+
+ size_t index_bytes_size = sizeof(ImDrawIdx) * cmd_list->IdxBuffer.size();
+ memcpy(static_cast<uint8_t*>(index_buffer.mapped_ptr) + index_offset, cmd_list->IdxBuffer.Data, index_bytes_size);
+ index_offset += static_cast<off_t>(index_bytes_size);
+ }
+}
+
int main() {
#ifdef ENABLE_RENDERDOC
@@ -193,6 +223,7 @@ int main() {
command_buffers[0].barrier(gpu_texture_handle, VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT, VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
command_buffers[0].stop();
+
std::array<struct command_buffer, 1U> compute_command_buffers = {command_buffers[0]};
device->submit(compute_command_buffers, nullptr, &semaphore);
@@ -206,33 +237,7 @@ int main() {
ui();
auto* draw_data = ImGui::GetDrawData();
- struct vertex {
- ImVec2 pos;
- ImVec2 uv;
- uint32_t color;
- uint32_t padding;
- };
-
- off_t vertex_offset = 0;
- off_t index_offset = 0;
- for (auto index {0U} ; index < draw_data->CmdListsCount; index++) {
- auto* cmd_list = draw_data->CmdLists[index];
-
- size_t vertex_bytes_size = sizeof(ImDrawVert) * cmd_list->VtxBuffer.size();
- auto* vtx_ptr = static_cast<vertex*>(vertex_buffer.mapped_ptr) + vertex_offset;
- for (auto vtx_index{0}; vtx_index < cmd_list->VtxBuffer.size(); vtx_index++, vtx_ptr++) {
- auto& vtx = cmd_list->VtxBuffer[vtx_index];
- vtx_ptr->pos = vtx.pos;
- vtx_ptr->uv = vtx.uv;
- vtx_ptr->color = vtx.col;
- }
- // memcpy(static_cast<uint8_t*>(vertex_buffer.mapped_ptr) + vertex_offset, cmd_list->VtxBuffer.Data, vertex_bytes_size);
- vertex_offset += static_cast<off_t>(vertex_bytes_size);
-
- size_t index_bytes_size = sizeof(ImDrawIdx) * cmd_list->IdxBuffer.size();
- memcpy(static_cast<uint8_t*>(index_buffer.mapped_ptr) + index_offset, cmd_list->IdxBuffer.Data, index_bytes_size);
- index_offset += static_cast<off_t>(index_bytes_size);
- }
+ update_buffers(draw_data, vertex_buffer, index_buffer);
device->wait(semaphore);
@@ -259,8 +264,6 @@ int main() {
printf("%llu\n", sizeof(ImDrawVert));
uint32_t draw_index = 0U;
- uint32_t vtx_offset = 0U;
- uint32_t idx_offset = 0U;
std::array<draw_params, 100U> draws;
for (auto index {0U} ; index < draw_data->CmdListsCount; index++) {
auto* cmd_list = draw_data->CmdLists[index];
@@ -290,7 +293,6 @@ int main() {
});
draw_index++;
- // vtx_offset += draw_command.
}
}
@@ -303,7 +305,6 @@ int main() {
device->submit(ui_command_buffers, nullptr, &semaphore);
RD_END_CAPTURE;
- // std::system("PAUSE");
break;
}
diff --git a/api-test/vk-device.cpp b/api-test/vk-device.cpp
index 296d76c..502143a 100644
--- a/api-test/vk-device.cpp
+++ b/api-test/vk-device.cpp
@@ -235,7 +235,6 @@ handle<device_buffer> vkdevice::create_buffer(const buffer_desc& desc) {
handle<device_pipeline> vkdevice::create_pipeline(const pipeline_desc& desc) {
device_pipeline device_pipeline{
.desc = desc,
- .bindless = &bindless,
};
if (!desc.cs_code.empty()) {
VkShaderModule shader_module;
@@ -587,7 +586,7 @@ void vkdevice::submit(std::span<command_buffer> buffers, vksemaphore* wait, vkse
#endif
}
-void vkdevice::present(vksurface& surface, const vksemaphore& semaphore) {
+void vkdevice::present(device_surface& surface, const vksemaphore& semaphore) {
VkResult result;
VkPresentInfoKHR present_info{
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
diff --git a/include/api-test/vk-device-types.hpp b/include/api-test/vk-device-types.hpp
index 987eb13..b069883 100644
--- a/include/api-test/vk-device-types.hpp
+++ b/include/api-test/vk-device-types.hpp
@@ -69,5 +69,18 @@ struct device_pipeline {
VkPipelineBindPoint bind_point;
pipeline_desc desc;
- bindless_model* bindless = nullptr;
+ // bindless_model* bindless = nullptr;
+};
+
+
+struct surface_desc {
+
+};
+
+struct device_surface {
+ VkSurfaceKHR vk_surface;
+ VkSwapchainKHR vk_swapchain;
+
+ handle<device_texture> swapchain_images;
+ uint32_t image_index;
};
diff --git a/include/api-test/vk-device.hpp b/include/api-test/vk-device.hpp
index 32a0707..5b71529 100644
--- a/include/api-test/vk-device.hpp
+++ b/include/api-test/vk-device.hpp
@@ -15,12 +15,6 @@ using VmaAllocator = struct VmaAllocator_T*;
class window;
-struct vksurface {
- VkSurfaceKHR vk_surface;
- VkSwapchainKHR vk_swapchain;
- uint32_t image_index;
-};
-
struct vksemaphore {
VkSemaphore vk_semaphore = nullptr;
uint64_t value = 0U;
@@ -89,7 +83,7 @@ class vkdevice {
void submit(std::span<command_buffer> buffers, vksemaphore* wait, vksemaphore* signal);
- void present(vksurface& surface, const vksemaphore& semaphore);
+ void present(device_surface& surface, const vksemaphore& semaphore);
private:
vkdevice(const window& window);
diff --git a/shaders/api-test-ui.frag b/shaders/api-test-ui.frag
index fc1c1ee..d0e3377 100644
--- a/shaders/api-test-ui.frag
+++ b/shaders/api-test-ui.frag
@@ -18,6 +18,6 @@ layout(set = 2, binding = 0) uniform parameters {
} params;
void main() {
- o_Color = In.color * texture(sampler2D(textures[nonuniformEXT(params.texture_index)], samplers[nonuniformEXT(0U)]), In.uv.xy);
+ o_Color = In.color * texture(sampler2D(textures[nonuniformEXT(params.texture_index)], samplers[nonuniformEXT(1U)]), In.uv.xy);
// o_Color = vec4(1, 0, 0, 1);
}