mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Fixed partial depth-stencil clear operations
This commit is contained in:
parent
370ff34e9f
commit
cf1358b2f4
@ -389,6 +389,35 @@ namespace dxvk {
|
|||||||
const VkClearValue& clearValue) {
|
const VkClearValue& clearValue) {
|
||||||
this->updateFramebuffer();
|
this->updateFramebuffer();
|
||||||
|
|
||||||
|
// Prepare attachment ops
|
||||||
|
DxvkColorAttachmentOps colorOp;
|
||||||
|
colorOp.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
|
colorOp.loadLayout = imageView->imageInfo().layout;
|
||||||
|
colorOp.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
|
colorOp.storeLayout = imageView->imageInfo().layout;
|
||||||
|
|
||||||
|
DxvkDepthAttachmentOps depthOp;
|
||||||
|
depthOp.loadOpD = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
|
depthOp.loadOpS = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||||
|
depthOp.loadLayout = imageView->imageInfo().layout;
|
||||||
|
depthOp.storeOpD = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
|
depthOp.storeOpS = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
|
depthOp.storeLayout = imageView->imageInfo().layout;
|
||||||
|
|
||||||
|
if (clearAspects & VK_IMAGE_ASPECT_COLOR_BIT)
|
||||||
|
colorOp.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||||
|
|
||||||
|
if (clearAspects & VK_IMAGE_ASPECT_DEPTH_BIT)
|
||||||
|
depthOp.loadOpD = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||||
|
|
||||||
|
if (clearAspects & VK_IMAGE_ASPECT_STENCIL_BIT)
|
||||||
|
depthOp.loadOpS = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||||
|
|
||||||
|
if (clearAspects == imageView->info().aspect) {
|
||||||
|
colorOp.loadLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
depthOp.loadLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
}
|
||||||
|
|
||||||
// Check whether the render target view is an attachment
|
// Check whether the render target view is an attachment
|
||||||
// of the current framebuffer. If not, we need to create
|
// of the current framebuffer. If not, we need to create
|
||||||
// a temporary framebuffer.
|
// a temporary framebuffer.
|
||||||
@ -400,12 +429,6 @@ namespace dxvk {
|
|||||||
if (attachmentIndex < 0) {
|
if (attachmentIndex < 0) {
|
||||||
this->spillRenderPass();
|
this->spillRenderPass();
|
||||||
|
|
||||||
DxvkAttachmentOps op;
|
|
||||||
op.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
|
||||||
op.loadLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
||||||
op.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
|
||||||
op.storeLayout = imageView->imageInfo().layout;
|
|
||||||
|
|
||||||
// Set up and bind a temporary framebuffer
|
// Set up and bind a temporary framebuffer
|
||||||
DxvkRenderTargets attachments;
|
DxvkRenderTargets attachments;
|
||||||
DxvkRenderPassOps ops;
|
DxvkRenderPassOps ops;
|
||||||
@ -413,11 +436,11 @@ namespace dxvk {
|
|||||||
if (clearAspects & VK_IMAGE_ASPECT_COLOR_BIT) {
|
if (clearAspects & VK_IMAGE_ASPECT_COLOR_BIT) {
|
||||||
attachments.color[0].view = imageView;
|
attachments.color[0].view = imageView;
|
||||||
attachments.color[0].layout = imageView->pickLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
attachments.color[0].layout = imageView->pickLayout(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
ops.colorOps[0] = op;
|
ops.colorOps[0] = colorOp;
|
||||||
} else {
|
} else {
|
||||||
attachments.depth.view = imageView;
|
attachments.depth.view = imageView;
|
||||||
attachments.depth.layout = imageView->pickLayout(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
attachments.depth.layout = imageView->pickLayout(VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||||
ops.depthOps = op;
|
ops.depthOps = depthOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->renderPassBindFramebuffer(
|
this->renderPassBindFramebuffer(
|
||||||
@ -437,13 +460,11 @@ namespace dxvk {
|
|||||||
1, &clearInfo, 1, &clearRect);
|
1, &clearInfo, 1, &clearRect);
|
||||||
} else {
|
} else {
|
||||||
// Perform the clear when starting the render pass
|
// Perform the clear when starting the render pass
|
||||||
if (clearAspects & VK_IMAGE_ASPECT_COLOR_BIT) {
|
if (clearAspects & VK_IMAGE_ASPECT_COLOR_BIT)
|
||||||
m_state.om.renderPassOps.colorOps[attachmentIndex].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
m_state.om.renderPassOps.colorOps[attachmentIndex] = colorOp;
|
||||||
m_state.om.renderPassOps.colorOps[attachmentIndex].loadLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
||||||
} else {
|
if (clearAspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT))
|
||||||
m_state.om.renderPassOps.depthOps.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
m_state.om.renderPassOps.depthOps = depthOp;
|
||||||
m_state.om.renderPassOps.depthOps.loadLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_state.om.clearValues[attachmentIndex] = clearValue;
|
m_state.om.clearValues[attachmentIndex] = clearValue;
|
||||||
m_flags.set(DxvkContextFlag::GpClearRenderTargets);
|
m_flags.set(DxvkContextFlag::GpClearRenderTargets);
|
||||||
@ -1586,17 +1607,23 @@ namespace dxvk {
|
|||||||
const DxvkRenderTargets& renderTargets,
|
const DxvkRenderTargets& renderTargets,
|
||||||
DxvkRenderPassOps& renderPassOps) {
|
DxvkRenderPassOps& renderPassOps) {
|
||||||
renderPassOps.depthOps = renderTargets.depth.view != nullptr
|
renderPassOps.depthOps = renderTargets.depth.view != nullptr
|
||||||
? DxvkAttachmentOps {
|
? DxvkDepthAttachmentOps {
|
||||||
VK_ATTACHMENT_LOAD_OP_LOAD, renderTargets.depth.view->imageInfo().layout,
|
VK_ATTACHMENT_LOAD_OP_LOAD,
|
||||||
VK_ATTACHMENT_STORE_OP_STORE, renderTargets.depth.view->imageInfo().layout }
|
VK_ATTACHMENT_LOAD_OP_LOAD,
|
||||||
: DxvkAttachmentOps { };
|
renderTargets.depth.view->imageInfo().layout,
|
||||||
|
VK_ATTACHMENT_STORE_OP_STORE,
|
||||||
|
VK_ATTACHMENT_STORE_OP_STORE,
|
||||||
|
renderTargets.depth.view->imageInfo().layout }
|
||||||
|
: DxvkDepthAttachmentOps { };
|
||||||
|
|
||||||
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
|
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
|
||||||
renderPassOps.colorOps[i] = renderTargets.color[i].view != nullptr
|
renderPassOps.colorOps[i] = renderTargets.color[i].view != nullptr
|
||||||
? DxvkAttachmentOps {
|
? DxvkColorAttachmentOps {
|
||||||
VK_ATTACHMENT_LOAD_OP_LOAD, renderTargets.color[i].view->imageInfo().layout,
|
VK_ATTACHMENT_LOAD_OP_LOAD,
|
||||||
VK_ATTACHMENT_STORE_OP_STORE, renderTargets.color[i].view->imageInfo().layout }
|
renderTargets.color[i].view->imageInfo().layout,
|
||||||
: DxvkAttachmentOps { };
|
VK_ATTACHMENT_STORE_OP_STORE,
|
||||||
|
renderTargets.color[i].view->imageInfo().layout }
|
||||||
|
: DxvkColorAttachmentOps { };
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO provide a sane alternative for this
|
// TODO provide a sane alternative for this
|
||||||
|
@ -89,10 +89,10 @@ namespace dxvk {
|
|||||||
desc.flags = 0;
|
desc.flags = 0;
|
||||||
desc.format = m_format.depth.format;
|
desc.format = m_format.depth.format;
|
||||||
desc.samples = m_format.sampleCount;
|
desc.samples = m_format.sampleCount;
|
||||||
desc.loadOp = ops.depthOps.loadOp;
|
desc.loadOp = ops.depthOps.loadOpD;
|
||||||
desc.storeOp = ops.depthOps.storeOp;
|
desc.storeOp = ops.depthOps.storeOpD;
|
||||||
desc.stencilLoadOp = ops.depthOps.loadOp;
|
desc.stencilLoadOp = ops.depthOps.loadOpS;
|
||||||
desc.stencilStoreOp = ops.depthOps.storeOp;
|
desc.stencilStoreOp = ops.depthOps.storeOpS;
|
||||||
desc.initialLayout = ops.depthOps.loadLayout;
|
desc.initialLayout = ops.depthOps.loadLayout;
|
||||||
desc.finalLayout = ops.depthOps.storeLayout;
|
desc.finalLayout = ops.depthOps.storeLayout;
|
||||||
|
|
||||||
@ -179,9 +179,11 @@ namespace dxvk {
|
|||||||
bool DxvkRenderPass::compareOps(
|
bool DxvkRenderPass::compareOps(
|
||||||
const DxvkRenderPassOps& a,
|
const DxvkRenderPassOps& a,
|
||||||
const DxvkRenderPassOps& b) {
|
const DxvkRenderPassOps& b) {
|
||||||
bool eq = a.depthOps.loadOp == b.depthOps.loadOp
|
bool eq = a.depthOps.loadOpD == b.depthOps.loadOpD
|
||||||
|
&& a.depthOps.loadOpS == b.depthOps.loadOpS
|
||||||
&& a.depthOps.loadLayout == b.depthOps.loadLayout
|
&& a.depthOps.loadLayout == b.depthOps.loadLayout
|
||||||
&& a.depthOps.storeOp == b.depthOps.storeOp
|
&& a.depthOps.storeOpD == b.depthOps.storeOpD
|
||||||
|
&& a.depthOps.storeOpS == b.depthOps.storeOpS
|
||||||
&& a.depthOps.storeLayout == b.depthOps.storeLayout;
|
&& a.depthOps.storeLayout == b.depthOps.storeLayout;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < MaxNumRenderTargets && eq; i++) {
|
for (uint32_t i = 0; i < MaxNumRenderTargets && eq; i++) {
|
||||||
|
@ -35,12 +35,12 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Attachment transitions
|
* \brief Color attachment transitions
|
||||||
*
|
*
|
||||||
* Stores the load/store ops and the initial
|
* Stores the load/store ops and the initial
|
||||||
* and final layout of a single attachment.
|
* and final layout of a single attachment.
|
||||||
*/
|
*/
|
||||||
struct DxvkAttachmentOps {
|
struct DxvkColorAttachmentOps {
|
||||||
VkAttachmentLoadOp loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
VkAttachmentLoadOp loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
VkImageLayout loadLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
VkImageLayout loadLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
VkAttachmentStoreOp storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
VkAttachmentStoreOp storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
@ -48,6 +48,22 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Depth attachment transitions
|
||||||
|
*
|
||||||
|
* Stores the load/store ops and the initial and
|
||||||
|
* final layout of the depth-stencil attachment.
|
||||||
|
*/
|
||||||
|
struct DxvkDepthAttachmentOps {
|
||||||
|
VkAttachmentLoadOp loadOpD = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
|
VkAttachmentLoadOp loadOpS = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
|
VkImageLayout loadLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
|
VkAttachmentStoreOp storeOpD = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
|
VkAttachmentStoreOp storeOpS = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
|
VkImageLayout storeLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Render pass transitions
|
* \brief Render pass transitions
|
||||||
*
|
*
|
||||||
@ -56,8 +72,8 @@ namespace dxvk {
|
|||||||
* from a group of render passes with the same format.
|
* from a group of render passes with the same format.
|
||||||
*/
|
*/
|
||||||
struct DxvkRenderPassOps {
|
struct DxvkRenderPassOps {
|
||||||
DxvkAttachmentOps depthOps;
|
DxvkDepthAttachmentOps depthOps;
|
||||||
DxvkAttachmentOps colorOps[MaxNumRenderTargets];
|
DxvkColorAttachmentOps colorOps[MaxNumRenderTargets];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user