Giter Club home page Giter Club logo

hlslcc's Introduction

HLSLcc

DirectX shader bytecode cross compiler.

Originally based on https://github.com/James-Jones/HLSLCrossCompiler.

This library takes DirectX bytecode as input, and translates it into the following languages:

  • GLSL (OpenGL 3.2 and later)
  • GLSL ES (OpenGL ES 3.0 and later)
  • GLSL for Vulkan consumption (as input for Glslang to generate SPIR-V)
  • Metal Shading Language

This library is used to generate all shaders in Unity for OpenGL, OpenGL ES 3.0+, Metal and Vulkan.

Changes from original HLSLCrossCompiler:

  • Codebase changed to C++11, with major code reorganizations.
  • Support for multiple language output backends (currently ToGLSL and ToMetal)
  • Metal language output support
  • Temp register type analysis: In DX bytecode the registers are typeless 32-bit 4-vectors. We do code analysis to infer the actual data types (to prevent the need for tons of bitcasts).
  • Loop transformation: Detect constructs that look like for-loops and transform them back to their original form
  • Support for partial precision variables in HLSL (min16float etc). Do extra analysis pass to infer the intended precision of samplers.
  • Reflection interface to retrieve the shader inputs and their types.
  • Lots of workarounds for various driver/shader compiler bugs.
  • Lots of minor fixes and improvements for correctness
  • Lots of Unity-specific tweaks to allow extending HLSL without having to change the D3D compiler itself.

Note

This project is originally integrated into the Unity build systems. However, building this library should be fairly straightforward: just compile src/*.cpp (in C++11 mode!) and src/cbstring/*.c with the following include paths:

  • include
  • src/internal_includes
  • src/cbstrinc
  • src

Alternatively, a CMakeLists.txt is provided to build the project using cmake.

The main entry point is TranslateHLSLFromMem() function in HLSLcc.cpp (taking DX bytecode as input).

Contributors

  • Mikko Strandborg
  • Juho Oravainen
  • David Rogers
  • Marton Ekler
  • Antti Tapaninen
  • Florian Penzkofer
  • Alexey Orlov
  • Povilas Kanapickas

License

MIT license for HLSLcc itself, BSD license for the bstring library. See license.txt.

hlslcc's People

Contributors

strandborg avatar thestr4ng3r avatar vinjn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.