Skip to content
Sean Moss edited this page Aug 11, 2019 · 5 revisions

Welcome to the HLSV wiki!

This wiki serves as the central documentation repository for the HLSV project. It contains information on not only how to write and use HLSV programs, but also how to understand the code base so you can develop your own features and extensions to the language and tools.

Overview

HLSV (High-Level SPIR-V) is a C-like GPU shader language very similar to GLSL and HLSL, mainly derived from GLSL for Vulkan. It is designed to be easy to pick up if you know either GLSL or HLSL, and even more so if you are familiar with the GLSL extensions for Vulkan. The language is cross-compiled into Vulkan-style GLSL, which is then compiled into SPIR-V bytecode programs using the existing tools in the Vulkan SDK.

HLSV was created over frustration with some of the limitations of GLSL, its extreme verbosity and error-prone syntax when extended to support Vulkan features, and near-complete lack of program reflection. It is mostly a personal project, and is not meant to support all of the nuanced features of full GLSL. The goal is for it to support all of the common shader functions, and to eventually become a viable alternative to GLSL for most common use cases.

An (incomplete) feature matrix:

HLSV Feature Replaces/Improves from GLSL
Single source file
  • All shader stages are now in the same source file.
  • Inter-stage variables and interfaces are now trivial, no more layout(location=...) mismatches.
  • No need to rewrite the same shader interface statements for every single stage.
  • Option to compile all stages into a single optimized bytecode binary file, removing to need to track multiple files for each shader program.
Significantly lower verbosity
  • Complete replacement of unnecessarily verbose layout(...) statements.
  • Shorter keywords that are still clear in meaning.
  • A reduced set of types, limited to the smaller main set of types used in 95% of GLSL programs.
Syntactic Sugar
  • Limited type inference and support for C++-like initializer lists ({ ... }).
  • Built-in variables now start with $ to mark them as special, instead of the OpenGL-centric, confusing gl_.
Detailed multi-format reflection GLSL and the Vulkan SDK currently have terrible and incomplete reflection support (good luck trying to tell the difference between types of samplers and textures) that outputs only in a human readable format. The HLSV compiler generates fully-featured and detailed reflection information about shader programs and their interfaces, in both human-readable and binary machine-consumable formats.

Writing and Using HLSV

Note that this wiki will not teach you what a shader program is, how to write them, or how to use them in a Vulkan application. It will only provide an overview on the HLSV language and toolset for those who are already familiar with shaders. You should already know GLSL or HLSL, how they apply and are used in Vulkan, at how to use SPIR-V modules. There are plenty of resources online to learn the above.

Understanding and Using the HLSV Source Code

Clone this wiki locally