Class: RLSL::MSL::Shader
- Inherits:
-
RuntimeShader
- Object
- RuntimeShader
- RLSL::MSL::Shader
- Defined in:
- lib/rlsl/msl/shader.rb
Instance Attribute Summary collapse
-
#msl_source ⇒ Object
readonly
Returns the value of attribute msl_source.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from RuntimeShader
#uniform_names, #uniform_types
Instance Method Summary collapse
-
#initialize(name, uniforms, msl_source) ⇒ Shader
constructor
A new instance of Shader.
- #metal? ⇒ Boolean
- #render(handle, width, height, uniforms = {}) ⇒ Object
- #render_metal(handle, width, height, uniforms = {}) ⇒ Object
Constructor Details
#initialize(name, uniforms, msl_source) ⇒ Shader
Returns a new instance of Shader.
15 16 17 18 19 20 |
# File 'lib/rlsl/msl/shader.rb', line 15 def initialize(name, uniforms, msl_source) super(name, uniforms) @msl_source = msl_source @compiled_handles = {} @uniform_buffer_packer = UniformBufferPacker.new(@name, @uniform_types, @uniform_names) end |
Instance Attribute Details
#msl_source ⇒ Object (readonly)
Returns the value of attribute msl_source.
13 14 15 |
# File 'lib/rlsl/msl/shader.rb', line 13 def msl_source @msl_source end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/rlsl/msl/shader.rb', line 13 def name @name end |
Instance Method Details
#metal? ⇒ Boolean
22 23 24 |
# File 'lib/rlsl/msl/shader.rb', line 22 def true end |
#render(handle, width, height, uniforms = {}) ⇒ Object
26 27 28 |
# File 'lib/rlsl/msl/shader.rb', line 26 def render(handle, width, height, uniforms = {}) (handle, width, height, uniforms) end |
#render_metal(handle, width, height, uniforms = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rlsl/msl/shader.rb', line 30 def (handle, width, height, uniforms = {}) unless METACO_AVAILABLE raise LoadError, "metaco gem is required for Metal rendering. Install it with: gem install metaco" end unless @compiled_handles[handle] Metaco.compile_compute_shader(handle, @msl_source) @compiled_handles[handle] = true end uniform_data = pack_uniforms(uniforms, width, height) Metaco.dispatch_compute(handle, uniform_data) Metaco.present_compute(handle) end |