mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-30 04:24:11 +01:00
[d3d10] Implement D3D10Shader
This commit is contained in:
parent
346c59bb62
commit
e671692886
@ -371,8 +371,21 @@ namespace dxvk {
|
||||
const void* pShaderBytecode,
|
||||
SIZE_T BytecodeLength,
|
||||
ID3D10VertexShader** ppVertexShader) {
|
||||
Logger::err("D3D10Device::CreateVertexShader: Not implemented");
|
||||
return E_NOTIMPL;
|
||||
InitReturnPtr(ppVertexShader);
|
||||
|
||||
ID3D11VertexShader* d3d11Shader = nullptr;
|
||||
|
||||
HRESULT hr = m_device->CreateVertexShader(
|
||||
pShaderBytecode, BytecodeLength, nullptr,
|
||||
ppVertexShader ? &d3d11Shader : nullptr);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (ppVertexShader != nullptr) {
|
||||
*ppVertexShader = static_cast<D3D11VertexShader*>(d3d11Shader)->GetD3D10Iface();
|
||||
return S_OK;
|
||||
} return S_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -380,8 +393,21 @@ namespace dxvk {
|
||||
const void* pShaderBytecode,
|
||||
SIZE_T BytecodeLength,
|
||||
ID3D10GeometryShader** ppGeometryShader) {
|
||||
Logger::err("D3D10Device::CreateGeometryShader: Not implemented");
|
||||
return E_NOTIMPL;
|
||||
InitReturnPtr(ppGeometryShader);
|
||||
|
||||
ID3D11GeometryShader* d3d11Shader = nullptr;
|
||||
|
||||
HRESULT hr = m_device->CreateGeometryShader(
|
||||
pShaderBytecode, BytecodeLength, nullptr,
|
||||
ppGeometryShader ? &d3d11Shader : nullptr);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (ppGeometryShader != nullptr) {
|
||||
*ppGeometryShader = static_cast<D3D11GeometryShader*>(d3d11Shader)->GetD3D10Iface();
|
||||
return S_OK;
|
||||
} return S_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -392,8 +418,36 @@ namespace dxvk {
|
||||
UINT NumEntries,
|
||||
UINT OutputStreamStride,
|
||||
ID3D10GeometryShader** ppGeometryShader) {
|
||||
Logger::err("D3D10Device::CreateGeometryShaderWithStreamOutput: Not implemented");
|
||||
return E_NOTIMPL;
|
||||
InitReturnPtr(ppGeometryShader);
|
||||
|
||||
std::vector<D3D11_SO_DECLARATION_ENTRY> d3d11Entries(NumEntries);
|
||||
|
||||
for (uint32_t i = 0; i < NumEntries; i++) {
|
||||
d3d11Entries[i].Stream = 0;
|
||||
d3d11Entries[i].SemanticName = pSODeclaration[i].SemanticName;
|
||||
d3d11Entries[i].SemanticIndex = pSODeclaration[i].SemanticIndex;
|
||||
d3d11Entries[i].StartComponent = pSODeclaration[i].StartComponent;
|
||||
d3d11Entries[i].ComponentCount = pSODeclaration[i].ComponentCount;
|
||||
d3d11Entries[i].OutputSlot = pSODeclaration[i].OutputSlot;
|
||||
}
|
||||
|
||||
ID3D11GeometryShader* d3d11Shader = nullptr;
|
||||
|
||||
HRESULT hr = m_device->CreateGeometryShaderWithStreamOutput(
|
||||
pShaderBytecode, BytecodeLength,
|
||||
d3d11Entries.data(),
|
||||
d3d11Entries.size(),
|
||||
&OutputStreamStride, 1,
|
||||
D3D11_SO_NO_RASTERIZED_STREAM, nullptr,
|
||||
ppGeometryShader ? &d3d11Shader : nullptr);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (ppGeometryShader != nullptr) {
|
||||
*ppGeometryShader = static_cast<D3D11GeometryShader*>(d3d11Shader)->GetD3D10Iface();
|
||||
return S_OK;
|
||||
} return S_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@ -401,8 +455,21 @@ namespace dxvk {
|
||||
const void* pShaderBytecode,
|
||||
SIZE_T BytecodeLength,
|
||||
ID3D10PixelShader** ppPixelShader) {
|
||||
Logger::err("D3D10Device::CreatePixelShader: Not implemented");
|
||||
return E_NOTIMPL;
|
||||
InitReturnPtr(ppPixelShader);
|
||||
|
||||
ID3D11PixelShader* d3d11Shader = nullptr;
|
||||
|
||||
HRESULT hr = m_device->CreatePixelShader(
|
||||
pShaderBytecode, BytecodeLength, nullptr,
|
||||
ppPixelShader ? &d3d11Shader : nullptr);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (ppPixelShader != nullptr) {
|
||||
*ppPixelShader = static_cast<D3D11PixelShader*>(d3d11Shader)->GetD3D10Iface();
|
||||
return S_OK;
|
||||
} return S_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
78
src/d3d10/d3d10_shader.h
Normal file
78
src/d3d10/d3d10_shader.h
Normal file
@ -0,0 +1,78 @@
|
||||
#pragma once
|
||||
|
||||
#include "d3d10_util.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
template<typename D3D11Interface, typename D3D10Interface>
|
||||
class D3D11Shader;
|
||||
|
||||
template<typename D3D10Interface, typename D3D11Interface>
|
||||
class D3D10Shader : public D3D10Interface {
|
||||
using D3D11ShaderClass = D3D11Shader<D3D11Interface, D3D10Interface>;
|
||||
public:
|
||||
|
||||
D3D10Shader(D3D11Shader<D3D11Interface, D3D10Interface>* pParent)
|
||||
: m_d3d11(pParent) { }
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(
|
||||
REFIID riid,
|
||||
void** ppvObject) {
|
||||
return m_d3d11->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
|
||||
ULONG STDMETHODCALLTYPE AddRef() {
|
||||
return m_d3d11->AddRef();
|
||||
}
|
||||
|
||||
|
||||
ULONG STDMETHODCALLTYPE Release() {
|
||||
return m_d3d11->Release();
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE GetDevice(
|
||||
ID3D10Device** ppDevice) {
|
||||
GetD3D10Device(m_d3d11, ppDevice);
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE GetPrivateData(
|
||||
REFGUID guid,
|
||||
UINT* pDataSize,
|
||||
void* pData) {
|
||||
return m_d3d11->GetPrivateData(guid, pDataSize, pData);
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateData(
|
||||
REFGUID guid,
|
||||
UINT DataSize,
|
||||
const void* pData) {
|
||||
return m_d3d11->SetPrivateData(guid, DataSize, pData);
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE SetPrivateDataInterface(
|
||||
REFGUID guid,
|
||||
const IUnknown* pData) {
|
||||
return m_d3d11->SetPrivateDataInterface(guid, pData);
|
||||
}
|
||||
|
||||
D3D11ShaderClass* GetD3D11Iface() {
|
||||
return m_d3d11;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
D3D11ShaderClass* m_d3d11;
|
||||
|
||||
};
|
||||
|
||||
using D3D10VertexShader = D3D10Shader<ID3D10VertexShader, ID3D11VertexShader>;
|
||||
using D3D10GeometryShader = D3D10Shader<ID3D10GeometryShader, ID3D11GeometryShader>;
|
||||
using D3D10PixelShader = D3D10Shader<ID3D10PixelShader, ID3D11PixelShader>;
|
||||
|
||||
}
|
@ -6,6 +6,8 @@
|
||||
#include "../dxbc/dxbc_module.h"
|
||||
#include "../dxvk/dxvk_device.h"
|
||||
|
||||
#include "../d3d10/d3d10_shader.h"
|
||||
|
||||
#include "../util/sha1/sha1_util.h"
|
||||
|
||||
#include "../util/util_env.h"
|
||||
@ -104,13 +106,13 @@ namespace dxvk {
|
||||
* interfaces and stores the actual shader
|
||||
* module object.
|
||||
*/
|
||||
template<typename Base>
|
||||
class D3D11Shader : public D3D11DeviceChild<Base> {
|
||||
|
||||
template<typename D3D11Interface, typename D3D10Interface>
|
||||
class D3D11Shader : public D3D11DeviceChild<D3D11Interface> {
|
||||
using D3D10ShaderClass = D3D10Shader<D3D10Interface, D3D11Interface>;
|
||||
public:
|
||||
|
||||
D3D11Shader(D3D11Device* device, const D3D11CommonShader& shader)
|
||||
: m_device(device), m_shader(shader) { }
|
||||
: m_device(device), m_shader(shader), m_d3d10(this) { }
|
||||
|
||||
~D3D11Shader() { }
|
||||
|
||||
@ -119,11 +121,18 @@ namespace dxvk {
|
||||
|
||||
if (riid == __uuidof(IUnknown)
|
||||
|| riid == __uuidof(ID3D11DeviceChild)
|
||||
|| riid == __uuidof(Base)) {
|
||||
|| riid == __uuidof(D3D11Interface)) {
|
||||
*ppvObject = ref(this);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (riid == __uuidof(IUnknown)
|
||||
|| riid == __uuidof(ID3D10DeviceChild)
|
||||
|| riid == __uuidof(D3D10Interface)) {
|
||||
*ppvObject = ref(&m_d3d10);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
Logger::warn("D3D11Shader::QueryInterface: Unknown interface query");
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
@ -135,20 +144,25 @@ namespace dxvk {
|
||||
const D3D11CommonShader* GetCommonShader() const {
|
||||
return &m_shader;
|
||||
}
|
||||
|
||||
|
||||
D3D10ShaderClass* GetD3D10Iface() {
|
||||
return &m_d3d10;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Com<D3D11Device> m_device;
|
||||
D3D11CommonShader m_shader;
|
||||
D3D10ShaderClass m_d3d10;
|
||||
|
||||
};
|
||||
|
||||
using D3D11VertexShader = D3D11Shader<ID3D11VertexShader>;
|
||||
using D3D11HullShader = D3D11Shader<ID3D11HullShader>;
|
||||
using D3D11DomainShader = D3D11Shader<ID3D11DomainShader>;
|
||||
using D3D11GeometryShader = D3D11Shader<ID3D11GeometryShader>;
|
||||
using D3D11PixelShader = D3D11Shader<ID3D11PixelShader>;
|
||||
using D3D11ComputeShader = D3D11Shader<ID3D11ComputeShader>;
|
||||
using D3D11VertexShader = D3D11Shader<ID3D11VertexShader, ID3D10VertexShader>;
|
||||
using D3D11HullShader = D3D11Shader<ID3D11HullShader, ID3D10DeviceChild>;
|
||||
using D3D11DomainShader = D3D11Shader<ID3D11DomainShader, ID3D10DeviceChild>;
|
||||
using D3D11GeometryShader = D3D11Shader<ID3D11GeometryShader, ID3D10GeometryShader>;
|
||||
using D3D11PixelShader = D3D11Shader<ID3D11PixelShader, ID3D10PixelShader>;
|
||||
using D3D11ComputeShader = D3D11Shader<ID3D11ComputeShader, ID3D10DeviceChild>;
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user