mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Fixed software palettized textures when PalettizedTextures is off
Fixes menu corruption in Colin McRae Rally.
This commit is contained in:
parent
383ffd28b9
commit
9eba917e09
@ -145,10 +145,6 @@ namespace D3dDdi
|
||||
auto p8FormatOp = formatOp.second;
|
||||
p8FormatOp.Format = D3DDDIFMT_P8;
|
||||
p8FormatOp.Operations |= FORMATOP_OFFSCREENPLAIN;
|
||||
if (!Config::palettizedTextures.get())
|
||||
{
|
||||
p8FormatOp.Operations &= ~(FORMATOP_TEXTURE | FORMATOP_VOLUMETEXTURE | FORMATOP_CUBETEXTURE);
|
||||
}
|
||||
fixedFormatOps[D3DDDIFMT_P8] = p8FormatOp;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
#include <Common/Comparison.h>
|
||||
#include <Common/CompatPtr.h>
|
||||
@ -23,6 +22,7 @@
|
||||
#include <DDraw/Surfaces/PrimarySurface.h>
|
||||
#include <DDraw/Surfaces/TagSurface.h>
|
||||
#include <DDraw/Visitors/DirectDrawVtblVisitor.h>
|
||||
#include <Win32/DisplayMode.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -47,12 +47,15 @@ namespace
|
||||
TSurfaceDesc desc = *lpDDSurfaceDesc;
|
||||
if (!D3dDdi::SurfaceRepository::inCreateSurface())
|
||||
{
|
||||
const bool isPalettized = (desc.dwFlags & DDSD_PIXELFORMAT)
|
||||
? (desc.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
|
||||
: (Win32::DisplayMode::getBpp() <= 8);
|
||||
|
||||
if (&IID_IDirect3DHALDevice == Config::softwareDevice.get())
|
||||
{
|
||||
if ((desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) &&
|
||||
!(desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) &&
|
||||
(desc.dwFlags & DDSD_PIXELFORMAT) &&
|
||||
(DDPF_RGB | DDPF_PALETTEINDEXED8) == desc.ddpfPixelFormat.dwFlags)
|
||||
isPalettized)
|
||||
{
|
||||
desc.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
|
||||
desc.ddsCaps.dwCaps &= ~DDSCAPS_OFFSCREENPLAIN;
|
||||
@ -66,18 +69,28 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
if (Config::palettizedTextures.get() &&
|
||||
(desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) &&
|
||||
!(desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) &&
|
||||
(desc.dwFlags & DDSD_PIXELFORMAT) &&
|
||||
(DDPF_RGB | DDPF_PALETTEINDEXED8) == desc.ddpfPixelFormat.dwFlags)
|
||||
if (isPalettized && (desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
||||
{
|
||||
return DDraw::PalettizedTexture::create<TDirectDraw>(*This, desc, *lplpDDSurface);
|
||||
if (Config::palettizedTextures.get())
|
||||
{
|
||||
if (!(desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY))
|
||||
{
|
||||
return DDraw::PalettizedTexture::create<TDirectDraw>(*This, desc, *lplpDDSurface);
|
||||
}
|
||||
}
|
||||
else if (desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
|
||||
{
|
||||
return DDERR_UNSUPPORTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
desc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DDraw::Surface::create<TDirectDraw>(
|
||||
*This, desc, *lplpDDSurface, std::make_unique<DDraw::Surface>(desc.dwFlags, desc.ddsCaps.dwCaps));
|
||||
return DDraw::Surface::create<TDirectDraw>(*This, desc, *lplpDDSurface,
|
||||
std::make_unique<DDraw::Surface>(desc.dwFlags, lpDDSurfaceDesc->ddsCaps.dwCaps));
|
||||
}
|
||||
|
||||
template <typename TDirectDraw>
|
||||
|
@ -91,8 +91,9 @@ namespace DDraw
|
||||
CompatRef<TDirectDraw> dd, TSurfaceDesc desc, TSurface*& surface, std::unique_ptr<Surface> privateData)
|
||||
{
|
||||
if ((desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) &&
|
||||
((desc.dwFlags & DDSD_PIXELFORMAT) && (desc.ddpfPixelFormat.dwRGBBitCount <= 8)) ||
|
||||
(!(desc.dwFlags & DDSD_PIXELFORMAT) && Win32::DisplayMode::getBpp() <= 8))
|
||||
((desc.dwFlags & DDSD_PIXELFORMAT)
|
||||
? (desc.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
|
||||
: (Win32::DisplayMode::getBpp() <= 8)))
|
||||
{
|
||||
desc.ddsCaps.dwCaps &= ~DDSCAPS_3DDEVICE;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <Common/CompatRef.h>
|
||||
#include <Common/CompatVtable.h>
|
||||
#include <Common/Log.h>
|
||||
#include <Config/Settings/PalettizedTextures.h>
|
||||
#include <Config/Settings/SupportedTextureFormats.h>
|
||||
#include <D3dDdi/Device.h>
|
||||
#include <D3dDdi/FormatInfo.h>
|
||||
@ -27,6 +28,10 @@ namespace
|
||||
// and with proper pixel formats these cannot be created in video memory anyway.
|
||||
return false;
|
||||
}
|
||||
if ((pf.dwFlags & DDPF_PALETTEINDEXED8) && !Config::palettizedTextures.get())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Config::supportedTextureFormats.isSupported(D3dDdi::getFormat(pf));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user