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
34979078
Commit
34979078
authored
3 years ago
by
Alexander Gauggel
Browse files
Options
Downloads
Patches
Plain Diff
[
#66
] Fix first mesh project main
parent
369d3dcf
No related branches found
No related tags found
1 merge request
!54
Resolve "Cmd/Sync-Rework"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
projects/first_mesh/src/main.cpp
+25
-30
25 additions, 30 deletions
projects/first_mesh/src/main.cpp
with
25 additions
and
30 deletions
projects/first_mesh/src/main.cpp
+
25
−
30
View file @
34979078
...
...
@@ -63,18 +63,12 @@ int main(int argc, const char** argv) {
// 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
()
);
const
vkcv
::
AttachmentDescription
depth_attachment
(
vkcv
::
AttachmentLayout
::
UNDEFINED
,
vkcv
::
AttachmentLayout
::
DEPTH_STENCIL_ATTACHMENT
,
vkcv
::
AttachmentLayout
::
DEPTH_STENCIL_ATTACHMENT
,
vkcv
::
AttachmentOperation
::
STORE
,
vkcv
::
AttachmentOperation
::
CLEAR
,
vk
::
Format
::
eD32Sfloat
...
...
@@ -100,17 +94,10 @@ int main(int argc, const char** argv) {
return
static_cast
<
uint32_t
>
(
x
.
type
)
<
static_cast
<
uint32_t
>
(
y
.
type
);
});
vkcv
::
Descriptor
SetConfig
setConfig
(
{
std
::
vector
<
vkcv
::
Descriptor
Binding
>
descriptorBindings
=
{
vkcv
::
DescriptorBinding
(
vkcv
::
DescriptorType
::
IMAGE_SAMPLED
,
1
,
vkcv
::
ShaderStage
::
FRAGMENT
),
vkcv
::
DescriptorBinding
(
vkcv
::
DescriptorType
::
SAMPLER
,
1
,
vkcv
::
ShaderStage
::
FRAGMENT
)
});
vkcv
::
DescriptorSetHandle
set
=
core
.
createDescriptorSet
({
setConfig
});
//only exemplary code for testing
for
(
int
i
=
0
;
i
<
1001
;
i
++
)
{
vkcv
::
DescriptorSetHandle
furtherSets
=
core
.
createDescriptorSet
({
setConfig
});
}
//end of exemplary code
vkcv
::
DescriptorBinding
(
vkcv
::
DescriptorType
::
SAMPLER
,
1
,
vkcv
::
ShaderStage
::
FRAGMENT
)
};
vkcv
::
DescriptorSetHandle
descriptorSet
=
core
.
createDescriptorSet
(
descriptorBindings
);
const
vkcv
::
PipelineConfig
trianglePipelineDefinition
(
triangleShaderProgram
,
...
...
@@ -118,7 +105,7 @@ int main(int argc, const char** argv) {
UINT32_MAX
,
trianglePass
,
mesh
.
vertexGroups
[
0
].
vertexBuffer
.
attributes
,
{
core
.
getDescriptorSet
(
set
,
0
)
},
{
core
.
getDescriptorSet
(
descriptorSet
).
layout
},
true
);
vkcv
::
PipelineHandle
trianglePipeline
=
core
.
createGraphicsPipeline
(
trianglePipelineDefinition
);
...
...
@@ -137,16 +124,16 @@ int main(int argc, const char** argv) {
vkcv
::
SamplerAddressMode
::
REPEAT
);
std
::
vector
<
vkcv
::
VertexBufferBinding
>
vertexBufferBindings
=
{
{
mesh
.
vertexGroups
[
0
].
vertexBuffer
.
attributes
[
0
].
offset
,
vertexBuffer
.
getHandle
()
}
,
{
mesh
.
vertexGroups
[
0
].
vertexBuffer
.
attributes
[
1
].
offset
,
vertexBuffer
.
getHandle
()
}
,
{
mesh
.
vertexGroups
[
0
].
vertexBuffer
.
attributes
[
2
].
offset
,
vertexBuffer
.
getHandle
()
}
const
std
::
vector
<
vkcv
::
VertexBufferBinding
>
vertexBufferBindings
=
{
vkcv
::
VertexBufferBinding
(
mesh
.
vertexGroups
[
0
].
vertexBuffer
.
attributes
[
0
].
offset
,
vertexBuffer
.
get
Vulkan
Handle
()
)
,
vkcv
::
VertexBufferBinding
(
mesh
.
vertexGroups
[
0
].
vertexBuffer
.
attributes
[
1
].
offset
,
vertexBuffer
.
get
Vulkan
Handle
()
)
,
vkcv
::
VertexBufferBinding
(
mesh
.
vertexGroups
[
0
].
vertexBuffer
.
attributes
[
2
].
offset
,
vertexBuffer
.
get
Vulkan
Handle
()
)
};
vkcv
::
DescriptorWrites
setWrites
;
setWrites
.
sampledImageWrites
=
{
vkcv
::
SampledImageDescriptorWrite
(
0
,
texture
.
getHandle
())
};
setWrites
.
samplerWrites
=
{
vkcv
::
SamplerDescriptorWrite
(
1
,
sampler
)
};
core
.
writeResourceDescription
(
s
et
,
0
,
setWrites
);
core
.
writeResourceDescription
(
descriptorS
et
,
0
,
setWrites
);
vkcv
::
ImageHandle
depthBuffer
=
core
.
createImage
(
vk
::
Format
::
eD32Sfloat
,
windowWidth
,
windowHeight
).
getHandle
();
...
...
@@ -156,6 +143,11 @@ int main(int argc, const char** argv) {
const
vkcv
::
ImageHandle
swapchainInput
=
vkcv
::
ImageHandle
::
createSwapchainImageHandle
();
const
vkcv
::
Mesh
renderMesh
(
vertexBufferBindings
,
indexBuffer
.
getVulkanHandle
(),
mesh
.
vertexGroups
[
0
].
numIndices
);
vkcv
::
DescriptorSetUsage
descriptorUsage
(
0
,
core
.
getDescriptorSet
(
descriptorSet
).
vulkanHandle
);
vkcv
::
DrawcallInfo
drawcall
(
renderMesh
,
{
descriptorUsage
});
auto
start
=
std
::
chrono
::
system_clock
::
now
();
while
(
window
.
isWindowOpen
())
{
vkcv
::
Window
::
pollEvents
();
...
...
@@ -170,17 +162,20 @@ int main(int argc, const char** argv) {
cameraManager
.
getCamera
().
updateView
(
std
::
chrono
::
duration
<
double
>
(
deltatime
).
count
());
const
glm
::
mat4
mvp
=
cameraManager
.
getCamera
().
getProjection
()
*
cameraManager
.
getCamera
().
getView
();
vkcv
::
PushConstantData
pushConstantData
((
void
*
)
&
mvp
,
sizeof
(
glm
::
mat4
));
const
std
::
vector
<
vkcv
::
ImageHandle
>
renderTargets
=
{
swapchainInput
,
depthBuffer
};
auto
cmdStream
=
core
.
createCommandStream
(
vkcv
::
QueueType
::
Graphics
);
core
.
recordDrawcallsToCmdStream
(
cmdStream
,
trianglePass
,
trianglePipeline
,
sizeof
(
mvp
),
&
mvp
,
vertexBufferBindings
,
indexBuffer
.
getHandle
(),
mesh
.
vertexGroups
[
0
].
numIndices
,
set
,
0
,
{
swapchainInput
,
depthBuffer
});
pushConstantData
,
{
drawcall
},
renderTargets
);
core
.
prepareSwapchainImageForPresent
(
cmdStream
);
core
.
submitCommandStream
(
cmdStream
);
core
.
endFrame
();
}
...
...
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