All Projects → reignstudios → Cs2x

reignstudios / Cs2x

Licence: mit
Transpiles a C# subset to non .NET languages and runtimes. (Powered by Roslyn)

Programming Languages

c
50402 projects - #5 most used programming language
csharp
926 projects

Projects that are alternatives of or similar to Cs2x

Crossshader
⚔️ A tool for cross compiling shaders. Convert between GLSL, HLSL, Metal Shader Language, or older versions of GLSL.
Stars: ✭ 113 (+16.49%)
Mutual labels:  transpiler, glsl, hlsl
Pmtech
Lightweight, multi-platform, data-oriented game engine.
Stars: ✭ 478 (+392.78%)
Mutual labels:  glsl, hlsl, wasm
Hlsl2glslfork
HLSL to GLSL language translator based on ATI's HLSL2GLSL. Used in Unity.
Stars: ✭ 488 (+403.09%)
Mutual labels:  glsl, hlsl
Gpu Gems Book Source Code
💿 CD Content ( Source Code ) Collection of Book <GPU Gems > 1~ 3 | 《GPU精粹》 1~ 3 随书CD(源代码)珍藏
Stars: ✭ 567 (+484.54%)
Mutual labels:  glsl, hlsl
Raylib
A simple and easy-to-use library to enjoy videogames programming
Stars: ✭ 8,169 (+8321.65%)
Mutual labels:  wasm, embedded
Wasm3
🚀 The fastest WebAssembly interpreter, and the most universal runtime
Stars: ✭ 4,375 (+4410.31%)
Mutual labels:  wasm, embedded
Shadergen
Proof-of-concept library for generating HLSL, GLSL, and Metal shader code from C#,
Stars: ✭ 395 (+307.22%)
Mutual labels:  glsl, hlsl
Slang
Making it easier to work with shaders
Stars: ✭ 627 (+546.39%)
Mutual labels:  glsl, hlsl
CPP-Programming
Various C/C++ examples. DirectX, OpenGL, CUDA, Vulkan, OpenCL.
Stars: ✭ 30 (-69.07%)
Mutual labels:  glsl, hlsl
Rhai
Rhai - An embedded scripting language for Rust.
Stars: ✭ 958 (+887.63%)
Mutual labels:  wasm, embedded
Bonzomatic
Live shader coding tool and Shader Showdown workhorse
Stars: ✭ 829 (+754.64%)
Mutual labels:  glsl, hlsl
Shaderc
A collection of tools, libraries, and tests for Vulkan shader compilation.
Stars: ✭ 1,016 (+947.42%)
Mutual labels:  glsl, hlsl
Xshadercompiler
Shader cross compiler to translate HLSL (Shader Model 4 and 5) to GLSL
Stars: ✭ 327 (+237.11%)
Mutual labels:  glsl, hlsl
Shaderdebugger
[DEPRECATED] C++ library for debugging HLSL & GLSL shaders
Stars: ✭ 323 (+232.99%)
Mutual labels:  glsl, hlsl
Glslcc
GLSL cross-compiler tool (GLSL->HLSL, MSL, GLES2, GLES3, GLSLv3), using SPIRV-cross and glslang
Stars: ✭ 320 (+229.9%)
Mutual labels:  glsl, hlsl
Ouzel
C++ game engine for Windows, macOS, Linux, iOS, tvOS, Android, and web browsers
Stars: ✭ 607 (+525.77%)
Mutual labels:  glsl, hlsl
Shaderconductor
ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages
Stars: ✭ 1,146 (+1081.44%)
Mutual labels:  glsl, hlsl
inline-spirv-rs
Compile GLSL/HLSL/WGSL and inline SPIR-V right inside your crate.
Stars: ✭ 21 (-78.35%)
Mutual labels:  glsl, hlsl
TypeScriptXX
🧷 Stay safe! Type-safe scripting for C++ using TypeScriptToLua and CMake with auto-generated declarations.
Stars: ✭ 33 (-65.98%)
Mutual labels:  embedded, wasm
Imguicolortextedit
Colorizing text editor for ImGui
Stars: ✭ 772 (+695.88%)
Mutual labels:  glsl, hlsl

Gitter

CS2X (Under development)

