Code Monkey home page Code Monkey logo

terrafx's Introduction

TerraFX

A framework for developing multimedia-based applications.

ci Discord

Packages are available at: https://github.com/orgs/terrafx/packages or via the NuGet Feed URL: https://pkgs.terrafx.dev/index.json

Table of Contents

Code of Conduct

ClangSharp and everyone contributing (this includes issues, pull requests, the wiki, etc) must abide by the .NET Foundation Code of Conduct: https://dotnetfoundation.org/about/code-of-conduct.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected].

License

Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.

Contributing

If you are looking to contribute you should read our Contributing documentation.

Documentation

Design

Project

Samples

terrafx's People

Contributors

finitereality avatar ingmarbitter avatar john-h-k avatar nathan-alden-sr avatar tannergooding 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

terrafx's Issues

Expose core functionality on Matrix4x4

Rationale

Matrix4x4 is currently a fairly opaque type. It should be update to expose a standard set of APIs such as are exposed in the DirectX Math library.

Proposed API

public readonly struct Matrix4x4
{
    public static Matrix4x4 CreateRotation(Quaternion rotation);
    public static Matrix4x4 CreateScale(Vector4 scale);
    public static Matrix4x4 CreateTranslation(Vector4 translation);

    public static Matrix4x4 operator +(Matrix4x4 value);
    public static Matrix4x4 operator -(Matrix4x4 value);

    public static Matrix4x4 operator +(Matrix4x4 left, Matrix4x4 right);
    public static Matrix4x4 operator -(Matrix4x4 left, Matrix4x4 right);

    public static Matrix4x4 operator *(Matrix4x4 left, Matrix4x4 right);

    public static Matrix4x4 operator *(Matrix4x4 left, float right);
    public static Matrix4x4 operator /(Matrix4x4 left, float right);

    public static Matrix4x4 Inverse(Matrix4x4 value);
    public static Matrix4x4 Transpose(Matrix4x4 value);
    public static bool TryInverse(Matrix4x4 value, out Matrix4x4 result);

    public float Determinant { get; }
    public bool IsIdentity { get; }

    public void Deconstruct(out Vector4 scale, out Quaternion rotation, out Vector4 translation);
}

[BUG] PulseAudio provider does not have recording abilities

Description

PulseAudio does not yet implement audio recording. This is the issue to track that.

Reproduction Steps

Call IAudioProvider.RequestAudioRecordingDevice with any value, when using the PulseAudio provider.

Expected Behaviour

A recording device should be returned, or an exception thrown if the passed adapter is invalid.

Actual Behaviour

A NotImplementedException is thrown.

Infos about

more infos about the project we'll be good to help for contribution :)

Design and expose the input interface

Rationale

An input interface should be designed so users can receive and respond to input in
their application.

The initial subsystem should support a standard keyboard at minimum. Supporting
additional devices such as a mouse and Xbox Gamepad are nice to have and will
help validate the design.

Expose core functionality on Quaternion

Rationale

Quaternion is currently a fairly opaque type. It should be update to expose a standard set of APIs such as are exposed in the DirectX Math library.

Proposed API

public readonly struct Quaternion
{
    public Quaternion(float value);

    public static bool operator ==(Quaternion left, Quaternion right);
    public static bool operator !=(Quaternion left, Quaternion right);

    public static Quaternion operator +(Quaternion value);
    public static Quaternion operator -(Quaternion value);

    public static Quaternion operator +(Quaternion left, Quaternion right);
    public static Quaternion operator -(Quaternion left, Quaternion right);

    public static Quaternion operator *(Quaternion left, Quaternion right);
    public static Quaternion operator /(Quaternion left, Quaternion right);

    public static Quaternion operator *(Quaternion left, float right);
    public static Quaternion operator /(Quaternion left, float right);

    public static float Dot(Quaternion left, Quaternion right);

    public static Quaternion Conjugate(Quaternion value);
    public static Quaternion Inverse(Quaternion value);
    public static Quaternion Normalize(Quaternion value);

    public float Length { get; }
    public float LengthSquared { get; }
}

