Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

game: Update game's GPU test to output the GPU vendor info #3717

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# logs
/log
prof.json
/gpu-test.json

# for CMake
/Testing
Expand Down
13 changes: 13 additions & 0 deletions .vs/launch.vs.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@
"-debug"
]
},
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "gk.exe (bin\\gk.exe)",
"name": "Game - GPU Test",
"args": [
"-v",
"--gpu-test",
"opengl",
"--gpu-test-out-path",
"./gpu-test.json"
]
},
{
"type": "default",
"project": "CMakeLists.txt",
Expand Down
7 changes: 7 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ tasks:
lint:
cmds:
- python ./scripts/ci/lint-trailing-whitespace.py
run-gpu-test:
desc: "Runs the game's built in GPU test"
preconditions:
- sh: test -f {{.GK_BIN_RELEASE_DIR}}/gk{{.EXE_FILE_EXTENSION}}
msg: "Couldn't locate runtime executable in '{{.GK_BIN_RELEASE_DIR}}/gk'"
cmds:
- "{{.GK_BIN_RELEASE_DIR}}/gk -v --gpu-test opengl --gpu-test-out-path ./gpu-test.json"
# TESTS
offline-tests: # ran by jenkins
cmds:
Expand Down
27 changes: 21 additions & 6 deletions game/graphics/gfx_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

#include "game/system/hid/sdl_util.h"

#include "third-party/glad/include/glad/glad.h"

namespace tests {
void to_json(json& j, const GPUTestOutput& obj) {
j = json{
{"success", obj.success},
{"error", obj.error},
{"errorCause", obj.errorCause},
};
json_serialize(success);
json_serialize(error);
json_serialize(errorCause);
json_serialize_optional(gpuRendererString);
json_serialize_optional(gpuVendorString);
}

GPUTestOutput run_gpu_test(const std::string& test_type) {
Expand Down Expand Up @@ -40,7 +42,20 @@ GPUTestOutput run_gpu_test(const std::string& test_type) {
output = {false, "Required OpenGL Version is not supported",
sdl_util::log_and_return_error("SDL initialization failed")};
} else {
output = {true, "", ""};
gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress);
if (!gladLoadGL()) {
output = {false, "Unable to init GLAD", ""};
} else {
output = {true, "", ""};
const auto rendererString = glGetString(GL_RENDERER);
if (rendererString) {
output.gpuRendererString = (const char*)rendererString;
}
const auto vendorString = glGetString(GL_VENDOR);
if (vendorString) {
output.gpuVendorString = (const char*)vendorString;
}
}
SDL_GL_DeleteContext(glContext);
}
SDL_DestroyWindow(window);
Expand Down
2 changes: 2 additions & 0 deletions game/graphics/gfx_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ struct GPUTestOutput {
bool success;
std::string error;
std::string errorCause;
std::optional<std::string> gpuRendererString;
std::optional<std::string> gpuVendorString;
};
void to_json(json& j, const GPUTestOutput& obj);

Expand Down
Loading