Skip to content

Commit bbe83b9

Browse files
committed
Initial commit
0 parents  commit bbe83b9

File tree

441 files changed

+43256
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

441 files changed

+43256
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.deb
2+
net-core/dotnet-runtime-2.1.18-linux-arm.tar.gz
3+
RenderSamples/bin/
4+
RenderSamples/obj/
5+
Vrmac/bin/
6+
Vrmac/obj/
7+
VrmacInterop/bin/
8+
VrmacInterop/obj/
9+
*.user
10+
.vs/
11+
Vrmac/linux-arm/libVrmac.so
12+
Vrmac/win10-x64/VrmacFT.dll
13+
Vrmac/win10-x64/Vrmac.dll

EULA.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Copyright (c) 2020 Konstantin, const.me
2+
3+
Vrmac Graphics End User License Agreement
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
6+
(the "Software"), to use, copy, publish, distribute, sublicense, and/or sell copies of the Software,
7+
and to permit persons to whom the Software is furnished to do so, subject to the following conditions.
8+
9+
1. The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to
10+
the warranties of merchantability, fitness for a particular purpose and noninfringement.
11+
In no event shall the authors or copyright holders be liable for any claim, damages or other liability,
12+
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software
13+
or the use or other dealings in the software.
14+
15+
2. The complete text of this agreement, including the above copyright notice,
16+
shall be included in all copies or substantial portions of the software.
17+
If you distribute a derivative product in binary form, this license must be available to end users of the software.
18+
19+
3. You may not reverse engineer the software, except when this is allowed by EU Directive 2009/24
20+
https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=CELEX:32009L0024&from=EN or the laws of your jurisdiction.
21+
22+
4. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity
23+
or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto,
24+
such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
25+
26+
5. If you institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit)
27+
alleging that the program itself (excluding combinations of the program with other software or hardware) infringes your patent(s),
28+
then your rights granted by this license agreement shall terminate as of the date such litigation is filed.

