mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Log used resource formats
This commit is contained in:
parent
15d78048d0
commit
25f325ec17
@ -1,7 +1,11 @@
|
|||||||
|
#include <map>
|
||||||
|
|
||||||
#include <D3dDdi/FormatInfo.h>
|
#include <D3dDdi/FormatInfo.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
DDPIXELFORMAT getPixelFormat(const D3dDdi::FormatInfo& info);
|
||||||
|
|
||||||
struct ArgbColor
|
struct ArgbColor
|
||||||
{
|
{
|
||||||
BYTE blue;
|
BYTE blue;
|
||||||
@ -10,85 +14,164 @@ namespace
|
|||||||
BYTE alpha;
|
BYTE alpha;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RgbFormatInfo : D3dDdi::FormatInfo
|
struct FormatInfoBuilder : D3dDdi::FormatInfo
|
||||||
{
|
{
|
||||||
RgbFormatInfo(BYTE unusedBitCount, BYTE alphaBitCount, BYTE redBitCount, BYTE greenBitCount, BYTE blueBitCount)
|
void setComponent(D3dDdi::FormatInfo::Component& component, BYTE bitCount)
|
||||||
: FormatInfo(unusedBitCount, alphaBitCount, redBitCount, greenBitCount, blueBitCount)
|
|
||||||
{
|
{
|
||||||
red.pos = greenBitCount + blueBitCount;
|
component.pos = bitsPerPixel;
|
||||||
green.pos = blueBitCount;
|
component.bitCount = bitCount;
|
||||||
|
bitsPerPixel += bitCount;
|
||||||
|
bytesPerPixel = (bitsPerPixel + 7) / 8;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BgrFormatInfo : D3dDdi::FormatInfo
|
struct FormatInfoXARGB : FormatInfoBuilder
|
||||||
{
|
{
|
||||||
BgrFormatInfo(BYTE unusedBitCount, BYTE alphaBitCount, BYTE blueBitCount, BYTE greenBitCount, BYTE redBitCount)
|
FormatInfoXARGB::FormatInfoXARGB(BYTE x, BYTE a, BYTE r, BYTE g, BYTE b)
|
||||||
: FormatInfo(unusedBitCount, alphaBitCount, redBitCount, greenBitCount, blueBitCount)
|
|
||||||
{
|
{
|
||||||
green.pos = redBitCount;
|
setComponent(blue, b);
|
||||||
blue.pos = redBitCount + greenBitCount;
|
setComponent(green, g);
|
||||||
|
setComponent(red, r);
|
||||||
|
setComponent(alpha, a);
|
||||||
|
setComponent(unused, x);
|
||||||
|
pixelFormat = getPixelFormat(*this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DxsFormatInfo : D3dDdi::FormatInfo
|
struct FormatInfoXABGR : FormatInfoBuilder
|
||||||
{
|
{
|
||||||
DxsFormatInfo(BYTE depthBitCount, BYTE unusedBitCount, BYTE stencilBitCount)
|
FormatInfoXABGR::FormatInfoXABGR(BYTE x, BYTE a, BYTE b, BYTE g, BYTE r)
|
||||||
: FormatInfo(unusedBitCount, depthBitCount, stencilBitCount)
|
|
||||||
{
|
{
|
||||||
depth.pos = unusedBitCount + stencilBitCount;
|
setComponent(red, r);
|
||||||
unused.pos = stencilBitCount;
|
setComponent(green, g);
|
||||||
|
setComponent(blue, b);
|
||||||
|
setComponent(alpha, a);
|
||||||
|
setComponent(unused, x);
|
||||||
|
pixelFormat = getPixelFormat(*this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct XsdFormatInfo : D3dDdi::FormatInfo
|
struct FormatInfoAP : FormatInfoBuilder
|
||||||
{
|
{
|
||||||
XsdFormatInfo(BYTE unusedBitCount, BYTE stencilBitCount, BYTE depthBitCount)
|
FormatInfoAP::FormatInfoAP(BYTE a, BYTE p)
|
||||||
: FormatInfo(unusedBitCount, depthBitCount, stencilBitCount)
|
|
||||||
{
|
{
|
||||||
unused.pos = stencilBitCount + depthBitCount;
|
setComponent(palette, p);
|
||||||
stencil.pos = depthBitCount;
|
setComponent(alpha, a);
|
||||||
|
pixelFormat = getPixelFormat(*this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FormatInfoDXS : FormatInfoBuilder
|
||||||
|
{
|
||||||
|
FormatInfoDXS::FormatInfoDXS(BYTE d, BYTE x, BYTE s)
|
||||||
|
{
|
||||||
|
setComponent(stencil, s);
|
||||||
|
setComponent(unused, x);
|
||||||
|
setComponent(depth, d);
|
||||||
|
pixelFormat = getPixelFormat(*this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FormatInfoXSD : FormatInfoBuilder
|
||||||
|
{
|
||||||
|
FormatInfoXSD::FormatInfoXSD(BYTE x, BYTE s, BYTE d)
|
||||||
|
{
|
||||||
|
setComponent(depth, d);
|
||||||
|
setComponent(stencil, s);
|
||||||
|
setComponent(unused, x);
|
||||||
|
pixelFormat = getPixelFormat(*this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FormatInfoXALVU : FormatInfoBuilder
|
||||||
|
{
|
||||||
|
FormatInfoXALVU::FormatInfoXALVU(BYTE x, BYTE a, BYTE l, BYTE v, BYTE u)
|
||||||
|
{
|
||||||
|
setComponent(du, u);
|
||||||
|
setComponent(dv, v);
|
||||||
|
setComponent(luminance, l);
|
||||||
|
setComponent(alpha, a);
|
||||||
|
setComponent(unused, x);
|
||||||
|
pixelFormat = getPixelFormat(*this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::map<D3DDDIFORMAT, D3dDdi::FormatInfo> g_formatInfo = {
|
||||||
|
{ D3DDDIFMT_R8G8B8, FormatInfoXARGB(0, 0, 8, 8, 8) },
|
||||||
|
{ D3DDDIFMT_A8R8G8B8, FormatInfoXARGB(0, 8, 8, 8, 8) },
|
||||||
|
{ D3DDDIFMT_X8R8G8B8, FormatInfoXARGB(8, 0, 8, 8, 8) },
|
||||||
|
{ D3DDDIFMT_R5G6B5, FormatInfoXARGB(0, 0, 5, 6, 5) },
|
||||||
|
{ D3DDDIFMT_X1R5G5B5, FormatInfoXARGB(1, 0, 5, 5, 5) },
|
||||||
|
{ D3DDDIFMT_A1R5G5B5, FormatInfoXARGB(0, 1, 5, 5, 5) },
|
||||||
|
{ D3DDDIFMT_A4R4G4B4, FormatInfoXARGB(0, 4, 4, 4, 4) },
|
||||||
|
{ D3DDDIFMT_R3G3B2, FormatInfoXARGB(0, 0, 3, 3, 2) },
|
||||||
|
{ D3DDDIFMT_A8, FormatInfoXARGB(0, 8, 0, 0, 0) },
|
||||||
|
{ D3DDDIFMT_A8R3G3B2, FormatInfoXARGB(0, 8, 3, 3, 2) },
|
||||||
|
{ D3DDDIFMT_X4R4G4B4, FormatInfoXARGB(4, 0, 4, 4, 4) },
|
||||||
|
|
||||||
|
{ D3DDDIFMT_A8B8G8R8, FormatInfoXABGR(0, 8, 8, 8, 8) },
|
||||||
|
{ D3DDDIFMT_X8B8G8R8, FormatInfoXABGR(8, 0, 8, 8, 8) },
|
||||||
|
|
||||||
|
{ D3DDDIFMT_A8P8, FormatInfoAP(8, 8) },
|
||||||
|
{ D3DDDIFMT_P8, FormatInfoAP(0, 8) },
|
||||||
|
|
||||||
|
{ D3DDDIFMT_L8, FormatInfoXALVU(0, 0, 8, 0, 0) },
|
||||||
|
{ D3DDDIFMT_A8L8, FormatInfoXALVU(0, 8, 8, 0, 0) },
|
||||||
|
{ D3DDDIFMT_A4L4, FormatInfoXALVU(0, 4, 4, 0, 0) },
|
||||||
|
|
||||||
|
{ D3DDDIFMT_V8U8, FormatInfoXALVU(0, 0, 0, 8, 8) },
|
||||||
|
{ D3DDDIFMT_L6V5U5, FormatInfoXALVU(0, 0, 6, 5, 5) },
|
||||||
|
{ D3DDDIFMT_X8L8V8U8, FormatInfoXALVU(8, 0, 8, 8, 8) },
|
||||||
|
|
||||||
|
{ D3DDDIFMT_D32, FormatInfoDXS(32, 0, 0) },
|
||||||
|
{ D3DDDIFMT_D15S1, FormatInfoDXS(15, 0, 1) },
|
||||||
|
{ D3DDDIFMT_D24S8, FormatInfoDXS(24, 0, 8) },
|
||||||
|
{ D3DDDIFMT_D24X8, FormatInfoDXS(24, 8, 0) },
|
||||||
|
{ D3DDDIFMT_D16, FormatInfoDXS(16, 0, 0) },
|
||||||
|
|
||||||
|
{ D3DDDIFMT_S1D15, FormatInfoXSD(0, 1, 15) },
|
||||||
|
{ D3DDDIFMT_S8D24, FormatInfoXSD(0, 8, 24) },
|
||||||
|
{ D3DDDIFMT_X8D24, FormatInfoXSD(8, 0, 24) },
|
||||||
|
};
|
||||||
|
|
||||||
DWORD getMask(const D3dDdi::FormatInfo::Component& component)
|
DWORD getMask(const D3dDdi::FormatInfo::Component& component)
|
||||||
{
|
{
|
||||||
return ((1 << component.bitCount) - 1) << component.pos;
|
return ((1ULL << component.bitCount) - 1) << component.pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
DDPIXELFORMAT getPixelFormat(const D3dDdi::FormatInfo& info)
|
||||||
|
{
|
||||||
|
DDPIXELFORMAT pf = {};
|
||||||
|
pf.dwSize = sizeof(pf);
|
||||||
|
pf.dwFlags =
|
||||||
|
(info.alpha.bitCount ? (info.alpha.bitCount == info.bitsPerPixel ? DDPF_ALPHA : DDPF_ALPHAPIXELS) : 0) |
|
||||||
|
((info.red.bitCount || info.palette.bitCount) ? DDPF_RGB : 0) |
|
||||||
|
(info.palette.bitCount ? DDPF_PALETTEINDEXED8 : 0) |
|
||||||
|
(info.depth.bitCount ? DDPF_ZBUFFER : 0) |
|
||||||
|
(info.stencil.bitCount ? DDPF_STENCILBUFFER : 0) |
|
||||||
|
(info.luminance.bitCount ? (info.du.bitCount ? DDPF_BUMPLUMINANCE : DDPF_LUMINANCE) : 0) |
|
||||||
|
(info.du.bitCount ? DDPF_BUMPDUDV : 0);
|
||||||
|
pf.dwRGBBitCount = info.bitsPerPixel;
|
||||||
|
|
||||||
|
pf.dwRGBAlphaBitMask = info.alpha.bitCount == info.bitsPerPixel ? 0 : getMask(info.alpha);
|
||||||
|
pf.dwRBitMask = getMask(info.red);
|
||||||
|
pf.dwGBitMask = getMask(info.green);
|
||||||
|
pf.dwBBitMask = getMask(info.blue);
|
||||||
|
|
||||||
|
pf.dwStencilBitDepth |= info.stencil.bitCount;
|
||||||
|
pf.dwZBitMask |= getMask(info.depth);
|
||||||
|
pf.dwStencilBitMask |= getMask(info.stencil);
|
||||||
|
|
||||||
|
pf.dwLuminanceBitMask |= info.du.bitCount ? 0 : getMask(info.luminance);
|
||||||
|
pf.dwBumpDuBitMask |= getMask(info.du);
|
||||||
|
pf.dwBumpDvBitMask |= getMask(info.dv);
|
||||||
|
pf.dwBumpLuminanceBitMask |= info.du.bitCount ? getMask(info.luminance) : 0;
|
||||||
|
return pf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace D3dDdi
|
namespace D3dDdi
|
||||||
{
|
{
|
||||||
FormatInfo::FormatInfo()
|
|
||||||
{
|
|
||||||
memset(this, 0, sizeof(*this));
|
|
||||||
}
|
|
||||||
|
|
||||||
FormatInfo::FormatInfo(BYTE unusedBitCount, BYTE alphaBitCount, BYTE redBitCount, BYTE greenBitCount, BYTE blueBitCount)
|
|
||||||
: bitsPerPixel(unusedBitCount + alphaBitCount + redBitCount + greenBitCount + blueBitCount)
|
|
||||||
, bytesPerPixel((bitsPerPixel + 7) / 8)
|
|
||||||
, unused{ unusedBitCount, static_cast<BYTE>(alphaBitCount + redBitCount + greenBitCount + blueBitCount) }
|
|
||||||
, alpha{ alphaBitCount, static_cast<BYTE>(redBitCount + greenBitCount + blueBitCount) }
|
|
||||||
, red{ redBitCount, 0 }
|
|
||||||
, green{ greenBitCount, 0 }
|
|
||||||
, blue{ blueBitCount, 0 }
|
|
||||||
, depth{}
|
|
||||||
, stencil{}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
FormatInfo::FormatInfo(BYTE unusedBitCount, BYTE depthBitCount, BYTE stencilBitCount)
|
|
||||||
: bitsPerPixel(unusedBitCount + depthBitCount + stencilBitCount)
|
|
||||||
, bytesPerPixel((bitsPerPixel + 7) / 8)
|
|
||||||
, unused{ unusedBitCount, 0 }
|
|
||||||
, alpha{}
|
|
||||||
, red{}
|
|
||||||
, green{}
|
|
||||||
, blue{}
|
|
||||||
, depth{ depthBitCount, 0 }
|
|
||||||
, stencil{ stencilBitCount, 0 }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
D3DCOLOR convertFrom32Bit(const FormatInfo& dstFormatInfo, D3DCOLOR srcColor)
|
D3DCOLOR convertFrom32Bit(const FormatInfo& dstFormatInfo, D3DCOLOR srcColor)
|
||||||
{
|
{
|
||||||
auto& src = *reinterpret_cast<ArgbColor*>(&srcColor);
|
auto& src = *reinterpret_cast<ArgbColor*>(&srcColor);
|
||||||
@ -96,12 +179,12 @@ namespace D3dDdi
|
|||||||
BYTE alpha = src.alpha >> (8 - dstFormatInfo.alpha.bitCount);
|
BYTE alpha = src.alpha >> (8 - dstFormatInfo.alpha.bitCount);
|
||||||
BYTE red = src.red >> (8 - dstFormatInfo.red.bitCount);
|
BYTE red = src.red >> (8 - dstFormatInfo.red.bitCount);
|
||||||
BYTE green = src.green >> (8 - dstFormatInfo.green.bitCount);
|
BYTE green = src.green >> (8 - dstFormatInfo.green.bitCount);
|
||||||
BYTE blue = src.blue >> (8 - dstFormatInfo.blue.bitCount);
|
BYTE blue = src.blue >> (8 - (dstFormatInfo.blue.bitCount | dstFormatInfo.palette.bitCount));
|
||||||
|
|
||||||
return (alpha << dstFormatInfo.alpha.pos) |
|
return (alpha << dstFormatInfo.alpha.pos) |
|
||||||
(red << dstFormatInfo.red.pos) |
|
(red << dstFormatInfo.red.pos) |
|
||||||
(green << dstFormatInfo.green.pos) |
|
(green << dstFormatInfo.green.pos) |
|
||||||
(blue << dstFormatInfo.blue.pos);
|
(blue << (dstFormatInfo.blue.pos | dstFormatInfo.palette.pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceState::ShaderConstF convertToShaderConst(const FormatInfo& srcFormatInfo, D3DCOLOR srcColor)
|
DeviceState::ShaderConstF convertToShaderConst(const FormatInfo& srcFormatInfo, D3DCOLOR srcColor)
|
||||||
@ -130,86 +213,39 @@ namespace D3dDdi
|
|||||||
return static_cast<float>((color & mask) >> component.pos) / max;
|
return static_cast<float>((color & mask) >> component.pos) / max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
D3DDDIFORMAT getFormat(const DDPIXELFORMAT& pixelFormat)
|
||||||
|
{
|
||||||
|
if (pixelFormat.dwFlags & DDPF_FOURCC)
|
||||||
|
{
|
||||||
|
return static_cast<D3DDDIFORMAT>(pixelFormat.dwFourCC);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& info : g_formatInfo)
|
||||||
|
{
|
||||||
|
if (0 == memcmp(&info.second.pixelFormat, &pixelFormat, sizeof(pixelFormat)))
|
||||||
|
{
|
||||||
|
return info.first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DDPIXELFORMAT pf = g_formatInfo.at(D3DDDIFMT_X8D24).pixelFormat;
|
||||||
|
pf.dwZBufferBitDepth = 24; // https://bugs.winehq.org/show_bug.cgi?id=22434
|
||||||
|
if (0 == memcmp(&pf, &pixelFormat, sizeof(pixelFormat)))
|
||||||
|
{
|
||||||
|
return D3DDDIFMT_X8D24;
|
||||||
|
}
|
||||||
|
|
||||||
|
return D3DDDIFMT_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
FormatInfo getFormatInfo(D3DDDIFORMAT format)
|
FormatInfo getFormatInfo(D3DDDIFORMAT format)
|
||||||
{
|
{
|
||||||
switch (format)
|
auto it = g_formatInfo.find(format);
|
||||||
{
|
return it != g_formatInfo.end() ? it->second : FormatInfo{};
|
||||||
case D3DDDIFMT_R3G3B2: return RgbFormatInfo(0, 0, 3, 3, 2);
|
|
||||||
case D3DDDIFMT_A8: return RgbFormatInfo(0, 8, 0, 0, 0);
|
|
||||||
case D3DDDIFMT_P8: return RgbFormatInfo(0, 0, 0, 0, 8);
|
|
||||||
case D3DDDIFMT_R8: return RgbFormatInfo(0, 0, 8, 0, 0);
|
|
||||||
|
|
||||||
case D3DDDIFMT_R5G6B5: return RgbFormatInfo(0, 0, 5, 6, 5);
|
|
||||||
case D3DDDIFMT_X1R5G5B5: return RgbFormatInfo(1, 0, 5, 5, 5);
|
|
||||||
case D3DDDIFMT_A1R5G5B5: return RgbFormatInfo(0, 1, 5, 5, 5);
|
|
||||||
case D3DDDIFMT_A4R4G4B4: return RgbFormatInfo(0, 4, 4, 4, 4);
|
|
||||||
case D3DDDIFMT_A8R3G3B2: return RgbFormatInfo(0, 8, 3, 3, 2);
|
|
||||||
case D3DDDIFMT_X4R4G4B4: return RgbFormatInfo(4, 0, 4, 4, 4);
|
|
||||||
case D3DDDIFMT_A8P8: return RgbFormatInfo(0, 8, 0, 0, 8);
|
|
||||||
case D3DDDIFMT_G8R8: return BgrFormatInfo(0, 0, 0, 8, 8);
|
|
||||||
|
|
||||||
case D3DDDIFMT_R8G8B8: return RgbFormatInfo(0, 0, 8, 8, 8);
|
|
||||||
|
|
||||||
case D3DDDIFMT_A8R8G8B8: return RgbFormatInfo(0, 8, 8, 8, 8);
|
|
||||||
case D3DDDIFMT_X8R8G8B8: return RgbFormatInfo(8, 0, 8, 8, 8);
|
|
||||||
case D3DDDIFMT_A8B8G8R8: return BgrFormatInfo(0, 8, 8, 8, 8);
|
|
||||||
case D3DDDIFMT_X8B8G8R8: return BgrFormatInfo(8, 0, 8, 8, 8);
|
|
||||||
|
|
||||||
case D3DDDIFMT_D32: return DxsFormatInfo(32, 0, 0);
|
|
||||||
case D3DDDIFMT_D15S1: return DxsFormatInfo(15, 0, 1);
|
|
||||||
case D3DDDIFMT_D24S8: return DxsFormatInfo(24, 0, 8);
|
|
||||||
case D3DDDIFMT_D24X8: return DxsFormatInfo(24, 8, 0);
|
|
||||||
case D3DDDIFMT_D24X4S4: return DxsFormatInfo(24, 4, 4);
|
|
||||||
case D3DDDIFMT_D16: return DxsFormatInfo(16, 0, 0);
|
|
||||||
case D3DDDIFMT_S1D15: return XsdFormatInfo(0, 1, 15);
|
|
||||||
case D3DDDIFMT_S8D24: return XsdFormatInfo(0, 8, 24);
|
|
||||||
case D3DDDIFMT_X8D24: return XsdFormatInfo(8, 0, 24);
|
|
||||||
case D3DDDIFMT_X4S4D24: return XsdFormatInfo(4, 4, 24);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return FormatInfo();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DDPIXELFORMAT getPixelFormat(D3DDDIFORMAT format)
|
DDPIXELFORMAT getPixelFormat(D3DDDIFORMAT format)
|
||||||
{
|
{
|
||||||
auto info = getFormatInfo(format);
|
return getFormatInfo(format).pixelFormat;
|
||||||
if (0 == info.bytesPerPixel)
|
|
||||||
{
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
DDPIXELFORMAT pf = {};
|
|
||||||
pf.dwSize = sizeof(pf);
|
|
||||||
if (0 != info.depth.bitCount)
|
|
||||||
{
|
|
||||||
pf.dwFlags = DDPF_ZBUFFER;
|
|
||||||
pf.dwZBufferBitDepth = info.depth.bitCount;
|
|
||||||
pf.dwZBitMask = getMask(info.depth);
|
|
||||||
if (0 != info.stencil.bitCount)
|
|
||||||
{
|
|
||||||
pf.dwFlags |= DDPF_STENCILBUFFER;
|
|
||||||
pf.dwZBufferBitDepth += info.stencil.bitCount;
|
|
||||||
pf.dwStencilBitDepth = info.stencil.bitCount;
|
|
||||||
pf.dwStencilBitMask = getMask(info.stencil);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pf.dwRGBBitCount = info.bitsPerPixel;
|
|
||||||
if (info.bitsPerPixel > info.alpha.bitCount)
|
|
||||||
{
|
|
||||||
pf.dwFlags = DDPF_RGB;
|
|
||||||
pf.dwRBitMask = getMask(info.red);
|
|
||||||
pf.dwGBitMask = getMask(info.green);
|
|
||||||
pf.dwBBitMask = getMask(info.blue);
|
|
||||||
}
|
|
||||||
if (0 != info.alpha.bitCount)
|
|
||||||
{
|
|
||||||
pf.dwFlags |= (0 == pf.dwFlags) ? DDPF_ALPHA : DDPF_ALPHAPIXELS;
|
|
||||||
pf.dwRGBAlphaBitMask = getMask(info.alpha);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pf;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,29 +15,31 @@ namespace D3dDdi
|
|||||||
{
|
{
|
||||||
struct Component
|
struct Component
|
||||||
{
|
{
|
||||||
BYTE bitCount;
|
BYTE bitCount = 0;
|
||||||
BYTE pos;
|
BYTE pos = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
BYTE bitsPerPixel;
|
BYTE bitsPerPixel = 0;
|
||||||
BYTE bytesPerPixel;
|
BYTE bytesPerPixel = 0;
|
||||||
Component unused;
|
Component unused;
|
||||||
Component alpha;
|
Component alpha;
|
||||||
Component red;
|
Component red;
|
||||||
Component green;
|
Component green;
|
||||||
Component blue;
|
Component blue;
|
||||||
|
Component palette;
|
||||||
Component depth;
|
Component depth;
|
||||||
Component stencil;
|
Component stencil;
|
||||||
|
Component luminance;
|
||||||
FormatInfo();
|
Component du;
|
||||||
FormatInfo(BYTE unusedBitCount, BYTE alphaBitCount, BYTE redBitCount, BYTE greenBitCount, BYTE blueBitCount);
|
Component dv;
|
||||||
FormatInfo(BYTE unusedBitCount, BYTE depthBitCount, BYTE stencilBitCount);
|
DDPIXELFORMAT pixelFormat = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
D3DCOLOR convertFrom32Bit(const FormatInfo& dstFormatInfo, D3DCOLOR srcColor);
|
D3DCOLOR convertFrom32Bit(const FormatInfo& dstFormatInfo, D3DCOLOR srcColor);
|
||||||
DeviceState::ShaderConstF convertToShaderConst(const FormatInfo& srcFormatInfo, D3DCOLOR srcColor);
|
DeviceState::ShaderConstF convertToShaderConst(const FormatInfo& srcFormatInfo, D3DCOLOR srcColor);
|
||||||
DWORD getComponent(D3DCOLOR color, const D3dDdi::FormatInfo::Component& component);
|
DWORD getComponent(D3DCOLOR color, const D3dDdi::FormatInfo::Component& component);
|
||||||
float getComponentAsFloat(D3DCOLOR color, const D3dDdi::FormatInfo::Component& component);
|
float getComponentAsFloat(D3DCOLOR color, const D3dDdi::FormatInfo::Component& component);
|
||||||
|
D3DDDIFORMAT getFormat(const DDPIXELFORMAT& pixelFormat);
|
||||||
FormatInfo getFormatInfo(D3DDDIFORMAT format);
|
FormatInfo getFormatInfo(D3DDDIFORMAT format);
|
||||||
DDPIXELFORMAT getPixelFormat(D3DDDIFORMAT format);
|
DDPIXELFORMAT getPixelFormat(D3DDDIFORMAT format);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include <D3dDdi/Resource.h>
|
#include <D3dDdi/Resource.h>
|
||||||
#include <D3dDdi/SurfaceRepository.h>
|
#include <D3dDdi/SurfaceRepository.h>
|
||||||
#include <DDraw/DirectDrawSurface.h>
|
#include <DDraw/DirectDrawSurface.h>
|
||||||
|
#include <DDraw/LogUsedResourceFormat.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -56,6 +57,7 @@ namespace D3dDdi
|
|||||||
desc.dwBackBufferCount = surfaceCount - 1;
|
desc.dwBackBufferCount = surfaceCount - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DDraw::SuppressResourceFormatLogs suppressResourceFormatLogs;
|
||||||
s_inCreateSurface = true;
|
s_inCreateSurface = true;
|
||||||
HRESULT result = dd.get()->lpVtbl->CreateSurface(dd, &desc, &surface.getRef(), nullptr);
|
HRESULT result = dd.get()->lpVtbl->CreateSurface(dd, &desc, &surface.getRef(), nullptr);
|
||||||
s_inCreateSurface = false;
|
s_inCreateSurface = false;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <Common/Comparison.h>
|
#include <Common/Comparison.h>
|
||||||
#include <Common/CompatPtr.h>
|
#include <Common/CompatPtr.h>
|
||||||
#include <Common/CompatVtable.h>
|
#include <Common/CompatVtable.h>
|
||||||
|
#include <Common/Log.h>
|
||||||
#include <Config/Settings/AltTabFix.h>
|
#include <Config/Settings/AltTabFix.h>
|
||||||
#include <Config/Settings/PalettizedTextures.h>
|
#include <Config/Settings/PalettizedTextures.h>
|
||||||
#include <Config/Settings/SoftwareDevice.h>
|
#include <Config/Settings/SoftwareDevice.h>
|
||||||
@ -15,6 +16,7 @@
|
|||||||
#include <D3dDdi/SurfaceRepository.h>
|
#include <D3dDdi/SurfaceRepository.h>
|
||||||
#include <DDraw/DirectDraw.h>
|
#include <DDraw/DirectDraw.h>
|
||||||
#include <DDraw/DirectDrawSurface.h>
|
#include <DDraw/DirectDrawSurface.h>
|
||||||
|
#include <DDraw/LogUsedResourceFormat.h>
|
||||||
#include <DDraw/RealPrimarySurface.h>
|
#include <DDraw/RealPrimarySurface.h>
|
||||||
#include <DDraw/ScopedThreadLock.h>
|
#include <DDraw/ScopedThreadLock.h>
|
||||||
#include <DDraw/Surfaces/PalettizedTexture.h>
|
#include <DDraw/Surfaces/PalettizedTexture.h>
|
||||||
@ -33,6 +35,10 @@ namespace
|
|||||||
return getOrigVtable(This).CreateSurface(This, lpDDSurfaceDesc, lplpDDSurface, pUnkOuter);
|
return getOrigVtable(This).CreateSurface(This, lpDDSurfaceDesc, lplpDDSurface, pUnkOuter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DDSURFACEDESC2 desc2 = {};
|
||||||
|
memcpy(&desc2, lpDDSurfaceDesc, sizeof(*lpDDSurfaceDesc));
|
||||||
|
DDraw::LogUsedResourceFormat logUsedResourceFormat(desc2, reinterpret_cast<IUnknown*&>(*lplpDDSurface));
|
||||||
|
|
||||||
if (lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
if (lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
||||||
{
|
{
|
||||||
return DDraw::PrimarySurface::create<TDirectDraw>(*This, *lpDDSurfaceDesc, *lplpDDSurface);
|
return DDraw::PrimarySurface::create<TDirectDraw>(*This, *lpDDSurfaceDesc, *lplpDDSurface);
|
||||||
|
183
DDrawCompat/DDraw/LogUsedResourceFormat.cpp
Normal file
183
DDrawCompat/DDraw/LogUsedResourceFormat.cpp
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <d3d.h>
|
||||||
|
#include <d3dumddi.h>
|
||||||
|
|
||||||
|
#include <Common/CompatPtr.h>
|
||||||
|
#include <D3dDdi/FormatInfo.h>
|
||||||
|
#include <D3dDdi/Log/CommonLog.h>
|
||||||
|
#include <DDraw/DirectDraw.h>
|
||||||
|
#include <DDraw/LogUsedResourceFormat.h>
|
||||||
|
#include <Win32/DisplayMode.h>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
struct ResourceFormat
|
||||||
|
{
|
||||||
|
D3DDDIFORMAT format;
|
||||||
|
DWORD caps;
|
||||||
|
DWORD caps2;
|
||||||
|
DWORD memCaps;
|
||||||
|
};
|
||||||
|
|
||||||
|
UINT g_suppressResourceFormatLogs = 0;
|
||||||
|
|
||||||
|
auto toTuple(const ResourceFormat& format)
|
||||||
|
{
|
||||||
|
return std::make_tuple(format.format, format.caps, format.caps2, format.memCaps);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<(const ResourceFormat& left, const ResourceFormat& right)
|
||||||
|
{
|
||||||
|
return toTuple(left) < toTuple(right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace DDraw
|
||||||
|
{
|
||||||
|
LogUsedResourceFormat::LogUsedResourceFormat(const DDSURFACEDESC2& desc, IUnknown*& surface)
|
||||||
|
: m_desc(desc)
|
||||||
|
, m_surface(surface)
|
||||||
|
{
|
||||||
|
if (!(m_desc.dwFlags & DDSD_PIXELFORMAT))
|
||||||
|
{
|
||||||
|
m_desc.ddpfPixelFormat = {};
|
||||||
|
if (m_desc.dwFlags & DDSD_ZBUFFERBITDEPTH)
|
||||||
|
{
|
||||||
|
switch (m_desc.dwMipMapCount)
|
||||||
|
{
|
||||||
|
case 16: m_desc.ddpfPixelFormat = D3dDdi::getPixelFormat(D3DDDIFMT_D16); break;
|
||||||
|
case 24: m_desc.ddpfPixelFormat = D3dDdi::getPixelFormat(D3DDDIFMT_X8D24); break;
|
||||||
|
case 32: m_desc.ddpfPixelFormat = D3dDdi::getPixelFormat(D3DDDIFMT_D32); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!(desc.ddsCaps.dwCaps & DDSCAPS_RESERVED2))
|
||||||
|
{
|
||||||
|
m_desc.ddpfPixelFormat = DDraw::DirectDraw::getRgbPixelFormat(Win32::DisplayMode::getBpp());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LogUsedResourceFormat::~LogUsedResourceFormat()
|
||||||
|
{
|
||||||
|
if (g_suppressResourceFormatLogs)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto format = (m_desc.ddsCaps.dwCaps & DDSCAPS_RESERVED2)
|
||||||
|
? D3DDDIFMT_VERTEXDATA
|
||||||
|
: D3dDdi::getFormat(m_desc.ddpfPixelFormat);
|
||||||
|
if (D3DDDIFMT_UNKNOWN == format)
|
||||||
|
{
|
||||||
|
LOG_ONCE("Unknown resource format: " << format);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isMipMap = (m_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) && (m_desc.ddsCaps.dwCaps & DDSCAPS_COMPLEX) &&
|
||||||
|
(!(m_desc.dwFlags & DDSD_MIPMAPCOUNT) || m_desc.dwMipMapCount > 1);
|
||||||
|
auto caps = m_desc.ddsCaps.dwCaps & (DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY |
|
||||||
|
DDSCAPS_3DDEVICE | DDSCAPS_TEXTURE | (isMipMap ? DDSCAPS_MIPMAP : 0) | DDSCAPS_ZBUFFER | DDSCAPS_RESERVED2 |
|
||||||
|
DDSCAPS_PRIMARYSURFACE | DDSCAPS_OVERLAY);
|
||||||
|
auto caps2 = m_desc.ddsCaps.dwCaps2 & (DDSCAPS2_CUBEMAP | DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE);
|
||||||
|
DWORD memCaps = 0;
|
||||||
|
|
||||||
|
if (!(m_desc.ddsCaps.dwCaps & (DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY)) &&
|
||||||
|
!(m_desc.ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE)))
|
||||||
|
{
|
||||||
|
auto surface(CompatPtr<IDirectDrawSurface7>::from(m_surface));
|
||||||
|
if (surface)
|
||||||
|
{
|
||||||
|
DDSCAPS2 realCaps = {};
|
||||||
|
surface->GetCaps(surface, &realCaps);
|
||||||
|
memCaps = realCaps.dwCaps & (DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::set<ResourceFormat> formats;
|
||||||
|
if (formats.insert({ format, caps, caps2, memCaps }).second)
|
||||||
|
{
|
||||||
|
Compat::Log log(Config::Settings::LogLevel::INFO);
|
||||||
|
log << "Using resource format: " << format << ',';
|
||||||
|
|
||||||
|
if (caps & DDSCAPS_3DDEVICE)
|
||||||
|
{
|
||||||
|
log << " render target";
|
||||||
|
}
|
||||||
|
if (caps & DDSCAPS_ZBUFFER)
|
||||||
|
{
|
||||||
|
log << " depth buffer";
|
||||||
|
}
|
||||||
|
if (caps & DDSCAPS_RESERVED2)
|
||||||
|
{
|
||||||
|
log << " vertex buffer";
|
||||||
|
}
|
||||||
|
if (caps2 & DDSCAPS2_CUBEMAP)
|
||||||
|
{
|
||||||
|
log << " cubic";
|
||||||
|
}
|
||||||
|
if (caps & DDSCAPS_MIPMAP)
|
||||||
|
{
|
||||||
|
log << " mipmap";
|
||||||
|
}
|
||||||
|
if (caps & DDSCAPS_TEXTURE)
|
||||||
|
{
|
||||||
|
log << " texture";
|
||||||
|
}
|
||||||
|
if (caps & DDSCAPS_PRIMARYSURFACE)
|
||||||
|
{
|
||||||
|
log << " primary";
|
||||||
|
}
|
||||||
|
if (caps & DDSCAPS_OVERLAY)
|
||||||
|
{
|
||||||
|
log << " overlay";
|
||||||
|
}
|
||||||
|
if (!(caps & (DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER | DDSCAPS_RESERVED2 | DDSCAPS_TEXTURE |
|
||||||
|
DDSCAPS_PRIMARYSURFACE | DDSCAPS_OVERLAY)))
|
||||||
|
{
|
||||||
|
log << " plain";
|
||||||
|
}
|
||||||
|
|
||||||
|
log << ", ";
|
||||||
|
if (caps2 & DDSCAPS2_D3DTEXTUREMANAGE)
|
||||||
|
{
|
||||||
|
log << "D3D managed";
|
||||||
|
}
|
||||||
|
else if (caps2 & DDSCAPS2_TEXTUREMANAGE)
|
||||||
|
{
|
||||||
|
log << "managed";
|
||||||
|
}
|
||||||
|
else if (caps & DDSCAPS_VIDEOMEMORY)
|
||||||
|
{
|
||||||
|
log << "vidmem";
|
||||||
|
}
|
||||||
|
else if (caps & DDSCAPS_SYSTEMMEMORY)
|
||||||
|
{
|
||||||
|
log << "sysmem";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log << "anymem";
|
||||||
|
if (m_surface)
|
||||||
|
{
|
||||||
|
log << " -> " << ((memCaps & DDSCAPS_VIDEOMEMORY) ? "vidmem" : "sysmem");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_surface)
|
||||||
|
{
|
||||||
|
log << " (FAILED)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SuppressResourceFormatLogs::SuppressResourceFormatLogs()
|
||||||
|
{
|
||||||
|
++g_suppressResourceFormatLogs;
|
||||||
|
}
|
||||||
|
|
||||||
|
SuppressResourceFormatLogs::~SuppressResourceFormatLogs()
|
||||||
|
{
|
||||||
|
--g_suppressResourceFormatLogs;
|
||||||
|
}
|
||||||
|
}
|
22
DDrawCompat/DDraw/LogUsedResourceFormat.h
Normal file
22
DDrawCompat/DDraw/LogUsedResourceFormat.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include <ddraw.h>
|
||||||
|
|
||||||
|
namespace DDraw
|
||||||
|
{
|
||||||
|
class LogUsedResourceFormat
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LogUsedResourceFormat(const DDSURFACEDESC2& desc, IUnknown*& surface);
|
||||||
|
~LogUsedResourceFormat();
|
||||||
|
|
||||||
|
private:
|
||||||
|
DDSURFACEDESC2 m_desc;
|
||||||
|
IUnknown*& m_surface;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SuppressResourceFormatLogs
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SuppressResourceFormatLogs();
|
||||||
|
~SuppressResourceFormatLogs();
|
||||||
|
};
|
||||||
|
}
|
@ -17,6 +17,7 @@
|
|||||||
#include <DDraw/DirectDraw.h>
|
#include <DDraw/DirectDraw.h>
|
||||||
#include <DDraw/DirectDrawSurface.h>
|
#include <DDraw/DirectDrawSurface.h>
|
||||||
#include <DDraw/IReleaseNotifier.h>
|
#include <DDraw/IReleaseNotifier.h>
|
||||||
|
#include <DDraw/LogUsedResourceFormat.h>
|
||||||
#include <DDraw/RealPrimarySurface.h>
|
#include <DDraw/RealPrimarySurface.h>
|
||||||
#include <DDraw/ScopedThreadLock.h>
|
#include <DDraw/ScopedThreadLock.h>
|
||||||
#include <DDraw/Surfaces/PrimarySurface.h>
|
#include <DDraw/Surfaces/PrimarySurface.h>
|
||||||
@ -120,6 +121,7 @@ namespace
|
|||||||
auto tagSurface = DDraw::TagSurface::findFullscreenWindow();
|
auto tagSurface = DDraw::TagSurface::findFullscreenWindow();
|
||||||
LOG_DEBUG << "Creating " << (tagSurface ? "fullscreen" : "windowed") << " default primary";
|
LOG_DEBUG << "Creating " << (tagSurface ? "fullscreen" : "windowed") << " default primary";
|
||||||
|
|
||||||
|
DDraw::SuppressResourceFormatLogs suppressResourceFormatLogs;
|
||||||
if (tagSurface)
|
if (tagSurface)
|
||||||
{
|
{
|
||||||
DDSURFACEDESC desc = {};
|
DDSURFACEDESC desc = {};
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <D3dDdi/SurfaceRepository.h>
|
#include <D3dDdi/SurfaceRepository.h>
|
||||||
#include <DDraw/DirectDrawClipper.h>
|
#include <DDraw/DirectDrawClipper.h>
|
||||||
#include <DDraw/DirectDrawSurface.h>
|
#include <DDraw/DirectDrawSurface.h>
|
||||||
|
#include <DDraw/LogUsedResourceFormat.h>
|
||||||
#include <DDraw/RealPrimarySurface.h>
|
#include <DDraw/RealPrimarySurface.h>
|
||||||
#include <DDraw/Surfaces/PrimarySurface.h>
|
#include <DDraw/Surfaces/PrimarySurface.h>
|
||||||
#include <DDraw/Surfaces/Surface.h>
|
#include <DDraw/Surfaces/Surface.h>
|
||||||
@ -225,6 +226,7 @@ namespace DDraw
|
|||||||
template <typename TSurface>
|
template <typename TSurface>
|
||||||
HRESULT SurfaceImpl<TSurface>::QueryInterface(TSurface* This, REFIID riid, LPVOID* obp)
|
HRESULT SurfaceImpl<TSurface>::QueryInterface(TSurface* This, REFIID riid, LPVOID* obp)
|
||||||
{
|
{
|
||||||
|
DDraw::SuppressResourceFormatLogs suppressResourceFormatLogs;
|
||||||
auto& iid = Direct3d::replaceDevice(riid);
|
auto& iid = Direct3d::replaceDevice(riid);
|
||||||
HRESULT result = getOrigVtable(This).QueryInterface(This, iid, obp);
|
HRESULT result = getOrigVtable(This).QueryInterface(This, iid, obp);
|
||||||
if (DDERR_INVALIDOBJECT == result)
|
if (DDERR_INVALIDOBJECT == result)
|
||||||
|
@ -228,6 +228,7 @@
|
|||||||
<ClInclude Include="DDraw\DirectDrawSurface.h" />
|
<ClInclude Include="DDraw\DirectDrawSurface.h" />
|
||||||
<ClInclude Include="DDraw\Hooks.h" />
|
<ClInclude Include="DDraw\Hooks.h" />
|
||||||
<ClInclude Include="DDraw\Log.h" />
|
<ClInclude Include="DDraw\Log.h" />
|
||||||
|
<ClInclude Include="DDraw\LogUsedResourceFormat.h" />
|
||||||
<ClInclude Include="DDraw\ScopedThreadLock.h" />
|
<ClInclude Include="DDraw\ScopedThreadLock.h" />
|
||||||
<ClInclude Include="DDraw\Surfaces\PalettizedTexture.h" />
|
<ClInclude Include="DDraw\Surfaces\PalettizedTexture.h" />
|
||||||
<ClInclude Include="DDraw\Surfaces\PalettizedTextureImpl.h" />
|
<ClInclude Include="DDraw\Surfaces\PalettizedTextureImpl.h" />
|
||||||
@ -366,6 +367,7 @@
|
|||||||
<ClCompile Include="DDraw\Hooks.cpp" />
|
<ClCompile Include="DDraw\Hooks.cpp" />
|
||||||
<ClCompile Include="DDraw\IReleaseNotifier.cpp" />
|
<ClCompile Include="DDraw\IReleaseNotifier.cpp" />
|
||||||
<ClCompile Include="DDraw\Log.cpp" />
|
<ClCompile Include="DDraw\Log.cpp" />
|
||||||
|
<ClCompile Include="DDraw\LogUsedResourceFormat.cpp" />
|
||||||
<ClCompile Include="DDraw\RealPrimarySurface.cpp" />
|
<ClCompile Include="DDraw\RealPrimarySurface.cpp" />
|
||||||
<ClCompile Include="DDraw\Surfaces\PalettizedTexture.cpp" />
|
<ClCompile Include="DDraw\Surfaces\PalettizedTexture.cpp" />
|
||||||
<ClCompile Include="DDraw\Surfaces\PalettizedTextureImpl.cpp" />
|
<ClCompile Include="DDraw\Surfaces\PalettizedTextureImpl.cpp" />
|
||||||
|
@ -633,6 +633,9 @@
|
|||||||
<ClInclude Include="Config\Settings\CpuAffinityRotation.h">
|
<ClInclude Include="Config\Settings\CpuAffinityRotation.h">
|
||||||
<Filter>Header Files\Config\Settings</Filter>
|
<Filter>Header Files\Config\Settings</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="DDraw\LogUsedResourceFormat.h">
|
||||||
|
<Filter>Header Files\DDraw</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Gdi\Gdi.cpp">
|
<ClCompile Include="Gdi\Gdi.cpp">
|
||||||
@ -998,6 +1001,9 @@
|
|||||||
<ClCompile Include="Overlay\StatsEventGroup.cpp">
|
<ClCompile Include="Overlay\StatsEventGroup.cpp">
|
||||||
<Filter>Source Files\Overlay</Filter>
|
<Filter>Source Files\Overlay</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="DDraw\LogUsedResourceFormat.cpp">
|
||||||
|
<Filter>Source Files\DDraw</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="DDrawCompat.rc">
|
<ResourceCompile Include="DDrawCompat.rc">
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <Config/Settings/SoftwareDevice.h>
|
#include <Config/Settings/SoftwareDevice.h>
|
||||||
#include <D3dDdi/Device.h>
|
#include <D3dDdi/Device.h>
|
||||||
#include <DDraw/DirectDrawSurface.h>
|
#include <DDraw/DirectDrawSurface.h>
|
||||||
|
#include <DDraw/LogUsedResourceFormat.h>
|
||||||
#include <DDraw/ScopedThreadLock.h>
|
#include <DDraw/ScopedThreadLock.h>
|
||||||
#include <DDraw/Surfaces/Surface.h>
|
#include <DDraw/Surfaces/Surface.h>
|
||||||
#include <Direct3d/Direct3d.h>
|
#include <Direct3d/Direct3d.h>
|
||||||
@ -23,6 +24,7 @@ namespace
|
|||||||
TDirect3dDevice** lplpD3DDevice,
|
TDirect3dDevice** lplpD3DDevice,
|
||||||
Params... params)
|
Params... params)
|
||||||
{
|
{
|
||||||
|
DDraw::SuppressResourceFormatLogs suppressResourceFormatLogs;
|
||||||
auto& iid = Direct3d::replaceDevice(rclsid);
|
auto& iid = Direct3d::replaceDevice(rclsid);
|
||||||
HRESULT result = getOrigVtable(This).CreateDevice(This, iid, lpDDS, lplpD3DDevice, params...);
|
HRESULT result = getOrigVtable(This).CreateDevice(This, iid, lpDDS, lplpD3DDevice, params...);
|
||||||
if (DDERR_INVALIDOBJECT == result && lpDDS)
|
if (DDERR_INVALIDOBJECT == result && lpDDS)
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <D3dDdi/Hooks.h>
|
#include <D3dDdi/Hooks.h>
|
||||||
#include <DDraw/DirectDraw.h>
|
#include <DDraw/DirectDraw.h>
|
||||||
#include <DDraw/Hooks.h>
|
#include <DDraw/Hooks.h>
|
||||||
|
#include <DDraw/LogUsedResourceFormat.h>
|
||||||
#include <Direct3d/Hooks.h>
|
#include <Direct3d/Hooks.h>
|
||||||
#include <Dll/Dll.h>
|
#include <Dll/Dll.h>
|
||||||
#include <Gdi/Gdi.h>
|
#include <Gdi/Gdi.h>
|
||||||
@ -72,6 +73,7 @@ namespace
|
|||||||
static bool isAlreadyInstalled = false;
|
static bool isAlreadyInstalled = false;
|
||||||
if (!isAlreadyInstalled)
|
if (!isAlreadyInstalled)
|
||||||
{
|
{
|
||||||
|
DDraw::SuppressResourceFormatLogs suppressResourceFormatLogs;
|
||||||
LOG_INFO << "Installing display mode hooks";
|
LOG_INFO << "Installing display mode hooks";
|
||||||
Win32::DisplayMode::installHooks();
|
Win32::DisplayMode::installHooks();
|
||||||
LOG_INFO << "Installing registry hooks";
|
LOG_INFO << "Installing registry hooks";
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <D3dDdi/Resource.h>
|
#include <D3dDdi/Resource.h>
|
||||||
#include <D3dDdi/ScopedCriticalSection.h>
|
#include <D3dDdi/ScopedCriticalSection.h>
|
||||||
#include <DDraw/DirectDraw.h>
|
#include <DDraw/DirectDraw.h>
|
||||||
|
#include <DDraw/LogUsedResourceFormat.h>
|
||||||
#include <DDraw/RealPrimarySurface.h>
|
#include <DDraw/RealPrimarySurface.h>
|
||||||
#include <DDraw/ScopedThreadLock.h>
|
#include <DDraw/ScopedThreadLock.h>
|
||||||
#include <DDraw/Surfaces/PrimarySurface.h>
|
#include <DDraw/Surfaces/PrimarySurface.h>
|
||||||
@ -176,6 +177,7 @@ namespace Gdi
|
|||||||
primary->GetDDInterface(primary, reinterpret_cast<void**>(&ddUnk.getRef()));
|
primary->GetDDInterface(primary, reinterpret_cast<void**>(&ddUnk.getRef()));
|
||||||
CompatPtr<IDirectDraw7> dd(ddUnk);
|
CompatPtr<IDirectDraw7> dd(ddUnk);
|
||||||
|
|
||||||
|
DDraw::SuppressResourceFormatLogs suppressResourceFormatLogs;
|
||||||
CompatPtr<IDirectDrawSurface7> surface;
|
CompatPtr<IDirectDrawSurface7> surface;
|
||||||
dd.get()->lpVtbl->CreateSurface(dd, &desc, &surface.getRef(), nullptr);
|
dd.get()->lpVtbl->CreateSurface(dd, &desc, &surface.getRef(), nullptr);
|
||||||
return surface;
|
return surface;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user