summaryrefslogtreecommitdiffstats
path: root/drivers/d3d12/rendering_device_driver_d3d12.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/d3d12/rendering_device_driver_d3d12.h')
-rw-r--r--drivers/d3d12/rendering_device_driver_d3d12.h41
1 files changed, 29 insertions, 12 deletions
diff --git a/drivers/d3d12/rendering_device_driver_d3d12.h b/drivers/d3d12/rendering_device_driver_d3d12.h
index 06d5cb65c4..852cb9db0e 100644
--- a/drivers/d3d12/rendering_device_driver_d3d12.h
+++ b/drivers/d3d12/rendering_device_driver_d3d12.h
@@ -33,6 +33,7 @@
#include "core/templates/hash_map.h"
#include "core/templates/paged_allocator.h"
+#include "core/templates/self_list.h"
#include "servers/rendering/rendering_device_driver.h"
#if defined(__GNUC__) && !defined(__clang__)
@@ -215,17 +216,21 @@ private:
struct States {
// As many subresources as mipmaps * layers; planes (for depth-stencil) are tracked together.
TightLocalVector<D3D12_RESOURCE_STATES> subresource_states; // Used only if not a view.
- uint32_t last_batch_transitioned_to_uav = 0;
uint32_t last_batch_with_uav_barrier = 0;
+ struct CrossFamillyFallback {
+ TightLocalVector<uint64_t> subresources_dirty;
+ ComPtr<ID3D12Resource> interim_buffer;
+ ComPtr<D3D12MA::Allocation> interim_buffer_alloc;
+ } xfamily_fallback; // [[CROSS_FAMILY_FALLBACK]].
};
- ID3D12Resource *resource = nullptr; // Non-null even if a view.
+ ID3D12Resource *resource = nullptr; // Non-null even if not owned.
struct {
ComPtr<ID3D12Resource> resource;
ComPtr<D3D12MA::Allocation> allocation;
States states;
- } owner_info; // All empty if a view.
- States *states_ptr = nullptr; // Own or from another if a view.
+ } owner_info; // All empty if the resource is not owned.
+ States *states_ptr = nullptr; // Own or from another if it doesn't own the D3D12 resource.
};
struct BarrierRequest {
@@ -257,7 +262,7 @@ private:
uint64_t frame_barriers_cpu_time = 0;
#endif
- void _resource_transition_batch(ResourceInfo *p_resource, uint32_t p_subresource, uint32_t p_num_planes, D3D12_RESOURCE_STATES p_new_state, ID3D12Resource *p_resource_override = nullptr);
+ void _resource_transition_batch(ResourceInfo *p_resource, uint32_t p_subresource, uint32_t p_num_planes, D3D12_RESOURCE_STATES p_new_state);
void _resource_transitions_flush(ID3D12GraphicsCommandList *p_cmd_list);
/*****************/
@@ -298,16 +303,12 @@ private:
D3D12_UNORDERED_ACCESS_VIEW_DESC uav;
} view_descs = {};
- ID3D12Resource *main_texture = nullptr;
- struct {
- D3D12_UNORDERED_ACCESS_VIEW_DESC main_uav_desc;
- struct {
- HashMap<DXGI_FORMAT, ComPtr<ID3D12Resource>> aliases; // Key is the DXGI format family.
- } owner_info = {};
- } aliasing_hack = {}; // [[CROSS_FAMILY_ALIASING]]
+ TextureInfo *main_texture = nullptr;
UINT mapped_subresource = UINT_MAX;
+ SelfList<TextureInfo> pending_clear{ this };
};
+ SelfList<TextureInfo>::List textures_pending_clear;
HashMap<DXGI_FORMAT, uint32_t> format_sample_counts_mask_cache;
@@ -331,6 +332,10 @@ public:
virtual void texture_unmap(TextureID p_texture) override final;
virtual BitField<TextureUsageBits> texture_get_usages_supported_by_format(DataFormat p_format, bool p_cpu_readable) override final;
+private:
+ TextureID _texture_create_shared_from_slice(TextureID p_original_texture, const TextureView &p_view, TextureSliceType p_slice_type, uint32_t p_layer, uint32_t p_layers, uint32_t p_mipmap, uint32_t p_mipmaps);
+
+public:
/*****************/
/**** SAMPLER ****/
/*****************/
@@ -459,6 +464,16 @@ private:
RenderPassState render_pass_state;
bool descriptor_heaps_set = false;
+
+ // [[CROSS_FAMILY_FALLBACK]].
+ struct FamilyFallbackCopy {
+ TextureInfo *texture = nullptr;
+ uint32_t subresource = 0;
+ uint32_t mipmap = 0;
+ D3D12_RESOURCE_STATES dst_wanted_state = {};
+ };
+ LocalVector<FamilyFallbackCopy> family_fallback_copies;
+ uint32_t family_fallback_copy_count = 0;
};
public:
@@ -513,6 +528,7 @@ private:
};
D3D12_RENDER_TARGET_VIEW_DESC _make_rtv_for_texture(const TextureInfo *p_texture_info, uint32_t p_mipmap_offset, uint32_t p_layer_offset, uint32_t p_layers, bool p_add_bases = true);
+ D3D12_UNORDERED_ACCESS_VIEW_DESC _make_ranged_uav_for_texture(const TextureInfo *p_texture_info, uint32_t p_mipmap_offset, uint32_t p_layer_offset, uint32_t p_layers, bool p_add_bases = true);
D3D12_DEPTH_STENCIL_VIEW_DESC _make_dsv_for_texture(const TextureInfo *p_texture_info);
FramebufferID _framebuffer_create(RenderPassID p_render_pass, VectorView<TextureID> p_attachments, uint32_t p_width, uint32_t p_height, bool p_is_screen);
@@ -758,6 +774,7 @@ public:
virtual void command_resolve_texture(CommandBufferID p_cmd_buffer, TextureID p_src_texture, TextureLayout p_src_texture_layout, uint32_t p_src_layer, uint32_t p_src_mipmap, TextureID p_dst_texture, TextureLayout p_dst_texture_layout, uint32_t p_dst_layer, uint32_t p_dst_mipmap) override final;
virtual void command_clear_color_texture(CommandBufferID p_cmd_buffer, TextureID p_texture, TextureLayout p_texture_layout, const Color &p_color, const TextureSubresourceRange &p_subresources) override final;
+public:
virtual void command_copy_buffer_to_texture(CommandBufferID p_cmd_buffer, BufferID p_src_buffer, TextureID p_dst_texture, TextureLayout p_dst_texture_layout, VectorView<BufferTextureCopyRegion> p_regions) override final;
virtual void command_copy_texture_to_buffer(CommandBufferID p_cmd_buffer, TextureID p_src_texture, TextureLayout p_src_texture_layout, BufferID p_dst_buffer, VectorView<BufferTextureCopyRegion> p_regions) override final;