Skip to content

Commit 2076985

Browse files
committed
Update source code for RMV v1.8 release
1 parent 250730d commit 2076985

39 files changed

+1220
-282
lines changed

CMakeLists.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ project(RMV)
77

88
# Define version information
99
set(RMV_MAJOR_VERSION 1)
10-
set(RMV_MINOR_VERSION 7)
10+
set(RMV_MINOR_VERSION 8)
1111
if (NOT RMV_BUGFIX_NUMBER)
1212
set(RMV_BUGFIX_NUMBER 0)
1313
endif ()
@@ -32,14 +32,14 @@ option(RDF_STATIC "Build RDF as a static library" ON)
3232
## For RMV we only care about the Debug and Release configuration types
3333
set(CMAKE_CONFIGURATION_TYPES Debug Release)
3434

35-
## Determine build suffixes based on configuration, bitness and internal status
35+
## Determine build suffixes based on configuration and bitness
3636
## These values will be inherited by all child projects
3737
set(ADT_PLATFORM_POSTFIX "-x86")
3838
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
3939
set(ADT_PLATFORM_POSTFIX "-x64")
4040
ENDIF()
4141

42-
# As default for RMV, include the debug & internal status in filename - but not the platform bitness
42+
# As default for RMV, include the debug status in filename - but not the platform bitness
4343
set (CMAKE_DEBUG_POSTFIX -d)
4444
set (CMAKE_RELEASE_POSTFIX)
4545

@@ -63,11 +63,10 @@ include_directories("${PROJECT_SOURCE_DIR}/external/third_party/")
6363

6464
# Global compiler options
6565
IF(WIN32)
66-
add_compile_options(/MP)
6766
# bump the stack size
6867
add_link_options(/STACK:16777216)
6968
ELSEIF(UNIX)
70-
add_compile_options(-D_LINUX -mno-avx2)
69+
add_compile_options(-mno-avx2)
7170
# Allow executable to be double clicked.
7271
add_link_options(-no-pie)
7372
# Use _DEBUG on Unix for Debug Builds (defined automatically on Windows)
@@ -101,9 +100,6 @@ MACRO(SOURCE_GROUP_BY_FOLDER target)
101100
ENDIF (files)
102101
ENDMACRO(SOURCE_GROUP_BY_FOLDER)
103102

104-
# Define C++ standard for RMV
105-
set(CMAKE_CXX_STANDARD 17)
106-
107103
add_subdirectory(external/qt_common qt_common)
108104
add_subdirectory(external/rdf/imported/zstd)
109105
add_subdirectory(external/rdf/rdf)

build/dependency_map.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
# Define a set of dependencies that exist as separate git projects.
2222
# each git dependency has a desired directory where it will be cloned - along with a commit to checkout
2323
git_mapping = {
24-
github_tools + "QtCommon" : ["../external/qt_common", "v3.12.0"],
25-
github_tools + "UpdateCheckApi" : ["../external/update_check_api", "v2.0.1"],
26-
github_tools + "system_info_utils" : ["../external/system_info_utils", "88a338a01949f8d8bad60a30b78b65300fd13a9f"],
27-
github_root + "GPUOpen-Drivers/libamdrdf" : ["../external/rdf", "v1.1.2"],
24+
github_tools + "QtCommon" : ["../external/qt_common", "v3.12.0", True],
25+
github_tools + "UpdateCheckApi" : ["../external/update_check_api", "v2.1.0", True],
26+
github_tools + "system_info_utils" : ["../external/system_info_utils", "88a338a01949f8d8bad60a30b78b65300fd13a9f", False],
27+
github_root + "GPUOpen-Drivers/libamdrdf" : ["../external/rdf", "v1.1.2", True],
2828
}

build/fetch_dependencies.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
import platform
1818
import argparse
1919

20+
# Indices for fields in the git_mapping struct.
21+
kDestinationIndex = 0
22+
kCommitIndex = 1
23+
kShallowCloneIndex = 2
24+
2025
# Check for the python 3.x name and import it as the 2.x name
2126
try:
2227
import urllib.request as urllib
@@ -43,19 +48,23 @@ def log_print(message):
4348
def update_git_dependencies(git_mapping, update):
4449
for git_repo in git_mapping:
4550
# add script directory to path
46-
tmp_path = os.path.join(script_root, git_mapping[git_repo][0])
51+
tmp_path = os.path.join(script_root, git_mapping[git_repo][kDestinationIndex])
4752

4853
# clean up path, collapsing any ../ and converting / to \ for Windows
4954
path = os.path.normpath(tmp_path)
5055

5156
# required commit
52-
reqd_commit = git_mapping[git_repo][1]
57+
reqd_commit = git_mapping[git_repo][kCommitIndex]
58+
shallow_clone = git_mapping[git_repo][kShallowCloneIndex]
5359

5460
do_checkout = False
5561
if not os.path.isdir(path):
5662
# directory doesn't exist - clone from git
5763
log_print("Directory %s does not exist, using 'git clone' to get latest from %s" % (path, git_repo))
58-
p = subprocess.Popen((["git", "clone", git_repo ,path]), stderr=subprocess.STDOUT)
64+
if (shallow_clone):
65+
p = subprocess.Popen((["git", "clone", "--depth", "1", "--branch", reqd_commit, git_repo ,path]), stderr=subprocess.STDOUT)
66+
else:
67+
p = subprocess.Popen((["git", "clone", git_repo ,path]), stderr=subprocess.STDOUT)
5968
p.wait()
6069
if(p.returncode == 0):
6170
do_checkout = True

build/pre_build.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
parser.add_argument("--qt-root", default="~/Qt", help="specify the root directory for locating QT on this system (default: ~/Qt) ")
6363
else:
6464
parser.add_argument("--qt-root", default="~/Qt", help="specify the root directory for locating QT on this system (default: ~/Qt) ")
65-
parser.add_argument("--disable-extra-qt-lib-deploy", action="store_true", help="prevent extra Qt library files (XCB and ICU libs) from being copied during post build step")
6665
parser.add_argument("--qt-system", action="store_true", help="use the system-installed version of QT")
6766
parser.add_argument("--qt", default="5.15.2", help="specify the version of QT to be used with the script (default: 5.15.2)" )
6867
parser.add_argument("--clean", action="store_true", help="delete any directories created by this script")
@@ -261,8 +260,6 @@ def generate_config(config):
261260
cmake_args.extend(["-Tv141"])
262261

263262
if sys.platform.startswith('linux'):
264-
if args.disable_extra_qt_lib_deploy:
265-
cmake_args.extend(["-DDISABLE_EXTRA_QT_LIB_DEPLOY:BOOL=TRUE"])
266263
if args.qt_system:
267264
cmake_args.extend(["-DQT_SYSTEM:BOOL=TRUE"])
268265

cmake/dev_tools.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ function(devtools_target_options name)
3030
-Wall
3131
-Werror
3232
-Wextra
33-
-Wno-deprecated-declarations
34-
-Wno-unused-variable
35-
-Wno-missing-field-initializers
36-
-Wno-unknown-pragmas
3733
)
3834
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
3935
target_compile_options(${name}

source/backend/CMakeLists.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,9 @@ include_directories(AFTER ../backend ../parser ../../external/rdf/rdf/inc)
66

77
add_definitions(-DSYSTEM_INFO_ENABLE_RDF)
88
add_definitions(-DRDF_CXX_BINDINGS)
9-
IF(WIN32)
10-
# Warnings as errors for Windows
11-
add_compile_options(/W4 /WX)
12-
ELSEIF(UNIX)
13-
# Remove warnings for Linux in backend
14-
add_compile_options(-D_LINUX -Wall -Wextra -Werror)
15-
ENDIF(WIN32)
169

1710
# List of all source files. It may be possible to have the build process call cmake to update the makefiles
1811
# only when this file has changed (ie source files have been added or removed)
19-
2012
set( SOURCES
2113
"rmt_adapter_info.cpp"
2214
"rmt_adapter_info.h"
@@ -37,6 +29,8 @@ set( SOURCES
3729
"rmt_linear_buffer.h"
3830
"rmt_legacy_snapshot_writer.cpp"
3931
"rmt_legacy_snapshot_writer.h"
32+
"rmt_memory_aliasing_timeline.cpp"
33+
"rmt_memory_aliasing_timeline.h"
4034
"rmt_memory_event_history.cpp"
4135
"rmt_memory_event_history.h"
4236
"rmt_memory_event_history_impl.cpp"
@@ -101,3 +95,4 @@ foreach(source IN LISTS SOURCES)
10195
endforeach()
10296
ENDIF(WIN32)
10397

98+
devtools_target_options(${PROJECT_NAME})

source/backend/rmt_data_set.cpp

Lines changed: 88 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "rmt_adapter_info.h"
1111
#include "rmt_address_helper.h"
12+
#include "rmt_memory_aliasing_timeline.h"
1213
#include "rmt_assert.h"
1314
#include "rmt_constants.h"
1415
#include "rmt_data_snapshot.h"
@@ -166,6 +167,8 @@ RmtErrorCode DestroySnapshotWriter(RmtDataSet* data_set)
166167
return kRmtOk;
167168
}
168169

170+
using namespace RmtMemoryAliasingTimelineAlgorithm;
171+
169172
// Map used to lookup unique resource ID hash using the original resource ID as the key.
170173
static std::unordered_map<RmtResourceIdentifier, RmtResourceIdentifier> unique_resource_id_lookup_map;
171174

@@ -653,7 +656,7 @@ static void PerformFree(RmtDataSet* data_set, void* pointer)
653656
}
654657

655658
// Allocate memory for a snapshot.
656-
static RmtErrorCode AllocateMemoryForSnapshot(RmtDataSet* data_set, RmtDataSnapshot* out_snapshot)
659+
static RmtErrorCode AllocateMemoryForSnapshot(RmtDataSet* data_set, RmtDataSnapshot* out_snapshot, bool enable_aliased_resource_usage_sizes)
657660
{
658661
// Set a pointer to parent data set.
659662
out_snapshot->data_set = data_set;
@@ -687,7 +690,8 @@ static RmtErrorCode AllocateMemoryForSnapshot(RmtDataSet* data_set, RmtDataSnaps
687690
out_snapshot->resource_list_buffer,
688691
resource_list_buffer_size,
689692
&out_snapshot->virtual_allocation_list,
690-
data_set->data_profile.max_concurrent_resources);
693+
data_set->data_profile.max_concurrent_resources,
694+
enable_aliased_resource_usage_sizes);
691695
RMT_ASSERT(error_code == kRmtOk);
692696
RMT_RETURN_ON_ERROR(error_code == kRmtOk, error_code);
693697
}
@@ -710,7 +714,25 @@ static RmtErrorCode ProcessTokenForSnapshot(RmtDataSet* data_set, RmtToken* curr
710714
{
711715
case kRmtTokenTypeVirtualFree:
712716
{
713-
717+
const RmtVirtualAllocation* virtual_allocation = nullptr;
718+
RmtErrorCode result = RmtVirtualAllocationListGetAllocationForAddress(
719+
&(out_snapshot->virtual_allocation_list), current_token->virtual_free_token.virtual_address, &virtual_allocation);
720+
// Remove the virtual allocation if it is being tracked and a virtual allocation could be found.
721+
if ((result == kRmtOk) && (out_snapshot->resource_list.enable_aliased_resource_usage_sizes))
722+
{
723+
// Update memory sizes grouped by resource usage types taking into account overlapped aliased resources.
724+
RmtMemoryAliasingCalculator* memory_aliasing_calculator = RmtMemoryAliasingCalculatorInstance();
725+
RMT_ASSERT(memory_aliasing_calculator != nullptr);
726+
memory_aliasing_calculator->DestroyAllocation(virtual_allocation->allocation_identifier);
727+
SizePerResourceUsageType sizes_per_resource_usage_type;
728+
SizeType unbound_size;
729+
memory_aliasing_calculator->CalculateSizes(sizes_per_resource_usage_type, unbound_size);
730+
for (int usage_index = 0; usage_index < RmtResourceUsageType::kRmtResourceUsageTypeCount; usage_index++)
731+
{
732+
out_snapshot->resource_list.total_resource_usage_aliased_size[usage_index] = sizes_per_resource_usage_type.size_[usage_index];
733+
}
734+
out_snapshot->resource_list.total_resource_usage_aliased_size[kRmtResourceUsageTypeFree] = unbound_size;
735+
}
714736
error_code = RmtVirtualAllocationListRemoveAllocation(&out_snapshot->virtual_allocation_list, current_token->virtual_free_token.virtual_address);
715737
RMT_ASSERT(error_code == kRmtOk);
716738
//RMT_RETURN_ON_ERROR(error_code == kRmtOk, error_code);
@@ -826,6 +848,13 @@ static RmtErrorCode ProcessTokenForSnapshot(RmtDataSet* data_set, RmtToken* curr
826848
kDummyHeapPref,
827849
RmtOwnerType::kRmtOwnerTypeClientDriver,
828850
allocation_identifier);
851+
852+
if (out_snapshot->resource_list.enable_aliased_resource_usage_sizes)
853+
{
854+
RmtMemoryAliasingCalculator* memory_aliasing_calculator = RmtMemoryAliasingCalculatorInstance();
855+
RMT_ASSERT(memory_aliasing_calculator != nullptr);
856+
memory_aliasing_calculator->CreateAllocation(allocation_identifier, current_token->resource_bind_token.size_in_bytes);
857+
}
829858
}
830859
else if (error_code == kRmtErrorResourceAlreadyBound)
831860
{
@@ -925,9 +954,11 @@ static RmtErrorCode ProcessTokenForSnapshot(RmtDataSet* data_set, RmtToken* curr
925954
case kRmtTokenTypeVirtualAllocate:
926955
{
927956
// The byte offset of the token in the data stream is used to uniquely identify this allocation.
928-
// The offset is used rather than the virtual allocation address in case there are allocations/frees then another allocation with the same base address.
957+
// The offset is used rather than the virtual allocation address in case there are allocations/frees
958+
// and then another allocation is made with the same base address.
929959
uint64_t allocation_identifier = current_token->common.offset;
930-
error_code = RmtVirtualAllocationListAddAllocation(&out_snapshot->virtual_allocation_list,
960+
961+
error_code = RmtVirtualAllocationListAddAllocation(&out_snapshot->virtual_allocation_list,
931962
current_token->common.timestamp,
932963
current_token->virtual_allocate_token.virtual_address,
933964
(int32_t)(current_token->virtual_allocate_token.size_in_bytes >> 12),
@@ -936,6 +967,14 @@ static RmtErrorCode ProcessTokenForSnapshot(RmtDataSet* data_set, RmtToken* curr
936967
allocation_identifier);
937968
RMT_ASSERT(error_code == kRmtOk);
938969
RMT_RETURN_ON_ERROR(error_code == kRmtOk, error_code);
970+
971+
if (out_snapshot->resource_list.enable_aliased_resource_usage_sizes)
972+
{
973+
// Track virtual allocation for aliased resource size calculation.
974+
RmtMemoryAliasingCalculator* memory_aliasing_calculator = RmtMemoryAliasingCalculatorInstance();
975+
RMT_ASSERT(memory_aliasing_calculator != nullptr);
976+
memory_aliasing_calculator->CreateAllocation(allocation_identifier, current_token->virtual_allocate_token.size_in_bytes);
977+
}
939978
}
940979
break;
941980

@@ -1397,9 +1436,13 @@ static int32_t UpdateSeriesValuesFromCurrentSnapshot(const RmtDataSnapshot* curr
13971436

13981437
case kRmtDataTimelineTypeResourceUsageVirtualSize:
13991438
{
1439+
// For Resource Usage Virtual Size timeline type, aliased sizing should be enabled
1440+
// (disabled for all other timeline types).
1441+
RMT_ASSERT(current_snapshot->resource_list.enable_aliased_resource_usage_sizes);
1442+
14001443
for (int32_t current_resource_index = 0; current_resource_index < kRmtResourceUsageTypeCount; ++current_resource_index)
14011444
{
1402-
const uint64_t resource_size_for_usage_type = current_snapshot->resource_list.resource_usage_size[current_resource_index];
1445+
const uint64_t resource_size_for_usage_type = current_snapshot->resource_list.total_resource_usage_aliased_size[current_resource_index];
14031446

14041447
// Write this to the correct slot in the series.
14051448
if (current_resource_index == kRmtResourceUsageTypeHeap)
@@ -1488,11 +1531,15 @@ static RmtErrorCode TimelineGeneratorParseData(RmtDataSet* data_set, RmtDataTime
14881531
{
14891532
RMT_ASSERT(data_set);
14901533

1534+
// Reset the cancel flag.
1535+
data_set->flags.cancel_background_task_flag = false;
1536+
14911537
// Allocate temporary snapshot.
14921538
RmtDataSnapshot* temp_snapshot = (RmtDataSnapshot*)PerformAllocation(data_set, sizeof(RmtDataSnapshot), alignof(RmtDataSnapshot));
14931539
RMT_ASSERT(temp_snapshot);
14941540
RMT_RETURN_ON_ERROR(temp_snapshot, kRmtErrorOutOfMemory);
1495-
RmtErrorCode error_code = AllocateMemoryForSnapshot(data_set, temp_snapshot);
1541+
RmtErrorCode error_code =
1542+
AllocateMemoryForSnapshot(data_set, temp_snapshot, timeline_type == RmtDataTimelineType::kRmtDataTimelineTypeResourceUsageVirtualSize);
14961543
RMT_ASSERT(error_code == kRmtOk);
14971544
RMT_RETURN_ON_ERROR(error_code == kRmtOk, error_code);
14981545

@@ -1534,7 +1581,7 @@ static RmtErrorCode TimelineGeneratorParseData(RmtDataSet* data_set, RmtDataTime
15341581

15351582
// if the heap has something there, then add it.
15361583
int32_t last_value_index = -1;
1537-
while (!RmtStreamMergerIsEmpty(&data_set->stream_merger))
1584+
while (!RmtStreamMergerIsEmpty(&data_set->stream_merger) && !RmtDataSetIsBackgroundTaskCancelled(data_set))
15381585
{
15391586
// grab the next token from the heap.
15401587
RmtToken current_token = {};
@@ -1561,6 +1608,10 @@ static RmtErrorCode TimelineGeneratorParseData(RmtDataSet* data_set, RmtDataTime
15611608
}
15621609

15631610
// clean up temporary structures we allocated to construct the timeline.
1611+
if (timeline_type == RmtDataTimelineType::kRmtDataTimelineTypeResourceUsageVirtualSize)
1612+
{
1613+
RmtMemoryAliasingCalculatorCleanup();
1614+
}
15641615
RmtDataSnapshotDestroy(temp_snapshot);
15651616
PerformFree(data_set, temp_snapshot);
15661617
return kRmtOk;
@@ -1745,8 +1796,13 @@ static RmtErrorCode MergeResourceMemoryRegions(const RmtVirtualAllocation* virtu
17451796
{
17461797
const RmtGpuAddress allocation_base_address = virtual_allocation->base_address;
17471798
const RmtResource* current_resource = virtual_allocation->resources[current_resource_index];
1748-
bound_memory_regions.push_back(RegionOffsets{current_resource->address - allocation_base_address,
1749-
(current_resource->address - allocation_base_address) + current_resource->size_in_bytes});
1799+
1800+
// Skip over Heap type resources.
1801+
if (current_resource->resource_type != RmtResourceType::kRmtResourceTypeHeap)
1802+
{
1803+
bound_memory_regions.push_back(RegionOffsets{current_resource->address - allocation_base_address,
1804+
(current_resource->address - allocation_base_address) + current_resource->size_in_bytes});
1805+
}
17501806
}
17511807

17521808
// Sort the bound memory regions by starting offsets.
@@ -1800,7 +1856,6 @@ static RmtErrorCode SnapshotGeneratorAddUnboundResources(RmtDataSnapshot* snapsh
18001856
std::vector<RmtMemoryRegion> unbound_regions; ///< The list of unbound memory regions.
18011857
uint64_t allocation_size_in_bytes = RmtGetAllocationSizeInBytes(virtual_allocation->size_in_4kb_page,
18021858
kRmtPageSize4Kb); ///< The virtual allocation size in bytes.
1803-
18041859
if (bound_regions.size() < 1)
18051860
{
18061861
// Create an unbound region covering the entire virtual allocation.
@@ -1866,7 +1921,7 @@ static RmtErrorCode SnapshotGeneratorAddUnboundResources(RmtDataSnapshot* snapsh
18661921
return kRmtOk;
18671922
}
18681923

1869-
// Calculate the aliased size for each resource.
1924+
// Calculate the size after aliasing for each resource.
18701925
static RmtErrorCode SnapshotGeneratorCalculateAliasedResourceSizes(RmtDataSnapshot* snapshot)
18711926
{
18721927
uint64_t resource_usage_mask = (1ULL << (kRmtResourceUsageTypeCount - 1)) - 1;
@@ -2007,7 +2062,7 @@ RmtErrorCode RmtDataSetGenerateSnapshot(RmtDataSet* data_set, RmtSnapshotPoint*
20072062
// set up the snapshot.
20082063
memcpy(out_snapshot->name, snapshot_point->name, RMT_MINIMUM(strlen(snapshot_point->name), sizeof(out_snapshot->name)));
20092064
out_snapshot->timestamp = snapshot_point->timestamp;
2010-
RmtErrorCode error_code = AllocateMemoryForSnapshot(data_set, out_snapshot);
2065+
RmtErrorCode error_code = AllocateMemoryForSnapshot(data_set, out_snapshot, false);
20112066

20122067
out_snapshot->maximum_physical_memory_in_bytes = RmtDataSetGetTotalVideoMemoryInBytes(data_set);
20132068

@@ -2247,3 +2302,23 @@ uint64_t RmtDataSetGetTotalVideoMemoryInBytes(const RmtDataSet* data_set)
22472302
{
22482303
return data_set->segment_info[kRmtHeapTypeLocal].size + data_set->segment_info[kRmtHeapTypeInvisible].size;
22492304
}
2305+
2306+
void RmtDataSetCancelBackgroundTask(RmtDataSet* data_set)
2307+
{
2308+
RMT_ASSERT(data_set != nullptr);
2309+
data_set->flags.cancel_background_task_flag = true;
2310+
}
2311+
2312+
bool RmtDataSetIsBackgroundTaskCancelled(const RmtDataSet* data_set)
2313+
{
2314+
RMT_ASSERT(data_set != nullptr);
2315+
2316+
bool result = false;
2317+
2318+
if (data_set->flags.cancel_background_task_flag)
2319+
{
2320+
result = true;
2321+
}
2322+
2323+
return result;
2324+
}

0 commit comments

Comments
 (0)