This commit is contained in:
2026-07-22 13:44:17 +02:00
commit f1b4b109b0
4 changed files with 334 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
BeefSpace_User.toml
BeefSpace_Lock.toml
build
recovery
+36
View File
@@ -0,0 +1,36 @@
FileVersion = 1
[Project]
Name = "KTXVulkan"
TargetType = "BeefLib"
StartupObject = "KTXVulkan.Program"
ProcessorMacros = ["KTX_VULKAN"]
[Dependencies]
corlib = "*"
"KTX.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/KTX.git"}
"Vulkan-Beef.git" = {Git = "https://git.unicon-gmbh.de/Rune/Vulkan-Beef.git"}
[Configs.Debug.Win32]
PreBuildCmds = ["CopyFilesIfNewer(\"$(ProjectDir KTX.git)/src/KTXVulkan.bf\", \"$(ProjectDir)/src/\")"]
[Configs.Debug.Win64]
PreBuildCmds = ["CopyFilesIfNewer(\"$(ProjectDir KTX.git)/src/KTXVulkan.bf\", \"$(ProjectDir)/src/\")"]
[Configs.Release.Win32]
PreBuildCmds = ["CopyFilesIfNewer(\"$(ProjectDir KTX.git)/src/KTXVulkan.bf\", \"$(ProjectDir)/src/\")"]
[Configs.Release.Win64]
PreBuildCmds = ["CopyFilesIfNewer(\"$(ProjectDir KTX.git)/src/KTXVulkan.bf\", \"$(ProjectDir)/src/\")"]
[Configs.Paranoid.Win32]
PreBuildCmds = ["CopyFilesIfNewer(\"$(ProjectDir KTX.git)/src/KTXVulkan.bf\", \"$(ProjectDir)/src/\")"]
[Configs.Paranoid.Win64]
PreBuildCmds = ["CopyFilesIfNewer(\"$(ProjectDir KTX.git)/src/KTXVulkan.bf\", \"$(ProjectDir)/src/\")"]
[Configs.Test.Win32]
PreBuildCmds = ["CopyFilesIfNewer(\"$(ProjectDir KTX.git)/src/KTXVulkan.bf\", \"$(ProjectDir)/src/\")"]
[Configs.Test.Win64]
PreBuildCmds = ["CopyFilesIfNewer(\"$(ProjectDir KTX.git)/src/KTXVulkan.bf\", \"$(ProjectDir)/src/\")"]
+9
View File
@@ -0,0 +1,9 @@
FileVersion = 1
[Workspace]
StartupProject = "KTXVulkan"
[Projects]
KTXVulkan = {Path = "."}
"KTX.git" = {Git = "https://git.unicon-gmbh.de/BeefBindings/KTX.git"}
"Vulkan-Beef.git" = {Git = "https://git.unicon-gmbh.de/Rune/Vulkan-Beef.git"}
+285
View File
@@ -0,0 +1,285 @@
// This file was generated by Cpp2Beef
#if KTX_VULKAN
using System;
using System.Interop;
using Vulkan;
namespace KTX;
static
{
/* -*- tab-width: 4; -*- */
/* vi: set sw=2 ts=4 expandtab: */
}
/*
* Copyright 2017-2020 The Khronos Group, Inc.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @internal
* @file
* @~English
*
* @brief Declares the public functions and structures of the
* KTX Vulkan texture loading API.
*
* A separate header file is used to avoid extra dependencies for those not
* using Vulkan. The nature of the Vulkan API, rampant structures and enums,
* means that vulkan.h must be included @e before including this file. The
* alternative is duplicating unattractively large parts of it.
*
* @author Mark Callow, github.com/MarkCallow
*/
/* Avoid Vulkan include file */
/**
* @struct ktxVulkanFunctions
* @~English
* @brief Struct for applications to pass Vulkan function pointers to the
* ktxTexture_VkUpload functions via a ktxVulkanDeviceInfo struct.
*
* @c vkGetInstanceProcAddr and @c vkGetDeviceProcAddr should be set, others
* are optional.
*/
[CRepr] public struct ktxVulkanFunctions {
// These are functions pointers we need to perform our vulkan duties.
public PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr;
public PFN_vkGetDeviceProcAddr vkGetDeviceProcAddr;
// These we optionally specify
public PFN_vkAllocateCommandBuffers vkAllocateCommandBuffers;
public PFN_vkAllocateMemory vkAllocateMemory;
public PFN_vkBeginCommandBuffer vkBeginCommandBuffer;
public PFN_vkBindBufferMemory vkBindBufferMemory;
public PFN_vkBindImageMemory vkBindImageMemory;
public PFN_vkCmdBlitImage vkCmdBlitImage;
public PFN_vkCmdCopyBufferToImage vkCmdCopyBufferToImage;
public PFN_vkCmdPipelineBarrier vkCmdPipelineBarrier;
public PFN_vkCreateImage vkCreateImage;
public PFN_vkDestroyImage vkDestroyImage;
public PFN_vkCreateBuffer vkCreateBuffer;
public PFN_vkDestroyBuffer vkDestroyBuffer;
public PFN_vkCreateFence vkCreateFence;
public PFN_vkDestroyFence vkDestroyFence;
public PFN_vkEndCommandBuffer vkEndCommandBuffer;
public PFN_vkFreeCommandBuffers vkFreeCommandBuffers;
public PFN_vkFreeMemory vkFreeMemory;
public PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements;
public PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements;
public PFN_vkGetImageSubresourceLayout vkGetImageSubresourceLayout;
public PFN_vkGetPhysicalDeviceImageFormatProperties vkGetPhysicalDeviceImageFormatProperties;
public PFN_vkGetPhysicalDeviceFormatProperties vkGetPhysicalDeviceFormatProperties;
public PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties;
public PFN_vkMapMemory vkMapMemory;
public PFN_vkQueueSubmit vkQueueSubmit;
public PFN_vkQueueWaitIdle vkQueueWaitIdle;
public PFN_vkUnmapMemory vkUnmapMemory;
public PFN_vkWaitForFences vkWaitForFences;
}
/**
* @class ktxVulkanTexture
* @~English
* @brief Struct for returning information about the Vulkan texture image
* created by the ktxTexture_VkUpload* functions.
*
* Creation of these objects is internal to the upload functions.
*/
[CRepr] public struct ktxVulkanTexture
{
public PFN_vkDestroyImage vkDestroyImage; /*!< Pointer to vkDestroyImage function */
public PFN_vkFreeMemory vkFreeMemory; /*!< Pointer to vkFreeMemory function */
public VkImage image; /*!< Handle to the Vulkan image created by the loader. */
public VkFormat imageFormat; /*!< Format of the image data. */
public VkImageLayout imageLayout; /*!< Layout of the created image. Has the same
value as @p layout parameter passed to the
loader. */
public VkDeviceMemory deviceMemory; /*!< The memory (sub)allocation for the
image on the Vulkan device. Will not be
used with suballocators.*/
public VkImageViewType viewType; /*!< ViewType corresponding to @p image. Reflects
the dimensionality, cubeness and arrayness
of the image. */
public uint32 width; /*!< The width of the image. */
public uint32 height; /*!< The height of the image. */
public uint32 depth; /*!< The depth of the image. */
public uint32 levelCount; /*!< The number of MIP levels in the image. */
public uint32 layerCount; /*!< The number of array layers in the image. */
public uint64 allocationId; /*!< An id referencing suballocation(s). */
}
[CallingConvention(KTX_APIENTRYP)] public function uint64 ktxVulkanTexture_subAllocatorAllocMemFuncPtr(VkMemoryAllocateInfo* allocInfo, VkMemoryRequirements* memReq, uint64* pageCount);
[CallingConvention(KTX_APIENTRYP)] public function VkResult ktxVulkanTexture_subAllocatorBindBufferFuncPtr(VkBuffer buffer, uint64 allocId);
[CallingConvention(KTX_APIENTRYP)] public function VkResult ktxVulkanTexture_subAllocatorBindImageFuncPtr(VkImage image, uint64 allocId);
[CallingConvention(KTX_APIENTRYP)] public function VkResult ktxVulkanTexture_subAllocatorMemoryMapFuncPtr(uint64 allocId, uint64 pageNumber, VkDeviceSize* mapLength, void** dataPtr);
[CallingConvention(KTX_APIENTRYP)] public function void ktxVulkanTexture_subAllocatorMemoryUnmapFuncPtr(uint64 allocId, uint64 pageNumber);
[CallingConvention(KTX_APIENTRYP)] public function void ktxVulkanTexture_subAllocatorFreeMemFuncPtr(uint64 allocId);
/**
* @class ktxVulkanTexture_subAllocatorCallbacks
* @~English
* @brief Struct that contains all callbacks necessary for suballocation.
*
* These pointers must all be provided for upload or destroy to occur using suballocator callbacks.
*/
[CRepr] public struct ktxVulkanTexture_subAllocatorCallbacks {
public ktxVulkanTexture_subAllocatorAllocMemFuncPtr allocMemFuncPtr; /*!< Pointer to the memory procurement function. Can suballocate one or more pages. */
public ktxVulkanTexture_subAllocatorBindBufferFuncPtr bindBufferFuncPtr; /*!< Pointer to bind-buffer-to-suballocation(s) function. */
public ktxVulkanTexture_subAllocatorBindImageFuncPtr bindImageFuncPtr; /*!< Pointer to bind-image-to-suballocation(s) function. */
public ktxVulkanTexture_subAllocatorMemoryMapFuncPtr memoryMapFuncPtr; /*!< Pointer to function for mapping the memory of a specific page. */
public ktxVulkanTexture_subAllocatorMemoryUnmapFuncPtr memoryUnmapFuncPtr; /*!< Pointer to function for unmapping the memory of a specific page. */
public ktxVulkanTexture_subAllocatorFreeMemFuncPtr freeMemFuncPtr; /*!< Pointer to the free procurement function. */
}
extension ktxVulkanTexture
{
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanTexture_Destruct_WithSuballocator")] public static extern ktx_error_code_e Destruct_WithSuballocator(ktxVulkanTexture* This, VkDevice device, VkAllocationCallbacks* pAllocator, ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanTexture_Destruct")] public static extern void Destruct(ktxVulkanTexture* This, VkDevice device, VkAllocationCallbacks* pAllocator);
}
/**
* @class ktxVulkanDeviceInfo
* @~English
* @brief Struct for passing information about the Vulkan device on which
* to create images to the texture image loading functions.
*
* Avoids passing a large number of parameters to each loading function.
* Use of ktxVulkanDeviceInfo_create() or ktxVulkanDeviceInfo_construct() to
* populate this structure is highly recommended.
*
* @code
ktxVulkanDeviceInfo vdi;
ktxVulkanTexture texture;
vdi = ktxVulkanDeviceInfo_create(physicalDevice,
device,
queue,
cmdPool,
&allocator);
ktxLoadVkTextureN("texture_1.ktx", vdi, &texture, NULL, NULL);
// ...
ktxLoadVkTextureN("texture_n.ktx", vdi, &texture, NULL, NULL);
ktxVulkanDeviceInfo_destroy(vdi);
* @endcode
*/
[CRepr] public struct ktxVulkanDeviceInfo {
public VkInstance instance; /*!< Instance used to communicate with vulkan. */
public VkPhysicalDevice physicalDevice; /*!< Handle of the physical device. */
public VkDevice device; /*!< Handle of the logical device. */
public VkQueue queue; /*!< Handle to the queue to which to submit commands. */
public VkCommandBuffer cmdBuffer; /*!< Handle of the cmdBuffer to use. */
/** Handle of the command pool from which to allocate the command buffer. */
public VkCommandPool cmdPool;
/** Pointer to the allocator to use for the command buffer and created
* images.
*/
public VkAllocationCallbacks* pAllocator;
/** Memory properties of the Vulkan physical device. */
public VkPhysicalDeviceMemoryProperties deviceMemoryProperties;
/** The functions needed to operate functions */
public ktxVulkanFunctions vkFuncs;
}
extension ktxVulkanDeviceInfo
{
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_CreateEx")] public static extern ktxVulkanDeviceInfo* CreateEx(VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, VkCommandPool cmdPool, VkAllocationCallbacks* pAllocator, ktxVulkanFunctions* pFunctions);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_Create")] public static extern ktxVulkanDeviceInfo* Create(VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, VkCommandPool cmdPool, VkAllocationCallbacks* pAllocator);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_Construct")] public static extern ktx_error_code_e Construct(ktxVulkanDeviceInfo* This, VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, VkCommandPool cmdPool, VkAllocationCallbacks* pAllocator);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_ConstructEx")] public static extern ktx_error_code_e ConstructEx(ktxVulkanDeviceInfo* This, VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, VkCommandPool cmdPool, VkAllocationCallbacks* pAllocator, ktxVulkanFunctions* pFunctions);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_Destruct")] public static extern void Destruct(ktxVulkanDeviceInfo* This);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxVulkanDeviceInfo_Destroy")] public static extern void Destroy(ktxVulkanDeviceInfo* This);
}
extension ktxTexture
{
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture_VkUploadEx_WithSuballocator")] public static extern ktx_error_code_e VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout, ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture_VkUploadEx")] public static extern ktx_error_code_e VkUploadEx(ktxTexture* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture_VkUpload")] public static extern ktx_error_code_e VkUpload(ktxTexture* texture, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture);
}
extension ktxTexture1
{
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture1_VkUploadEx_WithSuballocator")] public static extern ktx_error_code_e VkUploadEx_WithSuballocator(ktxTexture1* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout, ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture1_VkUploadEx")] public static extern ktx_error_code_e VkUploadEx(ktxTexture1* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture1_VkUpload")] public static extern ktx_error_code_e VkUpload(ktxTexture1* texture, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture);
}
extension ktxTexture2
{
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture2_VkUploadEx_WithSuballocator")] public static extern ktx_error_code_e VkUploadEx_WithSuballocator(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout, ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture2_VkUploadEx")] public static extern ktx_error_code_e VkUploadEx(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout);
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture2_VkUpload")] public static extern ktx_error_code_e VkUpload(ktxTexture2* texture, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture);
}
extension ktxTexture
{
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture_GetVkFormat")] public static extern VkFormat GetVkFormat(ktxTexture* This);
}
extension ktxTexture1
{
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture1_GetVkFormat")] public static extern VkFormat GetVkFormat(ktxTexture1* This);
}
extension ktxTexture2
{
[CallingConvention(KTX_APIENTRYP)] [LinkName("ktxTexture2_GetVkFormat")] public static extern VkFormat GetVkFormat(ktxTexture2* This);
}
/* KTX_H_A55A6F00956F42F3A137C11929827FE1 */