diff options
| author | ladevieq <ladevie.quentin@gmail.com> | 2023-02-07 23:53:55 +0100 |
|---|---|---|
| committer | ladevieq <ladevie.quentin@gmail.com> | 2023-02-07 23:53:55 +0100 |
| commit | 74a223d1a9d23369c6c20457424b34cf17da95ab (patch) | |
| tree | 18ccf56b8ddc6274410150e7ad4b986e6cb7dbc5 /api-test/command-buffer.cpp | |
| parent | 9286a3db4f529f435ea4270ffc2ca7a7a1da922d (diff) | |
Remove presentation stuff from device class
Device instance is no more a pointer
Remove desc member in device structs
Diffstat (limited to 'api-test/command-buffer.cpp')
| -rw-r--r-- | api-test/command-buffer.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/api-test/command-buffer.cpp b/api-test/command-buffer.cpp index 78b1505..79b8aef 100644 --- a/api-test/command-buffer.cpp +++ b/api-test/command-buffer.cpp @@ -18,7 +18,7 @@ void command_buffer::start() const { VKCHECK(vkBeginCommandBuffer(vk_command_buffer, &begin_info)); - const auto& bindless = vkdevice::get_render_device()->get_bindingmodel(); + const auto& bindless = vkdevice::get_render_device().get_bindingmodel(); const auto* global_set = &bindless.sets[BindlessSetType::GLOBAL]; if (queue_type == QueueType::GRAPHICS) { vkCmdBindDescriptorSets(vk_command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bindless.layout, 0, 1U, global_set, 0U, nullptr); @@ -33,13 +33,10 @@ void command_buffer::stop() const { } void command_buffer::barrier(handle<device_texture> texture_handle, VkPipelineStageFlags2 stage, VkAccessFlags2 access, VkImageLayout layout) const { - auto& texture = vkdevice::get_render_device()->get_texture(texture_handle); - VkImageAspectFlags aspect_mask = ((texture.desc.usages & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0U) - ? VK_IMAGE_ASPECT_DEPTH_BIT - : VK_IMAGE_ASPECT_COLOR_BIT; + auto& texture = vkdevice::get_render_device().get_texture(texture_handle); VkImageSubresourceRange subresource_range{ - .aspectMask = aspect_mask, + .aspectMask = texture.aspects, .baseMipLevel = 0U, .levelCount = 1U, .baseArrayLayer = 0U, @@ -80,14 +77,12 @@ void command_buffer::barrier(handle<device_texture> texture_handle, VkPipelineSt } void command_buffer::copy(handle<device_buffer> buffer_handle, ::handle<device_texture> texture_handle, VkDeviceSize offset) const { - auto* device = vkdevice::get_render_device(); - const auto& buffer = device->get_buffer(buffer_handle); - const auto& texture = device->get_texture(texture_handle); - VkImageAspectFlags aspect_mask = ((texture.desc.usages & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0U) - ? VK_IMAGE_ASPECT_DEPTH_BIT - : VK_IMAGE_ASPECT_COLOR_BIT; + auto& device = vkdevice::get_render_device(); + const auto& buffer = device.get_buffer(buffer_handle); + const auto& texture = device.get_texture(texture_handle); + VkImageSubresourceLayers image_subresource_layers{ - .aspectMask = aspect_mask, + .aspectMask = texture.aspects, .mipLevel = 0, .baseArrayLayer = 0, .layerCount = 1, @@ -100,9 +95,9 @@ void command_buffer::copy(handle<device_buffer> buffer_handle, ::handle<device_t .imageSubresource = image_subresource_layers, .imageOffset = { .x = 0, .y = 0, .z = 0 }, .imageExtent = { - .width = texture.desc.width, - .height = texture.desc.height, - .depth = texture.desc.depth, + .width = texture.width, + .height = texture.height, + .depth = texture.depth, }, }; @@ -110,8 +105,8 @@ void command_buffer::copy(handle<device_buffer> buffer_handle, ::handle<device_t } void graphics_command_buffer::dispatch(const dispatch_params& params) const { - const auto& pipeline = vkdevice::get_render_device()->get_pipeline(params.pipeline); - const auto& bindless = vkdevice::get_render_device()->get_bindingmodel(); + const auto& pipeline = vkdevice::get_render_device().get_pipeline(params.pipeline); + const auto& bindless = vkdevice::get_render_device().get_bindingmodel(); vkCmdBindDescriptorSets(vk_command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, bindless.layout, static_cast<uint32_t>(BindlessSetType::INSTANCES_UNIFORMS), 1U, &bindless.sets[BindlessSetType::INSTANCES_UNIFORMS], 1U, ¶ms.uniforms_offset); vkCmdBindDescriptorSets(vk_command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, bindless.layout, static_cast<uint32_t>(BindlessSetType::DRAWS_UNIFORMS), 1U, &bindless.sets[BindlessSetType::DRAWS_UNIFORMS], 1U, ¶ms.uniforms_offset); @@ -125,7 +120,7 @@ void graphics_command_buffer::begin_renderpass(const renderpass_params& params) for (auto index{ 0U }; index < params.color_attachments.size(); index++) { auto& attachment_info = attachments_info[index]; - auto& attachment = vkdevice::get_render_device()->get_texture(params.color_attachments[index]); + auto& attachment = vkdevice::get_render_device().get_texture(params.color_attachments[index]); attachment_info.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO; attachment_info.pNext = nullptr; @@ -180,16 +175,16 @@ void graphics_command_buffer::begin_renderpass(const renderpass_params& params) } void graphics_command_buffer::render(const draw_params& params) const { - auto* device = vkdevice::get_render_device(); - const auto& pipeline = device->get_pipeline(params.pipeline); + auto& device = vkdevice::get_render_device(); + const auto& pipeline = device.get_pipeline(params.pipeline); - const auto& bindless = device->get_bindingmodel(); + const auto& bindless = device.get_bindingmodel(); vkCmdBindDescriptorSets(vk_command_buffer, pipeline.bind_point, bindless.layout, static_cast<uint32_t>(BindlessSetType::DRAWS_UNIFORMS), 1U, &bindless.sets[BindlessSetType::DRAWS_UNIFORMS], 1U, ¶ms.uniforms_offset); vkCmdBindPipeline(vk_command_buffer, pipeline.bind_point, pipeline.vk_pipeline); if (params.index_buffer.is_valid()) { - const auto& index_buffer = device->get_buffer(params.index_buffer); + const auto& index_buffer = device.get_buffer(params.index_buffer); vkCmdBindIndexBuffer(vk_command_buffer, index_buffer.vk_buffer, 0U, VK_INDEX_TYPE_UINT16); vkCmdDrawIndexed(vk_command_buffer, params.vertex_count, params.instance_count, params.index_offset, static_cast<int32_t>(params.vertex_offset), 0U); } else { |
