From 7a6d3f15a3175e3be8824b47248df584a9b41ff4 Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Fri, 27 Sep 2024 03:18:05 +0200 Subject: [PATCH] Introduce texture views --- .../Sources/kope/direct3d12/commandlist.cpp | 30 +++--- .../Sources/kope/direct3d12/descriptorset.cpp | 98 +++++++++++-------- .../kope/direct3d12/descriptorset_functions.h | 16 +-- .../Sources/kope/direct3d12/device.cpp | 10 +- .../Sources/kope/direct3d12/texture.cpp | 4 + .../kope/direct3d12/texture_functions.h | 2 + Sources/kope/graphics5/commandlist.h | 8 +- Sources/kope/graphics5/texture.h | 26 +++++ 8 files changed, 124 insertions(+), 70 deletions(-) diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp index 27968156f..1c46ba5ef 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/commandlist.cpp @@ -5,6 +5,8 @@ #include #include +#include + #include "pipeline_structs.h" #include @@ -226,19 +228,25 @@ void kope_d3d12_command_list_copy_buffer_to_texture(kope_g5_command_list *list, source->buffer->d3d12.resource_state = D3D12_RESOURCE_STATE_COPY_SOURCE; } - if (destination->texture->d3d12.resource_states[destination->mip_level] != D3D12_RESOURCE_STATE_COPY_DEST) { - D3D12_RESOURCE_BARRIER barrier; - barrier.Transition.pResource = destination->texture->d3d12.resource; - barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - barrier.Transition.StateBefore = (D3D12_RESOURCE_STATES)destination->texture->d3d12.resource_states[destination->mip_level]; - barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST; - barrier.Transition.Subresource = D3D12CalcSubresource(destination->mip_level, destination->origin_z, 0, destination->texture->d3d12.mip_level_count, - destination->texture->d3d12.depth_or_array_layers); + for (uint32_t array_layer = destination->origin_z; array_layer < destination->origin_z + depth_or_array_layers; ++array_layer) { + if (destination->texture->d3d12.resource_states[kope_d3d12_texture_resource_state_index(destination->texture, destination->mip_level, array_layer)] != + D3D12_RESOURCE_STATE_COPY_DEST) { + D3D12_RESOURCE_BARRIER barrier; + barrier.Transition.pResource = destination->texture->d3d12.resource; + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + barrier.Transition.StateBefore = + (D3D12_RESOURCE_STATES)destination->texture->d3d12 + .resource_states[kope_d3d12_texture_resource_state_index(destination->texture, destination->mip_level, array_layer)]; + barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST; + barrier.Transition.Subresource = D3D12CalcSubresource(destination->mip_level, destination->origin_z, 0, destination->texture->d3d12.mip_level_count, + destination->texture->d3d12.depth_or_array_layers); - list->d3d12.list->ResourceBarrier(1, &barrier); + list->d3d12.list->ResourceBarrier(1, &barrier); - destination->texture->d3d12.resource_states[destination->mip_level] = D3D12_RESOURCE_STATE_COPY_DEST; + destination->texture->d3d12.resource_states[kope_d3d12_texture_resource_state_index(destination->texture, destination->mip_level, array_layer)] = + D3D12_RESOURCE_STATE_COPY_DEST; + } } D3D12_TEXTURE_COPY_LOCATION src; diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset.cpp index 7714b6330..9d42604ee 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset.cpp @@ -1,6 +1,8 @@ #include "descriptorset_functions.h" #include "descriptorset_structs.h" +#include + #include void kope_d3d12_descriptor_set_set_buffer_view_cbv(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_buffer *buffer, uint32_t index) { @@ -40,13 +42,13 @@ void kope_d3d12_descriptor_set_set_bvh_view_srv(kope_g5_device *device, kope_d3d device->d3d12.device->CreateShaderResourceView(nullptr, &desc, descriptor_handle); } -void kope_d3d12_descriptor_set_set_texture_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_texture *texture, - uint32_t highest_mip_level, uint32_t mip_count, uint32_t index) { +void kope_d3d12_descriptor_set_set_texture_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, const kope_g5_texture_view *texture_view, + uint32_t index) { D3D12_SHADER_RESOURCE_VIEW_DESC desc = {}; desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - DXGI_FORMAT format = (DXGI_FORMAT)texture->d3d12.format; + DXGI_FORMAT format = (DXGI_FORMAT)texture_view->texture->d3d12.format; switch (format) { case DXGI_FORMAT_D16_UNORM: desc.Format = DXGI_FORMAT_R16_UNORM; @@ -59,21 +61,22 @@ void kope_d3d12_descriptor_set_set_texture_view_srv(kope_g5_device *device, kope break; } - desc.Texture2D.MipLevels = mip_count; - desc.Texture2D.MostDetailedMip = highest_mip_level; + desc.Texture2D.MipLevels = texture_view->mip_level_count; + desc.Texture2D.MostDetailedMip = texture_view->base_mip_level; desc.Texture2D.ResourceMinLODClamp = 0.0f; D3D12_CPU_DESCRIPTOR_HANDLE descriptor_handle = device->d3d12.descriptor_heap->GetCPUDescriptorHandleForHeapStart(); descriptor_handle.ptr += (set->descriptor_allocation.offset + index) * device->d3d12.cbv_srv_uav_increment; - device->d3d12.device->CreateShaderResourceView(texture->d3d12.resource, &desc, descriptor_handle); + device->d3d12.device->CreateShaderResourceView(texture_view->texture->d3d12.resource, &desc, descriptor_handle); } -void kope_d3d12_descriptor_set_set_texture_array_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_texture *texture, uint32_t index) { +void kope_d3d12_descriptor_set_set_texture_array_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, const kope_g5_texture_view *texture_view, + uint32_t index) { D3D12_SHADER_RESOURCE_VIEW_DESC desc = {}; desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - DXGI_FORMAT format = (DXGI_FORMAT)texture->d3d12.format; + DXGI_FORMAT format = (DXGI_FORMAT)texture_view->texture->d3d12.format; switch (format) { case DXGI_FORMAT_D16_UNORM: desc.Format = DXGI_FORMAT_R16_UNORM; @@ -83,23 +86,24 @@ void kope_d3d12_descriptor_set_set_texture_array_view_srv(kope_g5_device *device break; } - desc.Texture2DArray.MipLevels = 1; - desc.Texture2DArray.MostDetailedMip = 0; + desc.Texture2DArray.MipLevels = texture_view->mip_level_count; + desc.Texture2DArray.MostDetailedMip = texture_view->base_mip_level; desc.Texture2DArray.ResourceMinLODClamp = 0.0f; - desc.Texture2DArray.FirstArraySlice = 0; - desc.Texture2DArray.ArraySize = 2; + desc.Texture2DArray.FirstArraySlice = texture_view->base_array_layer; + desc.Texture2DArray.ArraySize = texture_view->array_layer_count; D3D12_CPU_DESCRIPTOR_HANDLE descriptor_handle = device->d3d12.descriptor_heap->GetCPUDescriptorHandleForHeapStart(); descriptor_handle.ptr += (set->descriptor_allocation.offset + index) * device->d3d12.cbv_srv_uav_increment; - device->d3d12.device->CreateShaderResourceView(texture->d3d12.resource, &desc, descriptor_handle); + device->d3d12.device->CreateShaderResourceView(texture_view->texture->d3d12.resource, &desc, descriptor_handle); } -void kope_d3d12_descriptor_set_set_texture_cube_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_texture *texture, uint32_t index) { +void kope_d3d12_descriptor_set_set_texture_cube_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, const kope_g5_texture_view *texture_view, + uint32_t index) { D3D12_SHADER_RESOURCE_VIEW_DESC desc = {}; desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE; desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - DXGI_FORMAT format = (DXGI_FORMAT)texture->d3d12.format; + DXGI_FORMAT format = (DXGI_FORMAT)texture_view->texture->d3d12.format; switch (format) { case DXGI_FORMAT_D16_UNORM: desc.Format = DXGI_FORMAT_R16_UNORM; @@ -109,26 +113,26 @@ void kope_d3d12_descriptor_set_set_texture_cube_view_srv(kope_g5_device *device, break; } - desc.TextureCube.MipLevels = 1; - desc.TextureCube.MostDetailedMip = 0; + desc.TextureCube.MipLevels = texture_view->mip_level_count; + desc.TextureCube.MostDetailedMip = texture_view->base_mip_level; desc.TextureCube.ResourceMinLODClamp = 0.0f; D3D12_CPU_DESCRIPTOR_HANDLE descriptor_handle = device->d3d12.descriptor_heap->GetCPUDescriptorHandleForHeapStart(); descriptor_handle.ptr += (set->descriptor_allocation.offset + index) * device->d3d12.cbv_srv_uav_increment; - device->d3d12.device->CreateShaderResourceView(texture->d3d12.resource, &desc, descriptor_handle); + device->d3d12.device->CreateShaderResourceView(texture_view->texture->d3d12.resource, &desc, descriptor_handle); } -void kope_d3d12_descriptor_set_set_texture_view_uav(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_texture *texture, uint32_t mip_level, +void kope_d3d12_descriptor_set_set_texture_view_uav(kope_g5_device *device, kope_d3d12_descriptor_set *set, const kope_g5_texture_view *texture_view, uint32_t index) { D3D12_UNORDERED_ACCESS_VIEW_DESC desc = {}; desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; - desc.Format = (DXGI_FORMAT)texture->d3d12.format; - desc.Texture2D.MipSlice = mip_level; + desc.Format = (DXGI_FORMAT)texture_view->texture->d3d12.format; + desc.Texture2D.MipSlice = texture_view->base_mip_level; desc.Texture2D.PlaneSlice = 0; D3D12_CPU_DESCRIPTOR_HANDLE descriptor_handle = device->d3d12.descriptor_heap->GetCPUDescriptorHandleForHeapStart(); descriptor_handle.ptr += (set->descriptor_allocation.offset + index) * device->d3d12.cbv_srv_uav_increment; - device->d3d12.device->CreateUnorderedAccessView(texture->d3d12.resource, NULL, &desc, descriptor_handle); + device->d3d12.device->CreateUnorderedAccessView(texture_view->texture->d3d12.resource, NULL, &desc, descriptor_handle); } void kope_d3d12_descriptor_set_set_sampler(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_sampler *sampler, uint32_t index) { @@ -157,36 +161,46 @@ void kope_d3d12_descriptor_set_prepare_cbv_buffer(kope_g5_command_list *list, ko } } -void kope_d3d12_descriptor_set_prepare_srv_texture(kope_g5_command_list *list, kope_g5_texture *texture, uint32_t highest_mip_level, uint32_t mip_count) { - for (uint32_t mip_level = highest_mip_level; mip_level < highest_mip_level + mip_count; ++mip_level) { - if (texture->d3d12.resource_states[mip_level] != (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE)) { - D3D12_RESOURCE_BARRIER barrier; - barrier.Transition.pResource = texture->d3d12.resource; - barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - barrier.Transition.StateBefore = (D3D12_RESOURCE_STATES)texture->d3d12.resource_states[mip_level]; - barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; - barrier.Transition.Subresource = D3D12CalcSubresource(mip_level, 0, 0, texture->d3d12.mip_level_count, texture->d3d12.depth_or_array_layers); - - list->d3d12.list->ResourceBarrier(1, &barrier); - - texture->d3d12.resource_states[mip_level] = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; +void kope_d3d12_descriptor_set_prepare_srv_texture(kope_g5_command_list *list, const kope_g5_texture_view *texture_view) { + for (uint32_t array_layer = texture_view->base_array_layer; array_layer < texture_view->base_array_layer + texture_view->array_layer_count; ++array_layer) { + for (uint32_t mip_level = texture_view->base_mip_level; mip_level < texture_view->base_mip_level + texture_view->mip_level_count; ++mip_level) { + if (texture_view->texture->d3d12.resource_states[mip_level] != + (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE)) { + D3D12_RESOURCE_BARRIER barrier; + barrier.Transition.pResource = texture_view->texture->d3d12.resource; + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + barrier.Transition.StateBefore = + (D3D12_RESOURCE_STATES) + texture_view->texture->d3d12.resource_states[kope_d3d12_texture_resource_state_index(texture_view->texture, mip_level, array_layer)]; + barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; + barrier.Transition.Subresource = + D3D12CalcSubresource(mip_level, 0, 0, texture_view->texture->d3d12.mip_level_count, texture_view->texture->d3d12.depth_or_array_layers); + + list->d3d12.list->ResourceBarrier(1, &barrier); + + texture_view->texture->d3d12.resource_states[mip_level] = + D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; + } } } } -void kope_d3d12_descriptor_set_prepare_uav_texture(kope_g5_command_list *list, kope_g5_texture *texture, uint32_t mip_level) { - if (texture->d3d12.resource_states[mip_level] != D3D12_RESOURCE_STATE_UNORDERED_ACCESS) { +void kope_d3d12_descriptor_set_prepare_uav_texture(kope_g5_command_list *list, const kope_g5_texture_view *texture_view) { + if (texture_view->texture->d3d12.resource_states[texture_view->base_mip_level] != D3D12_RESOURCE_STATE_UNORDERED_ACCESS) { D3D12_RESOURCE_BARRIER barrier; - barrier.Transition.pResource = texture->d3d12.resource; + barrier.Transition.pResource = texture_view->texture->d3d12.resource; barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - barrier.Transition.StateBefore = (D3D12_RESOURCE_STATES)texture->d3d12.resource_states[mip_level]; + barrier.Transition.StateBefore = + (D3D12_RESOURCE_STATES) + texture_view->texture->d3d12.resource_states[kope_d3d12_texture_resource_state_index(texture_view->texture, texture_view->base_mip_level, 0)]; barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; - barrier.Transition.Subresource = D3D12CalcSubresource(mip_level, 0, 0, texture->d3d12.mip_level_count, texture->d3d12.depth_or_array_layers); + barrier.Transition.Subresource = D3D12CalcSubresource(texture_view->base_mip_level, 0, 0, texture_view->texture->d3d12.mip_level_count, + texture_view->texture->d3d12.depth_or_array_layers); list->d3d12.list->ResourceBarrier(1, &barrier); - texture->d3d12.resource_states[mip_level] = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; + texture_view->texture->d3d12.resource_states[texture_view->base_mip_level] = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; } } diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_functions.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_functions.h index 9e7f7c530..c322c511c 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_functions.h +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/descriptorset_functions.h @@ -14,17 +14,19 @@ extern "C" { void kope_d3d12_descriptor_set_set_buffer_view_cbv(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_buffer *buffer, uint32_t index); void kope_d3d12_descriptor_set_set_buffer_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_buffer *buffer, uint32_t index); void kope_d3d12_descriptor_set_set_bvh_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_raytracing_hierarchy *bvh, uint32_t index); -void kope_d3d12_descriptor_set_set_texture_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_texture *texture, - uint32_t highest_mip_level, uint32_t mip_count, uint32_t index); -void kope_d3d12_descriptor_set_set_texture_array_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_texture *texture, uint32_t index); -void kope_d3d12_descriptor_set_set_texture_cube_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_texture *texture, uint32_t index); -void kope_d3d12_descriptor_set_set_texture_view_uav(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_texture *texture, uint32_t mip_level, +void kope_d3d12_descriptor_set_set_texture_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, const kope_g5_texture_view *texture_view, + uint32_t index); +void kope_d3d12_descriptor_set_set_texture_array_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, const kope_g5_texture_view *texture_view, + uint32_t index); +void kope_d3d12_descriptor_set_set_texture_cube_view_srv(kope_g5_device *device, kope_d3d12_descriptor_set *set, const kope_g5_texture_view *texture_view, + uint32_t index); +void kope_d3d12_descriptor_set_set_texture_view_uav(kope_g5_device *device, kope_d3d12_descriptor_set *set, const kope_g5_texture_view *texture_view, uint32_t index); void kope_d3d12_descriptor_set_set_sampler(kope_g5_device *device, kope_d3d12_descriptor_set *set, kope_g5_sampler *sampler, uint32_t index); void kope_d3d12_descriptor_set_prepare_cbv_buffer(kope_g5_command_list *list, kope_g5_buffer *buffer); -void kope_d3d12_descriptor_set_prepare_srv_texture(kope_g5_command_list *list, kope_g5_texture *texture, uint32_t highest_mip_level, uint32_t mip_count); -void kope_d3d12_descriptor_set_prepare_uav_texture(kope_g5_command_list *list, kope_g5_texture *texture, uint32_t mip_level); +void kope_d3d12_descriptor_set_prepare_srv_texture(kope_g5_command_list *list, const kope_g5_texture_view *texture_view); +void kope_d3d12_descriptor_set_prepare_uav_texture(kope_g5_command_list *list, const kope_g5_texture_view *texture_view); #ifdef __cplusplus } diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp index f7bbb1f91..2bd49c363 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp @@ -480,9 +480,6 @@ void kope_d3d12_device_create_texture(kope_g5_device *device, const kope_g5_text D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, optimizedClearValuePointer, IID_GRAPHICS_PPV_ARGS(&texture->d3d12.resource))); - for (size_t mip_level = 0; mip_level < parameters->mip_level_count; ++mip_level) { - texture->d3d12.resource_states[mip_level] = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - } texture->d3d12.format = format; texture->d3d12.width = parameters->width; @@ -491,6 +488,13 @@ void kope_d3d12_device_create_texture(kope_g5_device *device, const kope_g5_text texture->d3d12.mip_level_count = parameters->mip_level_count; texture->d3d12.in_flight_frame_index = 0; + + for (uint32_t array_layer = 0; array_layer < parameters->depth_or_array_layers; ++array_layer) { + for (uint32_t mip_level = 0; mip_level < parameters->mip_level_count; ++mip_level) { + texture->d3d12.resource_states[kope_d3d12_texture_resource_state_index(texture, mip_level, array_layer)] = + D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + } + } } kope_g5_texture *kope_d3d12_device_get_framebuffer(kope_g5_device *device) { diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/texture.cpp b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/texture.cpp index afc368e54..32de0a3a9 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/texture.cpp +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/texture.cpp @@ -3,3 +3,7 @@ #include "d3d12unit.h" #include + +uint32_t kope_d3d12_texture_resource_state_index(kope_g5_texture *texture, uint32_t mip_level, uint32_t array_layer) { + return mip_level + (array_layer * texture->d3d12.mip_level_count); +} diff --git a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/texture_functions.h b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/texture_functions.h index ee9b9a0d0..ce7035356 100644 --- a/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/texture_functions.h +++ b/Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/texture_functions.h @@ -7,6 +7,8 @@ extern "C" { #endif +uint32_t kope_d3d12_texture_resource_state_index(kope_g5_texture *texture, uint32_t mip_level, uint32_t array_layer); + #ifdef __cplusplus } #endif diff --git a/Sources/kope/graphics5/commandlist.h b/Sources/kope/graphics5/commandlist.h index 4872de786..5a6b539f9 100644 --- a/Sources/kope/graphics5/commandlist.h +++ b/Sources/kope/graphics5/commandlist.h @@ -81,14 +81,8 @@ typedef struct kope_g5_render_pass_parameters { KOPE_FUNC void kope_g5_command_list_begin_render_pass(kope_g5_command_list *list, const kope_g5_render_pass_parameters *parameters); -typedef enum kope_g5_image_copy_aspect { - KOPE_G5_IMAGE_COPY_ASPECT_ALL, - KOPE_G5_IMAGE_COPY_ASPECT_DEPTH_ONLY, - KOPE_G5_IMAGE_COPY_ASPECT_STENCIL_ONLY -} kope_g5_image_copy_aspect; - typedef struct kope_g5_image_copy_texture { - kope_g5_image_copy_aspect aspect; + kope_g5_texture_aspect aspect; uint32_t mip_level; uint32_t origin_x; uint32_t origin_y; diff --git a/Sources/kope/graphics5/texture.h b/Sources/kope/graphics5/texture.h index 0235d8a0f..705765562 100644 --- a/Sources/kope/graphics5/texture.h +++ b/Sources/kope/graphics5/texture.h @@ -25,6 +25,32 @@ typedef struct kope_g5_texture { KOPE_G5_IMPL(texture); } kope_g5_texture; +typedef enum kope_g5_texture_view_dimension { + KOPE_G5_TEXTURE_VIEW_DIMENSION_1D, + KOPE_G5_TEXTURE_VIEW_DIMENSION_2D, + KOPE_G5_TEXTURE_VIEW_DIMENSION_2DARRAY, + KOPE_G5_TEXTURE_VIEW_DIMENSION_CUBE, + KOPE_G5_TEXTURE_VIEW_DIMENSION_CUBEARRAY, + KOPE_G5_TEXTURE_VIEW_DIMENSION_3D +} kope_g5_texture_view_dimension; + +typedef enum kope_g5_texture_aspect { + KOPE_G5_IMAGE_COPY_ASPECT_ALL, + KOPE_G5_IMAGE_COPY_ASPECT_DEPTH_ONLY, + KOPE_G5_IMAGE_COPY_ASPECT_STENCIL_ONLY +} kope_g5_texture_aspect; + +typedef struct kope_g5_texture_view { + kope_g5_texture *texture; + kope_g5_texture_format format; + kope_g5_texture_view_dimension dimension; + kope_g5_texture_aspect aspect; + uint32_t base_mip_level; + uint32_t mip_level_count; + uint32_t base_array_layer; + uint32_t array_layer_count; +} kope_g5_texture_view; + #ifdef __cplusplus } #endif