-
Notifications
You must be signed in to change notification settings - Fork 869
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
[d3d9] Several Wine device test fixes #4492
Open
WinterSnowfall
wants to merge
7
commits into
doitsujin:master
Choose a base branch
from
WinterSnowfall:d3d9-winetests1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+88
−56
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b16deed
[d3d9] Only advertise SRCCOLOR2 & INVSRCCOLOR2 with 9Ex
WinterSnowfall a8539a5
[d3d9] Prevent device child refcount underrun
WinterSnowfall 65ae3f7
[d3d9] Skip recording MultiplyTransform calls in state blocks
WinterSnowfall 10cf8c8
[d3d9] Adjust out of bounds clip plane index handling
WinterSnowfall 8e25b1a
[d3d9] Validate supported formats in D3D9Surface::GetDC
WinterSnowfall 4d624b1
[d3d9] Adjust device reset failure error codes
WinterSnowfall aea624d
[d3d9] Fixes for state block specific behavior
WinterSnowfall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,6 +309,14 @@ namespace dxvk { | |
|
||
// When in SWVP mode, 256 matrices can be used for indexed vertex blending | ||
pCaps->MaxVertexBlendMatrixIndex = m_isSWVP ? 255 : 8; | ||
// Only 9Ex devices advertise D3DPBLENDCAPS_SRCCOLOR2 and D3DPBLENDCAPS_INVSRCCOLOR2 | ||
if (!IsExtended()) { | ||
pCaps->SrcBlendCaps &= ~D3DPBLENDCAPS_SRCCOLOR2 | ||
& ~D3DPBLENDCAPS_INVSRCCOLOR2; | ||
|
||
pCaps->DestBlendCaps &= ~D3DPBLENDCAPS_SRCCOLOR2 | ||
& ~D3DPBLENDCAPS_INVSRCCOLOR2; | ||
} | ||
|
||
return D3D_OK; | ||
} | ||
|
@@ -514,7 +522,8 @@ namespace dxvk { | |
if (unlikely(m_losableResourceCounter.load() != 0 && !IsExtended() && m_d3d9Options.countLosableResources)) { | ||
Logger::warn(str::format("Device reset failed because device still has alive losable resources: Device not reset. Remaining resources: ", m_losableResourceCounter.load())); | ||
m_deviceLostState = D3D9DeviceLostState::NotReset; | ||
return D3DERR_DEVICELOST; | ||
// D3D8 expects a D3DERR_DEVICELOST error code | ||
return m_isD3D8Compatible ? D3DERR_DEVICELOST : D3DERR_INVALIDCALL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... and D3D9 expects INVALIDCALL? Maybe mention that in the comment :P |
||
} | ||
|
||
hr = ResetSwapChain(pPresentationParameters, nullptr); | ||
|
@@ -2025,10 +2034,6 @@ namespace dxvk { | |
|
||
const uint32_t idx = GetTransformIndex(TransformState); | ||
|
||
// D3D8 state blocks ignore capturing calls to MultiplyTransform(). | ||
if (unlikely(!m_isD3D8Compatible && ShouldRecord())) | ||
return m_recorder->MultiplyStateTransform(idx, pMatrix); | ||
|
||
m_state.transforms[idx] = m_state.transforms[idx] * ConvertMatrix(pMatrix); | ||
|
||
m_flags.set(D3D9DeviceFlag::DirtyFFVertexData); | ||
|
@@ -2191,9 +2196,13 @@ namespace dxvk { | |
HRESULT STDMETHODCALLTYPE D3D9DeviceEx::SetClipPlane(DWORD Index, const float* pPlane) { | ||
D3D9DeviceLock lock = LockDevice(); | ||
|
||
if (unlikely(Index >= caps::MaxClipPlanes || !pPlane)) | ||
if (unlikely(!pPlane)) | ||
return D3DERR_INVALIDCALL; | ||
|
||
// Higher indexes will be capped to the last valid index | ||
if (unlikely(Index >= caps::MaxClipPlanes)) | ||
Index = caps::MaxClipPlanes - 1; | ||
|
||
if (unlikely(ShouldRecord())) | ||
return m_recorder->SetClipPlane(Index, pPlane); | ||
|
||
|
@@ -2217,9 +2226,13 @@ namespace dxvk { | |
HRESULT STDMETHODCALLTYPE D3D9DeviceEx::GetClipPlane(DWORD Index, float* pPlane) { | ||
D3D9DeviceLock lock = LockDevice(); | ||
|
||
if (unlikely(Index >= caps::MaxClipPlanes || !pPlane)) | ||
if (unlikely(!pPlane)) | ||
return D3DERR_INVALIDCALL; | ||
|
||
// Higher indexes will be capped to the last valid index | ||
if (unlikely(Index >= caps::MaxClipPlanes)) | ||
Index = caps::MaxClipPlanes - 1; | ||
|
||
for (uint32_t i = 0; i < 4; i++) | ||
pPlane[i] = m_state.clipPlanes[Index].coeff[i]; | ||
|
||
|
@@ -2586,6 +2599,10 @@ namespace dxvk { | |
IDirect3DStateBlock9** ppSB) { | ||
D3D9DeviceLock lock = LockDevice(); | ||
|
||
// A state block can not be created while another is being recorded. | ||
if (unlikely(ShouldRecord())) | ||
return D3DERR_INVALIDCALL; | ||
|
||
InitReturnPtr(ppSB); | ||
|
||
if (unlikely(ppSB == nullptr)) | ||
|
@@ -2609,7 +2626,8 @@ namespace dxvk { | |
HRESULT STDMETHODCALLTYPE D3D9DeviceEx::BeginStateBlock() { | ||
D3D9DeviceLock lock = LockDevice(); | ||
|
||
if (unlikely(m_recorder != nullptr)) | ||
// Only one state block can be recorded at a given time. | ||
if (unlikely(ShouldRecord())) | ||
return D3DERR_INVALIDCALL; | ||
|
||
m_recorder = new D3D9StateBlock(this, D3D9StateBlockType::None); | ||
|
@@ -2621,11 +2639,12 @@ namespace dxvk { | |
HRESULT STDMETHODCALLTYPE D3D9DeviceEx::EndStateBlock(IDirect3DStateBlock9** ppSB) { | ||
D3D9DeviceLock lock = LockDevice(); | ||
|
||
InitReturnPtr(ppSB); | ||
|
||
if (unlikely(ppSB == nullptr || m_recorder == nullptr)) | ||
// Recording a state block can't end if recording hasn't been started. | ||
if (unlikely(ppSB == nullptr || !ShouldRecord())) | ||
return D3DERR_INVALIDCALL; | ||
|
||
InitReturnPtr(ppSB); | ||
|
||
*ppSB = m_recorder.ref(); | ||
if (!m_isD3D8Compatible) | ||
m_losableResourceCounter++; | ||
|
@@ -4626,21 +4645,18 @@ namespace dxvk { | |
} | ||
|
||
|
||
inline bool D3D9DeviceEx::ShouldRecord() { | ||
return m_recorder != nullptr && !m_recorder->IsApplying(); | ||
} | ||
|
||
|
||
D3D9_VK_FORMAT_MAPPING D3D9DeviceEx::LookupFormat( | ||
D3D9Format Format) const { | ||
return m_adapter->GetFormatMapping(Format); | ||
} | ||
|
||
|
||
const DxvkFormatInfo* D3D9DeviceEx::UnsupportedFormatInfo( | ||
D3D9Format Format) const { | ||
return m_adapter->GetUnsupportedFormatInfo(Format); | ||
} | ||
|
||
|
||
bool D3D9DeviceEx::WaitForResource( | ||
const DxvkPagedResource& Resource, | ||
uint64_t SequenceNumber, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be cleaner to just conditionally add those two flags if the adapter is extended in Adapter::GetDeviceCaps rather than conditionally removing them in both the device and the interface.