mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-04 16:24:29 +01:00
[d3d11] Only apply viewport and scissor rect if they have changed
Resident Evil 2 calls these functions before every single draw call, so we should avoid emitting redundant viewport updates.
This commit is contained in:
parent
c804d99db7
commit
79eded9ae2
@ -2705,12 +2705,24 @@ namespace dxvk {
|
|||||||
const D3D11_VIEWPORT* pViewports) {
|
const D3D11_VIEWPORT* pViewports) {
|
||||||
D3D10DeviceLock lock = LockContext();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
|
bool dirty = m_state.rs.numViewports != NumViewports;
|
||||||
m_state.rs.numViewports = NumViewports;
|
m_state.rs.numViewports = NumViewports;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < NumViewports; i++)
|
for (uint32_t i = 0; i < NumViewports; i++) {
|
||||||
m_state.rs.viewports.at(i) = pViewports[i];
|
const D3D11_VIEWPORT& vp = m_state.rs.viewports[i];
|
||||||
|
|
||||||
|
dirty |= vp.TopLeftX != pViewports[i].TopLeftX
|
||||||
|
|| vp.TopLeftY != pViewports[i].TopLeftY
|
||||||
|
|| vp.Width != pViewports[i].Width
|
||||||
|
|| vp.Height != pViewports[i].Height
|
||||||
|
|| vp.MinDepth != pViewports[i].MinDepth
|
||||||
|
|| vp.MaxDepth != pViewports[i].MaxDepth;
|
||||||
|
|
||||||
|
m_state.rs.viewports[i] = pViewports[i];
|
||||||
|
}
|
||||||
|
|
||||||
ApplyViewportState();
|
if (dirty)
|
||||||
|
ApplyViewportState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2719,15 +2731,24 @@ namespace dxvk {
|
|||||||
const D3D11_RECT* pRects) {
|
const D3D11_RECT* pRects) {
|
||||||
D3D10DeviceLock lock = LockContext();
|
D3D10DeviceLock lock = LockContext();
|
||||||
|
|
||||||
|
bool dirty = m_state.rs.numScissors != NumRects;
|
||||||
m_state.rs.numScissors = NumRects;
|
m_state.rs.numScissors = NumRects;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < NumRects; i++) {
|
for (uint32_t i = 0; i < NumRects; i++) {
|
||||||
if (pRects[i].bottom >= pRects[i].top
|
if (pRects[i].bottom >= pRects[i].top
|
||||||
&& pRects[i].right >= pRects[i].left)
|
&& pRects[i].right >= pRects[i].left) {
|
||||||
m_state.rs.scissors.at(i) = pRects[i];
|
const D3D11_RECT& sr = m_state.rs.scissors[i];
|
||||||
|
|
||||||
|
dirty |= sr.top != pRects[i].top
|
||||||
|
|| sr.left != pRects[i].left
|
||||||
|
|| sr.bottom != pRects[i].bottom
|
||||||
|
|| sr.right != pRects[i].right;
|
||||||
|
|
||||||
|
m_state.rs.scissors[i] = pRects[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_state.rs.state != nullptr) {
|
if (m_state.rs.state != nullptr && dirty) {
|
||||||
D3D11_RASTERIZER_DESC rsDesc;
|
D3D11_RASTERIZER_DESC rsDesc;
|
||||||
m_state.rs.state->GetDesc(&rsDesc);
|
m_state.rs.state->GetDesc(&rsDesc);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user