1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 13:08:50 +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:
Philip Rebohle 2019-01-12 20:22:08 +01:00
parent c804d99db7
commit 79eded9ae2
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -2705,12 +2705,24 @@ namespace dxvk {
const D3D11_VIEWPORT* pViewports) {
D3D10DeviceLock lock = LockContext();
bool dirty = m_state.rs.numViewports != NumViewports;
m_state.rs.numViewports = NumViewports;
for (uint32_t i = 0; i < NumViewports; i++)
m_state.rs.viewports.at(i) = pViewports[i];
for (uint32_t i = 0; i < NumViewports; 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) {
D3D10DeviceLock lock = LockContext();
bool dirty = m_state.rs.numScissors != NumRects;
m_state.rs.numScissors = NumRects;
for (uint32_t i = 0; i < NumRects; i++) {
if (pRects[i].bottom >= pRects[i].top
&& pRects[i].right >= pRects[i].left)
m_state.rs.scissors.at(i) = pRects[i];
&& pRects[i].right >= pRects[i].left) {
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;
m_state.rs.state->GetDesc(&rsDesc);