mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-30 22:24:15 +01:00
[d3d11] Added support for tessellation patch primitives
This commit is contained in:
parent
8c4d94b570
commit
52e8918b57
@ -899,33 +899,48 @@ namespace dxvk {
|
||||
|
||||
if (Topology == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED)
|
||||
return;
|
||||
|
||||
const DxvkInputAssemblyState iaState = [&] () -> DxvkInputAssemblyState {
|
||||
switch (Topology) {
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_POINTLIST:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_POINT_LIST, VK_FALSE };
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_LINELIST:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_LINE_LIST, VK_FALSE };
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, VK_TRUE };
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, VK_FALSE };
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, VK_TRUE };
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, VK_FALSE };
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY, VK_TRUE };
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, VK_FALSE };
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY, VK_TRUE };
|
||||
|
||||
default:
|
||||
Logger::err(str::format("D3D11DeviceContext::IASetPrimitiveTopology: Unknown primitive topology: ", Topology));
|
||||
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, VK_FALSE };
|
||||
|
||||
const DxvkInputAssemblyState iaState = [Topology] () -> DxvkInputAssemblyState {
|
||||
if (Topology >= D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST
|
||||
&& Topology <= D3D11_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST) {
|
||||
// Tessellation patch. The number of control points per
|
||||
// patch can be inferred from the enum value in D3D11.
|
||||
return { VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, VK_FALSE,
|
||||
uint32_t(Topology - D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + 1) };
|
||||
} else {
|
||||
switch (Topology) {
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_POINTLIST:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_POINT_LIST, VK_FALSE, 0 };
|
||||
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_LINELIST:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_LINE_LIST, VK_FALSE, 0 };
|
||||
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, VK_TRUE, 0 };
|
||||
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, VK_FALSE, 0 };
|
||||
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, VK_TRUE, 0 };
|
||||
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, VK_FALSE, 0 };
|
||||
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY, VK_TRUE, 0 };
|
||||
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, VK_FALSE, 0 };
|
||||
|
||||
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ:
|
||||
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY, VK_TRUE, 0 };
|
||||
|
||||
default:
|
||||
Logger::err(str::format("D3D11: Invalid primitive topology: ", Topology));
|
||||
return { };
|
||||
}
|
||||
}
|
||||
|
||||
}();
|
||||
|
||||
EmitCs([iaState] (DxvkContext* ctx) {
|
||||
@ -2209,6 +2224,5 @@ namespace dxvk {
|
||||
return slice;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -584,7 +584,6 @@ namespace dxvk {
|
||||
|
||||
virtual void EmitCsChunk(Rc<DxvkCsChunk>&& chunk) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ namespace dxvk {
|
||||
struct DxvkInputAssemblyState {
|
||||
VkPrimitiveTopology primitiveTopology;
|
||||
VkBool32 primitiveRestart;
|
||||
uint32_t patchVertexCount;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1006,6 +1006,7 @@ namespace dxvk {
|
||||
void DxvkContext::setInputAssemblyState(const DxvkInputAssemblyState& ia) {
|
||||
m_state.gp.state.iaPrimitiveTopology = ia.primitiveTopology;
|
||||
m_state.gp.state.iaPrimitiveRestart = ia.primitiveRestart;
|
||||
m_state.gp.state.iaPatchVertexCount = ia.patchVertexCount;
|
||||
|
||||
m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
|
||||
}
|
||||
|
@ -139,6 +139,12 @@ namespace dxvk {
|
||||
iaInfo.topology = state.iaPrimitiveTopology;
|
||||
iaInfo.primitiveRestartEnable = state.iaPrimitiveRestart;
|
||||
|
||||
VkPipelineTessellationStateCreateInfo tsInfo;
|
||||
tsInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
|
||||
tsInfo.pNext = nullptr;
|
||||
tsInfo.flags = 0;
|
||||
tsInfo.patchControlPoints = state.iaPatchVertexCount;
|
||||
|
||||
VkPipelineViewportStateCreateInfo vpInfo;
|
||||
vpInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
||||
vpInfo.pNext = nullptr;
|
||||
@ -222,7 +228,7 @@ namespace dxvk {
|
||||
info.pStages = stages.data();
|
||||
info.pVertexInputState = &viInfo;
|
||||
info.pInputAssemblyState = &iaInfo;
|
||||
info.pTessellationState = nullptr; // TODO implement
|
||||
info.pTessellationState = &tsInfo;
|
||||
info.pViewportState = &vpInfo;
|
||||
info.pRasterizationState = &rsInfo;
|
||||
info.pMultisampleState = &msInfo;
|
||||
@ -235,6 +241,9 @@ namespace dxvk {
|
||||
info.basePipelineHandle = baseHandle;
|
||||
info.basePipelineIndex = -1;
|
||||
|
||||
if (tsInfo.patchControlPoints == 0)
|
||||
info.pTessellationState = nullptr;
|
||||
|
||||
VkPipeline pipeline = VK_NULL_HANDLE;
|
||||
if (m_vkd->vkCreateGraphicsPipelines(m_vkd->device(),
|
||||
m_cache->handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS)
|
||||
|
@ -37,6 +37,7 @@ namespace dxvk {
|
||||
|
||||
VkPrimitiveTopology iaPrimitiveTopology;
|
||||
VkBool32 iaPrimitiveRestart;
|
||||
uint32_t iaPatchVertexCount;
|
||||
|
||||
uint32_t ilAttributeCount;
|
||||
uint32_t ilBindingCount;
|
||||
|
Loading…
Reference in New Issue
Block a user