Expose core functionality on Matrix3x3

Rationale

Matrix3x3 is currently a fairly opaque type. It should be update to expose a standard set of APIs such as are exposed in the DirectX Math library.

Proposed API

public readonly struct Matrix3x3
{
    public static Matrix3x3 CreateRotation(Quaternion rotation);
    public static Matrix3x3 CreateScale(Vector3 scale);
    public static Matrix3x3 CreateTranslation(Vector3 translation);

    public static Matrix3x3 operator +(Matrix3x3 value);
    public static Matrix3x3 operator -(Matrix3x3 value);

    public static Matrix3x3 operator +(Matrix3x3 left, Matrix3x3 right);
    public static Matrix3x3 operator -(Matrix3x3 left, Matrix3x3 right);

    public static Matrix3x3 operator *(Matrix3x3 left, Matrix3x3 right);

    public static Matrix3x3 operator *(Matrix3x3 left, float right);
    public static Matrix3x3 operator /(Matrix3x3 left, float right);

    public static Matrix3x3 Inverse(Matrix3x3 value);
    public static Matrix3x3 Transpose(Matrix3x3 value);
    public static bool TryInverse(Matrix3x3 value, out Matrix3x3 result);

    public float Determinant { get; }
    public bool IsIdentity { get; }

    public void Deconstruct(out Vector3 scale, out Quaternion rotation, out Vector3 translation);
}

D3D12.HelloTexture throw Out of memory

Description (optional)

TerraFX.Samples.exe D3D12.HelloTexture
Running: D3D12.HelloTexture
Out of memory.

Reproduction Steps

I build and run the the TerraFX.Samples.

Expected Behavior

It can work well.

Actual Behavior

The window is hangs and the console outputs out of memory.

Graphics Samples to be plugged into different GUI frameworks.

Description

The windows interop samples have an option to be embedded into a Windows.Forms based application, where they are all visible in a list box and can be launched in a panel next to it by clicking on the sample name. The same should be done for the TerraFX samples. There should be three editions (in order of importance): WinUI3.0, WinForms, WPF.

Rationale

  • WinUI3.0 is the highest priority because it is the future of C# business application development.
  • WinForms is the second priority because it is easier to implement than WPF and because people that are still on WinForms are more likely feeling the urge to update their technology than those on WPF. If TerraFX demonstrates how first just the rendering can be modernized, but keeping WinForms as the container, then developers can do that as the first step, and when it is done update WinForms to WinUI3.0. So the changes can be spread over two releases and allow faster time to market.
  • WPF is third, but still important, as there are a lot of applications based on it. TerraFX might be wanted as a means to upgrade the rendering but without any intention to change the GUI system.

Additional Thoughts

  • The title should be editable and by default should update to the name of the sample, followed by the current rendering frame rate.
  • There should be simple stubs for standard interaction events, such as WindowResize, MouseMove/Dn/Up, TouchTap/Pinch/Rotate.

Expose core functionality on Vector2

Rationale

Vector2 is currently a fairly opaque type. It should be update to expose a standard set of APIs such as are exposed in the DirectX Math library.

Proposed API

public readonly struct Vector2
{
    public Vector2(float value);

    public static bool operator ==(Vector2 left, Vector2 right);
    public static bool operator !=(Vector2 left, Vector2 right);

    public static Vector2 operator +(Vector2 value);
    public static Vector2 operator -(Vector2 value);

    public static Vector2 operator +(Vector2 left, Vector2 right);
    public static Vector2 operator -(Vector2 left, Vector2 right);

    public static Vector2 operator *(Vector2 left, Vector2 right);
    public static Vector2 operator /(Vector2 left, Vector2 right);

    public static Vector2 operator *(Vector2 left, float right);
    public static Vector2 operator /(Vector2 left, float right);

    public static float Dot(Vector2 left, Vector2 right);

    public static Vector2 Normalize(Vector2 value);

    public float Length { get; }
    public float LengthSquared { get; }
}

