All Projects → PiMaker → rvc

PiMaker / rvc

Licence: MIT License
A 32-bit RISC-V emulator in a shader (and C)

Programming Languages

Makefile
30231 projects
HTML
75241 projects
c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language
shell
77523 projects
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to rvc

ACLS-Shader
Unity HLSL VR ready "Toony/PBR hybrid" avatar shader for VRCHAT and similar platforms. Built with game industry standard toony appearances and adaptive to vrchat render constraints and reactive to common incorrect user generated map lighting.
Stars: ✭ 20 (-95.93%)
Mutual labels:  shader, hlsl, vrchat
VRC-Cancerspace
Cancerous screenspace shader for VRChat. Please use responsibly. :^)
Stars: ✭ 55 (-88.8%)
Mutual labels:  shader, hlsl, vrchat
YOLOv4-Tiny-in-UnityCG-HLSL
A modern object detector inside fragment shaders
Stars: ✭ 38 (-92.26%)
Mutual labels:  hlsl, vrchat
Computestochasticreflections
Compute Stochastic Screen Space Reflections for unity post processing
Stars: ✭ 163 (-66.8%)
Mutual labels:  shader, hlsl
Water Shader
Procedural water shader for general use.
Stars: ✭ 183 (-62.73%)
Mutual labels:  shader, hlsl
Unity Raymarching Framework
A framework to easy implement raymarching in unity. Include lots of hash,noise,fbm,SDF,rotate functions
Stars: ✭ 129 (-73.73%)
Mutual labels:  shader, hlsl
Glslang
Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Stars: ✭ 2,034 (+314.26%)
Mutual labels:  shader, hlsl
Spirv Vm
Virtual machine for executing SPIR-V
Stars: ✭ 173 (-64.77%)
Mutual labels:  shader, hlsl
Pbr proj
Shader of PBR for Unity
Stars: ✭ 68 (-86.15%)
Mutual labels:  shader, hlsl
VaKawaseBlur
Fast and furious Kawase blur implementation for Unreal Engine 4
Stars: ✭ 37 (-92.46%)
Mutual labels:  shader, hlsl
hassle-rs
🦀 This crate provides an FFI layer and idiomatic rust wrappers for the new DirectXShaderCompiler library.
Stars: ✭ 34 (-93.08%)
Mutual labels:  shader, hlsl
ada
A general porpose OpenGL app library
Stars: ✭ 105 (-78.62%)
Mutual labels:  shader, hlsl
Proccharvfx
Procedural character generation with Unity Shader Graph and VFX Graph
Stars: ✭ 114 (-76.78%)
Mutual labels:  shader, hlsl
Gpu Planetary Rendering
GPU atmosphertic scattering and planet generation in Unity 3D
Stars: ✭ 92 (-81.26%)
Mutual labels:  shader, hlsl
Unityurptoonlitshaderexample
A very simple toon lit shader example, for you to learn writing custom lit shader in Unity URP
Stars: ✭ 2,988 (+508.55%)
Mutual labels:  shader, hlsl
Hlslexplorer
See how hardware understands your HLSL
Stars: ✭ 91 (-81.47%)
Mutual labels:  shader, hlsl
Bloodfx
Procedural blood stain shader
Stars: ✭ 170 (-65.38%)
Mutual labels:  shader, hlsl
Shaderconductor
ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages
Stars: ✭ 1,146 (+133.4%)
Mutual labels:  shader, hlsl
3d Game Shaders For Beginners
🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and more for your 3D game.
Stars: ✭ 11,698 (+2282.48%)
Mutual labels:  shader, hlsl
Unity Shaders
✨ Shader demo - More than 300 examples
Stars: ✭ 198 (-59.67%)
Mutual labels:  shader, hlsl

rvc - risc v in c / HLSL

An experimental 32-bit [0] RISC-V emulator written in plain C [1], with a focus on porting the result to a HLSL pixel shader.