Installation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Installation## Windows 10On Windows 10 you only need the nuget package, and .NET Core runtime. I have only tested with 2.1 and 2.2, will probably work with newer versions, too.Microsoft did decent job packaging their .NET core for Windows.Download an installer [from their official web site](https://dotnet.microsoft.com/download/dotnet-core), and very likely it’ll work just fine.If you want to compile apps, you’ll need SDK, not just the runtime.The native binary is only available for 64-bit Windows.Make sure that damn “Prefer 32-bit” checkbox is **not** checked in the properties of your project.It won’t run otherwise, you’ll get a startup exception telling something about not being able to load Vrmac.dll.## Raspberry Pi### .NET CoreMicrosoft did poor job packaging their .NET Core for ARM Linux.I had to come up with something better.From the Releases page of this repository, download `dotnet-runtime_2.1.18_armhf.deb` to the Pi, and run this command on the Pi:```sudo dpkg -i ./dotnet-runtime_2.1.18_armhf.deb```This will install .NET Core version 2.1.18 LTS. The sources of that Debian package are in this repository, in `net-core` subfolder. The `package` bash script from that folder compiles the package.### Other Runtime DependenciesIn addition to that, Vrmac Graphics requires some Debian packages which may or may not be installed on your Pi.To install all of them, copy-paste the following to the Linux command-line shell, and run it:```sudo apt-get install -y libegl1 libgles2 libgbm1 libdrm2 libx11-6 libxcb1 libx11-xcb1 libpng16-16 \libfreetype6 libtiff5 libjpeg62-turbo libstdc++6 libc6 libgcc1 fonts-liberation2 fonts-quicksand```All these packages are from the official repository. Presumably, they are supported by Debian maintainers.### Video Driver Setup```sudo raspi-config7 Advanced Options Configure advanced settingsA8 GL Driver Enable/Disable experimental desktop GL driverG2 GL (Fake KMS) OpenGL desktop driver with fake KMS```By default, Linux doesn’t grant you permissions to 3D render things. Here’s a fix:```sudo usermod -a -G render pi```Reboot after all these changes, with `sudo reboot` command.### Running SamplesOnce the above setup is complete, you should be able to run samples with the following command:```dotnet RenderSamples.dll```Vrmac graphics doesn’t care about SSH sessions or X windows.If you’ll run it anyhow on the Pi, and the X server is running, it will create a window on the monitor plugged into the Pi.If no X server is running, will render directly into the physical monitor plugged into Pi, using that lower-level workflow with drm/kms and raw input.If both methods fail, the library should throw some exception with a meaningful error message about that.If you have DSI display, or two HDMI displays, should work in theory but I never tested.The API to select display, resolution and refresh rate is exposed to .NET.It does work on my Pi 4 when a single monitor is a FullHD one plugged into MicroHDMI, but I haven’t tested anything else.ARM Linux doesn’t currently have .NET SDK, just the runtime. To build stuff for Pi4, you’ll need some non-ARM PC which supports the SDK.Windows, OSX or Linux should all work. On Windows, click Build / Publish, in command line that’s `dotnet publish`, then copy output folder to the Pi.Personally, I shared a network drive in Windows 10 PC, and mounted it on the Pi with a long command which starts with `sudo mount -t cifs`

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Konstantin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Pre-existing IP.txt

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Diligent Engine (c) Diligent Graphics
2+
https://github.com/DiligentGraphics/DiligentEngine
3+
Apache License 2.0
4+
5+
.NET Core (c) Microsoft
6+
https://dotnet.microsoft.com/download/dotnet-core
7+
MIT license
8+
9+
ComLightInterop (c) const.me
10+
https://github.com/Const-me/ComLightInterop
11+
MIT license
12+
13+
PlexAllocator (c) const.me
14+
https://github.com/Const-me/CollectionMicrobench/tree/master/Source/PlexAlloc
15+
MIT license
16+
17+
MonoGame
18+
https://github.com/MonoGame/MonoGame
19+
The source files I used say "MIT license", check the sources in VrmacInterop/MonoGame folder.
20+
21+
DirectXMath (c) Microsoft
22+
https://github.com/Microsoft/DirectXMath
23+
MIT license
24+
25+
LibTess2 (c) Silicon Graphics, Inc. and Mikko Mononen
26+
https://github.com/memononen/libtess2
27+
SGI FREE SOFTWARE LICENSE B
28+
29+
NanoVG ClearType Fork (c) Mikko Mononen and const.me
30+
https://github.com/Const-me/nanovg/
31+
MIT license
32+
33+
Mesh Optimizer (c) Arseny Kapoulkine
34+
https://github.com/zeux/meshoptimizer
35+
MIT license
36+
37+
-------------------------------------------------------------------
38+
The following libraries are only present in Windows C++ DLLs.
39+
On Linux, OS-provided equivalents are linked dynamically instead.
40+
-------------------------------------------------------------------
41+
42+
FreeType 2.10.2
43+
https://www.freetype.org/index.html
44+
FreeType Project License
45+
46+
LibPNG 1.6.17
47+
http://www.libpng.org/pub/png/libpng.html
48+
libpng license
49+
50+
zlib 1.2.8
51+
http://www.zlib.net/
52+
zlib license
53+
54+
libjpeg 9a (c) Independent JPEG Group
55+
http://ijg.org/
56+
Custom BSD-like license
57+
58+
libtiff 4.0.10 (c) Sam Leffler, Silicon Graphics, Inc.
59+
http://simplesystems.org/libtiff/
60+
BSD-like licence
61+
62+
-------------------------------------------------------------------
63+
The following data files are compiled into .NET DLLs.
64+
Mouse cursors are in VrmacGraphics.dll
65+
The rest of them are for samples, compiled into RenderSamples.dll
66+
-------------------------------------------------------------------
67+
68+
Mouse cursors, found on the Internets somewhere.
69+
They look suspiciously close to Windows Vista or Windows 7 cursors.
70+
Might be a copyrighted work by Microsoft.
71+
Ideally, please replace these assets with your own ones.
72+
I’m not a graphics designer and don’t have skills for that.
73+
They are in the *.gz files in Vrmac/Utils/Cursor/Assets folder.
74+
75+
Utah teapot (c) Martin Newell
76+
STL model by zzubnik (Nik Clark, Norwich, UK)
77+
https://commons.wikimedia.org/wiki/File:Utah_teapot_(solid).stl
78+
79+
Tiger from the Ghostscript examples (c) Ghostscript authors
80+
https://commons.wikimedia.org/wiki/File:Ghostscript_Tiger.svg
81+
82+
Well-known Standard Test Image "Lenna" (c) 1973 Playboy Magazine
83+
Use of 512x512 scan is "overlooked" and by implication permitted by Playboy.
84+
https://en.wikipedia.org/wiki/File:Lenna_(test_image).png
85+
86+
Picture of jelly beans taken at USC.
87+
Free to use for any purpose including unrestricted redistribution, commercial use, and modification.
88+
https://commons.wikimedia.org/wiki/File:SIPI_Jelly_Beans_4.1.07.tiff
89+
90+
Random PNG icons found on some third-party web site related to World of Warcraft.
91+
Probably a copyrighted work by Activision Blizzard.
92+
If so, including them in the samples of a freeware software library is fair use.

