daily uodate on 20240626 by nitload youmu[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[p
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("OEM")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7fb220c523c50504348a6b44e526999a45b4c242")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b2cb0cbddfff2845396010b6dbcd4e6ae51b0177")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("OEM")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("OEM")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -41,12 +41,20 @@ namespace StgSharp
|
||||
{
|
||||
public static unsafe partial class StgSharp
|
||||
{
|
||||
private static int _mainThreadID = -1;
|
||||
|
||||
static byte[] _currentHash;
|
||||
|
||||
private static bool _inited;
|
||||
internal const int ssdSegmentLength = 16;
|
||||
|
||||
public static int MainThreadID
|
||||
{
|
||||
get => _mainThreadID == -1 ?
|
||||
throw new InvalidOperationException("StgSharp environment is not inited. " +
|
||||
"Main thread id is not available") :_mainThreadID;
|
||||
}
|
||||
|
||||
public static byte[] CurrentAssemblyHash
|
||||
{
|
||||
get
|
||||
|
||||
@@ -42,6 +42,7 @@ using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#if Windows
|
||||
@@ -64,8 +65,6 @@ namespace StgSharp
|
||||
VK
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static partial class StgSharp
|
||||
{
|
||||
|
||||
@@ -89,6 +88,7 @@ namespace StgSharp
|
||||
InternalIO.InternalWriteLog(
|
||||
$"Program {Assembly.GetEntryAssembly()!.FullName} Started.",
|
||||
LogType.Info);
|
||||
_mainThreadID = Environment.CurrentManagedThreadId;
|
||||
}
|
||||
|
||||
public static void LogError(Exception ex)
|
||||
|
||||
@@ -48,13 +48,15 @@ namespace StgSharp.Graphics
|
||||
|
||||
public unsafe delegate void FrameBufferSizeHandler(IntPtr window, uint width, uint height);
|
||||
|
||||
public unsafe delegate void FramePositionHandler(IntPtr window, float width, float height);
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Function handler to load an opengl function by searching its name.
|
||||
/// </summary>
|
||||
/// <param name="name">the name of the Opengl function</param>
|
||||
/// <returns>An intptr value representing the pointer to the function</returns>
|
||||
/// <returns>An Intptr value representing the pointer to the function</returns>
|
||||
public delegate IntPtr glLoader(string name);
|
||||
|
||||
#region glDEBUG
|
||||
|
||||
@@ -103,7 +103,6 @@ namespace StgSharp.Graphics
|
||||
internal unsafe delegate void GLFWkeyfun(glfwWindow* window, int key, int scancode, int action, int mods);
|
||||
internal unsafe delegate void GLFWjoystickfun(int jid, int keyevent);
|
||||
public unsafe delegate void GLFWglproc();
|
||||
internal unsafe delegate void FramebuffersizeHandler(IntPtr window, int width, int height); //window is the pointer to a glfwWindow instance
|
||||
internal unsafe delegate void GLFWerrorfun(int error_code, sbyte* description);
|
||||
internal unsafe delegate void GLFWdropfun(glfwWindow* window, int path_count, sbyte*[] paths);
|
||||
internal unsafe delegate void GLFWcursorposfun(glfwWindow* window, double xpos, double ypos);
|
||||
|
||||
@@ -120,15 +120,6 @@ namespace StgSharp.Graphics.GL
|
||||
NativeCamera.SetViewDirection(position, direction, up);
|
||||
}
|
||||
|
||||
protected static void PollEvents()
|
||||
{
|
||||
InternalIO.glfwPollEvents();
|
||||
}
|
||||
|
||||
protected void SwapBuffers()
|
||||
{
|
||||
InternalIO.glfwSwapBuffers(CanvasHandle);
|
||||
}
|
||||
|
||||
#region Key Control
|
||||
|
||||
|
||||
@@ -84,15 +84,6 @@ namespace StgSharp.Graphics
|
||||
public string[] OutputInterfacesName => OutputPortsName;
|
||||
|
||||
|
||||
public FrameBufferSizeHandler FrameSizeCallback
|
||||
{
|
||||
set
|
||||
{
|
||||
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(value);
|
||||
InternalIO.glfwSetFramebufferSizeCallback(CanvasHandle, handlerPtr);
|
||||
}
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get => primeArgs.Height;
|
||||
@@ -186,6 +177,15 @@ namespace StgSharp.Graphics
|
||||
InternalDraw(in input, in output);
|
||||
}
|
||||
|
||||
internal protected static void PollEvents()
|
||||
{
|
||||
InternalIO.glfwPollEvents();
|
||||
}
|
||||
|
||||
internal protected void SwapBuffers()
|
||||
{
|
||||
InternalIO.glfwSwapBuffers(CanvasHandle);
|
||||
}
|
||||
|
||||
#region native camera operation
|
||||
protected abstract void NativeCameraViewRange(Radius fieldOfRange, vec2d offset, (float frontDepth, float backDepth) viewDepth);
|
||||
|
||||
@@ -34,6 +34,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
@@ -42,7 +43,9 @@ namespace StgSharp.Graphics
|
||||
public class ViewPort
|
||||
{
|
||||
private int _width, _height;
|
||||
|
||||
private FrameBufferSizeHandler _sizeHandler;
|
||||
private FramePositionHandler _positionHandler;
|
||||
|
||||
internal ViewPort()
|
||||
{
|
||||
_height = 800;
|
||||
@@ -119,5 +122,24 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
public FrameBufferSizeHandler FrameSizeCallback
|
||||
{
|
||||
set
|
||||
{
|
||||
_sizeHandler = value;
|
||||
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(_sizeHandler);
|
||||
InternalIO.glfwSetFramebufferSizeCallback(ViewPortID, handlerPtr);
|
||||
}
|
||||
}
|
||||
|
||||
public FramePositionHandler FramePostionCallback
|
||||
{
|
||||
set
|
||||
{
|
||||
_positionHandler = value;
|
||||
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(_positionHandler);
|
||||
InternalIO.glfwSetWindowPosCallback(ViewPortID,handlerPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace StgSharp
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "glfwGetWindowUserPointer")] internal static extern unsafe void* glfwGetWindowUserPointer(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "glfwSetWindowPosCallback")] internal static extern unsafe GLFWwindowposfun glfwSetWindowPosCallback(IntPtr window, GLFWwindowposfun callback);
|
||||
[DllImport(SSC_libName, EntryPoint = "glfwSetWindowPosCallback")] internal static extern unsafe GLFWwindowposfun glfwSetWindowPosCallback(IntPtr window, IntPtr callback);
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "glfwSetWindowSizeCallback")] internal static extern unsafe GLFWwindowsizefun glfwSetWindowSizeCallback(IntPtr window, GLFWwindowsizefun callback);
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace StgSharp
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "glfwSetWindowMaximizeCallback")] internal static extern unsafe GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(IntPtr window, GLFWwindowmaximizefun callback);
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "glfwSetFramebufferSizeCallback")] internal static extern unsafe FramebuffersizeHandler glfwSetFramebufferSizeCallback(IntPtr window, IntPtr callback);
|
||||
[DllImport(SSC_libName, EntryPoint = "glfwSetFramebufferSizeCallback")] internal static extern unsafe FrameBufferSizeHandler glfwSetFramebufferSizeCallback(IntPtr window, IntPtr callback);
|
||||
|
||||
[DllImport(SSC_libName, EntryPoint = "glfwSetWindowContentScaleCallback")] internal static extern unsafe GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(IntPtr window, GLFWwindowcontentscalefun callback);
|
||||
|
||||
|
||||
@@ -52,26 +52,26 @@ namespace StgSharp.Logic
|
||||
/// </summary>
|
||||
public partial class Blueprint : IConvertableToBlueprintNode
|
||||
{
|
||||
private int runningFlag;
|
||||
|
||||
private BeginningNode beginNode;
|
||||
private Dictionary<string, BlueprintNode> allNode;
|
||||
private EndingNode endNode;
|
||||
|
||||
private Func<bool> terminate;
|
||||
private List<BlueprintNode> globalNodeList;
|
||||
private List<BlueprintNode> nativeNodeList;
|
||||
|
||||
private SemaphoreSlim runningStat;
|
||||
|
||||
internal int currentGlobalNodeIndex;
|
||||
internal int currentNativeNodeIndex;
|
||||
|
||||
private List<BlueprintNode> nativeNodeList;
|
||||
private List<BlueprintNode> globalNodeList;
|
||||
|
||||
public Blueprint()
|
||||
{
|
||||
allNode = new Dictionary<string, BlueprintNode>();
|
||||
globalNodeList = new List<BlueprintNode>();
|
||||
nativeNodeList = new List<BlueprintNode>();
|
||||
//terminate = () => true;
|
||||
runningStat = new SemaphoreSlim(1, 1);
|
||||
beginNode = new BeginningNode(this);
|
||||
endNode = new EndingNode(this);
|
||||
}
|
||||
@@ -79,10 +79,14 @@ namespace StgSharp.Logic
|
||||
public BlueprintNode BeginLayer => beginNode;
|
||||
public BlueprintNode EndLayer => endNode;
|
||||
|
||||
internal SemaphoreSlim RunningStat
|
||||
{
|
||||
get => runningStat;
|
||||
}
|
||||
|
||||
public bool IsRunning
|
||||
{
|
||||
get => runningFlag == 1;
|
||||
internal set => Interlocked.Exchange(ref runningFlag ,(value ? 1 : 0));
|
||||
get => runningStat.CurrentCount == 0;
|
||||
}
|
||||
|
||||
/**/
|
||||
@@ -100,6 +104,12 @@ namespace StgSharp.Logic
|
||||
allNode.Add(node.Name, node);
|
||||
}
|
||||
|
||||
public void ExecuteMain(in Dictionary<string, BlueprintPipeline> input,
|
||||
in Dictionary<string, BlueprintPipeline> output)
|
||||
{
|
||||
BlueprintRunner.Run(this, () => true);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public (string name, BlueprintPipelineArgs arg)[] GetOutput()
|
||||
{
|
||||
@@ -123,18 +133,18 @@ namespace StgSharp.Logic
|
||||
globalNodeList.Sort();
|
||||
}
|
||||
|
||||
public void ExecuteMain(in Dictionary<string, BlueprintPipeline> input,
|
||||
in Dictionary<string, BlueprintPipeline> output)
|
||||
{
|
||||
BlueprintRunner.Run(this, () => true);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetInput(params (string name, BlueprintPipelineArgs arg)[] parameters)
|
||||
{
|
||||
beginNode.InputData = parameters;
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
Interlocked.Exchange(ref currentGlobalNodeIndex, int.MaxValue);
|
||||
Interlocked.Exchange(ref currentNativeNodeIndex, int.MaxValue);
|
||||
}
|
||||
|
||||
internal bool RequestNexGlobalNode(out BlueprintNode node)
|
||||
{
|
||||
if (currentGlobalNodeIndex < globalNodeList.Count)
|
||||
@@ -170,12 +180,6 @@ namespace StgSharp.Logic
|
||||
get { return beginNode.OutputInterfaces.Select(p => p.Key).ToArray(); }
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
Interlocked.Exchange(ref currentGlobalNodeIndex, int.MaxValue);
|
||||
Interlocked.Exchange(ref currentNativeNodeIndex, int.MaxValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using StgSharp.Logic;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharpDebug.Logic
|
||||
{
|
||||
public class BlueprintActionNode : IConvertableToBlueprintNode
|
||||
{
|
||||
private Action<Dictionary<string, BlueprintPipeline>, Dictionary<string, BlueprintPipeline>> mainAction;
|
||||
private string[] inPorts;
|
||||
private string[] outPorts;
|
||||
|
||||
internal BlueprintActionNode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string[] InputInterfacesName => inPorts;
|
||||
|
||||
public string[] OutputInterfacesName => outPorts;
|
||||
|
||||
public void ExecuteMain(in Dictionary<string, BlueprintPipeline> input, in Dictionary<string, BlueprintPipeline> output)
|
||||
{
|
||||
mainAction?.Invoke(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ using StgSharp.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
@@ -57,14 +58,12 @@ namespace StgSharp.Logic
|
||||
{
|
||||
|
||||
private protected bool levelAvailable, nativeRequested;
|
||||
|
||||
private protected Dictionary<string, BlueprintPipeline> _inputInterfaces;
|
||||
private protected Dictionary<string, BlueprintPipeline> _outputInterfaces;
|
||||
private protected int _level;
|
||||
private IConvertableToBlueprintNode mainOperation;
|
||||
private string name;
|
||||
|
||||
|
||||
internal BlueprintNode(string name,
|
||||
IConvertableToBlueprintNode node, bool isNative)
|
||||
{
|
||||
@@ -85,10 +84,13 @@ namespace StgSharp.Logic
|
||||
}
|
||||
}
|
||||
|
||||
public BlueprintNode(string name, bool isNative,
|
||||
|
||||
#pragma warning disable CS8618
|
||||
internal BlueprintNode(string name, bool isNative,
|
||||
string[] inputPorts,
|
||||
string[] outputPorts
|
||||
)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
if (inputPorts == null || inputPorts.Length == 0)
|
||||
{
|
||||
@@ -260,34 +262,35 @@ namespace StgSharp.Logic
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public static IConvertableToBlueprintNode AsBlueprintNodeMainExecution(this BlueprintNodeMainExecution execution, string name)
|
||||
{
|
||||
if (execution == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(execution));
|
||||
}
|
||||
var attributeArray = execution.Method.GetCustomAttributes(typeof(BpNodeActionAttribute), false);
|
||||
var attri = (BpNodeActionAttribute)attributeArray[0];
|
||||
if ( attributeArray.Length < 0 || attri == null)
|
||||
{
|
||||
throw new InvalidCastException($"Delegate {nameof(execution)} is not marked by {typeof(BpNodeActionAttribute)}");
|
||||
}
|
||||
if (attri.OperationSpan <= 1)
|
||||
{
|
||||
return new DefaultConvertableToBlueprintNode();
|
||||
}
|
||||
return new CrossFrameOperation(
|
||||
|
||||
);
|
||||
}
|
||||
}//--------------------------------- end of class -----------------------------------
|
||||
|
||||
public interface IConvertableToBlueprintNode
|
||||
{
|
||||
#pragma warning disable CA1819
|
||||
public string[] InputInterfacesName { get; }
|
||||
#pragma warning restore CA1819
|
||||
|
||||
|
||||
#pragma warning disable CA1819
|
||||
public string[] OutputInterfacesName { get; }
|
||||
#pragma warning restore CA1819
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ExecuteMain(
|
||||
in Dictionary<string, BlueprintPipeline> input,
|
||||
in Dictionary<string, BlueprintPipeline> output);
|
||||
}
|
||||
|
||||
|
||||
public class BlueprintNodeRunException : Exception
|
||||
{
|
||||
|
||||
protected BlueprintNodeRunException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{
|
||||
}
|
||||
|
||||
public BlueprintNodeRunException()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -12,9 +12,10 @@ namespace StgSharp.Logic
|
||||
{
|
||||
public static class BlueprintRunner
|
||||
{
|
||||
private static int _callingThread;
|
||||
private static ConcurrentStack<Blueprint> blueprintInWaiting = new ConcurrentStack<Blueprint>();
|
||||
private static NodeRunner[] allAvailableTask = new NodeRunner[1];
|
||||
private static ReaderWriterLockSlim bpLock = new ReaderWriterLockSlim();
|
||||
private static SemaphoreSlim bpLock = new SemaphoreSlim(0,1);
|
||||
private static CancellationTokenSource cts = new CancellationTokenSource();
|
||||
|
||||
public static void Run(Blueprint blueprint, Func<bool> terminateInstructor)
|
||||
@@ -27,36 +28,48 @@ namespace StgSharp.Logic
|
||||
}
|
||||
if (blueprint.IsRunning)
|
||||
{
|
||||
throw new InvalidOperationException( $"Attempt to run a blueprint twice." );
|
||||
throw new InvalidOperationException("Attempt to run a blueprint instance twice.");
|
||||
}
|
||||
blueprint.ShouldClose = terminateInstructor;
|
||||
if (IsInternalCalling)
|
||||
if (IsValidCalling)
|
||||
{
|
||||
if(InterruptAndRunNewBp(blueprint))
|
||||
//Console.WriteLine("valid and run");
|
||||
if (InterruptAndRunNewBp(blueprint))
|
||||
do { } while(InterruptAndRunNewBp(NodeRunner.CurrentBlueprint));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bpLock.IsWriteLockHeld)
|
||||
{
|
||||
bpLock.EnterWriteLock();
|
||||
}
|
||||
bpLock.Wait();
|
||||
if (InterruptAndRunNewBp(blueprint))
|
||||
do { } while (InterruptAndRunNewBp(NodeRunner.CurrentBlueprint));
|
||||
bpLock.ExitWriteLock();
|
||||
bpLock.Release();
|
||||
}
|
||||
Interlocked.Exchange(ref _callingThread, -1);
|
||||
}
|
||||
|
||||
internal static bool IsInternalCalling
|
||||
internal static bool IsValidCalling
|
||||
{
|
||||
get
|
||||
{
|
||||
if (NodeRunner.CurrentBlueprint == null || //no bp running at all
|
||||
(blueprintInWaiting.Count == 0 && NodeRunner.CurrentBlueprint.IsRunning == false)) // a bp is quiting
|
||||
{
|
||||
//in case no bp is running
|
||||
return true;
|
||||
}
|
||||
int? id = Task.CurrentId;
|
||||
if (id is null) return false;
|
||||
if (id is null)
|
||||
{
|
||||
// in case calling from main thread and current running bp
|
||||
//Console.WriteLine($"\t{_callingThread}");
|
||||
//Console.WriteLine($"\t{Thread.CurrentThread.ManagedThreadId}");
|
||||
return _callingThread == Thread.CurrentThread.ManagedThreadId;
|
||||
}
|
||||
foreach (var item in allAvailableTask)
|
||||
{
|
||||
if (item.Id == id)
|
||||
{
|
||||
//if calling from any bp running task
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -69,13 +82,18 @@ namespace StgSharp.Logic
|
||||
Debug.Assert(newBp != null);
|
||||
if (newBp != NodeRunner.CurrentBlueprint && NodeRunner.CurrentBlueprint != null)
|
||||
{
|
||||
//if a running bp exists
|
||||
blueprintInWaiting.Push(NodeRunner.CurrentBlueprint);
|
||||
}
|
||||
//load new bp to current bp
|
||||
Interlocked.Exchange(ref NodeRunner.CurrentBlueprint!, newBp);
|
||||
Interlocked.Exchange(ref _callingThread, Thread.CurrentThread.ManagedThreadId);
|
||||
//run beginning node to init it first.
|
||||
if (!NodeRunner.CurrentBlueprint.IsRunning)
|
||||
{
|
||||
(NodeRunner.CurrentBlueprint.BeginLayer as BeginningNode)!.Run();
|
||||
}
|
||||
//refresh all tasks
|
||||
for (int i = 0; i < allAvailableTask.Length; i++)
|
||||
{
|
||||
var item = allAvailableTask[i];
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Logic
|
||||
{
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class BpNodeActionAttribute : Attribute
|
||||
{
|
||||
private string[] _input;
|
||||
private string[] _output;
|
||||
private int _operationSpan;
|
||||
|
||||
internal string[] InputPort => _input;
|
||||
internal string[] OutputPort => _output;
|
||||
internal int OperationSpan => _operationSpan;
|
||||
|
||||
public BpNodeActionAttribute(string[] inputPort, string[] outputPort, int operationSpan)
|
||||
{
|
||||
_input = inputPort;
|
||||
_output = outputPort;
|
||||
this._operationSpan = operationSpan;
|
||||
}
|
||||
|
||||
public BpNodeActionAttribute(string[] inputPort, string[] outputPort)
|
||||
{
|
||||
_input = inputPort;
|
||||
_output = outputPort;
|
||||
this._operationSpan = 1;
|
||||
}
|
||||
|
||||
public BpNodeActionAttribute()
|
||||
{
|
||||
_input = Array.Empty<string>();
|
||||
_output = Array.Empty<string>();
|
||||
_operationSpan = 1;
|
||||
}
|
||||
|
||||
public BpNodeActionAttribute(int operationSpan)
|
||||
{
|
||||
_input = Array.Empty<string>();
|
||||
_output = Array.Empty<string>();
|
||||
_operationSpan = operationSpan;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Logic
|
||||
{
|
||||
public interface IConvertableToBlueprintNode
|
||||
{
|
||||
#pragma warning disable CA1819
|
||||
public string[] InputInterfacesName { get; }
|
||||
#pragma warning restore CA1819
|
||||
|
||||
#pragma warning disable CA1819
|
||||
public string[] OutputInterfacesName { get; }
|
||||
#pragma warning restore CA1819
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ExecuteMain(
|
||||
in Dictionary<string, BlueprintPipeline> input,
|
||||
in Dictionary<string, BlueprintPipeline> output);
|
||||
}
|
||||
|
||||
internal class DefaultConvertableToBlueprintNode : IConvertableToBlueprintNode
|
||||
{
|
||||
private string[] _input;
|
||||
private string[] _output;
|
||||
private BlueprintNodeMainExecution _execute;
|
||||
|
||||
string[] IConvertableToBlueprintNode.InputInterfacesName => _input;
|
||||
|
||||
string[] IConvertableToBlueprintNode.OutputInterfacesName => _output;
|
||||
|
||||
void IConvertableToBlueprintNode.ExecuteMain(in Dictionary<string, BlueprintPipeline> input, in Dictionary<string, BlueprintPipeline> output)
|
||||
{
|
||||
_execute(in input, in output);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public delegate void BlueprintNodeMainExecution(in Dictionary<string, BlueprintPipeline> input, in Dictionary<string, BlueprintPipeline> output);
|
||||
}
|
||||
@@ -43,7 +43,6 @@ namespace StgSharp.Logic
|
||||
|
||||
public class BlueprintPipeline
|
||||
{
|
||||
|
||||
private BlueprintNode after;
|
||||
private BlueprintNode former;
|
||||
private BlueprintPipelineArgs args;
|
||||
@@ -68,6 +67,8 @@ namespace StgSharp.Logic
|
||||
set => args = value;
|
||||
}
|
||||
|
||||
#region pipline op
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CompleteAndSkip()
|
||||
{
|
||||
@@ -82,6 +83,8 @@ namespace StgSharp.Logic
|
||||
CompleteAndSkip();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static void SkipAll(Dictionary<string, BlueprintPipeline> ports)
|
||||
{
|
||||
if (ports == null)
|
||||
@@ -118,6 +121,12 @@ namespace StgSharp.Logic
|
||||
formerCompleteSemaphore.Wait();
|
||||
}
|
||||
|
||||
~BlueprintPipeline()
|
||||
{
|
||||
formerCompleteSemaphore.Dispose();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public abstract class BlueprintPipelineArgs
|
||||
|
||||
@@ -46,8 +46,8 @@ namespace StgSharp.Logic
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
_bp.RunningStat.Wait();
|
||||
BlueprintPipeline.SkipAll(_outputInterfaces);
|
||||
_bp.IsRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace StgSharp.Logic
|
||||
BlueprintPipeline.WaitAll(_inputInterfaces);
|
||||
Interlocked.Exchange(ref _bp.currentGlobalNodeIndex, 0);
|
||||
Interlocked.Exchange(ref _bp.currentNativeNodeIndex, 0);
|
||||
_bp.IsRunning = false;
|
||||
_bp.RunningStat.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,11 +43,32 @@ namespace StgSharp.Logic
|
||||
}
|
||||
}
|
||||
BlueprintRunner.Run(renderLogic, ()=>ShouldClose);
|
||||
RenderStream.PollEvents();
|
||||
frameTimeProvider.WaitNextSpan();
|
||||
Interlocked.Add(ref _frameCount, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void PrivateShow()
|
||||
{
|
||||
if(0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortID))
|
||||
{
|
||||
frameTimeProvider.WaitNextSpan();
|
||||
Interlocked.Add(ref _frameCount, 1);
|
||||
viewPortDisplay.FlushSize();
|
||||
foreach (var item in this._globalKeyAction)
|
||||
{
|
||||
if (InternalIO.glfwGetKey(this.viewPortDisplay.ViewPortID, (int)item.Key.TargetKeyOrButtonID)
|
||||
== item.Key.TriggeredStatus)
|
||||
{
|
||||
item.Value();
|
||||
}
|
||||
}
|
||||
BlueprintRunner.Run(renderLogic, () => ShouldClose);
|
||||
RenderStream.PollEvents();
|
||||
}
|
||||
}
|
||||
|
||||
public T BuildNewRenderStream<T>(View arg, (int x, int y, int z) unitCubeSize) where T : RenderStream
|
||||
{
|
||||
if (arg.ContextName == this.Name)
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Controlling.UsrActivity;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.GL;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
@@ -96,6 +97,18 @@ namespace StgSharp.Logic
|
||||
{
|
||||
};
|
||||
_globalKeyAction = new Dictionary<KeyTrigger, Action>();
|
||||
viewPortDisplay.FrameSizeCallback = (handle, width, height)
|
||||
=>
|
||||
{
|
||||
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
|
||||
glFunc.Viewport(0, 0, width, height);
|
||||
PrivateShow();
|
||||
};
|
||||
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)
|
||||
=>
|
||||
{
|
||||
PrivateShow();
|
||||
};
|
||||
}
|
||||
|
||||
private void CountFps()
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7fb220c523c50504348a6b44e526999a45b4c242")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b2cb0cbddfff2845396010b6dbcd4e6ae51b0177")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -86,12 +86,6 @@ namespace StgSharp
|
||||
{
|
||||
//SetSizeLimit(800, 800, 800, 800);
|
||||
|
||||
FrameSizeCallback = new FrameBufferSizeHandler(
|
||||
(window, width, height) =>
|
||||
{
|
||||
glFunc.Viewport(0, 0, width, height);
|
||||
});
|
||||
|
||||
vbo = CreateVertexBuffer(2);
|
||||
vao = CreateVertexArray(1);
|
||||
ebo = CreateElementBuffer(1);
|
||||
@@ -199,7 +193,6 @@ namespace StgSharp
|
||||
BlueprintPipeline.SkipAll(output);
|
||||
|
||||
SwapBuffers();
|
||||
PollEvents();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,9 +78,6 @@ namespace StgSharp
|
||||
{
|
||||
//SetSizeLimit(800, 800, 800, 800);
|
||||
|
||||
FrameSizeCallback =
|
||||
(IntPtr id, uint width, uint height) => glFunc.Viewport(0, 0, width, height);
|
||||
|
||||
shader = CreateShaderProgram();
|
||||
Shader vertex = CreateShaderSegment(ShaderType.Vertex, 1);
|
||||
Shader fragment = CreateShaderSegment(ShaderType.Fragment, 1);
|
||||
|
||||
@@ -108,9 +108,6 @@ namespace StgSharp
|
||||
|
||||
//SetSizeLimit(800, 800, 800, 800);
|
||||
|
||||
FrameSizeCallback =
|
||||
(IntPtr id, uint width, uint height) => glFunc.Viewport(0, 0, width, height);
|
||||
|
||||
s = CreateShaderProgram();
|
||||
Shader pvs = CreateShaderSegment(ShaderType.Vertex, 1);
|
||||
Shader pfs = CreateShaderSegment(ShaderType.Fragment, 1);
|
||||
|
||||
@@ -50,8 +50,6 @@ namespace StgSharp
|
||||
);
|
||||
StgSharpDemoForm demoForm = new StgSharpDemoForm(vp: viewport,60);
|
||||
|
||||
|
||||
|
||||
View v = demoForm.BuildNewView(null, (1,1,1));
|
||||
|
||||
var stream = demoForm.BuildRenderStream
|
||||
@@ -74,16 +72,15 @@ namespace StgSharp
|
||||
"port_1", "input_1");
|
||||
node0.AddBefore(node1,
|
||||
"output_1", "TextureInput");
|
||||
/**/
|
||||
/*
|
||||
node1.AddBefore(blueprint.EndLayer,
|
||||
"Output", "port2");
|
||||
node2.AddAfter(blueprint.BeginLayer,
|
||||
"port_2", CrossFrameOperation.InputInterfacesName);
|
||||
/**/
|
||||
/*
|
||||
node1.AddBefore(node2,
|
||||
"Output", CrossFrameOperation.InputInterfacesName);
|
||||
node2.AddAfter(blueprint.BeginLayer,"input_2", CrossFrameOperation.InputInterfacesName);
|
||||
/**/
|
||||
node2.AddAfter(blueprint.BeginLayer,
|
||||
"input_2", CrossFrameOperation.InputInterfacesName);
|
||||
/**/
|
||||
node2.AddBefore(blueprint.EndLayer,
|
||||
CrossFrameOperation.OutputInterfacesName, "port_1");
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7fb220c523c50504348a6b44e526999a45b4c242")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b2cb0cbddfff2845396010b6dbcd4e6ae51b0177")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/7fb220c523c50504348a6b44e526999a45b4c242/*"}}
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/b2cb0cbddfff2845396010b6dbcd4e6ae51b0177/*"}}
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgsharpEnvDebug")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7fb220c523c50504348a6b44e526999a45b4c242")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b2cb0cbddfff2845396010b6dbcd4e6ae51b0177")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("StgsharpEnvDebug")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgsharpEnvDebug")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
Reference in New Issue
Block a user