Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 1 addition & 44 deletions src/Veldrid.SPIRV/SpirvReflection.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.IO;

namespace Veldrid.SPIRV
{
/// <summary>
Expand All @@ -12,8 +7,6 @@ namespace Veldrid.SPIRV
/// </summary>
public class SpirvReflection
{
private static readonly Lazy<JsonSerializer> s_serializer = new Lazy<JsonSerializer>(CreateSerializer);

/// <summary>
/// An array containing a description of each vertex element that is used by the compiled shader set.
/// This array will be empty for compute shaders.
Expand All @@ -39,41 +32,5 @@ public SpirvReflection(
VertexElements = vertexElements;
ResourceLayouts = resourceLayouts;
}

/// <summary>
/// Loads a <see cref="SpirvReflection"/> object from a serialized JSON file at the given path.
/// </summary>
/// <param name="jsonPath">The path to the JSON file.</param>
/// <returns>A new <see cref="SpirvReflection"/> object, deserialized from the file.</returns>
public static SpirvReflection LoadFromJson(string jsonPath)
{
using (FileStream jsonStream = File.OpenRead(jsonPath))
{
return LoadFromJson(jsonStream);
}
}

/// <summary>
/// Loads a <see cref="SpirvReflection"/> object from a serialized JSON stream.
/// </summary>
/// <param name="jsonStream">The stream of serialized JSON text.</param>
/// <returns>A new <see cref="SpirvReflection"/> object, deserialized from the stream.</returns>
public static SpirvReflection LoadFromJson(Stream jsonStream)
{
using (StreamReader sr = new StreamReader(jsonStream))
using (JsonTextReader jtr = new JsonTextReader(sr))
{
return s_serializer.Value.Deserialize<SpirvReflection>(jtr);
}
}

private static JsonSerializer CreateSerializer()
{
JsonSerializer serializer = new JsonSerializer();
serializer.Formatting = Formatting.Indented;
StringEnumConverter enumConverter = new StringEnumConverter();
serializer.Converters.Add(enumConverter);
return serializer;
}
}
}
}
114 changes: 58 additions & 56 deletions src/Veldrid.SPIRV/Veldrid.SPIRV.csproj
Original file line number Diff line number Diff line change
@@ -1,69 +1,71 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Label="Nuget">
<PackageId>ppy.Veldrid.SPIRV</PackageId>
<Version>0.0.0</Version>
<IsPackable>true</IsPackable>
</PropertyGroup>
<PropertyGroup Label="Nuget">
<PackageId>ppy.Veldrid.SPIRV</PackageId>
<Version>0.0.0</Version>
<IsPackable>true</IsPackable>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>ppy.Veldrid.SPIRV</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>$(BinDir)\$(AssemblyName).xml</DocumentationFile>
<NativeAssetsPath Condition="'$(NativeAssetsPath)' == ''">$(RepositoryRootDirectory)/build/</NativeAssetsPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>ppy.Veldrid.SPIRV</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>$(BinDir)\$(AssemblyName).xml</DocumentationFile>
<NativeAssetsPath Condition="'$(NativeAssetsPath)' == ''">$(RepositoryRootDirectory)/build/</NativeAssetsPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="ppy.Veldrid" Version="4.9.3-g91ce5a6cda" />
</ItemGroup>

<ItemGroup>
<Content Include="build\MonoAndroid10\Veldrid.SPIRV.targets">
<PackagePath>build/MonoAndroid10/Veldrid.SPIRV.targets</PackagePath>
<Pack>true</Pack>
</Content>
<Content Include="build\net40\Veldrid.SPIRV.targets">
<PackagePath>build/net40/Veldrid.SPIRV.targets</PackagePath>
<Pack>true</Pack>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.Veldrid" Version="4.9.3-g91ce5a6cda"/>
</ItemGroup>

<ItemGroup>
<Content Include="../../build/$(Configuration)/ios/**/*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes/ios/native</PackagePath>
<Pack>true</Pack>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="build\MonoAndroid10\Veldrid.SPIRV.targets">
<PackagePath>build/MonoAndroid10/Veldrid.SPIRV.targets</PackagePath>
<Pack>true</Pack>
</Content>
<Content Include="build\net40\Veldrid.SPIRV.targets">
<PackagePath>build/net40/Veldrid.SPIRV.targets</PackagePath>
<Pack>true</Pack>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Nerdbank.GitVersioning" Version="3.4.255" />
</ItemGroup>
<ItemGroup>
<Content Include="../../build/$(Configuration)/ios/**/*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackagePath>runtimes/ios/native</PackagePath>
<Pack>true</Pack>
</Content>
</ItemGroup>

