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;
|
auto p8FormatOp = formatOp.second;
|
||||||
p8FormatOp.Format = D3DDDIFMT_P8;
|
p8FormatOp.Format = D3DDDIFMT_P8;
|
||||||
p8FormatOp.Operations |= FORMATOP_OFFSCREENPLAIN;
|
p8FormatOp.Operations |= FORMATOP_OFFSCREENPLAIN;
|
||||||
if (!Config::palettizedTextures.get())
|
|
||||||
{
|
|
||||||
p8FormatOp.Operations &= ~(FORMATOP_TEXTURE | FORMATOP_VOLUMETEXTURE | FORMATOP_CUBETEXTURE);
|
|
||||||
}
|
|
||||||
fixedFormatOps[D3DDDIFMT_P8] = p8FormatOp;
|
fixedFormatOps[D3DDDIFMT_P8] = p8FormatOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include <Common/Comparison.h>
|
#include <Common/Comparison.h>
|
||||||
#include <Common/CompatPtr.h>
|
#include <Common/CompatPtr.h>
|
||||||
@ -23,6 +22,7 @@
|
|||||||
#include <DDraw/Surfaces/PrimarySurface.h>
|
#include <DDraw/Surfaces/PrimarySurface.h>
|
||||||
#include <DDraw/Surfaces/TagSurface.h>
|
#include <DDraw/Surfaces/TagSurface.h>
|
||||||
#include <DDraw/Visitors/DirectDrawVtblVisitor.h>
|
#include <DDraw/Visitors/DirectDrawVtblVisitor.h>
|
||||||
|
#include <Win32/DisplayMode.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -47,12 +47,15 @@ namespace
|
|||||||
TSurfaceDesc desc = *lpDDSurfaceDesc;
|
TSurfaceDesc desc = *lpDDSurfaceDesc;
|
||||||
if (!D3dDdi::SurfaceRepository::inCreateSurface())
|
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 (&IID_IDirect3DHALDevice == Config::softwareDevice.get())
|
||||||
{
|
{
|
||||||
if ((desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) &&
|
if ((desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) &&
|
||||||
!(desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) &&
|
!(desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) &&
|
||||||
(desc.dwFlags & DDSD_PIXELFORMAT) &&
|
isPalettized)
|
||||||
(DDPF_RGB | DDPF_PALETTEINDEXED8) == desc.ddpfPixelFormat.dwFlags)
|
|
||||||
{
|
{
|
||||||
desc.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
|
desc.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
|
||||||
desc.ddsCaps.dwCaps &= ~DDSCAPS_OFFSCREENPLAIN;
|
desc.ddsCaps.dwCaps &= ~DDSCAPS_OFFSCREENPLAIN;
|
||||||
@ -66,18 +69,28 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config::palettizedTextures.get() &&
|
if (isPalettized && (desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
||||||
(desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) &&
|
|
||||||
!(desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) &&
|
|
||||||
(desc.dwFlags & DDSD_PIXELFORMAT) &&
|
|
||||||
(DDPF_RGB | DDPF_PALETTEINDEXED8) == desc.ddpfPixelFormat.dwFlags)
|
|
||||||
{
|
{
|
||||||
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>(
|
return DDraw::Surface::create<TDirectDraw>(*This, desc, *lplpDDSurface,
|
||||||
*This, desc, *lplpDDSurface, std::make_unique<DDraw::Surface>(desc.dwFlags, desc.ddsCaps.dwCaps));
|
std::make_unique<DDraw::Surface>(desc.dwFlags, lpDDSurfaceDesc->ddsCaps.dwCaps));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename TDirectDraw>
|
template <typename TDirectDraw>
|
||||||
|
@ -91,8 +91,9 @@ namespace DDraw
|
|||||||
CompatRef<TDirectDraw> dd, TSurfaceDesc desc, TSurface*& surface, std::unique_ptr<Surface> privateData)
|
CompatRef<TDirectDraw> dd, TSurfaceDesc desc, TSurface*& surface, std::unique_ptr<Surface> privateData)
|
||||||
{
|
{
|
||||||
if ((desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) &&
|
if ((desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) &&
|
||||||
((desc.dwFlags & DDSD_PIXELFORMAT) && (desc.ddpfPixelFormat.dwRGBBitCount <= 8)) ||
|
((desc.dwFlags & DDSD_PIXELFORMAT)
|
||||||
(!(desc.dwFlags & DDSD_PIXELFORMAT) && Win32::DisplayMode::getBpp() <= 8))
|
? (desc.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
|
||||||
|
: (Win32::DisplayMode::getBpp() <= 8)))
|
||||||
{
|
{
|
||||||
desc.ddsCaps.dwCaps &= ~DDSCAPS_3DDEVICE;
|
desc.ddsCaps.dwCaps &= ~DDSCAPS_3DDEVICE;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <Common/CompatRef.h>
|
#include <Common/CompatRef.h>
|
||||||
#include <Common/CompatVtable.h>
|
#include <Common/CompatVtable.h>
|
||||||
#include <Common/Log.h>
|
#include <Common/Log.h>
|
||||||
|
#include <Config/Settings/PalettizedTextures.h>
|
||||||
#include <Config/Settings/SupportedTextureFormats.h>
|
#include <Config/Settings/SupportedTextureFormats.h>
|
||||||
#include <D3dDdi/Device.h>
|
#include <D3dDdi/Device.h>
|
||||||
#include <D3dDdi/FormatInfo.h>
|
#include <D3dDdi/FormatInfo.h>
|
||||||
@ -27,6 +28,10 @@ namespace
|
|||||||
// and with proper pixel formats these cannot be created in video memory anyway.
|
// and with proper pixel formats these cannot be created in video memory anyway.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ((pf.dwFlags & DDPF_PALETTEINDEXED8) && !Config::palettizedTextures.get())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return Config::supportedTextureFormats.isSupported(D3dDdi::getFormat(pf));
|
return Config::supportedTextureFormats.isSupported(D3dDdi::getFormat(pf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user