Code Monkey home page Code Monkey logo

veldrid's Introduction

Veldrid

Veldrid is a cross-platform, graphics API-agnostic rendering and compute library for .NET. It provides a powerful, unified interface to a system's GPU and includes more advanced features than any other .NET library. Unlike other platform- or vendor-specific technologies, Veldrid can be used to create high-performance 3D applications that are truly portable.

As of February 2023, I'm no longer able to publicly share updates to Veldrid and related libraries. If you're an active user or have contributed improvements in the past, feel free to reach out or join the Discord server for more information about the status of Veldrid.

Supported backends:

  • Direct3D 11
  • Vulkan
  • Metal
  • OpenGL 3
  • OpenGL ES 3

Veldrid documentation site

Join the Discord server:

Join the Discord server

Veldrid is available on NuGet:

NuGet

Pre-release versions of Veldrid are also available from MyGet: https://www.myget.org/feed/mellinoe/package/nuget/Veldrid

Sponza

Build instructions

Veldrid uses the standard .NET Core tooling. Install the tools and build normally (dotnet build).

Run the NeoDemo program to see a quick demonstration of the rendering capabilities of the library.

veldrid's People

Contributors

amerkoleci avatar barrybingo avatar bassill avatar csinkers avatar curiouserthing avatar doom2fan avatar drjaydenm avatar feliwir avatar frenzibyte avatar gleblebedev avatar helco avatar jjagg avatar krakean avatar mellinoe avatar ncatlin avatar opticfluorine avatar peppy avatar phelioz avatar sa-exe avatar seanspicer avatar smoogipoo avatar supinepandora43 avatar swoolcock avatar techpizzadev avatar tgjones avatar trolleyman avatar tzachshabtay avatar ukoolabs avatar voldien avatar zaafar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

veldrid's Issues

Unable to run AnimatedMesh sample

Hi, I fetched Veldrid.Samples source yesterday, and most of the sample work, but when I try to run the AnimatedMesh sample I get a build error. Below is the full log.

This is in Visual Studio 2017, with .net sdk 2.1.4 x64.

Do you need any more info?

Thanks,
Gary

1>------ Build started: Project: AnimatedMesh, Configuration: Debug Any CPU ------
1>D:\git\veldrid-samples\src\AnimatedMesh\AnimatedMesh.csproj : warning NU1603: AnimatedMesh depends on ShaderGen.Build (>= 1.1.0-g1b11bad785) but ShaderGen.Build 1.1.0-g1b11bad785 was not found. An approximate best match of ShaderGen.Build 1.1.0-g262a77fb72 was resolved.
1>D:\git\veldrid-samples\src\AnimatedMesh\AnimatedMesh.csproj : warning NU1603: AnimatedMesh depends on ShaderGen.Primitives (>= 1.1.0-g1b11bad785) but ShaderGen.Primitives 1.1.0-g1b11bad785 was not found. An approximate best match of ShaderGen.Primitives 1.1.0-g262a77fb72 was resolved.
1>An error was encountered while generating shader code:
1>System.NullReferenceException: Object reference not set to an instance of an object.
1> at ShaderGen.LanguageBackend.IsIndexerAccess(SymbolInfo member) in C:\projects\shadergen\src\ShaderGen\LanguageBackend.cs:line 151
1> at ShaderGen.ShaderMethodVisitor.VisitMemberAccessExpression(MemberAccessExpressionSyntax node) in C:\projects\shadergen\src\ShaderGen\ShaderMethodVisitor.cs:line 130
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor1.Visit(SyntaxNode node) 1> at ShaderGen.ShaderMethodVisitor.VisitArgument(ArgumentSyntax node) in C:\projects\shadergen\src\ShaderGen\ShaderMethodVisitor.cs:line 254 1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor1.Visit(SyntaxNode node)
1> at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext() 1> at System.String.Join(String separator, IEnumerable1 values)
1> at ShaderGen.ShaderMethodVisitor.VisitBracketedArgumentList(BracketedArgumentListSyntax node) in C:\projects\shadergen\src\ShaderGen\ShaderMethodVisitor.cs:line 408
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor1.Visit(SyntaxNode node) 1> at ShaderGen.ShaderMethodVisitor.VisitElementAccessExpression(ElementAccessExpressionSyntax node) in C:\projects\shadergen\src\ShaderGen\ShaderMethodVisitor.cs:line 403 1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor1.Visit(SyntaxNode node)
1> at ShaderGen.ShaderMethodVisitor.VisitBinaryExpression(BinaryExpressionSyntax node) in C:\projects\shadergen\src\ShaderGen\ShaderMethodVisitor.cs:line 235
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor1.Visit(SyntaxNode node) 1> at ShaderGen.ShaderMethodVisitor.VisitEqualsValueClause(EqualsValueClauseSyntax node) in C:\projects\shadergen\src\ShaderGen\ShaderMethodVisitor.cs:line 90 1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor1.Visit(SyntaxNode node)
1> at ShaderGen.ShaderMethodVisitor.VisitVariableDeclaration(VariableDeclarationSyntax node) in C:\projects\shadergen\src\ShaderGen\ShaderMethodVisitor.cs:line 388
1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor1.Visit(SyntaxNode node) 1> at ShaderGen.ShaderMethodVisitor.VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node) in C:\projects\shadergen\src\ShaderGen\ShaderMethodVisitor.cs:line 85 1> at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor1.Visit(SyntaxNode node)
1> at ShaderGen.ShaderMethodVisitor.VisitBlock(BlockSyntax node) in C:\projects\shadergen\src\ShaderGen\ShaderMethodVisitor.cs:line 58
1> at ShaderGen.ShaderMethodVisitor.VisitFunction(BlockSyntax node) in C:\projects\shadergen\src\ShaderGen\ShaderMethodVisitor.cs:line 38
1> at ShaderGen.HlslBackend.GenerateFullTextCore(String setName, ShaderFunction function) in C:\projects\shadergen\src\ShaderGen\HlslBackend.cs:line 216
1> at ShaderGen.LanguageBackend.GetCode(String setName, ShaderFunction function) in C:\projects\shadergen\src\ShaderGen\LanguageBackend.cs:line 118
1> at ShaderGen.LanguageBackend.GetShaderModel(String setName) in C:\projects\shadergen\src\ShaderGen\LanguageBackend.cs:line 73
1> at ShaderGen.ShaderGenerator.GenerateShaders(ShaderSetInfo ss, ShaderGenerationResult result) in C:\projects\shadergen\src\ShaderGen\ShaderGenerator.cs:line 203
1> at ShaderGen.ShaderGenerator.GenerateShaders() in C:\projects\shadergen\src\ShaderGen\ShaderGenerator.cs:line 151
1> at ShaderGen.App.Program.Main(String[] args) in C:\projects\shadergen\src\ShaderGen.App\Program.cs:line 158
1>
1>C:\Users\garym.nuget\packages\shadergen.build\1.1.0-g262a77fb72\build\ShaderGen.targets(35,5): error MSB3073: The command "dotnet C:\Users\garym.nuget\packages\shadergen.build\1.1.0-g262a77fb72\build\ShaderGen.App.dll --ref " D:\git\veldrid-samples\bin\obj\AnimatedMesh\Debug\netcoreapp2.0_sgreferences.txt " --src " D:\git\veldrid-samples\bin\obj\AnimatedMesh\Debug\netcoreapp2.0_sgsources.txt " --out " D:\git\veldrid-samples\bin\obj\AnimatedMesh\Shaders " --genlist "D:\git\veldrid-samples\bin\obj\AnimatedMesh\Debug\netcoreapp2.0_sggeneratedfiles.txt"" exited with code -1.
1>Done building project "AnimatedMesh.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Using Veldrid for 2d graphics?

