Commit 8c1e8f1f by Alexis Hetu Committed by Alexis Hétu

PipelineLayout implementation

Initial basic implementation of PipelineLayout. The information stored in the PipelineLayout will be used, among other things, to properly bind descriptor sets affected by a dynamic offset. Bug b/118386749 Change-Id: I05fa6f9c7740cf79a802a5276e2d88f6e6e4ebe7 Reviewed-on: https://swiftshader-review.googlesource.com/c/24948Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 1776af77
......@@ -13,21 +13,35 @@
// limitations under the License.
#include "VkPipelineLayout.hpp"
#include <cstring>
namespace vk
{
PipelineLayout::PipelineLayout(const VkPipelineLayoutCreateInfo* pCreateInfo, void* mem)
: setLayoutCount(pCreateInfo->setLayoutCount), pushConstantRangeCount(pCreateInfo->pushConstantRangeCount)
{
char* hostMem = reinterpret_cast<char*>(mem);
size_t setLayoutsSize = pCreateInfo->setLayoutCount * sizeof(DescriptorSetLayout*);
setLayouts = reinterpret_cast<DescriptorSetLayout**>(hostMem);
memcpy(setLayouts, pCreateInfo->pSetLayouts, setLayoutsSize); // Assumes Cast(VkDescriptorSetLayout) is nothing but a cast
hostMem += setLayoutsSize;
size_t pushConstantRangesSize = pCreateInfo->pushConstantRangeCount * sizeof(VkPushConstantRange);
pushConstantRanges = reinterpret_cast<VkPushConstantRange*>(hostMem);
memcpy(pushConstantRanges, pCreateInfo->pPushConstantRanges, pushConstantRangesSize);
}
void PipelineLayout::destroy(const VkAllocationCallbacks* pAllocator)
{
vk::deallocate(setLayouts, pAllocator); // pushConstantRanges are in the same allocation
}
size_t PipelineLayout::ComputeRequiredAllocationSize(const VkPipelineLayoutCreateInfo* pCreateInfo)
{
return 0;
return (pCreateInfo->setLayoutCount * sizeof(DescriptorSetLayout*)) +
(pCreateInfo->pushConstantRangeCount * sizeof(VkPushConstantRange));
}
} // namespace vk
......@@ -15,7 +15,7 @@
#ifndef VK_PIPELINE_LAYOUT_HPP_
#define VK_PIPELINE_LAYOUT_HPP_
#include "VkObject.hpp"
#include "VkDescriptorSetLayout.hpp"
namespace vk
{
......@@ -30,6 +30,10 @@ public:
static size_t ComputeRequiredAllocationSize(const VkPipelineLayoutCreateInfo* pCreateInfo);
private:
uint32_t setLayoutCount = 0;
DescriptorSetLayout** setLayouts = nullptr;
uint32_t pushConstantRangeCount = 0;
VkPushConstantRange* pushConstantRanges = nullptr;
};
static inline PipelineLayout* Cast(VkPipelineLayout object)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment