mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-02 13:29:14 +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:
parent
ba707f95b7
commit
0c2058e8c4
@ -1,8 +1,20 @@
|
|||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "dxvk_compute.h"
|
#include "dxvk_compute.h"
|
||||||
#include "dxvk_device.h"
|
#include "dxvk_device.h"
|
||||||
|
|
||||||
namespace dxvk {
|
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(
|
DxvkComputePipeline::DxvkComputePipeline(
|
||||||
const DxvkDevice* device,
|
const DxvkDevice* device,
|
||||||
const Rc<DxvkPipelineCache>& cache,
|
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() {
|
void DxvkComputePipeline::compilePipeline() {
|
||||||
std::vector<VkDescriptorSetLayoutBinding> bindings;
|
std::vector<VkDescriptorSetLayoutBinding> bindings;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "dxvk_binding.h"
|
||||||
#include "dxvk_pipecache.h"
|
#include "dxvk_pipecache.h"
|
||||||
#include "dxvk_pipelayout.h"
|
#include "dxvk_pipelayout.h"
|
||||||
#include "dxvk_resource.h"
|
#include "dxvk_resource.h"
|
||||||
@ -9,6 +10,17 @@ namespace dxvk {
|
|||||||
|
|
||||||
class DxvkDevice;
|
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
|
* \brief Compute pipeline
|
||||||
*
|
*
|
||||||
@ -41,11 +53,12 @@ namespace dxvk {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Pipeline handle
|
* \brief Pipeline handle
|
||||||
|
*
|
||||||
|
* \param [in] state Pipeline state
|
||||||
* \returns Pipeline handle
|
* \returns Pipeline handle
|
||||||
*/
|
*/
|
||||||
VkPipeline getPipelineHandle() const {
|
VkPipeline getPipelineHandle(
|
||||||
return m_pipeline;
|
const DxvkComputePipelineStateInfo& state) const;
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -1238,15 +1238,23 @@ namespace dxvk {
|
|||||||
if (m_flags.test(DxvkContextFlag::CpDirtyPipeline)) {
|
if (m_flags.test(DxvkContextFlag::CpDirtyPipeline)) {
|
||||||
m_flags.clr(DxvkContextFlag::CpDirtyPipeline);
|
m_flags.clr(DxvkContextFlag::CpDirtyPipeline);
|
||||||
|
|
||||||
|
m_state.cp.state.bsBindingState.clear();
|
||||||
m_state.cp.pipeline = m_device->createComputePipeline(
|
m_state.cp.pipeline = m_device->createComputePipeline(
|
||||||
m_state.cp.cs.shader);
|
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)
|
if (m_state.cp.pipeline != nullptr)
|
||||||
m_cmd->trackResource(m_state.cp.pipeline);
|
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) {
|
if (m_cpActivePipeline != VK_NULL_HANDLE) {
|
||||||
m_cmd->cmdBindPipeline(
|
m_cmd->cmdBindPipeline(
|
||||||
@ -1329,7 +1337,7 @@ namespace dxvk {
|
|||||||
if (m_state.cp.pipeline != nullptr) {
|
if (m_state.cp.pipeline != nullptr) {
|
||||||
this->updateShaderDescriptors(
|
this->updateShaderDescriptors(
|
||||||
VK_PIPELINE_BIND_POINT_COMPUTE,
|
VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||||
m_state.cp.bs,
|
m_state.cp.state.bsBindingState,
|
||||||
m_state.cp.pipeline->layout());
|
m_state.cp.pipeline->layout());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1367,7 +1375,7 @@ namespace dxvk {
|
|||||||
DxvkBindingState& bs =
|
DxvkBindingState& bs =
|
||||||
bindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS
|
bindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS
|
||||||
? m_state.gp.state.bsBindingState
|
? m_state.gp.state.bsBindingState
|
||||||
: m_state.cp.bs;
|
: m_state.cp.state.bsBindingState;
|
||||||
|
|
||||||
bool updatePipelineState = false;
|
bool updatePipelineState = false;
|
||||||
|
|
||||||
@ -1538,10 +1546,10 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkContext::commitComputeState() {
|
void DxvkContext::commitComputeState() {
|
||||||
// TODO handle CpDirtyPipelineState
|
|
||||||
this->renderPassEnd();
|
this->renderPassEnd();
|
||||||
this->updateComputePipeline();
|
this->updateComputePipeline();
|
||||||
this->updateComputeShaderResources();
|
this->updateComputeShaderResources();
|
||||||
|
this->updateComputePipelineState();
|
||||||
this->updateComputeShaderDescriptors();
|
this->updateComputeShaderDescriptors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1565,7 +1573,7 @@ namespace dxvk {
|
|||||||
auto layout = m_state.cp.pipeline->layout();
|
auto layout = m_state.cp.pipeline->layout();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < layout->bindingCount(); i++) {
|
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 DxvkDescriptorSlot binding = layout->binding(i);
|
||||||
const DxvkShaderResourceSlot& slot = m_rc[binding.slot];
|
const DxvkShaderResourceSlot& slot = m_rc[binding.slot];
|
||||||
|
|
||||||
|
@ -564,6 +564,7 @@ namespace dxvk {
|
|||||||
void renderPassEnd();
|
void renderPassEnd();
|
||||||
|
|
||||||
void updateComputePipeline();
|
void updateComputePipeline();
|
||||||
|
void updateComputePipelineState();
|
||||||
|
|
||||||
void updateGraphicsPipeline();
|
void updateGraphicsPipeline();
|
||||||
void updateGraphicsPipelineState();
|
void updateGraphicsPipelineState();
|
||||||
|
@ -83,8 +83,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
struct DxvkComputePipelineState {
|
struct DxvkComputePipelineState {
|
||||||
DxvkBindingState bs;
|
|
||||||
DxvkShaderStage cs;
|
DxvkShaderStage cs;
|
||||||
|
|
||||||
|
DxvkComputePipelineStateInfo state;
|
||||||
Rc<DxvkComputePipeline> pipeline;
|
Rc<DxvkComputePipeline> pipeline;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user