This commit is contained in:
parent
17ae5dd6c9
commit
4082dc3723
|
|
@ -5,8 +5,8 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
// --------------------------- Basic Constants ---------------------------
|
// --------------------------- Basic Constants ---------------------------
|
||||||
const int INITIAL_WINDOW_WIDTH = 1200;
|
const int INITIAL_WINDOW_WIDTH = 200;
|
||||||
const int INITIAL_WINDOW_HEIGHT = 900;
|
const int INITIAL_WINDOW_HEIGHT = 150;
|
||||||
|
|
||||||
const double epsilon = 1e-10f;
|
const double epsilon = 1e-10f;
|
||||||
const double infty = 1e15f; // This value is used to represent missing values in data
|
const double infty = 1e15f; // This value is used to represent missing values in data
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
#include "cuda_runtime.h"
|
#include "cuda_runtime.h"
|
||||||
|
#include <csignal>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
@ -11,6 +12,9 @@
|
||||||
Window::Window(unsigned int w, unsigned int h) {
|
Window::Window(unsigned int w, unsigned int h) {
|
||||||
this->w = w;
|
this->w = w;
|
||||||
this->h = h;
|
this->h = h;
|
||||||
|
|
||||||
|
this->gpuPerf.open("gpuPerformance");
|
||||||
|
this->cpuPerf.open("cpuPerformance");
|
||||||
}
|
}
|
||||||
|
|
||||||
void framebuffer_size_callback(GLFWwindow* window, int w, int h) {
|
void framebuffer_size_callback(GLFWwindow* window, int w, int h) {
|
||||||
|
|
@ -87,6 +91,9 @@ void Window::free(float* data) {
|
||||||
|
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
|
||||||
|
this->gpuPerf.close();
|
||||||
|
this->cpuPerf.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -95,6 +102,7 @@ void Window::tick() {
|
||||||
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
||||||
float diff = (float) std::chrono::duration_cast<std::chrono::milliseconds>(now - this->last_frame).count();
|
float diff = (float) std::chrono::duration_cast<std::chrono::milliseconds>(now - this->last_frame).count();
|
||||||
this->last_frame = now;
|
this->last_frame = now;
|
||||||
|
this->cpuPerf << diff << "\n";
|
||||||
|
|
||||||
// input
|
// input
|
||||||
this->widget->tick(1000.0/diff);
|
this->widget->tick(1000.0/diff);
|
||||||
|
|
@ -107,7 +115,23 @@ void Window::tick() {
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
if (!this->widget->paused) this->quad->render();
|
if (!this->widget->paused){
|
||||||
|
cudaEvent_t start, stop;
|
||||||
|
cudaEventCreate(&start);
|
||||||
|
cudaEventCreate(&stop);
|
||||||
|
cudaEventRecord(start, 0);
|
||||||
|
this->quad->render();
|
||||||
|
|
||||||
|
cudaEventRecord(stop, 0);
|
||||||
|
cudaEventSynchronize(stop);
|
||||||
|
float t;
|
||||||
|
cudaEventElapsedTime(&t, start, stop);
|
||||||
|
this->gpuPerf << t << "\n";
|
||||||
|
|
||||||
|
cudaEventDestroy(start);
|
||||||
|
cudaEventDestroy(stop);
|
||||||
|
}
|
||||||
|
|
||||||
this->shader->use();
|
this->shader->use();
|
||||||
glBindVertexArray(this->quad->VAO);
|
glBindVertexArray(this->quad->VAO);
|
||||||
glBindTexture(GL_TEXTURE_2D, this->quad->tex);
|
glBindTexture(GL_TEXTURE_2D, this->quad->tex);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include "input/Widget.h"
|
#include "input/Widget.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
class Window {
|
class Window {
|
||||||
|
|
@ -26,6 +28,9 @@ private:
|
||||||
std::unique_ptr<Quad> quad;
|
std::unique_ptr<Quad> quad;
|
||||||
Widget* widget;
|
Widget* widget;
|
||||||
|
|
||||||
|
std::ofstream gpuPerf;
|
||||||
|
std::ofstream cpuPerf;
|
||||||
|
|
||||||
std::chrono::steady_clock::time_point last_frame;
|
std::chrono::steady_clock::time_point last_frame;
|
||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue