1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-20 17:52:11 +01:00
dxvk/src/d3d8/d3d8_subresource.h
Jeff 60e523b4bf
[d3d8] Implement Direct3D 8 Frontend
Co-authored-by: WinterSnowfall <WinterSnowfall@users.noreply.github.com>

## Config Changes

Co-authored-by: Blisto91 <47954800+Blisto91@users.noreply.github.com>
Co-authored-by: simifor <simirmonfor@gmail.com>
2024-07-07 11:10:48 +00:00

61 lines
1.4 KiB
C++

#pragma once
#include "d3d8_resource.h"
namespace dxvk {
// Base class for Surfaces and Volumes,
// which can be attached to Textures.
template <typename D3D9, typename D3D8>
class D3D8Subresource : public D3D8Resource<D3D9, D3D8> {
using Resource = D3D8Resource<D3D9, D3D8>;
public:
D3D8Subresource(
D3D8Device* pDevice,
Com<D3D9>&& Object,
IDirect3DBaseTexture8* pBaseTexture)
: Resource(pDevice, std::move(Object)),
m_container(pBaseTexture) {
}
~D3D8Subresource() {
}
// Refing subresources implicitly refs the container texture,
ULONG STDMETHODCALLTYPE AddRef() final {
if (m_container != nullptr)
return m_container->AddRef();
return Resource::AddRef();
}
// and releasing them implicitly releases the texture.
ULONG STDMETHODCALLTYPE Release() final {
if (m_container != nullptr)
return m_container->Release();
return Resource::Release();
}
// Clients can grab the container if they want
HRESULT STDMETHODCALLTYPE GetContainer(REFIID riid, void** ppContainer) final {
if (m_container != nullptr)
return m_container->QueryInterface(riid, ppContainer);
return this->GetDevice()->QueryInterface(riid, ppContainer);
}
inline IDirect3DBaseTexture8* GetBaseTexture() {
return m_container;
}
protected:
IDirect3DBaseTexture8* m_container;
};
}