Skip to content

Commit

Permalink
Convert more types
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 21, 2024
1 parent 9e81e1e commit 2558adb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Sources/backends/hlsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ static void write_types(char *hlsl, size_t *offset, shader_stage stage, type_id
size_t input_offsets[64];
input_offsets[0] = 0;

for (size_t input_index = 0; input_index < inputs_count - 1; ++input_index) {
type *t = get_type(inputs[input_index]);
input_offsets[input_index + 1] = input_offsets[input_index] + t->members.size;
if (inputs_count > 0) {
for (size_t input_index = 0; input_index < inputs_count - 1; ++input_index) {
type *t = get_type(inputs[input_index]);
input_offsets[input_index + 1] = input_offsets[input_index] + t->members.size;
}
}

for (size_t i = 0; i < types_size; ++i) {
Expand Down
39 changes: 39 additions & 0 deletions Sources/kong.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ static bool types_compatible(type_id left, type_id right) {
return true;
}

if ((left == uint_id && right == uint2_id) || (left == uint_id && right == uint3_id) || (left == uint_id && right == uint4_id) ||
(left == uint2_id && right == uint_id) || (left == uint3_id && right == uint_id) || (left == uint4_id && right == uint_id)) {
return true;
}

if ((left == uint_id && right == int2_id) || (left == uint_id && right == int3_id) || (left == uint_id && right == int4_id) ||
(left == int2_id && right == uint_id) || (left == int3_id && right == uint_id) || (left == int4_id && right == uint_id)) {
return true;
}

if ((left == int_id && right == uint2_id) || (left == int_id && right == uint3_id) || (left == int_id && right == uint4_id) ||
(left == uint2_id && right == int_id) || (left == uint3_id && right == int_id) || (left == uint4_id && right == int_id)) {
return true;
}

return false;
}

Expand Down Expand Up @@ -276,6 +291,30 @@ static type_ref upgrade_type(type_ref left_type, type_ref right_type) {
return right_type;
}

if ((left == uint2_id && right == uint_id) || (left == uint3_id && right == uint_id) || (left == uint4_id && right == uint_id)) {
return left_type;
}

if ((left == uint_id && right == uint2_id) || (left == uint_id && right == uint3_id) || (left == uint_id && right == uint4_id)) {
return right_type;
}

if ((left == uint2_id && right == int_id) || (left == uint3_id && right == int_id) || (left == uint4_id && right == int_id)) {
return left_type;
}

if ((left == int_id && right == uint2_id) || (left == int_id && right == uint3_id) || (left == int_id && right == uint4_id)) {
return right_type;
}

if ((left == int2_id && right == uint_id) || (left == int3_id && right == uint_id) || (left == int4_id && right == uint_id)) {
return left_type;
}

if ((left == uint_id && right == int2_id) || (left == uint_id && right == int3_id) || (left == uint_id && right == int4_id)) {
return right_type;
}

kong_log(LOG_LEVEL_WARNING, "Suspicious type upgrade");
return left_type;
}
Expand Down

0 comments on commit 2558adb

Please sign in to comment.