Skip to content

Commit 59abc35

Browse files
xoxor4dsultim-t-nv
authored andcommitted
Add option to only show textures assigned to a category; Legacy list fix
- Fix showing the category assignment popup when using legacy list mode - Add a new option to legacy mode that only shows assigned textures per category and adds a new texture list with unassigned textures - Variable child size for texture categories (only legacy mode with assigned textures)
1 parent d1ba9c9 commit 59abc35

File tree

3 files changed

+135
-72
lines changed

3 files changed

+135
-72
lines changed

src/dxvk/imgui/dxvk_imgui.cpp

Lines changed: 131 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,9 @@ namespace dxvk {
15061506
namespace texture_popup {
15071507
constexpr char POPUP_NAME[] = "rtx_texture_selection_popup";
15081508

1509+
bool lastOpenCategoryActive = false;
1510+
std::string lastOpenCategoryId = {};
1511+
15091512
// need to keep a reference to a texture that was passed to 'open()',
15101513
// as 'open()' is called only once, but popup needs to reference that texture throughout open-close
15111514
std::atomic<XXH64_hash_t> g_holdingTexture {};
@@ -1602,7 +1605,7 @@ namespace dxvk {
16021605
}
16031606
} // anonymous namespace
16041607

1605-
void ImGUI::showTextureSelectionGrid(const Rc<DxvkContext>& ctx, const char* uniqueId, const uint32_t texturesPerRow, const float thumbnailSize) {
1608+
void ImGUI::showTextureSelectionGrid(const Rc<DxvkContext>& ctx, const char* uniqueId, const uint32_t texturesPerRow, const float thumbnailSize, const float minChildHeight) {
16061609
ImGui::PushID(uniqueId);
16071610
auto common = ctx->getCommonObjects();
16081611
uint32_t cnt = 0;
@@ -1623,7 +1626,8 @@ namespace dxvk {
16231626
}
16241627

16251628
const ImVec2 availableSize = ImGui::GetContentRegionAvail();
1626-
const float childWindowHeight = availableSize.y < 600 ? 600 : availableSize.y;
1629+
const float childWindowHeight = minChildHeight <= 600.0f ? minChildHeight
1630+
: availableSize.y < 600 ? 600.0f : availableSize.y;
16271631
ImGuiWindowFlags window_flags = ImGuiWindowFlags_None;
16281632
ImGui::BeginChild(str::format("Child", uniqueId).c_str(), ImVec2(availableSize.x, childWindowHeight), false, window_flags);
16291633

@@ -1650,7 +1654,17 @@ namespace dxvk {
16501654
}
16511655
}
16521656
}
1653-
1657+
1658+
if (legacyTextureGuiShowAssignedOnly()) {
1659+
if (std::string_view(uniqueId) != "textures") {
1660+
if (!textureHasSelection) {
1661+
continue; // Texture is not assigned to this category -> skip
1662+
}
1663+
} else if (textureHasSelection) {
1664+
continue; // Currently handling the uncategorized texture tab and current texture is assigned to a category -> skip
1665+
}
1666+
}
1667+
16541668
if (texHash == textureInPopup || texHash == g_jumpto.load()) {
16551669
const auto blueColor = ImGui::GetStyleColorVec4(ImGuiCol_Button);
16561670
const auto nvidiaColor = ImVec4(0.462745f, 0.725490f, 0.f, 1.f);
@@ -1689,7 +1703,8 @@ namespace dxvk {
16891703
ImGui::SetCursorPosY(y + (thumbnailSize - extent.y) / 2.f);
16901704

16911705
if (ImGui::ImageButton(texImgui.texID, extent)) {
1692-
if (isListFiltered) {
1706+
// Legacy list = no popup // Legacy list + show assigned only = popup
1707+
if (isListFiltered && !legacyTextureGuiShowAssignedOnly()) {
16931708
toggleTextureSelection(texHash, uniqueId, listRtxOption.textureSetOption->getValue());
16941709
} else {
16951710
clickedOnTextureButton = true;
@@ -1723,6 +1738,9 @@ namespace dxvk {
17231738
if (ImGui::IsMouseReleased(ImGuiMouseButton_Middle)) {
17241739
ImGui::SetClipboardText(hashToString(texHash).c_str());
17251740
}
1741+
if (std::string_view(uniqueId) != texture_popup::lastOpenCategoryId) {
1742+
texture_popup::lastOpenCategoryId = uniqueId;
1743+
}
17261744
}
17271745
}
17281746

@@ -1738,7 +1756,8 @@ namespace dxvk {
17381756
}
17391757

17401758
// popup for texture selection from world / ui
1741-
{
1759+
// Only the "active" category is allowed to control the texture popup and highlighting logic
1760+
if (std::string_view(uniqueId) == texture_popup::lastOpenCategoryId) {
17421761
const bool wasUIClick =
17431762
!texture_popup::isOpened() &&
17441763
clickedOnTextureButton;
@@ -1769,6 +1788,10 @@ namespace dxvk {
17691788
});
17701789
}
17711790

1791+
if (wasUIClick || wasWorldClick) {
1792+
texture_popup::lastOpenCategoryId = uniqueId;
1793+
}
1794+
17721795
auto texHashToHighlight = std::optional<XXH64_hash_t>{};
17731796

17741797
// top priority for what's inside a currently open texture popup
@@ -1791,6 +1814,9 @@ namespace dxvk {
17911814
common->metaDebugView().Highlighting.requestHighlighting(XXH64_hash_t { kEmptyHash }, HighlightColor::UI, ctx->getDevice()->getCurrentFrameId());
17921815
}
17931816
}
1817+
1818+
// checked after the last 'showTextureSelectionGrid' call to see if saved category is still active
1819+
texture_popup::lastOpenCategoryActive = true;
17941820
}
17951821

17961822
ImGui::EndChild();
@@ -1846,6 +1872,8 @@ namespace dxvk {
18461872
void ImGUI::showSetupWindow(const Rc<DxvkContext>& ctx) {
18471873
ImGui::PushItemWidth(200);
18481874

1875+
texture_popup::lastOpenCategoryActive = false;
1876+
18491877
const float thumbnailScale = RtxOptions::textureGridThumbnailScale();
18501878
const float thumbnailSize = (120.f * thumbnailScale);
18511879
const float thumbnailSpacing = ImGui::GetStyle().ItemSpacing.x;
@@ -1856,6 +1884,11 @@ namespace dxvk {
18561884

18571885
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Step 1: Categorize Textures", collapsingHeaderClosedFlags), "Select texture definitions for Remix")) {
18581886
ImGui::Checkbox("Split Texture Category List", &showLegacyTextureGuiObject());
1887+
1888+
if (showLegacyTextureGui()) {
1889+
ImGui::Checkbox("Only Show Assigned Textures in Category Lists", &legacyTextureGuiShowAssignedOnlyObject());
1890+
}
1891+
18591892
ImGui::DragFloat("Texture Thumbnail Scale", &RtxOptions::Get()->textureGridThumbnailScaleObject(), 0.25f, 0.25f, 3.f, "%.2f", sliderFlags);
18601893
ImGui::Separator();
18611894

@@ -1867,136 +1900,164 @@ namespace dxvk {
18671900
showTextureSelectionGrid(ctx, "textures", numThumbnailsPerRow, thumbnailSize);
18681901
}
18691902
else {
1903+
// Wrapper function that controls childheight and logic specific to 'showTextureSelectionGrid'
1904+
const auto& showTextureSelectionGridWrapper = [&](const char* uniqueId) {
1905+
const bool isUncategorized = std::string_view(uniqueId) == "textures";
1906+
float childHeight = 600.0f;
1907+
uint32_t textureCount = 0;
1908+
uint32_t rowCount = 1;
1909+
1910+
// Count textures that are assigned to the current category to calculate childheight for ImGui::BeginChild in 'showTextureSelectionGrid'
1911+
if (legacyTextureGuiShowAssignedOnly() && !isUncategorized) {
1912+
RtxTextureOption listRtxOption;
1913+
1914+
for (auto rtxOption : rtxTextureOptions) {
1915+
if (strcmp(rtxOption.uniqueId, uniqueId) == 0) {
1916+
listRtxOption = rtxOption;
1917+
break;
1918+
}
1919+
}
1920+
1921+
for (auto& [texHash, texImgui] : g_imguiTextureMap) {
1922+
auto& textureSet = listRtxOption.textureSetOption->getValue();
1923+
bool textureHasSelection = textureSet.find(texHash) != textureSet.end();
1924+
1925+
if (!textureHasSelection) {
1926+
continue;
1927+
}
1928+
1929+
textureCount++;
1930+
1931+
if (textureCount > numThumbnailsPerRow * rowCount) {
1932+
rowCount++;
1933+
}
1934+
1935+
childHeight = static_cast<float>(rowCount) * thumbnailSize + 16.0f;
1936+
1937+
if (childHeight >= 600.0f) {
1938+
break;
1939+
}
1940+
}
1941+
}
1942+
1943+
if (textureCount || isUncategorized || !legacyTextureGuiShowAssignedOnly()) {
1944+
if (ImGui::IsItemToggledOpen() || texture_popup::lastOpenCategoryId.empty()) {
1945+
// Update last opened category ID if texture category (ImGui::CollapsingHeader) was just toggled open or if ID is empty
1946+
texture_popup::lastOpenCategoryId = uniqueId;
1947+
}
1948+
1949+
//Legacy GUI: Using indents in this field is causing issues with padding where the rightmost texture is cut off by the scroll bar.
1950+
//Unindent and indent around each list to preserve formatting and use full space while keeping headers and other UI indented for organization.
1951+
ImGui::Unindent();
1952+
showTextureSelectionGrid(ctx, uniqueId, numThumbnailsPerRow, thumbnailSize, childHeight);
1953+
ImGui::Indent();
1954+
}
1955+
else {
1956+
ImGui::Spacing();
1957+
ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("Empty").x) * 0.5f);
1958+
ImGui::Text("Empty");
1959+
ImGui::Spacing();
1960+
}
1961+
};
1962+
18701963
ImGui::Indent();
18711964
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("UI Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->uiTexturesDescription())) {
1872-
//Legacy GUI: Using indents in this field is causing issues with padding where the rightmost texture is cut off by the scroll bar.
1873-
//Unindent and indent around each list to preserve formatting and use full space while keeping headers and other UI indented for organization.
1874-
ImGui::Unindent();
1875-
showTextureSelectionGrid(ctx, "uitextures", numThumbnailsPerRow, thumbnailSize);
1876-
ImGui::Indent();
1965+
showTextureSelectionGridWrapper("uitextures");
18771966
}
18781967

18791968
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Worldspace UI Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->worldSpaceUiTexturesDescription())) {
1880-
ImGui::Unindent();
1881-
showTextureSelectionGrid(ctx, "worldspaceuitextures", numThumbnailsPerRow, thumbnailSize);
1882-
ImGui::Indent();
1969+
showTextureSelectionGridWrapper("worldspaceuitextures");
18831970
}
18841971

18851972
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Worldspace UI Background Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->worldSpaceUiBackgroundTexturesDescription())) {
1886-
ImGui::Unindent();
1887-
showTextureSelectionGrid(ctx, "worldspaceuibackgroundtextures", numThumbnailsPerRow, thumbnailSize);
1888-
ImGui::Indent();
1973+
showTextureSelectionGridWrapper("worldspaceuibackgroundtextures");
18891974
}
18901975

18911976
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Sky Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->skyBoxTexturesDescription())) {
1892-
ImGui::Unindent();
1893-
showTextureSelectionGrid(ctx, "skytextures", numThumbnailsPerRow, thumbnailSize);
1894-
ImGui::Indent();
1977+
showTextureSelectionGridWrapper("skytextures");
18951978
}
18961979