I'm wondering about the viability of using veldrid for 2d UI's?

I'm looking for a cross-platform UI solution to use for a project. I want it to be lightweight and do not really need any stock UI controls as my use case is quite specialized anyway. As I'm using .NET Core 2 this library seems to be a great fit, but I'm wondering if you have any pointers on how one could approach creating a simple 2d-renderer. I would typically need to draw vector graphics like solid filled rectangles, lines and text.

Keep up the great work, veldrid looks like an awesome library!

Support Vulkan on macOS/iOS

Since MoltenVK is now open source, Veldrid should support using Vulkan on macOS and iOS. I hacked some things together and got the basics working. There's only a few problems with the current code:

  • Need to add a little extra code to support creating a swapchain from an NSWindow or UIView.
  • The multi-viewport feature is assumed to be supported, but it's not on MoltenVK. Need to actually check that the feature is supported before enabling it and handle other stuff, like what happens when you set a non-zero viewport.
  • Geometry shaders are assumed to be supported, but they aren't.
  • VkEvents are not supported at all by MoltenVK. Unfortunately, VkCommandList uses events to determine when to recycle staging buffers. This dependency can probably be removed.

Aside from the above, there's still several bugs in MoltenVK that prevent Veldrid from working. After hacking around the bugs that I'm aware of, I'm able to render simple stuff, but NeoDemo renders completely wrong, despite not hitting any errors or warnings.

[Feature Request] DirectX 12 Support

While Vulkan support is great it most cases; it would be great to have DX12 support when building applications for Windows - especially when SharpDX is available with great bindings.

I've been reading through the Veldrid documentation and implementation details (which are great) so I've got a good idea of the structure of things - I'd be happy to start the implementation, with a slightly longer term completion estimate.

Any additional pointers would be great here.

Thanks, Jak.

Immutable resources

Now to update buffers or textures there a Update method on CommandList, all backends can handle immutable data being passed during creation.

Implement API calls for mipmapping.

As per the mention on gitter, I thought it would be worthwhile making an official request for this.

Having direct access to mipmapping is not only beneficial for graphics applications but also for GPGPU apps. E.g. calculating image pyramids.

The API calls are as follows:
OpenGL: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGenerateMipmap.xhtml
Metal: https://developer.apple.com/documentation/metal/mtlblitcommandencoder/1400748-generatemipmapsfortexture
DirectX: https://msdn.microsoft.com/en-us/library/windows/desktop/bb206251(v=vs.85).aspx (? - not sure since it DirectX 9)
Vulkan : No direct mipmapping here. Would have to use a compute shader chain, as stated in the gitter chat.

nU get packge

do you plan: release nu get package?
it is easier than use the submodule because git submodule checkout take long time, very large file

nu get restore much faster
maybe publish to you personal feed, see myget?

image.MetaData.HorizontalResolution is not correct, returns 1, and file properties shows 96

