Added Ink and ncore to modules

This commit is contained in:
2025-09-30 07:27:58 +02:00
commit 9ec1b9cf82
327 changed files with 14171 additions and 0 deletions

12
test/all.suite Normal file
View File

@@ -0,0 +1,12 @@
test/assign_arithmetic_expression.inx lex parse
test/empty_vertex_main.inx lex parse
test/empty_vertex_main_with_position_parameter.inx lex parse
test/meta_block.inx lex parse
test/basic_property_and_return_value.inx lex parse
test/function_call_return.inx lex parse
test/struct_field_access_test.inx lex parse
test/pass_and_access_struct_fields_in_functions.inx lex parse
test/field_without_type_specifier.inx lex parse
test/functions_with_same_name.inx lex parse
test/function_with_int_return.inx lex parse
test/type_as_variable_name.inx lex parse

View File

@@ -0,0 +1,4 @@
vertex main :: () {
v : float2;
v.x = (2.0 + ((4.0 - 2.0) * 1.5)) * 3.0;
}

6
test/arrays.ink Normal file
View File

@@ -0,0 +1,6 @@
vertex main :: () -> float4 @position {
arr : [16].float4;
arr[0] = float4(1, 1, 1, 1);
pos := arr[1];
return pos;
}

View File

@@ -0,0 +1,3 @@
vertex main :: () {
x : float = 2.0 + 5.0;
}

View File

@@ -0,0 +1,5 @@
vertex main :: () {
a : float2;
b : float2;
(a + b).x = 2.0;
}

View File

@@ -0,0 +1,10 @@
P :: struct {
v : float2;
}
vertex main :: () {
p : P;
p.v.x.y = 2.0;
// v : float2;
// v.x.y.z = 2.0;
}

View File

@@ -0,0 +1,11 @@
properties :: Constant_Buffer @properties {
color : float4;
}
vertex main :: (pos : float3 @position) -> float3 @position {
return pos;
}
pixel main :: () -> float4 @target0 {
return properties.color;
}

View File

@@ -0,0 +1,8 @@
props :: properties {
resolution : float2;
}
vertex main :: (pos : float3 @position) -> float4 @position {
p := float2(1.0 - 2.0 * props.resolution.x, 1.0 - 2.0 * props.resolution.y);
return float4(p, 1.0, 1.0);
}

11
test/buffers.ink Normal file
View File

@@ -0,0 +1,11 @@
property_buffer :: Buffer {
color : float4;
}
const_buffer :: Constant_Buffer {
color : float4;
}
pixel main :: (index : int) {
return property_buffer[index].color;
}

34
test/builtin_types.ink Normal file
View File

@@ -0,0 +1,34 @@
vertex main :: () {
v2 : float2 = float2(2.0, 2.0);
v2 = float2(2.0);
v2 = float2(v2);
v3 : float3 = float3(2.0, 2.0, 2.0);
v3 = float3(v2, 1.0);
v3 = float3(1.0, v2);
v3 = float3(1.0);
v3 = float3(v3);
v4 : float4 = float4(2.0, 2.0, 2.0, 2.0);
v4 = float4(v4);
v4 = float4(v2, v2);
v4 = float4(v2, 1.0, 1.0);
v4 = float4(1.0, v2, 1.0);
v4 = float4(1.0, 1.0, v2);
v4 = float4(v3, 2.0);
v4 = float4(2.0, v3);
v4 = float4(2.0);
v4 = float4(1.0, 1.0, v2);
v4 = float4(2.0);
v2.x = 2.0;
v2.y = 2.0;
p := v2.x + v3.z;
q := v4.w + v2.x;
m : float4x4;
}

View File

@@ -0,0 +1,6 @@
scope (global) [
[vertex__vs_main] : ()
scope (vertex__vs_main) [
[v] : float2
]
]

7
test/check/arrays.golden Normal file
View File

@@ -0,0 +1,7 @@
scope (global) [
[vertex__vs_main] : () -> float4
scope (vertex__vs_main) [
[pos] : float4
[arr] : [16].float4
]
]