18971980
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Ignore Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->ignoreTexturesDescription())) {
1898-
ImGui::Unindent();
1899-
showTextureSelectionGrid(ctx, "ignoretextures", numThumbnailsPerRow, thumbnailSize);
1900-
ImGui::Indent();
1981+
showTextureSelectionGridWrapper("ignoretextures");
19011982
}
19021983

19031984
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Hide Instance Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->hideInstanceTexturesDescription())) {
1904-
ImGui::Unindent();
1905-
showTextureSelectionGrid(ctx, "hidetextures", numThumbnailsPerRow, thumbnailSize);
1906-
ImGui::Indent();
1985+
showTextureSelectionGridWrapper("hidetextures");
19071986
}
19081987

19091988
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Lightmap Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->lightmapTexturesDescription())) {
1910-
ImGui::Unindent();
1911-
showTextureSelectionGrid(ctx, "lightmaptextures", numThumbnailsPerRow, thumbnailSize);
1912-
ImGui::Indent();
1989+
showTextureSelectionGridWrapper("lightmaptextures");
19131990
}
19141991

19151992
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Ignore Lights (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->ignoreLightsDescription())) {
1916-
ImGui::Unindent();
1917-
showTextureSelectionGrid(ctx, "ignorelights", numThumbnailsPerRow, thumbnailSize);
1918-
ImGui::Indent();
1993+
showTextureSelectionGridWrapper("ignorelights");
19191994
}
19201995

19211996
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Particle Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->particleTexturesDescription())) {
1922-
ImGui::Unindent();
1923-
showTextureSelectionGrid(ctx, "particletextures", numThumbnailsPerRow, thumbnailSize);
1924-
ImGui::Indent();
1997+
showTextureSelectionGridWrapper("particletextures");
19251998
}
19261999

19272000
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Beam Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->beamTexturesDescription())) {
1928-
ImGui::Unindent();
1929-
showTextureSelectionGrid(ctx, "beamtextures", numThumbnailsPerRow, thumbnailSize);
1930-
ImGui::Indent();
2001+
showTextureSelectionGridWrapper("beamtextures");
19312002
}
19322003

19332004
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Add Lights to Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->lightConverterDescription())) {
1934-
ImGui::Unindent();
1935-
showTextureSelectionGrid(ctx, "lightconvertertextures", numThumbnailsPerRow, thumbnailSize);
1936-
ImGui::Indent();
2005+
showTextureSelectionGridWrapper("lightconvertertextures");
19372006
}
19382007

19392008
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Decal Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->decalTexturesDescription())) {
1940-
ImGui::Unindent();
1941-
showTextureSelectionGrid(ctx, "decaltextures", numThumbnailsPerRow, thumbnailSize);
1942-
ImGui::Indent();
2009+
showTextureSelectionGridWrapper("decaltextures");
19432010
}
19442011

