Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small RSGetViewports fix #1117

Closed
wants to merge 2 commits into from
Closed

Conversation

K0bin
Copy link
Collaborator

@K0bin K0bin commented Jul 8, 2019

Closes #1116

In D3D11DeviceContext::RSGetViewports, D3D11 only sets pNumViewports if pViewports is null.
I've verified this with Windows D3D11. Wine also does it that way.

The behavior for RSGetScissorRects is the same.


MyGUI (a gui library that Scrap Mechanic uses) has a useless assert that only checks D3D11 runtime behavior.

UINT numViewports = 0;
D3D11_VIEWPORT viewports[8];
mpD3DContext->RSGetViewports(&numViewports, viewports);
MYGUI_PLATFORM_ASSERT(numViewports == 0, getClassTypeName() << " 0 viewport sets");

It does have a viewport at the point this gets executed but because it passes a valid pointer as pViewports, the count doesnt get changed.

https://github.com/MyGUI/mygui/blob/master/Platforms/DirectX11/DirectX11Platform/src/MyGUI_DirectX11RenderManager.cpp#L122

The MyGUI demos run fine with this PR.


*pNumViewports = m_state.rs.numViewports;
} else
*pNumViewports = m_state.rs.numViewports;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else if (pNumViewports != nullptr) perhaps? Not in our best interests to crash from user data.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows D3D11 also just crashes when you pass null for that.

@doitsujin
Copy link
Owner

Merged manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scrap Mechanic: Game fails to launch with DXVK but works with WineD3D11
3 participants