1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-05 19:46:15 +01:00
dxvk/src/d3d9/d3d9_buffer.h
Joshie 54ed8f0bb0 [d3d9] Implement Direct3D9 Frontend (#1275)
Co-authored-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Co-authored-by: Robin Kertels <robin.kertels@gmail.com>
Co-authored-by: pchome <pchome@users.noreply.github.com>
Co-authored-by: Christopher Egert <cme3000@gmail.com>
Co-authored-by: Derek Lesho <dereklesho52@Gmail.com>
Co-authored-by: Luis Cáceres <lacaceres97@gmail.com>
Co-authored-by: Nelson Chen <crazysim@gmail.com>
Co-authored-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Co-authored-by: Riesi <riesi@opentrash.com>
Co-authored-by: gbMichelle <gbmichelle.dev@gmail.com>
2019-12-16 04:28:01 +01:00

92 lines
2.0 KiB
C++

#pragma once
#include "d3d9_resource.h"
#include "d3d9_common_buffer.h"
namespace dxvk {
template <typename... Type>
class D3D9Buffer : public D3D9Resource<Type...> {
public:
D3D9Buffer(
D3D9DeviceEx* pDevice,
const D3D9_BUFFER_DESC* pDesc)
: D3D9Resource<Type...> ( pDevice )
, m_buffer ( pDevice, pDesc ) { }
HRESULT STDMETHODCALLTYPE Lock(
UINT OffsetToLock,
UINT SizeToLock,
void** ppbData,
DWORD Flags) final {
return m_buffer.Lock(
OffsetToLock,
SizeToLock,
ppbData,
Flags);
}
HRESULT STDMETHODCALLTYPE Unlock() final {
return m_buffer.Unlock();
}
D3D9CommonBuffer* GetCommonBuffer() {
return &m_buffer;
}
protected:
D3D9CommonBuffer m_buffer;
};
using D3D9VertexBufferBase = D3D9Buffer<IDirect3DVertexBuffer9>;
class D3D9VertexBuffer final : public D3D9VertexBufferBase {
public:
D3D9VertexBuffer(
D3D9DeviceEx* pDevice,
const D3D9_BUFFER_DESC* pDesc);
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject) final;
D3DRESOURCETYPE STDMETHODCALLTYPE GetType() final;
HRESULT STDMETHODCALLTYPE GetDesc(
D3DVERTEXBUFFER_DESC* pDesc) final;
};
using D3D9IndexBufferBase = D3D9Buffer<IDirect3DIndexBuffer9>;
class D3D9IndexBuffer final : public D3D9IndexBufferBase {
public:
D3D9IndexBuffer(
D3D9DeviceEx* pDevice,
const D3D9_BUFFER_DESC* pDesc);
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject) final;
D3DRESOURCETYPE STDMETHODCALLTYPE GetType() final;
HRESULT STDMETHODCALLTYPE GetDesc(
D3DINDEXBUFFER_DESC* pDesc) final;
};
template <typename T>
inline D3D9CommonBuffer* GetCommonBuffer(const T& pResource) {
return pResource != nullptr ? pResource->GetCommonBuffer() : nullptr;
}
}