setShader.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. return {
  2. tag = 'shaders',
  3. summary = 'Set the active Shader.',
  4. description = [[
  5. Sets the active shader. In a render pass, the Shader will affect all drawing operations until
  6. it is changed again. In a compute pass, the Shader will be run when `Pass:compute` is called.
  7. ]],
  8. arguments = {
  9. shader = {
  10. type = 'Shader',
  11. description = 'The shader to use.'
  12. },
  13. default = {
  14. type = 'DefaultShader',
  15. description = 'One of the default shaders to use.'
  16. }
  17. },
  18. returns = {},
  19. variants = {
  20. {
  21. arguments = { 'shader' },
  22. returns = {}
  23. },
  24. {
  25. description = 'Use one of the default shaders for drawing.',
  26. arguments = { 'default' },
  27. returns = {}
  28. },
  29. {
  30. description = 'Switch back to using an automatic shader for drawing.',
  31. arguments = {},
  32. returns = {}
  33. }
  34. },
  35. notes = [[
  36. Changing the shader will preserve resource bindings (the ones set using `Pass:send`) **unless**
  37. the new shader declares a resource for a binding number using a different type than the current
  38. shader. In this case, the resource "type" means one of the following:
  39. - Uniform buffer (`uniform`).
  40. - Storage buffer (`buffer`).
  41. - Sampled texture, (`uniform texture<type>`).
  42. - Storage texture, (`uniform image<type>`).
  43. - Sampler (`uniform sampler`).
  44. If the new shader doesn't declare a resource in a particular binding number, any resource there
  45. will be preserved.
  46. If there's a clash in resource types like this, the variable will be "cleared". Using a
  47. buffer variable that has been cleared is not well-defined, and may return random data or even
  48. crash the GPU. For textures, white pixels will be returned. Samplers will use `linear`
  49. filtering and the `repeat` wrap mode.
  50. Changing the shader will not clear push constants set in the `Constants` block.
  51. ]],
  52. related = {
  53. 'Pass:send',
  54. 'Pass:compute'
  55. }
  56. }