gfx_shader_watch
Tool for gfx-rs providing a PsoCell container that:
- (Debug mode) Watches for shader file changes and reloads automatically
- (Release mode) Includes shader file bytes at compile time
Watching and auto-loading shader file changes allows faster development of shader code without full program restarts or re-compiles. However, when releasing a final binary it is more convenient to simply include the shader code in source. Naturally this library can automatically act the desired way.
How It Works
There are two PsoCell variants SimplePsoCell
& WatcherPsoCell
, the former simply builds it's PipelineState once and
provides access. The latter refers to a shader source file that it will monitor, when changed it will reload it's
PipelineState on next access. To facilitate using SimplePsoCell
in release mode, and WatcherPsoCell
in debug mode
the debug_watcher_pso_cell!
& debug_watcher_pso_cell_type!
macros are available.
Code example:
extern crate gfx;
extern crate gfx_shader_watch;
use *;
use Primitive;
use Rasterizer;
Examples
Try running cargo run --example watch-shaders
you should see a white triangle. Now open examples/shader/frag.glsl
and modify it (ie change gl_FragColor = white;
-> gl_FragColor = red;
). You'll see the triangle shaded with the new code without the program reloading.