mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Validate compute state in commitComputePipelines
This way we can implement early-out for invalid dispatch calls and save a few validation checks later in the pipeline.
This commit is contained in:
parent
63cc8cdd35
commit
649c8d10d6
@ -1395,9 +1395,7 @@ namespace dxvk {
|
|||||||
uint32_t x,
|
uint32_t x,
|
||||||
uint32_t y,
|
uint32_t y,
|
||||||
uint32_t z) {
|
uint32_t z) {
|
||||||
this->commitComputeState();
|
if (this->commitComputeState()) {
|
||||||
|
|
||||||
if (m_cpActivePipeline) {
|
|
||||||
this->commitComputeInitBarriers();
|
this->commitComputeInitBarriers();
|
||||||
|
|
||||||
m_queryManager.beginQueries(m_cmd,
|
m_queryManager.beginQueries(m_cmd,
|
||||||
@ -1417,15 +1415,13 @@ namespace dxvk {
|
|||||||
|
|
||||||
void DxvkContext::dispatchIndirect(
|
void DxvkContext::dispatchIndirect(
|
||||||
VkDeviceSize offset) {
|
VkDeviceSize offset) {
|
||||||
this->commitComputeState();
|
|
||||||
|
|
||||||
auto bufferSlice = m_state.id.argBuffer.getSliceHandle(
|
auto bufferSlice = m_state.id.argBuffer.getSliceHandle(
|
||||||
offset, sizeof(VkDispatchIndirectCommand));
|
offset, sizeof(VkDispatchIndirectCommand));
|
||||||
|
|
||||||
if (m_execBarriers.isBufferDirty(bufferSlice, DxvkAccess::Read))
|
if (m_execBarriers.isBufferDirty(bufferSlice, DxvkAccess::Read))
|
||||||
m_execBarriers.recordCommands(m_cmd);
|
m_execBarriers.recordCommands(m_cmd);
|
||||||
|
|
||||||
if (m_cpActivePipeline) {
|
if (this->commitComputeState()) {
|
||||||
this->commitComputeInitBarriers();
|
this->commitComputeInitBarriers();
|
||||||
|
|
||||||
m_queryManager.beginQueries(m_cmd,
|
m_queryManager.beginQueries(m_cmd,
|
||||||
@ -3557,30 +3553,33 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::updateComputePipeline() {
|
bool DxvkContext::updateComputePipeline() {
|
||||||
m_flags.clr(DxvkContextFlag::CpDirtyPipeline);
|
|
||||||
|
|
||||||
m_state.cp.state.bsBindingMask.clear();
|
m_state.cp.state.bsBindingMask.clear();
|
||||||
m_state.cp.pipeline = lookupComputePipeline(m_state.cp.shaders);
|
m_state.cp.pipeline = lookupComputePipeline(m_state.cp.shaders);
|
||||||
|
|
||||||
|
if (unlikely(m_state.cp.pipeline == nullptr))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (m_state.cp.pipeline != nullptr
|
if (m_state.cp.pipeline->layout()->pushConstRange().size)
|
||||||
&& m_state.cp.pipeline->layout()->pushConstRange().size)
|
|
||||||
m_flags.set(DxvkContextFlag::DirtyPushConstants);
|
m_flags.set(DxvkContextFlag::DirtyPushConstants);
|
||||||
|
|
||||||
|
m_flags.clr(DxvkContextFlag::CpDirtyPipeline);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::updateComputePipelineState() {
|
bool DxvkContext::updateComputePipelineState() {
|
||||||
|
m_cpActivePipeline = m_state.cp.pipeline->getPipelineHandle(m_state.cp.state);
|
||||||
|
|
||||||
|
if (unlikely(!m_cpActivePipeline))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_cmd->cmdBindPipeline(
|
||||||
|
VK_PIPELINE_BIND_POINT_COMPUTE,
|
||||||
|
m_cpActivePipeline);
|
||||||
|
|
||||||
m_flags.clr(DxvkContextFlag::CpDirtyPipelineState);
|
m_flags.clr(DxvkContextFlag::CpDirtyPipelineState);
|
||||||
|
return true;
|
||||||
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(
|
|
||||||
VK_PIPELINE_BIND_POINT_COMPUTE,
|
|
||||||
m_cpActivePipeline);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3667,9 +3666,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkContext::updateComputeShaderResources() {
|
void DxvkContext::updateComputeShaderResources() {
|
||||||
if (m_state.cp.pipeline == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((m_flags.test(DxvkContextFlag::CpDirtyResources))
|
if ((m_flags.test(DxvkContextFlag::CpDirtyResources))
|
||||||
|| (m_flags.test(DxvkContextFlag::CpDirtyDescriptorBinding)
|
|| (m_flags.test(DxvkContextFlag::CpDirtyDescriptorBinding)
|
||||||
&& m_state.cp.pipeline->layout()->hasStaticBufferBindings())) {
|
&& m_state.cp.pipeline->layout()->hasStaticBufferBindings())) {
|
||||||
@ -3684,9 +3680,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkContext::updateComputeShaderDescriptors() {
|
void DxvkContext::updateComputeShaderDescriptors() {
|
||||||
if (m_state.cp.pipeline == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this->updateShaderDescriptorSetBinding<VK_PIPELINE_BIND_POINT_COMPUTE>(
|
this->updateShaderDescriptorSetBinding<VK_PIPELINE_BIND_POINT_COMPUTE>(
|
||||||
m_cpSet, m_state.cp.pipeline->layout());
|
m_cpSet, m_state.cp.pipeline->layout());
|
||||||
|
|
||||||
@ -4138,7 +4131,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
auto layout = BindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS
|
auto layout = BindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS
|
||||||
? (m_state.gp.pipeline != nullptr ? m_state.gp.pipeline->layout() : nullptr)
|
? (m_state.gp.pipeline != nullptr ? m_state.gp.pipeline->layout() : nullptr)
|
||||||
: (m_state.cp.pipeline != nullptr ? m_state.cp.pipeline->layout() : nullptr);
|
: m_state.cp.pipeline->layout();
|
||||||
|
|
||||||
if (!layout)
|
if (!layout)
|
||||||
return;
|
return;
|
||||||
@ -4156,29 +4149,35 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::commitComputeState() {
|
bool DxvkContext::commitComputeState() {
|
||||||
if (m_flags.test(DxvkContextFlag::GpRenderPassBound))
|
if (m_flags.test(DxvkContextFlag::GpRenderPassBound))
|
||||||
this->spillRenderPass();
|
this->spillRenderPass();
|
||||||
|
|
||||||
if (m_flags.test(DxvkContextFlag::GpClearRenderTargets))
|
if (m_flags.test(DxvkContextFlag::GpClearRenderTargets))
|
||||||
this->clearRenderPass();
|
this->clearRenderPass();
|
||||||
|
|
||||||
if (m_flags.test(DxvkContextFlag::CpDirtyPipeline))
|
if (m_flags.test(DxvkContextFlag::CpDirtyPipeline)) {
|
||||||
this->updateComputePipeline();
|
if (unlikely(!this->updateComputePipeline()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_flags.any(
|
if (m_flags.any(
|
||||||
DxvkContextFlag::CpDirtyResources,
|
DxvkContextFlag::CpDirtyResources,
|
||||||
DxvkContextFlag::CpDirtyDescriptorBinding))
|
DxvkContextFlag::CpDirtyDescriptorBinding))
|
||||||
this->updateComputeShaderResources();
|
this->updateComputeShaderResources();
|
||||||
|
|
||||||
if (m_flags.test(DxvkContextFlag::CpDirtyPipelineState))
|
if (m_flags.test(DxvkContextFlag::CpDirtyPipelineState)) {
|
||||||
this->updateComputePipelineState();
|
if (unlikely(!this->updateComputePipelineState()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_flags.test(DxvkContextFlag::CpDirtyDescriptorBinding))
|
if (m_flags.test(DxvkContextFlag::CpDirtyDescriptorBinding))
|
||||||
this->updateComputeShaderDescriptors();
|
this->updateComputeShaderDescriptors();
|
||||||
|
|
||||||
if (m_flags.test(DxvkContextFlag::DirtyPushConstants))
|
if (m_flags.test(DxvkContextFlag::DirtyPushConstants))
|
||||||
this->updatePushConstants<VK_PIPELINE_BIND_POINT_COMPUTE>();
|
this->updatePushConstants<VK_PIPELINE_BIND_POINT_COMPUTE>();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1116,8 +1116,8 @@ namespace dxvk {
|
|||||||
void pauseTransformFeedback();
|
void pauseTransformFeedback();
|
||||||
|
|
||||||
void unbindComputePipeline();
|
void unbindComputePipeline();
|
||||||
void updateComputePipeline();
|
bool updateComputePipeline();
|
||||||
void updateComputePipelineState();
|
bool updateComputePipelineState();
|
||||||
|
|
||||||
void unbindGraphicsPipeline();
|
void unbindGraphicsPipeline();
|
||||||
void updateGraphicsPipeline();
|
void updateGraphicsPipeline();
|
||||||
@ -1153,7 +1153,7 @@ namespace dxvk {
|
|||||||
template<VkPipelineBindPoint BindPoint>
|
template<VkPipelineBindPoint BindPoint>
|
||||||
void updatePushConstants();
|
void updatePushConstants();
|
||||||
|
|
||||||
void commitComputeState();
|
bool commitComputeState();
|
||||||
|
|
||||||
template<bool Indexed>
|
template<bool Indexed>
|
||||||
void commitGraphicsState();
|
void commitGraphicsState();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user