amerkoleci / vortice.vulkan Goto Github PK
View Code? Open in Web Editor NEWCross platform .NET bindings for Vulkan, VMA, SPIRV-Cross and shaderc
License: MIT License
Cross platform .NET bindings for Vulkan, VMA, SPIRV-Cross and shaderc
License: MIT License
Unlike spvc_resources_get_resource_list_for_type
this function doesn't offer a out
variable so I'm supposed to provide it a pointer, of presumably a reasonably sized spvc_combined_image_sampler
buffer.
However doing
spvc_combined_image_sampler* samplers = stackalloc spvc_combined_image_sampler[25];
SpirvCrossApi.spvc_compiler_get_combined_image_samplers(compiler, samplers, &samplerCount).CheckResult();
doesn't work, and
spvc_combined_image_sampler[] samplers = new spvc_combined_image_sampler[25];
SpirvCrossApi.spvc_compiler_get_combined_image_samplers(compiler, (spvc_combined_image_sampler*)Unsafe.AsPointer(ref samplers), &samplerCount).CheckResult();
almost works, but the array is short of four uints, or one struct+1 field
One thing I noticed is function signatures differ, and the C++ side works with SmallVector.
C
SPVC_PUBLIC_API spvc_result spvc_compiler_get_combined_image_samplers(spvc_compiler compiler,
const spvc_combined_image_sampler **samplers,
size_t *num_samplers);
C#
public unsafe spvc_result spvc_compiler_get_combined_image_samplers(spvc_compiler compiler,
spvc_combined_image_sampler* samplers,
nuint* num_samplers)
num_samplers is correctly set to 7
Hi,
I was unable to get Android Vulkan code working with Vortice.Vulkan. However, if I comment out the dlerror() call in the UnixLoader.LoadNativeLibrary method then it works without problem (see the commit in https://github.com/taumuon/Vortice.Vulkan ).
Is there a reason this call is there? Can it be fixed (I have forked Vortice.Vulkan to make this change but I'd prefer to reference the official version on Nuget).
The sample code is here: https://github.com/taumuon/TexturedCube-Vortice
Thanks,
Gary
Could not load type 'Vortice.Vulkan.vkDebugUtilsMessengerCallbackEXT' from assembly 'Vortice.Vulkan, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null'.'
Error is there from 1.3.0 -> current version
My experience using these bindings was very smooth up until I had to map some memory allocated with VMA. I used Vma.vmaCreateBuffer
to allocate a buffer, and I expected to find a function along the lines of Vma.vmaMapMemory
that would allow me to map the buffer, like how VMA is used in C++. I couldn't find that function or any alternative. Is this function missing or is there another way to do this? Thanks!
Edit:
I also couldn't find the corresponding vmaUnmapMemory
.
Seems wrong values for flags Libdl.RTLD_NOW and Libdl.RTLD_LOCAL on my linux system
When trying to build/set up this Vulkan I get: error MSB4237: The SDK resolver
type "DotNetMSBuildSdkResolver" failed to load. The type initializer for 'Microsoft.DotNet.MSBuildSdkResolver.VSSettin
gs' threw an exception. And I don't what to do.
What gives?
Stack overflow.
Repeat 31860 times:
--------------------------------
at Vortice.Vulkan.Vulkan.vkCmdSetViewport[[Vortice.Vulkan.VkViewport, Vortice.Vulkan, Version=1.5.13.0, Culture=neutral, PublicKeyToken=5431ec61a7e925da]](Vortice.Vulkan.VkCommandBuffer, UInt32, UInt32, Vortice.Vulkan.VkViewport*)
I'll try with 1.5.15 and see if anything is different.
[05:45:59 DBG] App run
[05:46:00 DBG] Glfw inited
[05:46:00 DBG] Vulkan supported
[05:46:00 DBG] vulkan lib initialized
[05:46:00 DBG] vk instance creating...
[05:46:00 DBG] vk instance created
[05:46:00 DBG] vk instance loading...
[05:46:00 DBG] vk instance loaded
[05:46:00 DBG] instance created
[05:46:00 DBG] surface created
[05:46:00 DBG] device picked
[05:46:00 DBG] logical device created
[05:46:00 DBG] swapchain created
[05:46:00 DBG] imageViews created
[05:46:00 DBG] render pass created
[05:46:00 DBG] buffers created
[05:46:00 DBG] command pool created
[05:46:00 DBG] command buffers created
[05:46:00 DBG] descriptor sets created
[05:46:00 DBG] read shader bytes...
[05:46:00 DBG] shader bytes readed
[05:46:00 DBG] shader models created
[05:46:00 DBG] graphics pipeline layout creating...
[05:46:00 DBG] graphics pipeline layout created
[05:46:00 DBG] graphics pipeline creating...
Segmentation fault
my application runs fine on windows, but on linux there is a memory error when creating a graphical pipeline:
Vulkan.VkCreateGraphicsPipeline
LibraryLoader was rolled back reintroducing #17. If the old code is needed, fall back to the new code before doing nothing.
Let me know if the old code is needed and I can work on merging the new code in.
vkBeginCommandBuffer takes in flags, but then just sets OneTimeSubmit anyway?
Vortice.Vulkan/src/Vortice.Vulkan/Vulkan.cs
Lines 459 to 468 in 620d2ec
Hi,
Any news here?
I would like to know if the library will be handwritten or generated by the vk.xml, I would like to help if it is handwritten and based on structures
shaderc_shared.dll is not found when compiling shaders. It was working on my development machine but not on a build server. I found that the code in LibraryLoader
was not finding the file and falling back to the OS default and was finding it in the Vulkan SDK folder which is in PATH
.
I verified this by using this code:
IntPtr handle;
#if NETSTANDARD2_0
handle = LoadPlatformLibrary(libraryPath);
#else
handle = NativeLibrary.Load(libraryPath);
#endif
if (handle == IntPtr.Zero)
throw new DllNotFoundException($"Unable to load library '{libraryName}'.");
var sbPath = new StringBuilder(1024);
var count = Win32.GetModuleFileNameA(handle, sbPath, sbPath.Capacity);
Console.WriteLine(sbPath);
[DllImport(SystemLibrary, SetLastError = true, CharSet = CharSet.Ansi)]
public static extern int GetModuleFileNameA(IntPtr hModule, StringBuilder lpFileName, int nSize);
The "blendConstants" argument of the "vkCmdSetBlendConstants" command must be a pointer to float.
current command signature:
void vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, float blendConstants);
valid command signature:
void vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, float* blendConstants);
Hi,
As Vortice.Windows has Dxc, I think this is the best place for Shaderc ,
I can send PR.
Cheers,
Faber
auto size_cpp = sizeof(VkAccelerationStructureMatrixMotionInstanceNV);
size_cpp == 112
var vortice_s = sizeof(Vortice.Vulkan.VkAccelerationStructureMatrixMotionInstanceNV);
vortice_s == 120
typedef struct VkAccelerationStructureMatrixMotionInstanceNV {
VkTransformMatrixKHR transformT0;
VkTransformMatrixKHR transformT1;
uint32_t instanceCustomIndex:24;
uint32_t mask:8;
uint32_t instanceShaderBindingTableRecordOffset:24;
VkGeometryInstanceFlagsKHR flags:8;
uint64_t accelerationStructureReference;
}
The struct might be handled manually
// Handled manually.
if (cppClass.Name == "VkClearColorValue"
|| cppClass.Name == "VkTransformMatrixKHR"
|| cppClass.Name == "VkAccelerationStructureInstanceKHR"
)
{
continue;
}
The struct "VkAccelerationStructureSRTMotionInstanceNV" has similar problem;
Hi Amer,
I found an issue with VkAccelerationStructureInstanceKHR struct in Vortice.Vulkan. The size of this struct in C++ API is 64 ( Ej. sizeof(VkAccelerationStructureInstanceKHR) ) however in Vortice C# API is 72 (Unsafe.SizeOf< VkAccelerationStructureInstanceKHR >()), and this doesn't work in my Raytracing sample. I think that you must specify the explicit layout for this struct.
Vortice.Vulkan struct
[StructLayout(LayoutKind.Sequential)]
public partial struct VkAccelerationStructureInstanceKHR
{
public VkTransformMatrixKHR transform;
public uint instanceCustomIndex;
public uint mask;
public uint instanceShaderBindingTableRecordOffset;
public VkGeometryInstanceFlagsKHR flags;
public ulong accelerationStructureReference;
}
Khronos Group specification vk.xml
<type category="struct" name="VkAccelerationStructureInstanceKHR">
<comment>The bitfields in this structure are non-normative since bitfield ordering is implementation-defined in C. The specification defines the normative layout.</comment>
<member><type>VkTransformMatrixKHR</type> <name>transform</name></member>
<member><type>uint32_t</type> <name>instanceCustomIndex</name>:24</member>
<member><type>uint32_t</type> <name>mask</name>:8</member>
<member><type>uint32_t</type> <name>instanceShaderBindingTableRecordOffset</name>:24</member>
<member optional="true"><type>VkGeometryInstanceFlagsKHR</type> <name>flags</name>:8</member>
<member><type>uint64_t</type> <name>accelerationStructureReference</name></member>
</type>
Vulkan C++ struct
typedef struct VkAccelerationStructureInstanceKHR {
VkTransformMatrixKHR transform;
uint32_t instanceCustomIndex:24;
uint32_t mask:8;
uint32_t instanceShaderBindingTableRecordOffset:24;
VkGeometryInstanceFlagsKHR flags:8;
uint64_t accelerationStructureReference;
} VkAccelerationStructureInstanceKHR;
Proposal C# struct
[StructLayout(LayoutKind.Explicit)]
public unsafe partial struct VkAccelerationStructureInstanceKHR
{
[FieldOffset(0)]
public VkTransformMatrixKHR transform;
[FieldOffset(48)]
public uint instanceCustomIndex;
[FieldOffset(51)]
public uint mask;
[FieldOffset(52)]
public uint instanceShaderBindingTableRecordOffset;
[FieldOffset(55)]
public VkGeometryInstanceFlagBitsKHR flags;
[FieldOffset(56)]
public ulong accelerationStructureReference;
}
I tested proposal struct and work fine :).
VkTransformMatrixKHR is a Matrix3x4 Vulkan specification so it should have 12 floats.
namespace Vortice.Vulkan
{
public struct VkTransformMatrixKHR
{
public float matrix_0;
public float matrix_1;
public float matrix_2;
}
}
I created 2 days ago a PR #24. Because of a new change two hours ago, the branch is now in conflict.
Because i did not got any feedback, my question is: Should i keep the PR up to date? A small feedback would be nice.
Is there any other way to contact you, like Discord or something else?
How do you set VkDebugUtilsMessengerCreateInfoEXT.pfnUserCallback
?
I was previously using 1.3.4 and updated to 1.3.16. I was using Marshal.GetFunctionPointerForDelegate()
on a delegate of type vkDebugUtilsMessengerCallbackEXT
but that is not possible anymore.
If I copy the new struct into my code it won't event compile
[StructLayout(LayoutKind.Sequential)]
public partial struct VkDebugUtilsMessengerCreateInfoEXT
{
public VkStructureType sType;
public unsafe void* pNext;
public VkDebugUtilsMessengerCreateFlagsEXT flags;
public VkDebugUtilsMessageSeverityFlagsEXT messageSeverity;
public VkDebugUtilsMessageTypeFlagsEXT messageType;
#if NETSTANDARD2_0
public unsafe delegate* unmanaged[Stdcall]<VkDebugUtilsMessageSeverityFlagsEXT, VkDebugUtilsMessageTypeFlagsEXT, VkDebugUtilsMessengerCallbackDataEXT*, void*, uint> pfnUserCallback;
#else
public unsafe delegate* unmanaged<VkDebugUtilsMessageSeverityFlagsEXT, VkDebugUtilsMessageTypeFlagsEXT, VkDebugUtilsMessengerCallbackDataEXT*, void*, uint> pfnUserCallback;
#endif
public unsafe void* pUserData;
}
error CS8370: Feature 'function pointers' is not available in C# 7.3. Please use language version 9.0 or greater.
My project target
<TargetFrameworks>netstandard2.0</TargetFrameworks>
which finally gets referenced in a project with
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
BTW, thanks for adding netstandard2.0 back in. I was having trouble updating to net5 since all my dependencies haven't caught up yet.
Hello. I am trying to use your VMA and shaderc bindings, but I keep getting my app crashing. I use Silk.NET as vulkan api wrapper, and unfortunately right now I am already super invested in it to make the change. I am trying to just create an allocator and it keeps crashing on me.
In Silk.NET .Handle is actually the real value of the object, as it would be in C. I am sending these to vmaCreateAllocator, and it keeps on crashing in "OnDllImport" callback. It gets here
if (libraryName.Equals(LibName) && TryResolveVMA(assembly, searchPath, out nativeLibrary)) { return nativeLibrary; }
All I do on my side is this:
VmaAllocatorCreateInfo allocatorCreateInfo; allocatorCreateInfo.vulkanApiVersion = VkVersion.Version_1_2; allocatorCreateInfo.physicalDevice = pdev.Handle; allocatorCreateInfo.device = dev.Handle; allocatorCreateInfo.instance = instance.Handle; VmaAllocator allocator; vmaCreateAllocator(&allocatorCreateInfo, &allocator).CheckResult();
and respectively before (successfully!!!) initializing vulkan, which runs without any validation errors. I am quite helpless with what might be going on. This is on Linux operating system, more specifically on Pop_OS!
I updated from 1.3.4 to 1.3.16 and a few methods no longer exist. The return is no longer an out
parameter.
Old signature (1.3.4)
public static VkResult vkAllocateCommandBuffers(VkDevice device, VkCommandBufferAllocateInfo* allocateInfo, out VkCommandBuffer commandBuffers);
public static VkResult vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, VkComputePipelineCreateInfo createInfo, out VkPipeline pipeline);
public static VkResult vkCreateGraphicsPipeline(VkDevice device, VkPipelineCache pipelineCache, VkGraphicsPipelineCreateInfo createInfo, out VkPipeline pipeline);
New signature (1.3.16)
public static VkResult vkAllocateCommandBuffers(VkDevice device, VkCommandBufferAllocateInfo* allocateInfo, VkCommandBuffer* commandBuffers);
public static VkResult vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, VkComputePipelineCreateInfo createInfo, VkPipeline* pipeline);
public static VkResult vkCreateGraphicsPipeline(VkDevice device, VkPipelineCache pipelineCache, VkGraphicsPipelineCreateInfo createInfo, VkPipeline* pipeline);
Proposed signature
public static VkResult vkAllocateCommandBuffer(VkDevice device, VkCommandBufferAllocateInfo* allocateInfo, out VkCommandBuffer commandBuffer);
public static VkResult vkCreateComputePipeline(VkDevice device, VkPipelineCache pipelineCache, VkComputePipelineCreateInfo createInfo, out VkPipeline pipeline);
public static VkResult vkCreateGraphicsPipeline(VkDevice device, VkPipelineCache pipelineCache, VkGraphicsPipelineCreateInfo createInfo, out VkPipeline pipeline);
Can these methods be added back in?
How to use Vortice.Vulkan on iOS?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.