void initialize(VkDescriptorSet descriptorSet);
size_t getSize() const;
size_t getBindingOffset(uint32_t binding) const;
+ uint8_t* getOffsetPointer(VkDescriptorSet descriptorSet, uint32_t binding, uint32_t arrayElement, uint32_t count, size_t* typeSize) const;
private:
uint32_t getBindingIndex(uint32_t binding) const;
- uint8_t* getOffsetPointer(VkDescriptorSet descriptorSet, uint32_t binding, uint32_t arrayElement, uint32_t count, size_t* typeSize) const;
static const uint8_t* GetInputData(const VkWriteDescriptorSet& descriptorWrites);
VkDescriptorSetLayoutCreateFlags flags;
--- /dev/null
+// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "VkDescriptorUpdateTemplate.hpp"
+#include "VkDescriptorSetLayout.hpp"
+#include <cstring>
+
+namespace vk
+{
+ DescriptorUpdateTemplate::DescriptorUpdateTemplate(const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, void* mem) :\r
+ descriptorUpdateEntryCount(pCreateInfo->descriptorUpdateEntryCount),\r
+ descriptorUpdateEntries(reinterpret_cast<VkDescriptorUpdateTemplateEntry*>(mem)),\r
+ descriptorSetLayout(Cast(pCreateInfo->descriptorSetLayout))\r
+ {\r
+ for(uint32_t i = 0; i < descriptorUpdateEntryCount; i++)\r
+ {\r
+ descriptorUpdateEntries[i] = pCreateInfo->pDescriptorUpdateEntries[i];\r
+ }\r
+ }\r
+\r
+ size_t DescriptorUpdateTemplate::ComputeRequiredAllocationSize(const VkDescriptorUpdateTemplateCreateInfo* info)\r
+ {\r
+ return info->descriptorUpdateEntryCount * sizeof(VkDescriptorUpdateTemplateEntry);\r
+ }\r
+\r
+ void DescriptorUpdateTemplate::updateDescriptorSet(VkDescriptorSet descriptorSet, const void* pData)\r
+ {
+ for(uint32_t i = 0; i < descriptorUpdateEntryCount; i++)
+ {
+ for(uint32_t j = 0; j < descriptorUpdateEntries[i].descriptorCount; j++)
+ {
+ const char *memToRead = (const char *)pData + descriptorUpdateEntries[i].offset + j * descriptorUpdateEntries[i].stride;
+ size_t typeSize = 0;
+ uint8_t* memToWrite = descriptorSetLayout->getOffsetPointer(
+ descriptorSet, descriptorUpdateEntries[i].dstBinding, descriptorUpdateEntries[i].dstArrayElement, 1, &typeSize);
+ memcpy(memToWrite, memToRead, typeSize);
+ }
+ }\r
+ }
+}
\ No newline at end of file
--- /dev/null
+// Copyright 2018 The SwiftShader Authors. All Rights Reserved.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
+#ifndef VK_DESCRIPTOR_UPDATE_TEMPLATE_HPP_\r
+#define VK_DESCRIPTOR_UPDATE_TEMPLATE_HPP_\r
+\r
+#include "VkObject.hpp"\r
+\r
+namespace vk\r
+{\r
+ class DescriptorSetLayout;\r
+\r
+ class DescriptorUpdateTemplate : public Object<DescriptorUpdateTemplate, VkDescriptorUpdateTemplate>\r
+ {\r
+ public:\r
+ DescriptorUpdateTemplate(const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, void* mem);\r
+ ~DescriptorUpdateTemplate() = delete;\r
+\r
+ static size_t ComputeRequiredAllocationSize(const VkDescriptorUpdateTemplateCreateInfo* info);\r
+\r
+ void updateDescriptorSet(VkDescriptorSet descriptorSet, const void* pData);\r
+\r
+ private:\r
+ uint32_t descriptorUpdateEntryCount = 0;\r
+ VkDescriptorUpdateTemplateEntry* descriptorUpdateEntries = nullptr;\r
+ DescriptorSetLayout* descriptorSetLayout = nullptr;\r
+ };\r
+\r
+ static inline DescriptorUpdateTemplate* Cast(VkDescriptorUpdateTemplate object)\r
+ {\r
+ return reinterpret_cast<DescriptorUpdateTemplate*>(object);\r
+ }\r
+\r
+} // namespace vk\r
+\r
+#endif // VK_DESCRIPTOR_UPDATE_TEMPLATE_HPP_\r
#include "VkDebug.hpp"
#include "VkDescriptorPool.hpp"
#include "VkDescriptorSetLayout.hpp"
+#include "VkDescriptorUpdateTemplate.hpp"
#include "VkDestroy.h"
#include "VkDevice.hpp"
#include "VkDeviceMemory.hpp"
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplate(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate)
{
- TRACE("()");
- UNIMPLEMENTED();
- return VK_SUCCESS;
+ TRACE("(VkDevice device = 0x%X, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate = 0x%X)",
+ device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate);
+
+ if(pCreateInfo->pNext || pCreateInfo->flags || (pCreateInfo->templateType != VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET))
+ {
+ UNIMPLEMENTED();
+ }
+
+ return vk::DescriptorUpdateTemplate::Create(pAllocator, pCreateInfo, pDescriptorUpdateTemplate);
}
VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplate(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks* pAllocator)
{
- TRACE("()");
- UNIMPLEMENTED();
+ TRACE("(VkDevice device = 0x%X, VkDescriptorUpdateTemplate descriptorUpdateTemplate = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
+ device, descriptorUpdateTemplate, pAllocator);
+
+ vk::destroy(descriptorUpdateTemplate, pAllocator);
}
VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplate(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void* pData)
{
- TRACE("()");
- UNIMPLEMENTED();
+ TRACE("(VkDevice device = 0x%X, VkDescriptorSet descriptorSet = 0x%X, VkDescriptorUpdateTemplate descriptorUpdateTemplate = 0x%X, const void* pData = 0x%X)",
+ device, descriptorSet, descriptorUpdateTemplate, pData);
+
+ vk::Cast(descriptorUpdateTemplate)->updateDescriptorSet(descriptorSet, pData);
}
VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties)
<ClCompile Include="VkDebug.cpp" />\r
<ClCompile Include="VkDescriptorPool.cpp" />\r
<ClCompile Include="VkDescriptorSetLayout.cpp" />\r
+ <ClCompile Include="VkDescriptorUpdateTemplate.cpp" />\r
<ClCompile Include="VkDevice.cpp" />\r
<ClCompile Include="VkDeviceMemory.cpp" />\r
<ClCompile Include="VkFramebuffer.cpp" />\r
<ClInclude Include="VkDebug.hpp" />\r
<ClInclude Include="VkDescriptorPool.hpp" />\r
<ClInclude Include="VkDescriptorSetLayout.hpp" />\r
+ <ClInclude Include="VkDescriptorUpdateTemplate.hpp" />\r
<ClInclude Include="VkDestroy.h" />\r
<ClInclude Include="VkDevice.hpp" />\r
<ClInclude Include="VkDeviceMemory.hpp" />\r
<ClCompile Include="VkDescriptorSetLayout.cpp">\r
<Filter>Source Files\Vulkan</Filter>\r
</ClCompile>\r
+ <ClCompile Include="VkDescriptorUpdateTemplate.cpp">\r
+ <Filter>Source Files\Vulkan</Filter>\r
+ </ClCompile>\r
<ClCompile Include="VkDevice.cpp">\r
<Filter>Source Files\Vulkan</Filter>\r
</ClCompile>\r
<ClInclude Include="VkDescriptorSetLayout.hpp">\r
<Filter>Header Files\Vulkan</Filter>\r
</ClInclude>\r
+ <ClInclude Include="VkDescriptorUpdateTemplate.hpp">\r
+ <Filter>Header Files\Vulkan</Filter>\r
+ </ClInclude>\r
<ClInclude Include="VkDevice.hpp">\r
<Filter>Header Files\Vulkan</Filter>\r
</ClInclude>\r