Skip to content

Commit 50f30eb

Browse files
author
yifeidong
committed
Some tweaks for rmv:
- Update the BUILD.md file to fix inconsistencies in the Windows pre-build options. - Add an option in Settings to toggle between KB and KiB units for size display. - Add "Dimension", "MipLevel" and "Format" columns in the Resource list for Textures, DepthStencils and RenderTargets. - Add a button to export all resource details from the Resource list.
1 parent 29bb28f commit 50f30eb

15 files changed

Lines changed: 377 additions & 7 deletions

BUILD.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ This can be installed once Python is installed, as follows:
3636
Run the python pre_build.py script in the build folder from a command prompt. If no command line options are provided, the defaults will be used (Qt 6.7.0 and Visual Studio 2022)
3737

3838
Some useful options of the pre_build.py script:
39-
* --vs <Visual Studio version>: generate the solution files for a specific Visual Studio version. For example, to target Visual Studio 2017, add --vs 2017 to the command.
40-
* --qt <path>: full path to the folder from where you would like the Qt binaries to be retrieved. By default, CMake would try to auto-detect Qt on the system.
39+
* --vs \<Visual Studio version\>: generate the solution files for a specific Visual Studio version. For example, to target Visual Studio 2017, add --vs 2017 to the command.
40+
* --qt \<QT Version\>: specify the version of QT to be used with the script (default: 6.7.0).
41+
* --qt-root \<path\>: full path to the folder from where you would like the Qt binaries to be retrieved. By default, CMake would try to auto-detect Qt on the system.
4142

4243
Once the script has finished, in the case of Visual Studio 2019, a sub-folder called 'vs2019' will be created containing the necessary build files.
4344
Go into the 'vs2019' folder (build/win/vs2019) and double click on the RMV.sln file and build the 64-bit Debug and Release builds.

source/frontend/models/proxy_models/resource_proxy_model.cpp

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ namespace rmv
3434
setSourceModel(model);
3535
SetFilterKeyColumns({kResourceColumnName,
3636
kResourceColumnVirtualAddress,
37+
kResourceColumnUsage,
38+
kResourceColumnDimension,
39+
kResourceColumnMipLevel,
40+
kResourceColumnFormat,
3741
kResourceColumnSize,
3842
kResourceColumnMappedInvisible,
3943
kResourceColumnMappedLocal,
4044
kResourceColumnMappedHost,
4145
kResourceColumnMappedNone,
42-
kResourceColumnPreferredHeap,
43-
kResourceColumnUsage});
46+
kResourceColumnPreferredHeap});
4447

4548
view->setModel(this);
4649
return model;
@@ -161,6 +164,48 @@ namespace rmv
161164
}
162165
return left_data < right_data;
163166
}
167+
else if ((left.column() == kResourceColumnDimension && right.column() == kResourceColumnDimension))
168+
{
169+
const QList<QVariant> left_data = left.data(Qt::UserRole).toList();
170+
const QList<QVariant> right_data = right.data(Qt::UserRole).toList();
171+
if (left_data == right_data)
172+
{
173+
return SortIdentical(left, right);
174+
}
175+
176+
qlonglong left_pixels = 1;
177+
qlonglong right_pixels = 1;
178+
for (const QVariant& data : left_data)
179+
{
180+
left_pixels *= data.toInt();
181+
}
182+
for (const QVariant& data : right_data)
183+
{
184+
right_pixels *= data.toInt();
185+
}
186+
187+
return left_pixels < right_pixels;
188+
}
189+
else if ((left.column() == kResourceColumnMipLevel && right.column() == kResourceColumnMipLevel))
190+
{
191+
const int left_data = left.data(Qt::UserRole).toInt();
192+
const int right_data = right.data(Qt::UserRole).toInt();
193+
if (left_data == right_data)
194+
{
195+
return SortIdentical(left, right);
196+
}
197+
return left_data < right_data;
198+
}
199+
else if ((left.column() == kResourceColumnFormat && right.column() == kResourceColumnFormat))
200+
{
201+
const QString left_data = left.data(Qt::UserRole).toString();
202+
const QString right_data = right.data(Qt::UserRole).toString();
203+
if (left_data == right_data)
204+
{
205+
return SortIdentical(left, right);
206+
}
207+
return left_data < right_data;
208+
}
164209
else if ((left.column() == kResourceColumnSize && right.column() == kResourceColumnSize))
165210
{
166211
const qulonglong left_data = left.data(Qt::UserRole).toULongLong();

source/frontend/models/proxy_models/table_proxy_model.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ namespace rmv
6262
return out;
6363
}
6464

65+
QString TableProxyModel::GetDataAsStr(int row, int column)
66+
{
67+
QString out("null");
68+
69+
const QModelIndex model_index = index(row, column, QModelIndex());
70+
71+
if (model_index.isValid() == true)
72+
{
73+
out = data(model_index, Qt::DisplayRole).toString();
74+
}
75+
return out;
76+
}
77+
6578
QModelIndex TableProxyModel::FindModelIndex(qulonglong lookup, int column) const
6679
{
6780
QModelIndex out_model_index;

source/frontend/models/proxy_models/table_proxy_model.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ namespace rmv
5252
/// @return The contents at row, column.
5353
qulonglong GetData(int row, int column);
5454

55+
/// @brief Get content from proxy model.
56+
///
57+
/// @param [in] row The row where the data is located.
58+
/// @param [in] column The column where the data is located.
59+
///
60+
/// @return The string contents at row, column.
61+
QString GetDataAsStr(int row, int column);
62+
5563
/// @brief Find a model index corresponding to the passed in data.
5664
///
5765
/// @param [in] lookup The value to find.

source/frontend/models/resource_item_model.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ namespace rmv
5353
resource_table->SetColumnWidthEms(kResourceColumnCompareId, 8);
5454
resource_table->SetColumnWidthEms(kResourceColumnName, 20);
5555
resource_table->SetColumnWidthEms(kResourceColumnVirtualAddress, 11);
56+
resource_table->SetColumnWidthEms(kResourceColumnDimension, 11);
57+
resource_table->SetColumnWidthEms(kResourceColumnMipLevel, 6);
58+
resource_table->SetColumnWidthEms(kResourceColumnFormat, 8);
5659
resource_table->SetColumnWidthEms(kResourceColumnSize, 8);
5760
resource_table->SetColumnWidthEms(kResourceColumnPreferredHeap, 11);
5861
resource_table->SetColumnWidthEms(kResourceColumnMappedInvisible, 13);
@@ -134,6 +137,18 @@ namespace rmv
134137
return cache_[row].resource_name;
135138
case kResourceColumnVirtualAddress:
136139
return rmv::string_util::LocalizedValueAddress(RmtResourceGetVirtualAddress(resource));
140+
case kResourceColumnDimension:
141+
return resource->resource_type == kRmtResourceTypeImage
142+
? QString::asprintf("%dx%dx%d", resource->image.dimension_x, resource->image.dimension_y, resource->image.dimension_z)
143+
: QString("-");
144+
case kResourceColumnMipLevel:
145+
return resource->resource_type == kRmtResourceTypeImage
146+
? QString::asprintf("%d", resource->image.mip_levels)
147+
: QString("-");
148+
case kResourceColumnFormat:
149+
return resource->resource_type == kRmtResourceTypeImage
150+
? QString(RmtGetFormatNameFromFormat(resource->image.format.format))
151+
: QString("-");
137152
case kResourceColumnSize:
138153
return rmv::string_util::LocalizedValueMemory(resource->size_in_bytes, false, false);
139154
case kResourceColumnMappedInvisible:
@@ -179,6 +194,18 @@ namespace rmv
179194
return QVariant::fromValue<qulonglong>(resource->identifier);
180195
case kResourceColumnVirtualAddress:
181196
return QVariant::fromValue<qulonglong>(RmtResourceGetVirtualAddress(resource));
197+
case kResourceColumnDimension:
198+
return resource->resource_type == kRmtResourceTypeImage
199+
? QList<QVariant>({resource->image.dimension_x, resource->image.dimension_y, resource->image.dimension_z})
200+
: QList<QVariant>({0, 0, 0});
201+
case kResourceColumnMipLevel:
202+
return resource->resource_type == kRmtResourceTypeImage
203+
? resource->image.mip_levels
204+
: 0;
205+
case kResourceColumnFormat:
206+
return resource->resource_type == kRmtResourceTypeImage
207+
? QString(RmtGetFormatNameFromFormat(resource->image.format.format))
208+
: QString("-");
182209
case kResourceColumnSize:
183210
return QVariant::fromValue<qulonglong>(resource->size_in_bytes);
184211
case kResourceColumnMappedInvisible:
@@ -207,6 +234,18 @@ namespace rmv
207234
{
208235
case kResourceColumnName:
209236
return cache_[row].resource_name;
237+
case kResourceColumnDimension:
238+
return resource->resource_type == kRmtResourceTypeImage
239+
? QString::asprintf("%dx%dx%d", resource->image.dimension_x, resource->image.dimension_y, resource->image.dimension_z)
240+
: QString("-");
241+
case kResourceColumnMipLevel:
242+
return resource->resource_type == kRmtResourceTypeImage
243+
? QString::asprintf("%d", resource->image.mip_levels)
244+
: QString("-");
245+
case kResourceColumnFormat:
246+
return resource->resource_type == kRmtResourceTypeImage
247+
? QString(RmtGetFormatNameFromFormat(resource->image.format.format))
248+
: QString("-");
210249
case kResourceColumnSize:
211250
return rmv::string_util::LocalizedValueBytes(resource->size_in_bytes);
212251
case kResourceColumnMappedInvisible:
@@ -243,6 +282,12 @@ namespace rmv
243282
return "Name";
244283
case kResourceColumnVirtualAddress:
245284
return "Virtual address";
285+
case kResourceColumnDimension:
286+
return "Dimension";
287+
case kResourceColumnMipLevel:
288+
return "Mip Level";
289+
case kResourceColumnFormat:
290+
return "Format";
246291
case kResourceColumnSize:
247292
return "Size";
248293
case kResourceColumnPreferredHeap:

source/frontend/models/resource_item_model.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ namespace rmv
2626
kResourceColumnCompareId,
2727
kResourceColumnName,
2828
kResourceColumnVirtualAddress,
29+
kResourceColumnUsage,
30+
kResourceColumnDimension,
31+
kResourceColumnMipLevel,
32+
kResourceColumnFormat,
2933
kResourceColumnSize,
3034
kResourceColumnPreferredHeap,
3135
kResourceColumnMappedInvisible,
3236
kResourceColumnMappedLocal,
3337
kResourceColumnMappedHost,
3438
kResourceColumnMappedNone,
35-
kResourceColumnUsage,
3639

3740
// Hidden, these columns are used as proxies for sorting by other columns.
3841
kResourceColumnAllocationIdInternal,

source/frontend/settings/rmv_settings.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ namespace rmv
206206
default_settings_[kSettingLastFileOpenLocation] = {"LastFileOpenLocation", ""};
207207
default_settings_[kSettingGeneralCheckForUpdatesOnStartup] = {"CheckForUpdatesOnStartup", "False"};
208208
default_settings_[kSettingGeneralTimeUnits] = {"TimeUnits", rmv::text::kSettingsUnitsSeconds};
209+
default_settings_[kSettingGeneralByteUnits] = {"ByteUnits", rmv::text::kSettingsByteUnitsDefault};
209210
default_settings_[kSettingGeneralDriverOverridesAllowNotifications] = {"DriverOverridesAllowNotifications", "True"};
210211

211212
default_settings_[kSettingThemesAndColorsPalette] = {"ColorPalette",
@@ -362,6 +363,11 @@ namespace rmv
362363
}
363364
}
364365

366+
QString RMVSettings::GetByteUnits() const
367+
{
368+
return active_settings_[kSettingGeneralByteUnits].value;
369+
}
370+
365371
int RMVSettings::GetWindowWidth() const
366372
{
367373
return GetIntValue(kSettingMainWindowWidth);
@@ -420,6 +426,19 @@ namespace rmv
420426
SaveSettings();
421427
}
422428

429+
void RMVSettings::SetByteUnits(const QString& units)
430+
{
431+
if (units == rmv::text::kSettingsByteUnitsBinary || units == rmv::text::kSettingsByteUnitsDecimal)
432+
{
433+
AddPotentialSetting(default_settings_[kSettingGeneralByteUnits].name, units);
434+
}
435+
else
436+
{
437+
AddPotentialSetting(default_settings_[kSettingGeneralByteUnits].name, rmv::text::kSettingsByteUnitsDefault);
438+
}
439+
SaveSettings();
440+
}
441+
423442
void RMVSettings::SetLastFileOpenLocation(const QString& last_file_open_location)
424443
{
425444
AddPotentialSetting("LastFileOpenLocation", last_file_open_location);

source/frontend/settings/rmv_settings.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ enum RMVSettingID
9797
kSettingThemesAndColorsCommitTypePlaced,
9898
kSettingThemesAndColorsCommitTypeVirtual,
9999

100+
kSettingGeneralByteUnits,
101+
100102
kSettingCount,
101103
};
102104

@@ -220,6 +222,11 @@ namespace rmv
220222
/// @return A TimeUnitType value.
221223
TimeUnitType GetUnits() const;
222224

225+
/// @brief Get byte units from the settings.
226+
///
227+
/// @return The string value for Byte Unit.
228+
QString GetByteUnits() const;
229+
223230
/// @brief Get last file open location from the settings.
224231
///
225232
/// @return Path to last opened file dir.
@@ -264,6 +271,11 @@ namespace rmv
264271
/// @param [in] units The new value of the timing units.
265272
void SetUnits(const TimeUnitType units);
266273

274+
/// @brief Set the byte units in the settings.
275+
///
276+
/// @param [in] units The new value of the byte units.
277+
void SetByteUnits(const QString& units);
278+
267279
/// @brief Get the value of kSettingGeneralCheckForUpdatesOnStartup in the settings.
268280
///
269281
/// @return The value of kSettingGeneralCheckForUpdatesOnStartup.

source/frontend/util/constants.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ namespace rmv
137137
static const QString kSettingsUnitsMinutes = "Minutes";
138138
static const QString kSettingsUnitsHours = "Hours";
139139

140+
// Byte units.
141+
static const QString kSettingsByteUnitsDefault = "Default";
142+
static const QString kSettingsByteUnitsBinary = "Binary";
143+
static const QString kSettingsByteUnitsDecimal = "Decimal";
144+
140145
// Help file locations for trace and RMV.
141146
static const QString kTraceHelpFile = "/help/rdp/index.html";
142147
static const QString kRmvHelpFile = "/help/rmv/index.html";

source/frontend/util/string_util.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include "qt_common/utils/qt_util.h"
1414

15+
#include "settings/rmv_settings.h"
16+
1517
QString rmv::string_util::ToUpperCase(const QString& string)
1618
{
1719
QString out;
@@ -69,8 +71,19 @@ QString rmv::string_util::LocalizedValuePrecise(double value)
6971
return str;
7072
}
7173

72-
QString rmv::string_util::LocalizedValueMemory(const double value, const bool base_10, const bool use_round, const bool include_decimal)
74+
QString rmv::string_util::LocalizedValueMemory(const double value, const bool in_base_10, const bool use_round, const bool include_decimal)
7375
{
76+
QString ByteUnits = RMVSettings::Get().GetByteUnits();
77+
bool base_10 = in_base_10;
78+
if (ByteUnits == rmv::text::kSettingsByteUnitsBinary)
79+
{
80+
base_10 = false;
81+
}
82+
else if (ByteUnits == rmv::text::kSettingsByteUnitsDecimal)
83+
{
84+
base_10 = true;
85+
}
86+
7487
double multiple;
7588
if (base_10)
7689
{

0 commit comments

Comments
 (0)