From 481ea1290f0833ba7f50eb5fe3fa762dc2ce087f Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Wed, 23 Oct 2024 19:26:35 +0200 Subject: [PATCH] Use texture-views for render pass parameters --- .../Sources/kope/direct3d12/commandlist.cpp | 21 ++++++++++++------- Sources/kope/graphics5/commandlist.h | 4 ++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp index e4c221df2..b6eca4579 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp @@ -36,7 +36,7 @@ void kope_d3d12_command_list_begin_render_pass(kope_g5_command_list *list, const D3D12_CPU_DESCRIPTOR_HANDLE render_target_views = list->d3d12.rtv_descriptors->GetCPUDescriptorHandleForHeapStart(); for (size_t render_target_index = 0; render_target_index < parameters->color_attachments_count; ++render_target_index) { - kope_g5_texture *render_target = parameters->color_attachments[render_target_index].texture; + kope_g5_texture *render_target = parameters->color_attachments[render_target_index].texture.texture; if (render_target->d3d12.in_flight_frame_index > 0) { list->d3d12.blocking_frame_index = render_target->d3d12.in_flight_frame_index; @@ -65,10 +65,11 @@ void kope_d3d12_command_list_begin_render_pass(kope_g5_command_list *list, const D3D12_RENDER_TARGET_VIEW_DESC desc = {}; desc.Format = DXGI_FORMAT_UNKNOWN; - if (parameters->color_attachments[render_target_index].depth_slice != 0) { + if (parameters->color_attachments[render_target_index].texture.array_layer_count > 1 || + parameters->color_attachments[render_target_index].texture.base_array_layer != 0) { desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY; - desc.Texture2DArray.FirstArraySlice = parameters->color_attachments[render_target_index].depth_slice; - desc.Texture2DArray.ArraySize = 1; + desc.Texture2DArray.FirstArraySlice = parameters->color_attachments[render_target_index].texture.base_array_layer; + desc.Texture2DArray.ArraySize = parameters->color_attachments[render_target_index].texture.array_layer_count; } else { desc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; @@ -123,12 +124,16 @@ void kope_d3d12_command_list_begin_render_pass(kope_g5_command_list *list, const } if (parameters->color_attachments_count > 0) { - D3D12_VIEWPORT viewport = { - 0.0f, 0.0f, (FLOAT)parameters->color_attachments[0].texture->d3d12.width, (FLOAT)parameters->color_attachments[0].texture->d3d12.height, - 0.0f, 1.0f}; + D3D12_VIEWPORT viewport = {0.0f, + 0.0f, + (FLOAT)parameters->color_attachments[0].texture.texture->d3d12.width, + (FLOAT)parameters->color_attachments[0].texture.texture->d3d12.height, + 0.0f, + 1.0f}; list->d3d12.list->RSSetViewports(1, &viewport); - D3D12_RECT scissor = {0, 0, (LONG)parameters->color_attachments[0].texture->d3d12.width, (LONG)parameters->color_attachments[0].texture->d3d12.height}; + D3D12_RECT scissor = {0, 0, (LONG)parameters->color_attachments[0].texture.texture->d3d12.width, + (LONG)parameters->color_attachments[0].texture.texture->d3d12.height}; list->d3d12.list->RSSetScissorRects(1, &scissor); } else if (parameters->depth_stencil_attachment.texture != NULL) { diff --git a/Sources/kope/graphics5/commandlist.h b/Sources/kope/graphics5/commandlist.h index 1c8532005..4c9f1dee2 100644 --- a/Sources/kope/graphics5/commandlist.h +++ b/Sources/kope/graphics5/commandlist.h @@ -53,9 +53,9 @@ typedef struct kope_g5_color { } kope_g5_color; typedef struct kope_g5_render_pass_color_attachment { - kope_g5_texture *texture; + kope_g5_texture_view texture; uint32_t depth_slice; - kope_g5_texture *resolve_target; + kope_g5_texture_view resolve_target; kope_g5_color clear_value; kope_g5_load_op load_op; kope_g5_store_op store_op;