Skip to content

Commit

Permalink
Add partial support for paletted render target
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Dec 6, 2024
1 parent d260b59 commit ba71776
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7360
#define BUILD_NUMBER 7361
8 changes: 4 additions & 4 deletions ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4344,7 +4344,7 @@ inline LPDIRECT3DTEXTURE9 m_IDirectDrawSurfaceX::Get3DTexture()
}

// Prepare paletted surface for display
if (surface.IsPaletteDirty && !primary.PaletteTexture)
if (surface.IsPaletteDirty && IsUsingEmulation() && !primary.PaletteTexture)
{
CopyEmulatedPaletteSurface(nullptr);
}
Expand Down Expand Up @@ -4550,7 +4550,7 @@ HRESULT m_IDirectDrawSurfaceX::CreateD9AuxiliarySurfaces()
}

// Create palette surface
if (!primary.PaletteTexture && IsPrimarySurface() && surface.Format == D3DFMT_P8 && !IsRenderTarget())
if (!primary.PaletteTexture && IsPrimarySurface() && surface.Format == D3DFMT_P8)
{
if (FAILED((*d3d9Device)->CreateTexture(MaxPaletteSize, MaxPaletteSize, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &primary.PaletteTexture, nullptr)))
{
Expand Down Expand Up @@ -4665,7 +4665,7 @@ HRESULT m_IDirectDrawSurfaceX::CreateD9Surface()
// ToDo: if render surface is a texture then create as a texture (MipMaps can be supported on render target textures)
surface.Usage = D3DUSAGE_RENDERTARGET;
surface.Pool = D3DPOOL_DEFAULT;
if (IsSurfaceTexture())
if (IsSurfaceTexture() || IsPalette())
{
surface.Type = D3DTYPE_TEXTURE;
if (FAILED((*d3d9Device)->CreateTexture(surface.Width, surface.Height, 1, surface.Usage, Format, surface.Pool, &surface.Texture, nullptr)) &&
Expand Down Expand Up @@ -7200,7 +7200,7 @@ HRESULT m_IDirectDrawSurfaceX::CopyToDrawTexture(LPRECT lpDestRect)
return DDERR_GENERIC;
}

DWORD ColorKey = (surfaceDesc2.ddpfPixelFormat.dwRGBBitCount && (surfaceDesc2.dwFlags & DDSD_CKSRCBLT)) ?
DWORD ColorKey = (surfaceDesc2.ddpfPixelFormat.dwRGBBitCount && (surfaceDesc2.dwFlags & DDSD_CKSRCBLT) && !IsPalette()) ?
GetARGBColorKey(surfaceDesc2.ddckCKSrcBlt.dwColorSpaceLowValue, surfaceDesc2.ddpfPixelFormat) : 0;

if (IsPalette())
Expand Down
2 changes: 1 addition & 1 deletion ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4677,7 +4677,7 @@ HRESULT m_IDirectDrawX::PresentScene(RECT* pRect)

// Copy or draw primary surface before presenting
HRESULT DrawRet = DDERR_GENERIC;
if (IsPrimaryRenderTarget())
if (IsPrimaryRenderTarget() && !PrimarySurface->GetD3d9Texture())
{
if (IsGammaSet)
{
Expand Down

0 comments on commit ba71776

Please sign in to comment.