mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-11 10:24:10 +01:00
[d3d11] Implement ID3D11RasterizerState2
This commit is contained in:
parent
f9d9307a28
commit
d9f409b92f
@ -910,7 +910,7 @@ namespace dxvk {
|
||||
ID3D11RasterizerState** ppRasterizerState) {
|
||||
InitReturnPtr(ppRasterizerState);
|
||||
|
||||
D3D11_RASTERIZER_DESC1 desc = pRasterizerDesc != nullptr
|
||||
D3D11_RASTERIZER_DESC2 desc = pRasterizerDesc
|
||||
? D3D11RasterizerState::PromoteDesc(pRasterizerDesc)
|
||||
: D3D11RasterizerState::DefaultDesc();
|
||||
|
||||
@ -929,8 +929,8 @@ namespace dxvk {
|
||||
ID3D11RasterizerState1** ppRasterizerState) {
|
||||
InitReturnPtr(ppRasterizerState);
|
||||
|
||||
D3D11_RASTERIZER_DESC1 desc = pRasterizerDesc != nullptr
|
||||
? *pRasterizerDesc
|
||||
D3D11_RASTERIZER_DESC2 desc = pRasterizerDesc
|
||||
? D3D11RasterizerState::PromoteDesc(pRasterizerDesc)
|
||||
: D3D11RasterizerState::DefaultDesc();
|
||||
|
||||
if (FAILED(D3D11RasterizerState::NormalizeDesc(&desc)))
|
||||
|
@ -5,7 +5,7 @@ namespace dxvk {
|
||||
|
||||
D3D11RasterizerState::D3D11RasterizerState(
|
||||
D3D11Device* device,
|
||||
const D3D11_RASTERIZER_DESC1& desc)
|
||||
const D3D11_RASTERIZER_DESC2& desc)
|
||||
: m_device(device), m_desc(desc), m_d3d10(this) {
|
||||
// Polygon mode. Determines whether the rasterizer fills
|
||||
// a polygon or renders lines connecting the vertices.
|
||||
@ -59,7 +59,8 @@ namespace dxvk {
|
||||
if (riid == __uuidof(IUnknown)
|
||||
|| riid == __uuidof(ID3D11DeviceChild)
|
||||
|| riid == __uuidof(ID3D11RasterizerState)
|
||||
|| riid == __uuidof(ID3D11RasterizerState1)) {
|
||||
|| riid == __uuidof(ID3D11RasterizerState1)
|
||||
|| riid == __uuidof(ID3D11RasterizerState2)) {
|
||||
*ppvObject = ref(this);
|
||||
return S_OK;
|
||||
}
|
||||
@ -96,6 +97,21 @@ namespace dxvk {
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D11RasterizerState::GetDesc1(D3D11_RASTERIZER_DESC1* pDesc) {
|
||||
pDesc->FillMode = m_desc.FillMode;
|
||||
pDesc->CullMode = m_desc.CullMode;
|
||||
pDesc->FrontCounterClockwise = m_desc.FrontCounterClockwise;
|
||||
pDesc->DepthBias = m_desc.DepthBias;
|
||||
pDesc->DepthBiasClamp = m_desc.DepthBiasClamp;
|
||||
pDesc->SlopeScaledDepthBias = m_desc.SlopeScaledDepthBias;
|
||||
pDesc->DepthClipEnable = m_desc.DepthClipEnable;
|
||||
pDesc->ScissorEnable = m_desc.ScissorEnable;
|
||||
pDesc->MultisampleEnable = m_desc.MultisampleEnable;
|
||||
pDesc->AntialiasedLineEnable = m_desc.AntialiasedLineEnable;
|
||||
pDesc->ForcedSampleCount = m_desc.ForcedSampleCount;
|
||||
}
|
||||
|
||||
|
||||
void STDMETHODCALLTYPE D3D11RasterizerState::GetDesc2(D3D11_RASTERIZER_DESC2* pDesc) {
|
||||
*pDesc = m_desc;
|
||||
}
|
||||
|
||||
@ -108,8 +124,8 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
D3D11_RASTERIZER_DESC1 D3D11RasterizerState::DefaultDesc() {
|
||||
D3D11_RASTERIZER_DESC1 dstDesc;
|
||||
D3D11_RASTERIZER_DESC2 D3D11RasterizerState::DefaultDesc() {
|
||||
D3D11_RASTERIZER_DESC2 dstDesc;
|
||||
dstDesc.FillMode = D3D11_FILL_SOLID;
|
||||
dstDesc.CullMode = D3D11_CULL_BACK;
|
||||
dstDesc.FrontCounterClockwise = FALSE;
|
||||
@ -121,13 +137,14 @@ namespace dxvk {
|
||||
dstDesc.MultisampleEnable = FALSE;
|
||||
dstDesc.AntialiasedLineEnable = FALSE;
|
||||
dstDesc.ForcedSampleCount = 0;
|
||||
dstDesc.ConservativeRaster = D3D11_CONSERVATIVE_RASTERIZATION_MODE_OFF;
|
||||
return dstDesc;
|
||||
}
|
||||
|
||||
|
||||
D3D11_RASTERIZER_DESC1 D3D11RasterizerState::PromoteDesc(
|
||||
D3D11_RASTERIZER_DESC2 D3D11RasterizerState::PromoteDesc(
|
||||
const D3D11_RASTERIZER_DESC* pSrcDesc) {
|
||||
D3D11_RASTERIZER_DESC1 dstDesc;
|
||||
D3D11_RASTERIZER_DESC2 dstDesc;
|
||||
dstDesc.FillMode = pSrcDesc->FillMode;
|
||||
dstDesc.CullMode = pSrcDesc->CullMode;
|
||||
dstDesc.FrontCounterClockwise = pSrcDesc->FrontCounterClockwise;
|
||||
@ -139,12 +156,32 @@ namespace dxvk {
|
||||
dstDesc.MultisampleEnable = pSrcDesc->MultisampleEnable;
|
||||
dstDesc.AntialiasedLineEnable = pSrcDesc->AntialiasedLineEnable;
|
||||
dstDesc.ForcedSampleCount = 0;
|
||||
dstDesc.ConservativeRaster = D3D11_CONSERVATIVE_RASTERIZATION_MODE_OFF;
|
||||
return dstDesc;
|
||||
}
|
||||
|
||||
|
||||
D3D11_RASTERIZER_DESC2 D3D11RasterizerState::PromoteDesc(
|
||||
const D3D11_RASTERIZER_DESC1* pSrcDesc) {
|
||||
D3D11_RASTERIZER_DESC2 dstDesc;
|
||||
dstDesc.FillMode = pSrcDesc->FillMode;
|
||||
dstDesc.CullMode = pSrcDesc->CullMode;
|
||||
dstDesc.FrontCounterClockwise = pSrcDesc->FrontCounterClockwise;
|
||||
dstDesc.DepthBias = pSrcDesc->DepthBias;
|
||||
dstDesc.DepthBiasClamp = pSrcDesc->DepthBiasClamp;
|
||||
dstDesc.SlopeScaledDepthBias = pSrcDesc->SlopeScaledDepthBias;
|
||||
dstDesc.DepthClipEnable = pSrcDesc->DepthClipEnable;
|
||||
dstDesc.ScissorEnable = pSrcDesc->ScissorEnable;
|
||||
dstDesc.MultisampleEnable = pSrcDesc->MultisampleEnable;
|
||||
dstDesc.AntialiasedLineEnable = pSrcDesc->AntialiasedLineEnable;
|
||||
dstDesc.ForcedSampleCount = 0;
|
||||
dstDesc.ConservativeRaster = D3D11_CONSERVATIVE_RASTERIZATION_MODE_OFF;
|
||||
return dstDesc;
|
||||
}
|
||||
|
||||
|
||||
HRESULT D3D11RasterizerState::NormalizeDesc(
|
||||
D3D11_RASTERIZER_DESC1* pDesc) {
|
||||
D3D11_RASTERIZER_DESC2* pDesc) {
|
||||
if (pDesc->FillMode < D3D11_FILL_WIREFRAME
|
||||
|| pDesc->FillMode > D3D11_FILL_SOLID)
|
||||
return E_INVALIDARG;
|
||||
@ -173,6 +210,10 @@ namespace dxvk {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
// Conservative rasterization currently not supported
|
||||
if (pDesc->ConservativeRaster != D3D11_CONSERVATIVE_RASTERIZATION_MODE_OFF)
|
||||
return E_INVALIDARG;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -10,15 +10,15 @@ namespace dxvk {
|
||||
|
||||
class D3D11Device;
|
||||
|
||||
class D3D11RasterizerState : public D3D11DeviceChild<ID3D11RasterizerState1> {
|
||||
class D3D11RasterizerState : public D3D11DeviceChild<ID3D11RasterizerState2> {
|
||||
|
||||
public:
|
||||
|
||||
using DescType = D3D11_RASTERIZER_DESC1;
|
||||
using DescType = D3D11_RASTERIZER_DESC2;
|
||||
|
||||
D3D11RasterizerState(
|
||||
D3D11Device* device,
|
||||
const D3D11_RASTERIZER_DESC1& desc);
|
||||
const D3D11_RASTERIZER_DESC2& desc);
|
||||
~D3D11RasterizerState();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(
|
||||
@ -34,7 +34,10 @@ namespace dxvk {
|
||||
void STDMETHODCALLTYPE GetDesc1(
|
||||
D3D11_RASTERIZER_DESC1* pDesc) final;
|
||||
|
||||
const D3D11_RASTERIZER_DESC1* Desc() const {
|
||||
void STDMETHODCALLTYPE GetDesc2(
|
||||
D3D11_RASTERIZER_DESC2* pDesc) final;
|
||||
|
||||
const D3D11_RASTERIZER_DESC2* Desc() const {
|
||||
return &m_desc;
|
||||
}
|
||||
|
||||
@ -45,18 +48,21 @@ namespace dxvk {
|
||||
return &m_d3d10;
|
||||
}
|
||||
|
||||
static D3D11_RASTERIZER_DESC1 DefaultDesc();
|
||||
static D3D11_RASTERIZER_DESC2 DefaultDesc();
|
||||
|
||||
static D3D11_RASTERIZER_DESC1 PromoteDesc(
|
||||
static D3D11_RASTERIZER_DESC2 PromoteDesc(
|
||||
const D3D11_RASTERIZER_DESC* pDesc);
|
||||
|
||||
static D3D11_RASTERIZER_DESC2 PromoteDesc(
|
||||
const D3D11_RASTERIZER_DESC1* pDesc);
|
||||
|
||||
static HRESULT NormalizeDesc(
|
||||
D3D11_RASTERIZER_DESC1* pDesc);
|
||||
D3D11_RASTERIZER_DESC2* pDesc);
|
||||
|
||||
private:
|
||||
|
||||
D3D11Device* const m_device;
|
||||
D3D11_RASTERIZER_DESC1 m_desc;
|
||||
D3D11_RASTERIZER_DESC2 m_desc;
|
||||
DxvkRasterizerState m_state;
|
||||
DxvkDepthBias m_depthBias;
|
||||
D3D10RasterizerState m_d3d10;
|
||||
|
@ -46,7 +46,7 @@ namespace dxvk {
|
||||
|
||||
|
||||
size_t D3D11StateDescHash::operator () (
|
||||
const D3D11_RASTERIZER_DESC1& desc) const {
|
||||
const D3D11_RASTERIZER_DESC2& desc) const {
|
||||
std::hash<float> fhash;
|
||||
|
||||
DxvkHashState hash;
|
||||
@ -61,6 +61,7 @@ namespace dxvk {
|
||||
hash.add(desc.MultisampleEnable);
|
||||
hash.add(desc.AntialiasedLineEnable);
|
||||
hash.add(desc.ForcedSampleCount);
|
||||
hash.add(desc.ConservativeRaster);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@ -144,8 +145,8 @@ namespace dxvk {
|
||||
|
||||
|
||||
bool D3D11StateDescEqual::operator () (
|
||||
const D3D11_RASTERIZER_DESC1& a,
|
||||
const D3D11_RASTERIZER_DESC1& b) const {
|
||||
const D3D11_RASTERIZER_DESC2& a,
|
||||
const D3D11_RASTERIZER_DESC2& b) const {
|
||||
return a.FillMode == b.FillMode
|
||||
&& a.CullMode == b.CullMode
|
||||
&& a.FrontCounterClockwise == b.FrontCounterClockwise
|
||||
@ -156,7 +157,8 @@ namespace dxvk {
|
||||
&& a.ScissorEnable == b.ScissorEnable
|
||||
&& a.MultisampleEnable == b.MultisampleEnable
|
||||
&& a.AntialiasedLineEnable == b.AntialiasedLineEnable
|
||||
&& a.ForcedSampleCount == b.ForcedSampleCount;
|
||||
&& a.ForcedSampleCount == b.ForcedSampleCount
|
||||
&& a.ConservativeRaster == b.ConservativeRaster;
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace dxvk {
|
||||
size_t operator () (const D3D11_BLEND_DESC1& desc) const;
|
||||
size_t operator () (const D3D11_DEPTH_STENCILOP_DESC& desc) const;
|
||||
size_t operator () (const D3D11_DEPTH_STENCIL_DESC& desc) const;
|
||||
size_t operator () (const D3D11_RASTERIZER_DESC1& desc) const;
|
||||
size_t operator () (const D3D11_RASTERIZER_DESC2& desc) const;
|
||||
size_t operator () (const D3D11_RENDER_TARGET_BLEND_DESC1& desc) const;
|
||||
size_t operator () (const D3D11_SAMPLER_DESC& desc) const;
|
||||
};
|
||||
@ -25,7 +25,7 @@ namespace dxvk {
|
||||
bool operator () (const D3D11_BLEND_DESC1& a, const D3D11_BLEND_DESC1& b) const;
|
||||
bool operator () (const D3D11_DEPTH_STENCILOP_DESC& a, const D3D11_DEPTH_STENCILOP_DESC& b) const;
|
||||
bool operator () (const D3D11_DEPTH_STENCIL_DESC& a, const D3D11_DEPTH_STENCIL_DESC& b) const;
|
||||
bool operator () (const D3D11_RASTERIZER_DESC1& a, const D3D11_RASTERIZER_DESC1& b) const;
|
||||
bool operator () (const D3D11_RASTERIZER_DESC2& a, const D3D11_RASTERIZER_DESC2& b) const;
|
||||
bool operator () (const D3D11_RENDER_TARGET_BLEND_DESC1& a, const D3D11_RENDER_TARGET_BLEND_DESC1& b) const;
|
||||
bool operator () (const D3D11_SAMPLER_DESC& a, const D3D11_SAMPLER_DESC& b) const;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user