Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
Unterteilungsalgorithmen
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
Unterteilungsalgorithmen
Commits
03f03769
Commit
03f03769
authored
Sep 01, 2016
by
Kai Westerkamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time trace
parent
fc9a48c7
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
10 deletions
+35
-10
logcategories.cpp
QTProject/logcategories.cpp
+1
-0
logcategories.h
QTProject/logcategories.h
+1
-0
main.cpp
QTProject/main.cpp
+2
-1
mainwidget.cpp
QTProject/mainwidget.cpp
+3
-1
mainwindow.cpp
QTProject/mainwindow.cpp
+1
-1
subdivision.cpp
QTProject/subdivision.cpp
+27
-7
No files found.
QTProject/logcategories.cpp
View file @
03f03769
...
@@ -4,3 +4,4 @@ Q_LOGGING_CATEGORY(log_subdiv, "subdiv")
...
@@ -4,3 +4,4 @@ Q_LOGGING_CATEGORY(log_subdiv, "subdiv")
Q_LOGGING_CATEGORY
(
log_subdiv_trace
,
"subdiv.trace"
)
Q_LOGGING_CATEGORY
(
log_subdiv_trace
,
"subdiv.trace"
)
Q_LOGGING_CATEGORY
(
log_mesh
,
"mesh"
)
Q_LOGGING_CATEGORY
(
log_mesh
,
"mesh"
)
Q_LOGGING_CATEGORY
(
log_mesh_render
,
"mesh.render"
)
Q_LOGGING_CATEGORY
(
log_mesh_render
,
"mesh.render"
)
Q_LOGGING_CATEGORY
(
log_timing
,
"timing"
)
QTProject/logcategories.h
View file @
03f03769
...
@@ -8,5 +8,6 @@ Q_DECLARE_LOGGING_CATEGORY(log_subdiv)
...
@@ -8,5 +8,6 @@ Q_DECLARE_LOGGING_CATEGORY(log_subdiv)
Q_DECLARE_LOGGING_CATEGORY
(
log_subdiv_trace
)
Q_DECLARE_LOGGING_CATEGORY
(
log_subdiv_trace
)
Q_DECLARE_LOGGING_CATEGORY
(
log_mesh
)
Q_DECLARE_LOGGING_CATEGORY
(
log_mesh
)
Q_DECLARE_LOGGING_CATEGORY
(
log_mesh_render
)
Q_DECLARE_LOGGING_CATEGORY
(
log_mesh_render
)
Q_DECLARE_LOGGING_CATEGORY
(
log_timing
)
#endif
#endif
QTProject/main.cpp
View file @
03f03769
...
@@ -5,7 +5,8 @@
...
@@ -5,7 +5,8 @@
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
QApplication
a
(
argc
,
argv
);
QApplication
a
(
argc
,
argv
);
QLoggingCategory
::
setFilterRules
(
"mesh.debug=false
\n
"
QLoggingCategory
::
setFilterRules
(
"timing.debug=true
\n
"
"mesh.debug=false
\n
"
"mesh.render.debug=false
\n
"
"mesh.render.debug=false
\n
"
"subdiv.debug=true
\n
"
"subdiv.debug=true
\n
"
"subdiv.trace.debug=false
\n
"
);
"subdiv.trace.debug=false
\n
"
);
...
...
QTProject/mainwidget.cpp
View file @
03f03769
...
@@ -139,16 +139,18 @@ void MainWidget::loadNewMesh(){
...
@@ -139,16 +139,18 @@ void MainWidget::loadNewMesh(){
tr
(
"*.md5mesh *.3ds *.md2 *.obj *.dae *.dxf *.mesh.xml *.blend *.b3d"
));
tr
(
"*.md5mesh *.3ds *.md2 *.obj *.dae *.dxf *.mesh.xml *.blend *.b3d"
));
loadNewMesh
(
fn
);
loadNewMesh
(
fn
);
}
}
void
MainWidget
::
loadNewMesh
(
QString
path
){
void
MainWidget
::
loadNewMesh
(
QString
path
){
QDir
dir
(
"."
);
QDir
dir
(
"."
);
qDebug
()
<<
dir
.
absolutePath
();
//
qDebug()<<dir.absolutePath();
if
(
path
.
isEmpty
())
if
(
path
.
isEmpty
())
return
;
return
;
qDebug
()
<<
"Opening File:"
<<
path
;
qDebug
()
<<
"Opening File:"
<<
path
;
mesh
=
new
Mesh
(
this
,
path
);
mesh
=
new
Mesh
(
this
,
path
);
qDebug
()
<<
"Mesh loading finished"
;
subdivision
->
splitRegular
(
mesh
);
subdivision
->
splitRegular
(
mesh
);
}
}
...
...
QTProject/mainwindow.cpp
View file @
03f03769
...
@@ -42,7 +42,7 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -42,7 +42,7 @@ MainWindow::MainWindow(QWidget *parent) :
subdivSlider
=
new
QSlider
(
Qt
::
Horizontal
);
subdivSlider
=
new
QSlider
(
Qt
::
Horizontal
);
subdivSlider
->
setMinimum
(
0
);
subdivSlider
->
setMinimum
(
0
);
subdivSlider
->
setMaximum
(
5
);
subdivSlider
->
setMaximum
(
6
);
subdivSlider
->
setSliderPosition
(
0
);
subdivSlider
->
setSliderPosition
(
0
);
subdivSlider
->
setSingleStep
(
1
);
subdivSlider
->
setSingleStep
(
1
);
...
...
QTProject/subdivision.cpp
View file @
03f03769
...
@@ -57,7 +57,7 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
...
@@ -57,7 +57,7 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
Input
input
;
Input
input
;
int
currentMax
=
current_mesh
->
buffers
.
size
()
-
1
;
int
currentMax
=
current_mesh
->
buffers
.
size
()
-
1
;
qCDebug
(
log_subdiv
)
<<
"Subdiv Level"
<<
level
<<
"Requested. Current Max:"
<<
currentMax
;
//
qCDebug(log_subdiv) << "Subdiv Level" << level << "Requested. Current Max:" << currentMax;
if
(
level
<=
currentMax
)
if
(
level
<=
currentMax
)
return
;
return
;
...
@@ -351,13 +351,16 @@ void Subdivision::precomputeVertexTable(Subdivision::Tables &tables, QVector<Ver
...
@@ -351,13 +351,16 @@ void Subdivision::precomputeVertexTable(Subdivision::Tables &tables, QVector<Ver
tables
.
vertex_offsets
.
push_back
(
offset
);
tables
.
vertex_offsets
.
push_back
(
offset
);
qCDebug
(
log_subdiv
)
<<
"Done with vertex index table. "
;
qCDebug
(
log_subdiv
)
<<
"Done with vertex index table. "
;
qCDebug
(
log_subdiv
)
<<
"Duplicates: "
;
qCDebug
(
log_subdiv
)
<<
"Duplicates: "
<<
duplicates
.
length
()
;
for
(
int
i
=
0
;
i
<
duplicates
.
length
();
i
++
){
for
(
int
i
=
0
;
i
<
duplicates
.
length
();
i
++
){
qCDebug
(
log_subdiv
)
<<
duplicates
[
i
];
qCDebug
(
log_subdiv
_trace
)
<<
duplicates
[
i
];
}
}
}
}
void
Subdivision
::
splitRegular
(
Mesh
*
mesh
)
{
void
Subdivision
::
splitRegular
(
Mesh
*
mesh
)
{
QTime
totalTimer
;
totalTimer
.
start
();
qCDebug
(
log_timing
)
<<
"splitRegular(mesh) started"
;
Mesh
::
Node
root
=
mesh
->
getRootNode
();
Mesh
::
Node
root
=
mesh
->
getRootNode
();
int
first_mesh_index
=
-
1
;
int
first_mesh_index
=
-
1
;
...
@@ -370,6 +373,7 @@ void Subdivision::splitRegular(Mesh *mesh) {
...
@@ -370,6 +373,7 @@ void Subdivision::splitRegular(Mesh *mesh) {
QVector
<
unsigned
int
>
regular
;
QVector
<
unsigned
int
>
regular
;
QVector
<
unsigned
int
>
irregular
;
QVector
<
unsigned
int
>
irregular
;
findRegular
(
current_mesh
->
buffers
[
0
]
->
indices_irregular
,
current_mesh
->
buffers
[
0
]
->
vertices
,
regular
,
irregular
);
findRegular
(
current_mesh
->
buffers
[
0
]
->
indices_irregular
,
current_mesh
->
buffers
[
0
]
->
vertices
,
regular
,
irregular
);
findRegular
(
current_mesh
->
buffers
[
0
]
->
indices_regular
,
current_mesh
->
buffers
[
0
]
->
vertices
,
regular
,
irregular
);
findRegular
(
current_mesh
->
buffers
[
0
]
->
indices_regular
,
current_mesh
->
buffers
[
0
]
->
vertices
,
regular
,
irregular
);
...
@@ -378,6 +382,8 @@ void Subdivision::splitRegular(Mesh *mesh) {
...
@@ -378,6 +382,8 @@ void Subdivision::splitRegular(Mesh *mesh) {
current_mesh
->
buffers
[
0
]
->
indices_irregular
=
irregular
;
current_mesh
->
buffers
[
0
]
->
indices_irregular
=
irregular
;
current_mesh
->
buffers
[
0
]
->
updateIndices
();
current_mesh
->
buffers
[
0
]
->
updateIndices
();
qCDebug
(
log_timing
)
<<
"splitRegular(mesh): time: "
<<
totalTimer
.
elapsed
()
<<
"ms"
;
qCDebug
(
log_subdiv
)
<<
"splitRegular(mesh): regular: "
<<
regular
.
length
();
qCDebug
(
log_subdiv
)
<<
"splitRegular(mesh): regular: "
<<
regular
.
length
();
qCDebug
(
log_subdiv
)
<<
"splitRegular(mesh): irregular: "
<<
irregular
.
length
();
qCDebug
(
log_subdiv
)
<<
"splitRegular(mesh): irregular: "
<<
irregular
.
length
();
}
}
...
@@ -404,6 +410,9 @@ void Subdivision::splitRegular(Mesh *mesh) {
...
@@ -404,6 +410,9 @@ void Subdivision::splitRegular(Mesh *mesh) {
* @return patch index buffer with 4 times as many indices. ! if something goes wrong, the current buffer is returned and might be incomplete or empty.
* @return patch index buffer with 4 times as many indices. ! if something goes wrong, the current buffer is returned and might be incomplete or empty.
*/
*/
QVector
<
unsigned
int
>
Subdivision
::
getPatchIndexBuffer
(
QVector
<
unsigned
int
>
ib_regular
,
QVector
<
unsigned
int
>
ib_irregular
,
QVector
<
Vertex
>
vb
){
QVector
<
unsigned
int
>
Subdivision
::
getPatchIndexBuffer
(
QVector
<
unsigned
int
>
ib_regular
,
QVector
<
unsigned
int
>
ib_irregular
,
QVector
<
Vertex
>
vb
){
QTime
totalTimer
;
totalTimer
.
start
();
qCDebug
(
log_timing
)
<<
"PatchIndexBuffer started"
;
QVector
<
unsigned
int
>
pib
;
QVector
<
unsigned
int
>
pib
;
QVector
<
unsigned
int
>
ib_combined
=
ib_regular
+
ib_irregular
;
QVector
<
unsigned
int
>
ib_combined
=
ib_regular
+
ib_irregular
;
for
(
int
i
=
0
;
i
<
ib_regular
.
length
()
-
2
;
i
+=
3
){
for
(
int
i
=
0
;
i
<
ib_regular
.
length
()
-
2
;
i
+=
3
){
...
@@ -422,7 +431,7 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib_
...
@@ -422,7 +431,7 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib_
int
count3
=
0
;
//counts other triangles with this vertex
int
count3
=
0
;
//counts other triangles with this vertex
int
count6
=
0
;
int
count6
=
0
;
int
count7
=
0
;
int
count7
=
0
;
/*
for (int j = 0; j < ib_combined.length(); j++){
for (int j = 0; j < ib_combined.length(); j++){
if (j != i && j != i+1 && j != i+2){
if (j != i && j != i+1 && j != i+2){
//for debugging // checking if patch is regular.
//for debugging // checking if patch is regular.
...
@@ -434,7 +443,7 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib_
...
@@ -434,7 +443,7 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib_
if (count3 != 5 || count6 != 5 || count7 != 5){
if (count3 != 5 || count6 != 5 || count7 != 5){
qCWarning(log_subdiv) << "Counts wrong! 3: "<< count3 <<", 6: " << count6 << ", 7: " << count7 << ".\nEither this patch is not regular, or you didn't pass all neighboring triangles.";
qCWarning(log_subdiv) << "Counts wrong! 3: "<< count3 <<", 6: " << count6 << ", 7: " << count7 << ".\nEither this patch is not regular, or you didn't pass all neighboring triangles.";
}
}
*/
//find triangles with shared edge. Fills i2, i4, i10.
//find triangles with shared edge. Fills i2, i4, i10.
{
{
...
@@ -525,6 +534,7 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib_
...
@@ -525,6 +534,7 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib_
}
}
}
}
qCDebug
(
log_timing
)
<<
"PatchIndexBuffer done:"
<<
totalTimer
.
elapsed
()
<<
"ms"
;
return
pib
;
return
pib
;
}
}
...
@@ -550,6 +560,9 @@ QVector<unsigned int> Subdivision::getTriangles(QVector<unsigned int> ib) {
...
@@ -550,6 +560,9 @@ QVector<unsigned int> Subdivision::getTriangles(QVector<unsigned int> ib) {
* @param irregular All irregular triangles are appended to this index buffer.
* @param irregular All irregular triangles are appended to this index buffer.
*/
*/
void
Subdivision
::
findRegular
(
QVector
<
unsigned
int
>
index_buffer
,
QVector
<
Vertex
>
vertex_buffer
,
QVector
<
unsigned
int
>
&
regular
,
QVector
<
unsigned
int
>
&
irregular
)
{
void
Subdivision
::
findRegular
(
QVector
<
unsigned
int
>
index_buffer
,
QVector
<
Vertex
>
vertex_buffer
,
QVector
<
unsigned
int
>
&
regular
,
QVector
<
unsigned
int
>
&
irregular
)
{
QTime
totalTimer
;
totalTimer
.
start
();
qCDebug
(
log_timing
)
<<
"Find Regular started"
;
for
(
int
i
=
0
;
i
<
index_buffer
.
length
()
-
2
;
i
+=
3
){
for
(
int
i
=
0
;
i
<
index_buffer
.
length
()
-
2
;
i
+=
3
){
Vertex
vx
=
vertex_buffer
[
index_buffer
[
i
]];
Vertex
vx
=
vertex_buffer
[
index_buffer
[
i
]];
Vertex
vy
=
vertex_buffer
[
index_buffer
[
i
+
1
]];
Vertex
vy
=
vertex_buffer
[
index_buffer
[
i
+
1
]];
...
@@ -581,6 +594,7 @@ void Subdivision::findRegular(QVector<unsigned int> index_buffer, QVector<Vertex
...
@@ -581,6 +594,7 @@ void Subdivision::findRegular(QVector<unsigned int> index_buffer, QVector<Vertex
irregular
.
push_back
(
index_buffer
[
i
+
2
]);
irregular
.
push_back
(
index_buffer
[
i
+
2
]);
}
}
}
}
qCDebug
(
log_timing
)
<<
"Find Regular done:"
<<
totalTimer
.
elapsed
()
<<
"ms"
;
}
}
bool
Subdivision
::
matchAndCompleteTriangleIndices
(
unsigned
int
sx
,
unsigned
int
sy
,
unsigned
int
sz
,
unsigned
int
tx
,
unsigned
int
ty
,
unsigned
int
&
tz
){
bool
Subdivision
::
matchAndCompleteTriangleIndices
(
unsigned
int
sx
,
unsigned
int
sy
,
unsigned
int
sz
,
unsigned
int
tx
,
unsigned
int
ty
,
unsigned
int
&
tz
){
...
@@ -649,10 +663,15 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
...
@@ -649,10 +663,15 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
result
.
vb_handle
=
output_handle
;
result
.
vb_handle
=
output_handle
;
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
0
);
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
0
);
QTime
timer
;
timer
.
start
();
runVertexShader
(
input
.
vertex_buffer
.
size
(),
input
.
vb_handle
,
vertex_indices_handle
,
vertex_offsets_handle
,
output_handle
);
runVertexShader
(
input
.
vertex_buffer
.
size
(),
input
.
vb_handle
,
vertex_indices_handle
,
vertex_offsets_handle
,
output_handle
);
int
vertexTime
=
timer
.
elapsed
();
timer
.
restart
();
int
edgeOffset
=
input
.
vertex_buffer
.
size
();
int
edgeOffset
=
input
.
vertex_buffer
.
size
();
runEdgeShader
(
tables
.
edge_indices
.
size
()
/
4
,
input
.
vb_handle
,
edge_indices_handle
,
output_handle
,
edgeOffset
);
runEdgeShader
(
tables
.
edge_indices
.
size
()
/
4
,
input
.
vb_handle
,
edge_indices_handle
,
output_handle
,
edgeOffset
);
int
edgeTime
=
timer
.
elapsed
();
timer
.
restart
();
// Map the output buffer so we can read the results
// Map the output buffer so we can read the results
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
output_handle
);
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
output_handle
);
...
@@ -669,7 +688,7 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
...
@@ -669,7 +688,7 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
qCDebug
(
log_subdiv_trace
)
<<
ptr
[
edgeOffset
+
i
].
pos
;
qCDebug
(
log_subdiv_trace
)
<<
ptr
[
edgeOffset
+
i
].
pos
;
result
.
vertex_buffer
.
push_back
(
ptr
[
edgeOffset
+
i
]);
result
.
vertex_buffer
.
push_back
(
ptr
[
edgeOffset
+
i
]);
}
}
int
bufferbildTime
=
timer
.
elapsed
();
f
->
glUnmapBuffer
(
GL_SHADER_STORAGE_BUFFER
);
f
->
glUnmapBuffer
(
GL_SHADER_STORAGE_BUFFER
);
...
@@ -678,6 +697,7 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
...
@@ -678,6 +697,7 @@ Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
f
->
glDeleteBuffers
(
1
,
&
vertex_offsets_handle
);
f
->
glDeleteBuffers
(
1
,
&
vertex_offsets_handle
);
f
->
glDeleteBuffers
(
1
,
&
edge_indices_handle
);
f
->
glDeleteBuffers
(
1
,
&
edge_indices_handle
);
qCDebug
(
log_timing
)
<<
"Compute Shader done. Vertexshader"
<<
vertexTime
<<
"ms; EdgeShader"
<<
edgeTime
<<
" BufferToCPU"
<<
bufferbildTime
<<
"ms"
;
return
result
;
return
result
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment