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
ec66e754
Commit
ec66e754
authored
3 years ago
by
Lars Hoerttrich
Browse files
Options
Downloads
Patches
Plain Diff
[
#91
] very basic main.cpp, still has errors
parent
28efc953
No related branches found
Branches containing commit
No related tags found
1 merge request
!79
Draft: Resolve "Compute: First Network"
Pipeline
#26346
passed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
projects/neural_network/resources/shaders/simpleShader.comp
+18
-0
18 additions, 0 deletions
projects/neural_network/resources/shaders/simpleShader.comp
projects/neural_network/src/main.cpp
+70
-3
70 additions, 3 deletions
projects/neural_network/src/main.cpp
with
88 additions
and
3 deletions
projects/neural_network/resources/shaders/simpleShader.comp
0 → 100644
+
18
−
0
View file @
ec66e754
#version 450 core
#extension GL_ARB_separate_shader_objects : enable
layout(local_size_x = 1) in;
layout(std430, binding = 0) coherent buffer buffer_input
{
int bufferInput[];
};
layout( push_constant ) uniform constants{
int increment;
};
void main() {
uint id = gl_GlobalInvocationID.x;
bufferInput[id] += increment;
}
This diff is collapsed.
Click to expand it.
projects/neural_network/src/main.cpp
+
70
−
3
View file @
ec66e754
#include
<iostream>
#include
<vkcv/Core.hpp>
#include
<GLFW/glfw3.h>
#include
<vkcv/camera/CameraManager.hpp>
#include
<chrono>
#include
<vkcv/asset/asset_loader.hpp>
#include
<vkcv/shader/GLSLCompiler.hpp>
#include
<vkcv/scene/Scene.hpp>
int
main
(
int
argc
,
const
char
**
argv
)
{
const
char
*
applicationName
=
"Neural-Network"
;
uint32_t
windowWidth
=
800
;
uint32_t
windowHeight
=
600
;
vkcv
::
Window
window
=
vkcv
::
Window
::
create
(
applicationName
,
windowWidth
,
windowHeight
,
true
);
vkcv
::
Core
core
=
vkcv
::
Core
::
create
(
window
,
applicationName
,
VK_MAKE_VERSION
(
0
,
0
,
1
),
{
vk
::
QueueFlagBits
::
eTransfer
,
vk
::
QueueFlagBits
::
eGraphics
,
vk
::
QueueFlagBits
::
eCompute
},
{},
{
"VK_KHR_swapchain"
}
);
int
input
[
64
]
=
{
0
};
vkcv
::
Buffer
<
int
>
inputBuffer
=
core
.
createBuffer
<
int
>
(
vkcv
::
BufferType
::
STORAGE
,
64
);
inputBuffer
.
fill
(
input
);
vkcv
::
PassConfig
computePassDefinition
({});
vkcv
::
PassHandle
computePass
=
core
.
createPass
(
computePassDefinition
);
if
(
!
computePass
)
{
std
::
cout
<<
"Error. Could not create renderpass. Exiting."
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
// shader path
std
::
string
shaderPathCompute
=
"resources/shaders/simpleShader.comp"
;
vkcv
::
shader
::
GLSLCompiler
compiler
;
vkcv
::
ShaderProgram
computeShaderProgram
{};
compiler
.
compile
(
vkcv
::
ShaderStage
::
COMPUTE
,
shaderPathCompute
,
[
&
](
vkcv
::
ShaderStage
shaderStage
,
const
std
::
filesystem
::
path
&
path
)
{
computeShaderProgram
.
addShader
(
shaderStage
,
path
);
});
vkcv
::
DescriptorSetHandle
computeDescriptorSet
=
core
.
createDescriptorSet
(
computeShaderProgram
.
getReflectedDescriptors
()[
0
]);
vkcv
::
PipelineHandle
computePipeline
=
core
.
createComputePipeline
(
computeShaderProgram
,
{
core
.
getDescriptorSet
(
computeDescriptorSet
).
layout
});
vkcv
::
DescriptorWrites
computeWrites
;
computeWrites
.
storageBufferWrites
=
{
vkcv
::
StorageBufferDescriptorWrite
(
0
,
inputBuffer
.
getHandle
())
};
core
.
writeDescriptorSet
(
computeDescriptorSet
,
computeWrites
);
if
(
!
computePipeline
)
{
std
::
cout
<<
"Error. Could not create compute pipeline. Exiting."
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
auto
cmdStream
=
core
.
createCommandStream
(
vkcv
::
QueueType
::
Compute
);
uint32_t
computeDispatchCount
[
3
]
=
{
inputBuffer
.
getSize
(),
1
,
1
};
vkcv
::
PushConstants
pushConstantsCompute
(
sizeof
(
int
));
pushConstantsCompute
.
appendDrawcall
(
1
);
core
.
recordComputeDispatchToCmdStream
(
cmdStream
,
computePipeline
,
computeDispatchCount
,
{
vkcv
::
DescriptorSetUsage
(
0
,
core
.
getDescriptorSet
(
computeDescriptorSet
).
vulkanHandle
)
},
pushConstantsCompute
);
core
.
recordBufferMemoryBarrier
(
cmdStream
,
inputBuffer
.
getHandle
());
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