return (struct d3d12_bufmgr *)mgr;
}
-static struct TransitionableResourceState *
-create_trans_state(ID3D12Resource *res)
-{
- D3D12_RESOURCE_DESC desc = GetDesc(res);
-
- // Calculate the total number of subresources
- unsigned arraySize = desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ?
- 1 : desc.DepthOrArraySize;
- unsigned total_subresources = desc.MipLevels *
- arraySize *
- d3d12_non_opaque_plane_count(desc.Format);
-
- return new TransitionableResourceState(res,
- total_subresources,
- d3d12_resource_supports_simultaneous_access(&desc));
-}
-
static void
describe_direct_bo(char *buf, struct d3d12_bo *ptr)
{
if (!bo)
return NULL;
+ D3D12_RESOURCE_DESC desc = GetDesc(res);
+ unsigned array_size = desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? 1 : desc.DepthOrArraySize;
+ unsigned total_subresources = desc.MipLevels * array_size * d3d12_non_opaque_plane_count(desc.Format);
+ bool supports_simultaneous_access = d3d12_resource_supports_simultaneous_access(&desc);
+
pipe_reference_init(&bo->reference, 1);
bo->screen = screen;
bo->res = res;
- bo->trans_state = create_trans_state(res);
+ bo->trans_state = new TransitionableResourceState(res, total_subresources, supports_simultaneous_access);
bo->unique_id = p_atomic_inc_return(&screen->resource_id_generator);
+ if (!supports_simultaneous_access)
+ d3d12_resource_state_init(&bo->global_state, total_subresources, false);
bo->residency_status = residency;
bo->last_used_timestamp = 0;
- D3D12_RESOURCE_DESC desc = GetDesc(res);
screen->dev->GetCopyableFootprints(&desc, 0, bo->trans_state->NumSubresources(), 0, nullptr, nullptr, nullptr, &bo->estimated_size);
if (residency != d3d12_evicted) {
mtx_lock(&screen->submit_mutex);
mtx_unlock(&bo->screen->submit_mutex);
+ d3d12_resource_state_cleanup(&bo->global_state);
if (bo->trans_state)
delete bo->trans_state;
if (bo->res)
#include "util/list.h"
#include "d3d12_common.h"
+#include "d3d12_resource_state.h"
struct d3d12_bufmgr;
struct d3d12_screen;
ID3D12Resource *res;
struct pb_buffer *buffer;
struct TransitionableResourceState *trans_state;
+ struct d3d12_resource_state global_state;
/* Used as a key in per-context resource state maps,
* to avoid needing to lock them for single-threaded lookups to
d3d12_bo *bo = (d3d12_bo *)bo_entry->key;
d3d12_context_state_table_entry *bo_state = find_or_create_state_entry(ctx->bo_state_table, bo);
if (!bo_state->batch_end.supports_simultaneous_access) {
+ assert(bo->res && bo->global_state.subresource_states);
d3d12_resource_state_copy(&bo_state->batch_begin, &bo_state->batch_end);
+ d3d12_resource_state_copy(&bo->global_state, &bo_state->batch_end);
} else {
d3d12_reset_resource_state(&bo_state->batch_end);
}