1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[d3d10] Implement D3D10Buffer

This commit is contained in:
Philip Rebohle 2018-08-11 19:28:30 +02:00
parent 7754cb1115
commit 553c90307a
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 224 additions and 4 deletions

113
src/d3d10/d3d10_buffer.cpp Normal file
View File

@ -0,0 +1,113 @@
#include "d3d10_buffer.h"
#include "../d3d11/d3d11_buffer.h"
#include "../d3d11/d3d11_device.h"
#include "../d3d11/d3d11_context.h"
namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D10Buffer::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_d3d11->QueryInterface(riid, ppvObject);
}
ULONG STDMETHODCALLTYPE D3D10Buffer::AddRef() {
return m_d3d11->AddRef();
}
ULONG STDMETHODCALLTYPE D3D10Buffer::Release() {
return m_d3d11->Release();
}
void STDMETHODCALLTYPE D3D10Buffer::GetDevice(
ID3D10Device** ppDevice) {
GetD3D10Device(m_d3d11, ppDevice);
}
HRESULT STDMETHODCALLTYPE D3D10Buffer::GetPrivateData(
REFGUID guid,
UINT* pDataSize,
void* pData) {
return m_d3d11->GetPrivateData(guid, pDataSize, pData);
}
HRESULT STDMETHODCALLTYPE D3D10Buffer::SetPrivateData(
REFGUID guid,
UINT DataSize,
const void* pData) {
return m_d3d11->SetPrivateData(guid, DataSize, pData);
}
HRESULT STDMETHODCALLTYPE D3D10Buffer::SetPrivateDataInterface(
REFGUID guid,
const IUnknown* pData) {
return m_d3d11->SetPrivateDataInterface(guid, pData);
}
void STDMETHODCALLTYPE D3D10Buffer::GetType(
D3D10_RESOURCE_DIMENSION* rType) {
*rType = D3D10_RESOURCE_DIMENSION_TEXTURE1D;
}
void STDMETHODCALLTYPE D3D10Buffer::SetEvictionPriority(
UINT EvictionPriority) {
m_d3d11->SetEvictionPriority(EvictionPriority);
}
UINT STDMETHODCALLTYPE D3D10Buffer::GetEvictionPriority() {
return m_d3d11->GetEvictionPriority();
}
HRESULT STDMETHODCALLTYPE D3D10Buffer::Map(
D3D10_MAP MapType,
UINT MapFlags,
void** ppData) {
Com<ID3D11DeviceContext> ctx;
GetD3D11Context(m_d3d11, &ctx);
D3D11_MAPPED_SUBRESOURCE sr;
HRESULT hr = ctx->Map(m_d3d11, 0,
D3D11_MAP(MapType), MapFlags, &sr);
if (FAILED(hr))
return hr;
if (ppData != nullptr) {
*ppData = sr.pData;
return S_OK;
} return S_FALSE;
}
void STDMETHODCALLTYPE D3D10Buffer::Unmap() {
Com<ID3D11DeviceContext> ctx;
GetD3D11Context(m_d3d11, &ctx);
ctx->Unmap(m_d3d11, 0);
}
void STDMETHODCALLTYPE D3D10Buffer::GetDesc(
D3D10_BUFFER_DESC* pDesc) {
D3D11_BUFFER_DESC d3d11Desc;
m_d3d11->GetDesc(&d3d11Desc);
pDesc->ByteWidth = d3d11Desc.ByteWidth;
pDesc->Usage = D3D10_USAGE(d3d11Desc.Usage);
pDesc->BindFlags = d3d11Desc.BindFlags & 0x7F;
pDesc->CPUAccessFlags = d3d11Desc.CPUAccessFlags;
pDesc->MiscFlags = ConvertD3D11ResourceFlags(d3d11Desc.MiscFlags);
}
}

70
src/d3d10/d3d10_buffer.h Normal file
View File

