-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First Timeline Semaphore use #158
Open
MoritzRoth
wants to merge
17
commits into
development
Choose a base branch
from
timeline-semaphores
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
84b7467
enable timeline semaphore feature
MoritzRoth c23dd36
add documentation
MoritzRoth d2f9424
typo fix
MoritzRoth 1278e6b
adjust for auto_vk changes to semaphore_signal_info creation
MoritzRoth 9231193
stop enabling timeline semaphores by default
MoritzRoth 5a5441f
Adapted to changes in Auto-Vk, which now require the syntax: stage >>…
johannesugb db06a39
adapt to operator changes for timeline semaphores in auto_vk
MoritzRoth 3feb870
create particle example setup (duplicate of hello_world example, erro…
MoritzRoth 4bbb1c8
Fixed the .user file for the particles project, which fixes the worki…
johannesugb af6b349
start compute shader setup
MoritzRoth 158b9ed
intermediate changes to ensure that the graphics pipeline works corre…
MoritzRoth e7f32ee
rename a_triangle.vert/.frag to particle.vert/.frag
MoritzRoth a7c0d1b
iterate further to use particle buffer filled by compute shader
MoritzRoth 440b921
also use metadata uniform buffer
MoritzRoth 2d3e3e6
when recording and submitting a cmdBuffer with timeline semaphore, ca…
MoritzRoth acb073a
move compute shader execution to separate queue and dispatch in separ…
MoritzRoth fca360b
start implementing the particle compute shader
MoritzRoth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule auto_vk
updated
5 files
+17 −0 | include/avk/avk.hpp | |
+105 −4 | include/avk/commands.hpp | |
+12 −0 | include/avk/cpp_utils.hpp | |
+392 −2 | include/avk/semaphore.hpp | |
+74 −4 | src/avk.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
add_executable(particles | ||
source/hello_world.cpp) | ||
target_include_directories(particles PRIVATE ${PROJECT_NAME}) | ||
target_link_libraries(particles PRIVATE ${PROJECT_NAME}) | ||
|
||
get_target_property(particles_BINARY_DIR particles BINARY_DIR) | ||
|
||
add_post_build_commands(particles | ||
${PROJECT_SOURCE_DIR}/examples/particles/shaders | ||
${particles_BINARY_DIR}/shaders | ||
$<TARGET_FILE_DIR:particles>/assets | ||
"" | ||
${avk_toolkit_CreateDependencySymlinks}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# "Hello World" Example's Root Folder | ||
|
||
This is the root directory of the "Hello World" example. It contains all the source code for the example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#version 450 | ||
#extension GL_ARB_separate_shader_objects : enable | ||
|
||
layout(location = 0) in vec3 fragColor; | ||
|
||
layout(location = 0) out vec4 outColor; | ||
|
||
void main() { | ||
outColor = vec4(fragColor, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#version 450 | ||
#extension GL_ARB_separate_shader_objects : enable | ||
|
||
#define PART_CNT 50 | ||
|
||
struct Particle { | ||
vec3 pos; | ||
vec3 vel; | ||
float size; | ||
float age; | ||
}; | ||
|
||
layout(set = 0, binding = 0) uniform ParticleBuffer | ||
{ | ||
Particle[PART_CNT] p; | ||
} particleBuffer; | ||
|
||
layout(location = 0) out vec3 fragColor; | ||
|
||
vec2 positions[6] = vec2[]( | ||
vec2(-0.5, -0.5), | ||
vec2(0.5, -0.5), | ||
vec2(-0.5, 0.5), | ||
|
||
vec2(0.5, -0.5), | ||
vec2(0.5, 0.5), | ||
vec2(-0.5, 0.5) | ||
); | ||
|
||
vec3 colors[3] = vec3[]( | ||
vec3(1.0, 0.0, 0.0), | ||
vec3(0.0, 1.0, 0.0), | ||
vec3(0.0, 0.0, 1.0) | ||
); | ||
|
||
void main() { | ||
uint id = gl_VertexIndex / 6; | ||
Particle p = particleBuffer.p[id]; | ||
gl_Position = vec4(positions[gl_VertexIndex % 6]*p.size*p.age + p.pos.xy /*+ vec2(id/3.,0.)*/, 0.0, 1.0); | ||
//gl_Position += vec4(p.vel * (p.age + p.pos.z), 0.); | ||
fragColor = colors[gl_VertexIndex % 3]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#version 450 | ||
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable | ||
|
||
#define PARTICLE_CNT 50 | ||
#define COLLIDER_CNT 10 | ||
|
||
struct Particle { | ||
vec3 pos; | ||
vec3 vel; | ||
float size; | ||
float age; | ||
}; | ||
|
||
struct AACube { | ||
vec3 min; | ||
vec3 max; | ||
}; | ||
|
||
struct Sphere { | ||
vec3 origin; | ||
float radius; | ||
}; | ||
|
||
struct Colliders { | ||
uint cubeCount; | ||
uint sphereCount; | ||
AACube cubes[COLLIDER_CNT]; | ||
Sphere spheres[COLLIDER_CNT]; | ||
}; | ||
|
||
struct ParticleSystem{ | ||
vec3 origin; | ||
float spawnRadius; | ||
float spawnRate; | ||
vec3 initialVelocity; | ||
float velocityRandomization; | ||
vec3 gravity; | ||
float particleSize; | ||
float particleLifetime; | ||
}; | ||
|
||
layout (local_size_x = 1, local_size_y = 1) in; | ||
|
||
layout(set = 0, binding = 0) buffer Particles { | ||
Particle p[]; | ||
} particles; | ||
|
||
layout (set = 0, binding = 1) uniform Metadata { | ||
uint64_t runTime; | ||
uint64_t deltaTime; | ||
ParticleSystem systemProperties; | ||
//Colliders colliders; | ||
} m; | ||
|
||
|
||
// Hash without Sine | ||
// MIT License... | ||
/* Copyright (c)2014 David Hoskins. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE.*/ | ||
|
||
//---------------------------------------------------------------------------------------- | ||
// 1 out, 2 in... | ||
float hash12(vec2 p) | ||
{ | ||
vec3 p3 = fract(vec3(p.xyx) * .1031); | ||
p3 += dot(p3, p3.yzx + 33.33); | ||
return fract((p3.x + p3.y) * p3.z); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------- | ||
/// 2 out, 2 in... | ||
vec2 hash22(vec2 p) | ||
{ | ||
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973)); | ||
p3 += dot(p3, p3.yzx+33.33); | ||
return fract((p3.xx+p3.yz)*p3.zy); | ||
|
||
} | ||
|
||
//---------------------------------------------------------------------------------------- | ||
/// 3 out, 2 in... | ||
vec3 hash32(vec2 p) | ||
{ | ||
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973)); | ||
p3 += dot(p3, p3.yxz+33.33); | ||
return fract((p3.xxy+p3.yzz)*p3.zyx); | ||
} | ||
|
||
void main() { | ||
float rt = float(m.runTime) / 1e6; | ||
float dt = float(m.deltaTime) / 1e6; | ||
|
||
ParticleSystem sys = m.systemProperties; | ||
|
||
int beginId = 0; | ||
int endId = PARTICLE_CNT; | ||
for(int i = beginId; i < endId; i++) { | ||
Particle p = particles.p[i]; | ||
|
||
if(p.age > 0) { | ||
p.vel += sys.gravity * dt; | ||
p.pos += p.vel * dt; | ||
p.age -= dt; | ||
}else { | ||
vec2 seed = vec2(rt, float(i)*0.34982); | ||
if(hash12(seed) < sys.spawnRate * dt) { | ||
seed = hash22(seed); | ||
p.pos = sys.origin + normalize(hash32(seed)) * (hash12(seed) - 0.5) * 2. * sys.spawnRadius; | ||
seed = hash22(seed); | ||
p.vel = mix(sys.initialVelocity, (hash32(seed) - 0.5) * 2. * length(sys.initialVelocity), sys.velocityRandomization); | ||
p.size = sys.particleSize; | ||
p.age = sys.particleLifetime; | ||
|
||
|
||
}else { | ||
p.size = 0.; | ||
} | ||
} | ||
|
||
|
||
particles.p[i] = p; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add spaces before the
*
, so that all*
are vertically aligned!