forked from AbleOS/ableos
ignim checkpoint
This commit is contained in:
parent
91380539d9
commit
028949559b
21
sysdata/libraries/ignim/src/application.hb
Normal file
21
sysdata/libraries/ignim/src/application.hb
Normal file
|
@ -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
|
||||||
|
}
|
35
sysdata/libraries/ignim/src/instance.hb
Normal file
35
sysdata/libraries/ignim/src/instance.hb
Normal file
|
@ -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
|
||||||
|
}
|
|
@ -1,3 +1,5 @@
|
||||||
|
application := @use("rel:application.hb")
|
||||||
|
|
||||||
results := @use("rel:results.hb")
|
results := @use("rel:results.hb")
|
||||||
errors := @use("rel:errors.hb")
|
errors := @use("rel:errors.hb")
|
||||||
|
|
||||||
|
@ -6,9 +8,9 @@ extends := @use("rel:extends.hb")
|
||||||
|
|
||||||
rect := @use("rel:rect.hb")
|
rect := @use("rel:rect.hb")
|
||||||
structures := @use("rel:structures.hb")
|
structures := @use("rel:structures.hb")
|
||||||
|
instance := @use("rel:instance.hb")
|
||||||
|
|
||||||
VK_VERSION_MAJOR := 1
|
version := @use("rel:version.hb")
|
||||||
VK_VERSION_MINOR := 0
|
|
||||||
|
|
||||||
init_vulkan := fn(): int {
|
init_vulkan := fn(): int {
|
||||||
return errors.IncompatibleDriver
|
return errors.IncompatibleDriver
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
ApplicationInfo := 0
|
ApplicationInfoType := 0
|
||||||
InstanceCreateInfo := 1
|
InstanceCreateInfoType := 1
|
||||||
DeviceQueueCreateInfo := 2
|
DeviceQueueCreateInfo := 2
|
||||||
DeviceCreateInfo := 3
|
DeviceCreateInfo := 3
|
||||||
SubmitInfo := 4
|
SubmitInfo := 4
|
||||||
|
|
9
sysdata/libraries/ignim/src/version.hb
Normal file
9
sysdata/libraries/ignim/src/version.hb
Normal file
|
@ -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
|
||||||
|
}
|
|
@ -1,21 +1,35 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
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");
|
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
|
||||||
.{create_window} := horizon_api
|
.{create_window} := horizon_api
|
||||||
|
|
||||||
ignim := @use("../../../libraries/ignim/src/lib.hb");
|
ignim := @use("../../../libraries/ignim/src/lib.hb");
|
||||||
.{init_vulkan} := ignim
|
.{errors} := ignim
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
windowing_system_buffer := buffer.create("XHorizon\0")
|
windowing_system_buffer := buffer.create("XHorizon\0")
|
||||||
|
|
||||||
create_window(windowing_system_buffer)
|
|
||||||
// TODO: get WindowID
|
// TODO: get WindowID
|
||||||
|
create_window(windowing_system_buffer)
|
||||||
|
|
||||||
vk_state := init_vulkan()
|
program_name := "Horizon Testing Program\0"
|
||||||
if vk_state == ignim.errors.IncompatibleDriver {
|
program_version := ignim.version.make_version(0, 1, 0)
|
||||||
stn.log.info("Incompatible Vulkan Driver\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
|
return 0
|
||||||
|
|
Loading…
Reference in a new issue