mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
* Fix enqueue_flags test to use correct barrier type. Currently, enqueue_flags test uses CLK_LOCAL_MEM_FENCE. Use CLK_GLOBAL_MEM_FENCE instead as all threads across work-groups need to wait here. * Add check for support for Read-Wrie images Read-Write images have required OpenCL 2.x. Read-Write image tests are already being skipped for 1.x devices. With OpenCL 3.0, read-write images being optional, the tests should be run or skipped depending on the implementation support. Add a check to decide if Read-Write images are supported or required to be supported depending on OpenCL version and decide if the tests should be run on skipped. Fixes issue #894 * Fix formatting in case of Read-Write image checks. Fix formatting in case of Read-write image checks. Also, combine two ifs into one in case of kerne_read_write tests * Fix some more formatting for RW-image checks Remove unnecessary spaces at various places. Also, fix lengthy lines. * Fix malloc-size calculation in test imagedim unsigned char size is silently assumed to be 1 in imagedim test of test_basic. Pass sizeof(type) in malloc size calculation. Also, change loop variable from signed to unsigned. Add checks for null pointer for malloced memory. * Initial CTS for external sharing extensions Initial set of tests for below extensions with Vulkan as producer 1. cl_khr_external_memory 2. cl_khr_external_memory_win32 3. cl_khr_external_memory_opaque_fd 4. cl_khr_external_semaphore 5. cl_khr_external_semaphore_win32 6. cl_khr_external_semaphore_opaque_fd * Updates to external sharing CTS Updates to external sharing CTS 1. Fix some build issues to remove unnecessary, non-existent files 2. Add new tests for platform and device queries. 3. Some added checks for VK Support. * Update CTS build script for Vulkan Headers Update CTS build to clone Vulkan Headers repo and pass it to CTS build in preparation for external memory and semaphore tests * Fix Vulkan header path Fix Vulkan header include path. * Add Vulkan loader dependency Vulkan loader is required to build test_vulkan of OpenCL-CTS. Clone and build Vulkan loader as prerequisite to OpenCL-CTS. * Fix Vulkan loader path in test_vulkan Remove arch/os suffix in Vulkan loader path to match vulkan loader repo build. * Fix warnings around getHandle API. Return type of getHandle is defined differently based on win or linux builds. Use appropriate guards when using API at other places. While at it remove duplicate definition of ARRAY_SIZE. * Use ARRAY_SIZE in harness. Use already defined ARRAY_SIZE macro from test_harness. * Fix build issues for test_vulkan Fix build issues for test_vulkan 1. Add cl_ext.h in common files 2. Replace cl_mem_properties_khr with cl_mem_properties 3. Replace cl_external_mem_handle_type_khr with cl_external_memory_handle_type_khr 4. Type-cast malloc as required. * Fix code formatting. Fix code formatting to get CTS CI builds clean. * Fix formatting fixes part-2 Another set of formatting fixes. * Fix code formatting part-3 Some more code formatting fixes. * Fix code formatting issues part-4 More code formatting fixes. * Formatting fixes part-5 Some more formatting fixes * Fix formatting part-6 More formatting fixes continued. * Code formatting fixes part-7 Code formatting fixes for image * Code formatting fixes part-8 Fixes for platform and device query tests. * Code formatting fixes part-9 More formatting fixes for vulkan_wrapper * Code formatting fixes part-10 More fixes to wrapper header * Code formatting fixes part-11 Formatting fixes for api_list * Code formatting fixes part-12 Formatting fixes for api_list_map. * Code formatting changes part-13 Code formatting changes for utility. * Code formatting fixes part-15 Formatting fixes for wrapper. * Misc Code formatting fixes Some more misc code formatting fixes. * Fix build breaks due to code formatting Fix build issues arised with recent code formatting issues. * Fix presubmit script after merge Fix presubmit script after merge conflicts. * Fix Vulkan loader build in presubmit script. Use cmake ninja and appropriate toolchain for Vulkan loader dependency to fix linking issue on arm/aarch64. * Use static array sizes Use static array sizes to fix windows builds. * Some left-out formatting fixes. Fix remaining formatting issues. * Fix harness header path Fix harness header path While at it, remove Misc and test pragma. * Add/Fix license information Add Khronos License info for test_vulkan. Replace Apple license with Khronos as applicable. * Fix headers for Mac OSX builds. Use appropriate headers for Mac OSX builds * Fix Mac OSX builds. Use appropriate headers for Mac OSX builds. Also, fix some build issues due to type-casting. * Fix new code formatting issues Fix new code formatting issues with recent MacOS fixes. * Add back missing case statement Add back missing case statement that was accidentally removed. * Disable USE_GAS for Vulkan Loader build. Disable USE_GAS for Vulkan Loader build to fix aarch64 build. * Fixes to OpenCL external sharing tests Fix clReleaseSemaphore() API. Fix copyright year. Some other minor fixes. * Improvements to OpenCL external sharing CTS Use SPIR-V shaders instead of NV extension path from GLSL to Vulkan shaders. Fixes for lower end GPUs to use limited memory. Update copy-right year at some more places. * Fix new code formatting issues. Fix code formatting issues with recent changes for external sharing tests. * More formatting fixes. More formatting fixes for recent updates to external sharing tests. * Final code formatting fixes. Minor formatting fixes to get format checks clean.
581 lines
20 KiB
C++
581 lines
20 KiB
C++
//
|
|
// Copyright (c) 2022 The Khronos Group Inc.
|
|
//
|
|
// 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 _vulkan_wrapper_hpp_
|
|
#define _vulkan_wrapper_hpp_
|
|
|
|
#include <vulkan/vulkan.h>
|
|
#include "vulkan_wrapper_types.hpp"
|
|
#include "vulkan_list_map.hpp"
|
|
#include "vulkan_api_list.hpp"
|
|
|
|
class VulkanInstance {
|
|
friend const VulkanInstance &getVulkanInstance();
|
|
|
|
protected:
|
|
VkInstance m_vkInstance;
|
|
VulkanPhysicalDeviceList m_physicalDeviceList;
|
|
|
|
VulkanInstance();
|
|
VulkanInstance(const VulkanInstance &);
|
|
virtual ~VulkanInstance();
|
|
|
|
public:
|
|
const VulkanPhysicalDeviceList &getPhysicalDeviceList() const;
|
|
operator VkInstance() const;
|
|
};
|
|
|
|
class VulkanPhysicalDevice {
|
|
friend class VulkanInstance;
|
|
|
|
protected:
|
|
VkPhysicalDevice m_vkPhysicalDevice;
|
|
VkPhysicalDeviceProperties m_vkPhysicalDeviceProperties;
|
|
uint8_t m_vkDeviceUUID[VK_UUID_SIZE];
|
|
uint8_t m_vkDeviceLUID[VK_LUID_SIZE];
|
|
uint32_t m_vkDeviceNodeMask;
|
|
VkPhysicalDeviceFeatures m_vkPhysicalDeviceFeatures;
|
|
VkPhysicalDeviceMemoryProperties m_vkPhysicalDeviceMemoryProperties;
|
|
VulkanQueueFamilyList m_queueFamilyList;
|
|
VulkanMemoryHeapList m_memoryHeapList;
|
|
VulkanMemoryTypeList m_memoryTypeList;
|
|
|
|
VulkanPhysicalDevice(const VulkanPhysicalDevice &physicalDevice);
|
|
VulkanPhysicalDevice(VkPhysicalDevice vkPhysicalDevice);
|
|
virtual ~VulkanPhysicalDevice();
|
|
|
|
public:
|
|
const VulkanQueueFamilyList &getQueueFamilyList() const;
|
|
const VulkanMemoryHeapList &getMemoryHeapList() const;
|
|
const VulkanMemoryTypeList &getMemoryTypeList() const;
|
|
const uint8_t *getUUID() const;
|
|
const uint8_t *getLUID() const;
|
|
uint32_t getNodeMask() const;
|
|
operator VkPhysicalDevice() const;
|
|
};
|
|
|
|
class VulkanMemoryHeap {
|
|
friend class VulkanPhysicalDevice;
|
|
|
|
protected:
|
|
uint32_t m_memoryHeapIndex;
|
|
uint64_t m_size;
|
|
VulkanMemoryHeapFlag m_memoryHeapFlag;
|
|
|
|
VulkanMemoryHeap(const VulkanMemoryHeap &memoryHeap);
|
|
VulkanMemoryHeap(uint32_t m_memoryHeapIndex, uint64_t m_size,
|
|
VulkanMemoryHeapFlag m_memoryHeapFlag);
|
|
virtual ~VulkanMemoryHeap();
|
|
|
|
public:
|
|
uint64_t getSize() const;
|
|
VulkanMemoryHeapFlag getMemoryHeapFlag() const;
|
|
operator uint32_t() const;
|
|
};
|
|
|
|
class VulkanMemoryType {
|
|
friend class VulkanPhysicalDevice;
|
|
|
|
protected:
|
|
uint32_t m_memoryTypeIndex;
|
|
const VulkanMemoryTypeProperty m_memoryTypeProperty;
|
|
const VulkanMemoryHeap &m_memoryHeap;
|
|
|
|
VulkanMemoryType(const VulkanMemoryType &memoryType);
|
|
VulkanMemoryType(uint32_t memoryTypeIndex,
|
|
VulkanMemoryTypeProperty memoryTypeProperty,
|
|
const VulkanMemoryHeap &memoryHeap);
|
|
virtual ~VulkanMemoryType();
|
|
|
|
public:
|
|
VulkanMemoryTypeProperty getMemoryTypeProperty() const;
|
|
const VulkanMemoryHeap &getMemoryHeap() const;
|
|
operator uint32_t() const;
|
|
};
|
|
|
|
class VulkanQueueFamily {
|
|
friend class VulkanPhysicalDevice;
|
|
|
|
protected:
|
|
uint32_t m_queueFamilyIndex;
|
|
VkQueueFamilyProperties m_vkQueueFamilyProperties;
|
|
|
|
VulkanQueueFamily(const VulkanQueueFamily &queueFamily);
|
|
VulkanQueueFamily(uint32_t queueFamilyIndex,
|
|
VkQueueFamilyProperties vkQueueFamilyProperties);
|
|
virtual ~VulkanQueueFamily();
|
|
|
|
public:
|
|
uint32_t getQueueFlags() const;
|
|
uint32_t getQueueCount() const;
|
|
operator uint32_t() const;
|
|
};
|
|
|
|
class VulkanDevice {
|
|
protected:
|
|
const VulkanPhysicalDevice &m_physicalDevice;
|
|
VkDevice m_vkDevice;
|
|
VulkanQueueFamilyToQueueListMap m_queueFamilyIndexToQueueListMap;
|
|
|
|
VulkanDevice(const VulkanDevice &device);
|
|
|
|
public:
|
|
VulkanDevice(
|
|
const VulkanPhysicalDevice &physicalDevice = getVulkanPhysicalDevice(),
|
|
const VulkanQueueFamilyToQueueCountMap &queueFamilyToQueueCountMap =
|
|
getDefaultVulkanQueueFamilyToQueueCountMap());
|
|
virtual ~VulkanDevice();
|
|
const VulkanPhysicalDevice &getPhysicalDevice() const;
|
|
VulkanQueue &
|
|
getQueue(const VulkanQueueFamily &queueFamily = getVulkanQueueFamily(),
|
|
uint32_t queueIndex = 0);
|
|
operator VkDevice() const;
|
|
};
|
|
|
|
class VulkanQueue {
|
|
friend class VulkanDevice;
|
|
|
|
protected:
|
|
VkQueue m_vkQueue;
|
|
|
|
VulkanQueue(VkQueue vkQueue);
|
|
VulkanQueue(const VulkanQueue &queue);
|
|
virtual ~VulkanQueue();
|
|
|
|
public:
|
|
const VulkanQueueFamily &getQueueFamily();
|
|
void submit(const VulkanSemaphoreList &waitSemaphoreList,
|
|
const VulkanCommandBufferList &commandBufferList,
|
|
const VulkanSemaphoreList &signalSemaphoreList);
|
|
void submit(const VulkanSemaphore &waitSemaphore,
|
|
const VulkanCommandBuffer &commandBuffer,
|
|
const VulkanSemaphore &signalSemaphore);
|
|
void submit(const VulkanCommandBuffer &commandBuffer,
|
|
const VulkanSemaphore &signalSemaphore);
|
|
void submit(const VulkanCommandBuffer &commandBuffer);
|
|
void waitIdle();
|
|
operator VkQueue() const;
|
|
};
|
|
|
|
class VulkanDescriptorSetLayoutBinding {
|
|
protected:
|
|
VkDescriptorSetLayoutBinding m_vkDescriptorSetLayoutBinding;
|
|
|
|
VulkanDescriptorSetLayoutBinding(
|
|
const VulkanDescriptorSetLayoutBinding &descriptorSetLayoutBinding);
|
|
|
|
public:
|
|
VulkanDescriptorSetLayoutBinding(
|
|
uint32_t binding, VulkanDescriptorType descriptorType,
|
|
uint32_t descriptorCount = 1,
|
|
VulkanShaderStage shaderStage = VULKAN_SHADER_STAGE_COMPUTE);
|
|
virtual ~VulkanDescriptorSetLayoutBinding();
|
|
operator VkDescriptorSetLayoutBinding() const;
|
|
};
|
|
|
|
class VulkanDescriptorSetLayout {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
VkDescriptorSetLayout m_vkDescriptorSetLayout;
|
|
|
|
VulkanDescriptorSetLayout(
|
|
const VulkanDescriptorSetLayout &descriptorSetLayout);
|
|
void
|
|
VulkanDescriptorSetLayoutCommon(const VulkanDescriptorSetLayoutBindingList
|
|
&descriptorSetLayoutBindingList);
|
|
|
|
public:
|
|
VulkanDescriptorSetLayout(
|
|
const VulkanDevice &device,
|
|
const VulkanDescriptorSetLayoutBinding &descriptorSetLayoutBinding);
|
|
VulkanDescriptorSetLayout(
|
|
const VulkanDevice &device,
|
|
const VulkanDescriptorSetLayoutBinding &descriptorSetLayoutBinding0,
|
|
const VulkanDescriptorSetLayoutBinding &descriptorSetLayoutBinding1);
|
|
VulkanDescriptorSetLayout(const VulkanDevice &device,
|
|
const VulkanDescriptorSetLayoutBindingList
|
|
&descriptorSetLayoutBindingList);
|
|
virtual ~VulkanDescriptorSetLayout();
|
|
operator VkDescriptorSetLayout() const;
|
|
};
|
|
|
|
class VulkanPipelineLayout {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
VkPipelineLayout m_vkPipelineLayout;
|
|
|
|
VulkanPipelineLayout(const VulkanPipelineLayout &pipelineLayout);
|
|
void VulkanPipelineLayoutCommon(
|
|
const VulkanDescriptorSetLayoutList &descriptorSetLayoutList);
|
|
|
|
public:
|
|
VulkanPipelineLayout(const VulkanDevice &device,
|
|
const VulkanDescriptorSetLayout &descriptorSetLayout);
|
|
VulkanPipelineLayout(
|
|
const VulkanDevice &device,
|
|
const VulkanDescriptorSetLayoutList &descriptorSetLayoutList =
|
|
getEmptyVulkanDescriptorSetLayoutList());
|
|
virtual ~VulkanPipelineLayout();
|
|
operator VkPipelineLayout() const;
|
|
};
|
|
|
|
class VulkanShaderModule {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
VkShaderModule m_vkShaderModule;
|
|
|
|
VulkanShaderModule(const VulkanShaderModule &shaderModule);
|
|
|
|
public:
|
|
VulkanShaderModule(const VulkanDevice &device,
|
|
const std::vector<char> &code);
|
|
virtual ~VulkanShaderModule();
|
|
operator VkShaderModule() const;
|
|
};
|
|
|
|
class VulkanPipeline {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
VkPipeline m_vkPipeline;
|
|
|
|
VulkanPipeline(const VulkanPipeline &pipeline);
|
|
|
|
public:
|
|
VulkanPipeline(const VulkanDevice &device);
|
|
virtual ~VulkanPipeline();
|
|
virtual VulkanPipelineBindPoint getPipelineBindPoint() const = 0;
|
|
operator VkPipeline() const;
|
|
};
|
|
|
|
class VulkanComputePipeline : public VulkanPipeline {
|
|
protected:
|
|
VulkanComputePipeline(const VulkanComputePipeline &computePipeline);
|
|
|
|
public:
|
|
VulkanComputePipeline(const VulkanDevice &device,
|
|
const VulkanPipelineLayout &pipelineLayout,
|
|
const VulkanShaderModule &shaderModule,
|
|
const std::string &entryFuncName = "main");
|
|
virtual ~VulkanComputePipeline();
|
|
VulkanPipelineBindPoint getPipelineBindPoint() const;
|
|
};
|
|
|
|
class VulkanDescriptorPool {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
VkDescriptorPool m_vkDescriptorPool;
|
|
|
|
VulkanDescriptorPool(const VulkanDescriptorPool &descriptorPool);
|
|
void VulkanDescriptorPoolCommon(const VulkanDescriptorSetLayoutBindingList
|
|
&descriptorSetLayoutBindingList);
|
|
|
|
public:
|
|
VulkanDescriptorPool(
|
|
const VulkanDevice &device,
|
|
const VulkanDescriptorSetLayoutBinding &descriptorSetLayoutBinding);
|
|
VulkanDescriptorPool(
|
|
const VulkanDevice &device,
|
|
const VulkanDescriptorSetLayoutBinding &descriptorSetLayoutBinding0,
|
|
const VulkanDescriptorSetLayoutBinding &descriptorSetLayoutBinding1);
|
|
VulkanDescriptorPool(const VulkanDevice &device,
|
|
const VulkanDescriptorSetLayoutBindingList
|
|
&descriptorSetLayoutBindingList);
|
|
virtual ~VulkanDescriptorPool();
|
|
operator VkDescriptorPool() const;
|
|
};
|
|
|
|
class VulkanDescriptorSet {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
const VulkanDescriptorPool &m_descriptorPool;
|
|
VkDescriptorSet m_vkDescriptorSet;
|
|
|
|
VulkanDescriptorSet(const VulkanDescriptorSet &descriptorSet);
|
|
|
|
public:
|
|
VulkanDescriptorSet(const VulkanDevice &device,
|
|
const VulkanDescriptorPool &descriptorPool,
|
|
const VulkanDescriptorSetLayout &descriptorSetLayout);
|
|
virtual ~VulkanDescriptorSet();
|
|
void update(uint32_t binding, const VulkanBuffer &buffer);
|
|
void update(uint32_t binding, const VulkanImageView &imageView);
|
|
operator VkDescriptorSet() const;
|
|
};
|
|
|
|
class VulkanOffset3D {
|
|
protected:
|
|
VkOffset3D m_vkOffset3D;
|
|
|
|
public:
|
|
VulkanOffset3D(const VulkanOffset3D &extent3D);
|
|
VulkanOffset3D(uint32_t x = 0, uint32_t y = 0, uint32_t z = 0);
|
|
virtual ~VulkanOffset3D();
|
|
uint32_t getX() const;
|
|
uint32_t getY() const;
|
|
uint32_t getZ() const;
|
|
operator VkOffset3D() const;
|
|
};
|
|
|
|
class VulkanExtent3D {
|
|
protected:
|
|
VkExtent3D m_vkExtent3D;
|
|
|
|
public:
|
|
VulkanExtent3D(const VulkanExtent3D &extent3D);
|
|
VulkanExtent3D(uint32_t width, uint32_t height = 1, uint32_t depth = 1);
|
|
virtual ~VulkanExtent3D();
|
|
uint32_t getWidth() const;
|
|
uint32_t getHeight() const;
|
|
uint32_t getDepth() const;
|
|
operator VkExtent3D() const;
|
|
};
|
|
|
|
class VulkanCommandPool {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
VkCommandPool m_vkCommandPool;
|
|
|
|
VulkanCommandPool(const VulkanCommandPool &commandPool);
|
|
|
|
public:
|
|
VulkanCommandPool(
|
|
const VulkanDevice &device,
|
|
const VulkanQueueFamily &queueFamily = getVulkanQueueFamily());
|
|
virtual ~VulkanCommandPool();
|
|
operator VkCommandPool() const;
|
|
};
|
|
|
|
class VulkanCommandBuffer {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
const VulkanCommandPool &m_commandPool;
|
|
VkCommandBuffer m_vkCommandBuffer;
|
|
|
|
VulkanCommandBuffer(const VulkanCommandBuffer &commandBuffer);
|
|
|
|
public:
|
|
VulkanCommandBuffer(const VulkanDevice &device,
|
|
const VulkanCommandPool &commandPool);
|
|
virtual ~VulkanCommandBuffer();
|
|
void begin();
|
|
void bindPipeline(const VulkanPipeline &pipeline);
|
|
void bindDescriptorSets(const VulkanPipeline &pipeline,
|
|
const VulkanPipelineLayout &pipelineLayout,
|
|
const VulkanDescriptorSet &descriptorSet);
|
|
void pipelineBarrier(const VulkanImage2DList &image2DList,
|
|
VulkanImageLayout oldImageLayout,
|
|
VulkanImageLayout newImageLayout);
|
|
void dispatch(uint32_t groupCountX, uint32_t groupCountY,
|
|
uint32_t groupCountZ);
|
|
void fillBuffer(const VulkanBuffer &buffer, uint32_t data,
|
|
uint64_t offset = 0, uint64_t size = VK_WHOLE_SIZE);
|
|
void updateBuffer(const VulkanBuffer &buffer, void *pdata,
|
|
uint64_t offset = 0, uint64_t size = VK_WHOLE_SIZE);
|
|
void copyBufferToImage(const VulkanBuffer &buffer, const VulkanImage &image,
|
|
VulkanImageLayout imageLayout =
|
|
VULKAN_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
|
void copyBufferToImage(const VulkanBuffer &buffer, const VulkanImage &image,
|
|
uint64_t bufferOffset = 0, uint32_t mipLevel = 0,
|
|
uint32_t baseArrayLayer = 0, uint32_t layerCount = 1,
|
|
VulkanOffset3D offset3D = VulkanOffset3D(0, 0, 0),
|
|
VulkanExtent3D extent3D = VulkanExtent3D(0, 0, 0));
|
|
void copyImageToBuffer(const VulkanImage &image, const VulkanBuffer &buffer,
|
|
uint64_t bufferOffset = 0, uint32_t mipLevel = 0,
|
|
uint32_t baseArrayLayer = 0, uint32_t layerCount = 1,
|
|
VulkanOffset3D offset3D = VulkanOffset3D(0, 0, 0),
|
|
VulkanExtent3D extent3D = VulkanExtent3D(0, 0, 0));
|
|
void end();
|
|
operator VkCommandBuffer() const;
|
|
};
|
|
|
|
class VulkanBuffer {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
VkBuffer m_vkBuffer;
|
|
uint64_t m_size;
|
|
uint64_t m_alignment;
|
|
VulkanMemoryTypeList m_memoryTypeList;
|
|
|
|
VulkanBuffer(const VulkanBuffer &buffer);
|
|
|
|
public:
|
|
VulkanBuffer(const VulkanDevice &device, uint64_t size,
|
|
VulkanExternalMemoryHandleType externalMemoryHandleType =
|
|
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
|
|
VulkanBufferUsage bufferUsage =
|
|
VULKAN_BUFFER_USAGE_STORAGE_BUFFER_TRANSFER_SRC_DST,
|
|
VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE,
|
|
const VulkanQueueFamilyList &queueFamilyList =
|
|
getEmptyVulkanQueueFamilyList());
|
|
virtual ~VulkanBuffer();
|
|
uint64_t getSize() const;
|
|
uint64_t getAlignment() const;
|
|
const VulkanMemoryTypeList &getMemoryTypeList() const;
|
|
operator VkBuffer() const;
|
|
};
|
|
|
|
class VulkanImage {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
const VulkanImageType m_imageType;
|
|
const VulkanExtent3D m_extent3D;
|
|
const VulkanFormat m_format;
|
|
const uint32_t m_numMipLevels;
|
|
const uint32_t m_numLayers;
|
|
VkImage m_vkImage;
|
|
uint64_t m_size;
|
|
uint64_t m_alignment;
|
|
VulkanMemoryTypeList m_memoryTypeList;
|
|
VkImageCreateInfo VulkanImageCreateInfo;
|
|
VulkanImage(const VulkanImage &image);
|
|
|
|
public:
|
|
VulkanImage(
|
|
const VulkanDevice &device, VulkanImageType imageType,
|
|
VulkanFormat format, const VulkanExtent3D &extent3D,
|
|
uint32_t numMipLevels = 1, uint32_t arrayLayers = 1,
|
|
VulkanExternalMemoryHandleType externalMemoryHandleType =
|
|
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
|
|
VulkanImageCreateFlag imageCreateFlags = VULKAN_IMAGE_CREATE_FLAG_NONE,
|
|
VulkanImageTiling imageTiling = VULKAN_IMAGE_TILING_OPTIMAL,
|
|
VulkanImageUsage imageUsage =
|
|
VULKAN_IMAGE_USAGE_SAMPLED_STORAGE_TRANSFER_SRC_DST,
|
|
VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE);
|
|
virtual ~VulkanImage();
|
|
virtual VulkanExtent3D getExtent3D(uint32_t mipLevel = 0) const;
|
|
VulkanFormat getFormat() const;
|
|
uint32_t getNumMipLevels() const;
|
|
uint32_t getNumLayers() const;
|
|
uint64_t getSize() const;
|
|
uint64_t getAlignment() const;
|
|
const VulkanMemoryTypeList &getMemoryTypeList() const;
|
|
VkImageCreateInfo getVkImageCreateInfo() const;
|
|
operator VkImage() const;
|
|
};
|
|
|
|
class VulkanImage2D : public VulkanImage {
|
|
protected:
|
|
VkImageView m_vkImageView;
|
|
|
|
VulkanImage2D(const VulkanImage2D &image2D);
|
|
|
|
public:
|
|
VulkanImage2D(
|
|
const VulkanDevice &device, VulkanFormat format, uint32_t width,
|
|
uint32_t height, uint32_t numMipLevels = 1,
|
|
VulkanExternalMemoryHandleType externalMemoryHandleType =
|
|
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
|
|
VulkanImageCreateFlag imageCreateFlag = VULKAN_IMAGE_CREATE_FLAG_NONE,
|
|
VulkanImageUsage imageUsage =
|
|
VULKAN_IMAGE_USAGE_SAMPLED_STORAGE_TRANSFER_SRC_DST,
|
|
VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE);
|
|
virtual ~VulkanImage2D();
|
|
virtual VulkanExtent3D getExtent3D(uint32_t mipLevel = 0) const;
|
|
};
|
|
|
|
class VulkanImageView {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
VkImageView m_vkImageView;
|
|
|
|
VulkanImageView(const VulkanImageView &imageView);
|
|
|
|
public:
|
|
VulkanImageView(const VulkanDevice &device, const VulkanImage &image,
|
|
VulkanImageViewType imageViewType,
|
|
uint32_t baseMipLevel = 0,
|
|
uint32_t mipLevelCount = VULKAN_REMAINING_MIP_LEVELS,
|
|
uint32_t baseArrayLayer = 0,
|
|
uint32_t layerCount = VULKAN_REMAINING_ARRAY_LAYERS);
|
|
virtual ~VulkanImageView();
|
|
operator VkImageView() const;
|
|
};
|
|
|
|
class VulkanDeviceMemory {
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
VkDeviceMemory m_vkDeviceMemory;
|
|
uint64_t m_size;
|
|
bool m_isDedicated;
|
|
|
|
VulkanDeviceMemory(const VulkanDeviceMemory &deviceMemory);
|
|
|
|
public:
|
|
VulkanDeviceMemory(const VulkanDevice &device, uint64_t size,
|
|
const VulkanMemoryType &memoryType,
|
|
VulkanExternalMemoryHandleType externalMemoryHandleType =
|
|
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
|
|
const void *name = NULL);
|
|
VulkanDeviceMemory(const VulkanDevice &device, const VulkanImage &image,
|
|
const VulkanMemoryType &memoryType,
|
|
VulkanExternalMemoryHandleType externalMemoryHandleType =
|
|
VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE,
|
|
const void *name = NULL);
|
|
virtual ~VulkanDeviceMemory();
|
|
uint64_t getSize() const;
|
|
#ifdef _WIN32
|
|
HANDLE
|
|
getHandle(VulkanExternalMemoryHandleType externalMemoryHandleType) const;
|
|
#else
|
|
int
|
|
getHandle(VulkanExternalMemoryHandleType externalMemoryHandleType) const;
|
|
#endif
|
|
bool isDedicated() const;
|
|
void *map(size_t offset = 0, size_t size = VK_WHOLE_SIZE);
|
|
void unmap();
|
|
void bindBuffer(const VulkanBuffer &buffer, uint64_t offset = 0);
|
|
void bindImage(const VulkanImage &image, uint64_t offset = 0);
|
|
operator VkDeviceMemory() const;
|
|
};
|
|
|
|
class VulkanSemaphore {
|
|
friend class VulkanQueue;
|
|
|
|
protected:
|
|
const VulkanDevice &m_device;
|
|
VkSemaphore m_vkSemaphore;
|
|
const std::wstring m_name;
|
|
|
|
VulkanSemaphore(const VulkanSemaphore &semaphore);
|
|
|
|
public:
|
|
VulkanSemaphore(
|
|
const VulkanDevice &device,
|
|
VulkanExternalSemaphoreHandleType externalSemaphoreHandleType =
|
|
VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NONE,
|
|
const std::wstring name = L"");
|
|
virtual ~VulkanSemaphore();
|
|
#ifdef _WIN32
|
|
HANDLE getHandle(
|
|
VulkanExternalSemaphoreHandleType externalSemaphoreHandleType) const;
|
|
#else
|
|
int getHandle(
|
|
VulkanExternalSemaphoreHandleType externalSemaphoreHandleType) const;
|
|
#endif
|
|
const std::wstring &getName() const;
|
|
operator VkSemaphore() const;
|
|
};
|
|
|
|
|
|
#define VK_FUNC_DECL(name) extern "C" PFN_##name _##name;
|
|
VK_FUNC_LIST
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
VK_WINDOWS_FUNC_LIST
|
|
#endif
|
|
#undef VK_FUNC_DECL
|
|
|
|
#endif // _vulkan_wrapper_hpp_
|