Typed where it matters
Compose vectors, matrices, comparisons, texture samples, GLSL.std.450 operations, and structured branches without writing raw opcodes.
Ruby 3.1+ / SPIR-V 1.0–1.6
Electra builds compact vertex and fragment shaders without a GLSL compiler, native bindings, or runtime gem dependencies.
fragment / main
mod.fragment_shader do |f|
out = f.output(:vec4, location: 0)
out.store(f.constant([1, 0, 0, 1]))
end
OpEntryPoint Fragment %1 "main" %8
OpExecutionMode %1 OriginUpperLeft
OpDecorate %8 Location 0
%8 = OpVariable %7 Output
%11 = OpConstantComposite %6 %9 %10 %10 %9
OpStore %8 %11
Work with typed values in Ruby, then inspect or store the exact bytes your Vulkan application consumes.
Compose vectors, matrices, comparisons, texture samples, GLSL.std.450 operations, and structured branches without writing raw opcodes.
Assemble and disassemble numeric-ID SPIR-V with byte-for-byte round trips, exact bounds, and preserved floating-point payloads.
Set descriptor bindings, offsets, array strides, matrix layout, and push constants yourself. Electra never guesses the CPU/GPU ABI.
A deliberate boundary
Electra keeps deployment simple by doing one job in Ruby. The Vulkan implementation and SPIRV-Tools remain the authorities for complete semantic validation.
Install version 0.1.0 from RubyGems. Ruby 3.1 or newer is required; SPIRV-Tools is optional for development validation.
$ gem install electra