Commit 4b389e4c authored by Gaurav Kukreja's avatar Gaurav Kukreja

Completed UI

Signed-off-by: 's avatarGaurav Kukreja <gmkukreja@gmail.com>
parent d7e32b4a
#include "glwidget.h" #include "glwidget.h"
#include "camera.h" #include "camera.h"
#include "kernel.h" #include "kernel.h"
#include "timer.h"
#include <QGLFunctions> #include <QGLFunctions>
#include <iostream> #include <iostream>
...@@ -14,6 +15,12 @@ static struct cudaGraphicsResource* pixelsVBO_CUDA; ...@@ -14,6 +15,12 @@ static struct cudaGraphicsResource* pixelsVBO_CUDA;
GlWidget::GlWidget(QWidget *parent) GlWidget::GlWidget(QWidget *parent)
: QGLWidget(QGLFormat(), parent), gl(context()) : QGLWidget(QGLFormat(), parent), gl(context())
{ {
lambda = 1.0;
sigma = 0.4;
tau = 0.4;
N = 160;
c1 = 1.0;
c2 = 0.00;
} }
GlWidget::~GlWidget() GlWidget::~GlWidget()
...@@ -59,7 +66,7 @@ void GlWidget::paintGL() ...@@ -59,7 +66,7 @@ void GlWidget::paintGL()
} }
// Execute kernel // Execute kernel
executeKernel(d_in, d_out, camera.width(), camera.height()); executeKernel(d_in, d_out, camera.width(), camera.height(), lambda, sigma, tau, N, c1, c2);
// Unmap buffer object // Unmap buffer object
cudaGraphicsUnmapResources(1, &pixelsVBO_CUDA, 0); cudaGraphicsUnmapResources(1, &pixelsVBO_CUDA, 0);
...@@ -67,4 +74,9 @@ void GlWidget::paintGL() ...@@ -67,4 +74,9 @@ void GlWidget::paintGL()
// Render from buffer object // Render from buffer object
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDrawPixels(camera.width(), camera.height(), GL_RGBA, GL_UNSIGNED_BYTE, 0); glDrawPixels(camera.width(), camera.height(), GL_RGBA, GL_UNSIGNED_BYTE, 0);
timer.end();
fps = 1.F / timer.get();
std::cout << "FPS = "<< fps << std::endl;
emit fps_updated(fps);
timer.start();
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <QGLWidget> #include <QGLWidget>
#include <QGLFunctions> #include <QGLFunctions>
#include "timer.h"
class GlWidget : public QGLWidget class GlWidget : public QGLWidget
{ {
...@@ -13,6 +14,14 @@ public: ...@@ -13,6 +14,14 @@ public:
~GlWidget(); ~GlWidget();
QSize sizeHint() const; QSize sizeHint() const;
float *d_in; float *d_in;
float lambda;
float sigma;
float tau;
int N;
float c1;
float c2;
Timer timer;
float fps;
protected: protected:
void initializeGL(); void initializeGL();
...@@ -20,6 +29,9 @@ protected: ...@@ -20,6 +29,9 @@ protected:
private: private:
QGLFunctions gl; QGLFunctions gl;
signals:
void fps_updated(float fps);
}; };
#endif // GLWIDGET_H #endif // GLWIDGET_H
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 2.7.1, 2014-03-28T16:17:01. --> <!-- Written by QtCreator 2.7.1, 2014-03-28T17:03:36. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>
...@@ -224,7 +224,7 @@ ...@@ -224,7 +224,7 @@
</valuelist> </valuelist>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">hello-opengl</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">hello-opengl</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/gkukreja/workspace/cuda_lab/miklos/project_integration/hello-opengl.pro</value> <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/gkukreja/workspace/cuda_lab/miklos/project_integration_gui/hello-opengl.pro</value>
<value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value> <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">hello-opengl.pro</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">hello-opengl.pro</value>
......
#include "kernel.h" #include "kernel.h"
#include "timer.h" // #include "timer.h"
#include <algorithm> #include <algorithm>
#include <stdio.h> #include <stdio.h>
...@@ -133,27 +133,19 @@ void allocate_device_memory(float *d_in, size_t w, size_t h) ...@@ -133,27 +133,19 @@ void allocate_device_memory(float *d_in, size_t w, size_t h)
} }
void executeKernel(float *d_U, void *d_out, size_t w, size_t h) void executeKernel(float *d_U, void *d_out, size_t w, size_t h, float lambda, float sigma, float tau, int N, float c1, float c2)
{ {
// float *d_U = reinterpret_cast<float *>(d_in); // float *d_U = reinterpret_cast<float *>(d_in);
uchar4 *pixel = reinterpret_cast<uchar4 *>(d_out); uchar4 *pixel = reinterpret_cast<uchar4 *>(d_out);
static Timer timer; // static Timer timer;
timer.end(); // timer.end();
printf("time: %.2fms (%.2f FPS)\n", timer.get() * 1E3F, 1.F / timer.get()); // printf("time: %.2fms (%.2f FPS)\n", timer.get() * 1E3F, 1.F / timer.get());
timer.start(); // timer.start();
dim3 dimBlock(32, 16); dim3 dimBlock(32, 16);
dim3 dimGrid = make_grid(dim3(w, h, 1), dimBlock); dim3 dimGrid = make_grid(dim3(w, h, 1), dimBlock);
// set parameters manually here
float lambda = 1.0;
float sigma = 0.4;
float tau = 0.4;
int N = 160;
float c1 = 1.0;
float c2 = 0.00;
size_t imageBytes = w*h*sizeof(float); size_t imageBytes = w*h*sizeof(float);
cudaMemcpy(d_T, d_U, imageBytes, cudaMemcpyDeviceToDevice); cudaMemcpy(d_T, d_U, imageBytes, cudaMemcpyDeviceToDevice);
cudaMemset(d_Xi, 0, imageBytes); cudaMemset(d_Xi, 0, imageBytes);
......
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
#include <stdlib.h> #include <stdlib.h>
extern "C" void allocate_device_memory(float *d_in, size_t width, size_t height); extern "C" void allocate_device_memory(float *d_in, size_t width, size_t height);
extern "C" void executeKernel(float *d_in, void *d_out, size_t width, size_t height); extern "C" void executeKernel(float *d_U, void *d_out, size_t w, size_t h, float lambda, float sigma, float tau, int N, float c1, float c2);
#endif // KERNEL_H #endif // KERNEL_H
...@@ -28,7 +28,35 @@ int MainWindow::init() ...@@ -28,7 +28,35 @@ int MainWindow::init()
QObject::connect(&camera, SIGNAL(newFrame()), ui->widget, SLOT(updateGL())); QObject::connect(&camera, SIGNAL(newFrame()), ui->widget, SLOT(updateGL()));
allocate_device_memory(ui->widget->d_in, camera.width(), camera.height()); allocate_device_memory(ui->widget->d_in, camera.width(), camera.height());
QObject::connect(ui->widget, SIGNAL(fps_updated(float)), this, SLOT(update_fps(float)));
camera.start(); camera.start();
return 0; return 0;
} }
void MainWindow::on_spinBox_valueChanged(int arg1)
{
ui->widget->N = arg1;
}
void MainWindow::on_doubleSpinBox_3_valueChanged(double arg1)
{
ui->widget->lambda = arg1;
}
void MainWindow::on_doubleSpinBox_4_valueChanged(double arg1)
{
ui->widget->c2 = arg1;
}
void MainWindow::on_doubleSpinBox_5_valueChanged(double arg1)
{
ui->widget->c1 = arg1;
}
void MainWindow::update_fps(float fps)
{
ui->plainTextEdit->appendPlainText(QString::number((double)fps));
}
...@@ -17,6 +17,19 @@ public: ...@@ -17,6 +17,19 @@ public:
int init(); int init();
public slots:
void update_fps(float fps);
private slots:
void on_spinBox_valueChanged(int arg1);
void on_doubleSpinBox_3_valueChanged(double arg1);
void on_doubleSpinBox_4_valueChanged(double arg1);
void on_doubleSpinBox_5_valueChanged(double arg1);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
}; };
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
...@@ -54,16 +54,58 @@ ...@@ -54,16 +54,58 @@
</size> </size>
</property> </property>
</widget> </widget>
<widget class="QWidget" name="layoutWidget"> <widget class="QWidget" name="">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>700</x> <x>700</x>
<y>50</y> <y>32</y>
<width>131</width> <width>151</width>
<height>481</height> <height>501</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>FPS</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>29</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
...@@ -78,9 +120,9 @@ ...@@ -78,9 +120,9 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_7">
<property name="text"> <property name="text">
<string>FPS</string> <string>Itertions</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
...@@ -88,12 +130,22 @@ ...@@ -88,12 +130,22 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLCDNumber" name="lcdNumber"/> <widget class="QSpinBox" name="spinBox">
<property name="maximum">
<number>500</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="value">
<number>160</number>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>Alpha</string> <string>c1</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
...@@ -101,12 +153,22 @@ ...@@ -101,12 +153,22 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QDoubleSpinBox" name="doubleSpinBox_3"/> <widget class="QDoubleSpinBox" name="doubleSpinBox_5">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>Beta</string> <string>c2</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
...@@ -114,12 +176,19 @@ ...@@ -114,12 +176,19 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QDoubleSpinBox" name="doubleSpinBox_2"/> <widget class="QDoubleSpinBox" name="doubleSpinBox_4">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Gama</string> <string>lambda</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
...@@ -127,12 +196,15 @@ ...@@ -127,12 +196,15 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QDoubleSpinBox" name="doubleSpinBox"/> <widget class="QDoubleSpinBox" name="doubleSpinBox_3">
</item> <property name="maximum">
<item> <double>1.000000000000000</double>
<widget class="QPushButton" name="pushButton_2"> </property>
<property name="text"> <property name="singleStep">
<string>&amp;Refresh</string> <double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -146,16 +218,6 @@ ...@@ -146,16 +218,6 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>865</width>
<height>23</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
</widget> </widget>
<customwidgets> <customwidgets>
...@@ -164,9 +226,6 @@ ...@@ -164,9 +226,6 @@
<extends>QWidget</extends> <extends>QWidget</extends>
<header>glwidget.h</header> <header>glwidget.h</header>
<container>1</container> <container>1</container>
<slots>
<signal>update_param()</signal>
</slots>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
...@@ -178,8 +237,8 @@ ...@@ -178,8 +237,8 @@
<slot>close()</slot> <slot>close()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>742</x> <x>743</x>
<y>543</y> <y>529</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>713</x> <x>713</x>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment