rj-action-library/Runtime/Rendering/Objects/RDProgram.cs

81 lines
1.7 KiB
C#
Raw Normal View History

2025-04-26 20:04:11 +00:00
using Godot;
using Godot.Collections;
namespace Rokojori
{
public class RDProgram
{
2025-04-29 19:46:45 +00:00
protected RDContext _context;
public RDContext context => _context;
public RDProgram( RDContext context )
{
_context = context;
}
2025-04-26 20:04:11 +00:00
public enum Type
{
VertexFragment,
Compute
}
protected Type _type;
public Type type => _type;
protected RDShader _shader;
2025-04-29 19:46:45 +00:00
public RDShader shader => _shader;
2025-04-26 20:04:11 +00:00
protected RDPipeline _pipeline;
2025-04-29 19:46:45 +00:00
public RDPipeline pipeline => _pipeline;
2025-09-21 07:35:17 +00:00
public static RDProgram ComputeFromPath( RDContext context, string path )
2025-04-29 19:46:45 +00:00
{
var p = new RDProgram( context );
p._shader = RDShader.FromPath( context, path );
if ( p._shader == null || ! p._shader.rid.IsValid )
{
context.Error( "Invalid shader", path );
return null;
}
2025-09-21 07:35:17 +00:00
p._pipeline = RDPipeline.CreateCompute( context, p._shader );
2025-04-29 19:46:45 +00:00
if ( p._pipeline == null || ! p._pipeline.rid.IsValid )
{
context.Error( "Invalid pipeline", path );
return null;
}
return p;
}
2025-04-26 20:04:11 +00:00
}
2025-09-21 07:35:17 +00:00
2025-09-26 12:00:59 +00:00
// public static RDProgram RenderFromPath( RDContext context, string path, RDRenderPipelineSetup setup )
// {
// var p = new RDProgram( context );
// p._shader = RDShader.FromPath( context, path );
// if ( p._shader == null || ! p._shader.rid.IsValid )
// {
// context.Error( "Invalid shader", path );
// return null;
// }
// p._pipeline = RDPipeline.CreateRender( context, p._shader, setup );
// if ( p._pipeline == null || ! p._pipeline.rid.IsValid )
// {
// context.Error( "Invalid pipeline", path );
// return null;
// }
// return p;
// }
// }
// }
2025-04-26 20:04:11 +00:00
}