diff --git a/sysdata/libraries/ignim/src/application.hb b/sysdata/libraries/ignim/src/application.hb new file mode 100644 index 00000000..61d42c66 --- /dev/null +++ b/sysdata/libraries/ignim/src/application.hb @@ -0,0 +1,21 @@ +structures := @use("rel:structures.hb") +version := @use("rel:version.hb") + +// Refer to here https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkApplicationInfo.html +ApplicationInfo := struct { + sType: int, + pNext: ^int, + application_name: ^u8, + application_version: int, + engine_name: int, + engine_version: int, + api_version: int, +} + +new_application_info := fn(app_name: ^u8, app_version: int, engine_name: ^u8, engine_version: int, api_version: int): ApplicationInfo { + app_info_type := structures.ApplicationInfoType + + app_info := ApplicationInfo.(app_info_type, 0, app_name, app_version, engine_name, engine_version, api_version) + + return app_info +} \ No newline at end of file diff --git a/sysdata/libraries/ignim/src/instance.hb b/sysdata/libraries/ignim/src/instance.hb new file mode 100644 index 00000000..0841b98e --- /dev/null +++ b/sysdata/libraries/ignim/src/instance.hb @@ -0,0 +1,35 @@ +application := @use("rel:application.hb"); +.{ApplicationInfo} := application + +structures := @use("rel:structures.hb") +errors := @use("rel:errors.hb") + +// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkInstanceCreateInfo.html +InstanceCreateInfo := struct { + sType: int, + pNext: int, + flags: int, + application_info: ^ApplicationInfo, + enabled_layer_count: int, + ppEnabledLayerNames: int, + enabled_extension_count: int, + ppEnabledExtensionNames: int, +} + +new_create_info := fn(application_info: ^ApplicationInfo): InstanceCreateInfo { + create_info_type := structures.InstanceCreateInfoType + enabled_layer_count := 0 + + create_info := InstanceCreateInfo.(create_info_type, 0, 0, application_info, enabled_layer_count, 0, 0, 0) + return create_info +} + +// TODO +Instance := struct {inner: int} +void_instance := fn(): Instance { + return Instance.(0) +} + +create_instance := fn(create_info: ^InstanceCreateInfo, allocator_callback: int, new_obj: ^Instance): int { + return errors.IncompatibleDriver +} \ No newline at end of file diff --git a/sysdata/libraries/ignim/src/lib.hb b/sysdata/libraries/ignim/src/lib.hb index 647f831a..bc9cc123 100644 --- a/sysdata/libraries/ignim/src/lib.hb +++ b/sysdata/libraries/ignim/src/lib.hb @@ -1,3 +1,5 @@ +application := @use("rel:application.hb") + results := @use("rel:results.hb") errors := @use("rel:errors.hb") @@ -6,9 +8,9 @@ extends := @use("rel:extends.hb") rect := @use("rel:rect.hb") structures := @use("rel:structures.hb") +instance := @use("rel:instance.hb") -VK_VERSION_MAJOR := 1 -VK_VERSION_MINOR := 0 +version := @use("rel:version.hb") init_vulkan := fn(): int { return errors.IncompatibleDriver diff --git a/sysdata/libraries/ignim/src/structures.hb b/sysdata/libraries/ignim/src/structures.hb index 71b1847d..d9eb2b27 100644 --- a/sysdata/libraries/ignim/src/structures.hb +++ b/sysdata/libraries/ignim/src/structures.hb @@ -1,5 +1,5 @@ -ApplicationInfo := 0 -InstanceCreateInfo := 1 +ApplicationInfoType := 0 +InstanceCreateInfoType := 1 DeviceQueueCreateInfo := 2 DeviceCreateInfo := 3 SubmitInfo := 4 diff --git a/sysdata/libraries/ignim/src/version.hb b/sysdata/libraries/ignim/src/version.hb new file mode 100644 index 00000000..f8f59983 --- /dev/null +++ b/sysdata/libraries/ignim/src/version.hb @@ -0,0 +1,9 @@ +ApiVersion1_0 := make_api_version(0, 1, 0, 0) + +make_version := fn(major: int, minor: int, patch: int): int { + return major << 22 | minor << 12 | patch +} + +make_api_version := fn(variant: int, major: int, minor: int, patch: int): int { + return variant << 29 | major << 22 | minor << 12 | patch +} \ No newline at end of file diff --git a/sysdata/programs/horizon_testing_program/src/main.hb b/sysdata/programs/horizon_testing_program/src/main.hb index 15ebc3f2..b04a7fcb 100644 --- a/sysdata/programs/horizon_testing_program/src/main.hb +++ b/sysdata/programs/horizon_testing_program/src/main.hb @@ -1,21 +1,35 @@ stn := @use("../../../libraries/stn/src/lib.hb"); -.{string, memory, buffer} := stn +.{string, memory, buffer, log} := stn horizon_api := @use("../../../libraries/horizon_api/src/lib.hb"); .{create_window} := horizon_api ignim := @use("../../../libraries/ignim/src/lib.hb"); -.{init_vulkan} := ignim +.{errors} := ignim main := fn(): int { windowing_system_buffer := buffer.create("XHorizon\0") - create_window(windowing_system_buffer) // TODO: get WindowID + create_window(windowing_system_buffer) - vk_state := init_vulkan() - if vk_state == ignim.errors.IncompatibleDriver { - stn.log.info("Incompatible Vulkan Driver\0") + program_name := "Horizon Testing Program\0" + program_version := ignim.version.make_version(0, 1, 0) + engine_name := "None\0" + engine_version := ignim.version.make_version(0, 0, 0) + api_version := ignim.version.make_api_version(0, 1, 0, 0) + + app_info := ignim.application.new_application_info(program_name, program_version, engine_name, engine_version, api_version) + + create_info := ignim.instance.new_create_info(&app_info) + + instance := ignim.instance.void_instance() + + + // TODO: recursively follow this https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Instance + ret := ignim.instance.create_instance(&create_info, 0, &instance) + if ret == errors.IncompatibleDriver { + log.error("Driver Incompatible with Vulkan\0") } return 0