add unit tests

This commit is contained in:
2026-08-01 00:59:18 -07:00
parent 06ade6a4b7
commit fca6bd0945
6 changed files with 191 additions and 27 deletions
+27 -24
View File
@@ -4,43 +4,46 @@ import "core:fmt"
import "core:os"
import sdl "vendor:sdl3"
choose_shader_runtime :: proc(device: ^sdl.GPUDevice) -> (Shader_Runtime, bool) {
supported := sdl.GetGPUShaderFormats(device)
choose_shader_runtime_from_formats :: proc(
supported: sdl.GPUShaderFormat,
) -> (
Shader_Runtime,
bool,
) {
if .MSL in supported {
return {
backend = .Metal_MSL,
format = {.MSL},
shader_dir = "shaders/metal",
entrypoint = "main",
},
true
backend = .Metal_MSL,
format = {.MSL},
shader_dir = "shaders/metal",
entrypoint = "main",
}, true
}
if .DXIL in supported {
return {
backend = .DSD12_DXIL,
format = {.DXIL},
shader_dir = "shaders/d3d12",
entrypoint = "main",
},
true
backend = .DSD12_DXIL,
format = {.DXIL},
shader_dir = "shaders/d3d12",
entrypoint = "main",
}, true
}
if .SPIRV in supported {
return {
backend = .Vulkan_SPIRV,
format = {.SPIRV},
shader_dir = "shaders/vulkan",
entrypoint = "main",
},
true
backend = .Vulkan_SPIRV,
format = {.SPIRV},
shader_dir = "shaders/vulkan",
entrypoint = "main",
}, true
}
fmt.eprintfln("No supported shader format from device {got %v}", supported)
fmt.eprintfln("No supported shader format from device (got %v)", supported)
return {}, false
}
choose_shader_runtime :: proc(device: ^sdl.GPUDevice) -> (Shader_Runtime, bool) {
supported := sdl.GetGPUShaderFormats(device)
return choose_shader_runtime_from_formats(supported)
}
load_shader_blob :: proc(path: string) -> ([]u8, bool) {
data, err := os.read_entire_file(path, context.allocator)
if err != nil {