Move Hello* samples related shaders into their own subfolders

Description

Shaders that are now in sources\Graphics\Assets\Shaders should be moved one subfolder down such that Identity* will reside in the subfolder ./Identity/ and Sierpinski* in ./Sierpinski/ etc.

Rationale

Clutter in the Solution Explorer is not nice. Folders with too many entries should be broken up.

Discussions

Should be a quick change. Although not trivial. I gave it a quick try and moving + updating the path variable alone is not enough.

Ambiguities

public static readonly Vector2 UnitX = new Vector2(1.0f, 0.0f);

Amongst other places you define an ABI and API for a Vectoral type.

You constantiate the static symbol UnitX and UnitY as a version of a two values which therein are constant components representing the Unit of X or Y for ALL vector types instated of such.

This should be DefaultUnitX and DefaultUnitY and really should NOT be defined in the ordinate space of what you are defining as it becomes concrete and not discrete.

Given the arbitrary sequence [1,0,1,1] and staring at position [1] the only 0 value present that would appear as a UnitY where as the underlying unit is actually UnitX.

Furthermore the Unit is not a specific component of the vector and is discrete amongst the components and MUST not be mistaken for such.

The vector whose components do not reside in the realm of the ordinates and is defined as just for the purpose of orientation and always exists is a must better sentinel value IMHO.

Regards.

Problem with terrafx build failures

Description (optional)

This section should contain an expanded description of the proposal, if the
title is not sufficient.

Rationale

This section should contain the reasoning behind the proposal. It should include
things like "Why do we need this", "How will it improve a developers quality of
life", etc.

Proposed API

This section should contain the APIs being proposed along with a brief
description of what each API does.

Drawbacks

This should contain any drawbacks for the proposal that came up during the
discussions.

Alternatives

This should contain any alternative proposals that came up during the
discussions.

Other thoughts

This should contain any additional thoughts or footnotes on the proposal.

Discussions (optional)

This section should contain a link to all discussions related to the proposal
that have been made thus far.

I have downloaded with git clone and change cd terrafx and git checkout "experimental/vulkan" then I check ls there are sh files.
And I got errors because safety with net6.0

Build FAILED.

/home/jens/Documents/terrafx/sources/Core/Utilities/MarshalUtilities.cs(120,44): error CS9094: This returns a parameter by reference 'source' through a ref parameter; but it can only safely be returned in a return statement [/home/jens/Documents/terrafx/sources/Core/TerraFX.csproj::TargetFramework=net6.0]
/home/jens/Documents/terrafx/sources/Core/Utilities/MarshalUtilities.cs(166,44): error CS9094: This returns a parameter by reference 'source' through a ref parameter; but it can only safely be returned in a return statement [/home/jens/Documents/terrafx/sources/Core/TerraFX.csproj::TargetFramework=net6.0]
    0 Warning(s)
    2 Error(s)

My dotnet installed in $HOME/.dotnet
dotnet --info tells

.NET SDK:
 Version:   7.0.202
 Commit:    6c74320bc3

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /home/jens/.dotnet/sdk/7.0.202/

Host:
  Version:      7.0.4
  Architecture: x64
  Commit:       0a396acafe

