Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Output FPS only when it was recalculated #35

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions samples/001_HelloTriangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ void android_main(android_app* app) {
do {
timespec newTime = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &newTime);
fps_.tick(((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec) -
((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec));
LLOGL("FPS: %.1f\n", fps_.getFPS());
if (fps_.tick(((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec) -
((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec))) {
LLOGL("FPS: %.1f\n", fps_.getFPS());
}
prevTime = newTime;
if (ctx_) {
render();
Expand Down
7 changes: 4 additions & 3 deletions samples/001_HelloTriangle_Slang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,10 @@ void android_main(android_app* app) {
do {
timespec newTime = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &newTime);
fps_.tick(((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec) -
((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec));
LLOGL("FPS: %.1f\n", fps_.getFPS());
if (fps_.tick(((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec) -
((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec))) {
LLOGL("FPS: %.1f\n", fps_.getFPS());
}
prevTime = newTime;
if (ctx_) {
render();
Expand Down
5 changes: 3 additions & 2 deletions samples/002_RenderToCubeMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ void android_main(android_app* app) {
timespec newTime = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &newTime);
double newTimeSec = ((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec);
fps_.tick(newTimeSec - ((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec));
LLOGL("FPS: %.1f\n", fps_.getFPS());
if (fps_.tick(newTimeSec - ((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec))) {
LLOGL("FPS: %.1f\n", fps_.getFPS());
}
prevTime = newTime;
if (ctx_) {
render((float)newTimeSec);
Expand Down
5 changes: 3 additions & 2 deletions samples/003_RenderToCubeMapSinglePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,9 @@ void android_main(android_app* app) {
timespec newTime = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &newTime);
double newTimeSec = ((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec);
fps_.tick(newTimeSec - ((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec));
LLOGL("FPS: %.1f\n", fps_.getFPS());
if (fps_.tick(newTimeSec - ((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec))) {
LLOGL("FPS: %.1f\n", fps_.getFPS());
}
prevTime = newTime;
if (ctx_) {
render((float)newTimeSec);
Expand Down
7 changes: 4 additions & 3 deletions samples/004_YUV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,10 @@ void android_main(android_app* app) {
do {
timespec newTime = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &newTime);
fps_.tick(((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec) -
((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec));
LLOGL("FPS: %.1f\n", fps_.getFPS());
if (fps_.tick(((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec) -
((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec))) {
LLOGL("FPS: %.1f\n", fps_.getFPS());
}
prevTime = newTime;
if (ctx_) {
render();
Expand Down
5 changes: 3 additions & 2 deletions samples/006_RayTracingHello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,9 @@ void android_main(android_app* app) {
do {
double newTime = glfwGetTime();
double delta = newTime - prevTime;
fps_.tick(delta);
LLOGL("FPS: %.1f\n", fps_.getFPS());
if (fps_.tick(delta)) {
LLOGL("FPS: %.1f\n", fps_.getFPS());
}
prevTime = newTime;
if (ctx_) {
render();
Expand Down
5 changes: 3 additions & 2 deletions samples/007_RayTracingAO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,9 @@ void android_main(android_app* app) {
do {
double newTime = getCurrentTimestamp();
double delta = newTime - prevTime;
fps_.tick(delta);
LLOGL("FPS: %.1f\n", fps_.getFPS());
if (fps_.tick(delta)) {
LLOGL("FPS: %.1f\n", fps_.getFPS());
}
prevTime = newTime;
if (ctx_) {
render(delta, frameIndex);
Expand Down
7 changes: 4 additions & 3 deletions samples/Tiny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,10 @@ void android_main(android_app* app) {
do {
timespec newTime = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &newTime);
fps_.tick(((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec) -
((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec));
LLOGL("FPS: %.1f\n", fps_.getFPS());
if (fps_.tick(((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec) -
((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec))) {
LLOGL("FPS: %.1f\n", fps_.getFPS());
}
prevTime = newTime;
if (ctx_) {
vk.render();
Expand Down
5 changes: 3 additions & 2 deletions samples/Tiny_Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,9 @@ void android_main(android_app* app) {
timespec newTime = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &newTime);
double newTimeSec = ((double)newTime.tv_sec + 1.0e-9 * newTime.tv_nsec);
fps_.tick(newTimeSec - ((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec));
LLOGL("FPS: %.1f\n", fps_.getFPS());
if (fps_.tick(newTimeSec - ((double)prevTime.tv_sec + 1.0e-9 * prevTime.tv_nsec))) {
LLOGL("FPS: %.1f\n", fps_.getFPS());
}
prevTime = newTime;
if (ctx_) {
render(frameIndex, (float)newTimeSec);
Expand Down
5 changes: 3 additions & 2 deletions samples/Tiny_MeshLarge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2334,8 +2334,9 @@ void android_main(android_app* app) {
do {
double newTime = getCurrentTimestamp();
double delta = newTime - prevTime;
fps_.tick(delta);
LLOGL("FPS: %.1f\n", fps_.getFPS());
if (fps_.tick(delta)) {
LLOGL("FPS: %.1f\n", fps_.getFPS());
}
prevTime = newTime;
if (ctx_) {
render(delta, frameIndex);
Expand Down
Loading