1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-04-06 00:57:40 +02:00

[d3d11] Added support for tessellation patch primitives

This commit is contained in:
Philip Rebohle 2018-01-29 11:31:00 +01:00
parent 8c4d94b570
commit 52e8918b57
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 54 additions and 29 deletions

View File

@ -899,33 +899,48 @@ namespace dxvk {
if (Topology == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED) if (Topology == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED)
return; return;
const DxvkInputAssemblyState iaState = [&] () -> DxvkInputAssemblyState { const DxvkInputAssemblyState iaState = [Topology] () -> DxvkInputAssemblyState {
switch (Topology) { if (Topology >= D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST
case D3D11_PRIMITIVE_TOPOLOGY_POINTLIST: && Topology <= D3D11_PRIMITIVE_TOPOLOGY_32_CONTROL_POINT_PATCHLIST) {
return { VK_PRIMITIVE_TOPOLOGY_POINT_LIST, VK_FALSE }; // Tessellation patch. The number of control points per
case D3D11_PRIMITIVE_TOPOLOGY_LINELIST: // patch can be inferred from the enum value in D3D11.
return { VK_PRIMITIVE_TOPOLOGY_LINE_LIST, VK_FALSE }; return { VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, VK_FALSE,
case D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP: uint32_t(Topology - D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + 1) };
return { VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, VK_TRUE }; } else {
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST: switch (Topology) {
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, VK_FALSE }; case D3D11_PRIMITIVE_TOPOLOGY_POINTLIST:
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP: return { VK_PRIMITIVE_TOPOLOGY_POINT_LIST, VK_FALSE, 0 };
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, VK_TRUE };
case D3D11_PRIMITIVE_TOPOLOGY_LINELIST_ADJ: case D3D11_PRIMITIVE_TOPOLOGY_LINELIST:
return { VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, VK_FALSE }; return { VK_PRIMITIVE_TOPOLOGY_LINE_LIST, VK_FALSE, 0 };
case D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ:
return { VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY, VK_TRUE }; case D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP:
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ: return { VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, VK_TRUE, 0 };
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY, VK_FALSE };
case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ: case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST:
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY, VK_TRUE }; return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, VK_FALSE, 0 };
default: case D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP:
Logger::err(str::format("D3D11DeviceContext::IASetPrimitiveTopology: Unknown primitive topology: ", Topology)); return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, VK_TRUE, 0 };
return { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, VK_FALSE };
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) { EmitCs([iaState] (DxvkContext* ctx) {
@ -2209,6 +2224,5 @@ namespace dxvk {
return slice; return slice;
} }
} }
} }

View File

@ -584,7 +584,6 @@ namespace dxvk {
virtual void EmitCsChunk(Rc<DxvkCsChunk>&& chunk) = 0; virtual void EmitCsChunk(Rc<DxvkCsChunk>&& chunk) = 0;
}; };
} }

View File

@ -29,6 +29,7 @@ namespace dxvk {
struct DxvkInputAssemblyState { struct DxvkInputAssemblyState {
VkPrimitiveTopology primitiveTopology; VkPrimitiveTopology primitiveTopology;
VkBool32 primitiveRestart; VkBool32 primitiveRestart;
uint32_t patchVertexCount;
}; };

View File

@ -1006,6 +1006,7 @@ namespace dxvk {
void DxvkContext::setInputAssemblyState(const DxvkInputAssemblyState& ia) { void DxvkContext::setInputAssemblyState(const DxvkInputAssemblyState& ia) {
m_state.gp.state.iaPrimitiveTopology = ia.primitiveTopology; m_state.gp.state.iaPrimitiveTopology = ia.primitiveTopology;
m_state.gp.state.iaPrimitiveRestart = ia.primitiveRestart; m_state.gp.state.iaPrimitiveRestart = ia.primitiveRestart;
m_state.gp.state.iaPatchVertexCount = ia.patchVertexCount;
m_flags.set(DxvkContextFlag::GpDirtyPipelineState); m_flags.set(DxvkContextFlag::GpDirtyPipelineState);
} }

View File

@ -139,6 +139,12 @@ namespace dxvk {
iaInfo.topology = state.iaPrimitiveTopology; iaInfo.topology = state.iaPrimitiveTopology;
iaInfo.primitiveRestartEnable = state.iaPrimitiveRestart; 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; VkPipelineViewportStateCreateInfo vpInfo;
vpInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; vpInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
vpInfo.pNext = nullptr; vpInfo.pNext = nullptr;
@ -222,7 +228,7 @@ namespace dxvk {
info.pStages = stages.data(); info.pStages = stages.data();
info.pVertexInputState = &viInfo; info.pVertexInputState = &viInfo;
info.pInputAssemblyState = &iaInfo; info.pInputAssemblyState = &iaInfo;
info.pTessellationState = nullptr; // TODO implement info.pTessellationState = &tsInfo;
info.pViewportState = &vpInfo; info.pViewportState = &vpInfo;
info.pRasterizationState = &rsInfo; info.pRasterizationState = &rsInfo;
info.pMultisampleState = &msInfo; info.pMultisampleState = &msInfo;
@ -235,6 +241,9 @@ namespace dxvk {
info.basePipelineHandle = baseHandle; info.basePipelineHandle = baseHandle;
info.basePipelineIndex = -1; info.basePipelineIndex = -1;
if (tsInfo.patchControlPoints == 0)
info.pTessellationState = nullptr;
VkPipeline pipeline = VK_NULL_HANDLE; VkPipeline pipeline = VK_NULL_HANDLE;
if (m_vkd->vkCreateGraphicsPipelines(m_vkd->device(), if (m_vkd->vkCreateGraphicsPipelines(m_vkd->device(),
m_cache->handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS) m_cache->handle(), 1, &info, nullptr, &pipeline) != VK_SUCCESS)

View File

@ -37,6 +37,7 @@ namespace dxvk {
VkPrimitiveTopology iaPrimitiveTopology; VkPrimitiveTopology iaPrimitiveTopology;
VkBool32 iaPrimitiveRestart; VkBool32 iaPrimitiveRestart;
uint32_t iaPatchVertexCount;
uint32_t ilAttributeCount; uint32_t ilAttributeCount;
uint32_t ilBindingCount; uint32_t ilBindingCount;