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 "camera.h"
#include "kernel.h"
#include "timer.h"
#include <QGLFunctions>
#include <iostream>
......@@ -14,6 +15,12 @@ static struct cudaGraphicsResource* pixelsVBO_CUDA;
GlWidget::GlWidget(QWidget *parent)
: QGLWidget(QGLFormat(), parent), gl(context())
{
lambda = 1.0;
sigma = 0.4;
tau = 0.4;
N = 160;
c1 = 1.0;
c2 = 0.00;
}
GlWidget::~GlWidget()
......@@ -59,7 +66,7 @@ void GlWidget::paintGL()
}
// 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
cudaGraphicsUnmapResources(1, &pixelsVBO_CUDA, 0);
......@@ -67,4 +74,9 @@ void GlWidget::paintGL()
// Render from buffer object
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
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 @@
#include <QGLWidget>
#include <QGLFunctions>
#include "timer.h"
class GlWidget : public QGLWidget
{
......@@ -13,6 +14,14 @@ public:
~GlWidget();
QSize sizeHint() const;
float *d_in;
float lambda;
float sigma;
float tau;
int N;
float c1;
float c2;
Timer timer;
float fps;
protected:
void initializeGL();
......@@ -20,6 +29,9 @@ protected:
private:
QGLFunctions gl;
signals:
void fps_updated(float fps);
};
#endif // GLWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
......@@ -224,7 +224,7 @@
</valuelist>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">hello-opengl</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="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">hello-opengl.pro</value>
......
#include "kernel.h"
#include "timer.h"
// #include "timer.h"
#include <algorithm>
#include <stdio.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);
uchar4 *pixel = reinterpret_cast<uchar4 *>(d_out);
static Timer timer;
timer.end();
printf("time: %.2fms (%.2f FPS)\n", timer.get() * 1E3F, 1.F / timer.get());
timer.start();
// static Timer timer;
// timer.end();
// printf("time: %.2fms (%.2f FPS)\n", timer.get() * 1E3F, 1.F / timer.get());
// timer.start();
dim3 dimBlock(32, 16);
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);
cudaMemcpy(d_T, d_U, imageBytes, cudaMemcpyDeviceToDevice);
cudaMemset(d_Xi, 0, imageBytes);
......
......@@ -4,6 +4,6 @@
#include <stdlib.h>
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
......@@ -28,7 +28,35 @@ int MainWindow::init()
QObject::connect(&camera, SIGNAL(newFrame()), ui->widget, SLOT(updateGL()));
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();
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:
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:
Ui::MainWindow *ui;
};
......
......@@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -54,16 +54,58 @@
</size>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>700</x>
<y>50</y>
<width>131</width>
<height>481</height>
<y>32</y>
<width>151</width>
<height>501</height>
</rect>
</property>
<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>
<spacer name="verticalSpacer">
<property name="orientation">
......@@ -78,9 +120,9 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="label_7">
<property name="text">
<string>FPS</string>
<string>Itertions</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
......@@ -88,12 +130,22 @@
</widget>
</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>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Alpha</string>
<string>c1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
......@@ -101,12 +153,22 @@
</widget>
</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>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Beta</string>
<string>c2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
......@@ -114,12 +176,19 @@
</widget>
</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>
<widget class="QLabel" name="label">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Gama</string>
<string>lambda</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
......@@ -127,12 +196,15 @@
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>&amp;Refresh</string>
<widget class="QDoubleSpinBox" name="doubleSpinBox_3">
<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>
......@@ -146,16 +218,6 @@
</layout>
</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>
<customwidgets>
......@@ -164,9 +226,6 @@
<extends>QWidget</extends>
<header>glwidget.h</header>
<container>1</container>
<slots>
<signal>update_param()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
......@@ -178,8 +237,8 @@
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>742</x>
<y>543</y>
<x>743</x>
<y>529</y>
</hint>
<hint type="destinationlabel">
<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