Browse Source

Vk: Enhance Framebuffer, Image, Pipeline wrap DescriptorPool, DescriptorSet

Signed-off-by: Squareys <squareys@googlemail.com>

More WIP

Signed-off-by: Squareys <squareys@googlemail.com>

WIP

Signed-off-by: Squareys <squareys@googlemail.com>
pull/202/head
Squareys 10 years ago committed by Squareys
parent
commit
62ba27ee31
  1. 5
      src/Magnum/Vk/CMakeLists.txt
  2. 36
      src/Magnum/Vk/DescriptorPool.cpp
  3. 126
      src/Magnum/Vk/DescriptorPool.h
  4. 38
      src/Magnum/Vk/DescriptorSet.cpp
  5. 165
      src/Magnum/Vk/DescriptorSet.h
  6. 4
      src/Magnum/Vk/Framebuffer.cpp
  7. 34
      src/Magnum/Vk/Framebuffer.h
  8. 2
      src/Magnum/Vk/Image.cpp
  9. 25
      src/Magnum/Vk/Image.h
  10. 35
      src/Magnum/Vk/Pipeline.h
  11. 67
      src/Magnum/Vk/ShaderStage.h

5
src/Magnum/Vk/CMakeLists.txt

@ -32,6 +32,8 @@ set(MagnumVk_SRCS
CommandBuffer.cpp CommandBuffer.cpp
CommandPool.cpp CommandPool.cpp
Context.cpp Context.cpp
DescriptorPool.cpp
DescriptorSet.cpp
Device.cpp Device.cpp
DeviceMemory.cpp DeviceMemory.cpp
Framebuffer.cpp Framebuffer.cpp
@ -51,6 +53,8 @@ set(MagnumVk_HEADERS
CommandBuffer.h CommandBuffer.h
CommandPool.h CommandPool.h
Context.h Context.h
DescriptorPool.h
DescriptorSet.h
Device.h Device.h
DeviceMemory.h DeviceMemory.h
Framebuffer.h Framebuffer.h
@ -63,6 +67,7 @@ set(MagnumVk_HEADERS
RenderPass.h RenderPass.h
Semaphore.h Semaphore.h
Shader.h Shader.h
ShaderStage.h
Swapchain.h Swapchain.h
visibility.h) visibility.h)

36
src/Magnum/Vk/DescriptorPool.cpp

@ -0,0 +1,36 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016
Vladimír Vondruš <mosra@centrum.cz>
Copyright © 2016 Jonathan Hale <squareys@googlemail.com>
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.
*/
#include "DescriptorPool.h"
namespace Magnum { namespace Vk {
DescriptorPool::~DescriptorPool() {
vkDestroyDescriptorPool(_device, _descriptorPool, nullptr);
}
}}

126
src/Magnum/Vk/DescriptorPool.h

@ -0,0 +1,126 @@
#ifndef Magnum_Vk_DescriptorPool_h
#define Magnum_Vk_DescriptorPool_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016
Vladimír Vondruš <mosra@centrum.cz>
Copyright © 2016 Jonathan Hale <squareys@googlemail.com>
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.
*/
/** @file
* @brief Class @ref Magnum::Vk::DescriptorPool
*/
#include <Corrade/Containers/Array.h>
#include "Magnum/Magnum.h"
#include "Magnum/Vk/DescriptorSet.h"
#include "Magnum/Vk/Device.h"
#include "Magnum/Vk/visibility.h"
#include "vulkan.h"
namespace Magnum { namespace Vk {
class MAGNUM_VK_EXPORT DescriptorPoolCreateInfo {
friend class DescriptorPool;
public:
DescriptorPoolCreateInfo(Device& device):
_device{device}, _poolSizes{}
{
}
DescriptorPoolCreateInfo& setPoolSize(DescriptorType type, UnsignedInt size) {
_poolSizes.push_back(VkDescriptorPoolSize{VkDescriptorType(type), size});
return *this;
}
private:
Device& _device;
std::vector<VkDescriptorPoolSize> _poolSizes;
};
class MAGNUM_VK_EXPORT DescriptorPool {
public:
DescriptorPool(Device& device, UnsignedLong maxSets, const DescriptorPoolCreateInfo& ci):
_device{device}
{
VkDescriptorPoolCreateInfo createInfo = {
VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, nullptr, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
maxSets,
ci._poolSizes.size(), ci._poolSizes.data()
};
VkResult err = vkCreateDescriptorPool(_device, &createInfo, nullptr, &_descriptorPool);
MAGNUM_VK_ASSERT_ERROR(err);
}
/** @brief Copying is not allowed */
DescriptorPool(const DescriptorPool&) = delete;
/** @brief Move constructor */
DescriptorPool(DescriptorPool&& other);
/**
* @brief Destructor
*
* @see @fn_vk{DestroyDescriptorPool}
*/
~DescriptorPool();
/** @brief Copying is not allowed */
DescriptorPool& operator=(const DescriptorPool&) = delete;
/** @brief Move assignment is not allowed */
DescriptorPool& operator=(DescriptorPool&&) = delete;
operator VkDescriptorPool() const {
return _descriptorPool;
}
std::unique_ptr<DescriptorSet> allocateDescriptorSet(const DescriptorSetLayout& layout) {
VkDescriptorSetLayout vkLayout = layout;
VkDescriptorSetAllocateInfo allocateInfo = {
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, nullptr,
*this,
1,
&vkLayout
};
VkDescriptorSet set;
VkResult err = vkAllocateDescriptorSets(_device, &allocateInfo, &set);
MAGNUM_VK_ASSERT_ERROR(err);
return std::unique_ptr<DescriptorSet>(new DescriptorSet{_device, *this, set});
}
private:
Device& _device;
VkDescriptorPool _descriptorPool;
};
}}
#endif

38
src/Magnum/Vk/DescriptorSet.cpp

@ -0,0 +1,38 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016
Vladimír Vondruš <mosra@centrum.cz>
Copyright © 2016 Jonathan Hale <squareys@googlemail.com>
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.
*/
#include "DescriptorSet.h"
#include "Magnum/Vk/DescriptorPool.h"
namespace Magnum { namespace Vk {
DescriptorSet::~DescriptorSet() {
vkFreeDescriptorSets(_device, _pool, 1, &_descriptorSet);
}
}}

165
src/Magnum/Vk/DescriptorSet.h

@ -0,0 +1,165 @@
#ifndef Magnum_Vk_DescriptorSet_h
#define Magnum_Vk_DescriptorSet_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016
Vladimír Vondruš <mosra@centrum.cz>
Copyright © 2016 Jonathan Hale <squareys@googlemail.com>
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.
*/
/** @file
* @brief Class @ref Magnum::Vk::DescriptorSet
*/
#include <Corrade/Containers/Array.h>
#include "Magnum/Magnum.h"
#include "Magnum/Vk/Device.h"
#include "Magnum/Vk/visibility.h"
#include "Magnum/Vk/ShaderStage.h"
#include "vulkan.h"
namespace Magnum { namespace Vk {
class DescriptorPool;
class ShadereStageFlags;
enum class DescriptorType: UnsignedInt {
Sampler = VK_DESCRIPTOR_TYPE_SAMPLER,
CombinedImageSampler = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
SampledImage = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
StorageImage = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
UniformTexelBuffer = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
StorageTexelBuffer = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
UniformBuffer = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
StorageBuffer = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
UniformBufferDynamic = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
StorageBufferDynamic = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
InputAttachment = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
};
struct DescriptorSetLayoutBinding {
public:
DescriptorSetLayoutBinding(UnsignedInt binding, DescriptorType type,
UnsignedInt descriptorsCount, ShaderStageFlags flags): // TODO: Immutable samplers
_layoutBinding{
binding, VkDescriptorType(type), descriptorsCount,
VkShaderStageFlags(flags), nullptr
}
{}
private:
VkDescriptorSetLayoutBinding _layoutBinding;
};
class MAGNUM_VK_EXPORT DescriptorSetLayout {
public:
DescriptorSetLayout(Device& device,
std::initializer_list<DescriptorSetLayoutBinding> bindings):
_device{device}
{
const std::vector<DescriptorSetLayoutBinding> bndgs{bindings};
VkDescriptorSetLayoutCreateInfo descLayout = {
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
nullptr, 0,
bndgs.size(),
reinterpret_cast<const VkDescriptorSetLayoutBinding*>(bndgs.data())
};
VkResult err = vkCreateDescriptorSetLayout(_device, &descLayout, nullptr, &_layout);
}
/** @brief Copying is not allowed */
DescriptorSetLayout(const DescriptorSetLayout&) = delete;
/** @brief Move constructor */
DescriptorSetLayout(DescriptorSetLayout&& other);
/**
* @brief Destructor
*
* @see @fn_vk{DestroyDescriptorSet}
*/
~DescriptorSetLayout() {
vkDestroyDescriptorSetLayout(_device, _layout, nullptr);
}
/** @brief Copying is not allowed */
DescriptorSetLayout& operator=(const DescriptorSetLayout&) = delete;
/** @brief Move assignment is not allowed */
DescriptorSetLayout& operator=(DescriptorSetLayout&&) = delete;
operator VkDescriptorSetLayout() const {
return _layout;
}
private:
Device& _device;
VkDescriptorSetLayout _layout;
};
class MAGNUM_VK_EXPORT DescriptorSet {
public:
DescriptorSet(Device& device, DescriptorPool& pool, VkDescriptorSet vkDescriptorSet):
_device{device},
_pool{pool},
_descriptorSet{vkDescriptorSet}
{
}
/** @brief Copying is not allowed */
DescriptorSet(const DescriptorSet&) = delete;
/** @brief Move constructor */
DescriptorSet(DescriptorSet&& other);
/**
* @brief Destructor
*
* @see @fn_vk{DestroyDescriptorSet}
*/
~DescriptorSet();
/** @brief Copying is not allowed */
DescriptorSet& operator=(const DescriptorSet&) = delete;
/** @brief Move assignment is not allowed */
DescriptorSet& operator=(DescriptorSet&&) = delete;
operator VkDescriptorSet() const {
return _descriptorSet;
}
private:
Device& _device;
DescriptorPool& _pool;
VkDescriptorSet _descriptorSet;
};
}}
#endif

4
src/Magnum/Vk/Framebuffer.cpp

@ -30,6 +30,10 @@
namespace Magnum { namespace Vk { namespace Magnum { namespace Vk {
Framebuffer::~Framebuffer() { Framebuffer::~Framebuffer() {
// TODO: The spec allowes VK_NULL_HANDLE for _framebuffer, but validation failes?
if (_framebuffer == VK_NULL_HANDLE) {
return;
}
vkDestroyFramebuffer(_device, _framebuffer, nullptr); vkDestroyFramebuffer(_device, _framebuffer, nullptr);
} }

34
src/Magnum/Vk/Framebuffer.h

@ -43,33 +43,39 @@ namespace Magnum { namespace Vk {
class MAGNUM_VK_EXPORT Framebuffer { class MAGNUM_VK_EXPORT Framebuffer {
public: public:
Framebuffer(Device& device, RenderPass& renderPass, Vector2ui size, std::initializer_list<Vk::ImageView>& attachments): Framebuffer(Device& device, RenderPass& renderPass, const Vector3ui& size,
const std::initializer_list<std::reference_wrapper<const Vk::ImageView>>& attachments):
_device{device} _device{device}
{ {
std::vector<VkImageView> vkAttachments; std::vector<VkImageView> vkAttachments;
vkAttachments.reserve(attachments.size()); vkAttachments.reserve(attachments.size());
for (auto& imageView : attachments) { for (auto& imageView : attachments) {
vkAttachments.push_back(imageView); vkAttachments.push_back(imageView.get());
} }
VkFramebufferCreateInfo createInfo = {}; VkFramebufferCreateInfo createInfo = {
createInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
createInfo.pNext = nullptr; nullptr, 0,
createInfo.renderPass = renderPass; renderPass,
createInfo.attachmentCount = attachments.size(); vkAttachments.size(),
createInfo.pAttachments = vkAttachments.data(); vkAttachments.data(),
createInfo.width = size.x(); size.x(), size.y(), size.z()
createInfo.height = size.y(); };
createInfo.layers = 1;
VkResult err = vkCreateFramebuffer(_device, &createInfo, nullptr, &_framebuffer);
vkCreateFramebuffer(_device, &createInfo, nullptr, &_framebuffer); MAGNUM_VK_ASSERT_ERROR(err);
} }
/** @brief Copying is not allowed */ /** @brief Copying is not allowed */
Framebuffer(const Framebuffer&) = delete; Framebuffer(const Framebuffer&) = delete;
/** @brief Move constructor */ /** @brief Move constructor */
Framebuffer(Framebuffer&& other); Framebuffer(Framebuffer&& other):
_device{other._device},
_framebuffer{other._framebuffer}
{
other._framebuffer = VK_NULL_HANDLE;
}
/** /**
* @brief Destructor * @brief Destructor

2
src/Magnum/Vk/Image.cpp

@ -30,7 +30,9 @@
namespace Magnum { namespace Vk { namespace Magnum { namespace Vk {
Image::~Image() { Image::~Image() {
if(_flags >= ObjectFlag::DeleteOnDestruction) {
vkDestroyImage(_device, _image, nullptr); vkDestroyImage(_device, _image, nullptr);
} }
}
}} }}

25
src/Magnum/Vk/Image.h

@ -34,6 +34,7 @@
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/Math/Vector3.h" #include "Magnum/Math/Vector3.h"
#include "Magnum/Vk/Device.h" #include "Magnum/Vk/Device.h"
#include "Magnum/Vk/DeviceMemory.h"
#include "Magnum/Vk/Math.h" #include "Magnum/Vk/Math.h"
#include "Magnum/Vk/visibility.h" #include "Magnum/Vk/visibility.h"
@ -94,15 +95,27 @@ enum class ImageLayout: UnsignedInt {
PresentSrc = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, PresentSrc = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
}; };
enum class ObjectFlag: UnsignedByte {
/** Delete the object on destruction. */
DeleteOnDestruction = 1 << 1
};
typedef Containers::EnumSet<ObjectFlag> ObjectFlags;
CORRADE_ENUMSET_OPERATORS(ObjectFlags)
class MAGNUM_VK_EXPORT Image { class MAGNUM_VK_EXPORT Image {
public: public:
Image(Device& device, VkImage vkImage): Image(Device& device, VkImage vkImage):
_device{device}, _device{device},
_image{vkImage} _image{vkImage},
_flags{}
{} {}
Image(Device& device, Vector3ui extent, VkFormat format, ImageUsageFlags usage): _device{device} { Image(Device& device, Vector3ui extent, VkFormat format, ImageUsageFlags usage):
_device{device}, _flags{ObjectFlag::DeleteOnDestruction}
{
VkImageCreateInfo image = {}; VkImageCreateInfo image = {};
image.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; image.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
image.flags = 0; image.flags = 0;
@ -150,9 +163,17 @@ class MAGNUM_VK_EXPORT Image {
return memReqs; return memReqs;
} }
Image& bindImageMemory(DeviceMemory& memory, UnsignedLong memoryOffset=0) {
VkResult err = vkBindImageMemory(_device, _image, memory, memoryOffset);
MAGNUM_VK_ASSERT_ERROR(err);
return *this;
}
private: private:
Device& _device; Device& _device;
VkImage _image; VkImage _image;
ObjectFlags _flags;
}; };
struct ImageMemoryBarrier { struct ImageMemoryBarrier {

35
src/Magnum/Vk/Pipeline.h

@ -36,6 +36,7 @@
#include "Magnum/Vk/Device.h" #include "Magnum/Vk/Device.h"
#include "Magnum/Vk/RenderPass.h" #include "Magnum/Vk/RenderPass.h"
#include "Magnum/Vk/Shader.h" #include "Magnum/Vk/Shader.h"
#include "Magnum/Vk/DescriptorSet.h"
#include "Magnum/Math/Vector3.h" // TEMPORARY!!! #include "Magnum/Math/Vector3.h" // TEMPORARY!!!
@ -45,16 +46,7 @@
namespace Magnum { namespace Vk { namespace Magnum { namespace Vk {
enum class ShaderStage: UnsignedInt { class DescriptorSetLayout;
Vertex = VK_SHADER_STAGE_VERTEX_BIT,
TesslationControl = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
TesslationEvaluation = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
Geometry = VK_SHADER_STAGE_GEOMETRY_BIT,
Fragment = VK_SHADER_STAGE_FRAGMENT_BIT,
Compute = VK_SHADER_STAGE_COMPUTE_BIT,
AllGraphics = VK_SHADER_STAGE_ALL_GRAPHICS,
All = VK_SHADER_STAGE_ALL,
};
enum class DynamicState: UnsignedInt { enum class DynamicState: UnsignedInt {
Viewport = VK_DYNAMIC_STATE_VIEWPORT, Viewport = VK_DYNAMIC_STATE_VIEWPORT,
@ -147,13 +139,30 @@ class MAGNUM_VK_EXPORT Pipeline {
return _layout; return _layout;
} }
auto bind(BindPoint bindPoint, std::initializer_list<VkDescriptorSet> descriptorSets) { auto bind(BindPoint bindPoint) {
const VkPipeline pipeline = _pipeline;
return [bindPoint, pipeline](VkCommandBuffer cmdBuffer){
vkCmdBindPipeline(cmdBuffer,
VkPipelineBindPoint(bindPoint),
pipeline);
};
}
auto bindDescriptorSets(BindPoint bindPoint, std::initializer_list<std::reference_wrapper<DescriptorSet>> descriptorSets) {
const VkPipelineLayout pl = _layout; const VkPipelineLayout pl = _layout;
return [bindPoint, &descriptorSets, pl](VkCommandBuffer cmdBuffer){ return [bindPoint, &descriptorSets, pl](VkCommandBuffer cmdBuffer){
std::vector<VkDescriptorSet> vkDescriptorSets{};
vkDescriptorSets.reserve(descriptorSets.size());
for (auto& ds : descriptorSets) {
vkDescriptorSets.push_back(VkDescriptorSet(ds.get()));
}
vkCmdBindDescriptorSets(cmdBuffer, vkCmdBindDescriptorSets(cmdBuffer,
VkPipelineBindPoint(bindPoint), VkPipelineBindPoint(bindPoint),
pl, 0, pl, 0,
descriptorSets.size(), std::vector<VkDescriptorSet>(descriptorSets).data(), descriptorSets.size(), vkDescriptorSets.data(),
0, nullptr); 0, nullptr);
}; };
} }
@ -333,7 +342,7 @@ class MAGNUM_VK_EXPORT GraphicsPipelineFactory {
return *this; return *this;
} }
GraphicsPipelineFactory& addDescriptorSetLayout(const VkDescriptorSetLayout& layout) { GraphicsPipelineFactory& addDescriptorSetLayout(const DescriptorSetLayout& layout) {
_setLayouts.push_back(layout); _setLayouts.push_back(layout);
return *this; return *this;
} }

67
src/Magnum/Vk/ShaderStage.h

@ -0,0 +1,67 @@
#ifndef Magnum_Vk_ShaderStage_h
#define Magnum_Vk_ShaderStage_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016
Vladimír Vondruš <mosra@centrum.cz>
Copyright © 2016 Jonathan Hale <squareys@googlemail.com>
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.
*/
/** @file
* @brief Class @ref Magnum::Vk::ShaderStage
*/
#include "Magnum/Magnum.h"
#include "Magnum/Vk/visibility.h"
#include "Magnum/Vk/Device.h"
#include "Magnum/Vk/RenderPass.h"
#include "Magnum/Vk/Shader.h"
#include "Magnum/Vk/DescriptorSet.h"
#include "Magnum/Math/Vector3.h" // TEMPORARY!!!
#include <Corrade/Containers/Array.h>
#include "vulkan.h"
namespace Magnum { namespace Vk {
enum class ShaderStage: UnsignedInt {
Vertex = VK_SHADER_STAGE_VERTEX_BIT,
TesslationControl = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
TesslationEvaluation = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
Geometry = VK_SHADER_STAGE_GEOMETRY_BIT,
Fragment = VK_SHADER_STAGE_FRAGMENT_BIT,
Compute = VK_SHADER_STAGE_COMPUTE_BIT,
AllGraphics = VK_SHADER_STAGE_ALL_GRAPHICS,
All = VK_SHADER_STAGE_ALL,
};
typedef Containers::EnumSet<ShaderStage> ShaderStageFlags;
CORRADE_ENUMSET_OPERATORS(ShaderStageFlags)
}}
#endif
Loading…
Cancel
Save