Transpiles a C# subset to non .NET languages, platforms, runtimes and enviroments. (Powered by Roslyn)

CS2X is activily being tested in the development of the Orbital-Framework:
https://github.com/reignstudios/Orbital-Framework
This provides real-world tests and as things progress more features will tested and supported here.

WASM Demo

Renders a 1280x720 image then prints how long it took in seconds.
http://reign-studios.com/wasm/cs2x/ray-trace-benchmark/cs2x.html

Goals

This project will focus on transpiling a C# subset with a modified type system for writing CPU and GPU programs.

  • Custom Standard lib(s) for various targets.
  • Documentation

CPU targets

  • C89
    • Native C performance
    • C89: modern, legacy and embedded platforms (x86, MIPS, SPARC, RISC-V, PPC, M68K, AVR, etc)
    • CC65: 6502 platforms (Atari, C64, NES, Apple II, etc)
    • SDCC: Many targets (ColecoVision, ZX Spectrum, etc)
    • z88dk: Z80 platforms
  • LLVM
  • LLVM IR => Assembly: CP1610 (Intellivision)
  • LLVM IR => Assembly: Intel 8048 (Magnavox Odyssey 2)
  • LLVM IR => Retarget: Custom assembly targets (FPGA CPU, 16bit bytes, etc)
  • Java
  • Kotlin
  • javaScript
  • Python
  • ActionScript

GPU targets

  • HLSL (DirectX Shader Assembly Language) [D3D9.0c +]
  • ALS (DirectX Shader Assembly Language) [D3D8.0 - D3D9.0c]
  • GLSL (OpenGL shading language) [OpenGL2.0 / GLES2 +]
  • ARB (ARB assembly language) [legacy / homebrew systems]
  • CG (Cg programming language) [PSVita, Nvidia / other]
  • PSSL (PlayStation Shader Language) [PS4]
  • MSL (Metal Shading Language) [macOS / iOS]
  • AGAL (Adobe Graphics Assembly Language)
  • Custom: Plugin system

Primary Project libraries

  • CS2X.Core: .NET transpiler lib
  • CS2X.CLI: CLI interface for CS2X.Core
  • CS2X.Analyzer: C# syntax analyzer to limit unsuported features.
  • CS2X.CoreLib: Portable CoreLib subset

How does it basically work?

  • C89
    • Each executable gets built to a single '.c' source file including all dependencies.
    • String literals on embedded devices, cartridges, etc can be stored in program memory / ROM to save ram.
    • All GC methods are agnostic allowing any built-in or custom GC backend.
  • Other: TODO

Performance

Almost zero performance loss. C# code will generate in a manner as if hand written in the target language in many respects. There are a couple key differences in the CS2X runtime / type system vs .NET CLR

  • Structs are not part of the object system as they are in the .NET runtime.
    • No auto boxing for value types are supported (.NET has many easy to fall in syntax performance pitfalls here).
    • System.Object can never equal a 'struct', 'enum' or 'primitive' type.
    • Virtuals like 'MyStruct.GetType()' or 'MyEnum.GetType()' give compile time errors (use typeof instead).
    • Cannot bind a delegate to a structs non-static method.
  • Interfaces are considered 'type-classes' and are compile time only.
    • Used for generics or general code consistency.
    • No casting to them or variable declarations of them.
  • No up-casting performance loss in C and down-casting checks can be disabled for C output.
  • Auto-Marshalling of managed types not supported.
    • Varies to much between platforms in contrast to .NET making writing portable code confusing.
    • Auto string marshalling has way to many implicits that depend on to many factors to keep track of.
    • Redundant allocations. If you want to pass the same string multiple times in multiple methods for example auto-marshaling it everytime doesn't make sense. Its far better to be explicit here and make that obvious by pre-marshalling the type once.
    • Portability. Forcing PInvokes to be used this way ensures code functions the same in all runtimes.

Building

  • Prerequisites
    • Visual Studios 2019 (VS for Mac / MonoDevelop or VSCode have not yet been tested)
    • .NET Core 5
    • .NET Compiler Platform SDK
  • Run: CS2X.Core.Test proj in VS. This will build "PortableTestApp.csproj" to "TestOutput" folder
  • NOTE: Early stages so nothing else is supported yet.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].