Commit 47555f1d authored by Joshua Ashton's avatar Joshua Ashton 🐸

[d3d9] Add GetSurfaceExtent helper

parent cd58b147
Pipeline #990 passed with stage
in 4 minutes and 10 seconds
......@@ -1134,22 +1134,21 @@ namespace dxvk {
return D3DERR_INVALIDCALL;
if (RenderTargetIndex == 0) {
uint32_t width = std::max(1u, desc->Width >> rt->GetMipLevel());
uint32_t height = std::max(1u, desc->Height >> rt->GetMipLevel());
auto rtSize = rt->GetSurfaceExtent();
D3DVIEWPORT9 viewport;
viewport.X = 0;
viewport.Y = 0;
viewport.Width = width;
viewport.Height = height;
viewport.Width = rtSize.width;
viewport.Height = rtSize.height;
viewport.MinZ = 0.0f;
viewport.MaxZ = 1.0f;
RECT scissorRect;
scissorRect.left = 0;
scissorRect.top = 0;
scissorRect.right = width;
scissorRect.bottom = height;
scissorRect.right = rtSize.width;
scissorRect.bottom = rtSize.height;
if (m_state.viewport != viewport) {
m_flags.set(D3D9DeviceFlag::DirtyFFViewport);
......@@ -1398,11 +1397,10 @@ namespace dxvk {
// This works around that.
uint32_t alignment = m_d3d9Options.lenientClear ? 8 : 1;
uint32_t rt0Width = std::max(1u, rt0Desc->Width >> m_state.renderTargets[0]->GetMipLevel());
uint32_t rt0Height = std::max(1u, rt0Desc->Height >> m_state.renderTargets[0]->GetMipLevel());
auto rtSize = m_state.renderTargets[0]->GetSurfaceExtent();
bool extentMatches = align(extent.width, alignment) == align(rt0Width, alignment)
&& align(extent.height, alignment) == align(rt0Height, alignment);
bool extentMatches = align(extent.width, alignment) == align(rtSize.width, alignment)
&& align(extent.height, alignment) == align(rtSize.height, alignment);
bool rtSizeMatchesClearSize = offset.x == 0 && offset.y == 0 && extentMatches;
......
......@@ -6,6 +6,8 @@
#include "../util/util_gdi.h"
#include <algorithm>
namespace dxvk {
using D3D9GDIDesc = D3DKMT_DESTROYDCFROMMEMORY;
......@@ -45,6 +47,15 @@ namespace dxvk {
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:
D3D9GDIDesc m_dcDesc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment