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
7dcc1f7b
Commit
7dcc1f7b
authored
3 years ago
by
Lars Hoerttrich
Browse files
Options
Downloads
Patches
Plain Diff
[
#31
] Added simple create function
parent
7598c8c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!32
Resolve "Image-Klasse"
Pipeline
#25196
failed
3 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/vkcv/ImageManager.hpp
+2
-1
2 additions, 1 deletion
include/vkcv/ImageManager.hpp
src/vkcv/ImageManager.cpp
+66
-2
66 additions, 2 deletions
src/vkcv/ImageManager.cpp
with
68 additions
and
3 deletions
include/vkcv/ImageManager.hpp
+
2
−
1
View file @
7dcc1f7b
...
...
@@ -31,8 +31,9 @@ namespace vkcv {
ImageManager
&
operator
=
(
ImageManager
&&
other
)
=
delete
;
ImageManager
&
operator
=
(
const
ImageManager
&
other
)
=
delete
;
void
copyBufferToImage
(
vk
::
Buffer
bufffer
,
vk
::
Image
image
,
uint32_t
width
,
uint32_t
height
);
uint64_t
createImage
();
uint64_t
createImage
(
uint32_t
width
,
uint32_t
height
);
/**
* Destroys and deallocates image represented by a given
...
...
This diff is collapsed.
Click to expand it.
src/vkcv/ImageManager.cpp
+
66
−
2
View file @
7dcc1f7b
...
...
@@ -7,6 +7,25 @@
#include
"vkcv/Core.hpp"
namespace
vkcv
{
uint32_t
searchMemoryType
(
const
vk
::
PhysicalDeviceMemoryProperties
&
physicalMemoryProperties
,
uint32_t
typeBits
,
vk
::
MemoryPropertyFlags
requirements
)
{
const
uint32_t
memoryCount
=
physicalMemoryProperties
.
memoryTypeCount
;
for
(
uint32_t
memoryIndex
=
0
;
memoryIndex
<
memoryCount
;
++
memoryIndex
)
{
const
uint32_t
memoryTypeBits
=
(
1
<<
memoryIndex
);
const
bool
isRequiredMemoryType
=
typeBits
&
memoryTypeBits
;
const
vk
::
MemoryPropertyFlags
properties
=
physicalMemoryProperties
.
memoryTypes
[
memoryIndex
].
propertyFlags
;
const
bool
hasRequiredProperties
=
(
properties
&
requirements
)
==
requirements
;
if
(
isRequiredMemoryType
&&
hasRequiredProperties
)
return
static_cast
<
int32_t
>
(
memoryIndex
);
}
// failed to find memory type
return
-
1
;
}
ImageManager
::
ImageManager
()
noexcept
:
m_core
(
nullptr
),
m_images
()
...
...
@@ -19,10 +38,55 @@ namespace vkcv {
}
}
uint64_t
ImageManager
::
createImage
()
void
ImageManager
::
copyBufferToImage
(
vk
::
Buffer
bufffer
,
vk
::
Image
image
,
uint32_t
width
,
uint32_t
height
)
{
//TODO
}
uint64_t
ImageManager
::
createImage
(
uint32_t
width
,
uint32_t
height
)
{
vk
::
ImageCreateFlags
createFlags
;
vk
::
ImageUsageFlags
imageUsageFlags
=
(
vk
::
ImageUsageFlagBits
::
eSampled
|
vk
::
ImageUsageFlagBits
::
eTransferDst
);
vk
::
Format
format
=
vk
::
Format
::
eR8G8B8A8Unorm
;
// als Argument variabel?
const
vk
::
Device
&
device
=
m_core
->
getContext
().
getDevice
();
vk
::
ImageCreateInfo
imageCreateInfo
(
createFlags
,
vk
::
ImageType
::
e2D
,
format
,
vk
::
Extent3D
(
width
,
height
,
1
),
1
,
1
,
vk
::
SampleCountFlagBits
::
e1
,
vk
::
ImageTiling
::
eOptimal
,
imageUsageFlags
,
vk
::
SharingMode
::
eExclusive
,
{},
vk
::
ImageLayout
::
eUndefined
);
vk
::
Image
image
=
device
.
createImage
(
imageCreateInfo
);
return
uint64_t
();
const
vk
::
MemoryRequirements
requirements
=
device
.
getImageMemoryRequirements
(
image
);
const
vk
::
PhysicalDevice
&
physicalDevice
=
m_core
->
getContext
().
getPhysicalDevice
();
vk
::
MemoryPropertyFlags
memoryTypeFlags
=
vk
::
MemoryPropertyFlagBits
::
eHostVisible
|
vk
::
MemoryPropertyFlagBits
::
eHostCoherent
;
bool
mappable
=
false
;
const
uint32_t
memoryTypeIndex
=
searchMemoryType
(
physicalDevice
.
getMemoryProperties
(),
requirements
.
memoryTypeBits
,
memoryTypeFlags
);
vk
::
DeviceMemory
memory
=
device
.
allocateMemory
(
vk
::
MemoryAllocateInfo
(
requirements
.
size
,
memoryTypeIndex
));
device
.
bindImageMemory
(
image
,
memory
,
0
);
const
uint64_t
id
=
m_images
.
size
();
m_images
.
push_back
({
image
,
memory
,
nullptr
,
mappable
});
return
id
;
}
void
ImageManager
::
destroyImage
(
uint64_t
id
)
...
...
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