1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

203 Commits

Author SHA1 Message Date
narzoul
727be63db1 Implement GDI system palette emulation 2018-12-31 20:31:58 +01:00
narzoul
12e78aab84 Moved presentation windows to dedicated thread 2018-12-08 21:58:19 +01:00
narzoul
906ef5ebe2 Added ReleaseWithDebugLogs configuration 2018-12-08 21:58:18 +01:00
narzoul
cd674d54c8 Fixed potential deadlocks during WM_ACTIVATEAPP 2018-12-08 21:57:15 +01:00
narzoul
7785133d02 Improved GDI performance 2018-12-08 21:57:14 +01:00
narzoul
c53ffab664 Indented function logging 2018-12-08 21:57:14 +01:00
narzoul
58aba66ca2 Hook all GDI threads 2018-12-08 21:57:13 +01:00
narzoul
4717b9aa1b Fixed caret display issues 2018-12-08 21:57:12 +01:00
narzoul
2f00b74a56 Fixed display issues with user32 controls 2018-12-08 21:57:12 +01:00
narzoul
537ef9c595 Improved presentation scheduling
Fixes cursor flickering issues in Siege of Avalon (issue #34)
and multimon flip issues on Windows 8.1 (issue #28).
2018-12-08 21:57:09 +01:00
narzoul
e69b5e312c Moved common macros to compiler options 2018-12-08 21:53:41 +01:00
narzoul
785663700d Separate GDI and DirectDraw surfaces 2018-12-08 21:53:40 +01:00
narzoul
6183aed7da Optimize GDI redraw on window position changes 2018-12-08 21:53:38 +01:00
narzoul
7cbc65878a Update visible regions of all top-level windows on pos changes 2018-12-08 21:53:38 +01:00
narzoul
1ee48b11df Enable GDI emulation in windowed mode 2018-12-08 21:53:38 +01:00
narzoul
c384167244 Removed layered windows from DirectDraw primary surface 2018-12-08 21:53:31 +01:00
narzoul
5770c990ed Fixed GDI resource handle initialization 2018-03-17 13:11:45 +01:00
narzoul
335d093cb9 Fixed palette issues with GetDC on primary surface 2018-03-12 21:02:28 +01:00
narzoul
6c34bbb437 Fixed QueryInterface on same interface
Because multiple DirectDraw interface versions may share the same
method implementations, CompatVtable may dispatch calls to an earlier
interface where that method implementation was already hooked.

Therefore a call to QueryInterface is needed even if the method
thinks the result will be the same interface type; a simple
AddRef may not have the same effect.
2018-02-27 20:21:04 +01:00
narzoul
39d148e3ba Aggregate render target locks 2018-02-03 17:02:32 +01:00
narzoul
60c3c4f153 Mitigate performance issues caused by slow surface interface release
Releasing the last reference to a surface interface has a significant
performance impact. Mitigating the issue by eliminating some frequent
but unnecessary QueryInterface calls.

Fixes most of the performance drop reported in issue #24.
2017-11-18 22:43:55 +01:00
narzoul
3f1fa0fae1 Updated windowed mode presentation to use multiple window-clipped blits
Windowed mode presentation is changed to use a series of blits clipped to
each top level window to work around performance issues when a clipper uses
a clip list instead of a window. Otherwise DirectDraw uses StretchBlt rather
than the driver Present call even if the clip list is a single rectangle
matching the window client area.

Fixes a performance issue reported in issue #24.
2017-11-18 22:36:31 +01:00
narzoul
46f71be51a Removed CpuOptimized flag on off-screen plain surfaces
Fixes a black screen issue on some Intel GPU drivers, reported in issue #23.
2017-11-05 13:20:38 +01:00
narzoul
cff2b7e1eb Updated project to VS2017 and latest SDK/WDK (10.0.16299.0) 2017-11-05 13:14:13 +01:00
narzoul
4dc1c70f41 Fix pixel W-fog when projection matrix is not set
When the 3D projection matrix is not set (transformation is performed in
software), pixel (table) fog effects appear to be missing on some drivers.

The matrix itself normally isn't passed to the user mode SetTransform
driver function anyway due to the fixed-function shader converters being
enabled by default. Instead only UpdateWInfo is called with the W-range
calculated from the matrix.

For the initial identity matrix, UpdateWInfo receives the range (1.0, 1.0).
This seems to cause Intel (HD 4600) drivers to interpret pixel fog ranges as
Z-depth values, while with any other range specified eye-relative (W) depth
is used. The actual values otherwise don't seem to matter with respect to
how fog is rendered.
On AMD (RX 480), eye-relative depth is used irrespective of the W-range.
There is currently no information on how NVIDIA drivers behave, except that
with the default W-range no fog seems to be produced.

This fix replaces the W-range (1.0, 1.0) with (0.0, 1.0) which causes Intel
to also interpret fog range in eye-relative depth with the default identity
projection matrix.

Fixes missing fog on Intel HD (and hopefully NVIDIA) in Combat Mission
games reported in issue #20.
2017-08-21 22:26:44 +02:00
narzoul
8ab8058ceb Fix reported memory caps of primary surface
Changed primary surface caps to report video memory in case the surface
was only forced into system memory by DDrawCompat.

Fixes startup issues in C&C 95 and Red Alert, reported in issue #3.
2017-08-06 21:42:24 +02:00
narzoul
e3396a18b8 Support for COM instantiation
Added proper installation of hooks when DirectDraw interfaces are instantiated
through the COM API (e.g. with CoCreateInstance).

Fixes a crash in Warhammer 40,000: Chaos Gate mentioned in issue #15.
2017-08-05 11:32:28 +02:00
narzoul
947bb41bf3 Emulate flip when the primary surface is requested in system memory
When the primary surface chain is requested to be created in system memory,
flip should be emulated (copy from back buffer to front buffer) to be
consistent with legacy DirectDraw behavior.

Fixes flashing graphical artifacts in Carmageddon (Win95 version) menus
when exiting from a race, mentioned in issue #3.
2017-07-25 21:27:40 +02:00
narzoul
b78446c16f Hook IDirect3DDevice7 only if needed
Creating an instance of the IDirect3DDevice7 interface appears to cause
problems in some games that use only older versions of Direct3D.
IDirect3DDevice7 is now only hooked when an application creates an instance.

Fixes video playback artifacts in Populous: The Beginning.
Fixes a crash in Carmageddon (Win95 version) reported in issue #3.
2017-07-23 12:00:09 +02:00
narzoul
1af227afc4 Fixed display of check boxes and radio buttons
Fixes an issue with missing icons on check/radio buttons, reported in
issue #15.
2017-07-20 20:55:32 +02:00
narzoul
c63d36d831 Fixed issue with GDI controls not always being visible
Reverted an earlier optimization that tried to handle WM_ERASEBKGND and
WM_PAINT events in a single update cycle for reduced flickering.
It caused some child controls to not display properly.

Fixes an issue reported in #15.
2017-07-16 22:47:19 +02:00
narzoul
d2adc5c811 Fixed incorrect primary update schedule when updates are disabled/enabled 2017-07-16 22:47:14 +02:00
narzoul
6a2255160f Add extra rows to system memory primary surface buffers
Fixes a memory corruption issue in Diablo 1, reported in issue #3.
2017-07-15 12:47:08 +02:00
narzoul
5668bf7c35 Repaint scrolled area when smooth scrolling is disabled
When the SW_SMOOTHSCROLL flag is removed in ScrollWindowEx, it needs to be
replaced with SW_ERASE and SW_INVALIDATE to properly repaint the scrolled
portions of the window.

Fixes an issue reported in #16.
2017-07-14 11:31:55 +02:00
narzoul
ab7271b986 Disable primary surface updates during display mode change 2017-07-02 16:38:31 +02:00
narzoul
c81c12df84 Redirect gamma controls to the real primary surface 2017-06-05 16:35:50 +02:00
narzoul
4b02a40bc9 Hooked the IDirectDrawGammaControl interface 2017-06-05 16:35:48 +02:00
narzoul
5c91706b03 Fixed black screen issue with Windows 10 Creators Update
Also added v-sync to direct primary surface updates (i.e. those that are
not using a back buffer and flip).

Fixes issues #3 and #15.
2017-06-05 16:35:32 +02:00
narzoul
640f746633 Implement 8/16 bit display mode emulation
8/16 bit display mode emulation is now implemented internally instead of
relying on the builtin Windows shims, as those are sometimes unreliable
(not triggering for some games on some systems when they should).

External DirectDraw hooks (such as the DWM8And16BitMitigation shim)
are disabled to avoid interference.

Fixes issues reported in #8, #9, #15.
2017-05-28 15:40:33 +02:00
narzoul
672b3b640f Fixed handling of IDirectDrawClipper window clip lists
DirectDraw does not properly update the clip lists of IDirectDrawClipper
objects that are using window handles. (Probably it only tracks child window
changes and not other overlapping windows when composition is enabled).

Clip lists are now manually calculated and updated on window position
changes instead.

Fixes "invisible" GDI windows in O2Jam (issue #9).
2017-05-28 12:43:51 +02:00
narzoul
5195a5e4b4 Minimize GDI redraws on window position changes
When the display mode changes in full screen mode, DirectDraw resets
the main window to topmost after a short delay, generating a
WM_WINDOWPOSCHANGED message. This could cause an unnecessary repainting
of the window, erasing the background even if nothing needed to be updated.

Now only the regions that change during window repositioning are redrawn.

Fixes the black flashing in Rogue Spear's menus after display mode changes,
mentioned in issue #2.
2017-05-28 12:43:43 +02:00
narzoul
d1cd72b304 Hooked the IDirectDrawClipper interface 2017-05-20 11:34:28 +02:00
narzoul
cd22b333e3 Support oversized surfaces in system memory
AMD drivers reject system memory surfaces that are larger than the maximum
texture width/height supported by the driver (usually 4096x4096 for AMD).
This can cause issues in games that create larger system memory surfaces.

This workaround crops the driver resource dimensions to the allowed
maximum values and handles blitting outside this region by creating a
temporary resource that maps to the actual affected system memory region.

Fixes crashes with AMD drivers in Rainbow Six games and Desperados,
mentioned in issue #2 and #8.
2017-02-18 18:53:53 +01:00
narzoul
60129a1000 Suppress the ForceDirectDrawEmulation compatibility shim 2016-12-27 17:31:48 +01:00
narzoul
8818d5b136 Fixed improper linking to functions not available in Windows Vista 2016-12-23 19:53:36 +01:00
narzoul
347713cdce Create off-screen plain surfaces in system memory
Fixes performance issues with Desperados mentioned in issue #5
(possibly #8 as well).
2016-12-22 20:49:12 +01:00
narzoul
1c82165214 Call window procedures through CallWindowProc 2016-12-22 20:49:06 +01:00
narzoul
26995d6108 Create palettized surfaces in system memory 2016-12-22 20:49:00 +01:00
narzoul
e6bb6b1e35 Fixed logging of uninitialized output parameters 2016-12-22 20:48:40 +01:00
narzoul
5b5863b028 Fixed various alt-tabbing issues 2016-12-20 18:52:50 +01:00