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
817044b4
Commit
817044b4
authored
Jun 27, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement edge vertex computation
parent
44d0a2d5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
subdivision.compute
QTProject/subdivision.compute
+5
-2
subdivision.cpp
QTProject/subdivision.cpp
+6
-6
No files found.
QTProject/subdivision.compute
View file @
817044b4
...
@@ -17,9 +17,12 @@ layout(std430, binding=1) readonly buffer EdgeIndices {
...
@@ -17,9 +17,12 @@ layout(std430, binding=1) readonly buffer EdgeIndices {
};
};
layout(std430, binding=2) writeonly buffer Output {
layout(std430, binding=2) writeonly buffer Output {
float data
[];
Vertex edges
[];
};
};
void main(){
void main(){
data[gl_GlobalInvocationID.x] = vertices[gl_GlobalInvocationID.x].pos.x;
edges[gl_GlobalInvocationID.x].norm = vec3(0.0, 0.0, 0.0);
edges[gl_GlobalInvocationID.x].uv = vec2(0.0, 0.0);
edges[gl_GlobalInvocationID.x].pos = 3.0/8.0 * (vertices[indices[gl_GlobalInvocationID.x][0]].pos + vertices[indices[gl_GlobalInvocationID.x][1]].pos) + 1.0/8.0 * (vertices[indices[gl_GlobalInvocationID.x][2]].pos + vertices[indices[gl_GlobalInvocationID.y][3]].pos);
}
}
QTProject/subdivision.cpp
View file @
817044b4
...
@@ -303,10 +303,10 @@ void Subdivision::runShader(Mesh *mesh, QVector<QVector<unsigned int> > &edgeInd
...
@@ -303,10 +303,10 @@ void Subdivision::runShader(Mesh *mesh, QVector<QVector<unsigned int> > &edgeInd
GLuint
bufferID
;
GLuint
bufferID
;
f
->
glGenBuffers
(
1
,
&
bufferID
);
f
->
glGenBuffers
(
1
,
&
bufferID
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
2
,
bufferID
);
f
->
glBindBufferBase
(
GL_SHADER_STORAGE_BUFFER
,
2
,
bufferID
);
f
->
glBufferData
(
GL_SHADER_STORAGE_BUFFER
,
vb
.
size
()
*
sizeof
(
GLfloat
),
NULL
,
GL_DYNAMIC_DRAW
);
f
->
glBufferData
(
GL_SHADER_STORAGE_BUFFER
,
edgeIndices
.
size
()
*
sizeof
(
Vertex
),
NULL
,
GL_DYNAMIC_DRAW
);
// Run the shader
// Run the shader
f
->
glDispatchCompute
(
vb
.
size
(),
1
,
1
);
f
->
glDispatchCompute
(
edgeIndices
.
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
);
...
@@ -318,10 +318,10 @@ void Subdivision::runShader(Mesh *mesh, QVector<QVector<unsigned int> > &edgeInd
...
@@ -318,10 +318,10 @@ void Subdivision::runShader(Mesh *mesh, QVector<QVector<unsigned int> > &edgeInd
// 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
,
bufferID
);
f
->
glBindBuffer
(
GL_SHADER_STORAGE_BUFFER
,
bufferID
);
GLfloat
*
ptr
;
Vertex
*
ptr
;
ptr
=
(
GLfloat
*
)
f
->
glMapBuffer
(
GL_SHADER_STORAGE_BUFFER
,
GL_WRITE_ONLY
);
ptr
=
(
Vertex
*
)
f
->
glMapBuffer
(
GL_SHADER_STORAGE_BUFFER
,
GL_WRITE_ONLY
);
for
(
int
i
=
0
;
i
<
vb
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
edgeIndices
.
size
();
i
++
)
{
qDebug
()
<<
ptr
[
i
]
<<
vb
[
i
].
pos
.
x
()
;
qDebug
()
<<
ptr
[
i
]
.
pos
;
}
}
f
->
glUnmapBuffer
(
GL_SHADER_STORAGE_BUFFER
);
f
->
glUnmapBuffer
(
GL_SHADER_STORAGE_BUFFER
);
...
...
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