Skip to content

Commit b215020

Browse files
committed
Version 3.2
1 parent 18889ed commit b215020

File tree

4 files changed

+57
-157
lines changed

4 files changed

+57
-157
lines changed

src/d3d11/d3d11_post_processor.cpp

Lines changed: 50 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -700,102 +700,75 @@ namespace vrperfkit {
700700
}
701701

702702

703-
void D3D11PostProcessor::CreateDynamicProfileQueries() {
704-
for (auto &profileQuery : dynamicProfileQueries) {
705-
D3D11_QUERY_DESC qd;
706-
qd.Query = D3D11_QUERY_TIMESTAMP;
707-
qd.MiscFlags = 0;
708-
device->CreateQuery(&qd, profileQuery.queryStart.ReleaseAndGetAddressOf());
709-
device->CreateQuery(&qd, profileQuery.queryEnd.ReleaseAndGetAddressOf());
710-
qd.Query = D3D11_QUERY_TIMESTAMP_DISJOINT;
711-
device->CreateQuery(&qd, profileQuery.queryDisjoint.ReleaseAndGetAddressOf());
712-
}
713-
}
714-
715703
void D3D11PostProcessor::StartDynamicProfiling() {
716-
++DynamicSleepCount;
717-
if (DynamicSleepCount < g_config.dynamicFramesCheck) {
704+
++dynamicSleepCount;
705+
if (dynamicSleepCount < g_config.dynamicFramesCheck) {
718706
return;
719707
}
720708

721709
is_DynamicProfiling = true;
722710

723-
DynamicSleepCount = 0;
711+
dynamicSleepCount = 0;
724712

725-
if (dynamicProfileQueries[0].queryStart == nullptr) {
726-
CreateDynamicProfileQueries();
727-
}
728-
729-
context->Begin(dynamicProfileQueries[DynamicCurrentQuery].queryDisjoint.Get());
730-
context->End(dynamicProfileQueries[DynamicCurrentQuery].queryStart.Get());
713+
GetSystemTimePreciseAsFileTime(&ft);
714+
dynamicTimeUs = ft.dwLowDateTime;
731715
}
732716

733717
void D3D11PostProcessor::EndDynamicProfiling() {
734718
if (is_DynamicProfiling) {
735-
context->End(dynamicProfileQueries[DynamicCurrentQuery].queryEnd.Get());
736-
context->End(dynamicProfileQueries[DynamicCurrentQuery].queryDisjoint.Get());
719+
GetSystemTimePreciseAsFileTime(&ft);
720+
const unsigned int end = ft.dwLowDateTime;
721+
722+
float frameTime = (end - dynamicTimeUs) / 10000000.f; // (1000 * 1000 * 10) FrameTime in seconds
737723

738-
DynamicCurrentQuery = (DynamicCurrentQuery + 1) % DYNAMIC_QUERY_COUNT;
739-
while (context->GetData(dynamicProfileQueries[0].queryDisjoint.Get(), nullptr, 0, 0) == S_FALSE) {
740-
Sleep(1);
741-
}
742-
D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjoint;
743-
HRESULT result = context->GetData(dynamicProfileQueries[DynamicCurrentQuery].queryDisjoint.Get(), &disjoint, sizeof(disjoint), 0);
744-
if (result == S_OK && !disjoint.Disjoint) {
745-
UINT64 begin, end;
746-
context->GetData(dynamicProfileQueries[DynamicCurrentQuery].queryStart.Get(), &begin, sizeof(UINT64), 0);
747-
context->GetData(dynamicProfileQueries[DynamicCurrentQuery].queryEnd.Get(), &end, sizeof(UINT64), 0);
748-
float frameTime = (end - begin) / float(disjoint.Frequency); // FrameTime in seconds
749-
750-
//LOG_INFO << "frameTime: " << std::setprecision(8) << frameTime;
751-
752-
// HRM
753-
if (g_config.hiddenMask.dynamic) {
754-
if (frameTime > g_config.hiddenMask.targetFrameTime) {
755-
if (g_config.hiddenMask.dynamicChangeRadius) {
756-
if ((edgeRadius - g_config.hiddenMask.decreaseRadiusStep) >= g_config.hiddenMask.minRadius) {
757-
edgeRadius -= g_config.hiddenMask.decreaseRadiusStep;
758-
}
759-
} else {
760-
hiddenMaskApply = true;
724+
//LOG_INFO << "frameTime: " << std::setprecision(8) << frameTime;
725+
726+
// HRM
727+
if (g_config.hiddenMask.dynamic) {
728+
if (frameTime > g_config.hiddenMask.targetFrameTime) {
729+
if (g_config.hiddenMask.dynamicChangeRadius) {
730+
if ((edgeRadius - g_config.hiddenMask.decreaseRadiusStep) >= g_config.hiddenMask.minRadius) {
731+
edgeRadius -= g_config.hiddenMask.decreaseRadiusStep;
761732
}
762-
} else if (frameTime < g_config.hiddenMask.marginFrameTime) {
763-
if (g_config.hiddenMask.dynamicChangeRadius) {
764-
if ((edgeRadius + g_config.hiddenMask.increaseRadiusStep) <= g_config.hiddenMask.maxRadius) {
765-
edgeRadius += g_config.hiddenMask.increaseRadiusStep;
766-
}
767-
} else {
768-
hiddenMaskApply = false;
733+
} else {
734+
hiddenMaskApply = true;
735+
}
736+
} else if (frameTime < g_config.hiddenMask.marginFrameTime) {
737+
if (g_config.hiddenMask.dynamicChangeRadius) {
738+
if ((edgeRadius + g_config.hiddenMask.increaseRadiusStep) <= g_config.hiddenMask.maxRadius) {
739+
edgeRadius += g_config.hiddenMask.increaseRadiusStep;
769740
}
741+
} else {
742+
hiddenMaskApply = false;
770743
}
771744
}
745+
}
772746

773-
// FFR
774-
if (g_config.ffr.dynamic) {
775-
if (frameTime > g_config.ffr.targetFrameTime) {
776-
if (g_config.ffr.dynamicChangeRadius) {
777-
if ((g_config.ffr.innerRadius - g_config.ffr.decreaseRadiusStep) >= g_config.ffr.minRadius) {
778-
g_config.ffr.innerRadius -= g_config.ffr.decreaseRadiusStep;
779-
g_config.ffr.midRadius -= g_config.ffr.decreaseRadiusStep;
780-
g_config.ffr.outerRadius -= g_config.ffr.decreaseRadiusStep;
781-
g_config.ffr.radiusChanged[0] = true;
782-
g_config.ffr.radiusChanged[1] = true;
783-
}
784-
} else {
785-
g_config.ffr.apply = true;
747+
// FFR
748+
if (g_config.ffr.dynamic) {
749+
if (frameTime > g_config.ffr.targetFrameTime) {
750+
if (g_config.ffr.dynamicChangeRadius) {
751+
if ((g_config.ffr.innerRadius - g_config.ffr.decreaseRadiusStep) >= g_config.ffr.minRadius) {
752+
g_config.ffr.innerRadius -= g_config.ffr.decreaseRadiusStep;
753+
g_config.ffr.midRadius -= g_config.ffr.decreaseRadiusStep;
754+
g_config.ffr.outerRadius -= g_config.ffr.decreaseRadiusStep;
755+
g_config.ffr.radiusChanged[0] = true;
756+
g_config.ffr.radiusChanged[1] = true;
786757
}
787-
} else if (frameTime < g_config.ffr.marginFrameTime) {
788-
if (g_config.ffr.dynamicChangeRadius) {
789-
if ((g_config.ffr.innerRadius + g_config.ffr.increaseRadiusStep) <= g_config.ffr.maxRadius) {
790-
g_config.ffr.innerRadius += g_config.ffr.increaseRadiusStep;
791-
g_config.ffr.midRadius += g_config.ffr.increaseRadiusStep;
792-
g_config.ffr.outerRadius += g_config.ffr.increaseRadiusStep;
793-
g_config.ffr.radiusChanged[0] = true;
794-
g_config.ffr.radiusChanged[1] = true;
795-
}
796-
} else {
797-
g_config.ffr.apply = false;
758+
} else {
759+
g_config.ffr.apply = true;
760+
}
761+
} else if (frameTime < g_config.ffr.marginFrameTime) {
762+
if (g_config.ffr.dynamicChangeRadius) {
763+
if ((g_config.ffr.innerRadius + g_config.ffr.increaseRadiusStep) <= g_config.ffr.maxRadius) {
764+
g_config.ffr.innerRadius += g_config.ffr.increaseRadiusStep;
765+
g_config.ffr.midRadius += g_config.ffr.increaseRadiusStep;
766+
g_config.ffr.outerRadius += g_config.ffr.increaseRadiusStep;
767+
g_config.ffr.radiusChanged[0] = true;
768+
g_config.ffr.radiusChanged[1] = true;
798769
}
770+
} else {
771+
g_config.ffr.apply = false;
799772
}
800773
}
801774
}
@@ -805,57 +778,4 @@ namespace vrperfkit {
805778

806779
StartDynamicProfiling();
807780
}
808-
809-
810-
/*
811-
void D3D11PostProcessor::CreateProfileQueries() {
812-
for (auto &profileQuery : profileQueries) {
813-
D3D11_QUERY_DESC qd;
814-
qd.Query = D3D11_QUERY_TIMESTAMP;
815-
qd.MiscFlags = 0;
816-
device->CreateQuery(&qd, profileQuery.queryStart.ReleaseAndGetAddressOf());
817-
device->CreateQuery(&qd, profileQuery.queryEnd.ReleaseAndGetAddressOf());
818-
qd.Query = D3D11_QUERY_TIMESTAMP_DISJOINT;
819-
device->CreateQuery(&qd, profileQuery.queryDisjoint.ReleaseAndGetAddressOf());
820-
}
821-
}
822-
823-
void D3D11PostProcessor::StartProfiling() {
824-
if (profileQueries[0].queryStart == nullptr) {
825-
CreateProfileQueries();
826-
}
827-
828-
context->Begin(profileQueries[currentQuery].queryDisjoint.Get());
829-
context->End(profileQueries[currentQuery].queryStart.Get());
830-
}
831-
832-
void D3D11PostProcessor::EndProfiling() {
833-
context->End(profileQueries[currentQuery].queryEnd.Get());
834-
context->End(profileQueries[currentQuery].queryDisjoint.Get());
835-
836-
currentQuery = (currentQuery + 1) % QUERY_COUNT;
837-
while (context->GetData(profileQueries[currentQuery].queryDisjoint.Get(), nullptr, 0, 0) == S_FALSE) {
838-
Sleep(1);
839-
}
840-
D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjoint;
841-
HRESULT result = context->GetData(profileQueries[currentQuery].queryDisjoint.Get(), &disjoint, sizeof(disjoint), 0);
842-
if (result == S_OK && !disjoint.Disjoint) {
843-
UINT64 begin, end;
844-
context->GetData(profileQueries[currentQuery].queryStart.Get(), &begin, sizeof(UINT64), 0);
845-
context->GetData(profileQueries[currentQuery].queryEnd.Get(), &end, sizeof(UINT64), 0);
846-
float duration = (end - begin) / float(disjoint.Frequency);
847-
summedGpuTime += duration;
848-
++countedQueries;
849-
850-
if (countedQueries >= 500) {
851-
float avgTimeMs = 1000.f / countedQueries * summedGpuTime;
852-
// Queries are done per eye, but we want the average for both eyes per frame
853-
avgTimeMs *= 2;
854-
LOG_INFO << "Average GPU processing time for post-processing: " << avgTimeMs << " ms";
855-
countedQueries = 0;
856-
summedGpuTime = 0.f;
857-
}
858-
}
859-
}
860-
*/
861781
}

src/d3d11/d3d11_post_processor.h

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ namespace vrperfkit {
5757
ComPtr<ID3D11Query> queryStart;
5858
ComPtr<ID3D11Query> queryEnd;
5959
};
60-
static const int DYNAMIC_QUERY_COUNT = 1;
61-
int DynamicSleepCount = 0;
62-
DynamicProfileQuery dynamicProfileQueries[DYNAMIC_QUERY_COUNT];
63-
int DynamicCurrentQuery = 0;
64-
float DynamicSummedGpuTime = 0.0f;
65-
int DynamicCountedQueries = 0;
60+
FILETIME ft;
61+
unsigned int dynamicTimeUs = 0;
62+
int dynamicSleepCount = 0;
6663
bool is_DynamicProfiling = false;
6764
bool enableDynamic = false;
6865
bool hiddenMaskApply = false;
@@ -113,22 +110,5 @@ namespace vrperfkit {
113110
void D3D11PostProcessor::PrepareRdmResources(DXGI_FORMAT format);
114111
void D3D11PostProcessor::ApplyRadialDensityMask(ID3D11Texture2D *depthStencilTex, float depth, uint8_t stencil);
115112
void D3D11PostProcessor::ReconstructRdmRender(const D3D11PostProcessInput &input);
116-
117-
/*
118-
struct ProfileQuery {
119-
ComPtr<ID3D11Query> queryDisjoint;
120-
ComPtr<ID3D11Query> queryStart;
121-
ComPtr<ID3D11Query> queryEnd;
122-
};
123-
static const int QUERY_COUNT = 6;
124-
ProfileQuery profileQueries[QUERY_COUNT];
125-
int currentQuery = 0;
126-
float summedGpuTime = 0.0f;
127-
int countedQueries = 0;
128-
129-
void CreateProfileQueries();
130-
void StartProfiling();
131-
void EndProfiling();
132-
*/
133113
};
134114
}

src/dllmain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace {
8888

8989
vrperfkit::OpenLogFile(vrperfkit::g_basePath / "vrperfkit_RSF.log");
9090
LOG_INFO << "===============================";
91-
LOG_INFO << "VR Performance Toolkit RSF v3.1";
91+
LOG_INFO << "VR Performance Toolkit RSF v3.2";
9292
LOG_INFO << "===============================\n";
9393

9494
vrperfkit::LoadConfig(vrperfkit::g_basePath / "vrperfkit_RSF.yml");

vrperfkit_RSF.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# =============================== #
2-
# VR Performance Toolkit RSF v3.1 #
2+
# VR Performance Toolkit RSF v3.2 #
33
# =============================== #
44

55
# dxgi.dll: If game uses its own dxgi.dll or other post-processor library, like
@@ -76,7 +76,7 @@ fixedFoveated:
7676
# FPS to start recovering decrasing radius.
7777
marginFPS: 65.0
7878
# Change default dynamic behavior: FFR is always enabled but dynamic mode changes radius dinamically
79-
dynamicChangeRadius: false
79+
dynamicChangeRadius: true
8080
# Minimal radius: This is the minimal radius applied to innerRadius when dynamic is enabled
8181
minRadius: 0.30
8282
# Decreased radius amount applied for each frametime check when needed
@@ -141,7 +141,7 @@ hiddenMask:
141141
# FPS to start recovering decrasing radius.
142142
marginFPS: 60.0
143143
# Change default dynamic behavior: HRM is always enabled but dynamic mode changes radius dinamically
144-
dynamicChangeRadius: false
144+
dynamicChangeRadius: true
145145
# Minimal radius: This is the minimal radius applied when dynamic is enabled
146146
minRadius: 0.85
147147
# Decreased radius amount applied for each frametime check when needed

0 commit comments

Comments
 (0)