19452012
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Legacy Cutout Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->cutoutTexturesDescription())) {
1946-
ImGui::Unindent();
1947-
showTextureSelectionGrid(ctx, "cutouttextures", numThumbnailsPerRow, thumbnailSize);
1948-
ImGui::Indent();
2013+
showTextureSelectionGridWrapper("cutouttextures");
19492014
}
19502015

19512016
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Terrain Textures", collapsingHeaderClosedFlags), RtxOptions::Get()->terrainTexturesDescription())) {
1952-
ImGui::Unindent();
1953-
showTextureSelectionGrid(ctx, "terraintextures", numThumbnailsPerRow, thumbnailSize);
1954-
ImGui::Indent();
2017+
showTextureSelectionGridWrapper("terraintextures");
19552018
}
19562019

19572020
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Water Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->animatedWaterTexturesDescription())) {
1958-
ImGui::Unindent();
1959-
showTextureSelectionGrid(ctx, "watertextures", numThumbnailsPerRow, thumbnailSize);
1960-
ImGui::Indent();
2021+
showTextureSelectionGridWrapper("watertextures");
19612022
}
19622023

19632024
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Player Model Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->playerModelTexturesDescription())) {
1964-
ImGui::Unindent();
1965-
showTextureSelectionGrid(ctx, "playermodeltextures", numThumbnailsPerRow, thumbnailSize);
1966-
ImGui::Indent();
2025+
showTextureSelectionGridWrapper("playermodeltextures");
19672026
}
19682027

19692028
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Player Model Body Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->playerModelBodyTexturesDescription())) {
1970-
ImGui::Unindent();
1971-
showTextureSelectionGrid(ctx, "playermodelbodytextures", numThumbnailsPerRow, thumbnailSize);
1972-
ImGui::Indent();
2029+
showTextureSelectionGridWrapper("playermodelbodytextures");
19732030
}
19742031

19752032
if (RtxOptions::AntiCulling::Object::enable() &&
19762033
IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Anti-Culling Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->antiCullingTexturesDescription())) {
1977-
ImGui::Unindent();
1978-
showTextureSelectionGrid(ctx, "antiCullingTextures", numThumbnailsPerRow, thumbnailSize);
1979-
ImGui::Indent();
2034+
showTextureSelectionGridWrapper("antiCullingTextures");
19802035
}
19812036

