Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m_gBuffer = {
- m_allocator.createImage(c_windowSize, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_ASPECT_COLOR_BIT),
- m_allocator.createImage(c_windowSize, VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_ASPECT_COLOR_BIT),
- m_allocator.createImage(c_windowSize, VK_FORMAT_R16G16B16A16_SFLOAT, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_ASPECT_COLOR_BIT)
- };
- VkDescriptorSetLayoutBinding gBuffBinding = {};
- gBuffBinding.binding = 0;
- gBuffBinding.descriptorCount = m_gBuffer.size();
- gBuffBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
- gBuffBinding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
- VkDescriptorSetLayoutCreateInfo gBuffInfo = {};
- gBuffInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
- gBuffInfo.pNext = nullptr;
- gBuffInfo.bindingCount = 1;
- gBuffInfo.flags = 0;
- gBuffInfo.pBindings = &gBuffBinding;
- vkCreateDescriptorSetLayout(m_device, &gBuffInfo, nullptr, &m_gBufferSetLayout);
- VkDescriptorSetAllocateInfo allocInfo = {};
- allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
- allocInfo.pNext = nullptr;
- allocInfo.descriptorPool = m_descriptorPool;
- allocInfo.descriptorSetCount = 1;
- allocInfo.pSetLayouts = &m_gBufferSetLayout;
- vkAllocateDescriptorSets(m_device, &allocInfo, &m_gBufferTexturesSet);
- VkSamplerCreateInfo samplerInfo = {};
- samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
- samplerInfo.pNext = nullptr;
- samplerInfo.magFilter = VK_FILTER_LINEAR;
- samplerInfo.minFilter = VK_FILTER_LINEAR;
- samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
- samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
- samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
- samplerInfo.compareOp = VK_COMPARE_OP_NEVER;
- samplerInfo.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
- vkCreateSampler(m_device, &samplerInfo, nullptr, &m_gBufferSampler);
- VkDescriptorImageInfo gBuffImgInfo[m_gBuffer.size()];
- for (uint i = 0; i < m_gBuffer.size(); ++i)
- {
- gBuffImgInfo[i].sampler = m_gBufferSampler;
- gBuffImgInfo[i].imageView = m_gBuffer[i].view;
- gBuffImgInfo[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
- }
- VkWriteDescriptorSet gBuffTextures = {};
- gBuffTextures.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
- gBuffTextures.pNext = nullptr;
- gBuffTextures.dstBinding = 0;
- gBuffTextures.dstSet = m_gBufferTexturesSet;
- gBuffTextures.descriptorCount = m_gBuffer.size();
- gBuffTextures.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
- gBuffTextures.pImageInfo = gBuffImgInfo;
- vkUpdateDescriptorSets(m_device, 1, &gBuffTextures, 0, nullptr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement