Home | History | Annotate | Download | only in vulkan
      1 /*-------------------------------------------------------------------------
      2  * Vulkan CTS Framework
      3  * --------------------
      4  *
      5  * Copyright (c) 2015 Google Inc.
      6  *
      7  * Licensed under the Apache License, Version 2.0 (the "License");
      8  * you may not use this file except in compliance with the License.
      9  * You may obtain a copy of the License at
     10  *
     11  *      http://www.apache.org/licenses/LICENSE-2.0
     12  *
     13  * Unless required by applicable law or agreed to in writing, software
     14  * distributed under the License is distributed on an "AS IS" BASIS,
     15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16  * See the License for the specific language governing permissions and
     17  * limitations under the License.
     18  *
     19  *//*!
     20  * \file
     21  * \brief Vulkan object reference holder utilities.
     22  *//*--------------------------------------------------------------------*/
     23 
     24 #include "vkRefUtil.hpp"
     25 
     26 namespace vk
     27 {
     28 
     29 #include "vkRefUtilImpl.inl"
     30 
     31 Move<VkPipeline> createGraphicsPipeline (const DeviceInterface&					vk,
     32 										 VkDevice								device,
     33 										 VkPipelineCache						pipelineCache,
     34 										 const VkGraphicsPipelineCreateInfo*	pCreateInfo,
     35 										 const VkAllocationCallbacks*			pAllocator)
     36 {
     37 	VkPipeline object = 0;
     38 	VK_CHECK(vk.createGraphicsPipelines(device, pipelineCache, 1u, pCreateInfo, pAllocator, &object));
     39 	return Move<VkPipeline>(check<VkPipeline>(object), Deleter<VkPipeline>(vk, device, pAllocator));
     40 }
     41 
     42 Move<VkPipeline> createComputePipeline (const DeviceInterface&				vk,
     43 										VkDevice							device,
     44 										VkPipelineCache						pipelineCache,
     45 										const VkComputePipelineCreateInfo*	pCreateInfo,
     46 										const VkAllocationCallbacks*		pAllocator)
     47 {
     48 	VkPipeline object = 0;
     49 	VK_CHECK(vk.createComputePipelines(device, pipelineCache, 1u, pCreateInfo, pAllocator, &object));
     50 	return Move<VkPipeline>(check<VkPipeline>(object), Deleter<VkPipeline>(vk, device, pAllocator));
     51 }
     52 
     53 Move<VkCommandBuffer> allocateCommandBuffer (const DeviceInterface& vk, VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo)
     54 {
     55 	VkCommandBuffer object = 0;
     56 	DE_ASSERT(pAllocateInfo->commandBufferCount == 1u);
     57 	VK_CHECK(vk.allocateCommandBuffers(device, pAllocateInfo, &object));
     58 	return Move<VkCommandBuffer>(check<VkCommandBuffer>(object), Deleter<VkCommandBuffer>(vk, device, pAllocateInfo->commandPool));
     59 }
     60 
     61 Move<VkDescriptorSet> allocateDescriptorSet (const DeviceInterface& vk, VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo)
     62 {
     63 	VkDescriptorSet object = 0;
     64 	DE_ASSERT(pAllocateInfo->descriptorSetCount == 1u);
     65 	VK_CHECK(vk.allocateDescriptorSets(device, pAllocateInfo, &object));
     66 	return Move<VkDescriptorSet>(check<VkDescriptorSet>(object), Deleter<VkDescriptorSet>(vk, device, pAllocateInfo->descriptorPool));
     67 }
     68 
     69 } // vk
     70