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
1221b6c9
Commit
1221b6c9
authored
Jun 28, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move edge shader code into new function
parent
badac240
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
15 deletions
+20
-15
subdivision.cpp
QTProject/subdivision.cpp
+19
-15
subdivision.h
QTProject/subdivision.h
+1
-0
No files found.
QTProject/subdivision.cpp
View file @
1221b6c9
...
@@ -298,14 +298,31 @@ void Subdivision::runShader(Input input, Tables &tables) {
...
@@ -298,14 +298,31 @@ void Subdivision::runShader(Input input, Tables &tables) {
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
0
);
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
0
);
runEdgeShader
(
tables
.
edge_indices
.
size
()
/
4
,
input
.
vb_handle
,
edge_indices_handle
,
output_handle
);
// Map the output buffer so we can read the results
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
output_handle
);
Vertex
*
ptr
;
ptr
=
(
Vertex
*
)
f
->
glMapBuffer
(
GL_SHADER_STORAGE_BUFFER
,
GL_WRITE_ONLY
);
for
(
int
i
=
0
;
i
<
tables
.
edge_indices
.
size
()
/
4
;
i
++
)
{
qDebug
()
<<
ptr
[
i
].
pos
;
}
f
->
glUnmapBuffer
(
GL_SHADER_STORAGE_BUFFER
);
// Delete the buffers the free the resources
f
->
glDeleteBuffers
(
1
,
&
edge_indices_handle
);
f
->
glDeleteBuffers
(
1
,
&
output_handle
);
}
void
Subdivision
::
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
)
{
edgeShader
->
bind
();
edgeShader
->
bind
();
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
0
,
input
.
vb_handle
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
0
,
vb_handle
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
1
,
edge_indices_handle
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
1
,
edge_indices_handle
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
2
,
output_handle
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
2
,
output_handle
);
// Run the shader
// Run the shader
f
->
glDispatchCompute
(
tables
.
edge_indices
.
size
()
/
4
,
1
,
1
);
f
->
glDispatchCompute
(
size
,
1
,
1
);
// Wait for the shader to complete and the data to be written back to the global memory
// Wait for the shader to complete and the data to be written back to the global memory
f
->
glMemoryBarrier
(
GL_SHADER_STORAGE_BARRIER_BIT
);
f
->
glMemoryBarrier
(
GL_SHADER_STORAGE_BARRIER_BIT
);
...
@@ -316,17 +333,4 @@ void Subdivision::runShader(Input input, Tables &tables) {
...
@@ -316,17 +333,4 @@ void Subdivision::runShader(Input input, Tables &tables) {
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
2
,
0
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
2
,
0
);
edgeShader
->
release
();
edgeShader
->
release
();
// Map the output buffer so we can read the results
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
output_handle
);
Vertex
*
ptr
;
ptr
=
(
Vertex
*
)
f
->
glMapBuffer
(
GL_SHADER_STORAGE_BUFFER
,
GL_WRITE_ONLY
);
for
(
int
i
=
0
;
i
<
tables
.
edge_indices
.
size
()
/
4
;
i
++
)
{
qDebug
()
<<
ptr
[
i
].
pos
;
}
f
->
glUnmapBuffer
(
GL_SHADER_STORAGE_BUFFER
);
// Delete the buffers the free the resources
f
->
glDeleteBuffers
(
1
,
&
edge_indices_handle
);
f
->
glDeleteBuffers
(
1
,
&
output_handle
);
}
}
QTProject/subdivision.h
View file @
1221b6c9
...
@@ -36,6 +36,7 @@ private:
...
@@ -36,6 +36,7 @@ private:
QOpenGLShaderProgram
*
initComputeShaderProgram
(
QString
&
source
);
QOpenGLShaderProgram
*
initComputeShaderProgram
(
QString
&
source
);
Tables
precomputeTables
(
Input
input
);
Tables
precomputeTables
(
Input
input
);
void
runShader
(
Input
input
,
Tables
&
tables
);
void
runShader
(
Input
input
,
Tables
&
tables
);
void
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
);
};
};
#endif
#endif
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