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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
On recent drivers, double buffered DirectDraw flips no longer wait for the
vertical sync before returning and instead just insert the flip into the
flip queue for later execution. This effectively results in triple buffered
behavior (in the render-ahead sense) and causes up to an extra frame of
latency even if the flip queue size is set to 1.
To restore the legacy double buffered behavior, each flip waits for the
presented frame to leave the flip queue before returning.
To restore the legacy triple buffered behavior, the flip queue size is
forced to 1. This causes the flip to wait if the previous flip is still
pending.
Video memory render target surfaces get an additional video memory off-screen
plain surface used for providing efficient direct memory access (locking).
All 2D operations starting with a lock are redirected to the off-screen plain
surface until the next rendering operation requires the render target surface.
The two surfaces are kept in sync via blits as needed.
Fixes performance issues in Rogue Spear menus, mentioned in issue #2.
Disabled the indication of mirrored blit support via the driver GetCaps routine
as this may be reported as supported on modern GPUs even when it's not.
Removing this indication allows the HEL (Hardware Emulation Layer) to correctly
handle all mirrored blits. It also seems to perform better than the previous
clumsy line-by-line mirroring emulation.
This flag forces linear (non-swizzled) surface layout on Intel HD drivers.
Fixes issues with games that keep writing to unlocked surfaces (e.g. Nox)
as well as greatly increases lock performance.
This change assigns a different DirectDraw repository object for each original
DirectDraw object that requires temporary surfaces, ensuring that video memory
surfaces are created on the appropriate device on a multi-GPU system.