Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Erik Faye-Lund
mesa
Commits
acae5af1
Commit
acae5af1
authored
Sep 15, 2020
by
Erik Faye-Lund
Browse files
d3d12: drop needless pre-draw dance
parent
a05052a9
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/gallium/drivers/d3d12/d3d12_blit.cpp
View file @
acae5af1
...
...
@@ -115,13 +115,11 @@ blit_resolve(struct d3d12_context *ctx, const struct pipe_blit_info *info)
struct
d3d12_resource
*
dst
=
d3d12_resource
(
info
->
dst
.
resource
);
d3d12_transition_resource_state
(
ctx
,
src
,
D3D12_RESOURCE_STATE_RESOLVE_SOURCE
,
SubresourceTransitionFlags_None
);
D3D12_RESOURCE_STATE_RESOLVE_SOURCE
);
d3d12_transition_resource_state
(
ctx
,
dst
,
D3D12_RESOURCE_STATE_RESOLVE_DEST
,
SubresourceTransitionFlags_None
);
D3D12_RESOURCE_STATE_RESOLVE_DEST
);
d3d12_apply_resource_states
(
ctx
,
false
);
d3d12_apply_resource_states
(
ctx
);
d3d12_batch_reference_resource
(
batch
,
src
);
d3d12_batch_reference_resource
(
batch
,
dst
);
...
...
@@ -423,15 +421,13 @@ d3d12_direct_copy(struct d3d12_context *ctx,
d3d12_transition_subresources_state
(
ctx
,
src
,
src_subres
,
1
,
0
,
1
,
0
,
d3d12_get_format_num_planes
(
src
->
base
.
format
),
D3D12_RESOURCE_STATE_COPY_SOURCE
,
SubresourceTransitionFlags_None
);
D3D12_RESOURCE_STATE_COPY_SOURCE
);
d3d12_transition_subresources_state
(
ctx
,
dst
,
dst_subres
,
1
,
0
,
1
,
0
,
d3d12_get_format_num_planes
(
dst
->
base
.
format
),
D3D12_RESOURCE_STATE_COPY_DEST
,
SubresourceTransitionFlags_None
);
D3D12_RESOURCE_STATE_COPY_DEST
);
d3d12_apply_resource_states
(
ctx
,
false
);
d3d12_apply_resource_states
(
ctx
);
d3d12_batch_reference_resource
(
batch
,
src
);
d3d12_batch_reference_resource
(
batch
,
dst
);
...
...
@@ -780,13 +776,11 @@ blit_resolve_stencil(struct d3d12_context *ctx,
struct
d3d12_resource
*
dst
=
d3d12_resource
(
info
->
dst
.
resource
);
d3d12_transition_subresources_state
(
ctx
,
d3d12_resource
(
tmp
),
0
,
1
,
0
,
1
,
0
,
1
,
D3D12_RESOURCE_STATE_COPY_SOURCE
,
SubresourceTransitionFlags_None
);
D3D12_RESOURCE_STATE_COPY_SOURCE
);
d3d12_transition_subresources_state
(
ctx
,
dst
,
0
,
1
,
0
,
1
,
1
,
1
,
D3D12_RESOURCE_STATE_COPY_DEST
,
SubresourceTransitionFlags_None
);
d3d12_apply_resource_states
(
ctx
,
false
);
D3D12_RESOURCE_STATE_COPY_DEST
);
d3d12_apply_resource_states
(
ctx
);
struct
d3d12_batch
*
batch
=
d3d12_current_batch
(
ctx
);
d3d12_batch_reference_resource
(
batch
,
d3d12_resource
(
tmp
));
...
...
src/gallium/drivers/d3d12/d3d12_context.cpp
View file @
acae5af1
...
...
@@ -1512,11 +1512,10 @@ d3d12_flush_cmdlist_and_wait(struct d3d12_context *ctx)
void
d3d12_transition_resource_state
(
struct
d3d12_context
*
ctx
,
struct
d3d12_resource
*
res
,
D3D12_RESOURCE_STATES
state
,
SubresourceTransitionFlags
flags
)
D3D12_RESOURCE_STATES
state
)
{
TransitionableResourceState
*
xres
=
d3d12_resource_state
(
res
);
ctx
->
resource_state_manager
->
TransitionResource
(
xres
,
state
,
flags
);
ctx
->
resource_state_manager
->
TransitionResource
(
xres
,
state
,
SubresourceTransitionFlags_None
);
}
void
...
...
@@ -1525,8 +1524,7 @@ d3d12_transition_subresources_state(struct d3d12_context *ctx,
uint32_t
start_level
,
uint32_t
num_levels
,
uint32_t
start_layer
,
uint32_t
num_layers
,
uint32_t
start_plane
,
uint32_t
num_planes
,
D3D12_RESOURCE_STATES
state
,
SubresourceTransitionFlags
flags
)
D3D12_RESOURCE_STATES
state
)
{
TransitionableResourceState
*
xres
=
d3d12_resource_state
(
res
);
...
...
@@ -1538,16 +1536,16 @@ d3d12_transition_subresources_state(struct d3d12_context *ctx,
const
uint32_t
plane
=
start_plane
+
p
;
uint32_t
subres_id
=
level
+
(
layer
*
res
->
mip_levels
)
+
plane
*
(
res
->
mip_levels
*
res
->
base
.
array_size
);
assert
(
subres_id
<
xres
->
NumSubresources
());
ctx
->
resource_state_manager
->
TransitionSubresource
(
xres
,
subres_id
,
state
,
flags
);
ctx
->
resource_state_manager
->
TransitionSubresource
(
xres
,
subres_id
,
state
,
SubresourceTransitionFlags_None
);
}
}
}
}
void
d3d12_apply_resource_states
(
struct
d3d12_context
*
ctx
,
bool
predraw
)
d3d12_apply_resource_states
(
struct
d3d12_context
*
ctx
)
{
ctx
->
resource_state_manager
->
ApplyAllResourceTransitions
(
ctx
->
cmdlist
,
ctx
->
fence_value
,
predraw
);
ctx
->
resource_state_manager
->
ApplyAllResourceTransitions
(
ctx
->
cmdlist
,
ctx
->
fence_value
);
}
static
void
...
...
@@ -1565,9 +1563,8 @@ d3d12_clear_render_target(struct pipe_context *pctx,
ctx
->
cmdlist
->
SetPredication
(
NULL
,
0
,
D3D12_PREDICATION_OP_EQUAL_ZERO
);
d3d12_transition_resource_state
(
ctx
,
d3d12_resource
(
psurf
->
texture
),
D3D12_RESOURCE_STATE_RENDER_TARGET
,
SubresourceTransitionFlags_None
);
d3d12_apply_resource_states
(
ctx
,
false
);
D3D12_RESOURCE_STATE_RENDER_TARGET
);
d3d12_apply_resource_states
(
ctx
);
enum
pipe_format
format
=
psurf
->
texture
->
format
;
float
clear_color
[
4
];
...
...
@@ -1619,9 +1616,8 @@ d3d12_clear_depth_stencil(struct pipe_context *pctx,
flags
|=
D3D12_CLEAR_FLAG_STENCIL
;
d3d12_transition_resource_state
(
ctx
,
d3d12_resource
(
ctx
->
fb
.
zsbuf
->
texture
),
D3D12_RESOURCE_STATE_DEPTH_WRITE
,
SubresourceTransitionFlags_None
);
d3d12_apply_resource_states
(
ctx
,
false
);
D3D12_RESOURCE_STATE_DEPTH_WRITE
);
d3d12_apply_resource_states
(
ctx
);
D3D12_RECT
rect
=
{
dstx
,
dsty
,
dstx
+
width
,
dsty
+
height
};
ctx
->
cmdlist
->
ClearDepthStencilView
(
surf
->
desc_handle
.
cpu_handle
,
flags
,
...
...
@@ -1687,9 +1683,8 @@ d3d12_flush_resource(struct pipe_context *pctx,
struct
d3d12_resource
*
res
=
d3d12_resource
(
pres
);
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_COMMON
,
SubresourceTransitionFlags_None
);
d3d12_apply_resource_states
(
ctx
,
false
);
D3D12_RESOURCE_STATE_COMMON
);
d3d12_apply_resource_states
(
ctx
);
}
static
void
...
...
src/gallium/drivers/d3d12/d3d12_context.h
View file @
acae5af1
...
...
@@ -306,8 +306,7 @@ d3d12_flush_cmdlist_and_wait(struct d3d12_context *ctx);
void
d3d12_transition_resource_state
(
struct
d3d12_context
*
ctx
,
struct
d3d12_resource
*
res
,
D3D12_RESOURCE_STATES
state
,
SubresourceTransitionFlags
flags
);
D3D12_RESOURCE_STATES
state
);
void
d3d12_transition_subresources_state
(
struct
d3d12_context
*
ctx
,
...
...
@@ -315,11 +314,10 @@ d3d12_transition_subresources_state(struct d3d12_context *ctx,
unsigned
start_level
,
unsigned
num_levels
,
unsigned
start_layer
,
unsigned
num_layers
,
unsigned
start_plane
,
unsigned
num_planes
,
D3D12_RESOURCE_STATES
state
,
SubresourceTransitionFlags
flags
);
D3D12_RESOURCE_STATES
state
);
void
d3d12_apply_resource_states
(
struct
d3d12_context
*
ctx
,
bool
predraw
);
d3d12_apply_resource_states
(
struct
d3d12_context
*
ctx
);
void
d3d12_draw_vbo
(
struct
pipe_context
*
pctx
,
...
...
src/gallium/drivers/d3d12/d3d12_draw.cpp
View file @
acae5af1
...
...
@@ -63,8 +63,7 @@ fill_cbv_descriptors(struct d3d12_context *ctx,
assert
(
buffer
->
buffer
);
struct
d3d12_resource
*
res
=
d3d12_resource
(
buffer
->
buffer
);
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER
,
SubresourceTransitionFlags_TransitionPreDraw
);
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER
);
D3D12_CONSTANT_BUFFER_VIEW_DESC
cbv_desc
=
{};
cbv_desc
.
BufferLocation
=
d3d12_resource_gpu_virtual_address
(
res
)
+
buffer
->
buffer_offset
;
cbv_desc
.
SizeInBytes
=
min
(
D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT
*
16
,
...
...
@@ -110,14 +109,13 @@ fill_srv_descriptors(struct d3d12_context *ctx,
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE
;
if
(
view
->
base
.
texture
->
target
==
PIPE_BUFFER
)
{
d3d12_transition_resource_state
(
ctx
,
d3d12_resource
(
view
->
base
.
texture
),
state
,
SubresourceTransitionFlags_TransitionPreDraw
);
state
);
}
else
{
d3d12_transition_subresources_state
(
ctx
,
d3d12_resource
(
view
->
base
.
texture
),
view
->
base
.
u
.
tex
.
first_level
,
view
->
mip_levels
,
view
->
base
.
u
.
tex
.
first_layer
,
view
->
array_size
,
0
,
d3d12_get_format_num_planes
(
view
->
base
.
format
),
state
,
SubresourceTransitionFlags_TransitionPreDraw
);
state
);
}
}
else
{
descs
[
i
]
=
ctx
->
null_srvs
[
shader
->
srv_bindings
[
i
].
dimension
].
cpu_handle
;
...
...
@@ -369,8 +367,7 @@ static void
transition_surface_subresources_state
(
struct
d3d12_context
*
ctx
,
struct
pipe_surface
*
psurf
,
struct
pipe_resource
*
pres
,
D3D12_RESOURCE_STATES
state
,
SubresourceTransitionFlags
flags
)
D3D12_RESOURCE_STATES
state
)
{
struct
d3d12_resource
*
res
=
d3d12_resource
(
pres
);
unsigned
start_layer
,
num_layers
;
...
...
@@ -385,7 +382,7 @@ transition_surface_subresources_state(struct d3d12_context *ctx,
psurf
->
u
.
tex
.
level
,
1
,
start_layer
,
num_layers
,
0
,
d3d12_get_format_num_planes
(
psurf
->
format
),
state
,
flags
);
state
);
}
static
bool
...
...
@@ -609,8 +606,7 @@ d3d12_draw_vbo(struct pipe_context *pctx,
for
(
unsigned
i
=
0
;
i
<
ctx
->
num_vbs
;
++
i
)
{
if
(
ctx
->
vbs
[
i
].
buffer
.
resource
)
{
struct
d3d12_resource
*
res
=
d3d12_resource
(
ctx
->
vbs
[
i
].
buffer
.
resource
);
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER
,
SubresourceTransitionFlags_TransitionPreDraw
);
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER
);
if
(
ctx
->
cmdlist_dirty
&
D3D12_DIRTY_VERTEX_BUFFERS
)
d3d12_batch_reference_resource
(
batch
,
res
);
}
...
...
@@ -624,8 +620,7 @@ d3d12_draw_vbo(struct pipe_context *pctx,
ibv
.
BufferLocation
=
d3d12_resource_gpu_virtual_address
(
res
)
+
index_offset
;
ibv
.
SizeInBytes
=
res
->
base
.
width0
-
index_offset
;
ibv
.
Format
=
ib_format
(
dinfo
->
index_size
);
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_INDEX_BUFFER
,
SubresourceTransitionFlags_TransitionPreDraw
);
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_INDEX_BUFFER
);
if
(
ctx
->
cmdlist_dirty
&
D3D12_DIRTY_INDEX_BUFFER
||
memcmp
(
&
ctx
->
ibv
,
&
ibv
,
sizeof
(
D3D12_INDEX_BUFFER_VIEW
))
!=
0
)
{
ctx
->
ibv
=
ibv
;
...
...
@@ -677,10 +672,8 @@ d3d12_draw_vbo(struct pipe_context *pctx,
d3d12_batch_reference_resource
(
batch
,
fill_buffer
);
}
d3d12_transition_resource_state
(
ctx
,
so_buffer
,
D3D12_RESOURCE_STATE_STREAM_OUT
,
SubresourceTransitionFlags_TransitionPreDraw
);
d3d12_transition_resource_state
(
ctx
,
fill_buffer
,
D3D12_RESOURCE_STATE_STREAM_OUT
,
SubresourceTransitionFlags_TransitionPreDraw
);
d3d12_transition_resource_state
(
ctx
,
so_buffer
,
D3D12_RESOURCE_STATE_STREAM_OUT
);
d3d12_transition_resource_state
(
ctx
,
fill_buffer
,
D3D12_RESOURCE_STATE_STREAM_OUT
);
}
if
(
ctx
->
cmdlist_dirty
&
D3D12_DIRTY_STREAM_OUTPUT
)
ctx
->
cmdlist
->
SOSetTargets
(
0
,
4
,
so_buffer_views
);
...
...
@@ -693,17 +686,15 @@ d3d12_draw_vbo(struct pipe_context *pctx,
struct
pipe_resource
*
pres
=
conversion_modes
[
i
]
==
D3D12_SURFACE_CONVERSION_BGRA_UINT
?
d3d12_surface
(
psurf
)
->
rgba_texture
:
psurf
->
texture
;
transition_surface_subresources_state
(
ctx
,
psurf
,
pres
,
D3D12_RESOURCE_STATE_RENDER_TARGET
,
SubresourceTransitionFlags_TransitionPreDraw
);
D3D12_RESOURCE_STATE_RENDER_TARGET
);
}
if
(
ctx
->
fb
.
zsbuf
)
{
struct
pipe_surface
*
psurf
=
ctx
->
fb
.
zsbuf
;
transition_surface_subresources_state
(
ctx
,
psurf
,
psurf
->
texture
,
D3D12_RESOURCE_STATE_DEPTH_WRITE
,
SubresourceTransitionFlags_TransitionPreDraw
);
D3D12_RESOURCE_STATE_DEPTH_WRITE
);
}
d3d12_apply_resource_states
(
ctx
,
true
);
d3d12_apply_resource_states
(
ctx
);
if
(
dinfo
->
index_size
>
0
)
ctx
->
cmdlist
->
DrawIndexedInstanced
(
dinfo
->
count
,
dinfo
->
instance_count
,
...
...
src/gallium/drivers/d3d12/d3d12_query.cpp
View file @
acae5af1
...
...
@@ -367,8 +367,8 @@ end_query(struct d3d12_context *ctx, struct d3d12_query *q)
offset
+=
q
->
buffer_offset
+
resolve_index
*
q
->
query_size
;
ctx
->
cmdlist
->
EndQuery
(
q
->
query_heap
,
q
->
d3d12qtype
,
end_index
);
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_COPY_DEST
,
SubresourceTransitionFlags
::
SubresourceTransitionFlags_None
);
d3d12_apply_resource_states
(
ctx
,
false
);
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_COPY_DEST
);
d3d12_apply_resource_states
(
ctx
);
ctx
->
cmdlist
->
ResolveQueryData
(
q
->
query_heap
,
q
->
d3d12qtype
,
resolve_index
,
resolve_count
,
d3d12_res
,
offset
);
...
...
@@ -483,18 +483,15 @@ d3d12_render_condition(struct pipe_context *pctx,
}
struct
d3d12_resource
*
res
=
(
struct
d3d12_resource
*
)
query
->
buffer
;
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_COPY_SOURCE
,
SubresourceTransitionFlags
::
SubresourceTransitionFlags_None
);
d3d12_transition_resource_state
(
ctx
,
query
->
predicate
,
D3D12_RESOURCE_STATE_COPY_DEST
,
SubresourceTransitionFlags
::
SubresourceTransitionFlags_None
);
d3d12_apply_resource_states
(
ctx
,
false
);
d3d12_transition_resource_state
(
ctx
,
res
,
D3D12_RESOURCE_STATE_COPY_SOURCE
);
d3d12_transition_resource_state
(
ctx
,
query
->
predicate
,
D3D12_RESOURCE_STATE_COPY_DEST
);
d3d12_apply_resource_states
(
ctx
);
ctx
->
cmdlist
->
CopyBufferRegion
(
d3d12_resource_resource
(
query
->
predicate
),
0
,
d3d12_resource_resource
(
res
),
0
,
sizeof
(
uint64_t
));
d3d12_transition_resource_state
(
ctx
,
query
->
predicate
,
D3D12_RESOURCE_STATE_PREDICATION
,
SubresourceTransitionFlags_None
);
d3d12_apply_resource_states
(
ctx
,
false
);
d3d12_transition_resource_state
(
ctx
,
query
->
predicate
,
D3D12_RESOURCE_STATE_PREDICATION
);
d3d12_apply_resource_states
(
ctx
);
ctx
->
current_predication
=
query
->
predicate
;
/* documentation of ID3D12GraphicsCommandList::SetPredication method:
...
...
src/gallium/drivers/d3d12/d3d12_resource.cpp
View file @
acae5af1
...
...
@@ -408,11 +408,9 @@ copy_texture_region(struct d3d12_context *ctx,
d3d12_batch_reference_resource
(
batch
,
info
.
src
);
d3d12_batch_reference_resource
(
batch
,
info
.
dst
);
d3d12_transition_resource_state
(
ctx
,
info
.
src
,
D3D12_RESOURCE_STATE_COPY_SOURCE
,
SubresourceTransitionFlags
::
SubresourceTransitionFlags_None
);
d3d12_transition_resource_state
(
ctx
,
info
.
dst
,
D3D12_RESOURCE_STATE_COPY_DEST
,
SubresourceTransitionFlags
::
SubresourceTransitionFlags_None
);
d3d12_apply_resource_states
(
ctx
,
false
);
d3d12_transition_resource_state
(
ctx
,
info
.
src
,
D3D12_RESOURCE_STATE_COPY_SOURCE
);
d3d12_transition_resource_state
(
ctx
,
info
.
dst
,
D3D12_RESOURCE_STATE_COPY_DEST
);
d3d12_apply_resource_states
(
ctx
);
ctx
->
cmdlist
->
CopyTextureRegion
(
&
info
.
dst_loc
,
info
.
dst_x
,
info
.
dst_y
,
info
.
dst_z
,
&
info
.
src_loc
,
info
.
src_box
);
}
...
...
src/microsoft/resource_state_manager/D3D12ResourceState.cpp
View file @
acae5af1
...
...
@@ -246,16 +246,12 @@ void ResourceStateManager::AddCurrentStateUpdate(TransitionableResourceState& Re
}
//----------------------------------------------------------------------------------------------------------------------------------
auto
ResourceStateManager
::
ProcessTransitioningResource
(
ID3D12Resource
*
pTransitioningResource
,
void
ResourceStateManager
::
ProcessTransitioningResource
(
ID3D12Resource
*
pTransitioningResource
,
TransitionableResourceState
&
TransitionableResourceState
,
CCurrentResourceState
&
CurrentState
,
UINT
NumTotalSubresources
,
UINT64
ExecutionId
,
bool
bIsPreDraw
)
->
TransitionResult
UINT64
ExecutionId
)
{
// By default, assume that the resource is fully processed by this routine.
TransitionResult
result
=
TransitionResult
::
Remove
;
// Figure out the set of subresources that are transitioning
auto
&
DestinationState
=
TransitionableResourceState
.
m_DesiredState
;
bool
bAllSubresourcesAtOnce
=
CurrentState
.
AreAllSubresourcesSame
()
&&
DestinationState
.
AreAllSubresourcesSame
();
...
...
@@ -271,16 +267,6 @@ auto ResourceStateManager::ProcessTransitioningResource(ID3D12Resource* pTransit
CDesiredResourceState
::
SubresourceInfo
SubresourceDestinationInfo
=
DestinationState
.
GetSubresourceInfo
(
i
);
TransitionDesc
.
Transition
.
Subresource
=
bAllSubresourcesAtOnce
?
D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES
:
i
;
// Is this subresource relevant for the current transition?
if
((
SubresourceDestinationInfo
.
Flags
&
SubresourceTransitionFlags_TransitionPreDraw
)
!=
SubresourceTransitionFlags_None
&&
!
bIsPreDraw
)
{
// Nope, we'll go to the next subresource, and also indicate to leave this resource in the transition list so that
// we come back to it on the next draw operation.
result
=
TransitionResult
::
Keep
;
continue
;
}
// Is this subresource currently being used, or is it just being iterated over?
D3D12_RESOURCE_STATES
after
=
SubresourceDestinationInfo
.
State
;
SubresourceTransitionFlags
Flags
=
SubresourceDestinationInfo
.
Flags
;
...
...
@@ -306,38 +292,9 @@ auto ResourceStateManager::ProcessTransitioningResource(ID3D12Resource* pTransit
UnknownDestinationState
.
Flags
=
SubresourceTransitionFlags_None
;
// Update destination states.
if
(
result
==
TransitionResult
::
Remove
)
// We're done
{
// Coalesce destination state to ensure that it's set for the entire resource.
DestinationState
.
SetResourceState
(
UnknownDestinationState
);
}
else
if
(
!
bIsPreDraw
)
{
// There must be some subresource which was pending a draw transition, but not one that transitioned this time.
// Make sure all *other* subresources have their pending transitions cleared.
assert
(
!
DestinationState
.
AreAllSubresourcesSame
()
||
(
DestinationState
.
GetSubresourceInfo
(
0
).
Flags
&
SubresourceTransitionFlags_TransitionPreDraw
)
!=
SubresourceTransitionFlags_None
);
bAllSubresourcesAtOnce
=
DestinationState
.
AreAllSubresourcesSame
();
numSubresources
=
bAllSubresourcesAtOnce
?
1
:
NumTotalSubresources
;
for
(
UINT
i
=
0
;
i
<
numSubresources
;
++
i
)
{
if
((
DestinationState
.
GetSubresourceInfo
(
i
).
Flags
&
SubresourceTransitionFlags_TransitionPreDraw
)
==
SubresourceTransitionFlags_None
)
{
if
(
bAllSubresourcesAtOnce
)
{
DestinationState
.
SetResourceState
(
UnknownDestinationState
);
}
else
{
DestinationState
.
SetSubresourceState
(
i
,
UnknownDestinationState
);
}
}
}
}
// Coalesce destination state to ensure that it's set for the entire resource.
DestinationState
.
SetResourceState
(
UnknownDestinationState
);
return
result
;
}
//----------------------------------------------------------------------------------------------------------------------------------
...
...
@@ -429,23 +386,22 @@ void ResourceStateManager::TransitionSubresource(TransitionableResourceState* pR
}
//----------------------------------------------------------------------------------------------------------------------------------
void
ResourceStateManager
::
ApplyAllResourceTransitions
(
ID3D12GraphicsCommandList
*
pCommandList
,
UINT64
ExecutionId
,
bool
bIsPreDraw
)
void
ResourceStateManager
::
ApplyAllResourceTransitions
(
ID3D12GraphicsCommandList
*
pCommandList
,
UINT64
ExecutionId
)
{
ApplyResourceTransitionsPreamble
();
ForEachTransitioningResource
([
=
](
TransitionableResourceState
&
ResourceBase
)
->
TransitionResult
ForEachTransitioningResource
([
=
](
TransitionableResourceState
&
ResourceBase
)
{
TransitionableResourceState
&
CurResource
=
static_cast
<
TransitionableResourceState
&>
(
ResourceBase
);
ID3D12Resource
*
pResource
=
CurResource
.
GetD3D12Resource
();
return
ProcessTransitioningResource
(
ProcessTransitioningResource
(
pResource
,
CurResource
,
CurResource
.
GetCurrentState
(),
CurResource
.
NumSubresources
(),
ExecutionId
,
bIsPreDraw
);
ExecutionId
);
});
SubmitResourceTransitions
(
pCommandList
);
...
...
src/microsoft/resource_state_manager/D3D12ResourceState.h
View file @
acae5af1
...
...
@@ -238,7 +238,7 @@ public:
SubresourceTransitionFlags
Flags
=
SubresourceTransitionFlags_None
);
// Submit all barriers and queue sync.
void
ApplyAllResourceTransitions
(
ID3D12GraphicsCommandList
*
pCommandList
,
UINT64
ExecutionId
,
bool
bIsPreDraw
=
false
);
void
ApplyAllResourceTransitions
(
ID3D12GraphicsCommandList
*
pCommandList
,
UINT64
ExecutionId
);
private:
// These methods set the destination state of the resource/subresources and ensure it's in the transition list.
...
...
@@ -268,23 +268,18 @@ private:
{
list_for_each_entry_safe
(
TransitionableResourceState
,
pResource
,
&
m_TransitionListHead
,
m_TransitionListEntry
)
{
TransitionResult
result
=
func
(
*
pResource
);
if
(
result
==
TransitionResult
::
Remove
)
{
list_delinit
(
&
pResource
->
m_TransitionListEntry
);
}
func
(
*
pResource
);
list_delinit
(
&
pResource
->
m_TransitionListEntry
);
}
}
// Updates vectors with the operations that should be applied to the requested resource.
// May update the destination state of the resource.
TransitionResult
ProcessTransitioningResource
(
ID3D12Resource
*
pTransitioningResource
,
TransitionableResourceState
&
TransitionableResourceState
,
CCurrentResourceState
&
CurrentState
,
UINT
NumTotalSubresources
,
UINT64
ExecutionId
,
bool
bIsPreDraw
);
void
ProcessTransitioningResource
(
ID3D12Resource
*
pTransitioningResource
,
TransitionableResourceState
&
TransitionableResourceState
,
CCurrentResourceState
&
CurrentState
,
UINT
NumTotalSubresources
,
UINT64
ExecutionId
);
private:
// Helpers
...
...
src/microsoft/resource_state_manager/D3D12StateTransitionFlags.h
View file @
acae5af1
...
...
@@ -4,7 +4,6 @@
typedef
enum
_SubresourceTransitionFlags
{
SubresourceTransitionFlags_None
=
0
,
SubresourceTransitionFlags_TransitionPreDraw
=
1
,
}
SubresourceTransitionFlags
;
DEFINE_ENUM_FLAG_OPERATORS
(
SubresourceTransitionFlags
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment