aboutsummaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-11-08 23:02:47 +0100
committerAdrian Kummerlaender2019-11-08 23:02:47 +0100
commitd864699c5ddd744ee7376c0d752b6bbb771429a2 (patch)
tree9dd8973b17a0617ce595c2b92ec1d0faa8388083 /src/main.cc
parent35e2c7a949dedf3221887ffdc14dddb4c5e84f4c (diff)
downloadcompustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar.gz
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar.bz2
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar.lz
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar.xz
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.tar.zst
compustream-d864699c5ddd744ee7376c0d752b6bbb771429a2.zip
Update lattice multiple times per frame
Controlled by `--lupf` _Lattice updates per frame_ MLUPS are now calculated and displayed. While performance is still bad compared to a optimized GPU implementation (such as [1] or [2]) this improves the situation. [1]: https://tree.kummerlaender.eu/projects/symlbm_playground/ [2]: https://code.kummerlaender.eu/boltzgen/about/
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/main.cc b/src/main.cc
index 8e9fa9a..7d2ebe8 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -24,7 +24,7 @@
#include "timer.h"
-GLuint maxLUPS = 100;
+GLuint maxLUPF = 100;
GLuint nX = 512;
GLuint nY = 256;
@@ -184,25 +184,19 @@ int render() {
MVP = getMVP(world_width, world_height);
}
- if ( update_lattice && timer::millisecondsSince(last_lattice_update) >= 1000/maxLUPS ) {
+ if ( update_lattice ) {
if ( timer::secondsSince(last_lups_update) >= 1.0 ) {
- std::cout << "\rComputing about " << statLUPS << " lattice updates per second." << std::flush;
+ std::cout << "\r~ " << nX*nY * statLUPS / timer::secondsSince(last_lups_update) * 1e-6 << " MLUPS" << std::flush;
statLUPS = 0;
last_lups_update = timer::now();
}
- statLUPS += 1;
-
if ( tick ) {
interact_shader->workOn(tick_buffers);
- collide_shader->workOn(tick_buffers);
extra_shader->workOn(tick_buffers);
- tick = false;
} else {
interact_shader->workOn(tock_buffers);
- collide_shader->workOn(tock_buffers);
extra_shader->workOn(tock_buffers);
- tick = true;
}
/// Perform collide & stream steps
@@ -213,7 +207,19 @@ int render() {
collide_shader->setUniform("iT", iT);
iT += 1;
- collide_shader->dispatch(nX, nY);
+ for (auto i=0; i < maxLUPF; ++i) {
+ if ( tick ) {
+ collide_shader->workOn(tick_buffers);
+ tick = false;
+ } else {
+ collide_shader->workOn(tock_buffers);
+ tick = true;
+ }
+
+ collide_shader->dispatch(nX, nY);
+ }
+
+ statLUPS += maxLUPF;
}
if ( display_mode == DisplayMode::CURL ) {
@@ -289,18 +295,18 @@ bool parseArguments(int argc, char* argv[]) {
for ( int i = 1; i < argc; ++i ) {
const auto& arg = std::string_view(argv[i]);
- if ( arg == "--lups" ) {
+ if ( arg == "--lupf" ) {
if ( i+1 < argc ) {
try {
i += 1;
- maxLUPS = std::stoi(argv[i]);
+ maxLUPF = std::stoi(argv[i]);
}
catch ( std::invalid_argument& ex ) {
- std::cerr << "Maximum lattice updates per second malformed." << std::endl;
+ std::cerr << "Maximum lattice updates per frame malformed." << std::endl;
return false;
}
} else {
- std::cerr << "Maximum lattice updates per second undefined." << std::endl;
+ std::cerr << "Maximum lattice updates per frame undefined." << std::endl;
return false;
}
}