Skip to content

Commit

Permalink
[d3d8] Correctly track SetTexture state
Browse files Browse the repository at this point in the history
Fixes #6. Checking == nullptr is not a valid way to check which textures are captured because a null texture is what tells d3d to use the material color instead.
  • Loading branch information
AlpyneDreams committed Jul 26, 2021
1 parent 767cbaf commit 4b2a5e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
15 changes: 5 additions & 10 deletions src/d3d8/d3d8_state_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ HRESULT dxvk::D3D8StateBlock::Capture() {
if (m_capture.vs) m_device->GetVertexShader(&m_vertexShader);
if (m_capture.ps) m_device->GetPixelShader(&m_pixelShader);

if (m_capture.textures)
for (DWORD stage = 0; stage < m_textures.size(); stage++)
for (DWORD stage = 0; stage < m_textures.size(); stage++)
if (m_capture.textures.get(stage))
m_device->GetTexture(stage, &m_textures[stage]);

if (m_capture.indices) m_device->GetIndices(&m_indices, &m_baseVertexIndex);
Expand All @@ -27,14 +27,9 @@ HRESULT dxvk::D3D8StateBlock::Apply() {
if (m_capture.vs) m_device->SetVertexShader(m_vertexShader);
if (m_capture.ps) m_device->SetPixelShader(m_pixelShader);

if (m_capture.textures) {
for (DWORD stage = 0; stage < m_textures.size(); stage++) {
IDirect3DBaseTexture8* pTexture = m_textures[stage];
if (pTexture != nullptr) {
m_device->SetTexture(stage, pTexture);
}
}
}
for (DWORD stage = 0; stage < m_textures.size(); stage++)
if (m_capture.textures.get(stage))
m_device->SetTexture(stage, m_textures[stage] );

if (m_capture.indices) m_device->SetIndices(m_indices, m_baseVertexIndex);

Expand Down
5 changes: 3 additions & 2 deletions src/d3d8/d3d8_state_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace dxvk {
bool vs : 1;
bool ps : 1;
bool indices : 1;
bool textures : 1;

bit::bitset<d8caps::MAX_TEXTURE_STAGES> textures;

D3D8StateCapture() {
// Ensure all bits are initialized to false
Expand Down Expand Up @@ -70,7 +71,7 @@ namespace dxvk {

inline HRESULT SetTexture(DWORD Stage, IDirect3DBaseTexture8* pTexture) {
m_textures[Stage] = pTexture;
m_capture.textures = true;
m_capture.textures.set(Stage, true);
return D3D_OK;
}

Expand Down

0 comments on commit 4b2a5e4

Please sign in to comment.