d3d12: Move d3d12_context_state_table_entry to d3d12_resource_state.h

Also renamed desired_resource_state to d3d12_desired_resource_state,
since it's also in the header now.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21528>
This commit is contained in:
Giancarlo Devich 2023-02-24 16:17:43 -08:00 committed by Marge Bot
parent 4c711460d4
commit bd0e1b3d02
2 changed files with 22 additions and 21 deletions

View file

@ -34,16 +34,8 @@
#define UNKNOWN_RESOURCE_STATE (D3D12_RESOURCE_STATES) 0x8000u #define UNKNOWN_RESOURCE_STATE (D3D12_RESOURCE_STATES) 0x8000u
/* Stores the current desired state of either an entire resource, or each subresource. */
struct desired_resource_state
{
bool homogenous;
uint32_t num_subresources;
D3D12_RESOURCE_STATES *subresource_states;
};
static bool static bool
desired_resource_state_init(desired_resource_state *state, uint32_t subresource_count) desired_resource_state_init(d3d12_desired_resource_state *state, uint32_t subresource_count)
{ {
state->homogenous = true; state->homogenous = true;
state->num_subresources = subresource_count; state->num_subresources = subresource_count;
@ -52,13 +44,13 @@ desired_resource_state_init(desired_resource_state *state, uint32_t subresource_
} }
static void static void
desired_resource_state_cleanup(desired_resource_state *state) desired_resource_state_cleanup(d3d12_desired_resource_state *state)
{ {
free(state->subresource_states); free(state->subresource_states);
} }
static D3D12_RESOURCE_STATES static D3D12_RESOURCE_STATES
get_desired_subresource_state(const desired_resource_state *state, uint32_t subresource_index) get_desired_subresource_state(const d3d12_desired_resource_state *state, uint32_t subresource_index)
{ {
if (state->homogenous) if (state->homogenous)
subresource_index = 0; subresource_index = 0;
@ -78,14 +70,14 @@ update_subresource_state(D3D12_RESOURCE_STATES *existing_state, D3D12_RESOURCE_S
} }
static void static void
set_desired_resource_state(desired_resource_state *state_obj, D3D12_RESOURCE_STATES state) set_desired_resource_state(d3d12_desired_resource_state *state_obj, D3D12_RESOURCE_STATES state)
{ {
state_obj->homogenous = true; state_obj->homogenous = true;
update_subresource_state(&state_obj->subresource_states[0], state); update_subresource_state(&state_obj->subresource_states[0], state);
} }
static void static void
set_desired_subresource_state(desired_resource_state *state_obj, set_desired_subresource_state(d3d12_desired_resource_state *state_obj,
uint32_t subresource, uint32_t subresource,
D3D12_RESOURCE_STATES state) D3D12_RESOURCE_STATES state)
{ {
@ -100,7 +92,7 @@ set_desired_subresource_state(desired_resource_state *state_obj,
} }
static void static void
reset_desired_resource_state(desired_resource_state *state_obj) reset_desired_resource_state(d3d12_desired_resource_state *state_obj)
{ {
set_desired_resource_state(state_obj, UNKNOWN_RESOURCE_STATE); set_desired_resource_state(state_obj, UNKNOWN_RESOURCE_STATE);
} }
@ -195,12 +187,6 @@ copy_resource_state(d3d12_resource_state *dest, d3d12_resource_state *src)
} }
} }
struct d3d12_context_state_table_entry
{
struct desired_resource_state desired;
struct d3d12_resource_state batch_begin, batch_end;
};
static void static void
destroy_context_state_table_entry(d3d12_context_state_table_entry *entry) destroy_context_state_table_entry(d3d12_context_state_table_entry *entry)
{ {
@ -524,7 +510,7 @@ d3d12_apply_resource_states(struct d3d12_context *ctx, bool is_implicit_dispatch
d3d12_bo *bo = (d3d12_bo *)entry->key; d3d12_bo *bo = (d3d12_bo *)entry->key;
d3d12_context_state_table_entry *state_entry = find_or_create_state_entry(ctx->bo_state_table, bo); d3d12_context_state_table_entry *state_entry = find_or_create_state_entry(ctx->bo_state_table, bo);
desired_resource_state *destination_state = &state_entry->desired; d3d12_desired_resource_state *destination_state = &state_entry->desired;
d3d12_resource_state *current_state = &state_entry->batch_end; d3d12_resource_state *current_state = &state_entry->batch_end;
// Figure out the set of subresources that are transitioning // Figure out the set of subresources that are transitioning

View file

@ -68,6 +68,21 @@ struct d3d12_resource_state
d3d12_subresource_state *subresource_states; d3d12_subresource_state *subresource_states;
}; };
/* Stores the current desired state of either an entire resource, or each subresource. */
struct d3d12_desired_resource_state
{
bool homogenous;
uint32_t num_subresources;
D3D12_RESOURCE_STATES* subresource_states;
};
struct d3d12_context_state_table_entry
{
struct d3d12_desired_resource_state desired;
struct d3d12_resource_state batch_begin, batch_end;
};
bool bool
d3d12_resource_state_init(d3d12_resource_state *state, uint32_t subresource_count, bool simultaneous_access); d3d12_resource_state_init(d3d12_resource_state *state, uint32_t subresource_count, bool simultaneous_access);