I'm using Veldrid.ImageSharp v4.1.1 from Nuget, and run the following code:
var fileStream = new FileStream("96Resolution.jpg", FileMode.Open);
IImageFormat format;
var image = Image.Load(fileStream, out format);
if (image.MetaData.HorizontalResolution < 72){ .... }

Here image.MetaData.HorizontalResolution is 1, but when I check the image properties, its resolution is 96 both vertically and horizontally. Another jpg file returns the correct resolution.
Just attached my test image.
invalidresolution

Thanks

Interfaces not prefixed with I

I once worked on my own similar project:
https://github.com/IntelOrca/OrcaML

Which closely mirrored ASP.NET core using dependency injection as a means for selecting different components (e.g. OpenGL over DirectX).

I noticed that many of your interfaces are not prefixed with uppercase I, how come?

Y-Axis Flipped when Rendering FBO to Texture in OpenGL

When rendering a scene to a FBO color attachment and then sampling the texture the Y-Axis is flipped in opengl.

In the example the coloured quad and the cube are rendered to the quad on the right.

Using Metal

metal

Using OpenGL

opengl

Best,
Marc

Veldrid roadmap?

@mellinoe
Hi
Is there any Veldrid roadmap around?
Just to understand what important features Veldrid is lack of at the moment and you plan to do :)

What should I be using for TexImage2D?

Hey there.

I'm a relative newbie to OpenGL but I have some simple code that displays a 3d array of RGB values to the screen using TexImage2D.

This is the example program, compatible with your .Net core port of OpenTK

void init()
{
    int width = 640;
    int height = 480;
    byte screen[, ,] = new byte[width, height, 3];

    for (int x = 0; x < width; x ++)
    {
        for (int y = 0; y < height; y++)
        {
            for (int c = 0, c < 3; c++)
            {
                screen[x,y,c] = 128;
            }
        }
    }

    GL.Viewport(0, 0, _width, _height);
    GL.MatrixMode(MatrixMode.Modelview);
    GL.Ortho(0, _width, _height, 0, -1.0, 1.0);
    GL.ShadeModel(ShadingModel.Flat);
    GL.Disable(EnableCap.DepthTest);
    GL.Disable(EnableCap.CullFace);
    GL.Disable(EnableCap.Dither);
    GL.Disable(EnableCap.Blend);
    GL.Enable(EnableCap.Texture2D);
    GL.ClearColor(Color.Black);
    GL.MatrixMode(MatrixMode.Projection);
    GL.LoadIdentity();
    GL.GenTextures(1, out texture);
    GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, new int[] { (int)TextureMinFilter.Nearest });
    GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, new int[] { (int)TextureMagFilter.Nearest });

    GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, 160, 144, 0, PixelFormat.Rgb, PixelType.UnsignedByte, screen);
}

void Render()
{
    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
    GL.Begin(BeginMode.Quads);
    GL.TexCoord2(0, 0); GL.Vertex2(0, 0);
    GL.TexCoord2(0, 1); GL.Vertex2(0, _height);
    GL.TexCoord2(1, 1); GL.Vertex2(_width, _height);
    GL.TexCoord2(1, 0); GL.Vertex2(_width, 0);
    GL.End();

    SwapBuffers();
}

screen repesents x, y, color - where color is RGB for each pixel. I've simplified the example for brevity.

So as you can see, it's straight forward. I see how to do most of the GL setup with Veldrid Api's.... but I'm not seeing a direct replacement for TexImage2D (unless i'm missing something, which I probably am). This is strictly a 2D render that I'm doing here.

What should I look at?

Thank you again for this awesome library @mellinoe !

(Ubuntu 17.10) Veldrid.VeldridException: The required instance extension was not available: Veldrid.Vk.FixedUtf8String

Hi Mellinoe,

