#pragma once #include "d3d8_resource.h" namespace dxvk { // Base class for Surfaces and Volumes, // which can be attached to Textures. template class D3D8Subresource : public D3D8Resource { using Resource = D3D8Resource; public: D3D8Subresource( D3D8Device* pDevice, Com&& 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; }; }