diff --git a/demo/tz/tz_triangle_demo.cpp b/demo/tz/tz_triangle_demo.cpp index b899b5fd6f..28057cee62 100644 --- a/demo/tz/tz_triangle_demo.cpp +++ b/demo/tz/tz_triangle_demo.cpp @@ -29,7 +29,8 @@ int main() { .clear_colour = {0.0f, 0.0f, 0.0f, 1.0f}, .colour_targets = colour_targets, - .depth_target = tz::gpu::window_resource + .depth_target = tz::gpu::window_resource, + .triangle_count = 1 }, .shader = graphics, })); diff --git a/include/tz/gpu/pass.hpp b/include/tz/gpu/pass.hpp index 886bda6b31..017bee3569 100644 --- a/include/tz/gpu/pass.hpp +++ b/include/tz/gpu/pass.hpp @@ -94,10 +94,16 @@ namespace tz::gpu std::span colour_targets = {}; /// Optional depth target. This will act as the depth image when performing depth testing/writes. resource_handle depth_target = tz::nullhand; + /// Buffer containing indices used for every frame. + resource_handle index_buffer = tz::nullhand; + /// Buffer containing an initial count and draw commands for every frame. + resource_handle draw_buffer = tz::nullhand; /// Describe which faces will be culled during rendering. cull culling = cull::back; /// Specifies extra optional behaviour for the pass. graphics_flag flags = static_cast(0); + /// Number of triangles to draw in a frame. @note This is ignored if you are using a draw buffer. + std::size_t triangle_count = 0; }; struct pass_compute_state diff --git a/src/tz/gpu/rhi_vulkan.cpp b/src/tz/gpu/rhi_vulkan.cpp index d6e4f2f1ee..65d827bfb0 100644 --- a/src/tz/gpu/rhi_vulkan.cpp +++ b/src/tz/gpu/rhi_vulkan.cpp @@ -1013,6 +1013,14 @@ namespace tz::gpu { UNERR(tz::error_code::precondition_failure, "no shader program provided when creating pass. you must provide a valid shader program."); } + if(info.graphics.index_buffer != tz::nullhand) + { + UNERR(tz::error_code::engine_bug, "support for index buffers is not yet implemented."); + } + if(info.graphics.draw_buffer != tz::nullhand) + { + UNERR(tz::error_code::engine_bug, "support for draw buffers is not yet implemented."); + } std::size_t ret_id = passes.size(); auto& pass = passes.emplace_back(); std::size_t buffer_count = 0; @@ -2386,7 +2394,7 @@ namespace tz::gpu vkCmdSetScissor(frame.cmds, 0, 1, &sci); // maybe bind index buffer // draw[_indexed]/draw_[indexed_]indirect/draw_[indexed_]indirect_count - vkCmdDraw(frame.cmds, 3, 1, 0, 0); // todo: dont hardcode this IDIOT + vkCmdDraw(frame.cmds, pass.info.graphics.triangle_count * 3, 1, 0, 0); // todo: dont hardcode this IDIOT vkCmdEndRendering(frame.cmds); if(render_into_system_image) {