View File

@@ -0,0 +1,6 @@
scope (global) [
[vertex__vs_main] : ()
scope (vertex__vs_main) [
[x] : float
]
]

View File

@@ -0,0 +1,6 @@
test/bad_double_access.ink:7,4: error: Attempting to access a field on a primitive type 'float'.
p.v.x.
^
declaration:
x: float


View File

@@ -0,0 +1,12 @@
scope (global) [
[pixel__ps_main] : () -> float4
[vertex__vs_main] : (pos : float3) -> float3
[properties] : {color : float4}
scope (properties) [
[color] : float4
]
scope (vertex__vs_main) [
[pos] : float3
]
scope (pixel__ps_main) []
]

View File

@@ -0,0 +1,11 @@
scope (global) [
[vertex__vs_main] : ()
scope (vertex__vs_main) [
[v2] : float2
[v4] : float4
[v3] : float3
[p] : float
[m] : float4x4
[q] : float
]
]

View File

@@ -0,0 +1,8 @@
scope (global) [
[vertex__vs_main] : ()
scope (vertex__vs_main) [
[x] : float
[z] : float
[y] : float
]
]

View File

@@ -0,0 +1,15 @@
scope (global) [
[pixel__ps_main] : () -> float4
[vertex__vs_main] : (pos : float4) -> float4
[camera] : {projection : float4x4, view : float4x4}
scope (camera) [
[projection] : float4x4
[view] : float4x4
]
scope (vertex__vs_main) [
[pos] : float4
[mv] : float4
[mvp] : float4
]
scope (pixel__ps_main) []
]

View File

@@ -0,0 +1,15 @@
scope (global) [
[pixel__ps_main] : (pos : float4) -> float4
[vertex__vs_main] : (pos : float3) -> float4
[p] : {time : float}
scope (p) [
[time] : float
]
scope (vertex__vs_main) [
[pos] : float3
]
scope (pixel__ps_main) [
[t] : float
[pos] : float4
]
]

View File

@@ -0,0 +1,10 @@
scope (global) [
[vertex__vs_main] : ()
[p] : {v : float2}
scope (p) [
[v] : float2
]
scope (vertex__vs_main) [
[x] : float
]
]

View File

@@ -0,0 +1,4 @@
scope (global) [
[Foo] : {}
scope (Foo) []
]

View File

@@ -0,0 +1,4 @@
scope (global) [
[vertex__vs_main] : ()
scope (vertex__vs_main) []
]

View File

@@ -0,0 +1,6 @@
scope (global) [
[vertex__vs_main] : (pos : float3) -> float3
scope (vertex__vs_main) [
[pos] : float3
]
]

View File

@@ -0,0 +1,7 @@
scope (global) [
[vertex__vs_main] : (pos : float4) -> float4
scope (vertex__vs_main) [
[x] : float
[pos] : float4
]
]

View File

@@ -0,0 +1,4 @@
test/field_without_type_specifier.shd:2,0: error: Expected type specifier after field name.
x := 5.0;
^


View File

@@ -0,0 +1,6 @@
test/float_if_cond.ink:0,0: error: Type of expression in if condition has to be bool.
if 1.0
^^^
1.0 has type float


View File

@@ -0,0 +1,4 @@
test/float_suffix.shd:2,12: error: We don't use 'f' suffixes for floating point values.
 x : float = 2.0f
^^^^


View File

@@ -0,0 +1,10 @@
scope (global) [
[vertex__vs_main] : ()
scope (vertex__vs_main) [
[x] : int
scope (block) [
[i] : int
scope (block) []
]
]
]

View File

@@ -0,0 +1,4 @@
test/for_index_outside.ink:6,0: error: Use of undeclared symbol 'i'
 i += 1;
^


View File

@@ -0,0 +1,6 @@
scope (global) [
[foo] : () -> int
[vertex__vs_main] : ()
scope (foo) []
scope (vertex__vs_main) []
]

View File

