Skip to content

Commit

Permalink
Define default APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Jun 18, 2024
1 parent c03878c commit 70a66c1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/api.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

typedef enum api_kind { API_UNKNOWN, API_DIRECT3D9, API_DIRECT3D11, API_DIRECT3D12, API_OPENGL, API_METAL, API_WEBGPU, API_VULKAN } api_kind;
typedef enum api_kind { API_DEFAULT, API_DIRECT3D9, API_DIRECT3D11, API_DIRECT3D12, API_OPENGL, API_METAL, API_WEBGPU, API_VULKAN } api_kind;
31 changes: 28 additions & 3 deletions Sources/kong.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ int main(int argc, char **argv) {
char *inputs[256] = {0};
size_t inputs_size = 0;
char *platform = NULL;
api_kind api = API_UNKNOWN;
api_kind api = API_DEFAULT;
char *output = NULL;

for (int i = 1; i < argc; ++i) {
Expand Down Expand Up @@ -497,6 +497,9 @@ int main(int argc, char **argv) {
else if (strcmp(argv[i], "vulkan") == 0) {
api = API_VULKAN;
}
else if (strcmp(argv[i], "default") == 0) {
api = API_DEFAULT;
}
else {
debug_context context = {0};
error(context, "Unknown API %s", argv[i]);
Expand All @@ -508,11 +511,33 @@ int main(int argc, char **argv) {
}

debug_context context = {0};
check(platform != NULL, context, "platform parameter not found");

if (api == API_DEFAULT) {
if (strcmp(platform, "windows") == 0) {
api = API_DIRECT3D12;
}
else if (strcmp(platform, "macos") == 0) {
api = API_METAL;
}
else if (strcmp(platform, "linux") == 0) {
api = API_VULKAN;
}
else if (strcmp(platform, "ios") == 0) {
api = API_METAL;
}
else if (strcmp(platform, "android") == 0) {
api = API_VULKAN;
}
else if (strcmp(platform, "wasm") == 0) {
api = API_WEBGPU;
}
}

check(mode == MODE_MODECHECK, context, "Wrong parameter syntax");
check(inputs_size > 0, context, "no input parameters found");
check(output != NULL, context, "output parameter not found");
check(platform != NULL, context, "platform parameter not found");
check(api != API_UNKNOWN, context, "api parameter not found");
check(api != API_DEFAULT, context, "api parameter not found");

names_init();
types_init();
Expand Down

0 comments on commit 70a66c1

Please sign in to comment.