Skip to content

Commit

Permalink
Merge branch 'xbei/missing_rt_fix' into 'main'
Browse files Browse the repository at this point in the history
[REMIX-2717] Fix missing render target texture

See merge request lightspeedrtx/dxvk-remix-nv!711
  • Loading branch information
xbei-nv committed Feb 29, 2024
2 parents d1e34a1 + 02622b8 commit a977da4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
16 changes: 15 additions & 1 deletion src/d3d9/d3d9_common_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <sstream>
#include "../dxvk/imgui/dxvk_imgui.h"

#include <charconv>

namespace dxvk {
D3D9CommonTexture::D3D9CommonTexture(
D3D9DeviceEx* pDevice,
Expand Down Expand Up @@ -335,7 +337,19 @@ namespace dxvk {
}

// NV-DXVK start: add debug names to VkImage objects
return m_device->GetDXVKDevice()->createImage(imageInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, DxvkMemoryStats::Category::AppTexture, "D3D9 texture primary");
auto image = m_device->GetDXVKDevice()->createImage(imageInfo, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, DxvkMemoryStats::Category::AppTexture, "D3D9 texture primary");
// Calculate hash for the render target textures
if (image->getHash() == kEmptyHash && IsRenderTarget()) {
static uint32_t renderTargetHashCounter = 0;
auto newHash = XXH3_64bits(&image->info().extent, sizeof(image->info().extent));
newHash = XXH3_64bits_withSeed(&renderTargetHashCounter, sizeof(uint32_t), newHash);
++renderTargetHashCounter;
image->setHash(newHash);
char addressStr[20] = { 0 };
std::to_chars(std::begin(addressStr), std::end(addressStr), newHash, 16);
TRACE("newHash: ", addressStr);
}
return image;
// NV-DXVK end
}

Expand Down
7 changes: 4 additions & 3 deletions src/d3d9/d3d9_rtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,10 @@ namespace dxvk {
// Conditions: non-textured flood-fill draws into a small quad render target
if (((d3d9State().textureStages[0][D3DTSS_COLOROP] == D3DTOP_SELECTARG1 && d3d9State().textureStages[0][D3DTSS_COLORARG1] != D3DTA_TEXTURE) ||
(d3d9State().textureStages[0][D3DTSS_COLOROP] == D3DTOP_SELECTARG2 && d3d9State().textureStages[0][D3DTSS_COLORARG2] != D3DTA_TEXTURE))) {
auto rtExt = d3d9State().renderTargets[kRenderTargetIndex]->GetSurfaceExtent();
// If rt is a quad at least 4 times smaller than backbuffer it is likely a shadow mask
if (rtExt.width == rtExt.height && rtExt.width < m_activePresentParams.BackBufferWidth / 4) {
const auto& rtExt = d3d9State().renderTargets[kRenderTargetIndex]->GetSurfaceExtent();
// If rt is a quad at least 4 times smaller than backbuffer and the format is invalid format, then it is likely a shadow mask
if (rtExt.width == rtExt.height && rtExt.width < m_activePresentParams.BackBufferWidth / 4 &&
Resources::getFormatCompatibilityCategoryIndex(d3d9State().renderTargets[kRenderTargetIndex]->GetImageView(false)->imageInfo().format) == Resources::kInvalidFormatCompatibilityCategoryIndex) {
ONCE(Logger::info("[RTX-Compatibility-Info] Skipped shadow mask drawcall."));
return { RtxGeometryStatus::Ignored, false };
}
Expand Down

0 comments on commit a977da4

Please sign in to comment.