mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 20:52:10 +01:00
[d3d11] Validate and correct scissor rects
Fixes Vulkan validation errors in Frostpunk and more closely emulates Windows behaviour.
This commit is contained in:
parent
a9c0f9e7c2
commit
49bda46a37
@ -2290,8 +2290,11 @@ namespace dxvk {
|
|||||||
const D3D11_RECT* pRects) {
|
const D3D11_RECT* pRects) {
|
||||||
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++) {
|
||||||
m_state.rs.scissors.at(i) = pRects[i];
|
if (pRects[i].bottom >= pRects[i].top
|
||||||
|
&& pRects[i].right >= pRects[i].left)
|
||||||
|
m_state.rs.scissors.at(i) = pRects[i];
|
||||||
|
}
|
||||||
|
|
||||||
if (m_state.rs.state != nullptr) {
|
if (m_state.rs.state != nullptr) {
|
||||||
D3D11_RASTERIZER_DESC rsDesc;
|
D3D11_RASTERIZER_DESC rsDesc;
|
||||||
@ -2554,17 +2557,22 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < m_state.rs.numViewports; i++) {
|
for (uint32_t i = 0; i < m_state.rs.numViewports; i++) {
|
||||||
// TODO D3D11 docs aren't clear about what should happen
|
|
||||||
// when there are undefined scissor rects for a viewport.
|
|
||||||
// Figure out what it does on Windows.
|
|
||||||
if (enableScissorTest && (i < m_state.rs.numScissors)) {
|
if (enableScissorTest && (i < m_state.rs.numScissors)) {
|
||||||
const D3D11_RECT& sr = m_state.rs.scissors.at(i);
|
D3D11_RECT sr = m_state.rs.scissors.at(i);
|
||||||
|
|
||||||
scissors.at(i) = VkRect2D {
|
VkOffset2D srPosA;
|
||||||
VkOffset2D { sr.left, sr.top },
|
srPosA.x = std::max<int32_t>(0, sr.left);
|
||||||
VkExtent2D {
|
srPosA.y = std::max<int32_t>(0, sr.top);
|
||||||
static_cast<uint32_t>(sr.right - sr.left),
|
|
||||||
static_cast<uint32_t>(sr.bottom - sr.top) } };
|
VkOffset2D srPosB;
|
||||||
|
srPosB.x = std::max<int32_t>(srPosA.x, sr.right);
|
||||||
|
srPosB.y = std::max<int32_t>(srPosA.y, sr.bottom);
|
||||||
|
|
||||||
|
VkExtent2D srSize;
|
||||||
|
srSize.width = uint32_t(srPosB.x - srPosA.x);
|
||||||
|
srSize.height = uint32_t(srPosB.y - srPosA.y);
|
||||||
|
|
||||||
|
scissors.at(i) = VkRect2D { srPosA, srSize };
|
||||||
} else {
|
} else {
|
||||||
scissors.at(i) = VkRect2D {
|
scissors.at(i) = VkRect2D {
|
||||||
VkOffset2D { 0, 0 },
|
VkOffset2D { 0, 0 },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user