Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
/ svvm Public archive

Scalar/Vector Virtual Machine: a proof-of-concept high-level shader assembler implemented as a Haskell EDSL

Notifications You must be signed in to change notification settings

gfxpg/svvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scalar/Vector Virtual Machine

Svvm is a proof-of-concept high-level shader assembler implemented as a Haskell EDSL.

Features

  1. Strongly-typed DSL with support for integer and FP32 operations
  2. Descriptive type-level error messages via TypeError
  3. GFX-independent intermediate representation with virtual registers
  4. Control-flow graph construction for further analysis both at IR and machine instruction level
  5. Register allocation with alignment constraints using a variation of the linear scan algorithm

Status

Several key issues were identified for the chosen approach:

  1. While the frontend and the IR are well-typed, machine instruction generation is not. This makes it hard to verify the backend's correctness and prevent regressions.
  2. The IR is too high-level/abstracted from the underlying hardware. The ability to emit compound loads (s_load_dwordxN) automatically is not worth the loss of fine control over the instructions that are generated. While it is possible to write machine instructions directly in the DSL, they are not typed (p.1), thus defeating the purpose a well-typed frontend—might as well use a regular assembler at that point.

Usage

Prerequisites

  1. The Haskell Tool Stack

  2. (Optional) Graphviz

Assembling the sample shader

Navigate to the repository root and run stack build. When this command is executed for the first time, Stack will download the compiler and build project dependencies. This may take a few minutes.

Next, execute stack run. The assembly for the sample shader will be printed out. In addition to that, a graph showing all intermediate translation stages will be written to the svvm-translation-graph.dot file in the current working directory.

If you have Graphviz installed, you can view it by running:

dot -Tsvg svvm-translation-graph.dot -o graph.svg && xdg-open graph.svg

Modifying the sample shader

  1. Open app/Main.hs and change sampleShader
  2. Save the file and execute stack run (a rebuild will be triggered automatically)

IDE support

About

Scalar/Vector Virtual Machine: a proof-of-concept high-level shader assembler implemented as a Haskell EDSL

Resources

Stars

Watchers

Forks