1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[d3d9] Add GetSurfaceExtent helper

This commit is contained in:
Joshua Ashton 2020-01-09 03:29:58 +00:00
parent cd58b147a1
commit 47555f1dda
2 changed files with 19 additions and 10 deletions

View File

@ -1134,22 +1134,21 @@ namespace dxvk {
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
if (RenderTargetIndex == 0) { if (RenderTargetIndex == 0) {
uint32_t width = std::max(1u, desc->Width >> rt->GetMipLevel()); auto rtSize = rt->GetSurfaceExtent();
uint32_t height = std::max(1u, desc->Height >> rt->GetMipLevel());
D3DVIEWPORT9 viewport; D3DVIEWPORT9 viewport;
viewport.X = 0; viewport.X = 0;
viewport.Y = 0; viewport.Y = 0;
viewport.Width = width; viewport.Width = rtSize.width;
viewport.Height = height; viewport.Height = rtSize.height;
viewport.MinZ = 0.0f; viewport.MinZ = 0.0f;
viewport.MaxZ = 1.0f; viewport.MaxZ = 1.0f;
RECT scissorRect; RECT scissorRect;
scissorRect.left = 0; scissorRect.left = 0;
scissorRect.top = 0; scissorRect.top = 0;
scissorRect.right = width; scissorRect.right = rtSize.width;
scissorRect.bottom = height; scissorRect.bottom = rtSize.height;
if (m_state.viewport != viewport) { if (m_state.viewport != viewport) {
m_flags.set(D3D9DeviceFlag::DirtyFFViewport); m_flags.set(D3D9DeviceFlag::DirtyFFViewport);
@ -1398,11 +1397,10 @@ namespace dxvk {
// This works around that. // This works around that.
uint32_t alignment = m_d3d9Options.lenientClear ? 8 : 1; uint32_t alignment = m_d3d9Options.lenientClear ? 8 : 1;
uint32_t rt0Width = std::max(1u, rt0Desc->Width >> m_state.renderTargets[0]->GetMipLevel()); auto rtSize = m_state.renderTargets[0]->GetSurfaceExtent();
uint32_t rt0Height = std::max(1u, rt0Desc->Height >> m_state.renderTargets[0]->GetMipLevel());
bool extentMatches = align(extent.width, alignment) == align(rt0Width, alignment) bool extentMatches = align(extent.width, alignment) == align(rtSize.width, alignment)
&& align(extent.height, alignment) == align(rt0Height, alignment); && align(extent.height, alignment) == align(rtSize.height, alignment);
bool rtSizeMatchesClearSize = offset.x == 0 && offset.y == 0 && extentMatches; bool rtSizeMatchesClearSize = offset.x == 0 && offset.y == 0 && extentMatches;

View File

@ -6,6 +6,8 @@
#include "../util/util_gdi.h" #include "../util/util_gdi.h"
#include <algorithm>
namespace dxvk { namespace dxvk {
using D3D9GDIDesc = D3DKMT_DESTROYDCFROMMEMORY; using D3D9GDIDesc = D3DKMT_DESTROYDCFROMMEMORY;
@ -45,6 +47,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE ReleaseDC(HDC hDC) final; HRESULT STDMETHODCALLTYPE ReleaseDC(HDC hDC) final;
inline VkExtent2D GetSurfaceExtent() const {
const auto* desc = m_texture->Desc();
return VkExtent2D {
std::max(1u, desc->Width >> GetMipLevel()),
std::max(1u, desc->Height >> GetMipLevel())
};
}
private: private:
D3D9GDIDesc m_dcDesc; D3D9GDIDesc m_dcDesc;