The resulting HLSL (Unity CG) can be found in _Nix/, read on to learn more.

A version of this shader running in VRChat can be found in this world:
https://vrchat.com/home/world/wrld_8126d9ef-eba5-4d49-9867-9e3c4f0b290d

The C version was initially based on takahirox/riscv-rust (see for example instruction decoder generation using instructions.txt and parse_ins.pl), which is a great resource for learning about RISC-V in general, aside from the official specs of course.

Linux running in VRChat

[0] GPUs only really support 32-bit integer math (in the use-case I want to put this in anyway)
[1] The elf loader ('elfy') is written in Rust, because I was too lazy to do it myself in C (Rust uses the 'elf' crate) and it doesn't need porting anyway.

Cloning this repository

This repo makes heavy use of submodules, so make sure to use git clone --recursive on initial cloning (may take a long time) and run git submodule update --recursive after a new pull.

To build any of the code included, you will probably need the following:

  • A C compiler (gcc, clang)
  • A rust compiler
  • Perl 5
  • A device tree compiler (dtc)

C version specifics

Pay no mind to the somewhat weird style of C please, it is mostly because of the need to port to HLSL.

To build, remove the 'rvc' binary and 'src/main.o', then run 'make rvc' from the top level directory.

To run the riscv-tests, use test.sh. test.sh all --clean can be used to run the full supported test suite.

Shader specifics

The shader version is a direct port of the C one. It can be found as part of a Unity project in _Nix/.

This is not a drag-and-drop prefab by any means, it will require careful setup and integration into a world to be useful.

The biggest pitfall is probably the required Perl support. The shader code uses perlpp and a valid runtime environment (I recommend Strawberry Perl for Windows). See the file AutoImport.cs for more information, you will need to set a valid path in there. Technically, the already created *.h files can be used as-is, but you won't be able to meaningfully change any code without it.

The approach uses a Custom Render Texture and some (really messy) VRChat Udon scripts to manage the emulator during runtime. They will probably require fixing up for use in your own world.

The NixDebug.cs (Udon) script needs to be placed on a camera pointing at a camera loop reading in from the 'display' shader. This provides a translation layer between the 128bit-per-pixel integer texture used in the CRT and the Color(float, float, float, float) struct available in Unity/C#.

NixControl.cs is built with support for my Dial prefab in mind, but can be changed to support any other control input too of course.

Build instructions (for the various subprojects/payloads)

Toolchain/Initramfs

For both the target toolchain (riscv32-gnu-linux-) and the initramfs, buildroot is used - this is not a submodule, but an extracted and slightly modified version instead.

To build, run make buildroot-2021.05/build.marker in the top level directory. The toolchain will be made in buildroot-2021.05/output/host and the rootfs in buildroot-2021.05/output/images. This will take a long time.

Micropython

Enter the 'mprv' subdirectory. Run 'make'. Requires the toolchain to be built.

bare_metal_test

Enter the 'bare_metal_test' subdirectory. Run 'make'. Requires the toolchain to be built.

toimg

This tool is responsible for converting binary images (not ELF!) into texture files you can import into Unity, which can then be run by the shader version.

Enter the 'toimg' subdirectory. Run cargo build --release. Use ./target/release/toimg <binary> 2048 2048 to create an image file. The second '2048' specifies the height, which may be smaller than '2048'. On the first run, the program will display the optimal size to give for running a second time. This is not necessary, but will produce smaller images.

rust_payload

This is a test payload written in rust. It demonstrates the ability to run rust code natively on the emulator (both C and shader version). Build by running make rust_payload.bin in the top-level directory.

NOTE: This requires a custom rust toolchain, as the default one does not have a 'rv32ima' target, only 'rv32imac' which is not supported. A demonstrative patch for rustc can be found in rust-target-rv32ima.patch.

linux

To build the linux payload, run make linux_payload.bin in the top level directory. This requires the toolchain and initramfs to be built.

Why?

Because.

License

MIT. See LICENSE for more.

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].