This commit is contained in:
Jörg Wollenschläger 2016-02-14 15:54:32 +09:00
Коммит 3e261dafbb
24 изменённых файлов: 9201 добавлений и 0 удалений

50
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,50 @@
#ignore thumbnails created by windows
Thumbs.db
#Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.orig
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
*.nogit
*.nupkg
*.zip
*.sdf
*.opensdf
*.suo
*.dotCover
sdk-include/
vc-include/
obj/
ipch*/
Demo/
AppPackages/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
#Generated*/
Build/
Temp*/
#ignore build log file
BuildErrors.log
#ignore certification test results
Source/CertificationTests/Results/*
*.tlog

19
LICENSE Normal file
Просмотреть файл

@ -0,0 +1,19 @@
Copyright (c) 2016 Jörg Wollenschläger
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

22
README.md Normal file
Просмотреть файл

@ -0,0 +1,22 @@
# SharpVulkan
C# bindings for the [Vulkan](https://www.khronos.org/vulkan/) graphics API
## About
> NOTE: This repository is work-in-progress and subject to changes
These bindings are automatically generated from C-headers by a custom tool, similarily to [SharpDX](http://sharpdx.org/).
TODO:
- [ ] Clean up and publish binding generator as stand-alone tool
- [ ] Clean up API, provide helpers where sensible
- [ ] Properly handle extensions
- [ ] Multi-platform support
- [ ] Include samples
- [ ] Generate comments from documentation
## Licensing
MIT

22
SharpVulkan.sln Normal file
Просмотреть файл

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpVulkan", "Source\SharpVulkan\SharpVulkan.csproj", "{5E203373-9D25-4FAB-B1A4-360C13160120}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5E203373-9D25-4FAB-B1A4-360C13160120}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E203373-9D25-4FAB-B1A4-360C13160120}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E203373-9D25-4FAB-B1A4-360C13160120}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E203373-9D25-4FAB-B1A4-360C13160120}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,42 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Jörg Wollenschläger")]
[assembly: AssemblyCopyright("Copyright © 2016 Jörg Wollenschläger")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en-us")]
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly:AssemblyConfiguration("Release")]
#endif
[assembly: ComVisible(false)]

Просмотреть файл

@ -0,0 +1,74 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace SharpVulkan
{
public partial struct Device
{
public unsafe SparseImageMemoryRequirements[] GetSparseMemoryRequirements(Image image)
{
uint count = 0;
GetImageSparseMemoryRequirements(image, ref count, null);
var result = new SparseImageMemoryRequirements[count];
fixed (SparseImageMemoryRequirements* resultPointer = &result[0])
GetImageSparseMemoryRequirements(image, ref count, resultPointer);
return result;
}
public unsafe byte[] GetPipelineCacheData(PipelineCache pipelineCache)
{
ulong count = 0;
GetPipelineCacheData(pipelineCache, ref count, IntPtr.Zero);
var result = new byte[count];
fixed (byte* resultPtr = &result[0])
GetPipelineCacheData(pipelineCache, ref count, new IntPtr(resultPtr));
return result;
}
public unsafe Image[] GetSwapchainImages(Swapchain swapchain)
{
uint count = 0;
GetSwapchainImages(swapchain, ref count, null);
var result = new Image[count];
fixed (Image* resultPtr = &result[0])
GetSwapchainImages(swapchain, ref count, resultPtr);
return result;
}
public unsafe Swapchain[] CreateSharedSwapchains(SwapchainCreateInfo[] createInfos, AllocationCallbacks allocator)
{
var swapchains = new Swapchain[createInfos.Length];
fixed (SwapchainCreateInfo* __createInfos__ = &createInfos[0])
fixed (Swapchain* __swapchains__ = &swapchains[0])
{
CreateSharedSwapchains_(this, (uint)createInfos.Length, __createInfos__, &allocator, __swapchains__).CheckError();
}
return swapchains;
}
}
}

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace SharpVulkan
{
public partial struct Extent2D
{
public Extent2D(uint width, uint height)
{
Width = width;
Height = height;
}
}
}

Просмотреть файл

@ -0,0 +1,32 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace SharpVulkan
{
public partial struct Extent3D
{
public Extent3D(uint width, uint height, uint depth)
{
Width = width;
Height = height;
Depth = depth;
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,40 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace SharpVulkan
{
public partial struct Instance
{
public unsafe PhysicalDevice[] PhysicalDevices
{
get
{
uint count = 0;
EnumeratePhysicalDevices(ref count, null);
var result = new PhysicalDevice[count];
fixed (PhysicalDevice* resultPointer = &result[0])
EnumeratePhysicalDevices(ref count, resultPointer);
return result;
}
}
}
}

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace SharpVulkan
{
public partial struct Offset2D
{
public Offset2D(int x, int y)
{
X = x;
Y = y;
}
}
}

Просмотреть файл

@ -0,0 +1,32 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace SharpVulkan
{
public partial struct Offset3D
{
public Offset3D(int x, int y, int z)
{
X = x;
Y = y;
Z = z;
}
}
}

Просмотреть файл

@ -0,0 +1,167 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Runtime.InteropServices;
namespace SharpVulkan
{
public partial struct PhysicalDevice
{
public unsafe LayerProperties[] DeviceLayerProperties
{
get
{
uint count = 0;
EnumerateDeviceLayerProperties(ref count, null);
var result = new LayerProperties[count];
fixed (LayerProperties* resultPointer = &result[0])
EnumerateDeviceLayerProperties(ref count, resultPointer);
return result;
}
}
public unsafe ExtensionProperties[] GetDeviceExtensionProperties(string layerName)
{
var nativeString = Marshal.StringToHGlobalAnsi(layerName);
try
{
uint count = 0;
EnumerateDeviceExtensionProperties((byte*)nativeString, ref count, null);
var result = new ExtensionProperties[count];
fixed (ExtensionProperties* resultPointer = &result[0])
EnumerateDeviceExtensionProperties((byte*)nativeString, ref count, resultPointer);
return result;
}
finally
{
Marshal.FreeHGlobal(nativeString);
}
}
public unsafe QueueFamilyProperties[] QueueFamilyProperties
{
get
{
uint count = 0;
GetQueueFamilyProperties(ref count, null);
var result = new QueueFamilyProperties[count];
fixed (QueueFamilyProperties* resultPointer = &result[0])
GetQueueFamilyProperties(ref count, resultPointer);
return result;
}
}
public unsafe DisplayPlaneProperties[] DisplayPlaneProperties
{
get
{
uint count = 0;
GetDisplayPlaneProperties(ref count, null);
var result = new DisplayPlaneProperties[count];
fixed (DisplayPlaneProperties* resultPointer = &result[0])
GetDisplayPlaneProperties(ref count, resultPointer);
return result;
}
}
public unsafe DisplayProperties[] DisplayProperties
{
get
{
uint count = 0;
GetDisplayProperties(ref count, null);
var result = new DisplayProperties[count];
fixed (DisplayProperties* resultPointer = &result[0])
GetDisplayProperties(ref count, resultPointer);
return result;
}
}
public unsafe SparseImageFormatProperties[] GetSparseImageFormatProperties(Format format, ImageType type, SampleCountFlags samples, ImageUsageFlags usage, ImageTiling tiling)
{
uint count = 0;
GetSparseImageFormatProperties(format, type, samples, usage, tiling, ref count, null);
var result = new SparseImageFormatProperties[count];
fixed (SparseImageFormatProperties* resultPointer = &result[0])
GetSparseImageFormatProperties(format, type, samples, usage, tiling, ref count, resultPointer);
return result;
}
public unsafe DisplayModeProperties[] GetDisplayModeProperties(Display display)
{
uint count = 0;
GetDisplayModeProperties(display, ref count, null);
var result = new DisplayModeProperties[count];
fixed (DisplayModeProperties* resultPointer = &result[0])
GetDisplayModeProperties(display, ref count, resultPointer);
return result;
}
public unsafe Display[] GetDisplayPlaneSupportedDisplays(uint planeIndex)
{
uint count = 0;
GetDisplayPlaneSupportedDisplays(planeIndex, ref count, null);
var result = new Display[count];
fixed (Display* resultPointer = &result[0])
GetDisplayPlaneSupportedDisplays(planeIndex, ref count, resultPointer);
return result;
}
public unsafe SurfaceFormat[] GetSurfaceFormats(Surface surface)
{
uint count = 0;
GetSurfaceFormats(surface, ref count, null);
var result = new SurfaceFormat[count];
fixed (SurfaceFormat* resultPointer = &result[0])
GetSurfaceFormats(surface, ref count, resultPointer);
return result;
}
public unsafe PresentMode[] GetSurfacePresentModes(Surface surface)
{
uint count = 0;
GetSurfacePresentModes(surface, ref count, null);
var result = new PresentMode[count];
fixed (PresentMode* resultPointer = &result[0])
GetSurfacePresentModes(surface, ref count, resultPointer);
return result;
}
}
}

Просмотреть файл

@ -0,0 +1,28 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyProduct("SharpVulkan")]
[assembly: AssemblyTitle("SharpVulkan")]
[assembly: AssemblyDescription("SharpVulkan core assembly")]
[assembly: Guid("5e203373-9d25-4fab-b1a4-360c13160120")]

Просмотреть файл

@ -0,0 +1,122 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Runtime.InteropServices;
namespace SharpVulkan
{
/// <summary>
/// A boolean value stored on 4 bytes (instead of 1 in .NET).
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 4)]
public struct RawBool : IEquatable<RawBool>
{
private int boolValue;
/// <summary>
/// Initializes a new instance of the <see cref="RawBool" /> class.
/// </summary>
/// <param name="boolValue">if set to <c>true</c> [bool value].</param>
public RawBool(bool boolValue)
{
this.boolValue = boolValue ? 1 : 0;
}
/// <summary>
/// Indicates whether this instance and a specified object are equal.
/// </summary>
/// <param name="other">The other.</param>
/// <returns>true if <paramref name="other" /> and this instance are the same type and represent the same value; otherwise, false.</returns>
public bool Equals(RawBool other)
{
return this.boolValue == other.boolValue;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
return false;
return obj is RawBool && Equals((RawBool)obj);
}
public override int GetHashCode()
{
return this.boolValue;
}
/// <summary>
/// Implements the ==.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static bool operator ==(RawBool left, RawBool right)
{
return left.Equals(right);
}
/// <summary>
/// Implements the !=.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !=(RawBool left, RawBool right)
{
return !left.Equals(right);
}
/// <summary>
/// Performs an explicit conversion from <see cref="RawBool"/> to <see cref="bool"/>.
/// </summary>
/// <param name="booleanValue">The value.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator bool(RawBool booleanValue)
{
return booleanValue.boolValue != 0;
}
/// <summary>
/// Performs an explicit conversion from <see cref="bool"/> to <see cref="RawBool"/>.
/// </summary>
/// <param name="boolValue">The value.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator RawBool(bool boolValue)
{
return new RawBool(boolValue);
}
public override string ToString()
{
return string.Format("{0}", boolValue != 0);
}
public static implicit operator int(RawBool booleanValue)
{
return booleanValue.boolValue;
}
public static implicit operator RawBool(int boolValue)
{
return new RawBool { boolValue = boolValue };
}
}
}

Просмотреть файл

@ -0,0 +1,73 @@
// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace SharpVulkan
{
/// <summary>
/// Interop type for a Color4 (RGBA, 4 floats).
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 4)]
[DebuggerDisplay("R:{R} G:{G} B:{B} A:{A}")]
public struct RawColor4
{
/// <summary>
/// Initializes a new instance of the <see cref="RawColor4"/> struct.
/// </summary>
/// <param name="r">The r.</param>
/// <param name="g">The g.</param>
/// <param name="b">The b.</param>
/// <param name="a">A.</param>
public RawColor4(float r, float g, float b, float a)
{
R = r;
G = g;
B = b;
A = a;
}
/// <summary>
/// The red component of the color.
/// </summary>
public float R;
/// <summary>
/// The green component of the color.
/// </summary>
public float G;
/// <summary>
/// The blue component of the color.
/// </summary>
public float B;
/// <summary>
/// The alpha component of the color.
/// </summary>
public float A;
public static unsafe implicit operator ClearColorValue(RawColor4 colorValue)
{
return *(ClearColorValue*)&colorValue;
}
}
}

Просмотреть файл

@ -0,0 +1,58 @@
// Copyright (c) 2010-2013 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace SharpVulkan
{
/// <summary>
/// Interop type for a Int4 (4 ints).
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 4)]
[DebuggerDisplay("X: {X}, Y: {Y}, Z: {Z}, W: {W}")]
public struct RawInt4
{
/// <summary>
/// The X component of the vector.
/// </summary>
public int X;
/// <summary>
/// The Y component of the vector.
/// </summary>
public int Y;
/// <summary>
/// The Z component of the vector.
/// </summary>
public int Z;
/// <summary>
/// The W component of the vector.
/// </summary>
public int W;
public static unsafe implicit operator ClearColorValue(RawInt4 intValue)
{
return *(ClearColorValue*)&intValue;
}
}
}

Просмотреть файл

@ -0,0 +1,33 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace SharpVulkan
{
public static class ResultExtensions
{
public static void CheckError(this Result result)
{
if (result < 0)
{
throw new SharpVulkanException(result);
}
}
}
}

Просмотреть файл

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5E203373-9D25-4FAB-B1A4-360C13160120}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SharpVulkan</RootNamespace>
<AssemblyName>SharpVulkan</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Device.cs" />
<Compile Include="Extent2D.cs" />
<Compile Include="Extent3D.cs" />
<Compile Include="Generated\Enumerations.cs" />
<Compile Include="Generated\Functions.cs" />
<Compile Include="Generated\Structures.cs" />
<Compile Include="Instance.cs" />
<Compile Include="Offset2D.cs" />
<Compile Include="Offset3D.cs" />
<Compile Include="PhysicalDevice.cs" />
<Compile Include="RawBool.cs" />
<Compile Include="RawColor4.cs" />
<Compile Include="RawInt4.cs" />
<Compile Include="ResultExtensions.cs" />
<Compile Include="SharpVulkanException.cs" />
<Compile Include="Version.cs" />
<Compile Include="Vulkan.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -0,0 +1,42 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
namespace SharpVulkan
{
/// <summary>
/// The base class for errors that occur in SharpVulkan.
/// </summary>
public class SharpVulkanException : Exception
{
public Result Result { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="SharpVulkanException" /> class.
/// </summary>
/// <param name="result">The result code that caused this exception.</param>
public SharpVulkanException(Result result)
: base("A Vulkan error occurred.")
{
Result = result;
}
}
}

Просмотреть файл

@ -0,0 +1,37 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace SharpVulkan
{
public struct Version
{
private readonly uint value;
public Version(uint major, uint minor, uint patch)
{
value = major << 22 | minor << 12 | patch;
}
public static implicit operator uint(Version version)
{
return version.value;
}
}
}

Просмотреть файл

@ -0,0 +1,64 @@
// Copyright (c) 2016 Jörg Wollenschläger
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System.Runtime.InteropServices;
namespace SharpVulkan
{
public static partial class Vulkan
{
public static readonly Version ApiVersion = new Version(1, 0, 2);
public static unsafe LayerProperties[] InstanceLayerProperties
{
get
{
uint count = 0;
EnumerateInstanceLayerProperties(ref count, null);
var result = new LayerProperties[count];
fixed (LayerProperties* resultPointer = &result[0])
EnumerateInstanceLayerProperties(ref count, resultPointer);
return result;
}
}
public static unsafe ExtensionProperties[] GetInstanceExtensionProperties(string layerName)
{
var nativeString = Marshal.StringToHGlobalAnsi(layerName);
try
{
uint count = 0;
EnumerateInstanceExtensionProperties((byte*)nativeString, ref count, null);
var result = new ExtensionProperties[count];
fixed (ExtensionProperties* resultPointer = &result[0])
EnumerateInstanceExtensionProperties((byte*)nativeString, ref count, resultPointer);
return result;
}
finally
{
Marshal.FreeHGlobal(nativeString);
}
}
}
}