README.md

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
using Diligent.Graphics;
2+
using Vrmac;
3+
4+
namespace RenderSamples
5+
{
6+
class HelloTriangle: SampleBase
7+
{
8+
IPipelineState pipelineState;
9+
10+
protected override void createResources( IRenderDevice device )
11+
{
12+
// Diligent Engine can use HLSL source on all supported platforms.
13+
// It will convert HLSL to GLSL in OpenGL mode, while Vulkan backend will compile it directly to SPIRV.
14+
string VSSource = @"
15+
struct PSInput
16+
{
17+
float4 Pos : SV_POSITION;
18+
float3 Color : COLOR;
19+
};
20+
21+
void main( in uint VertId : SV_VertexID, out PSInput PSIn )
22+
{
23+
float4 Pos[3];
24+
Pos[0] = float4(-0.5, -0.5, 0.0, 1.0);
25+
Pos[1] = float4( 0.0, +0.5, 0.0, 1.0);
26+
Pos[2] = float4(+0.5, -0.5, 0.0, 1.0);
27+
28+
float3 Col[3];
29+
Col[0] = float3(1.0, 0.0, 0.0); // red
30+
Col[1] = float3(0.0, 1.0, 0.0); // green
31+
Col[2] = float3(0.0, 0.0, 1.0); // blue
32+
33+
PSIn.Pos = Pos[VertId];
34+
PSIn.Color = Col[VertId];
35+
}";
36+
37+
string PSSource = @"
38+
struct PSInput
39+
{
40+
float4 Pos : SV_POSITION;
41+
float3 Color : COLOR;
42+
};
43+
44+
struct PSOutput
45+
{
46+
float4 Color : SV_TARGET;
47+
};
48+
49+
void main( in PSInput PSIn, out PSOutput PSOut )
50+
{
51+
PSOut.Color = float4(PSIn.Color.rgb, 1.0);
52+
}
53+
";
54+
PipelineStateDesc PSODesc = new PipelineStateDesc( false );
55+
56+
PSODesc.setBufferFormats( context );
57+
58+
// Primitive topology defines what kind of primitives will be rendered by this pipeline state
59+
PSODesc.GraphicsPipeline.PrimitiveTopology = PrimitiveTopology.TriangleList;
60+
// No back face culling for this tutorial
61+
PSODesc.GraphicsPipeline.RasterizerDesc.CullMode = CullMode.None;
62+
// Disable depth testing
63+
PSODesc.GraphicsPipeline.DepthStencilDesc.DepthEnable = false;
64+
65+
iShaderFactory shaderFactory = device.GetShaderFactory();
66+
67+
// We won't be using the device object after this, `using` is to release the COM interface once finished
68+
using( iPipelineStateFactory stateFactory = device.CreatePipelineStateFactory() )
69+
{
70+
// Compile the two shaders
71+
ShaderSourceInfo sourceInfo = new ShaderSourceInfo( ShaderType.Vertex, ShaderSourceLanguage.Hlsl );
72+
sourceInfo.combinedTextureSamplers = true; // This appears to be the requirement of OpenGL backend.
73+
74+
using( var vs = shaderFactory.compileFromSource( VSSource, sourceInfo ) )
75+
stateFactory.graphicsVertexShader( vs );
76+
77+
sourceInfo.shaderType = ShaderType.Pixel;
78+
using( var ps = shaderFactory.compileFromSource( PSSource, sourceInfo ) )
79+
stateFactory.graphicsPixelShader( ps );
80+
81+
stateFactory.apply( ref PSODesc );
82+
83+
pipelineState = device.CreatePipelineState( ref PSODesc );
84+
}
85+
}
86+
87+
static readonly Vector4 clearColor = Color.parse( "#ccc" );
88+
89+
protected override void render( ITextureView swapChainRgb, ITextureView swapChainDepthStencil )
90+
{
91+
var ic = context.context;
92+
93+
ic.SetRenderTarget( swapChainRgb, swapChainDepthStencil );
94+
95+
// Clear the back buffer
96+
float[] ClearColor = new float[ 4 ] { 0.350f, 0.350f, 0.350f, 1.0f };
97+
// Let the engine perform required state transitions
98+
ic.ClearRenderTarget( swapChainRgb, clearColor );
99+
ic.ClearDepthStencil( swapChainDepthStencil, ClearDepthStencilFlags.DepthFlag, 1.0f, 0 );
100+
101+
// Set the pipeline state in the immediate context
102+
ic.SetPipelineState( pipelineState );
103+
ic.CommitShaderResources( null );
104+
105+
DrawAttribs drawAttrs = new DrawAttribs( true );
106+
drawAttrs.NumVertices = 3; // We will render 3 vertices
107+
ic.Draw( ref drawAttrs );
108+
}
109+
}
110+
}

0 commit comments

Comments
 (0)