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
214b0f7b
Commit
214b0f7b
authored
Sep 15, 2020
by
Erik Faye-Lund
Browse files
d3d12: get rid of pointless SubresourceInfo struct
parent
3f5c8801
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/microsoft/resource_state_manager/D3D12ResourceState.cpp
View file @
214b0f7b
...
...
@@ -24,58 +24,58 @@
#include "D3D12ResourceState.h"
//----------------------------------------------------------------------------------------------------------------------------------
CDesiredResourceState
::
SubresourceInfo
const
&
CDesiredResourceState
::
GetSubresource
Info
(
UINT
SubresourceIndex
)
const
D3D12_RESOURCE_STATES
CDesiredResourceState
::
GetSubresource
State
(
UINT
SubresourceIndex
)
const
{
if
(
AreAllSubresourcesSame
())
{
SubresourceIndex
=
0
;
}
return
m_spSubresource
Info
[
SubresourceIndex
];
return
m_spSubresource
States
[
SubresourceIndex
];
}
//----------------------------------------------------------------------------------------------------------------------------------
void
CDesiredResourceState
::
UpdateSubresourceState
(
unsigned
SubresourceIndex
,
SubresourceInfo
const
&
info
)
void
CDesiredResourceState
::
UpdateSubresourceState
(
unsigned
SubresourceIndex
,
D3D12_RESOURCE_STATES
state
)
{
assert
(
SubresourceIndex
<
m_spSubresource
Info
.
size
());
if
(
m_spSubresource
Info
[
SubresourceIndex
]
.
State
==
UNKNOWN_RESOURCE_STATE
||
info
.
S
tate
==
UNKNOWN_RESOURCE_STATE
||
IsD3D12WriteState
(
info
.
S
tate
))
assert
(
SubresourceIndex
<
m_spSubresource
States
.
size
());
if
(
m_spSubresource
States
[
SubresourceIndex
]
==
UNKNOWN_RESOURCE_STATE
||
s
tate
==
UNKNOWN_RESOURCE_STATE
||
IsD3D12WriteState
(
s
tate
))
{
m_spSubresource
Info
[
SubresourceIndex
]
=
info
;
m_spSubresource
States
[
SubresourceIndex
]
=
state
;
}
else
{
// Accumulate read state state bits
m_spSubresource
Info
[
SubresourceIndex
]
.
State
|=
info
.
S
tate
;
m_spSubresource
States
[
SubresourceIndex
]
|=
s
tate
;
}
}
//----------------------------------------------------------------------------------------------------------------------------------
void
CDesiredResourceState
::
SetResourceState
(
SubresourceInfo
const
&
Info
)
void
CDesiredResourceState
::
SetResourceState
(
D3D12_RESOURCE_STATES
state
)
{
m_bAllSubresourcesSame
=
true
;
UpdateSubresourceState
(
0
,
Info
);
UpdateSubresourceState
(
0
,
state
);
}
//----------------------------------------------------------------------------------------------------------------------------------
void
CDesiredResourceState
::
SetSubresourceState
(
UINT
SubresourceIndex
,
SubresourceInfo
const
&
Info
)
void
CDesiredResourceState
::
SetSubresourceState
(
UINT
SubresourceIndex
,
D3D12_RESOURCE_STATES
state
)
{
if
(
m_bAllSubresourcesSame
&&
m_spSubresource
Info
.
size
()
>
1
)
if
(
m_bAllSubresourcesSame
&&
m_spSubresource
States
.
size
()
>
1
)
{
std
::
fill
(
m_spSubresource
Info
.
begin
()
+
1
,
m_spSubresource
Info
.
end
(),
m_spSubresource
Info
[
0
]);
std
::
fill
(
m_spSubresource
States
.
begin
()
+
1
,
m_spSubresource
States
.
end
(),
m_spSubresource
States
[
0
]);
m_bAllSubresourcesSame
=
false
;
}
if
(
m_spSubresource
Info
.
size
()
==
1
)
if
(
m_spSubresource
States
.
size
()
==
1
)
{
SubresourceIndex
=
0
;
}
UpdateSubresourceState
(
SubresourceIndex
,
Info
);
UpdateSubresourceState
(
SubresourceIndex
,
state
);
}
//----------------------------------------------------------------------------------------------------------------------------------
void
CDesiredResourceState
::
Reset
()
{
SetResourceState
(
SubresourceInfo
{}
);
SetResourceState
(
UNKNOWN_RESOURCE_STATE
);
}
//----------------------------------------------------------------------------------------------------------------------------------
...
...
@@ -169,9 +169,9 @@ ResourceStateManager::ResourceStateManager()
//----------------------------------------------------------------------------------------------------------------------------------
void
ResourceStateManager
::
TransitionResource
(
TransitionableResourceState
&
Resource
,
CDesiredResourceState
::
SubresourceInfo
const
&
S
tate
)
D3D12_RESOURCE_STATES
s
tate
)
{
Resource
.
m_DesiredState
.
SetResourceState
(
S
tate
);
Resource
.
m_DesiredState
.
SetResourceState
(
s
tate
);
if
(
!
Resource
.
IsTransitionPending
())
{
list_add
(
&
Resource
.
m_TransitionListEntry
,
&
m_TransitionListHead
);
...
...
@@ -180,10 +180,10 @@ void ResourceStateManager::TransitionResource(TransitionableResourceState& Resou
//----------------------------------------------------------------------------------------------------------------------------------
void
ResourceStateManager
::
TransitionSubresource
(
TransitionableResourceState
&
Resource
,
UINT
SubresourceIndex
,
CDesiredResourceState
::
SubresourceInfo
const
&
S
tate
)
UINT
SubresourceIndex
,
D3D12_RESOURCE_STATES
s
tate
)
{
Resource
.
m_DesiredState
.
SetSubresourceState
(
SubresourceIndex
,
S
tate
);
Resource
.
m_DesiredState
.
SetSubresourceState
(
SubresourceIndex
,
s
tate
);
if
(
!
Resource
.
IsTransitionPending
())
{
list_add
(
&
Resource
.
m_TransitionListEntry
,
&
m_TransitionListHead
);
...
...
@@ -263,11 +263,11 @@ void ResourceStateManager::ProcessTransitioningResource(ID3D12Resource* pTransit
UINT
numSubresources
=
bAllSubresourcesAtOnce
?
1
:
NumTotalSubresources
;
for
(
UINT
i
=
0
;
i
<
numSubresources
;
++
i
)
{
CDesiredResourceState
::
SubresourceInfo
SubresourceDestination
Info
=
DestinationState
.
GetSubresource
Info
(
i
);
D3D12_RESOURCE_STATES
SubresourceDestination
State
=
DestinationState
.
GetSubresource
State
(
i
);
TransitionDesc
.
Transition
.
Subresource
=
bAllSubresourcesAtOnce
?
D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES
:
i
;
// Is this subresource currently being used, or is it just being iterated over?
D3D12_RESOURCE_STATES
after
=
SubresourceDestinationInfo
.
State
;
D3D12_RESOURCE_STATES
after
=
DestinationState
.
GetSubresource
State
(
i
)
;
if
(
after
==
UNKNOWN_RESOURCE_STATE
)
{
// This subresource doesn't have any transition requested - move on to the next.
...
...
@@ -277,19 +277,16 @@ void ResourceStateManager::ProcessTransitioningResource(ID3D12Resource* pTransit
ProcessTransitioningSubresourceExplicit
(
CurrentState
,
i
,
SubresourceDestination
Info
,
SubresourceDestination
State
,
after
,
TransitionableResourceState
,
TransitionDesc
,
ExecutionId
);
// throw( bad_alloc )
}
CDesiredResourceState
::
SubresourceInfo
UnknownDestinationState
=
{};
UnknownDestinationState
.
State
=
UNKNOWN_RESOURCE_STATE
;
// Update destination states.
// Coalesce destination state to ensure that it's set for the entire resource.
DestinationState
.
SetResourceState
(
U
nknownDestinationState
);
DestinationState
.
SetResourceState
(
U
NKNOWN_RESOURCE_STATE
);
}
...
...
@@ -297,7 +294,7 @@ void ResourceStateManager::ProcessTransitioningResource(ID3D12Resource* pTransit
void
ResourceStateManager
::
ProcessTransitioningSubresourceExplicit
(
CCurrentResourceState
&
CurrentState
,
UINT
SubresourceIndex
,
CDesiredResourceState
::
SubresourceInfo
&
SubresourceDestinationInfo
,
D3D12_RESOURCE_STATES
state
,
D3D12_RESOURCE_STATES
after
,
TransitionableResourceState
&
TransitionableResourceState
,
D3D12_RESOURCE_BARRIER
&
TransitionDesc
,
...
...
@@ -369,15 +366,13 @@ void ResourceStateManager::SubmitResourceTransitions(ID3D12GraphicsCommandList *
//----------------------------------------------------------------------------------------------------------------------------------
void
ResourceStateManager
::
TransitionResource
(
TransitionableResourceState
*
pResource
,
D3D12_RESOURCE_STATES
State
)
{
CDesiredResourceState
::
SubresourceInfo
DesiredState
=
{
State
};
ResourceStateManager
::
TransitionResource
(
*
pResource
,
DesiredState
);
ResourceStateManager
::
TransitionResource
(
*
pResource
,
State
);
}
//----------------------------------------------------------------------------------------------------------------------------------
void
ResourceStateManager
::
TransitionSubresource
(
TransitionableResourceState
*
pResource
,
UINT
SubresourceIndex
,
D3D12_RESOURCE_STATES
State
)
{
CDesiredResourceState
::
SubresourceInfo
DesiredState
=
{
State
};
ResourceStateManager
::
TransitionSubresource
(
*
pResource
,
SubresourceIndex
,
DesiredState
);
ResourceStateManager
::
TransitionSubresource
(
*
pResource
,
SubresourceIndex
,
State
);
}
//----------------------------------------------------------------------------------------------------------------------------------
...
...
src/microsoft/resource_state_manager/D3D12ResourceState.h
View file @
214b0f7b
...
...
@@ -61,33 +61,27 @@ inline bool SupportsSimultaneousAccess(const D3D12_RESOURCE_DESC &desc)
//==================================================================================================================================
class
CDesiredResourceState
{
public:
struct
SubresourceInfo
{
D3D12_RESOURCE_STATES
State
=
UNKNOWN_RESOURCE_STATE
;
};
private:
bool
m_bAllSubresourcesSame
=
true
;
std
::
vector
<
SubresourceInfo
>
m_spSubresource
Info
;
std
::
vector
<
D3D12_RESOURCE_STATES
>
m_spSubresource
States
;
public:
CDesiredResourceState
(
UINT
SubresourceCount
)
:
m_spSubresource
Info
(
SubresourceCount
)
m_spSubresource
States
(
SubresourceCount
)
{
}
bool
AreAllSubresourcesSame
()
const
{
return
m_bAllSubresourcesSame
;
}
SubresourceInfo
const
&
GetSubresource
Info
(
UINT
SubresourceIndex
)
const
;
void
SetResourceState
(
SubresourceInfo
const
&
Info
);
void
SetSubresourceState
(
UINT
SubresourceIndex
,
SubresourceInfo
const
&
Info
);
D3D12_RESOURCE_STATES
GetSubresource
State
(
UINT
SubresourceIndex
)
const
;
void
SetResourceState
(
D3D12_RESOURCE_STATES
state
);
void
SetSubresourceState
(
UINT
SubresourceIndex
,
D3D12_RESOURCE_STATES
state
);
void
Reset
();
private:
void
UpdateSubresourceState
(
unsigned
SubresourceIndex
,
SubresourceInfo
const
&
info
);
void
UpdateSubresourceState
(
unsigned
SubresourceIndex
,
D3D12_RESOURCE_STATES
state
);
};
//==================================================================================================================================
...
...
@@ -121,7 +115,7 @@ public:
// Returns the destination state if the current state is promotable.
// Returns D3D12_RESOURCE_STATE_COMMON if not.
D3D12_RESOURCE_STATES
StateIfPromoted
(
D3D12_RESOURCE_STATES
S
tate
,
UINT
SubresourceIndex
);
D3D12_RESOURCE_STATES
StateIfPromoted
(
D3D12_RESOURCE_STATES
s
tate
,
UINT
SubresourceIndex
);
bool
AreAllSubresourcesSame
()
const
{
return
m_bAllSubresourcesSame
;
}
...
...
@@ -238,10 +232,10 @@ public:
private:
// These methods set the destination state of the resource/subresources and ensure it's in the transition list.
void
TransitionResource
(
TransitionableResourceState
&
Resource
,
CDesiredResourceState
::
SubresourceInfo
const
&
State
);
D3D12_RESOURCE_STATES
State
);
void
TransitionSubresource
(
TransitionableResourceState
&
Resource
,
UINT
SubresourceIndex
,
CDesiredResourceState
::
SubresourceInfo
const
&
State
);
D3D12_RESOURCE_STATES
State
);
// Clear out any state from previous iterations.
void
ApplyResourceTransitionsPreamble
();
...
...
@@ -285,7 +279,7 @@ private:
const
CCurrentResourceState
::
LogicalState
&
NewLogicalState
);
void
ProcessTransitioningSubresourceExplicit
(
CCurrentResourceState
&
CurrentState
,
UINT
i
,
CDesiredResourceState
::
SubresourceInfo
&
SubresourceDestinationInfo
,
D3D12_RESOURCE_STATES
state
,
D3D12_RESOURCE_STATES
after
,
TransitionableResourceState
&
TransitionableResourceState
,
D3D12_RESOURCE_BARRIER
&
TransitionDesc
,
...
...
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