@@ -0,0 +1,6 @@
scope (global) [
[foo] : ()
[vertex__vs_main] : ()
scope (vertex__vs_main) []
scope (foo) []
]

View File

@@ -0,0 +1,6 @@
scope (global) [
[pixel__ps_main] : () -> float4
[vertex__vs_main] : ()
scope (vertex__vs_main) []
scope (pixel__ps_main) []
]

View File

@@ -0,0 +1,6 @@
scope (global) [
[vertex__vs_main] : (pos : float3) -> int
scope (vertex__vs_main) [
[pos] : float3
]
]

View File

@@ -0,0 +1,8 @@
test/functions_with_same_name.ink:2,0: error: Redeclaration of 'foo'
 foo :: () {
^^^
test/functions_with_same_name.ink:1,0: info: Here is the first declaration of 'foo'
 foo :: () {
^^^


View File

@@ -0,0 +1,13 @@
scope (global) [
[vertex__vs_main] : (pos : float4) -> float4
[props] : {projection : float4x4, view : float4x4}
scope (props) [
[projection] : float4x4
[view] : float4x4
]
scope (vertex__vs_main) [
[pos] : float4
[mv] : float4
[mvp] : float4
]
]

View File

@@ -0,0 +1,6 @@
test/if_cond_assign.ink:0,0: error: Type of expression in if condition has to be bool.
if 0 = 100
^^^^^^
if 0 = 100 { has type int


View File

@@ -0,0 +1,8 @@
scope (global) [
[pixel__ps_main] : ()
scope (pixel__ps_main) [ scope (block) [
[alpha_color] : float4
[f] : float
]
]
]

View File

@@ -0,0 +1,4 @@
scope (global) [
[vertex__vs_console_main] : ()
scope (vertex__vs_console_main) []
]

8
test/check/ifdefs.golden Normal file
View File

@@ -0,0 +1,8 @@
scope (global) [
[vertex__vs_skinning_main] : ()
[pixel__ps_main] : ()
scope (vertex__vs_skinning_main) [
[x] : float
]
scope (pixel__ps_main) []
]

View File

@@ -0,0 +1,15 @@
scope (global) [
[foo] : () -> float
[vertex__vs_main] : (pos : float3) -> float4
[bar] : () -> float
scope (bar) []
scope (foo) []
scope (vertex__vs_main) [
[v2] : float2
[i] : int
[v4] : float4
[pos] : float3
[v3] : float3
[f] : float
]
]

View File

@@ -0,0 +1,13 @@
scope (global) [
[pixel__ps_main] : () -> float4
[vertex__vs_main] : (pos : float3, uv : float2) -> float3
[properties] : properties
scope (properties) [
[color] : float4
]
scope (vertex__vs_main) [
[pos] : float3
[uv] : float2
]
scope (pixel__ps_main) []
]

View File

@@ -0,0 +1,11 @@
scope (global) [
[foo] : () -> int
[vertex__vs_main] : ()
[bar] : () -> float
scope (foo) []
scope (bar) []
scope (vertex__vs_main) [
[x] : int
[y] : float
]
]

View File

@@ -0,0 +1,13 @@
scope (global) [
[pixel__ps_main] : () -> float4
[foo] : () -> float4
[vertex__vs_main] : (pos : float3) -> float3
scope (vertex__vs_main) [
[pos] : float3
]
scope (foo) []
scope (pixel__ps_main) [
[y] : float4
[color] : float4
]
]

View File

@@ -0,0 +1,9 @@
scope (global) [
[vertex__vs_main] : (pos : float3) -> float4
scope (vertex__vs_main) [
[pos] : float3
scope (block) [ scope (block) []
scope (block) []
]
]
]

View File

@@ -0,0 +1,6 @@
test/non_bool_cond.ink:0,0: error: Type of expression in if condition has to be bool.
if 1.0
^^^
1.0 has type float


View File

@@ -0,0 +1,15 @@
scope (global) [
[foo] : (f : Foo) -> float
[vertex__vs_main] : ()
[Foo] : {some_data : float}
scope (Foo) [
[some_data] : float
]
scope (foo) [
[f] : Foo
]
scope (vertex__vs_main) [
[d] : float
[f] : Foo
]
]

View File

@@ -0,0 +1,8 @@
scope (global) [
[pixel__ps_main] : () -> float4
[vertex__vs_main] : (pos : float3) -> float3
scope (vertex__vs_main) [
[pos] : float3
]
scope (pixel__ps_main) []
]

View File

@@ -0,0 +1,9 @@
scope (global) [
[vertex__vs_main] : (x : float, y : float, z : float, w : float)
scope (vertex__vs_main) [
[x] : float
[z] : float
[y] : float
[w] : float
]
]

View File

@@ -0,0 +1,12 @@
scope (global) [
[pixel__ps_main] : () -> float4
[vertex__vs_main] : (pos : float4) -> float4
[props] : {color : float4}
scope (props) [
[color] : float4
]
scope (vertex__vs_main) [
[pos] : float4
]
scope (pixel__ps_main) []
]

View File

@@ -0,0 +1,8 @@
test/redeclared_variable.ink:3,0: error: Redeclaration of 'x'
 x : float = 5.0
^
test/redeclared_variable.ink:2,0: info: Here is the first declaration of 'x'
 x : float = 1.0
^


View File

@@ -0,0 +1,8 @@
scope (global) [
[vertex__vs_main] : ()
scope (vertex__vs_main) [
[b] : float2
[x] : float
[a] : float2
]
]

View File

@@ -0,0 +1,9 @@
scope (global) [
[vertex__vs_main] : (pos : float3) -> float4
scope (vertex__vs_main) [
[pos] : float3
scope (block) []
scope (block) []
scope (block) []
]
]

View File

@@ -0,0 +1,7 @@
scope (global) [
[vertex__vs_main] : (pos : float3) -> float4
scope (vertex__vs_main) [
[pos] : float3
scope (block) []
]
]

View File

@@ -0,0 +1,8 @@
scope (global) [
[vertex__vs_main] : (pos : float3) -> float4
scope (vertex__vs_main) [
[pos] : float3
scope (block) []
scope (block) []
]
]

View File

@@ -0,0 +1,11 @@
scope (global) [
[Data] : {color : float4}
[vertex__vs_main] : ()
scope (Data) [
[color] : float4
]
scope (vertex__vs_main) [
[x] : float4
[d] : Data
]
]

View File

@@ -0,0 +1,6 @@
test/struct_access_primitive_type.ink:3,0: error: Attempting to access a field on a primitive type 'int'.
x.d = 4;
^
declaration:
x : int = 5


View File

@@ -0,0 +1,15 @@
scope (global) [
[Bar] : {t : Foo}
[vertex__vs_main] : ()
[Foo] : {color : float4}
scope (Foo) [
[color] : float4
]
scope (Bar) [
[t] : Foo
]
scope (vertex__vs_main) [
[b] : Bar
[f] : Foo
]
]

View File

@@ -0,0 +1,6 @@
test/temp_access.ink:5,10: error: Cannot assign to an lvalue.
 (a + b).x = 2.0;
^^^^^^^^^^^


View File

@@ -0,0 +1,4 @@
test/type_as_function_name.shd:1,0: error: Invalid function name 'int'
 int :: () {
^^^


View File

@@ -0,0 +1,4 @@
test/type_as_variable_name.ink:2,0: error: Invalid variable name 'int'
 int : float = 4.0
^^^


10
test/check/unary.golden Normal file
View File

@@ -0,0 +1,10 @@
scope (global) [
[pixel__ps_ps_main] : (position : float4) -> float4
[vertex__vs_vs_main] : (position : float3) -> float4
scope (vertex__vs_vs_main) [
[position] : float3
]
scope (pixel__ps_ps_main) [
[position] : float4
]
]

View File

@@ -0,0 +1,7 @@
test/undeclared_function.ink:2,0: error: Attempt to call undeclared function 'foo'.
 foo();
^^^


View File

@@ -0,0 +1,4 @@
test/undeclared_symbol.ink:2,10: error: Use of undeclared symbol 'f'
 b : int = f;
^


View File

@@ -0,0 +1,33 @@
test/unknown_overload.ink:6,0: error: Procedure call did not match any of the possible overloads for 'foo'
 found:
foo(v, v);
^^^
 While matching argument 1 in function call.
 foo(v, v);
^
 Possible overloads:
 foo :: (v1 : float3, v2 : float3) { (test/unknown_overload.ink:1)
 foo :: (v1 : float2, v2 : float2, v3 : float2) { (test/unknown_overload.ink:2)
test/unknown_overload.ink:6,4: error: Type mismatch. Expected float3 got float
 found:
foo(v, v);
^
expected:
float3
got:
v : float = 2.0
test/unknown_overload.ink:6,7: error: Type mismatch. Expected float3 got float
 found:
foo(v, v);
^
expected:
float3
got:
v : float = 2.0


View File

@@ -0,0 +1,6 @@
scope (global) [
[vertex__vs_main] : ()
scope (vertex__vs_main) [
[f] : float4
]
]

View File

@@ -0,0 +1,16 @@
test/wrong_argument_count.ink:5,19: error: Use of undeclared symbol 'w'
 return x * y * z * w;
^
test/wrong_argument_count.ink:9,0: error: Procedure call did not match any of the possible overloads for 'foo'
 found:
foo(2.0, 3.0);
^^^
 Possible overloads:
 foo :: (x : float, y : float, z : float) -> float { (test/wrong_argument_count.ink:1)
 Not enough arguments: Wanted 3, got 2.
 foo :: (x : float, y : float, z : float, w : float) -> float { (test/wrong_argument_count.ink:4)
 Not enough arguments: Wanted 4, got 2.


View File

@@ -0,0 +1,30 @@
test/wrong_multiply.ink:4,18: error: Procedure call did not match any of the possible overloads for 'float4'
 found:
result : float4 = float4(1.0, foo * res, 0.0, 1.0);
^^^^^^
 While matching argument 2 in function call.
 result : float4 = float4(1.0, foo * res, 0.0, 1.0);
^
 Possible overloads:
 float4 :: (float, float, float, float)
 float4 :: (float2, float2)
 float4 :: (float2, float, float)
 float4 :: (float, float2, float)
 float4 :: (float, float, float2)
 float4 :: (float, float3)
 float4 :: (float3, float)
 float4 :: (float4)
 float4 :: (float)
test/wrong_multiply.ink:4,34: error: Type mismatch. Expected float got float2
 found:
result : float4 = float4(1.0, foo * res, 0.0, 1.0);
^
expected:
float
got:
result : float4 = float4(1.0, foo * res, 0.0, 1.0);


View File

@@ -0,0 +1,30 @@
test/wrong_type_for_function.ink:11,17: error: Procedure call did not match any of the possible overloads for 'float4'
 found:
color : float4 = float4(y, 1.0, 1.0, 1.0);
^^^^^^
 While matching argument 1 in function call.
 color : float4 = float4(y, 1.0, 1.0, 1.0);
^
 Possible overloads:
 float4 :: (float, float, float, float)
 float4 :: (float2, float2)
 float4 :: (float2, float, float)
 float4 :: (float, float2, float)
 float4 :: (float, float, float2)
 float4 :: (float, float3)
 float4 :: (float3, float)
 float4 :: (float4)
 float4 :: (float)
test/wrong_type_for_function.ink:11,24: error: Type mismatch. Expected float got float2
 found:
color : float4 = float4(y, 1.0, 1.0, 1.0);
^
expected:
float
got:
y : float2 = foo()


47
test/check_all.suite Normal file
View File

@@ -0,0 +1,47 @@
test/assign_arithmetic_expression.ink check
test/arithmetic_parens.ink check
test/basic_property_and_return_value.ink check
test/builtin_types.ink check
test/complicated_computation.ink check
test/constant_buffer.ink check
test/bad_double_access.ink check
test/double_access.ink check
test/empty_struct.ink check
test/empty_vertex_main.ink check
test/empty_vertex_main_with_position_parameter.ink check
test/field_assignment.ink check
test/for_i_loop.ink check
test/function_call.ink check
test/function_call_out_of_order_declaration.ink check
test/function_call_return.ink check
test/functions_with_same_name.ink check
test/function_with_int_return.ink check
test/if_cond_assign.ink check
test/ifdefs.ink check
test/if_def_block.ink check
test/if_def_expression.ink check
test/inferred_types.ink check
test/multiple_functions.ink check
test/multiple_semicolons_everywhere.ink check
test/nested_if.ink check
test/non_bool_cond.ink check
test/pass_and_access_struct_fields_in_functions.ink check
test/passthrough.ink check
test/redeclared_variable.ink check
test/rvalue_binary.ink check
test/simple_else_if.ink check
test/simple_if_else.ink check
test/simple_if.ink check
test/simple_struct_access.ink check
test/struct_access_primitive_type.ink check
test/struct_within_struct.ink check
test/temp_access.ink check
test/type_as_variable_name.ink check
test/unary.ink check
test/undeclared_function.ink check
test/undeclared_symbol.ink check
test/unknown_overload.ink check
test/use_builtin_functions.ink check
test/wrong_argument_count.ink check
test/wrong_multiply.ink check
test/wrong_type_for_function.ink check

View File

@@ -0,0 +1,6 @@
void vs_main()
{
float2 v;
v.x = (2.0f + ((4.0f - 2.0f) * 1.5f)) * 3.0f;
}

View File

@@ -0,0 +1,6 @@
float4 vs_main() : SV_POSITION
{
float4 arr[16];
return arr[0];
}

View File

@@ -0,0 +1,5 @@
void vs_main()
{
float x = 2.0f + 5.0f;
}

View File

@@ -0,0 +1,15 @@
cbuffer properties : register(b0)
{
float4 color;
}
float3 vs_main(float3 pos : POSITION) : SV_POSITION
{
return pos;
}
float4 ps_main() : SV_TARGET
{
return properties.color;
}

View File

@@ -0,0 +1,28 @@
void vs_main()
{
float2 v2 = float2(2.0f, 2.0f);
v2 = float2(2.0f, 2.0f);
v2 = float2(v2, v2);
float3 v3 = float3(2.0f, 2.0f, 2.0f);
v3 = float3(v2, 1.0f);
v3 = float3(1.0f, v2);
v3 = float3(1.0f, 1.0f, 1.0f);
v3 = float3(v3, v3, v3);
float4 v4 = float4(2.0f, 2.0f, 2.0f, 2.0f);
v4 = float4(v4, v4, v4, v4);
v4 = float4(v2, v2);
v4 = float4(v2, 1.0f, 1.0f);
v4 = float4(1.0f, v2, 1.0f);
v4 = float4(1.0f, 1.0f, v2);
v4 = float4(v3, 2.0f);
v4 = float4(2.0f, v3);
v4 = float4(2.0f, 2.0f, 2.0f, 2.0f);
v4 = float4(1.0f, 1.0f, v2);
v4 = float4(2.0f, 2.0f, 2.0f, 2.0f);
v2.x = 2.0f;
v2.y = 2.0f;
float p = v2.x + v3.z;
float q = v4.w + v2.x;
float4x4 m;
}

View File

@@ -0,0 +1,7 @@
void vs_main()
{
float x = 5.0f;
float y = 3000.0f;
float z = (y * y) + x;
}

View File

@@ -0,0 +1,18 @@
cbuffer camera : register(b0)
{
float4x4 projection;
float4x4 view;
}
float4 vs_main(float4 pos : POSITION) : SV_POSITION
{
float4 mv = mul(camera.view, pos);
float4 mvp = mul(camera.projection, mv);
return mvp;
}
float4 ps_main() : SV_TARGET
{
return float4(0.5f, 0.5f, 0.5f, 1.0f);
}

View File

@@ -0,0 +1,17 @@
cbuffer __PROPERTIES : register(b0)
{
float __PROPERTIES__time;
}
float4 vs_main(float3 pos : POSITION) : SV_POSITION
{
return float4(pos.x, pos.y, pos.z, 1.0f);
}
float4 ps_main(float4 pos : SV_POSITION) : SV_TARGET
{
float t = __PROPERTIES__time;
return float4(1, 1, 1, 1);
}

View File

@@ -0,0 +1,2 @@
struct Foo {};

View File

@@ -0,0 +1,4 @@
void vs_main()
{
}

View File

@@ -0,0 +1,5 @@
float3 vs_main(float3 pos : POSITION)
{
return pos;
}

View File

@@ -0,0 +1,7 @@
float4 vs_main(float4 pos : POSITION) : SV_POSITION
{
float x = 5.0f;
x = 7.0f;
return pos;
}

View File

@@ -0,0 +1,12 @@
int foo();
int foo()
{
return 4;
}
void vs_main()
{
foo();
}

View File

@@ -0,0 +1,11 @@
void foo();
void vs_main()
{
foo();
}
void foo()
{
}

View File

@@ -0,0 +1,9 @@
void vs_main()
{
}
float4 ps_main() : SV_TARGET
{
return float4(1, 1, 1, 1);
}

View File

@@ -0,0 +1,13 @@
cbuffer props : register(b0)
{
float4x4 projection;
float4x4 view;
}
float4 vs_main(float4 pos : POSITION) : SV_POSITION
{
float4 mv = mul(props.view, pos);
float4 mvp = mul(props.projection, mv);
return mvp;
}

View File

@@ -0,0 +1,7 @@
void ps_main()
{
float4 alpha_color = float4(1, 0, 0, 1);
float f = 2.0f;
}

View File

@@ -0,0 +1,4 @@
void vs_console_main()
{
}

View File

@@ -0,0 +1,9 @@
void ps_main()
{
}
void vs_skinning_main()
{
float x = 5.0f;
}

View File

@@ -0,0 +1,24 @@
float bar();
float foo();
float bar()
{
return 5.0f;
}
float foo()
{
return bar();
}
float4 vs_main(float3 pos : POSITION) : SV_POSITION
{
float f = 2.0f;
int i = 10;
f = foo();
float2 v2 = float2(2, 2);
float3 v3 = float3(2, 2, 3);
float4 v4 = float4(4, 5, 6, 7);
return float4(1, 1, 1, 1);
}

View File

@@ -0,0 +1,16 @@
cbuffer __PROPERTIES : register(b0)
{
float4 __PROPERTIES__color;
}
float3 vs_main(float3 pos : POSITION, float2 uv : TEXCOORD0) : SV_POSITION
{
return pos;
}
float4 ps_main() : SV_TARGET
{
return __PROPERTIES__color;
}

View File

@@ -0,0 +1,19 @@
int foo();
float bar();
int foo()
{
return 5;
}
float bar()
{
return 1235.0f * 500;
}
void vs_main()
{
int x = foo();
float y = bar();
}

View File

@@ -0,0 +1,19 @@
float4 foo();
float3 vs_main(float3 pos : POSITION) : SV_POSITION
{
return pos;
}
float4 foo()
{
return float4(1.0f, 1.0f, 1.0f, 1.0f);
}
float4 ps_main() : SV_TARGET
{
float4 y = foo();
float4 color = y;
return color;
}

View File

@@ -0,0 +1,18 @@
float4 vs_main(float3 pos : POSITION) : SV_POSITION
{
if (pos.x > 100)
{
if (pos.x > 50)
{
return float4(pos, 1.0f);
}
else
{
return float4(1.0f, 1.0f, 1.0f, 1.0f);
}
return float4(pos, 1.0f);
}
return float4(0.0f, 0.0f, 0.0f, 0.0f);
}

View File

@@ -0,0 +1,93 @@
float4 apply_night(float4 color);
float4 apply_twilight(float4 color);
float4 apply_morning(float4 color);
float4 apply_dawn(float4 color);
cbuffer __PROPERTIES : register(b0)
{
float __PROPERTIES__hour_of_day;
}
Texture2D __PROPERTIES__input_tex : register(t0);
SamplerState __PROPERTIES__tex_sampler : register(s0);
struct VS_Input
{
float3 pos : POSITION;
float2 uv : TEXCOORD0;
};
struct VS_Output
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
VS_Output vs_main(VS_Input input)
{
VS_Output output;
output.pos = float4(input.pos, 1.0f);
output.uv = input.uv;
return output;
}
float4 apply_night(float4 color)
{
float4 result = color;
(result -= float4(0.3f, 0.2f, 0.0f, 0.0f));
(result *= 0.8f);
return result;
}
float4 apply_twilight(float4 color)
{
float4 result = color;
(result += float4(0.2f, -0.1f, 0.1f, 0.0f));
(result *= 0.9f);
return result;
}
float4 apply_morning(float4 color)
{
return (color * 1.3f);
}
float4 apply_dawn(float4 color)
{
return color;
}
float4 ps_main(VS_Output input)
{
float4 sampled_color = __PROPERTIES__input_tex.Sample(__PROPERTIES__tex_sampler, input.uv);
float t = 0.0f;
float4 a = float4(0, 0, 0, 0);
float4 b = float4(0, 0, 0, 0);
if (__PROPERTIES__hour_of_day > 16)
{
t = ((__PROPERTIES__hour_of_day - 16) / 6);
a = apply_twilight(sampled_color);
b = apply_night(sampled_color);
}
else if (__PROPERTIES__hour_of_day > 12)
{
t = ((__PROPERTIES__hour_of_day - 12) / 6);
a = sampled_color;
b = apply_twilight(sampled_color);
}
else if (__PROPERTIES__hour_of_day > 6)
{
t = ((__PROPERTIES__hour_of_day - 6) / 6);
a = apply_morning(sampled_color);
b = sampled_color;
}
else if (__PROPERTIES__hour_of_day >= 0)
{
t = (__PROPERTIES__hour_of_day / 6);
a = apply_night(sampled_color);
b = apply_morning(sampled_color);
}
return lerp(a, b, t);
}

View File

@@ -0,0 +1,19 @@
float foo(Foo f);
struct Foo
{
float some_data;
};
float foo(Foo f)
{
return f.some_data * 2.0f;
}
void vs_main()
{
Foo f;
f.some_data = 4.0f;
float d = foo(f);
}

View File

@@ -0,0 +1,10 @@
float3 vs_main(float3 pos : POSITION) : SV_POSITION
{
return pos;
}
float4 ps_main() : SV_TARGET
{
return float4(1.0f, 1.0f, 1.0f, 1.0f);
}

View File

@@ -0,0 +1,8 @@
void vs_main()
{
float x = 2;
float y = 5;
float z = 10;
float w = x * y + y * z - x / y * x;
}

View File

@@ -0,0 +1,16 @@
cbuffer __PROPERTIES : register(b0)
{
float4 __PROPERTIES__color;
}
float4 vs_main(float4 pos : POSITION) : SV_POSITION
{
return pos;
}
float4 ps_main() : SV_TARGET
{
return __PROPERTIES__color;
}

View File

@@ -0,0 +1,7 @@
void vs_main()
{
float2 a;
float2 b;
float x = (a + b).x;
}

View File

@@ -0,0 +1,17 @@
float4 vs_main(float3 pos : POSITION) : SV_POSITION
{
if (pos.x > 100)
{
return float4(pos, 1.0f);
}
else if (pos.x > 50)
{
return float4(pos, 1.0f);
}
else
{
return float4(1.0f, 1.0f, 1.0f, 1.0f);
}
return float4(0.0f, 0.0f, 0.0f, 0.0f);
}

Some files were not shown because too many files have changed in this diff Show More