2017-12-06 13:16:54 +01:00
|
|
|
#include "d3d11_device.h"
|
2017-12-10 23:27:20 +01:00
|
|
|
#include "d3d11_rasterizer.h"
|
2017-12-06 13:16:54 +01:00
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
D3D11RasterizerState::D3D11RasterizerState(
|
|
|
|
D3D11Device* device,
|
|
|
|
const D3D11_RASTERIZER_DESC& desc)
|
|
|
|
: m_device(device), m_desc(desc) {
|
|
|
|
|
2017-12-08 00:02:43 +01:00
|
|
|
// State that is not supported in D3D11
|
|
|
|
m_state.enableDepthClamp = VK_FALSE;
|
|
|
|
m_state.enableDiscard = VK_FALSE;
|
|
|
|
|
2017-12-06 13:16:54 +01:00
|
|
|
// Polygon mode. Determines whether the rasterizer fills
|
|
|
|
// a polygon or renders lines connecting the vertices.
|
2017-12-08 00:02:43 +01:00
|
|
|
m_state.polygonMode = VK_POLYGON_MODE_FILL;
|
2017-12-06 13:16:54 +01:00
|
|
|
|
|
|
|
switch (desc.FillMode) {
|
2017-12-08 00:02:43 +01:00
|
|
|
case D3D11_FILL_WIREFRAME: m_state.polygonMode = VK_POLYGON_MODE_LINE; break;
|
|
|
|
case D3D11_FILL_SOLID: m_state.polygonMode = VK_POLYGON_MODE_FILL; break;
|
2017-12-06 13:16:54 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
Logger::err(str::format(
|
|
|
|
"D3D11RasterizerState: Unsupported fill mode: ",
|
|
|
|
desc.FillMode));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Face culling properties. The rasterizer may discard
|
|
|
|
// polygons that are facing towards or away from the
|
|
|
|
// viewer, depending on the options below.
|
2017-12-08 00:02:43 +01:00
|
|
|
m_state.cullMode = VK_CULL_MODE_NONE;
|
2017-12-06 13:16:54 +01:00
|
|
|
|
|
|
|
switch (desc.CullMode) {
|
2017-12-08 00:02:43 +01:00
|
|
|
case D3D11_CULL_NONE: m_state.cullMode = VK_CULL_MODE_NONE; break;
|
|
|
|
case D3D11_CULL_FRONT: m_state.cullMode = VK_CULL_MODE_FRONT_BIT; break;
|
|
|
|
case D3D11_CULL_BACK: m_state.cullMode = VK_CULL_MODE_BACK_BIT; break;
|
2017-12-06 13:16:54 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
Logger::err(str::format(
|
|
|
|
"D3D11RasterizerState: Unsupported cull mode: ",
|
|
|
|
desc.CullMode));
|
|
|
|
}
|
|
|
|
|
2017-12-08 00:02:43 +01:00
|
|
|
m_state.frontFace = desc.FrontCounterClockwise
|
2017-12-06 13:16:54 +01:00
|
|
|
? VK_FRONT_FACE_COUNTER_CLOCKWISE
|
|
|
|
: VK_FRONT_FACE_CLOCKWISE;
|
|
|
|
|
2017-12-08 00:02:43 +01:00
|
|
|
// Let's treat the depth bias as enabled by default
|
|
|
|
m_state.depthBiasEnable = VK_TRUE;
|
|
|
|
m_state.depthBiasConstant = static_cast<float>(desc.DepthBias);
|
|
|
|
m_state.depthBiasClamp = desc.DepthBiasClamp;
|
|
|
|
m_state.depthBiasSlope = desc.SlopeScaledDepthBias;
|
2017-12-06 13:16:54 +01:00
|
|
|
|
2017-12-08 00:02:43 +01:00
|
|
|
// TODO implement depth clamp. Note that there are differences
|
|
|
|
// between D3D11 depth clip (disabled) and Vulkan depth clamp.
|
2017-12-06 13:16:54 +01:00
|
|
|
if (!desc.DepthClipEnable)
|
2017-12-08 00:02:43 +01:00
|
|
|
Logger::err("D3D11RasterizerState: Depth clamp not supported");
|
2017-12-06 13:16:54 +01:00
|
|
|
|
|
|
|
if (desc.AntialiasedLineEnable)
|
|
|
|
Logger::err("D3D11RasterizerState: Antialiased lines not supported");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
D3D11RasterizerState::~D3D11RasterizerState() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT D3D11RasterizerState::QueryInterface(REFIID riid, void** ppvObject) {
|
|
|
|
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
|
|
|
|
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
|
|
|
|
COM_QUERY_IFACE(riid, ppvObject, ID3D11RasterizerState);
|
|
|
|
|
|
|
|
Logger::warn("D3D11RasterizerState::QueryInterface: Unknown interface query");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void D3D11RasterizerState::GetDevice(ID3D11Device** ppDevice) {
|
2017-12-11 17:01:38 +01:00
|
|
|
*ppDevice = ref(m_device);
|
2017-12-06 13:16:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void D3D11RasterizerState::GetDesc(D3D11_RASTERIZER_DESC* pDesc) {
|
|
|
|
*pDesc = m_desc;
|
|
|
|
}
|
|
|
|
|
2017-12-11 13:07:27 +01:00
|
|
|
|
|
|
|
void D3D11RasterizerState::BindToContext(const Rc<DxvkContext>& ctx) {
|
|
|
|
ctx->setRasterizerState(m_state);
|
|
|
|
}
|
|
|
|
|
2017-12-06 13:16:54 +01:00
|
|
|
}
|