I am trying to give your framework a try (I'm really interested in true cross platform graphics with .NET core).

I have run into an issue during basic testing, specifically around Part 1 in the documentation.

I've created a bare bones new console application and added nuget references to Veldrid and Veldrid.StartupUtilities, then I used the finished example at the bottom to try and get a blank window to appear.

This works perfectly on Windows 10, however, I am having problems getting this to work on my Ubuntu System (17.10)

I did have some original issues with OpenGL and Vulkan, but those were due to missing dependencies on my system and got those cleared up.

Is there a chance i'm missing something else that may be causing this issue? I've dug around a bit but nothing jumped out at me.

I've also attached my project I was trying to use as well (even though its the same as the documentation code)
VeldridTest.zip

And if there is anything else I can provide please let me know!

Full Exception:

misnor@SINIX:~/Documents/VeldridTest$ dotnet run

Unhandled Exception: Veldrid.VeldridException: The required instance extension was not available: Veldrid.Vk.FixedUtf8String
   at Veldrid.Vk.VkGraphicsDevice.CreateInstance(Boolean debug)
   at Veldrid.Vk.VkGraphicsDevice..ctor(GraphicsDeviceOptions options, VkSurfaceSource surfaceSource, UInt32 width, UInt32 height)
   at Veldrid.StartupUtilities.VeldridStartup.CreateVulkanGraphicsDevice(GraphicsDeviceOptions options, Sdl2Window window)
   at Veldrid.StartupUtilities.VeldridStartup.CreateGraphicsDevice(Sdl2Window window, GraphicsDeviceOptions options, GraphicsBackend preferredBackend)
   at Veldrid.StartupUtilities.VeldridStartup.CreateGraphicsDevice(Sdl2Window window)
   at VeldridTest.Program.Main() in /home/misnor/Documents/VeldridTest/Program.cs:line 24

[OpenGL] Textures are always bound to unit 0

...in places other than ActivateResourceSet. So, basically, if a texture is bound as a result of calling any other method (such as Map or CopyTexture), it always ends up in unit 0.
And that can become a problem.
Imagine this scenario: you have a sampler in your shader bound to texture unit 0. In the meantime, a background thread is trying to load a new image. In the end, CopyTexture is called, which causes it to be bound to unit 0. As a result, the newly created texture is sampled instead of the original one.
For instance, in a 2D game, that would mean that whenever a new texture is loaded on a background thread, it is briefly displayed on the screen, as it replaces the texture that was previously in unit 0.

OpenGL ES Support

This evening I looked into running Veldrid on Android, using Veldrid.StartupUtilities and MonoGame's MonoGameAndroidGameView.cs as references. I noticed StartupUtilities requests OpenGL 4.0 when it is creating a context. I was wondering if Veldrid supports OpenGL ES and if so, which versions it supports. Is there a OpenGL 4.0 equivalent or otherwise compatible OpenGL ES version I should request when creating a context on Android? Thank you.

Strange Buffer Indexing Behaviour when using Metal

Hello,

So I wanted to port my OpenGL instancing example to Metal.
By doing so I discovered strange behaviour in 2 instances.

VertexLayoutDescription

Most importantly the use of multiple VertexLayoutDescription will change the buffer index that metal expects by 1.

E.g.

ShaderSet 
   = new ShaderSetDescription(
      vertexLayouts: new VertexLayoutDescription[ {vertexLayout,vertexLayoutPerInstance},
      shaders: new Shader[] {_vertexShader,_fragmentShader}
   )

With this layout I still expected that I have the following method signature in metal:
vertex PixelInput VS(VertexInput input[[stage_in]],constant projView &pj [[ buffer(1) ]])

However, it is actually: vertex PixelInput VS(VertexInput input[[stage_in]],constant projView &pj [[ buffer(2) ]])

UpdateBuffer Placement in Command List

The uniform buffer locations have to be written to before the memory associated with VertexLayouts are set. This is different from using the OpenGL backend.

        _commandList.Begin();
        _commandList.SetFramebuffer(_graphicsDevice.SwapchainFramebuffer);
        _commandList.SetFullViewports();
        _commandList.ClearColorTarget(0,RgbaFloat.White);
        _commandList.UpdateBuffer(_cameraProjViewBuffer,0,_camera.ViewMatrix);
        _commandList.UpdateBuffer(_cameraProjViewBuffer,64,_camera.ProjectionMatrix);
        _commandList.SetVertexBuffer(0,_vertexBuffer);
        _commandList.SetIndexBuffer(_indexBuffer,IndexFormat.UInt16);
        _commandList.SetVertexBuffer(1,_xOffsetBuffer);
        _commandList.SetPipeline(_pipeline);
        _commandList.SetGraphicsResourceSet(0,_resourceSet); // Always after SetPipeline
        // Updatebuffer here will not work
        // _commandList.UpdateBuffer(_cameraProjViewBuffer,0,_camera.ViewMatrix);
        //_commandList.UpdateBuffer(_cameraProjViewBuffer,64,_camera.ProjectionMatrix);
        _commandList.DrawIndexed(
            indexCount: 4,
            instanceCount: 2,
            indexStart: 0,
            vertexOffset: 0,
            instanceStart: 0
        );
        _commandList.End();

Best,
Marc

Improve Tutorials / Samples

It would be really nice to have a more complete set of tutorials/samples to work with.

E.g. None of the samples use Geometry Instancing,Indirect Buffers.
From the Vulkan/Metal docs it is also not clear, because each API handles this slightly differently.

Best,
Marc

Can't find SDL on Ubuntu 17.10 Wayland

I've compiled SDL2 from source and, for some reason, Veldrid can't find the lib.

System.TypeInitializationException: The type initializer for 'Veldrid.Sdl2.Sdl2Native' threw an exception. ---> System.IO.FileNotFoundException: Could not find or load the native library: libSDL2-2.0.so

I've tracked the code to: https://github.com/mellinoe/veldrid/blob/444d3295bf97346ffafdbdd0960c96fdce91d0a8/src/Veldrid.SDL2/Sdl2.cs#L19

Switching the library name to libSDL2-2.0.so.0 solved the issue. Maybe adding a regex for the NativeLoader lib that looks like this libSDL2-2.0.so(|.1|.0) would make builds more friendly?

Not able to build

I'm getting the following build errors (among several others, but I think these are the most relevant):

1>veldrid\src\Veldrid\Platform\OpenTKWindowBase.cs(75,27,75,34): error CS0012: The type 'CancelEventArgs' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
1>veldrid\src\Veldrid\Platform\OpenTKWindowBase.cs(75,13,75,53): error CS0123: No overload for 'OnWindowClosing' matches delegate 'EventHandler'
1>veldrid\src\Veldrid\Octree.cs(403,44,403,47): error CS1061: 'OctreeNode[]' does not contain a definition for 'Sum' and no extension method 'Sum' accepting a first argument of type 'OctreeNode[]' could be found (are you missing a using directive or an assembly reference?)
1>veldrid\src\Veldrid\Octree.cs(436,24,436,27): error CS1061: 'List<OctreeItem>' does not contain a definition for 'Any' and no extension method 'Any' accepting a first argument of type 'List<OctreeItem>' could be found (are you missing a using directive or an assembly reference?)
1>veldrid\src\Veldrid\Octree.cs(441,29,441,32): error CS1061: 'OctreeNode[]' does not contain a definition for 'Any' and no extension method 'Any' accepting a first argument of type 'OctreeNode[]' could be found (are you missing a using directive or an assembly reference?)
1>veldrid\src\Veldrid\Graphics\MtlParser.cs(268,39,268,51): error CS1061: 'IEnumerable' does not contain a definition for 'ToDictionary' and no extension method 'ToDictionary' accepting a first argument of type 'IEnumerable' could be found (are you missing a using directive or an assembly reference?)
1>veldrid\src\Veldrid\Graphics\Direct3D\D3DMaterial.cs(225,38,225,41): error CS1061: 'MaterialVertexInput[]' does not contain a definition for 'Sum' and no extension method 'Sum' accepting a first argument of type 'MaterialVertexInput[]' could be found (are you missing a using directive or an assembly reference?)
1>veldrid\src\Veldrid\Graphics\ObjParser.cs(524,29,524,35): error CS1061: 'VertexPositionNormalTexture[]' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'VertexPositionNormalTexture[]' could be found (are you missing a using directive or an assembly reference?)
1>veldrid\src\Veldrid\Graphics\OctreeVisibilityManager.cs(72,61,72,69): error CS1061: 'IEnumerable' does not contain a definition for 'Contains' and no extension method 'Contains' accepting a first argument of type 'IEnumerable' could be found (are you missing a using directive or an assembly reference?)
1>veldrid\src\Veldrid\Graphics\SimpleMeshDataProvider.cs(71,29,71,35): error CS1061: 'VertexPositionNormalTexture[]' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'VertexPositionNormalTexture[]' could be found (are you missing a using directive or an assembly reference?)
1>veldrid\src\Veldrid\Graphics\OpenGL\OpenGLMaterial.cs(142,33,142,39): error CS1061: 'MaterialVertexInput[]' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'MaterialVertexInput[]' could be found (are you missing a using directive or an assembly reference?)

[Metal] Strange behaviour with uniforms split up over vertex and fragment shaders.

Hello,

I noticed something odd when looking at uniforms and metal.

So I have a resource layout:
ResourceLayouts = new ResourceLayout[]{_cameraResourceLayout,_materialResourceLayout,_lightResourceLayout}

Which results in the following uniform bindings in metal

Vertex

vertex PixelInput VS(VertexInput input[[stage_in]],constant ProjView &pj [[ buffer(1) ]],constant Light &l [[ buffer(3) ]])

Sure, light is last in the layout so it gets assigned to 3

Fragment

fragment float4 FS(PixelInput input[[stage_in]],constant Material &material [[buffer(1)]])

I was expecting 2 here, but ok, its the first element in the fragment stage.

However, changing the resource layout has no effect on the bindings (?)

ResourceLayouts = new ResourceLayout[] {_cameraResourceLayout,_lightResourceLayout,_materialResourceLayout}

Vertex Expected

vertex PixelInput VS(VertexInput input[[stage_in]],constant ProjView &pj [[ buffer(1) ]],constant Light &l [[ buffer(2) ]])

But it is still 3.

Is this intended?

DX 12 support

Hello, can you tell me, if you're planning on implementing DirectX 12 support?
And/or OpenVR support (asking here, so I don't need to split it to two issues)

GLTF2 loader

I think as gltf2 growing as standard model/scene format would be good to have support for it

ShaderGen Rider incompatibility

The NeoDemo project, and many other samples, aren't compatbile with rider and fails at the following step:

<Exec Command="dotnet $(_SGExePath) $(_SGArgs)"
          WorkingDirectory="$(MSBuildProjectDirectory)"
          StandardOutputImportance="high"
          ContinueOnError="$(_SGContinueOnError)" />

The error is:

  ShaderGen.targets(35, 5): [MSB3073] The command "dotnet C:\Users\Dylan Perks\.nuget\packages\shadergen.build\1.2.0-g4bf25fc276\build\ShaderGen.App.dll  --ref " G:\veldrid\bin\obj\NeoDemo\Debug\netcoreapp2.0\_sgreferences.txt " --src " G:\veldrid\bin\obj\NeoDemo\Debug\netcoreapp2.0\_sgsources.txt " --out " G:\veldrid\src\NeoDemo\Assets\Shaders.Generated " --genlist "G:\veldrid\bin\obj\NeoDemo\Debug\netcoreapp2.0\_sggeneratedfiles.txt" --listall" exited with code 1.

Extending Sdl2Window

Hi,

I've used Veldrid.Sdl2 & Veldrid.StartupUtilities - at least initially - for convenience's sake. (I'm more used to GLFW). I've stuck with them as they seem to be quite sufficient for what I need to do, and I like the Sdl2Window abstraction.

But I've got a few gripes with InputSnapshot; I'm integrating a GUI system into my project and timestamps for events seems important, so that if e.g. a mouse click and a key press comes in on the same frame I can tell whether the click (which may change focus) came before or after the key press. The InputSnapshot API precludes being able to figure this out.

I'd also like to get my claws into some of the joystick/controller events, which are just ignored atm. So I've been thinking about extensibility w.r.t. Sdl2Window more generally.

What are your thoughts on the following approaches:

  • Adding an Action<SDL_Event> handler parameter to PumpEvents & ProcessEvents / public event Action<SDL_Event> SDLEvent; field to the class, and have this be called before the switch block inside the while (SDL_PollEvent(&ev) != 0) loop?
  • Changing ProcessEvents to protected virtual & a bunch of private fields to protected accessibility, so it could be possible to override some of this behaviour
  • Changing/Adding additional overloads in Veldrid.StartupUtilities.VeldridStartup.cs with IntPtr sdlWindowHandle in place of Sdl2Window window arguments, so it's easy to use a project-specific class that isn't Sdl2Window w/Veldrid.SU. (Would also need to add int windowWidth, int windowHeight arguments... bah)
  • Possibly just exposing a kind of EventSnapshot that just has a list of the received SDL_Events in order?

The first option is IMO minimally invasive & my favourite option, but I'd like to hear your thoughts.

Thanks for your time (& for veldrid) :)

Cannot build on linux due to failed HLSL shader compilation

The shader compilation target cannot compile HLSL shaders on linux (and I'd assume on mac as well) and the build fails:

✔ nathan:veldrid [ master | ✚ 1 ] $ dotnet build src/Veldrid.sln
Microsoft (R) Build Engine version 15.3.388.41745 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Veldrid.Primitives -> /home/nathan/projects/veldrid/bin/Debug/Veldrid.Primitives/netstandard1.6/Veldrid.Primitives.dll
  Veldrid -> /home/nathan/projects/veldrid/bin/Debug/Veldrid/netstandard1.6/Veldrid.dll
  Veldrid.Sdl2 -> /home/nathan/projects/veldrid/bin/Debug/Veldrid.Sdl2/netstandard1.6/Veldrid.Sdl2.dll
  Veldrid.SystemAbstractions -> /home/nathan/projects/veldrid/bin/Debug/Veldrid.SystemAbstractions/netstandard1.6/Veldrid.SystemAbstractions.dll
  Veldrid.ImGui -> /home/nathan/projects/veldrid/bin/Debug/Veldrid.ImGui/netstandard1.6/Veldrid.ImGui.dll
  Veldrid.Assets -> /home/nathan/projects/veldrid/bin/Debug/Veldrid.Assets/netcoreapp1.1/Veldrid.Assets.dll
  RenderDemo.Common -> /home/nathan/projects/veldrid/bin/Debug/RenderDemo.Common/netcoreapp1.1/RenderDemo.Common.dll
  Veldrid.Tests -> /home/nathan/projects/veldrid/bin/Debug/Veldrid.Tests/netcoreapp1.1/Veldrid.Tests.dll
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/billboard-geometry.hlsl.bytes" because it was not found. [/ho
me/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/cube-geometry.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/forward_mtl-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/lit-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/shadow-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/shadowmap-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/simple-2d-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/simple-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/skybox-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/textured-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/geometry-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/instanced-simple-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/wireframe-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/forward_mtl-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/shadow-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/shadowmap-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/simple-2d-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/simple-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/skybox-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/textured-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/geometry-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/instanced-simple-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/wireframe-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]

Build FAILED.

/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/billboard-geometry.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/cube-geometry.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/forward_mtl-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/lit-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/shadow-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/shadowmap-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/simple-2d-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/simple-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/skybox-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/textured-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/geometry-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/instanced-simple-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/wireframe-frag.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/forward_mtl-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/shadow-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/shadowmap-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/simple-2d-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/simple-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/skybox-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/textured-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/geometry-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/instanced-simple-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
/opt/dotnet/sdk/2.0.0-preview2-006497/Microsoft.Common.CurrentVersion.targets(4402,5): error MSB3030: Could not copy the file "/home/nathan/projects/veldrid/bin/obj/RenderDemo/Debug/netcoreapp1.1/HLSL/wireframe-vertex.hlsl.bytes" because it was not found. [/home/nathan/projects/veldrid/src/RenderDemo/RenderDemo.csproj]
    0 Warning(s)
    23 Error(s)

Time Elapsed 00:00:09.75

By setting <PreprocessHlslShaders>true</PreprocessHlslShaders> to <PreprocessHlslShaders>false</PreprocessHlslShaders> for the RenderDemo, the project can be built successfully and run.

Veldrid.StartupUtilities / Sdl2 do not add sdl2 binary

Hi,

I just trying your tutorials with vs code on mac.
My .csproject file after part1 of your tutorial looks like this
... <ItemGroup> <PackageReference Include="Veldrid" Version="4.0.0" /> <PackageReference Include="Veldrid.StartupUtilities" Version="4.0.0" /> </ItemGroup> ...

However, running dotnet restore does not include the binary.
Headerfiles are loaded, because autocompletion works.
But the program will crash at runtime.
Sdl2Window window = VeldridStartup.CreateWindow(ref windowCI); // crash

I dont know if nuget should resolve binary dependencies, but from the tutorial it seems like it should just work with these commands.

Thanks you for this API.

Best,
Marc

Type initializer for Veldrid.Sdl2.Sdl2Native: NullReferenceException

Exception thrown: 'System.TypeInitializationException' in Veldrid.SDL2.dll
An unhandled exception of type 'System.TypeInitializationException' occurred in Veldrid.SDL2.dll
The type initializer for 'Veldrid.Sdl2.Sdl2Native' threw an exception
---
NullReferenceException: Object reference not set to an instance of an object.

The code is the Part 1 tutorial:

using Veldrid;
using Veldrid.Sdl2;
using Veldrid.StartupUtilities;

namespace VeldridTutorial
{
    class Program
    {
        private static GraphicsDevice _graphicsDevice;

        static void Main(string[] args)
        {
            WindowCreateInfo windowCI = new WindowCreateInfo()
            {
                X = 100,
                Y = 100,
                WindowWidth = 960,
                WindowHeight = 540,
                WindowTitle = "Veldrid Tutorial"
            };
            Sdl2Window window = VeldridStartup.CreateWindow(ref windowCI);

            _graphicsDevice = VeldridStartup.CreateGraphicsDevice(window);

            while (window.Exists)
            {
                window.PumpEvents();
            }
        }
    }
}

I'm running Windows 10, using the v4.0.0-beta1 from NuGet. Any help is appreciated.

Vulkan RenderSets

Hey there!
I have been writing some stuff lately and have struck what seems to me like a bug. While using an OpenGL backend code works perfectly and renders a couple of transformed images with a help of a simple shader. However, when I switch to a Vulkan renderer, it seems like it doesn't create the resource sets, described by the ResourceLayout-s.

Here is an Exception:
Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Veldrid.Vk.VkCommandList.SetGraphicsResourceSetCore(UInt32 slot, ResourceSet rs)
at Neptune.Engine.Sample.SimpleRenderer.Draw() in /media/skyne/ExternalDrive/projects/Neptune/Engine/Sample/SimpleRenderer.cs:line 47
at Neptune.Engine.Sample.SimpleRenderer.BatchDraw(Action`1 action) in /media/skyne/ExternalDrive/projects/Neptune/Engine/Sample/SimpleRenderer.cs:line 38
at Neptune.Engine.Sample.SimpleGame.Render(RenderInfo info) in /media/skyne/ExternalDrive/projects/Neptune/Engine/Sample/SimpleGame.cs:line 49
at Neptune.Program.Main() in /media/skyne/ExternalDrive/projects/Neptune/Program.cs:line 39

Thanks for your attention!

Veldrid can't be compiled without VALIDATE_USAGE define

@mellinoe
2>3rdParty\Veldrid\Source\Veldrid\CommandList.cs(800,36,800,61): error CS1061: 'Pipeline' does not contain a definition for 'GraphicsOutputDescription' and no extension method 'GraphicsOutputDescription' accepting a first argument of type 'Pipeline' could be found (are you missing a using directive or an assembly reference?)

More likely this is because of:
#if VALIDATE_USAGE
internal OutputDescription GraphicsOutputDescription { get; }
#endif

Calling CommandList.SetVertexBuffer with a null DeviceBuffer throws a NullReferenceException

I'm trying to do this:

commandList.SetVertexBuffer(1, null);

in order to clear any previously-set buffers for that slot. But both CommandList.SetVertexBuffer and the derived implementations of CommandList.SetVertexBufferCore expect the buffer argument to be non-null.

Is this by-design, or a bug? If it's a bug I can create a PR to fix it. If it's by-design, is there a better way to do what I'm trying to do?

I suppose that what I'm trying to do is actually unnecessary, as long as the current pipeline doesn't reference a vertex buffer in that slot (and if it did I should be setting a non-null buffer anyway), but it doesn't feel right to leave the old buffer lying around.

Render passes

Hi,
I would like to introduce the concept of render passes, maybe you can tell me if you want to add this to veldrid or not, thus means I would suggest to rename Framebuffer into RenderPass and have something similar to metal render pass descriptor, then have BeginRenderPass and EndRenderPass on CommandList instead of SetFramebuffer.

What do you think?

Directory.Build.props ProjectDir conflicts

Hi,
I copied the Directory.Build.props into my project directory, I had some issue with Visual Studio 2017 not resolving the correct include paths, and it happens when you have native c++ projects into the solution.

$(ProjectDir) overrides the C++ ProjectDir and causes issues with resolve path.

Probably in Veldrid that won't cause issue as you have only Managed projects, just pointing the issue I faced :)

[Feature Request] Disable not needed graphics API?

@mellinoe
Is there any way to disable graphics API that you don't need?
May be some global defines like VULKAN_ENABLE / D3D11_ENABLE ?
For example, in my project I would like to support only Win64 & OSX64, so I need only D3D11 & Metal support, thus would like to disable OGL/Vulkan (so as result to not have a dependency on Vk module)

Can you add such feature (if there is none yet), please?

Help: How to render with a MVP Matrix

Hi,

I'm trying to make the OpenGL Tutorials by using Veldrid and I'm stuck a bit.

Currently I'm experimenting with the matrices tutorial:
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/

I can pass the MVP matrix to the vertex shader, but as soon as I'm applying it to the position vertex I can't see anything anymore.
https://github.com/lehmamic/VedridExercises/tree/Tutorial-3--Matrices

Could you please give me a hint what is wrong? Thanks.

-[NVMTLRenderCommandEncoder setViewports:count:]: unrecognized selector sent to instance

macOS Sierra 10.12.6

Exception:

2018-03-21 14:25:38.162 dotnet[14123:236176] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NVMTLRenderCommandEncoder_KEPLER_A setViewports:count:]: unrecognized selector sent to instance 0x7fd5cde57790'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fffbcb1a2cb __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x00007fffd193148d objc_exception_throw + 48
	2   CoreFoundation                      0x00007fffbcb9bf04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
	3   CoreFoundation                      0x00007fffbca8c755 ___forwarding___ + 1061
	4   CoreFoundation                      0x00007fffbca8c2a8 _CF_forwarding_prep_0 + 120
	5   ???                                 0x00000001112457c7 0x0 + 4582561735
	6   ???                                 0x0000000111245303 0x0 + 4582560515
	7   ???                                 0x0000000111242e5e 0x0 + 4582551134
	8   ???                                 0x00000001112429f3 0x0 + 4582550003
	9   ???                                 0x00000001112420ee 0x0 + 4582547694
	10  ???                                 0x000000011123f2a1 0x0 + 4582535841
	11  ???                                 0x0000000111220bfa 0x0 + 4582411258
	12  libcoreclr.dylib                    0x000000010a4ce111 CallDescrWorkerInternal + 124
	13  libcoreclr.dylib                    0x000000010a3c534d _ZN18MethodDescCallSite16CallTargetWorkerEPKmPmi + 909
	14  libcoreclr.dylib                    0x000000010a29bcaa _Z7RunMainP10MethodDescsPiPP8PtrArray + 682
	15  libcoreclr.dylib                    0x000000010a29bf1f _ZN8Assembly17ExecuteMainMethodEPP8PtrArrayi + 223
	16  libcoreclr.dylib                    0x000000010a2d6884 _ZN8CorHost215ExecuteAssemblyEjPKDsiPS1_Pj + 436
	17  libcoreclr.dylib                    0x000000010a20fe46 coreclr_execute_assembly + 230
	18  libhostpolicy.dylib                 0x0000000109b64ba8 _ZNSt3__16vectorIPKcNS_9allocatorIS2_EEE18__construct_at_endEm + 1288
	19  libhostpolicy.dylib                 0x0000000109b54b66 _ZNSt3__121__thread_specific_ptrINS_15__thread_structEE5resetEPS1_ + 47606
	20  libhostpolicy.dylib                 0x0000000109b568a0 _ZN17hostpolicy_init_t4initEP16host_interface_tPS_ + 2112
	21  libhostfxr.dylib                    0x0000000109a90ca3 _ZNSt3__112basic_stringIDsNS_11char_traitsIDsEENS_9allocatorIDsEEE6appendEmDs + 3283
	22  libhostfxr.dylib                    0x0000000109ab0b60 _ZNSt3__16vectorIPKcNS_9allocatorIS2_EEE6insertIPS2_EENS_9enable_ifIXaasr21__is_forward_iteratorIT_EE5valuesr16is_constructibleIS2_NS_15iterator_traitsIS9_E9referenceEEE5valueENS_11__wrap_iterIS7_EEE4typeENSD_IPKS2_EES9_S9_ + 12704
	23  libhostfxr.dylib                    0x0000000109aad7f0 _ZNK8fx_ver_t9get_patchEv + 61792
	24  libhostfxr.dylib                    0x0000000109ab18ca _ZN16runtime_config_t12get_dev_pathEv + 2666
	25  libhostfxr.dylib                    0x0000000109a915c5 _ZN15corehost_init_t18get_host_init_dataEv + 2277
	26  dotnet                              0x00000001099c3edc _ZN8fx_ver_taSERKS_ + 2988
	27  dotnet                              0x00000001099c4075 _ZN3pal10strcasecmpEPKcS1_ + 213
	28  libdyld.dylib                       0x00007fffd2217235 start + 1
	29  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Stack Trace:

Veldrid.MetalBindings.dll!Veldrid.MetalBindings.MTLRenderCommandEncoder.setViewports(Veldrid.MetalBindings.MTLViewport* viewports, System.UIntPtr count) Line 93
(/veldrid/src/Veldrid.MetalBindings/MTLRenderCommandEncoder.cs:93)
Veldrid.dll!Veldrid.MTL.MTLCommandList.PreDrawCommand() Line 153 (/veldrid/src/Veldrid/MTL/MTLCommandList.cs:153)
Veldrid.dll!Veldrid.MTL.MTLCommandList.DrawIndexedCore(uint indexCount, uint instanceCount, uint indexStart, int vertexOffset, uint instanceStart) Line 112 (/veldrid/src/Veldrid/MTL/MTLCommandList.cs:112)
Veldrid.dll!Veldrid.CommandList.DrawIndexed(uint indexCount, uint instanceCount, uint indexStart, int vertexOffset, uint instanceStart) Line 372 (/veldrid/src/Veldrid/CommandList.cs:372)

My code (in render loop):

            _commandList.Begin();

            _commandList.SetFramebuffer(GraphicsDevice.SwapchainFramebuffer);
            _commandList.SetFullViewports();

            _commandList.ClearColorTarget(0, RgbaFloat.Black);

            _commandList.SetVertexBuffer(0, _vertexBuffer);
            _commandList.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16);
            _commandList.SetPipeline(_pipeline);
            _commandList.DrawIndexed(
                indexCount : 4,
                instanceCount : 1,
                indexStart : 0,
                vertexOffset : 0,
                instanceStart : 0);
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.