@ -0,0 +1,70 @@
#pragma once
#include "d3d10_util.h"
namespace dxvk {
class D3D11Buffer;
class D3D11Device;
class D3D10Buffer : public ID3D10Buffer {
public:
D3D10Buffer(D3D11Buffer* pParent)
: m_d3d11(pParent) { }
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
void STDMETHODCALLTYPE GetDevice(
ID3D10Device** ppDevice);
HRESULT STDMETHODCALLTYPE GetPrivateData(
REFGUID guid,
UINT* pDataSize,
void* pData);
HRESULT STDMETHODCALLTYPE SetPrivateData(
REFGUID guid,
UINT DataSize,
const void* pData);
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(
REFGUID guid,
const IUnknown* pData);
void STDMETHODCALLTYPE GetType(
D3D10_RESOURCE_DIMENSION* rType);
void STDMETHODCALLTYPE SetEvictionPriority(
UINT EvictionPriority);
UINT STDMETHODCALLTYPE GetEvictionPriority();
HRESULT STDMETHODCALLTYPE Map(
D3D10_MAP MapType,
UINT MapFlags,
void** ppData);
void STDMETHODCALLTYPE Unmap();
void STDMETHODCALLTYPE GetDesc(
D3D10_BUFFER_DESC* pDesc);
D3D11Buffer* GetD3D11Iface() {
return m_d3d11;
}
private:
D3D11Buffer* m_d3d11;
};
}

View File

@ -93,8 +93,28 @@ namespace dxvk {
const D3D10_BUFFER_DESC* pDesc,
const D3D10_SUBRESOURCE_DATA* pInitialData,
ID3D10Buffer** ppBuffer) {
Logger::err("D3D10Device::CreateBuffer: Not implemented");
return E_NOTIMPL;
InitReturnPtr(ppBuffer);
D3D11_BUFFER_DESC d3d11Desc;
d3d11Desc.ByteWidth = pDesc->ByteWidth;
d3d11Desc.Usage = D3D11_USAGE(pDesc->Usage);
d3d11Desc.BindFlags = pDesc->BindFlags;
d3d11Desc.CPUAccessFlags = pDesc->CPUAccessFlags;
d3d11Desc.MiscFlags = ConvertD3D10ResourceFlags(pDesc->MiscFlags);
d3d11Desc.StructureByteStride = 0;
ID3D11Buffer* d3d11Buffer = nullptr;
HRESULT hr = m_device->CreateBuffer(&d3d11Desc,
reinterpret_cast<const D3D11_SUBRESOURCE_DATA*>(pInitialData),
ppBuffer != nullptr ? &d3d11Buffer : nullptr);
if (FAILED(hr))
return hr;
if (ppBuffer != nullptr) {
*ppBuffer = static_cast<D3D11Buffer*>(d3d11Buffer)->GetD3D10Iface();
return S_OK;
} return S_FALSE;
}

View File

@ -12,7 +12,8 @@ namespace dxvk {
: m_device (pDevice),
m_desc (*pDesc),
m_buffer (CreateBuffer(pDesc)),
m_mappedSlice (m_buffer->slice()) {
m_mappedSlice (m_buffer->slice()),
m_d3d10 (this) {
}
@ -33,6 +34,13 @@ namespace dxvk {
return S_OK;
}
if (riid == __uuidof(ID3D10DeviceChild)
|| riid == __uuidof(ID3D10Resource)
|| riid == __uuidof(ID3D10Buffer)) {
*ppvObject = ref(&m_d3d10);
return S_OK;
}
Logger::warn("D3D11Buffer::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
return E_NOINTERFACE;

View File

@ -1,6 +1,8 @@
#pragma once
#include <dxvk_device.h>
#include "../dxvk/dxvk_device.h"
#include "../d3d10/d3d10_buffer.h"
#include "d3d11_device_child.h"
#include "d3d11_interfaces.h"
@ -73,6 +75,10 @@ namespace dxvk {
m_mappedSlice = slice;
}
D3D10Buffer* GetD3D10Iface() {
return &m_d3d10;
}
private:
const Com<D3D11Device> m_device;
@ -81,6 +87,8 @@ namespace dxvk {
Rc<DxvkBuffer> m_buffer;
DxvkPhysicalBufferSlice m_mappedSlice;
D3D10Buffer m_d3d10;
Rc<DxvkBuffer> CreateBuffer(
const D3D11_BUFFER_DESC* pDesc) const;

View File

@ -1,4 +1,5 @@
d3d10_src = [
'../d3d10/d3d10_buffer.cpp',
'../d3d10/d3d10_device.cpp',
'../d3d10/d3d10_texture.cpp',
'../d3d10/d3d10_util.cpp',