Skip to content

Commit

Permalink
[d3d8] Validate depth stencil format use with CopyRects
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall committed Mar 10, 2024
1 parent 1a039a4 commit 9522ef7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/d3d8/d3d8_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,13 @@ namespace dxvk {
src->GetD3D9()->GetDesc(&srcDesc);
dst->GetD3D9()->GetDesc(&dstDesc);

// This method cannot be applied to surfaces whose formats
// are classified as depth stencil formats.
if (unlikely(isDepthStencilFormat(D3DFORMAT(srcDesc.Format)) ||
isDepthStencilFormat(D3DFORMAT(dstDesc.Format)))) {
return D3DERR_INVALIDCALL;
}

StateChange();

// If pSourceRectsArray is NULL, then the entire surface is copied
Expand Down
10 changes: 10 additions & 0 deletions src/d3d8/d3d8_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ namespace dxvk {
|| fmt == D3DFMT_D24X8;
}

inline constexpr bool isDepthStencilFormat(D3DFORMAT fmt) {
return fmt == D3DFMT_D16_LOCKABLE
|| fmt == D3DFMT_D16
|| fmt == D3DFMT_D32
|| fmt == D3DFMT_D15S1
|| fmt == D3DFMT_D24X4S4
|| fmt == D3DFMT_D24S8
|| fmt == D3DFMT_D24X8;
}

// Get bytes per pixel (or 4x4 block for DXT)
inline constexpr UINT getFormatStride(D3DFORMAT fmt) {
switch (fmt) {
Expand Down

0 comments on commit 9522ef7

Please sign in to comment.