Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vulkan2021
VkCV Framework
Commits
086acb21
Commit
086acb21
authored
3 years ago
by
Sebastian Gaida
Browse files
Options
Downloads
Patches
Plain Diff
[
#69
] tried to fix some things...
parent
4ed3dea8
No related branches found
No related tags found
1 merge request
!56
Resolve "Partikelsystem"
Pipeline
#25489
failed
3 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
projects/particle_simulation/src/main.cpp
+35
-43
35 additions, 43 deletions
projects/particle_simulation/src/main.cpp
with
35 additions
and
43 deletions
projects/particle_simulation/src/main.cpp
+
35
−
43
View file @
086acb21
...
...
@@ -5,15 +5,15 @@
#include
<chrono>
int
main
(
int
argc
,
const
char
**
argv
)
{
const
char
*
applicationName
=
"
First Triangle
"
;
const
char
*
applicationName
=
"
Particlesystem
"
;
const
in
t
windowWidth
=
800
;
const
in
t
windowHeight
=
600
;
uint32_
t
windowWidth
=
800
;
uint32_
t
windowHeight
=
600
;
vkcv
::
Window
window
=
vkcv
::
Window
::
create
(
applicationName
,
windowWidth
,
windowHeight
,
fals
e
tru
e
);
vkcv
::
CameraManager
cameraManager
(
window
,
windowWidth
,
windowHeight
);
...
...
@@ -53,34 +53,15 @@ int main(int argc, const char** argv) {
uint16_t
indices
[
3
]
=
{
0
,
1
,
2
};
triangleIndexBuffer
.
fill
(
&
indices
[
0
],
sizeof
(
indices
));
vkcv
::
SamplerHandle
sampler
=
core
.
createSampler
(
vkcv
::
SamplerFilterType
::
NEAREST
,
vkcv
::
SamplerFilterType
::
NEAREST
,
vkcv
::
SamplerMipmapMode
::
NEAREST
,
vkcv
::
SamplerAddressMode
::
REPEAT
);
std
::
cout
<<
"Physical device: "
<<
physicalDevice
.
getProperties
().
deviceName
<<
std
::
endl
;
switch
(
physicalDevice
.
getProperties
().
vendorID
)
{
case
0x1002
:
std
::
cout
<<
"Running AMD huh? You like underdogs, are you a Linux user?"
<<
std
::
endl
;
break
;
case
0x10DE
:
std
::
cout
<<
"An NVidia GPU, how predictable..."
<<
std
::
endl
;
break
;
case
0x8086
:
std
::
cout
<<
"Poor child, running on an Intel GPU, probably integrated..."
"or perhaps you are from the future with a dedicated one?"
<<
std
::
endl
;
break
;
case
0x13B5
:
std
::
cout
<<
"ARM? What the hell are you running on, next thing I know you're trying to run Vulkan on a leg..."
<<
std
::
endl
;
break
;
default:
std
::
cout
<<
"Unknown GPU vendor?! Either you're on an exotic system or your driver is broken..."
<<
std
::
endl
;
}
// an example attachment for passes that output to the window
const
vkcv
::
AttachmentDescription
present_color_attachment
(
vkcv
::
AttachmentLayout
::
UNDEFINED
,
vkcv
::
AttachmentLayout
::
COLOR_ATTACHMENT
,
vkcv
::
AttachmentLayout
::
PRESENTATION
,
vkcv
::
AttachmentOperation
::
STORE
,
vkcv
::
AttachmentOperation
::
CLEAR
,
core
.
getSwapchainImageFormat
());
vkcv
::
PassConfig
particlePassDefinition
({
present_color_attachment
});
vkcv
::
PassHandle
particlePass
=
core
.
createPass
(
particlePassDefinition
);
...
...
@@ -96,18 +77,19 @@ int main(int argc, const char** argv) {
particleShaderProgram
.
reflectShader
(
vkcv
::
ShaderStage
::
VERTEX
);
particleShaderProgram
.
reflectShader
(
vkcv
::
ShaderStage
::
FRAGMENT
);
vkcv
::
DescriptorSetConfig
setConfig
({
vkcv
::
DescriptorBinding
(
vkcv
::
DescriptorType
::
UNIFORM_BUFFER
,
1
,
vkcv
::
ShaderStage
::
FRAGMENT
),
});
vkcv
::
ResourcesHandle
set
=
core
.
createResourceDescription
({
setConfig
});
std
::
vector
<
vkcv
::
DescriptorBinding
>
descriptorBindings
=
{
vkcv
::
DescriptorBinding
(
vkcv
::
DescriptorType
::
UNIFORM_BUFFER
,
1
,
vkcv
::
ShaderStage
::
FRAGMENT
)};
vkcv
::
DescriptorSetHandle
descriptorSet
=
core
.
createDescriptorSet
(
descriptorBindings
);
const
vkcv
::
PipelineConfig
particlePipelineDefinition
(
particleShaderProgram
,
windowWidth
,
windowHeight
,
UINT32_MAX
,
UINT32_MAX
,
particlePass
,
{},
{
core
.
getDescriptorSetLayout
(
set
,
0
)});
{
core
.
getDescriptorSet
(
descriptorSet
).
layout
},
true
);
vkcv
::
PipelineHandle
particlePipeline
=
core
.
createGraphicsPipeline
(
particlePipelineDefinition
);
vkcv
::
Buffer
<
glm_vec4
>
color
=
core
.
createBuffer
<
glm_vec4
>
(
vkcv
::
BufferType
::
UNIFORM
,
...
...
@@ -116,7 +98,7 @@ int main(int argc, const char** argv) {
vkcv
::
DescriptorWrites
setWrites
;
setWrites
.
uniformBufferWrites
=
{
vkcv
::
UniformBufferDescriptorWrite
(
0
,
color
.
getHandle
())};
core
.
writeResourceDescription
(
s
et
,
0
,
setWrites
);
core
.
writeResourceDescription
(
descriptorS
et
,
0
,
setWrites
);
if
(
!
particlePipeline
)
{
...
...
@@ -124,30 +106,40 @@ int main(int argc, const char** argv) {
return
EXIT_FAILURE
;
}
std
::
vector
<
vkcv
::
VertexBufferBinding
>
vertexBufferBindings
;
const
vkcv
::
ImageHandle
swapchainInput
=
vkcv
::
ImageHandle
::
createSwapchainImageHandle
();
const
vkcv
::
Mesh
renderMesh
({},
triangleIndexBuffer
.
getVulkanHandle
(),
3
);
vkcv
::
DrawcallInfo
drawcalls
(
renderMesh
,
{});
auto
start
=
std
::
chrono
::
system_clock
::
now
();
while
(
window
.
isWindowOpen
())
{
core
.
beginFrame
();
window
.
pollEvents
();
uint32_t
swapchainWidth
,
swapchainHeight
;
if
(
!
core
.
beginFrame
(
swapchainWidth
,
swapchainHeight
))
{
continue
;
}
auto
end
=
std
::
chrono
::
system_clock
::
now
();
auto
deltatime
=
end
-
start
;
start
=
end
;
cameraManager
.
getCamera
().
updateView
(
std
::
chrono
::
duration
<
double
>
(
deltatime
).
count
());
const
glm
::
mat4
mvp
=
cameraManager
.
getCamera
().
getProjection
()
*
cameraManager
.
getCamera
().
getView
();
core
.
renderMesh
(
vkcv
::
PushConstantData
pushConstantData
((
void
*
)
&
mvp
,
sizeof
(
glm
::
mat4
));
auto
cmdStream
=
core
.
createCommandStream
(
vkcv
::
QueueType
::
Graphics
);
core
.
recordDrawcallsToCmdStream
(
cmdStream
,
particlePass
,
particlePipeline
,
sizeof
(
mvp
),
&
mvp
,
vertexBufferBindings
,
triangleIndexBuffer
.
getHandle
(),
3
,
vkcv
::
ResourcesHandle
(),
0
);
pushConstantData
,
{
drawcalls
},
{
swapchainInput
});
core
.
prepareSwapchainImageForPresent
(
cmdStream
);
core
.
submitCommandStream
(
cmdStream
);
core
.
endFrame
();
}
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment