mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Merge branch 'master' of https://github.com/odin-lang/Odin
This commit is contained in:
@@ -3,9 +3,10 @@ package sysinfo
|
|||||||
import sys "core:sys/windows"
|
import sys "core:sys/windows"
|
||||||
import "base:intrinsics"
|
import "base:intrinsics"
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
|
import "core:strconv"
|
||||||
import "core:unicode/utf16"
|
import "core:unicode/utf16"
|
||||||
|
|
||||||
import "core:fmt"
|
// import "core:fmt"
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
|
|
||||||
@(private)
|
@(private)
|
||||||
@@ -280,20 +281,56 @@ init_ram :: proc "contextless" () {
|
|||||||
|
|
||||||
@(init, private)
|
@(init, private)
|
||||||
init_gpu_info :: proc "contextless" () {
|
init_gpu_info :: proc "contextless" () {
|
||||||
GPU_INFO_BASE :: "SYSTEM\\ControlSet001\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\"
|
GPU_ROOT_KEY :: `SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}`
|
||||||
|
|
||||||
context = runtime.default_context()
|
context = runtime.default_context()
|
||||||
|
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||||
|
|
||||||
|
gpu_key: sys.HKEY
|
||||||
|
if status := sys.RegOpenKeyExW(
|
||||||
|
sys.HKEY_LOCAL_MACHINE,
|
||||||
|
GPU_ROOT_KEY,
|
||||||
|
0,
|
||||||
|
sys.KEY_ENUMERATE_SUB_KEYS,
|
||||||
|
&gpu_key,
|
||||||
|
); status != i32(sys.ERROR_SUCCESS) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer sys.RegCloseKey(gpu_key)
|
||||||
|
|
||||||
gpu_list: [dynamic]GPU
|
gpu_list: [dynamic]GPU
|
||||||
|
gpu: ^GPU
|
||||||
|
|
||||||
// TODO: Use registry APIs to iterate over entries instead of trying 0000..0009.
|
index := sys.DWORD(0)
|
||||||
for gpu_index in 0..<10 {
|
for {
|
||||||
key := fmt.tprintf("%v\\%04d", GPU_INFO_BASE, gpu_index)
|
defer index += 1
|
||||||
|
|
||||||
|
buf_wstring: [100]u16
|
||||||
|
buf_len := u32(len(buf_wstring))
|
||||||
|
buf_utf8: [4 * len(buf_wstring)]u8
|
||||||
|
|
||||||
|
if status := sys.RegEnumKeyW(
|
||||||
|
gpu_key,
|
||||||
|
index,
|
||||||
|
&buf_wstring[0],
|
||||||
|
&buf_len,
|
||||||
|
); status != i32(sys.ERROR_SUCCESS) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
utf16.decode_to_utf8(buf_utf8[:], buf_wstring[:])
|
||||||
|
leaf := string(cstring(&buf_utf8[0]))
|
||||||
|
|
||||||
|
// Skip leafs that are not of the form 000x
|
||||||
|
if _, is_integer := strconv.parse_int(leaf, 10); !is_integer {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
key := strings.concatenate({GPU_ROOT_KEY, "\\", leaf}, context.temp_allocator)
|
||||||
|
|
||||||
gpu: ^GPU
|
|
||||||
if vendor, ok := read_reg_string(sys.HKEY_LOCAL_MACHINE, key, "ProviderName"); ok {
|
if vendor, ok := read_reg_string(sys.HKEY_LOCAL_MACHINE, key, "ProviderName"); ok {
|
||||||
append(&gpu_list, GPU{vendor_name = vendor})
|
idx := append(&gpu_list, GPU{vendor_name = vendor})
|
||||||
gpu = &gpu_list[len(gpu_list) - 1]
|
gpu = &gpu_list[idx - 1]
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,6 +167,13 @@ foreign advapi32 {
|
|||||||
lpftLastWriteTime: ^FILETIME,
|
lpftLastWriteTime: ^FILETIME,
|
||||||
) -> LSTATUS ---
|
) -> LSTATUS ---
|
||||||
|
|
||||||
|
RegEnumKeyW :: proc(
|
||||||
|
hKey: HKEY,
|
||||||
|
dwIndex: DWORD,
|
||||||
|
lpName: LPWSTR,
|
||||||
|
lpcchName: LPDWORD,
|
||||||
|
) -> LSTATUS ---
|
||||||
|
|
||||||
RegEnumKeyExW :: proc(
|
RegEnumKeyExW :: proc(
|
||||||
hKey: HKEY,
|
hKey: HKEY,
|
||||||
dwIndex: DWORD,
|
dwIndex: DWORD,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ package all
|
|||||||
@(require) import "core:sys/darwin/Foundation"
|
@(require) import "core:sys/darwin/Foundation"
|
||||||
@(require) import "core:sys/darwin/CoreFoundation"
|
@(require) import "core:sys/darwin/CoreFoundation"
|
||||||
@(require) import "core:sys/darwin/Security"
|
@(require) import "core:sys/darwin/Security"
|
||||||
|
@(require) import "vendor:darwin/CoreVideo"
|
||||||
@(require) import "vendor:darwin/Metal"
|
@(require) import "vendor:darwin/Metal"
|
||||||
@(require) import "vendor:darwin/MetalKit"
|
@(require) import "vendor:darwin/MetalKit"
|
||||||
@(require) import "vendor:darwin/QuartzCore"
|
@(require) import "vendor:darwin/QuartzCore"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#+build windows
|
#+build windows
|
||||||
package all
|
package all
|
||||||
|
|
||||||
|
@(require) import "vendor:compress/lz4"
|
||||||
@(require) import "vendor:wgpu/glfwglue"
|
@(require) import "vendor:wgpu/glfwglue"
|
||||||
@(require) import "vendor:wgpu/sdl2glue"
|
@(require) import "vendor:wgpu/sdl2glue"
|
||||||
@(require) import "vendor:wgpu"
|
@(require) import "vendor:wgpu"
|
||||||
|
|||||||
Vendored
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// Bindings for [[ Box2D ; https://box2d.org ]].
|
||||||
package vendor_box2d
|
package vendor_box2d
|
||||||
|
|
||||||
import "base:intrinsics"
|
import "base:intrinsics"
|
||||||
|
|||||||
Vendored
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// Bindings for [[ cgtlf ; https://github.com/jkuhlmann/cgltf ]].
|
||||||
package cgltf
|
package cgltf
|
||||||
|
|
||||||
@(private)
|
@(private)
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Bindings against CMark (https://github.com/commonmark/cmark)
|
Bindings for [[CMark ; https://github.com/commonmark/cmark ]].
|
||||||
|
|
||||||
Original authors: John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer.
|
Original authors: John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer.
|
||||||
See LICENSE for license details.
|
See LICENSE for license details.
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#+build ignore
|
#+build ignore
|
||||||
/*
|
/*
|
||||||
Bindings against CMark (https://github.com/commonmark/cmark)
|
Bindings for [[CMark; https://github.com/commonmark/cmark]].
|
||||||
|
|
||||||
Original authors: John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer.
|
Original authors: John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer.
|
||||||
See LICENSE for license details.
|
See LICENSE for license details.
|
||||||
|
|||||||
Vendored
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// Bindings for [[LZ4 ; https://github.com/lz4/lz4]].
|
||||||
package vendor_compress_lz4
|
package vendor_compress_lz4
|
||||||
|
|
||||||
when ODIN_OS == .Windows {
|
when ODIN_OS == .Windows {
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// Bindings for [[ CoreVideo ; https://developer.apple.com/documentation/corevideo ]].
|
||||||
package CoreVideo
|
package CoreVideo
|
||||||
|
|
||||||
DisplayLinkRef :: distinct rawptr
|
DisplayLinkRef :: distinct rawptr
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// Bindings for [[ Metal ; https://developer.apple.com/documentation/metal ]].
|
||||||
package objc_Metal
|
package objc_Metal
|
||||||
|
|
||||||
import NS "core:sys/darwin/Foundation"
|
import NS "core:sys/darwin/Foundation"
|
||||||
|
|||||||
Vendored
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// Bindings for [[ MetalKit ; https://developer.apple.com/documentation/metalkit ]].
|
||||||
package objc_MetalKit
|
package objc_MetalKit
|
||||||
|
|
||||||
import NS "core:sys/darwin/Foundation"
|
import NS "core:sys/darwin/Foundation"
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// Bindings for [[ QuartzCore ; https://developer.apple.com/documentation/quartzcore ]].
|
||||||
package objc_QuartzCore
|
package objc_QuartzCore
|
||||||
|
|
||||||
import NS "core:sys/darwin/Foundation"
|
import NS "core:sys/darwin/Foundation"
|
||||||
|
|||||||
Reference in New Issue
Block a user