Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.

Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
Nitload
2025-06-18 05:17:14 +08:00
parent 74c01effe4
commit c624a8ca38
300 changed files with 12227 additions and 4303 deletions
@@ -48,11 +48,9 @@ namespace StgSharp.Graphics.ShaderEdit
private List<string> codeList;
private List<ShaderFunction> usedShaderFunctions;
public Uniform<T> DefineUniform<T>( string name, int index )
where T: struct
public Uniform<T> DefineUniform<T>( string name, int index ) where T: struct
{
ShaderParameter p = new ShaderParameter(
name, ShaderParameter.TypeMarshal<T>() );
ShaderParameter p = new ShaderParameter( name, ShaderParameter.TypeMarshal<T>() );
uniformDefine.Add( index, p );
//return new Uniform<TView>();
@@ -72,23 +70,26 @@ namespace StgSharp.Graphics.ShaderEdit
public int ParameterCount => inputList.Count;
public void EmitCall(
ShaderFunction function,
ShaderParameter outPut,
params ShaderParameter[] inputParams )
ShaderFunction function,
ShaderParameter outPut,
params ShaderParameter[] inputParams )
{
if( inputParams.Length != function.ParameterCount ) {
if( inputParams.Length != function.ParameterCount )
{
// Param list length not equal
throw new ArgumentException(
"Provided parameters does not match function's parameter list." );
}
if( !ShaderParameter.IsSameType( outPut, function.outPut ) ) {
if( !ShaderParameter.IsSameType( outPut, function.outPut ) )
{
// Type of returning value not equal
throw new ArgumentException(
"Provided parameters does not match function's parameter list." );
}
for( int i = 0; i < inputParams.Length; i++ ) {
if( !ShaderParameter.IsSameType(
function.inputList[ i ], inputParams[ i ] ) ) {
for( int i = 0; i < inputParams.Length; i++ )
{
if( !ShaderParameter.IsSameType( function.inputList[ i ], inputParams[ i ] ) )
{
// Input type not match
throw new InvalidCastException(
"Provided parameters does not match function's parameter list." );
@@ -124,20 +125,21 @@ namespace StgSharp.Graphics.ShaderEdit
isReadOnly = false;
}
public static bool IsSameType(
ShaderParameter param1,
ShaderParameter param2 )
public static bool IsSameType( ShaderParameter param1, ShaderParameter param2 )
{
if( param1.type != InternalShaderType.Struct ) {
if( param1.type != InternalShaderType.Struct )
{
return param1.type == param2.type;
} else {
} else
{
throw new Exception( "Struct is currently not supported." );
}
}
public static InternalShaderType TypeMarshal<T>() where T: struct
{
switch( Type.GetTypeCode( typeof( T ) ) ) {
switch( Type.GetTypeCode( typeof( T ) ) )
{
case TypeCode.Single:
return InternalShaderType.Float;
case TypeCode.Double:
@@ -149,7 +151,8 @@ namespace StgSharp.Graphics.ShaderEdit
default:
break;
}
switch( typeof( T ).Name ) {
switch( typeof( T ).Name )
{
case "vec4d":
return InternalShaderType.Vector4;
case "Matrix2x2":
@@ -171,8 +174,7 @@ namespace StgSharp.Graphics.ShaderEdit
case "Matrix4x4":
return InternalShaderType.Matrix4x4;
default:
throw new ArgumentException(
"Not supported shader data type." );
throw new ArgumentException( "Not supported shader data type." );
}
}
@@ -53,8 +53,7 @@ namespace StgSharp.Graphics.ShaderEdit
internal ShaderStruct() { }
public ShaderStruct(
params (GlHandle, ShaderStructMember)[] uniformPairs )
public ShaderStruct( params (GlHandle, ShaderStructMember)[] uniformPairs )
{
uniformPair = new Dictionary<GlHandle, ShaderStructMember>();
if( uniformPairs.Length == 0 ) {
@@ -69,10 +68,12 @@ namespace StgSharp.Graphics.ShaderEdit
public unsafe void SetAllUniforms()
{
OpenglContext* gl = ( OpenglContext* )OpenGL.OpenGLFunction.CurrentGL.ContextHandle;
foreach( KeyValuePair<GlHandle, ShaderStructMember> uniform in uniformPair ) {
foreach( KeyValuePair<GlHandle, ShaderStructMember> uniform in uniformPair )
{
int id = uniform.Key.SignedValue;
ShaderStructMember s = uniform.Value;
switch( s.type ) {
switch( s.type )
{
case InternalShaderType.Struct:
throw new ArgumentException(
"Incorrect type \"Struct\" defined in this self define type" );