.NET SDKs installed:
  6.0.300-preview.22204.3 [/home/jens/.dotnet/sdk]
  6.0.405 [/home/jens/.dotnet/sdk]
  6.0.407 [/home/jens/.dotnet/sdk]
  7.0.102 [/home/jens/.dotnet/sdk]
  7.0.202 [/home/jens/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.3 [/home/jens/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.13 [/home/jens/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.15 [/home/jens/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.2 [/home/jens/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.4 [/home/jens/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.3 [/home/jens/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.13 [/home/jens/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.15 [/home/jens/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.2 [/home/jens/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.4 [/home/jens/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/home/jens/.dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

How do I set current version?

Design and expose a camera system

Rationale

A camera system should be designed and exposed so users can trivially create perspective,
orthographic, and other types of cameras for use in their application.

HelloCombined

Description (optional)

HelloCombined is a sample that combines multiple of the single feature samples. At a minimum those of HelloTexture and HelloConstBuffer. The point is to show how to set the shaders and pipeline state such that all combined features are considered simultaneously.

Rationale

This sample is useful since it steps up implementation complexity a little. So it shows the next step toward a little more realistic application use.

Proposed API

Same as the other Hello* samples, derived from HelloWindow

Other thoughts

The class name initially would be more matchingly HelloTextureConstBuffer, but if more basic features are added then we do not want to have to change the class name. So HelloCombined is a little more future proof.

TexelFormat

The current enum TexelFormat should become a struct.

Rationale

TerraFX needs to interface with Dx12 and Vulkan which use similar but incompatible enums for texel formats. Thus TerraFX needs a bridge type. The target enums are very numerous and therefore somewhat confusing. A struct with separate fields for the different concepts that make up the format can decouple the combinatorial complexity into just a few enums that the struct will then combine to match to the target enum.

Proposed API

public struct TexelFormat
{
    public struct Channel
    {
        public enum Type
        {
            Unknown,
            Typeless,
            Int,
            Float,
        }

        public enum ValueRange
        {
            Signed,
            Unsigned,
        }

        public enum BitCount
        {
            8,
            16,
            32,
        }

        public enum Kind
        {
            R,
            G,
            B,
            A,
            X,
        }

        public enum SamplingConverstion
        {
            Identity,
            Normalize, // [0.0f,1.0f] if ValueRange.Signed; [-1.0f,1.0f] if ValueRange.Unsigned
        }

        private Type _type;
        private ValueRange _valueRange;
        private BitCount _bitCount;
        private Kind _kind;
        private SamplingConverstion _samplingConversion; 
    }

    private Channel[] _channels;
}

Discussions

In the commit f4206d1 with message "Reduced TexelFormat to a simple enum" has a partial early implementation of this.

An implementation of this may not need all target formats at the beginning, but the three of the current enum should be really supported:
R8G8B8A8_UNORM,
R16_SINT,
R16G16UINT,

Calling IDXGISwapChain::GetBuffer throws a C# Null Reference Exception unexpectedly

Description (optional)

Calling IDXGISwapChain::GetBuffer throws a C# Null Reference Exception unexpectedly

Reproduction Steps

Create a Win32 Window with a valid HWND instance

Create a D3D11CreateDeviceAndSwapChain formed swap chain, yielding a IDXGISwapChain instance

Call GetBuffer of the IDXGISwapChain instance to attempt to get a ID3D11Texture2D instance

Receive a Null Reference Exception

Expected Behavior

Expecting no C# exception, instead a HRESULT returned to indicate status of the operation

Actual Behavior

Get a C# null reference exception

Additional Information

I'm trying to figure out why this code [pic1] is throwing a null reference exception.
Where framebuffer is 0x00000258000bac18, *framebuffer: {TerraFX.Interop.DirectX.ID3D11Texture2D}
where chain is 0x00000258000ab300 *chain: {TerraFX.Interop.DirectX.IDXGISwapChain}
and retval is a HRESULT struct instance.
Windows.__uuidof() returns riid: 0x00007ffe5e010738
image

Any suggestions?

This occurs even after downgrading to stable version 10.0.20348
ppSurface
0x00007ffe62666da8
*ppSurface: 0x0000000000000000
riid
0x00007ffe62ca8708
*riid: {6f15aaf2-d208-4e89-9ab4-489535d34f9c}
Buffer
0
lpVtbl
'lpVtbl' threw an exception of type 'System.NullReferenceException'
image

I have a minimal reproducing example on my system here [ https://github.com/ShadowMarker789/TerraFX-DXGI-SwapChain/tree/master/TerraFX-DXGI-SwapChain ] - check out Program.cs file, Win32Window.cs is just producing the HWND instance.

[BUG] PulseAudio playback/recording devices only support little-endian signed shorts

Description

GetSampleFormat() in PulseAudioPlaybackDevice.CreateStream and PulseAudioRecordingDevice.CreateStream (see #55) returns a hard-coded constant, pa_sample_format.PA_SAMPLE_S16LE. This means they don't support anything other than signed little-endian shorts.

I actually forgot to open this in response to #26 - but working on the recording device reminded me that the issue still exists.

Reproduction Steps

Request any playback (or recording, with #55) device with a sample format other than PA_SAMPLE_S16LE.

Expected Behavior

The returned audio device uses the requested format.

Actual Behavior

The returned audio device only uses PA_SAMPLE_S16LE.

[PROPOSAL] Make IGraphicsContext and IWindow IDispoable

Rationale

This would remove an extra nesting level required right from the beginning of the Project, and allow the usage of using, removing the need to manually insert a try { } finally { } which would be quite useful for experimenation, when there is little abstraction, and causing issues is common (therefore catching issues is important)

Proposed API

- public interface IWindow
+ public interface IWindow : IDisposable
{
+    void Dispose();
}

- public interface IGraphicsContext
+ public interface IGraphicsContext : IDisposable
{
+    void Dispose();
}

Note: void Dispose() is implicit

Drawbacks

  • Future providers might need to implement an empty implementation of IDisposable.Dispose, but this is unlikely, as Graphics generally rely on unmanaged resources (all current do)
  • Future providers cannot choose to use IAsyncDisposable instead of IDisposable, but this would've been a hazard to the current implementation anyways. therefore I don't consider this a drawback worth considering

Alternatives

The current solution is to check if the returned implementation of IWindow / IGraphicsContext implement IDisposable and Dispose them if needed, which also requires a manual try { } finally { }
instead of a using var ... = ...

Other thoughts

I assume that this has been thought of, but there was some reasoning behind not doing this, but I cannot think of why, in part writing this because I'm curious of the reasoning

Setup a CI system

TerraFX does not currently have any CI system configured. One should be setup so that pull requests can ve validated to not exist the current state of the repository.

Refactor the graphics context to support instancing

Rationale

The graphics context currently supports rendering a single instance from a provided graphics primitive.

This should be refactored so a user can render an arbitrary number of instances with a single command
(within the limits of the underlying APIs).

A corresponding sample should be provided with this work.

StructuredBuffer

Description

TerraFX should allow StructuredBuffer as a resource.

Rationale

Expensive to calculate functions can be precomputed and the results stored in a lookup table. There is no need for any sampling, interpolation, or out-of-bounds address math. At render time, the shader just has to index into the buffer to lookup the computation result.

Discussions (optional)

Initially, StructuredBuffer<TexelFormat.R8G8B8A8_UNORM> as SRV resource is what is most needed.

Expose an audio provider on Windows

Rationale

There is currently only a single audio provider today, which is the PulseAudio provider available on Linux.

An additional audio provider should be implemented for use on Windows. It should likely use XAudio2 or
WASAPI. This will also allow the audio interface to be vetted and ensure it is in the correct shape.

Texture Sampling API

Description

TerraFX needs a way to specify the texture sampler state, especially for the addressing mode and the filtering mode.

Rationale

See
https://www.3dgep.com/learning-directx-12-4/#Address_Mode and
https://www.3dgep.com/learning-directx-12-4/#Filter
for pictures showing how the different modes work.

Proposed API

struct AddressMode {
Wrap,
Clamp,
Border,
Mirror, // not important to have
MirrorOnce, // not important to have
}

struct FilterMode {
Point,
Linear,
Anisotropic, // not important to have
}

[PROPOSAL] Make IAudioAdapter read-only

Description (optional)

From #26, we agreed that:

It seems wrong that users can modify the name, description, sample rate of the adapter; but doing so does nothing

As such, I believe we should make it read-only to prevent these cases, and add a separate class to handle the case which required these to be mutable.

Rationale

By adding a separate class to contain a "request" to find the closest matching adapter, we can simplify our code and make it less confusing to users.

Proposed API

 public interface IAudioAdapter
 {
     /// <summary>The type of device this adapter represents.</summary>
-    AudioDeviceType DeviceType { get; set; }
+    AudioDeviceType DeviceType { get; }
 
     /// <summary>The name of the adapter.</summary>
-    string Name { get; set; }
+    string Name { get; }
 
     /// <summary>The sample rate the adapter operates at.</summary>
-    int SampleRate { get; set; }
+    int SampleRate { get; }
 
     /// <summary>The number of bits in each sample this adapter operates at.</summary>
-    int BitDepth { get; set; }
+    int BitDepth { get; }
 
     /// <summary>The number of channels this adapter operates at.</summary>
-    int Channels { get; set; }
+    int Channels { get; }
 
     /// <summary>The endianness of the adapter.</summary>
     /// <remarks>If the adapter operates in big endian mode (MSB first), this will be <c>true</c>; otherwise, it operates in little endian mode (LSB first) and will be <c>false</c>.</remarks>
-    bool IsBigEndian { get; set; }
+    bool IsBigEndian { get; }
 }
 
 // Documentation is roughly the same as IAudioAdapter, except it talks about filtering instead of the adapter.
 // Abstract as implementations will likely have more properties to filter on.
+public abstract class AudioAdapterFilter
+{
+    AudioDeviceType? DeviceType { get; set; }
+    string? Name { get; set; }
+    int? SampleRate { get; set; }
+    int? BitDepth { get; set; }
+    int? Channels { get; set; }
+    bool? IsBigEndian { get; set; }
+}
 
 public interface IAudioProvider
 {
     // Searches for the adapter with the closest properties
+    ValueTask<IAudioAdapter> GetClosestAdapterAsync(AudioAdapterFilter filter);
 }

Drawbacks

There is no way of identifying how "close" the user wants the returned adapter to be. They could be fine with a varying sample rate or bit depth, for example. We should add documentation on how to correctly request a device so that the user can handle the inevitable case where these properties do not match up.

Alternatives

None yet.

Other thoughts

We could possibly just throw NotSupportedException on set instead of making a separate type, and then keep the interface as is, to allow passing an existing set of properties through, but this might just confuse users further. Solved by making RequestAudio(Playback/Recording)Device take an IAudioAdapter, and exposing a "find closest device" method.

Discussions

#26 (review)
#26 (review)
that have been made thus far.

[Question] Can't clone project, no access to https://[email protected]/tagoo/terrafx/

When trying to clone my Fork, I'm promted to login by LFS via the VS Credentials Window. But I do not have access to https://[email protected]/tagoo/terrafx/
Looks like the pictures in /docs/samples/ still point to that repo?
The specific error LFS returned is Error downloading object: docs/samples/D3D12.EnumerateGraphicsAdapters - Windows.png (36b7ddb): Smudge error: Error downloading docs/samples/D3D12.EnumerateGraphicsAdapters - Windows.png (36b7ddb1857f88dc4185de8e563fe34cee8f284d1e714519b905c3ffe5a0ac23): batch response: Git credentials for https://[email protected]/tagoo/terrafx/_git/terrafx.git/info/lfs not found.
Full Log

Expose core functionality on Vector3

Rationale

Vector3 is currently a fairly opaque type. It should be update to expose a standard set of APIs such as are exposed in the DirectX Math library.

Proposed API

public readonly struct Vector3
{
    public Vector3(float value);

    public static bool operator ==(Vector3 left, Vector3 right);
    public static bool operator !=(Vector3 left, Vector3 right);

    public static Vector3 operator +(Vector3 value);
    public static Vector3 operator -(Vector3 value);

    public static Vector3 operator +(Vector3 left, Vector3 right);
    public static Vector3 operator -(Vector3 left, Vector3 right);

    public static Vector3 operator *(Vector3 left, Vector3 right);
    public static Vector3 operator /(Vector3 left, Vector3 right);

    public static Vector3 operator *(Vector3 left, float right);
    public static Vector3 operator /(Vector3 left, float right);

    public static Vector3 Cross(Vector3 left, Vector3 right);
    public static float Dot(Vector3 left, Vector3 right);

    public static Vector3 Normalize(Vector3 value);

    public float Length { get; }
    public float LengthSquared { get; }
}

Exception in TerraFX.Samples coming from D3D12GraphicsHeap

Bug

I wanted to check out the project, so I cloned it, ran TerraFX.Samples (the default startup project) with Visual Studio, and I hit this exception:

Running: D3D12.EnumerateGraphicsAdapters
    Name: NVIDIA Quadro P400
        Device ID: 7347
        Vendor ID: 4318
    Name: Microsoft Basic Render Driver
        Device ID: 140
        Vendor ID: 5140
Running: Vulkan.EnumerateGraphicsAdapters
    Name: Quadro P400
        Device ID: 7347
        Vendor ID: 4318
Running: D3D12.HelloWindow
Running: Vulkan.HelloWindow
Running: D3D12.HelloTriangle
Unhandled exception. System.Runtime.InteropServices.ExternalException (0x80070057): CreateHeap failed with an error code of -2147024809
   at TerraFX.Utilities.ExceptionUtilities.ThrowExternalException(String methodName, Int32 errorCode) in D:\terrafx\sources\Utilities\ExceptionUtilities.cs:line 48
   at TerraFX.Graphics.Providers.D3D12.HelperUtilities.ThrowExternalExceptionIfFailed(String methodName, Int32 hr) in D:\terrafx\sources\Providers\Graphics\D3D12\HelperUtilities.cs:line 28
   at TerraFX.Graphics.Providers.D3D12.D3D12GraphicsHeap.CreateD3D12Heap() in D:\terrafx\sources\Providers\Graphics\D3D12\D3D12GraphicsHeap.cs:line 101
   at TerraFX.Utilities.ValueLazy`1.CreateValue() in D:\terrafx\sources\Utilities\ValueLazy`1.cs:line 119
   at TerraFX.Utilities.ValueLazy`1.get_Value() in D:\terrafx\sources\Utilities\ValueLazy`1.cs:line 64
   at TerraFX.Graphics.Providers.D3D12.D3D12GraphicsHeap.get_D3D12Heap() in D:\terrafx\sources\Providers\Graphics\D3D12\D3D12GraphicsHeap.cs:line 39
   at TerraFX.Graphics.Providers.D3D12.D3D12GraphicsBuffer.CreateD3D12Resource() in D:\terrafx\sources\Providers\Graphics\D3D12\D3D12GraphicsBuffer.cs:line 95
   at TerraFX.Utilities.ValueLazy`1.CreateValue() in D:\terrafx\sources\Utilities\ValueLazy`1.cs:line 119
   at TerraFX.Utilities.ValueLazy`1.get_Value() in D:\terrafx\sources\Utilities\ValueLazy`1.cs:line 64
   at TerraFX.Graphics.Providers.D3D12.D3D12GraphicsBuffer.get_D3D12Resource() in D:\terrafx\sources\Providers\Graphics\D3D12\D3D12GraphicsBuffer.cs:line 41
   at TerraFX.Graphics.Providers.D3D12.D3D12GraphicsBuffer.Map[T](UIntPtr readRangeOffset, UIntPtr readRangeLength) in D:\terrafx\sources\Providers\Graphics\D3D12\D3D12GraphicsBuffer.cs:line 56
   at TerraFX.Graphics.GraphicsBuffer.Map[T]() in D:\terrafx\sources\Graphics\GraphicsBuffer.cs:line 62
   at TerraFX.Samples.Graphics.HelloTriangle.<CreateTrianglePrimitive>g__CreateVertexBuffer|9_0(GraphicsContext graphicsContext, GraphicsHeap graphicsHeap, GraphicsBuffer vertexStagingBuffer, Single aspectRatio) in D:\terrafx\samples\TerraFX\Graphics\HelloTriangle.cs:line 110
   at TerraFX.Samples.Graphics.HelloTriangle.CreateTrianglePrimitive(GraphicsContext graphicsContext, GraphicsBuffer vertexStagingBuffer) in D:\terrafx\samples\TerraFX\Graphics\HelloTriangle.cs:line 103
   at TerraFX.Samples.Graphics.HelloTriangle.Initialize(Application application) in D:\terrafx\samples\TerraFX\Graphics\HelloTriangle.cs:line 59
   at TerraFX.Samples.Program.Run(Sample sample) in D:\terrafx\samples\TerraFX\Program.cs:line 108
   at TerraFX.Samples.Program.<>c__DisplayClass10_0.<RunSample>b__0() in D:\terrafx\samples\TerraFX\Program.cs:line 152
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

D:\terrafx\artifacts\bin\samples\TerraFX.Samples\Debug\net5.0\TerraFX.Samples.exe (process 12488) exited with code 0.

Description (optional)

Failure happened here:

ThrowExternalExceptionIfFailed(nameof(ID3D12Device.CreateHeap), D3D12GraphicsDevice.D3D12Device->CreateHeap(
&heapDesc,
&iid,
(void**)&d3d12Heap
));

I'm sure I'm missing something, maybe misconfiguration, or the project is running something incompatible with my machine.

This is my work PC with Windows 10 64 bits.

Texture3D max size to allow 512x512x1024

Description

HelloTexture3D uses a 3D texture of size 256x256x256. Increasing the texture size to 512x512x512 or 512x512x1024 fails to allocate the texture because of some size limits in TerraFX, not because of insufficient space on the graphics card.
This limit should be increased to handle those sizes.

UnmanagedReadOnlySpan returns a mutable ref and has a Clear method

/// <summary>Gets or sets the item at the specified index of the span.</summary>
/// <param name="index">The index of the item to get or set.</param>
/// <returns>The item that exists at <paramref name="index" /> in the span.</returns>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="index" /> is greater than or equal to <see cref="Length" />.</exception>
public ref T this[nuint index] => ref _span[index];

/// <inheritdoc cref="UnmanagedSpan{T}.Clear()" />
public void Clear() => _span.Clear();

Clear should be removed and the indexer should be modified to return by ref readonly.

Expose core functionality on Vector4

Rationale

Vector4 is currently a fairly opaque type. It should be update to expose a standard set of APIs such as are exposed in the DirectX Math library.

Proposed API

public readonly struct Vector4
{
    public Vector4(float value);

    public static bool operator ==(Vector4 left, Vector4 right);
    public static bool operator !=(Vector4 left, Vector4 right);

    public static Vector4 operator +(Vector4 value);
    public static Vector4 operator -(Vector4 value);

    public static Vector4 operator +(Vector4 left, Vector4 right);
    public static Vector4 operator -(Vector4 left, Vector4 right);

    public static Vector4 operator *(Vector4 left, Vector4 right);
    public static Vector4 operator /(Vector4 left, Vector4 right);

    public static Vector4 operator *(Vector4 left, float right);
    public static Vector4 operator /(Vector4 left, float right);

    public static float Dot(Vector4 left, Vector4 right);

    public static Vector4 Normalize(Vector4 value);

    public float Length { get; }
    public float LengthSquared { get; }
}

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.