Skip to content

Commit

Permalink
Add support for D3DFMT_NV12
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Sep 10, 2024
1 parent faedb2b commit eb3afbb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 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 7129
#define BUILD_NUMBER 7130
2 changes: 2 additions & 0 deletions Logging/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ std::ostream& operator<<(std::ostream& os, const D3DFORMAT& format)
return os << "D3DFMT_YUY2";
case MAKEFOURCC('Y', 'V', '1', '2'):
return os << "D3DFMT_YV12";
case MAKEFOURCC('N', 'V', '1', '2'):
return os << "D3DFMT_NV12";
case MAKEFOURCC('A', 'Y', 'U', 'V'):
return os << "D3DFMT_AYUV";
case MAKEFOURCC('G', 'R', 'G', 'B'):
Expand Down
2 changes: 1 addition & 1 deletion ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2810,7 +2810,7 @@ HRESULT m_IDirectDrawSurfaceX::Lock2(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSur
// Pitch for DXT surfaces in DirectDraw is the full surface byte size
LockedRect.Pitch =
ISDXTEX(surface.Format) ? ((surface.Width + 3) / 4) * ((lpDDSurfaceDesc2->dwHeight + 3) / 4) * (surface.Format == D3DFMT_DXT1 ? 8 : 16) :
(surface.Format == D3DFMT_YV12) ? surface.Width :
(surface.Format == D3DFMT_YV12 || surface.Format == D3DFMT_NV12) ? surface.Width :
LockedRect.Pitch;
lpDDSurfaceDesc2->lPitch = LockedRect.Pitch;
lpDDSurfaceDesc2->dwFlags |= DDSD_PITCH;
Expand Down
5 changes: 4 additions & 1 deletion ddraw/IDirectDrawTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ DWORD GetBitCount(D3DFORMAT Format)
return 16;

case D3DFMT_YV12:
case D3DFMT_NV12:
return 12;

case D3DFMT_P8:
Expand Down Expand Up @@ -607,7 +608,7 @@ DWORD GetSurfaceSize(D3DFORMAT Format, DWORD Width, DWORD Height, INT Pitch)
{
return ((GetByteAlignedWidth(Width, GetBitCount(Format)) + 3) / 4) * ((Height + 3) / 4) * (Format == D3DFMT_DXT1 ? 8 : 16);
}
else if (Format == D3DFMT_YV12)
else if (Format == D3DFMT_YV12 || Format == D3DFMT_NV12)
{
return GetByteAlignedWidth(Width, GetBitCount(Format)) * Height;
}
Expand Down Expand Up @@ -776,6 +777,7 @@ D3DFORMAT GetDisplayFormat(DDPIXELFORMAT ddpfPixelFormat)
case D3DFMT_UYVY:
case D3DFMT_YUY2:
case D3DFMT_YV12:
case D3DFMT_NV12:
case D3DFMT_MULTI2_ARGB8:
case D3DFMT_G8R8_G8B8:
case D3DFMT_R8G8_B8G8:
Expand Down Expand Up @@ -1198,6 +1200,7 @@ void SetPixelDisplayFormat(D3DFORMAT Format, DDPIXELFORMAT &ddpfPixelFormat)
case D3DFMT_UYVY:
case D3DFMT_YUY2:
case D3DFMT_YV12:
case D3DFMT_NV12:
ddpfPixelFormat.dwFlags = DDPF_FOURCC;
ddpfPixelFormat.dwFourCC = Format;
break;
Expand Down
3 changes: 2 additions & 1 deletion ddraw/IDirectDrawTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ constexpr DWORD MinUsedVidMemory = 8 * 1024; // 8 KBs
#define D3DCOLOR_GETBLUE(c) ((c) & 0xFF)

#define D3DFMT_B8G8R8 (D3DFORMAT)19
#define D3DFMT_YV12 (D3DFORMAT)MAKEFOURCC('Y','V','1','2')
#define D3DFMT_AYUV (D3DFORMAT)MAKEFOURCC('A', 'Y', 'U', 'V')
#define D3DFMT_YV12 (D3DFORMAT)MAKEFOURCC('Y', 'V', '1', '2')
#define D3DFMT_NV12 (D3DFORMAT)MAKEFOURCC('N', 'V', '1', '2')

#define D3DFMT_R5G6B5_TO_X8R8G8B8(w) \
((((DWORD)((w>>11)&0x1f)*8)<<16)+(((DWORD)((w>>5)&0x3f)*4)<<8)+((DWORD)(w&0x1f)*8))
Expand Down

0 comments on commit eb3afbb

Please sign in to comment.