19822037
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Motion Blur Mask-Out Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->motionBlurMaskOutTexturesDescription())) {
1983-
ImGui::Unindent();
1984-
showTextureSelectionGrid(ctx, "motionBlurMaskOutTextures", numThumbnailsPerRow, thumbnailSize);
1985-
ImGui::Indent();
2038+
showTextureSelectionGridWrapper("motionBlurMaskOutTextures");
19862039
}
19872040

19882041
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Opacity Micromap Ignore Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->opacityMicromapIgnoreTexturesDescription())) {
1989-
ImGui::Unindent();
1990-
showTextureSelectionGrid(ctx, "opacitymicromapignoretextures", numThumbnailsPerRow, thumbnailSize);
1991-
ImGui::Indent();
2042+
showTextureSelectionGridWrapper("opacitymicromapignoretextures");
19922043
}
19932044

19942045
if (IMGUI_ADD_TOOLTIP(ImGui::CollapsingHeader("Ignore Baked Lighting Textures (optional)", collapsingHeaderClosedFlags), RtxOptions::Get()->ignoreBakedLightingTexturesDescription())) {
1995-
ImGui::Unindent();
1996-
showTextureSelectionGrid(ctx, "ignorebakedlightingtextures", numThumbnailsPerRow, thumbnailSize);
1997-
ImGui::Indent();
2046+
showTextureSelectionGrid(ctx, "ignorebakedlightingtextures");
2047+
}
2048+
2049+
if (legacyTextureGuiShowAssignedOnly())
2050+
{
2051+
if (ImGui::CollapsingHeader("Uncategorized", collapsingHeaderClosedFlags)) {
2052+
showTextureSelectionGridWrapper("textures");
2053+
}
19982054
}
19992055
ImGui::Unindent();
2056+
2057+
// Check if last saved category was closed this frame
2058+
if (!texture_popup::lastOpenCategoryActive) {
2059+
texture_popup::lastOpenCategoryId.clear();
2060+
}
20002061
}
20012062
}
20022063

src/dxvk/imgui/dxvk_imgui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ namespace dxvk {
207207
void showAppConfig(const Rc<DxvkContext>& ctx);
208208

209209
// helper to display a configurable grid of all textures currently hooked to ImGUI
210-
void showTextureSelectionGrid(const Rc<DxvkContext>& ctx, const char* uniqueId, const uint32_t texturesPerRow, const float thumbnailSize);
210+
void showTextureSelectionGrid(const Rc<DxvkContext>& ctx, const char* uniqueId, const uint32_t texturesPerRow, const float thumbnailSize, const float minChildHeight = 600.0f);
211211

212212
void createFontsTexture(const Rc<DxvkContext>& ctx);
213213

@@ -221,6 +221,7 @@ namespace dxvk {
221221
void showMemoryStats() const;
222222

223223
RTX_OPTION("rtx.gui", bool, showLegacyTextureGui, false, "A setting to toggle the old texture selection GUI, where each texture category is represented as its own list.");
224+
RTX_OPTION("rtx.gui", bool, legacyTextureGuiShowAssignedOnly, false, "A setting to show only the textures in a category that are assigned to it (Unassigned textures are found in the \"Uncategorized\" list at the bottom).");
224225
RTX_OPTION("rtx.gui", float, reflexStatRangeInterpolationRate, 0.05f, "A value controlling the interpolation rate applied to the Reflex stat graph ranges for smoother visualization.");
225226
RTX_OPTION("rtx.gui", float, reflexStatRangePaddingRatio, 0.05f, "A value specifying the amount of padding applied to the Reflex stat graph ranges as a ratio to the calculated range.");
226227

src/dxvk/imgui/dxvk_imgui_about.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ namespace dxvk {
9191
ImGuiAbout::Credits::Credits()
9292
: m_sections({
9393
{ "Github Contributors",
94-
{ "Leonardo Leotte",
94+
{ "Alexander 'xoxor4d' Engel",
95+
"Leonardo Leotte",
9596
"Nico Rodrigues-McKenna"}},
9697
{ "Engineering",
9798
{ "Riley Alston",

0 commit comments

Comments
 (0)