[PATCH] dxgi: 0 / 0 means 0 for a DXGI_RATIONAL
Eduard - Gabriel Munteanu
eduard.munteanu at linux360.ro
Mon Nov 21 17:42:18 CST 2011
This fixes a division by zero generated in Unigine Tropics in D3D10
mode. It also adds a helper to handle such conversions, which takes the
form of a macro so we don't need to worry about the result's type.
Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu at linux360.ro>
---
dlls/dxgi/dxgi_private.h | 4 ++++
dlls/dxgi/factory.c | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h
index 047e083..2d86ae9 100644
--- a/dlls/dxgi/dxgi_private.h
+++ b/dlls/dxgi/dxgi_private.h
@@ -74,6 +74,10 @@ const char *debug_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN;
enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN;
+/* Helper for converting from DXGI_RATIONAL. */
+#define DXGI_FROM_NUM_DEN(num, den) ((num) == (den) && !(den) ? 0 : (num) / (den))
+#define DXGI_FROM_RATIONAL(rat) DXGI_FROM_NUM_DEN((rat).Numerator, (rat).Denominator)
+
/* IDXGIFactory */
struct dxgi_factory
{
diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c
index c7a11cf..2a910bd 100644
--- a/dlls/dxgi/factory.c
+++ b/dlls/dxgi/factory.c
@@ -221,7 +221,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *
present_parameters.AutoDepthStencilFormat = 0;
present_parameters.Flags = 0; /* WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL? */
present_parameters.FullScreen_RefreshRateInHz =
- desc->BufferDesc.RefreshRate.Numerator / desc->BufferDesc.RefreshRate.Denominator;
+ DXGI_FROM_RATIONAL(desc->BufferDesc.RefreshRate);
present_parameters.PresentationInterval = WINED3DPRESENT_INTERVAL_DEFAULT;
hr = wined3d_device_init_3d(wined3d_device, &present_parameters);
--
1.7.3.4
More information about the wine-patches
mailing list