Placeholder object for VkPipelineCache While implementing Pipeline Cache is optional, we still need a placeholder object in order to return have a valid handle for this object. b/118386749 Change-Id: I18abb4196fbc99d3f639c1ba14ceb570ac11b365 Reviewed-on: https://swiftshader-review.googlesource.com/c/22729 Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkDestroy.h b/src/Vulkan/VkDestroy.h index b70a17f..b627a3e 100644 --- a/src/Vulkan/VkDestroy.h +++ b/src/Vulkan/VkDestroy.h
@@ -24,6 +24,7 @@ #include "VkImage.hpp" #include "VkInstance.hpp" #include "VkPipeline.hpp" +#include "VkPipelineCache.hpp" #include "VkPipelineLayout.hpp" #include "VkPhysicalDevice.hpp" #include "VkQueue.hpp"
diff --git a/src/Vulkan/VkPipelineCache.hpp b/src/Vulkan/VkPipelineCache.hpp new file mode 100644 index 0000000..6218394 --- /dev/null +++ b/src/Vulkan/VkPipelineCache.hpp
@@ -0,0 +1,47 @@ +// 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. + +#ifndef VK_PIPELINE_CACHE_HPP_ +#define VK_PIPELINE_CACHE_HPP_ + +#include "VkObject.hpp" + +namespace vk +{ + +class PipelineCache : public Object<PipelineCache, VkPipelineCache> +{ +public: + PipelineCache(const VkPipelineCacheCreateInfo* pCreateInfo, void* mem) + { + } + + ~PipelineCache() = delete; + + static size_t ComputeRequiredAllocationSize(const VkPipelineCacheCreateInfo* pCreateInfo) + { + return 0; + } + +private: +}; + +static inline PipelineCache* Cast(VkPipelineCache object) +{ + return reinterpret_cast<PipelineCache*>(object); +} + +} // namespace vk + +#endif // VK_PIPELINE_CACHE_HPP_
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp index fe59570..21466db 100644 --- a/src/Vulkan/libVulkan.cpp +++ b/src/Vulkan/libVulkan.cpp
@@ -29,6 +29,7 @@ #include "VkInstance.hpp" #include "VkPhysicalDevice.hpp" #include "VkPipeline.hpp" +#include "VkPipelineCache.hpp" #include "VkPipelineLayout.hpp" #include "VkQueue.hpp" #include "VkSampler.hpp" @@ -777,15 +778,23 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache) { - TRACE("()"); - UNIMPLEMENTED(); - return VK_SUCCESS; + TRACE("(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache)", + device, pCreateInfo, pAllocator, pPipelineCache); + + if(pCreateInfo->pNext || pCreateInfo->flags) + { + UNIMPLEMENTED(); + } + + return vk::PipelineCache::Create(pAllocator, pCreateInfo, pPipelineCache); } VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator) { - TRACE("()"); - UNIMPLEMENTED(); + TRACE("(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator)", + device, pipelineCache, pAllocator); + + vk::destroy(pipelineCache, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData)
diff --git a/src/Vulkan/vulkan.vcxproj b/src/Vulkan/vulkan.vcxproj index 124d5ed..6d06892 100644 --- a/src/Vulkan/vulkan.vcxproj +++ b/src/Vulkan/vulkan.vcxproj
@@ -208,6 +208,7 @@ <ClInclude Include="VkObject.hpp" /> <ClInclude Include="VkPhysicalDevice.hpp" /> <ClInclude Include="VkPipeline.hpp" /> + <ClInclude Include="VkPipelineCache.hpp" /> <ClInclude Include="VkPipelineLayout.hpp" /> <ClInclude Include="VkQueue.hpp" /> <ClInclude Include="VkRenderPass.hpp" />
diff --git a/src/Vulkan/vulkan.vcxproj.filters b/src/Vulkan/vulkan.vcxproj.filters index 0f86ff6..ec3551e 100644 --- a/src/Vulkan/vulkan.vcxproj.filters +++ b/src/Vulkan/vulkan.vcxproj.filters
@@ -305,6 +305,9 @@ <ClInclude Include="VkPipeline.hpp"> <Filter>Header Files\Vulkan</Filter> </ClInclude> + <ClInclude Include="VkPipelineCache.hpp"> + <Filter>Header Files\Vulkan</Filter> + </ClInclude> <ClInclude Include="VkPipelineLayout.hpp"> <Filter>Header Files\Vulkan</Filter> </ClInclude>