daly update on 20230502 by nitload youmu
This commit is contained in:
@@ -86,7 +86,6 @@ namespace StgSharp.Graphics
|
||||
frameTimeProvider.SpanRefreshCallback =
|
||||
() =>
|
||||
{
|
||||
Interlocked.Increment(ref _frameCount);
|
||||
};
|
||||
height = 800;
|
||||
width = 600;
|
||||
@@ -104,8 +103,8 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
Interlocked.Exchange(ref _frameSpeed, _frameCount);
|
||||
Interlocked.Exchange(ref _frameCount, 0);
|
||||
//Console.Clear();
|
||||
//Console.WriteLine(_frameSpeed);
|
||||
Console.Clear();
|
||||
Console.WriteLine(_frameSpeed);
|
||||
};
|
||||
frameTimeProvider = new TimeSpanProvider(
|
||||
1000L * 1000L / 60, TimeSpanProvider.DefaultProvider
|
||||
@@ -113,8 +112,6 @@ namespace StgSharp.Graphics
|
||||
frameTimeProvider.SpanRefreshCallback =
|
||||
() =>
|
||||
{
|
||||
Interlocked.Increment(ref _frameCount);
|
||||
Console.WriteLine(1);
|
||||
};
|
||||
height = size.height;
|
||||
width = size.width;
|
||||
|
||||
@@ -56,12 +56,11 @@ namespace StgSharp.Graphics
|
||||
/// </summary>
|
||||
public unsafe void Show()
|
||||
{
|
||||
int a = 0;
|
||||
while (!ShouldClose)
|
||||
{
|
||||
a++;
|
||||
renderLogic.RunRepeatedly(() => ShouldClose);
|
||||
frameTimeProvider.WaitNextSpan();
|
||||
Interlocked.Add(ref _frameCount, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,17 +42,30 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
internal static unsafe partial class GL
|
||||
{
|
||||
private static IntPtr api;
|
||||
|
||||
private static ref GLcontext Context
|
||||
{
|
||||
get { return ref *(GLcontext*)api; }
|
||||
}
|
||||
private static GLcontext* context;
|
||||
|
||||
public static IntPtr CurrentContextHandle
|
||||
{
|
||||
get { return (IntPtr)api; }
|
||||
set { api = value; }
|
||||
get { return (IntPtr)context; }
|
||||
set
|
||||
{
|
||||
context = (GLcontext*)value;
|
||||
}
|
||||
}
|
||||
|
||||
private static ref GLcontext Context
|
||||
{
|
||||
get
|
||||
{
|
||||
#if DEBUG
|
||||
if ((IntPtr)context==IntPtr.Zero)
|
||||
{
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
#endif
|
||||
return ref *context;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -56,10 +56,9 @@ namespace StgSharp.Graphics
|
||||
private static string glExtensionList;
|
||||
|
||||
/// <summary>
|
||||
/// Load all supportted OpenGL APIs and bind them to given <see cref="Form"/> context.
|
||||
/// Load all supported OpenGL APIs and bind them to given <see cref="Form"/> context.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Form"/> used as current OpenGL context</param>
|
||||
/// <param name="loader">A delegate to get address of OpenGL api</param>
|
||||
public static unsafe void LoadGLapi(this glRenderStream stream)
|
||||
{
|
||||
GLcontext* context = (GLcontext*)stream.ContextHandle;
|
||||
@@ -94,7 +93,7 @@ namespace StgSharp.Graphics
|
||||
coreVersion.Replace(branch, string.Empty);
|
||||
}
|
||||
}
|
||||
string[] versionSep = coreVersion.Split('.');
|
||||
string[] versionSep = coreVersion!.Split('.');
|
||||
int majorVersion = int.Parse(versionSep[0]);
|
||||
int minorVersion = int.Parse(versionSep[1]);
|
||||
CheckCoreVersion(majorVersion, minorVersion);
|
||||
|
||||
@@ -100,10 +100,12 @@ namespace StgSharp.Graphics
|
||||
in Dictionary<string, BlueprintPipeline> output)
|
||||
{
|
||||
MakeAsCurrentContext();
|
||||
ProcessInput();
|
||||
Main(in input, in output);
|
||||
InternalIO.glfwSwapBuffers(CanvasHandle);
|
||||
InternalIO.glfwPollEvents();
|
||||
}
|
||||
|
||||
|
||||
internal sealed override void InternalTerminate()
|
||||
{
|
||||
Deinit();
|
||||
|
||||
@@ -81,18 +81,29 @@ namespace StgSharp.Logic
|
||||
|
||||
public void Init(int threadCount)
|
||||
{
|
||||
foreach (var item in allNode)
|
||||
if (threadCount!=0)
|
||||
{
|
||||
if (item.Value.IsNative)
|
||||
foreach (var item in allNode)
|
||||
{
|
||||
nativeNodeList.Add(item.Value);
|
||||
if (item.Value.IsNative)
|
||||
{
|
||||
nativeNodeList.Add(item.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeList.Add(item.Value);
|
||||
}
|
||||
}
|
||||
else
|
||||
nativeNodeList.Sort();
|
||||
PrepareTasks(threadCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in allNode)
|
||||
{
|
||||
nodeList.Add(item.Value);
|
||||
}
|
||||
}
|
||||
nativeNodeList.Sort();
|
||||
nodeList.Sort();
|
||||
if (threadCount > nodeList.Count)
|
||||
{
|
||||
@@ -100,29 +111,31 @@ namespace StgSharp.Logic
|
||||
"Thread setting error: amount of threads of this blueprint is larger than amount of nodes.", LogType.Warning);
|
||||
threadCount = nodeList.Count;
|
||||
}
|
||||
for (int i = 0; i < threadCount; i++)
|
||||
}
|
||||
|
||||
public void PrepareTasks(int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
allThread.Add(new Task(
|
||||
|
||||
() =>
|
||||
{
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
RequestNextNode().Run();
|
||||
}
|
||||
}
|
||||
catch (NodeClearException) { }
|
||||
} while (!terminate());
|
||||
}
|
||||
|
||||
));
|
||||
allThread.Add(new Task(IndividualTask));
|
||||
}
|
||||
}
|
||||
|
||||
private void IndividualTask()
|
||||
{
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
RequestNextNode().Run();
|
||||
}
|
||||
}
|
||||
catch (NodeClearException) { }
|
||||
} while (!terminate());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run all nodes repeatedly until it is instructed to terminate.
|
||||
/// </summary>
|
||||
@@ -160,11 +173,6 @@ namespace StgSharp.Logic
|
||||
|
||||
private void SingleThreadRun(Func<bool> terminateInstructor)
|
||||
{
|
||||
foreach (var node in nativeNodeList)
|
||||
{
|
||||
nodeList.Add(node);
|
||||
}
|
||||
nodeList.Sort();
|
||||
beginNode.Run();
|
||||
foreach (var item in nodeList)
|
||||
{
|
||||
|
||||
@@ -209,6 +209,7 @@ namespace StgSharp.Logic
|
||||
{
|
||||
try
|
||||
{
|
||||
//Console.WriteLine(name);
|
||||
BlueprintPipeline.WaitAll(inputInterfaces);
|
||||
mainOperation(in inputInterfaces, in outputInterfaces);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Security.Authentication.ExtendedProtection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@@ -68,15 +69,14 @@ namespace StgSharp.Logic
|
||||
|
||||
public void CompleteAndSkip()
|
||||
{
|
||||
Console.WriteLine(Former.Name);
|
||||
Console.WriteLine($"{former.Name}\t->\t{after.Name}\tComplete");
|
||||
//Console.WriteLine($"Complete\t{former.Name}\t->\t{after.Name}");
|
||||
formerCompleteSemaphore.Release();
|
||||
}
|
||||
|
||||
public void CompleteAndWriteData(BlueprintPipelineArgs args)
|
||||
{
|
||||
this.args = args;
|
||||
Console.WriteLine($"{former.Name}\t->\t{after.Name}\tComplete");
|
||||
//Console.WriteLine($"Complete\t{former.Name}\t->\t{after.Name}");
|
||||
formerCompleteSemaphore.Release();
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace StgSharp.Logic
|
||||
|
||||
public void WaitForStart()
|
||||
{
|
||||
Console.WriteLine($"Waiting\t{former.Name}\t->\t{after.Name}");
|
||||
//Console.WriteLine($"Waiting \t{former.Name}\t->\t{after.Name}");
|
||||
formerCompleteSemaphore.Wait();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace StgSharp
|
||||
public class TimeSpanProvider
|
||||
{
|
||||
|
||||
private Action<SemaphoreFullException> _frameUpdateMissCallback = null;
|
||||
private Action _frameUpdateMissCallback = null;
|
||||
|
||||
private readonly int _maxSpanCount;
|
||||
private Action _refreshCallback;
|
||||
@@ -108,7 +108,7 @@ namespace StgSharp
|
||||
/// </summary>
|
||||
public static TimeSourceProviderBase DefaultProvider => StgSharpTime.OnlyInstance;
|
||||
|
||||
public Action<SemaphoreFullException> FrameUpdateMissCallback
|
||||
public Action FrameUpdateMissCallback
|
||||
{
|
||||
get => _frameUpdateMissCallback;
|
||||
set => _frameUpdateMissCallback = value;
|
||||
@@ -140,30 +140,33 @@ namespace StgSharp
|
||||
|
||||
internal bool CheckTime(long microseconds)
|
||||
{
|
||||
if (microseconds - _spanBegin > _spanLength)
|
||||
if (microseconds - _spanBegin < _spanLength)
|
||||
{
|
||||
_spanBegin = microseconds;
|
||||
timeSpanCount++;
|
||||
try
|
||||
return true;
|
||||
}
|
||||
|
||||
_spanBegin = microseconds;
|
||||
timeSpanCount++;
|
||||
|
||||
if (_refreshCallback != null)
|
||||
{
|
||||
_refreshCallback();
|
||||
}
|
||||
if (_refreshSemaphore.CurrentCount == 0)
|
||||
{
|
||||
_refreshSemaphore.Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_frameUpdateMissCallback != null)
|
||||
{
|
||||
if (_refreshCallback != null)
|
||||
{
|
||||
_refreshCallback();
|
||||
}
|
||||
_refreshSemaphore.Release();
|
||||
}
|
||||
catch (SemaphoreFullException ex)
|
||||
{
|
||||
if (_frameUpdateMissCallback != null)
|
||||
{
|
||||
_frameUpdateMissCallback(ex);
|
||||
}
|
||||
}
|
||||
if (timeSpanCount > _maxSpanCount)
|
||||
{
|
||||
return false;
|
||||
_frameUpdateMissCallback();
|
||||
}
|
||||
}
|
||||
if (timeSpanCount > _maxSpanCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0cd01ed9ddc7e151899218121d69a29650b39b34")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8149dfacb01d49f8173ee2799eb2bc20f34ee231")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp")]
|
||||
[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/0cd01ed9ddc7e151899218121d69a29650b39b34/*"}}
|
||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/8149dfacb01d49f8173ee2799eb2bc20f34ee231/*"}}
|
||||
Reference in New Issue
Block a user