Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add D3DFMT_UNKNOWN checks on object creation #184

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions source/d3d8to9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateTexture(UINT Width, UINT Height
if (ppTexture == nullptr)
return D3DERR_INVALIDCALL;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

*ppTexture = nullptr;

if (Pool == D3DPOOL_DEFAULT)
Expand Down Expand Up @@ -312,6 +315,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateVolumeTexture(UINT Width, UINT
if (ppVolumeTexture == nullptr)
return D3DERR_INVALIDCALL;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

*ppVolumeTexture = nullptr;

IDirect3DVolumeTexture9 *TextureInterface = nullptr;
Expand All @@ -329,6 +335,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateCubeTexture(UINT EdgeLength, UI
if (ppCubeTexture == nullptr)
return D3DERR_INVALIDCALL;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

*ppCubeTexture = nullptr;

IDirect3DCubeTexture9 *TextureInterface = nullptr;
Expand Down Expand Up @@ -380,6 +389,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateRenderTarget(UINT Width, UINT H
if (ppSurface == nullptr)
return D3DERR_INVALIDCALL;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

*ppSurface = nullptr;

DWORD QualityLevels = 0;
Expand Down Expand Up @@ -409,6 +421,9 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateDepthStencilSurface(UINT Width,
if (ppSurface == nullptr)
return D3DERR_INVALIDCALL;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

*ppSurface = nullptr;

DWORD QualityLevels = 0;
Expand Down Expand Up @@ -442,8 +457,13 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::CreateImageSurface(UINT Width, UINT H
if (ppSurface == nullptr)
return D3DERR_INVALIDCALL;

// Only CreateImageSurface clears the content of ppSurface
// before checking if Format is equal to D3DFMT_UNKNOWN.
*ppSurface = nullptr;

if (Format == D3DFMT_UNKNOWN)
return D3DERR_INVALIDCALL;

IDirect3DSurface9 *SurfaceInterface = nullptr;

const HRESULT hr = ProxyInterface->CreateOffscreenPlainSurface(Width, Height, Format, D3DPOOL_SYSTEMMEM, &SurfaceInterface, nullptr);
Expand Down