mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Validate graphics state in commitGraphicsState
Same idea as for the related compute work.
This commit is contained in:
parent
649c8d10d6
commit
2c974cbe1e
@ -1454,9 +1454,7 @@ namespace dxvk {
|
|||||||
uint32_t instanceCount,
|
uint32_t instanceCount,
|
||||||
uint32_t firstVertex,
|
uint32_t firstVertex,
|
||||||
uint32_t firstInstance) {
|
uint32_t firstInstance) {
|
||||||
this->commitGraphicsState<false>();
|
if (this->commitGraphicsState<false>()) {
|
||||||
|
|
||||||
if (m_gpActivePipeline) {
|
|
||||||
m_cmd->cmdDraw(
|
m_cmd->cmdDraw(
|
||||||
vertexCount, instanceCount,
|
vertexCount, instanceCount,
|
||||||
firstVertex, firstInstance);
|
firstVertex, firstInstance);
|
||||||
@ -1472,9 +1470,7 @@ namespace dxvk {
|
|||||||
VkDeviceSize offset,
|
VkDeviceSize offset,
|
||||||
uint32_t count,
|
uint32_t count,
|
||||||
uint32_t stride) {
|
uint32_t stride) {
|
||||||
this->commitGraphicsState<false>();
|
if (this->commitGraphicsState<false>()) {
|
||||||
|
|
||||||
if (m_gpActivePipeline) {
|
|
||||||
auto descriptor = m_state.id.argBuffer.getDescriptor();
|
auto descriptor = m_state.id.argBuffer.getDescriptor();
|
||||||
|
|
||||||
m_cmd->cmdDrawIndirect(
|
m_cmd->cmdDrawIndirect(
|
||||||
@ -1494,9 +1490,7 @@ namespace dxvk {
|
|||||||
VkDeviceSize countOffset,
|
VkDeviceSize countOffset,
|
||||||
uint32_t maxCount,
|
uint32_t maxCount,
|
||||||
uint32_t stride) {
|
uint32_t stride) {
|
||||||
this->commitGraphicsState<false>();
|
if (this->commitGraphicsState<false>()) {
|
||||||
|
|
||||||
if (m_gpActivePipeline) {
|
|
||||||
auto argDescriptor = m_state.id.argBuffer.getDescriptor();
|
auto argDescriptor = m_state.id.argBuffer.getDescriptor();
|
||||||
auto cntDescriptor = m_state.id.cntBuffer.getDescriptor();
|
auto cntDescriptor = m_state.id.cntBuffer.getDescriptor();
|
||||||
|
|
||||||
@ -1520,9 +1514,7 @@ namespace dxvk {
|
|||||||
uint32_t firstIndex,
|
uint32_t firstIndex,
|
||||||
uint32_t vertexOffset,
|
uint32_t vertexOffset,
|
||||||
uint32_t firstInstance) {
|
uint32_t firstInstance) {
|
||||||
this->commitGraphicsState<true>();
|
if (this->commitGraphicsState<true>()) {
|
||||||
|
|
||||||
if (m_gpActivePipeline) {
|
|
||||||
m_cmd->cmdDrawIndexed(
|
m_cmd->cmdDrawIndexed(
|
||||||
indexCount, instanceCount,
|
indexCount, instanceCount,
|
||||||
firstIndex, vertexOffset,
|
firstIndex, vertexOffset,
|
||||||
@ -1539,9 +1531,7 @@ namespace dxvk {
|
|||||||
VkDeviceSize offset,
|
VkDeviceSize offset,
|
||||||
uint32_t count,
|
uint32_t count,
|
||||||
uint32_t stride) {
|
uint32_t stride) {
|
||||||
this->commitGraphicsState<true>();
|
if (this->commitGraphicsState<true>()) {
|
||||||
|
|
||||||
if (m_gpActivePipeline) {
|
|
||||||
auto descriptor = m_state.id.argBuffer.getDescriptor();
|
auto descriptor = m_state.id.argBuffer.getDescriptor();
|
||||||
|
|
||||||
m_cmd->cmdDrawIndexedIndirect(
|
m_cmd->cmdDrawIndexedIndirect(
|
||||||
@ -1561,9 +1551,7 @@ namespace dxvk {
|
|||||||
VkDeviceSize countOffset,
|
VkDeviceSize countOffset,
|
||||||
uint32_t maxCount,
|
uint32_t maxCount,
|
||||||
uint32_t stride) {
|
uint32_t stride) {
|
||||||
this->commitGraphicsState<true>();
|
if (this->commitGraphicsState<true>()) {
|
||||||
|
|
||||||
if (m_gpActivePipeline) {
|
|
||||||
auto argDescriptor = m_state.id.argBuffer.getDescriptor();
|
auto argDescriptor = m_state.id.argBuffer.getDescriptor();
|
||||||
auto cntDescriptor = m_state.id.cntBuffer.getDescriptor();
|
auto cntDescriptor = m_state.id.cntBuffer.getDescriptor();
|
||||||
|
|
||||||
@ -1585,9 +1573,7 @@ namespace dxvk {
|
|||||||
const DxvkBufferSlice& counterBuffer,
|
const DxvkBufferSlice& counterBuffer,
|
||||||
uint32_t counterDivisor,
|
uint32_t counterDivisor,
|
||||||
uint32_t counterBias) {
|
uint32_t counterBias) {
|
||||||
this->commitGraphicsState<false>();
|
if (this->commitGraphicsState<false>()) {
|
||||||
|
|
||||||
if (m_gpActivePipeline) {
|
|
||||||
auto physSlice = counterBuffer.getSliceHandle();
|
auto physSlice = counterBuffer.getSliceHandle();
|
||||||
|
|
||||||
m_cmd->cmdDrawIndirectVertexCount(1, 0,
|
m_cmd->cmdDrawIndirectVertexCount(1, 0,
|
||||||
@ -3602,25 +3588,26 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::updateGraphicsPipeline() {
|
bool DxvkContext::updateGraphicsPipeline() {
|
||||||
m_flags.clr(DxvkContextFlag::GpDirtyPipeline);
|
|
||||||
|
|
||||||
m_state.gp.state.bsBindingMask.clear();
|
m_state.gp.state.bsBindingMask.clear();
|
||||||
m_state.gp.pipeline = lookupGraphicsPipeline(m_state.gp.shaders);
|
m_state.gp.pipeline = lookupGraphicsPipeline(m_state.gp.shaders);
|
||||||
m_state.gp.flags = DxvkGraphicsPipelineFlags();
|
|
||||||
|
|
||||||
if (m_state.gp.pipeline != nullptr) {
|
|
||||||
m_state.gp.flags = m_state.gp.pipeline->flags();
|
|
||||||
|
|
||||||
if (m_state.gp.pipeline->layout()->pushConstRange().size)
|
if (unlikely(m_state.gp.pipeline == nullptr)) {
|
||||||
m_flags.set(DxvkContextFlag::DirtyPushConstants);
|
m_state.gp.flags = DxvkGraphicsPipelineFlags();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_state.gp.flags = m_state.gp.pipeline->flags();
|
||||||
|
|
||||||
|
if (m_state.gp.pipeline->layout()->pushConstRange().size)
|
||||||
|
m_flags.set(DxvkContextFlag::DirtyPushConstants);
|
||||||
|
|
||||||
|
m_flags.clr(DxvkContextFlag::GpDirtyPipeline);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkContext::updateGraphicsPipelineState() {
|
bool DxvkContext::updateGraphicsPipelineState() {
|
||||||
m_flags.clr(DxvkContextFlag::GpDirtyPipelineState);
|
|
||||||
|
|
||||||
this->pauseTransformFeedback();
|
this->pauseTransformFeedback();
|
||||||
|
|
||||||
// Set up vertex buffer strides for active bindings
|
// Set up vertex buffer strides for active bindings
|
||||||
@ -3653,15 +3640,17 @@ namespace dxvk {
|
|||||||
: DxvkContextFlag::GpDirtyStencilRef);
|
: DxvkContextFlag::GpDirtyStencilRef);
|
||||||
|
|
||||||
// Retrieve and bind actual Vulkan pipeline handle
|
// Retrieve and bind actual Vulkan pipeline handle
|
||||||
m_gpActivePipeline = m_state.gp.pipeline != nullptr && m_state.om.framebuffer != nullptr
|
m_gpActivePipeline = m_state.gp.pipeline->getPipelineHandle(m_state.gp.state, m_state.om.framebuffer->getRenderPass());
|
||||||
? m_state.gp.pipeline->getPipelineHandle(m_state.gp.state, m_state.om.framebuffer->getRenderPass())
|
|
||||||
: VK_NULL_HANDLE;
|
if (unlikely(!m_gpActivePipeline))
|
||||||
|
return false;
|
||||||
if (m_gpActivePipeline != VK_NULL_HANDLE) {
|
|
||||||
m_cmd->cmdBindPipeline(
|
m_cmd->cmdBindPipeline(
|
||||||
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
m_gpActivePipeline);
|
m_gpActivePipeline);
|
||||||
}
|
|
||||||
|
m_flags.clr(DxvkContextFlag::GpDirtyPipelineState);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3688,9 +3677,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkContext::updateGraphicsShaderResources() {
|
void DxvkContext::updateGraphicsShaderResources() {
|
||||||
if (m_state.gp.pipeline == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((m_flags.test(DxvkContextFlag::GpDirtyResources))
|
if ((m_flags.test(DxvkContextFlag::GpDirtyResources))
|
||||||
|| (m_flags.test(DxvkContextFlag::GpDirtyDescriptorBinding)
|
|| (m_flags.test(DxvkContextFlag::GpDirtyDescriptorBinding)
|
||||||
&& m_state.gp.pipeline->layout()->hasStaticBufferBindings())) {
|
&& m_state.gp.pipeline->layout()->hasStaticBufferBindings())) {
|
||||||
@ -3705,9 +3691,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
void DxvkContext::updateGraphicsShaderDescriptors() {
|
void DxvkContext::updateGraphicsShaderDescriptors() {
|
||||||
if (m_state.gp.pipeline == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this->updateShaderDescriptorSetBinding<VK_PIPELINE_BIND_POINT_GRAPHICS>(
|
this->updateShaderDescriptorSetBinding<VK_PIPELINE_BIND_POINT_GRAPHICS>(
|
||||||
m_gpSet, m_state.gp.pipeline->layout());
|
m_gpSet, m_state.gp.pipeline->layout());
|
||||||
|
|
||||||
@ -3728,7 +3711,7 @@ namespace dxvk {
|
|||||||
VkImage depthImage = VK_NULL_HANDLE;
|
VkImage depthImage = VK_NULL_HANDLE;
|
||||||
VkImageLayout depthLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
VkImageLayout depthLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
|
||||||
if (BindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS && m_state.om.framebuffer != nullptr) {
|
if (BindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS) {
|
||||||
const auto& depthAttachment = m_state.om.framebuffer->getDepthTarget();
|
const auto& depthAttachment = m_state.om.framebuffer->getDepthTarget();
|
||||||
|
|
||||||
if (depthAttachment.view != nullptr) {
|
if (depthAttachment.view != nullptr) {
|
||||||
@ -4130,7 +4113,7 @@ namespace dxvk {
|
|||||||
m_flags.clr(DxvkContextFlag::DirtyPushConstants);
|
m_flags.clr(DxvkContextFlag::DirtyPushConstants);
|
||||||
|
|
||||||
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->layout()
|
||||||
: m_state.cp.pipeline->layout();
|
: m_state.cp.pipeline->layout();
|
||||||
|
|
||||||
if (!layout)
|
if (!layout)
|
||||||
@ -4182,15 +4165,17 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
template<bool Indexed>
|
template<bool Indexed>
|
||||||
void DxvkContext::commitGraphicsState() {
|
bool DxvkContext::commitGraphicsState() {
|
||||||
if (m_flags.test(DxvkContextFlag::GpDirtyFramebuffer))
|
if (m_flags.test(DxvkContextFlag::GpDirtyFramebuffer))
|
||||||
this->updateFramebuffer();
|
this->updateFramebuffer();
|
||||||
|
|
||||||
if (!m_flags.test(DxvkContextFlag::GpRenderPassBound))
|
if (!m_flags.test(DxvkContextFlag::GpRenderPassBound))
|
||||||
this->startRenderPass();
|
this->startRenderPass();
|
||||||
|
|
||||||
if (m_flags.test(DxvkContextFlag::GpDirtyPipeline))
|
if (m_flags.test(DxvkContextFlag::GpDirtyPipeline)) {
|
||||||
this->updateGraphicsPipeline();
|
if (unlikely(!this->updateGraphicsPipeline()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_flags.test(DxvkContextFlag::GpDirtyIndexBuffer) && Indexed)
|
if (m_flags.test(DxvkContextFlag::GpDirtyIndexBuffer) && Indexed)
|
||||||
this->updateIndexBufferBinding();
|
this->updateIndexBufferBinding();
|
||||||
@ -4203,8 +4188,10 @@ namespace dxvk {
|
|||||||
DxvkContextFlag::GpDirtyDescriptorBinding))
|
DxvkContextFlag::GpDirtyDescriptorBinding))
|
||||||
this->updateGraphicsShaderResources();
|
this->updateGraphicsShaderResources();
|
||||||
|
|
||||||
if (m_flags.test(DxvkContextFlag::GpDirtyPipelineState))
|
if (m_flags.test(DxvkContextFlag::GpDirtyPipelineState)) {
|
||||||
this->updateGraphicsPipelineState();
|
if (unlikely(!this->updateGraphicsPipelineState()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_state.gp.flags.test(DxvkGraphicsPipelineFlag::HasTransformFeedback))
|
if (m_state.gp.flags.test(DxvkGraphicsPipelineFlag::HasTransformFeedback))
|
||||||
this->updateTransformFeedbackState();
|
this->updateTransformFeedbackState();
|
||||||
@ -4225,6 +4212,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (m_flags.test(DxvkContextFlag::DirtyPushConstants))
|
if (m_flags.test(DxvkContextFlag::DirtyPushConstants))
|
||||||
this->updatePushConstants<VK_PIPELINE_BIND_POINT_GRAPHICS>();
|
this->updatePushConstants<VK_PIPELINE_BIND_POINT_GRAPHICS>();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1120,8 +1120,8 @@ namespace dxvk {
|
|||||||
bool updateComputePipelineState();
|
bool updateComputePipelineState();
|
||||||
|
|
||||||
void unbindGraphicsPipeline();
|
void unbindGraphicsPipeline();
|
||||||
void updateGraphicsPipeline();
|
bool updateGraphicsPipeline();
|
||||||
void updateGraphicsPipelineState();
|
bool updateGraphicsPipelineState();
|
||||||
|
|
||||||
void updateComputeShaderResources();
|
void updateComputeShaderResources();
|
||||||
void updateComputeShaderDescriptors();
|
void updateComputeShaderDescriptors();
|
||||||
@ -1156,7 +1156,7 @@ namespace dxvk {
|
|||||||
bool commitComputeState();
|
bool commitComputeState();
|
||||||
|
|
||||||
template<bool Indexed>
|
template<bool Indexed>
|
||||||
void commitGraphicsState();
|
bool commitGraphicsState();
|
||||||
|
|
||||||
void commitComputeInitBarriers();
|
void commitComputeInitBarriers();
|
||||||
void commitComputePostBarriers();
|
void commitComputePostBarriers();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user