Skip to content

AlexeyGrishin/glsl-value-range-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is it

Prototype for GLSL static value range analysis, which shall prevent cases like that:

gl_FragColor.r = sin(something)+1.; //WARN: color shall be between 0 and 1

Status

Very-very alpha. It supports ~5% of GLSL functionality. But at least it covers the case from "What is it" section :)

Where to try

Here

How to build

Preparation

  1. Install SConstruct (required for unit tests only)
  2. Install node + npm
  3. Install google test in your environment
  4. How I did it in MAC, and that shall work for Linux too:
git clone https://github.com/google/googletest
cd googletest
mkdir build
cd build
cmake ..
make
make install
  1. Install https://leaningtech.com/cheerp/
  2. Run npm install in root folder
  3. Depending on your OS:
  4. MacOS - nothing else required
  5. Windows/Linux - please replace path to cheerp/bin/clang++ with valid one for your OS

Build

  • npm run wasm - to build dataflow analyzer from C to WebAssembly using cheerp. WASM is added to html folder
  • npm run js - to build js parser and UI
  • npm run server - to run web server on port 3355. Go to http://localhost:3355 and try editor
  • npm run dataflow-tests - to run some unit-tests for dataflow analyzer

About code

  • glsl - contains test UI, and also converter for GLSL to Command Sequence which goes to data flow analyzer
  • ast2dataflow.js contains most of conversion logic
  • index.js calls ast2dataflow.js and passes result to data flow analyzer
  • dataflow - contains data flow analyzer, which goes through command sequence and tries to predict variables ranges
  • analyzer.h - main facade interface
  • analisys_context.h - common processing logic, all about variables and branches management
  • ops/buildin_ops.cpp - list of supported GLSL operations and functions

About

GLSL value range analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published