You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Import GLSL source files as strings. Pre-processed, validated and optimized with [Khronos Group SPIRV-Tools](https://github.com/KhronosGroup/SPIRV-Tools).
15
13
@@ -19,23 +17,50 @@ Primary use-case is processing WebGL2 / GLSL ES 300 shaders.
19
17
importfragfrom'./shaders/myShader.frag';
20
18
console.log(frag);
21
19
```
20
+
21
+
## Features
22
+
23
+
### GLSL Optimizer
24
+
*For WebGL2 / GLSL ES >= 300*
25
+
26
+
With ``optimize: true`` (default) shaders will be compiled to SPIR-V (opengl semantics) and optimized for performance using the [Khronos SPIR-V Tools Optimizer](https://github.com/KhronosGroup/SPIRV-Tools) before being cross-compiled back to GLSL.
27
+
28
+
### Shader Preprocessor
29
+
Shaders are preprocessed and validated using the [Khronos Glslang Validator](https://github.com/KhronosGroup/glslang).
30
+
31
+
Macros are run at build time with support for C-style ``#include`` directives: \*
*\* Via the ``GL_GOOGLE_include_directive`` extension. But an ``#extension`` directive is not required nor recommended in your final inlined code.*
43
+
44
+
### Supports glslify
45
+
Specify ``glslify: true`` to process shader sources with [glslify](https://github.com/glslify/glslify) (a node.js-style module system for GLSL).
46
+
47
+
*And install glslify in your devDependencies with ``npm i -D glslify``*
48
+
22
49
## Installation
23
50
24
51
```sh
25
52
npm i rollup-plugin-glsl-optimize -D
26
53
```
27
54
28
-
### Khronos tool binaries
29
-
This plugin uses binaries from the [Khronos Glslang Validator](https://github.com/KhronosGroup/glslang), [Khronos SPIRV-Tools Optimizer](https://github.com/KhronosGroup/SPIRV-Tools) and [Khronos SPIRV Cross compiler](https://github.com/KhronosGroup/SPIRV-Cross).
55
+
### Khronos tools
56
+
This plugin uses the [Khronos Glslang Validator](https://github.com/KhronosGroup/glslang), [Khronos SPIRV-Tools Optimizer](https://github.com/KhronosGroup/SPIRV-Tools) and [Khronos SPIRV Cross compiler](https://github.com/KhronosGroup/SPIRV-Cross).
30
57
31
-
They are automatically installed for:
58
+
Binaries are automatically installed for:
32
59
* Windows 64bit (MSVC 2017)
33
60
* MacOS x86_64 (clang)
34
61
* Ubuntu Trusty / Debian Buster amd64 (clang)
35
-
* Untested: Other amd64 Linux distros, arm64 MacOS
36
-
37
62
38
-
Paths can also be manually provided / overridden with the ``GLSLANG_VALIDATOR``, ``GLSLANG_OPTIMIZER``, ``GLSLANG_CROSS`` environment variables.
63
+
*Paths can be manually provided / overridden with the ``GLSLANG_VALIDATOR``, ``GLSLANG_OPTIMIZER``, ``GLSLANG_CROSS`` environment variables.*
39
64
40
65
## Usage
41
66
```js
@@ -50,40 +75,6 @@ export default {
50
75
};
51
76
```
52
77
53
-
## Features
54
-
55
-
### Preprocessing and Validation
56
-
Shaders are pre-processed and validated using the [Khronos Glslang Validator](https://github.com/KhronosGroup/glslang).
57
-
58
-
Macros are run at build time with support for C-style ``#include`` directives: \*
*\* Via the ``GL_GOOGLE_include_directive`` extension. But an ``#extension`` directive is not required nor recommended in your final inlined code.*
71
-
72
-
### Optimization
73
-
**Requires WebGL2 / GLSL ES >= 300**
74
-
75
-
With ``optimize: true`` (default) shaders will also be compiled to SPIR-V (opengl semantics) and optimized for performance using the [Khronos SPIR-V Tools Optimizer](https://github.com/KhronosGroup/SPIRV-Tools) before being cross-compiled back to GLSL.
76
-
77
-
#### Known Issues / Caveats
78
-
*``lowp`` precision qualifier - emitted as ``mediump``\*
79
-
80
-
*\* Since SPIR-V has a single ``RelaxedPrecision`` decoration for 16-32bit precision. However most implementations now treat ``mediump`` and ``lowp`` equivalently, hence the lack of need for it in SPIR-V.*
81
-
82
-
### Support for glslify
83
-
Specify ``glslify: true`` to process shader sources with [glslify](https://github.com/glslify/glslify) (a node.js-style module system for GLSL) prior to all preprocessing, validation and optimization.
84
-
85
-
*Install glslify in your devDependencies with ``npm i -D glslify``*
86
-
87
78
## Shader stages
88
79
89
80
The following shader stages are supported by the Khronos tools and recognized by file extension:
@@ -124,27 +115,25 @@ The following shader stages are supported by the Khronos tools and recognized by
124
115
## Changelog
125
116
Available in [CHANGES.md](CHANGES.md).
126
117
127
-
## License
128
-
129
-
Released under the [MIT license](LICENSE).
118
+
#### Caveats & Known Issues
119
+
* This plugin handles glsl and glsify by itself. Use with conflicting plugins (e.g. rollup-plugin-glsl, rollup-plugin-glslify) will cause unpredictable results.
120
+
* Optimizer: ``lowp`` precision qualifier - emitted as ``mediump``\
121
+
*SPIR-V has a single ``RelaxedPrecision`` decoration for 16-32bit precision. However most implementations now treat ``mediump`` and ``lowp`` equivalently, hence the lack of need for it in SPIR-V.*
130
122
131
-
*Khronos tool binaries (built by the upstream projects) are distributed and installed with this plugin under the terms of the Apache License Version 2.0. See the corresponding LICENSE files in the ``bin`` folder.*
123
+
## License
132
124
133
-
## See also
125
+
Released under the [MIT license](LICENSE).\
126
+
*Thanks to Vincent Wochnik ([rollup-plugin-glsl](https://github.com/vwochnik/rollup-plugin-glsl)) for the whitespace minification code.*
Khronos tool binaries (built by the upstream projects) are distributed and installed with this plugin under the terms of the Apache License Version 2.0. See the corresponding LICENSE files in the ``bin`` folder.
0 commit comments