@@ -1340,10 +1340,26 @@ namespace dxvk {
1340
1340
desc.resolveTransparencyThreshold = std::max (desc.resolveTransparencyThreshold , OpacityMicromapOptions::Building::decalsMinResolveTransparencyThreshold ());
1341
1341
1342
1342
const auto & samplers = ctx->getCommonObjects ()->getSceneManager ().getSamplerTable ();
1343
- ctx->getCommonObjects ()->metaGeometryUtils ().dispatchBakeOpacityMicromap (
1344
- ctx, blasEntry.modifiedGeometryData ,
1345
- textures, samplers, instance.getAlbedoOpacityTextureIndex (), instance.getSamplerIndex (), instance.getSecondaryOpacityTextureIndex (), instance.getSecondarySamplerIndex (),
1346
- desc, ommCacheItem.bakingState , ommCacheItem.ommArrayBuffer );
1343
+
1344
+ // Bake micro triangles
1345
+ do {
1346
+ ctx->getCommonObjects ()->metaGeometryUtils ().dispatchBakeOpacityMicromap (
1347
+ ctx, blasEntry.modifiedGeometryData ,
1348
+ textures, samplers, instance.getAlbedoOpacityTextureIndex (), instance.getSamplerIndex (), instance.getSecondaryOpacityTextureIndex (), instance.getSecondarySamplerIndex (),
1349
+ desc, ommCacheItem.bakingState , ommCacheItem.ommArrayBuffer );
1350
+
1351
+ if (OpacityMicromapOptions::Building::enableUnlimitedBakingAndBuildingBudgets ()) {
1352
+ desc.maxNumMicroTrianglesToBake = UINT32_MAX;
1353
+
1354
+ // There are more micro triangles to bake
1355
+ if (ommCacheItem.bakingState .numMicroTrianglesBaked < ommCacheItem.bakingState .numMicroTrianglesToBake ) {
1356
+ continue ;
1357
+ }
1358
+ }
1359
+
1360
+ // Exit the loop
1361
+ break ;
1362
+ } while (true );
1347
1363
1348
1364
ctx->getCommandList ()->trackResource <DxvkAccess::Write>(ommCacheItem.ommArrayBuffer );
1349
1365
@@ -1534,6 +1550,10 @@ namespace dxvk {
1534
1550
1535
1551
ScopedGpuProfileZone (ctx, " Bake Opacity Micromap Arrays" );
1536
1552
1553
+ if (OpacityMicromapOptions::Building::enableUnlimitedBakingAndBuildingBudgets ()) {
1554
+ maxMicroTrianglesToBake = UINT32_MAX;
1555
+ }
1556
+
1537
1557
for (auto ommSrcHashIter = m_unprocessedList.begin (); ommSrcHashIter != m_unprocessedList.end () && maxMicroTrianglesToBake > 0 ; ) {
1538
1558
XXH64_hash_t ommSrcHash = *ommSrcHashIter;
1539
1559
@@ -1575,8 +1595,11 @@ namespace dxvk {
1575
1595
ommCacheItem.isUnprocessedCacheStateListIterValid = false ;
1576
1596
}
1577
1597
else {
1578
- // Do nothing, else path means all the budget has been used up and thus the loop will exit due to maxMicroTrianglesToBake == 0
1579
- // so don't need to increment the iterator
1598
+ // Do nothing, else path means all the budget has been used up and thus the loop will exit due to maxMicroTrianglesToBake == 0
1599
+ // so don't need to increment the iterator
1600
+ if (OpacityMicromapOptions::Building::enableUnlimitedBakingAndBuildingBudgets ()) {
1601
+ ONCE (Logger::err (" [RTX Opacity Micromap] Failed to fully bake an Opacity Micromap due to budget limits even with unlimited budgetting enabled." ));
1602
+ }
1580
1603
}
1581
1604
} else if (result == OmmResult::OutOfMemory) {
1582
1605
// Do nothing, try the next one
@@ -1603,6 +1626,10 @@ namespace dxvk {
1603
1626
Logger::warn (str::format (" [RTX Opacity Micromap] ~Baking " , ommSrcHash, " on thread_id " , std::this_thread::get_id ()));
1604
1627
#endif
1605
1628
}
1629
+
1630
+ if (OpacityMicromapOptions::Building::enableUnlimitedBakingAndBuildingBudgets ()) {
1631
+ maxMicroTrianglesToBake = UINT32_MAX;
1632
+ }
1606
1633
}
1607
1634
1608
1635
void OpacityMicromapManager::buildOpacityMicromapsInternal (Rc<DxvkContext> ctx,
@@ -1637,6 +1664,10 @@ namespace dxvk {
1637
1664
std::vector<VkMicromapBuildInfoEXT> micromapBuildInfos (maxBuildItems);
1638
1665
uint32_t buildItemCount = 0 ;
1639
1666
1667
+ if (OpacityMicromapOptions::Building::enableUnlimitedBakingAndBuildingBudgets ()) {
1668
+ maxMicroTrianglesToBuild = UINT32_MAX;
1669
+ }
1670
+
1640
1671
// Force at least one build since a build can't be split across frames even if doesn't fit within the budget
1641
1672
// They're cheap regardless, so it should be fine.
1642
1673
bool forceOmmBuild = maxMicroTrianglesToBuild > 0 ;
@@ -1673,6 +1704,10 @@ namespace dxvk {
1673
1704
} else if (result == OmmResult::OutOfBudget) {
1674
1705
// Do nothing, continue onto the next
1675
1706
ommSrcHashIter++;
1707
+
1708
+ if (OpacityMicromapOptions::Building::enableUnlimitedBakingAndBuildingBudgets ()) {
1709
+ ONCE (Logger::err (" [RTX Opacity Micromap] Failed to fully build an Opacity Micromap due to budget limits even with unlimited budgetting enabled." ));
1710
+ }
1676
1711
} else if (result == OmmResult::OutOfMemory) {
1677
1712
// Do nothing, try the next one
1678
1713
ommSrcHashIter++;
@@ -1684,6 +1719,10 @@ namespace dxvk {
1684
1719
#ifdef VALIDATION_MODE
1685
1720
Logger::warn (str::format (" [RTX Opacity Micromap] ~Building " , ommSrcHash, " on thread_id " , std::this_thread::get_id ()));
1686
1721
#endif
1722
+
1723
+ if (OpacityMicromapOptions::Building::enableUnlimitedBakingAndBuildingBudgets ()) {
1724
+ maxMicroTrianglesToBuild = UINT32_MAX;
1725
+ }
1687
1726
}
1688
1727
1689
1728
if (buildItemCount > 0 ) {
0 commit comments