Skip to content

Commit 8626978

Browse files
Merge branch 'rtxOptions1' into 'main'
[REMIX-715] Refactor RtxOptions to use hashes as keys See merge request lightspeedrtx/dxvk-remix-nv!1116
2 parents 912a164 + 26b71b0 commit 8626978

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

src/dxvk/rtx_render/rtx_game_capturer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ namespace dxvk {
10231023
exportPrep.meta.isZUp = RtxOptions::Get()->isZUp();
10241024
if (s_captureRemixConfigs) {
10251025
for (auto& pair : RtxOptionImpl::getGlobalRtxOptionMap()) {
1026-
exportPrep.meta.renderingSettingsDict[pair.first] = pair.second->genericValueToString(RtxOptionImpl::ValueType::Value);
1026+
exportPrep.meta.renderingSettingsDict[pair.second->getFullName()] = pair.second->genericValueToString(RtxOptionImpl::ValueType::Value);
10271027
}
10281028
}
10291029
exportPrep.meta.bCorrectBakedTransforms = false;

src/dxvk/rtx_render/rtx_mod_usd.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ XXH64_hash_t getStrongestOpinionatedPathHash(const pxr::UsdPrim& prim) {
146146
std::string originPath = spec->GetPath().GetString();
147147

148148
XXH64_hash_t usdOriginHash = 0;
149-
usdOriginHash = XXH64(originOfMeshFile.c_str(), originOfMeshFile.size(), usdOriginHash);
150-
usdOriginHash = XXH64(originPath.c_str(), originPath.size(), usdOriginHash);
149+
usdOriginHash = StringToXXH64(originOfMeshFile, usdOriginHash);
150+
usdOriginHash = StringToXXH64(originPath, usdOriginHash);
151151

152152
return usdOriginHash;
153153
}

src/dxvk/rtx_render/rtx_option.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,19 @@ Tables below enumerate all the options and their defaults set by RTX Remix. Note
379379

380380
// Write out all RTX Options
381381
auto& globalRtxOptions = getGlobalRtxOptionMap();
382+
383+
// Need to sort the options alphabetically by full name.
384+
std::vector<RtxOptionImpl*> sortedOptions;
385+
sortedOptions.reserve(globalRtxOptions.size());
382386
for (const auto& rtxOptionMapEntry : globalRtxOptions) {
383-
const RtxOptionImpl& rtxOption = *rtxOptionMapEntry.second.get();
387+
sortedOptions.push_back(rtxOptionMapEntry.second.get());
388+
}
389+
std::sort(sortedOptions.begin(), sortedOptions.end(), [](RtxOptionImpl* a, RtxOptionImpl* b) {
390+
return a->getFullName() < b->getFullName();
391+
});
392+
393+
for (const RtxOptionImpl* rtxOptionsPtr : sortedOptions) {
394+
const RtxOptionImpl& rtxOption = *rtxOptionsPtr;
384395

385396
// Allow processing of short or long value entry categories separately
386397
{

src/dxvk/rtx_render/rtx_option.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace dxvk {
7272
};
7373

7474
struct RtxOptionImpl {
75-
using RtxOptionMap = std::map<std::string, std::shared_ptr<RtxOptionImpl>>;
75+
using RtxOptionMap = std::map<XXH64_hash_t, std::shared_ptr<RtxOptionImpl>>;
7676
enum class ValueType {
7777
Value = 0,
7878
DefaultValue = 1,
@@ -260,12 +260,13 @@ namespace dxvk {
260260
private:
261261
bool allocateMemory(const char* category, const char* name, const char* environment, uint32_t flags, const char* description) {
262262
const std::string fullName = RtxOptionImpl::getFullName(category, name);
263+
const XXH64_hash_t optionHash = StringToXXH64(fullName, 0);
263264
auto& globalRtxOptions = RtxOptionImpl::getGlobalRtxOptionMap();
264-
auto pOption = globalRtxOptions.find(fullName);
265+
auto pOption = globalRtxOptions.find(optionHash);
265266
if (pOption == globalRtxOptions.end()) {
266267
// Cannot find existing object, make a new one
267268
pImpl = std::make_shared<RtxOptionImpl>(name, category, environment, getOptionType(), flags, description);
268-
globalRtxOptions[fullName] = pImpl;
269+
globalRtxOptions[optionHash] = pImpl;
269270
return true;
270271
} else {
271272
// If the variable already exists, use the existing object

src/dxvk/rtx_render/rtx_remix_api.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,8 @@ namespace {
996996
std::string strKey = std::string{ key };
997997

998998
const auto& globalRtxOptions = dxvk::RtxOptionImpl::getGlobalRtxOptionMap();
999-
auto found = globalRtxOptions.find(strKey);
999+
const XXH64_hash_t optionHash = dxvk::StringToXXH64(strKey, 0);
1000+
auto found = globalRtxOptions.find(optionHash);
10001001
if (found == globalRtxOptions.end()) {
10011002
return REMIXAPI_ERROR_CODE_GENERAL_FAILURE;
10021003
}

src/dxvk/rtx_render/rtx_utils.h

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ inline const std::string hashToString(XXH64_hash_t hash) {
8787
return ss.str();
8888
}
8989

90+
inline const XXH64_hash_t StringToXXH64(const std::string& str, const XXH64_hash_t seed) {
91+
return XXH64(str.c_str(), str.size(), seed);
92+
}
93+
9094
enum BufferType {
9195
Raster = 0,
9296
Raytrace

0 commit comments

Comments
 (0)