Skip to content

Commit

Permalink
Merge branch 'dev/adunn/texture_corruption' into 'main'
Browse files Browse the repository at this point in the history
Fix issue of texture corruption when reloading textures

See merge request lightspeedrtx/dxvk-remix-nv!685
  • Loading branch information
AlexDunn committed Jan 25, 2024
2 parents 1be52c2 + 7decaf1 commit e04a234
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/dxvk/rtx_render/rtx_asset_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ namespace dxvk {
uint32_t numLayers = 0;

const char* filename = nullptr;

bool matches(const AssetInfo& other) const {
return other.type == type &&
other.compression == compression &&
other.format == format &&
other.extent.width == extent.width &&
other.extent.height == extent.height &&
other.extent.depth == extent.depth &&
other.mipLevels == mipLevels &&
other.looseLevels == looseLevels &&
other.numLayers == numLayers;
}
};

class AssetData : public RcObject {
Expand Down
8 changes: 7 additions & 1 deletion src/dxvk/rtx_render/rtx_texture_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,13 @@ namespace dxvk {

auto it = m_assetHashToTextures.find(hash);
if (it != m_assetHashToTextures.end()) {
return it->second;
// Is this truly the same asset?
if (it->second->assetData->info().matches(assetData->info())) {
return it->second;
}

// Else, clear out the old
m_assetHashToTextures.erase(it);
}

{
Expand Down

0 comments on commit e04a234

Please sign in to comment.