2
0

compileShader.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. return {
  2. tag = 'graphics-objects',
  3. summary = 'Compile shader code to bytecode.',
  4. description = [[
  5. Compiles shader code to SPIR-V bytecode. The bytecode can be passed to
  6. `lovr.graphics.newShader` to create shaders, which will be faster than creating it from GLSL.
  7. The bytecode is portable, so bytecode compiled on one platform will work on other platforms.
  8. This allows shaders to be precompiled in a build step.
  9. ]],
  10. arguments = {
  11. stage = {
  12. type = 'ShaderStage',
  13. description = 'The type of shader to compile.'
  14. },
  15. source = {
  16. type = 'string',
  17. description = 'A string or filename with shader code.'
  18. },
  19. blob = {
  20. type = 'Blob',
  21. description = 'A Blob containing shader code.'
  22. }
  23. },
  24. returns = {
  25. bytecode = {
  26. type = 'Blob',
  27. description = 'A Blob containing compiled SPIR-V code.'
  28. }
  29. },
  30. variants = {
  31. {
  32. arguments = { 'stage', 'source' },
  33. returns = { 'bytecode' }
  34. },
  35. {
  36. arguments = { 'stage', 'blob' },
  37. returns = { 'bytecode' }
  38. }
  39. },
  40. notes = [[
  41. The input can be GLSL or SPIR-V. If it's SPIR-V, it will be returned unchanged as a Blob.
  42. If the shader fails to compile, an error will be thrown with the error message.
  43. ]],
  44. related = {
  45. 'lovr.graphics.newShader',
  46. 'Shader'
  47. }
  48. }