1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-29 01:24:11 +01:00

[d3d9] Use VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_EXT for hazards if available

This commit is contained in:
Joshua Ashton 2022-08-05 19:12:21 +00:00 committed by Joshie
parent 90abd993d4
commit 63d582a6e7
4 changed files with 20 additions and 12 deletions

View File

@ -343,20 +343,22 @@ namespace dxvk {
return m_sampleView.Pick(srgb && IsSrgbCompatible());
}
VkImageLayout DetermineRenderTargetLayout() const {
VkImageLayout DetermineRenderTargetLayout(VkImageLayout hazardLayout) const {
if (unlikely(m_hazardous))
return hazardLayout;
return m_image != nullptr &&
m_image->info().tiling == VK_IMAGE_TILING_OPTIMAL &&
!m_hazardous
m_image->info().tiling == VK_IMAGE_TILING_OPTIMAL
? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
: VK_IMAGE_LAYOUT_GENERAL;
}
VkImageLayout DetermineDepthStencilLayout(bool write, bool hazardous) const {
VkImageLayout DetermineDepthStencilLayout(bool write, bool hazardous, VkImageLayout hazardLayout) const {
VkImageLayout layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
if (unlikely(hazardous)) {
layout = write
? VK_IMAGE_LAYOUT_GENERAL
? hazardLayout
: VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL;
}

View File

@ -115,6 +115,10 @@ namespace dxvk {
m_availableMemory = DetermineInitialTextureMemory();
m_hazardLayout = dxvkDevice->features().extAttachmentFeedbackLoopLayout.attachmentFeedbackLoopLayout
? VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT
: VK_IMAGE_LAYOUT_GENERAL;
// Initially set all the dirty flags so we
// always end up giving the backend *something* to work with.
m_flags.set(D3D9DeviceFlag::DirtyFramebuffer);
@ -5241,7 +5245,7 @@ namespace dxvk {
// Guaranteed to not be nullptr...
auto tex = m_state.renderTargets[rtIdx]->GetCommonTexture();
if (unlikely(!tex->MarkHazardous())) {
TransitionImage(tex, VK_IMAGE_LAYOUT_GENERAL);
TransitionImage(tex, m_hazardLayout);
m_flags.set(D3D9DeviceFlag::DirtyFramebuffer);
}
}
@ -5447,7 +5451,7 @@ namespace dxvk {
attachments.color[i] = {
m_state.renderTargets[i]->GetRenderTargetView(srgb),
m_state.renderTargets[i]->GetRenderTargetLayout() };
m_state.renderTargets[i]->GetRenderTargetLayout(m_hazardLayout) };
}
if (m_state.depthStencil != nullptr &&
@ -5460,7 +5464,7 @@ namespace dxvk {
if (likely(sampleCount == VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM || sampleCount == dsImageInfo.sampleCount)) {
attachments.depth = {
m_state.depthStencil->GetDepthStencilView(),
m_state.depthStencil->GetDepthStencilLayout(depthWrite, m_activeHazardsDS != 0) };
m_state.depthStencil->GetDepthStencilLayout(depthWrite, m_activeHazardsDS != 0, m_hazardLayout) };
}
}

View File

@ -1255,6 +1255,8 @@ namespace dxvk {
bool m_amdATOC = false;
bool m_nvATOC = false;
bool m_ffZTest = false;
VkImageLayout m_hazardLayout = VK_IMAGE_LAYOUT_GENERAL;
float m_depthBiasScale = 0.0f;

View File

@ -95,8 +95,8 @@ namespace dxvk {
return view;
}
inline VkImageLayout GetRenderTargetLayout() const {
return m_texture->DetermineRenderTargetLayout();
inline VkImageLayout GetRenderTargetLayout(VkImageLayout hazardLayout) const {
return m_texture->DetermineRenderTargetLayout(hazardLayout);
}
inline const Rc<DxvkImageView>& GetDepthStencilView() {
@ -108,8 +108,8 @@ namespace dxvk {
return view;
}
inline VkImageLayout GetDepthStencilLayout(bool write, bool hazardous) const {
return m_texture->DetermineDepthStencilLayout(write, hazardous);
inline VkImageLayout GetDepthStencilLayout(bool write, bool hazardous, VkImageLayout hazardLayout) const {
return m_texture->DetermineDepthStencilLayout(write, hazardous, hazardLayout);
}
inline bool IsNull() {