1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-03 13:24:20 +01:00

[dxvk] Introduced DxvkComputePipelineStateInfo

Will be used to re-compile compute pipelines against the current
state, just like graphics pipelines. May fix GPU lockups etc.
This commit is contained in:
Philip Rebohle 2018-02-14 17:54:35 +01:00
parent ba707f95b7
commit 0c2058e8c4
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
5 changed files with 64 additions and 22 deletions

View File

@ -1,8 +1,20 @@
#include <cstring>
#include "dxvk_compute.h"
#include "dxvk_device.h"
namespace dxvk {
bool DxvkComputePipelineStateInfo::operator == (const DxvkComputePipelineStateInfo& other) const {
return std::memcmp(this, &other, sizeof(DxvkComputePipelineStateInfo)) == 0;
}
bool DxvkComputePipelineStateInfo::operator != (const DxvkComputePipelineStateInfo& other) const {
return std::memcmp(this, &other, sizeof(DxvkComputePipelineStateInfo)) != 0;
}
DxvkComputePipeline::DxvkComputePipeline(
const DxvkDevice* device,
const Rc<DxvkPipelineCache>& cache,
@ -28,6 +40,13 @@ namespace dxvk {
}
VkPipeline DxvkComputePipeline::getPipelineHandle(
const DxvkComputePipelineStateInfo& state) const {
// TODO take pipeine state into account
return m_pipeline;
}
void DxvkComputePipeline::compilePipeline() {
std::vector<VkDescriptorSetLayoutBinding> bindings;

View File

@ -1,5 +1,6 @@
#pragma once
#include "dxvk_binding.h"
#include "dxvk_pipecache.h"
#include "dxvk_pipelayout.h"
#include "dxvk_resource.h"
@ -9,6 +10,17 @@ namespace dxvk {
class DxvkDevice;
/**
* \brief Compute pipeline state info
*/
struct DxvkComputePipelineStateInfo {
bool operator == (const DxvkComputePipelineStateInfo& other) const;
bool operator != (const DxvkComputePipelineStateInfo& other) const;
DxvkBindingState bsBindingState;
};
/**
* \brief Compute pipeline
*
@ -41,20 +53,21 @@ namespace dxvk {
/**
* \brief Pipeline handle
*
* \param [in] state Pipeline state
* \returns Pipeline handle
*/
VkPipeline getPipelineHandle() const {
return m_pipeline;
}
VkPipeline getPipelineHandle(
const DxvkComputePipelineStateInfo& state) const;
private:
const DxvkDevice* const m_device;
const Rc<vk::DeviceFn> m_vkd;
Rc<DxvkPipelineCache> m_cache;
Rc<DxvkPipelineLayout> m_layout;
Rc<DxvkShaderModule> m_cs;
Rc<DxvkPipelineCache> m_cache;
Rc<DxvkPipelineLayout> m_layout;
Rc<DxvkShaderModule> m_cs;
VkPipeline m_pipeline = VK_NULL_HANDLE;

View File

@ -1238,15 +1238,23 @@ namespace dxvk {
if (m_flags.test(DxvkContextFlag::CpDirtyPipeline)) {
m_flags.clr(DxvkContextFlag::CpDirtyPipeline);
m_state.cp.state.bsBindingState.clear();
m_state.cp.pipeline = m_device->createComputePipeline(
m_state.cp.cs.shader);
m_cpActivePipeline = m_state.cp.pipeline != nullptr
? m_state.cp.pipeline->getPipelineHandle()
: VK_NULL_HANDLE;
if (m_state.cp.pipeline != nullptr)
m_cmd->trackResource(m_state.cp.pipeline);
}
}
void DxvkContext::updateComputePipelineState() {
if (m_flags.test(DxvkContextFlag::CpDirtyPipelineState)) {
m_flags.clr(DxvkContextFlag::CpDirtyPipelineState);
m_cpActivePipeline = m_state.cp.pipeline != nullptr
? m_state.cp.pipeline->getPipelineHandle(m_state.cp.state)
: VK_NULL_HANDLE;
if (m_cpActivePipeline != VK_NULL_HANDLE) {
m_cmd->cmdBindPipeline(
@ -1329,7 +1337,7 @@ namespace dxvk {
if (m_state.cp.pipeline != nullptr) {
this->updateShaderDescriptors(
VK_PIPELINE_BIND_POINT_COMPUTE,
m_state.cp.bs,
m_state.cp.state.bsBindingState,
m_state.cp.pipeline->layout());
}
}
@ -1367,7 +1375,7 @@ namespace dxvk {
DxvkBindingState& bs =
bindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS
? m_state.gp.state.bsBindingState
: m_state.cp.bs;
: m_state.cp.state.bsBindingState;
bool updatePipelineState = false;
@ -1538,10 +1546,10 @@ namespace dxvk {
void DxvkContext::commitComputeState() {
// TODO handle CpDirtyPipelineState
this->renderPassEnd();
this->updateComputePipeline();
this->updateComputeShaderResources();
this->updateComputePipelineState();
this->updateComputeShaderDescriptors();
}
@ -1565,7 +1573,7 @@ namespace dxvk {
auto layout = m_state.cp.pipeline->layout();
for (uint32_t i = 0; i < layout->bindingCount(); i++) {
if (m_state.cp.bs.isBound(i)) {
if (m_state.cp.state.bsBindingState.isBound(i)) {
const DxvkDescriptorSlot binding = layout->binding(i);
const DxvkShaderResourceSlot& slot = m_rc[binding.slot];

View File

@ -564,6 +564,7 @@ namespace dxvk {
void renderPassEnd();
void updateComputePipeline();
void updateComputePipelineState();
void updateGraphicsPipeline();
void updateGraphicsPipelineState();

View File

@ -71,11 +71,11 @@ namespace dxvk {
struct DxvkGraphicsPipelineState {
DxvkShaderStage vs;
DxvkShaderStage tcs;
DxvkShaderStage tes;
DxvkShaderStage gs;
DxvkShaderStage fs;
DxvkShaderStage vs;
DxvkShaderStage tcs;
DxvkShaderStage tes;
DxvkShaderStage gs;
DxvkShaderStage fs;
DxvkGraphicsPipelineStateInfo state;
Rc<DxvkGraphicsPipeline> pipeline;
@ -83,9 +83,10 @@ namespace dxvk {
struct DxvkComputePipelineState {
DxvkBindingState bs;
DxvkShaderStage cs;
Rc<DxvkComputePipeline> pipeline;
DxvkShaderStage cs;
DxvkComputePipelineStateInfo state;
Rc<DxvkComputePipeline> pipeline;
};