mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 07:03:34 +00:00
adding pixel put pipeline
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/01/23 18:40:44 by maldavid #+# #+# */
|
||||
/* Updated: 2023/01/23 18:54:28 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/03/31 17:54:38 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -18,25 +18,30 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
void DescriptorSet::init(Renderer* renderer, UBO* ubo, DescriptorSetLayout& layout, DescriptorPool& pool)
|
||||
void DescriptorSet::init(Renderer* renderer, DescriptorPool* pool, DescriptorSetLayout* layout)
|
||||
{
|
||||
_renderer = renderer;
|
||||
_layout = layout;
|
||||
_pool = pool;
|
||||
|
||||
auto device = Render_Core::get().getDevice().get();
|
||||
|
||||
_pool = pool.get();
|
||||
|
||||
std::array<VkDescriptorSetLayout, MAX_FRAMES_IN_FLIGHT> layouts;
|
||||
layouts.fill(layout.get());
|
||||
layouts.fill(layout->get());
|
||||
|
||||
VkDescriptorSetAllocateInfo allocInfo{};
|
||||
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||
allocInfo.descriptorPool = _pool;
|
||||
allocInfo.descriptorSetCount = MAX_FRAMES_IN_FLIGHT;
|
||||
allocInfo.descriptorPool = _pool->get();
|
||||
allocInfo.descriptorSetCount = static_cast<uint32_t>(MAX_FRAMES_IN_FLIGHT);
|
||||
allocInfo.pSetLayouts = layouts.data();
|
||||
|
||||
if(vkAllocateDescriptorSets(device, &allocInfo, _desc_set.data()) != VK_SUCCESS)
|
||||
core::error::report(e_kind::fatal_error, "Vulkan : failed to allocate descriptor set");
|
||||
}
|
||||
|
||||
void DescriptorSet::writeDescriptor(int binding, UBO* ubo) noexcept
|
||||
{
|
||||
auto device = Render_Core::get().getDevice().get();
|
||||
|
||||
for(int i = 0; i < MAX_FRAMES_IN_FLIGHT; i++)
|
||||
{
|
||||
@@ -48,7 +53,7 @@ namespace mlx
|
||||
VkWriteDescriptorSet descriptorWrite{};
|
||||
descriptorWrite.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
descriptorWrite.dstSet = _desc_set[i];
|
||||
descriptorWrite.dstBinding = 0;
|
||||
descriptorWrite.dstBinding = binding;
|
||||
descriptorWrite.dstArrayElement = 0;
|
||||
descriptorWrite.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
descriptorWrite.descriptorCount = 1;
|
||||
@@ -58,6 +63,34 @@ namespace mlx
|
||||
}
|
||||
}
|
||||
|
||||
void DescriptorSet::writeDescriptor(int binding, VkImageView view, VkSampler sampler) noexcept
|
||||
{
|
||||
auto device = Render_Core::get().getDevice().get();
|
||||
|
||||
VkDescriptorImageInfo imageInfo{};
|
||||
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
imageInfo.imageView = view;
|
||||
imageInfo.sampler = sampler;
|
||||
|
||||
VkWriteDescriptorSet descriptorWrite{};
|
||||
descriptorWrite.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
descriptorWrite.dstSet = _desc_set[_renderer->getActiveImageIndex()];
|
||||
descriptorWrite.dstBinding = binding;
|
||||
descriptorWrite.dstArrayElement = 0;
|
||||
descriptorWrite.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
descriptorWrite.descriptorCount = 1;
|
||||
descriptorWrite.pImageInfo = &imageInfo;
|
||||
|
||||
vkUpdateDescriptorSets(device, 1, &descriptorWrite, 0, nullptr);
|
||||
}
|
||||
|
||||
DescriptorSet DescriptorSet::duplicate()
|
||||
{
|
||||
DescriptorSet set;
|
||||
set.init(_renderer, _pool, _layout);
|
||||
return set;
|
||||
}
|
||||
|
||||
VkDescriptorSet& DescriptorSet::operator()() noexcept
|
||||
{
|
||||
return _desc_set[_renderer->getActiveImageIndex()];
|
||||
@@ -66,9 +99,4 @@ namespace mlx
|
||||
{
|
||||
return _desc_set[_renderer->getActiveImageIndex()];
|
||||
}
|
||||
|
||||
void DescriptorSet::destroy() noexcept
|
||||
{
|
||||
vkFreeDescriptorSets(Render_Core::get().getDevice().get(), _pool, MAX_FRAMES_IN_FLIGHT, _desc_set.data());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user