<Target Name="BeforePackage" BeforeTargets="AssignTargetPaths">
<ItemGroup>
<_NativeAssetName Include="$(Configuration)/win-x86/libveldrid-spirv.dll" PackagePath="runtimes/win-x86/native" />
<_NativeAssetName Include="$(Configuration)/win-x64/libveldrid-spirv.dll" PackagePath="runtimes/win-x64/native" />
<_NativeAssetName Include="$(Configuration)/win-arm64/libveldrid-spirv.dll" PackagePath="runtimes/win-arm64/native" />
<_NativeAssetName Include="$(Configuration)/linux-x64/libveldrid-spirv.so" PackagePath="runtimes/linux-x64/native" />
<_NativeAssetName Include="$(Configuration)/linux-arm64/libveldrid-spirv.so" PackagePath="runtimes/linux-arm64/native" />
<_NativeAssetName Include="$(Configuration)/osx/libveldrid-spirv.dylib" PackagePath="runtimes/osx/native" />
<_NativeAssetName Include="$(Configuration)/ios/**/*" PackagePath="runtimes/ios/native" />
<_NativeAssetName Include="$(Configuration)/android-arm64-v8a/libveldrid-spirv.so" PackagePath="build/MonoAndroid10/native/arm64-v8a" />
<_NativeAssetName Include="$(Configuration)/android-armeabi-v7a/libveldrid-spirv.so" PackagePath="build/MonoAndroid10/native/armeabi-v7a" />
<_NativeAssetName Include="$(Configuration)/android-x86_64/libveldrid-spirv.so" PackagePath="build/MonoAndroid10/native/x86_64" />
<PackageReference Update="Nerdbank.GitVersioning" Version="3.4.255">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<_ExistingAssets Include="@(_NativeAssetName)" Condition="Exists('$(NativeAssetsPath)%(Identity)')" />
<Target Name="BeforePackage" BeforeTargets="AssignTargetPaths">
<ItemGroup>
<_NativeAssetName Include="$(Configuration)/win-x86/libveldrid-spirv.dll" PackagePath="runtimes/win-x86/native"/>
<_NativeAssetName Include="$(Configuration)/win-x64/libveldrid-spirv.dll" PackagePath="runtimes/win-x64/native"/>
<_NativeAssetName Include="$(Configuration)/win-arm64/libveldrid-spirv.dll" PackagePath="runtimes/win-arm64/native"/>
<_NativeAssetName Include="$(Configuration)/linux-x64/libveldrid-spirv.so" PackagePath="runtimes/linux-x64/native"/>
<_NativeAssetName Include="$(Configuration)/linux-arm64/libveldrid-spirv.so" PackagePath="runtimes/linux-arm64/native"/>
<_NativeAssetName Include="$(Configuration)/osx/libveldrid-spirv.dylib" PackagePath="runtimes/osx/native"/>
<_NativeAssetName Include="$(Configuration)/ios/**/*" PackagePath="runtimes/ios/native"/>
<_NativeAssetName Include="$(Configuration)/android-arm64-v8a/libveldrid-spirv.so" PackagePath="build/MonoAndroid10/native/arm64-v8a"/>
<_NativeAssetName Include="$(Configuration)/android-armeabi-v7a/libveldrid-spirv.so" PackagePath="build/MonoAndroid10/native/armeabi-v7a"/>
<_NativeAssetName Include="$(Configuration)/android-x86_64/libveldrid-spirv.so" PackagePath="build/MonoAndroid10/native/x86_64"/>

<Content Include="@(_ExistingAssets->'$(NativeAssetsPath)%(Identity)')" CopyToOutputDirectory="PreserveNewest" PackagePath="%(PackagePath)" Pack="true" />
</ItemGroup>
</Target>
<_ExistingAssets Include="@(_NativeAssetName)" Condition="Exists('$(NativeAssetsPath)%(Identity)')"/>

<Content Include="@(_ExistingAssets->'$(NativeAssetsPath)%(Identity)')" CopyToOutputDirectory="PreserveNewest" PackagePath="%(PackagePath)" Pack="true"/>
</ItemGroup>
</Target>

<PropertyGroup>
<Description>Veldrid integration for the SPIRV-Cross native library. Contains functionality to cross-compile SPIR-V bytecode into HLSL, GLSL, ESSL, and MSL shaders for use with Veldrid.</Description>
<PackageTags>3D Graphics Direct3D DirectX Vulkan OpenGL Metal Core Standard Game</PackageTags>
</PropertyGroup>
<PropertyGroup>
<Description>Veldrid integration for the SPIRV-Cross native library. Contains functionality to cross-compile SPIR-V bytecode into HLSL, GLSL, ESSL, and MSL shaders for use with Veldrid.</Description>
<PackageTags>3D Graphics Direct3D DirectX Vulkan OpenGL Metal Core Standard Game</PackageTags>
</PropertyGroup>

</Project>