[dxvk] Implemented graphics pipeline creation

This commit is contained in:
Philip Rebohle 2017-11-20 14:11:09 +01:00
parent a9a03fec69
commit 8bb0325928
5 changed files with 70 additions and 12 deletions

View File

@ -40,20 +40,11 @@ namespace dxvk {
throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to create pipeline layout");
}
VkPipelineShaderStageCreateInfo sinfo;
sinfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
sinfo.pNext = nullptr;
sinfo.flags = 0;
sinfo.stage = VK_SHADER_STAGE_COMPUTE_BIT;
sinfo.module = m_shader->module();
sinfo.pName = "main";
sinfo.pSpecializationInfo = nullptr;
VkComputePipelineCreateInfo info;
info.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
info.pNext = nullptr;
info.flags = 0;
info.stage = sinfo;
info.stage = m_shader->stageInfo();
info.layout = m_pipelineLayout;
info.basePipelineHandle = VK_NULL_HANDLE;
info.basePipelineIndex = 0;

View File

@ -131,6 +131,8 @@ namespace dxvk {
uint32_t firstInstance) {
TRACE(this, vertexCount, instanceCount,
firstVertex, firstInstance);
this->commitGraphicsState();
}
@ -142,6 +144,8 @@ namespace dxvk {
uint32_t firstInstance) {
TRACE(this, indexCount, instanceCount,
firstIndex, vertexOffset, firstInstance);
this->commitGraphicsState();
}
@ -259,6 +263,7 @@ namespace dxvk {
m_cmd->cmdBindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS,
m_state.activeGraphicsPipeline->getPipelineHandle(gpState));
m_cmd->trackResource(m_state.activeGraphicsPipeline);
}
}
@ -295,7 +300,7 @@ namespace dxvk {
}
void DxvkContext::flushGraphicsState() {
void DxvkContext::commitGraphicsState() {
this->renderPassBegin();
this->bindGraphicsPipeline();
this->bindDynamicState();

View File

@ -184,7 +184,7 @@ namespace dxvk {
void bindIndexBuffer();
void bindVertexBuffers();
void flushGraphicsState();
void commitGraphicsState();
DxvkShaderStageState* getShaderStage(
VkShaderStageFlagBits stage);

View File

@ -47,12 +47,43 @@ namespace dxvk {
const Rc<DxvkShader>& fs)
: m_vkd(vkd), m_vs(vs), m_tcs(tcs),
m_tes(tes), m_gs(gs), m_fs(fs) {
TRACE(this, vs, tcs, tes, gs, fs);
std::vector<VkDescriptorSetLayoutBinding> bindings;
VkDescriptorSetLayoutCreateInfo dlayout;
dlayout.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
dlayout.pNext = nullptr;
dlayout.flags = 0;
dlayout.bindingCount = bindings.size();
dlayout.pBindings = bindings.data();
if (m_vkd->vkCreateDescriptorSetLayout(m_vkd->device(),
&dlayout, nullptr, &m_descriptorSetLayout) != VK_SUCCESS)
throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to create descriptor set layout");
VkPipelineLayoutCreateInfo playout;
playout.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
playout.pNext = nullptr;
playout.flags = 0;
playout.setLayoutCount = 1;
playout.pSetLayouts = &m_descriptorSetLayout;
playout.pushConstantRangeCount = 0;
playout.pPushConstantRanges = nullptr;
if (m_vkd->vkCreatePipelineLayout(m_vkd->device(),
&playout, nullptr, &m_pipelineLayout) != VK_SUCCESS) {
this->destroyObjects();
throw DxvkError("DxvkComputePipeline::DxvkComputePipeline: Failed to create pipeline layout");
}
}
DxvkGraphicsPipeline::~DxvkGraphicsPipeline() {
TRACE(this);
this->destroyPipelines();
this->destroyObjects();
}
@ -140,4 +171,12 @@ namespace dxvk {
m_vkd->vkDestroyDescriptorSetLayout(m_vkd->device(), m_descriptorSetLayout, nullptr);
}
void DxvkGraphicsPipeline::destroyPipelines() {
for (const auto& pair : m_pipelines) {
m_vkd->vkDestroyPipeline(
m_vkd->device(), pair.second, nullptr);
}
}
}

View File

@ -56,10 +56,32 @@ namespace dxvk {
const Rc<DxvkShader>& fs);
~DxvkGraphicsPipeline();
/**
* \brief Descriptor set layout
*
* The descriptor set layout for this pipeline.
* Use this to allocate new descriptor sets.
* \returns The descriptor set layout
*/
VkDescriptorSetLayout descriptorSetLayout() const {
return m_descriptorSetLayout;
}
/**
* \brief Pipeline layout layout
*
* The pipeline layout for this pipeline.
* Use this to bind descriptor sets.
* \returns The descriptor set layout
*/
VkPipelineLayout pipelineLayout() const {
return m_pipelineLayout;
}
/**
* \brief Pipeline handle
* \returns Pipeline handle
*/
VkPipeline getPipelineHandle(
const DxvkGraphicsPipelineStateInfo& state);
@ -85,6 +107,7 @@ namespace dxvk {
const DxvkGraphicsPipelineStateInfo& state) const;
void destroyObjects();
void destroyPipelines();
};