diff --git a/include/tz/gpu/resource.hpp b/include/tz/gpu/resource.hpp index 0cf378fdd6..1d8807dbca 100644 --- a/include/tz/gpu/resource.hpp +++ b/include/tz/gpu/resource.hpp @@ -208,6 +208,8 @@ namespace tz::gpu */ tz::error_code resource_write(resource_handle res, std::span new_data, std::size_t offset = 0); std::size_t resource_size(resource_handle res); + unsigned int image_get_width(resource_handle res); + unsigned int image_get_height(resource_handle res); /** * @ingroup tz_gpu_resource * @brief Retrieves the current data within a resource. diff --git a/include/tz/ren/quad.hpp b/include/tz/ren/quad.hpp index 75a4a4a8ad..a340aaed54 100644 --- a/include/tz/ren/quad.hpp +++ b/include/tz/ren/quad.hpp @@ -33,6 +33,7 @@ namespace tz::ren { tz::v4f clear_colour = {0.0f, 0.0f, 0.0f, 1.0f}; quad_renderer_flag flags = static_cast(0); + tz::gpu::resource_handle colour_target = tz::gpu::window_resource; }; std::expected create_quad_renderer(quad_renderer_info info); diff --git a/src/tz/gpu/rhi_vulkan.cpp b/src/tz/gpu/rhi_vulkan.cpp index 430a27eb47..e59376cda5 100644 --- a/src/tz/gpu/rhi_vulkan.cpp +++ b/src/tz/gpu/rhi_vulkan.cpp @@ -941,6 +941,42 @@ namespace tz::gpu return resources[resh.peek()].data.size(); } + unsigned int image_get_width(resource_handle res) + { + if(res == tz::nullhand) + { + return 0u; + } + if(res == tz::gpu::window_resource) + { + return swapchain_width; + } + const auto& resource = resources[res.peek()]; + if(!resource.is_image()) + { + return 0u; + } + return std::get(resource.res).width; + } + + unsigned int image_get_height(resource_handle res) + { + if(res == tz::nullhand) + { + return 0u; + } + if(res == tz::gpu::window_resource) + { + return swapchain_height; + } + const auto& resource = resources[res.peek()]; + if(!resource.is_image()) + { + return 0u; + } + return std::get(resource.res).height; + } + std::span resource_read(resource_handle resh) { auto& res = resources[resh.peek()]; diff --git a/src/tz/ren/quad.cpp b/src/tz/ren/quad.cpp index fbf95a56c2..39c8479fec 100644 --- a/src/tz/ren/quad.cpp +++ b/src/tz/ren/quad.cpp @@ -85,7 +85,7 @@ namespace tz::ren tz::gpu::resource_handle colour_targets[] = { - tz::gpu::window_resource + info.colour_target }; tz::gpu::resource_handle resources[] = { @@ -253,8 +253,8 @@ namespace tz::ren { auto& ren = renderers[renh.peek()]; - auto w = tz::os::window_get_width(); - auto h = tz::os::window_get_height(); + auto w = tz::gpu::image_get_width(ren.info.colour_target); + auto h = tz::gpu::image_get_height(ren.info.colour_target); if((w != 0 && h != 0) && (ren.window_width_cache != w || ren.window_height_cache != h)) { // window has resized