HRESULT WINAPI D3D9ProxySurface::UnlockRect() { if (IsStereo()) m_pActualSurfaceRight->UnlockRect(); return BaseDirect3DSurface9::UnlockRect(); }
HRESULT WINAPI D3D9ProxyCubeTexture::SetPrivateData(REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { if (IsStereo()) m_pActualTextureRight->SetPrivateData(refguid, pData, SizeOfData, Flags); return m_pActualTexture->SetPrivateData(refguid, pData, SizeOfData, Flags); }
DWORD WINAPI D3D9ProxySurface::SetPriority(DWORD PriorityNew) { if (IsStereo()) m_pActualSurfaceRight->SetPriority(PriorityNew); return m_pActualSurface->SetPriority(PriorityNew); }
HRESULT WINAPI D3D9ProxyCubeTexture::AddDirtyRect(D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect) { if (IsStereo()) m_pActualTextureRight->AddDirtyRect(FaceType, pDirtyRect); return m_pActualTexture->AddDirtyRect(FaceType, pDirtyRect); }
HRESULT WINAPI D3D9ProxySurface::FreePrivateData(REFGUID refguid) { if (IsStereo()) m_pActualSurfaceRight->FreePrivateData(refguid); return m_pActualSurface->FreePrivateData(refguid); }
HRESULT WINAPI D3D9ProxyTexture::AddDirtyRect(CONST RECT* pDirtyRect) { if (IsStereo()) m_pActualTextureRight->AddDirtyRect(pDirtyRect); return m_pActualTexture->AddDirtyRect(pDirtyRect); }
HRESULT WINAPI D3D9ProxyTexture::UnlockRect(UINT Level) { if (IsStereo()) m_pActualTextureRight->UnlockRect(Level); return m_pActualTexture->UnlockRect(Level); }
HRESULT WINAPI D3D9ProxyTexture::LockRect(UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) { if (IsStereo()) m_pActualTextureRight->LockRect(Level, pLockedRect, pRect, Flags); return m_pActualTexture->LockRect(Level, pLockedRect, pRect, Flags); }
void WINAPI D3D9ProxySurface::PreLoad() { if (IsStereo()) m_pActualSurfaceRight->PreLoad(); return m_pActualSurface->PreLoad(); }
HRESULT WINAPI D3D9ProxySurface::LockRect(D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) { if (IsStereo()) m_pActualSurfaceRight->LockRect(pLockedRect, pRect, Flags); return BaseDirect3DSurface9::LockRect(pLockedRect, pRect, Flags); }
void WINAPI D3D9ProxyCubeTexture::GenerateMipSubLevels() { if (IsStereo()) m_pActualTextureRight->GenerateMipSubLevels(); return m_pActualTexture->GenerateMipSubLevels(); }
HRESULT WINAPI D3D9ProxyCubeTexture::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType) { if (IsStereo()) m_pActualTextureRight->SetAutoGenFilterType(FilterType); return m_pActualTexture->SetAutoGenFilterType(FilterType); }
HRESULT WINAPI D3D9ProxySurface::ReleaseDC(HDC hdc) { if (IsStereo()) m_pActualSurfaceRight->ReleaseDC(hdc); return BaseDirect3DSurface9::ReleaseDC(hdc); }
void WINAPI D3D9ProxyCubeTexture::PreLoad() { if (IsStereo()) m_pActualTextureRight->PreLoad(); return m_pActualTexture->PreLoad(); }
DWORD WINAPI D3D9ProxyCubeTexture::SetLOD(DWORD LODNew) { if (IsStereo()) m_pActualTextureRight->SetLOD(LODNew); return m_pActualTexture->SetLOD(LODNew); }
DWORD WINAPI D3D9ProxyCubeTexture::SetPriority(DWORD PriorityNew) { if (IsStereo()) m_pActualTextureRight->SetPriority(PriorityNew); return m_pActualTexture->SetPriority(PriorityNew); }
HRESULT WINAPI D3D9ProxyCubeTexture::FreePrivateData(REFGUID refguid) { if (IsStereo()) m_pActualTextureRight->FreePrivateData(refguid); return m_pActualTexture->FreePrivateData(refguid); }
HRESULT WINAPI D3D9ProxyCubeTexture::LockRect(D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) { if (IsStereo()) m_pActualTextureRight->LockRect(FaceType, Level, pLockedRect, pRect, Flags); return m_pActualTexture->LockRect(FaceType, Level, pLockedRect, pRect, Flags); }
HRESULT WINAPI D3D9ProxyCubeTexture::UnlockRect(D3DCUBEMAP_FACES FaceType, UINT Level) { if (IsStereo()) m_pActualTextureRight->UnlockRect(FaceType, Level); return m_pActualTexture->UnlockRect(FaceType, Level); }
HRESULT WINAPI D3D9ProxyCubeTexture::GetCubeMapSurface(D3DCUBEMAP_FACES FaceType, UINT Level, IDirect3DSurface9** ppCubeMapSurface) { HRESULT finalResult; CubeSurfaceKey key = CubeSurfaceKey(FaceType,Level); // Have we already got a Proxy for this surface level? if (m_wrappedSurfaceLevels.count(key) == 1) { // yes *ppCubeMapSurface = m_wrappedSurfaceLevels[key]; (*ppCubeMapSurface)->AddRef(); finalResult = D3D_OK; } else { // Get underlying surfaces (stereo pair made from the surfaces at the same level in the left and right textues), // wrap, then store in m_wrappedSurfaceLevels and return the wrapped surface IDirect3DSurface9* pActualSurfaceLevelLeft = NULL; IDirect3DSurface9* pActualSurfaceLevelRight = NULL; HRESULT leftResult = m_pActualTexture->GetCubeMapSurface(FaceType, Level, &pActualSurfaceLevelLeft); if (IsStereo()) { HRESULT resultRight = m_pActualTextureRight->GetCubeMapSurface(FaceType, Level, &pActualSurfaceLevelRight); assert (leftResult == resultRight); } if (SUCCEEDED(leftResult)) { D3D9ProxySurface* pWrappedSurfaceLevel = new D3D9ProxySurface(pActualSurfaceLevelLeft, pActualSurfaceLevelRight, m_pOwningDevice, this); if(m_wrappedSurfaceLevels.insert(std::pair<CubeSurfaceKey, D3D9ProxySurface*>(key, pWrappedSurfaceLevel)).second) { // insertion of wrapped surface level into m_wrappedSurfaceLevels succeeded *ppCubeMapSurface = pWrappedSurfaceLevel; (*ppCubeMapSurface)->AddRef(); finalResult = D3D_OK; } else { // Failure to insert should not be possible. In this case we could still return the wrapped surface, // however, if we did and it was requested again a new wrapped instance will be returned and things would explode // at some point. Better to fail fast. OutputDebugString(__FUNCTION__); OutputDebugString("\n"); OutputDebugString("Unable to store surface level.\n"); assert(false); finalResult = D3DERR_INVALIDCALL; } } else { OutputDebugString(__FUNCTION__); OutputDebugString("\n"); OutputDebugString("Error fetching actual surface level.\n"); finalResult = leftResult; } } return finalResult; }
/** * Sets private data on both (left/right) surfaces. ***/ HRESULT WINAPI D3D9ProxySurface::SetPrivateData(REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { SHOW_CALL("D3D9ProxySurface::SetPrivateData"); if (IsStereo()) m_pActualSurfaceRight->SetPrivateData(refguid, pData, SizeOfData, Flags); return m_pActualSurface->SetPrivateData(refguid, pData, SizeOfData, Flags); }
void D3D9ProxyTexture::WritingInStereo(bool stereo) { if (!IsStereo()) { return; } IDirect3DSurface9* pTextureLevel0; GetSurfaceLevel(0, &pTextureLevel0); D3D9ProxySurface* pWrappedTextureLevel0 = static_cast<D3D9ProxySurface*>(pTextureLevel0); pWrappedTextureLevel0->WritingInStereo(stereo); pTextureLevel0->Release(); }
bool D3D9ProxyTexture::ContainsStereoData() { if (!IsStereo()) { return false; } bool containsStereo = false; IDirect3DSurface9* pTextureLevel0; GetSurfaceLevel(0, &pTextureLevel0); D3D9ProxySurface* pWrappedTextureLevel0 = static_cast<D3D9ProxySurface*>(pTextureLevel0); containsStereo = pWrappedTextureLevel0->ContainsStereoData(); pTextureLevel0->Release(); return containsStereo; }
/** * Unlocks rectangle on both (left/right) surfaces. ***/ HRESULT WINAPI D3D9ProxySurface::UnlockRect() { SHOW_CALL("D3D9ProxySurface::UnlockRect"); D3DSURFACE_DESC desc; m_pActualSurface->GetDesc(&desc); if (desc.Pool != D3DPOOL_DEFAULT) { return m_pActualSurface->UnlockRect(); } //Guard against multithreaded access as this could be causing us problems std::lock_guard<std::mutex> lck (m_mtx); //This would mean nothing to do if (lockedRects.size() == 0 && !fullSurface) return S_OK; IDirect3DSurface9 *pSurface = NULL; HRESULT hr = lockableSysMemTexture ? lockableSysMemTexture->GetSurfaceLevel(0, &pSurface) : D3DERR_INVALIDCALL; if (FAILED(hr)) return hr; hr = pSurface->UnlockRect(); if (IsStereo()) { if (fullSurface) { hr = m_pOwningDevice->getActual()->UpdateSurface(pSurface, NULL, m_pActualSurfaceRight, NULL); if (FAILED(hr)) WriteDesc(desc); } else { std::vector<RECT>::iterator rectIter = lockedRects.begin(); while (rectIter != lockedRects.end()) { POINT p; p.x = rectIter->left; p.y = rectIter->top; hr = m_pOwningDevice->getActual()->UpdateSurface(pSurface, &(*rectIter), m_pActualSurfaceRight, &p); if (FAILED(hr)) WriteDesc(desc); rectIter++; } } } if (fullSurface) { hr = m_pOwningDevice->getActual()->UpdateSurface(pSurface, NULL, m_pActualSurface, NULL); if (FAILED(hr)) WriteDesc(desc); } else { std::vector<RECT>::iterator rectIter = lockedRects.begin(); while (rectIter != lockedRects.end()) { POINT p; p.x = rectIter->left; p.y = rectIter->top; hr = m_pOwningDevice->getActual()->UpdateSurface(pSurface, &(*rectIter), m_pActualSurface, &p); if (FAILED(hr)) WriteDesc(desc); rectIter++; } } pSurface->Release(); fullSurface = false; return hr; }
HRESULT WINAPI D3D9ProxyTexture::GetSurfaceLevel(UINT Level, IDirect3DSurface9** ppSurfaceLevel) { HRESULT finalResult; // Have we already got a Proxy for this surface level? if (m_wrappedSurfaceLevels.count(Level) == 1) { // yes // TODO Should we call through to underlying texture and make sure the result of doing this operation on the // underlying texture would still be a success? (not if we don't have to, will see if it becomes a problem) *ppSurfaceLevel = m_wrappedSurfaceLevels[Level]; (*ppSurfaceLevel)->AddRef(); finalResult = D3D_OK; } else { // Get underlying surfaces (stereo pair made from the surfaces at the same level in the left and right textues), // wrap, then store in m_wrappedSurfaceLevels and return the wrapped surface IDirect3DSurface9* pActualSurfaceLevelLeft = NULL; IDirect3DSurface9* pActualSurfaceLevelRight = NULL; HRESULT leftResult = m_pActualTexture->GetSurfaceLevel(Level, &pActualSurfaceLevelLeft); if (IsStereo()) { HRESULT resultRight = m_pActualTextureRight->GetSurfaceLevel(Level, &pActualSurfaceLevelRight); assert (leftResult == resultRight); } if (SUCCEEDED(leftResult)) { D3D9ProxySurface* pWrappedSurfaceLevel = new D3D9ProxySurface(pActualSurfaceLevelLeft, pActualSurfaceLevelRight, m_pOwningDevice, this); if(m_wrappedSurfaceLevels.insert(std::pair<ULONG, D3D9ProxySurface*>(Level, pWrappedSurfaceLevel)).second) { // insertion of wrapped surface level into m_wrappedSurfaceLevels succeeded *ppSurfaceLevel = pWrappedSurfaceLevel; (*ppSurfaceLevel)->AddRef(); finalResult = D3D_OK; } else { // Failure to insert should not be possible. In this case we could still return the wrapped surface, // however, if we did and it was requested again a new wrapped instance will be returned and things would explode // at some point. Better to fail fast. OutputDebugString(__FUNCTION__); OutputDebugString("\n"); OutputDebugString("Unable to store surface level.\n"); assert(false); finalResult = D3DERR_INVALIDCALL; } } else { OutputDebugString(__FUNCTION__); OutputDebugString("\n"); OutputDebugString("Error fetching actual surface level.\n"); finalResult = leftResult; } } return finalResult; }