lovr.graphics.compileShader

Edit

Compiles shader code to SPIR-V bytecode. The bytecode can be passed to lovr.graphics.newShader to create shaders, which will be faster than creating it from GLSL. The bytecode is portable, so bytecode compiled on one platform will work on other platforms. This allows shaders to be precompiled in a build step.



Arguments

NameTypeDescription
stageShaderStage The type of shader to compile.
sourcestring A string or filename with shader code.

Returns

NameTypeDescription
bytecodeBlob A Blob containing compiled SPIR-V code.

Arguments

NameTypeDescription
stageShaderStage The type of shader to compile.
blobBlob A Blob containing shader code.

Returns

NameTypeDescription
bytecodeBlob A Blob containing compiled SPIR-V code.

Notes

The input can be GLSL or SPIR-V. If it's SPIR-V, it will be returned unchanged as a Blob.

If the shader fails to compile, an error will be thrown with the error message.

See also