Skip to content

Commit

Permalink
Fixing GPU testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorY97 committed Sep 7, 2024
1 parent 757f7a6 commit d924598
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 129 deletions.
1 change: 1 addition & 0 deletions .github/workflows/testing-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ jobs:
continue-on-error: true

- name: Deleting Build folder
if: always()
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: rm -r ${{ steps.strings.outputs.build-output-dir }}
3 changes: 1 addition & 2 deletions SlimeTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ endfunction()

# Create test executables
create_test_executable(ModelTesting Model.cpp)
create_test_executable(CameraTesting Camera.cpp)
create_test_executable(LightTesting Lighting.cpp)
create_test_executable(GPUTesting GPU.cpp)
152 changes: 25 additions & 127 deletions SlimeTests/GPU.cpp
Original file line number Diff line number Diff line change
@@ -1,127 +1,25 @@
// #include <vulkan/vulkan.h>
// #include <spdlog/spdlog.h>
// #include <vector>
// #include <stdexcept>
// #include <iostream>

// struct TestResult {
// std::string testName;
// std::string errorMessage;
// bool passed;
// };

// void logTestResult(const TestResult& result) {
// if (!result.passed) {
// spdlog::error("Test '{}' failed with error: {}", result.testName, result.errorMessage);
// }
// }

// VkInstance createInstance() {
// VkInstance instance;
// VkApplicationInfo appInfo = {};
// appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
// appInfo.pApplicationName = "Vulkan Test";
// appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
// appInfo.pEngineName = "No Engine";
// appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
// appInfo.apiVersion = VK_API_VERSION_1_3; // Target the latest Vulkan version

// VkInstanceCreateInfo createInfo = {};
// createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
// createInfo.pApplicationInfo = &appInfo;

// if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
// throw std::runtime_error("Failed to create Vulkan instance");
// }

// return instance;
// }

// VkPhysicalDevice selectPhysicalDevice(VkInstance instance) {
// VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
// uint32_t deviceCount = 0;
// vkEnumeratePhysicalDevices(instance, &deviceCount, nullptr);

// if (deviceCount == 0) {
// throw std::runtime_error("Failed to find GPUs with Vulkan support");
// }

// std::vector<VkPhysicalDevice> devices(deviceCount);
// vkEnumeratePhysicalDevices(instance, &deviceCount, devices.data());

// for (const auto& device : devices) {
// VkPhysicalDeviceProperties deviceProperties;
// vkGetPhysicalDeviceProperties(device, &deviceProperties);

// if (deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) {
// physicalDevice = device;
// break;
// }
// }

// if (physicalDevice == VK_NULL_HANDLE) {
// throw std::runtime_error("Failed to find a suitable GPU");
// }

// return physicalDevice;
// }

// VkDevice createLogicalDevice(VkPhysicalDevice physicalDevice) {
// VkDevice device;

// uint32_t queueFamilyCount = 0;
// vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, nullptr);

// if (queueFamilyCount == 0) {
// throw std::runtime_error("Failed to find any queue families");
// }

// float queuePriority = 1.0f;
// VkDeviceQueueCreateInfo queueCreateInfo = {};
// queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
// queueCreateInfo.queueFamilyIndex = 0; // Assume the first queue supports graphics
// queueCreateInfo.queueCount = 1;
// queueCreateInfo.pQueuePriorities = &queuePriority;

// VkDeviceCreateInfo createInfo = {};
// createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
// createInfo.queueCreateInfoCount = 1;
// createInfo.pQueueCreateInfos = &queueCreateInfo;

// if (vkCreateDevice(physicalDevice, &createInfo, nullptr, &device) != VK_SUCCESS) {
// throw std::runtime_error("Failed to create logical device");
// }

// return device;
// }

// void runVulkanInitializationTests() {
// TestResult result;

// try {
// result.testName = "Instance Creation";
// VkInstance instance = createInstance();
// result.passed = true;

// result.testName = "Physical Device Selection";
// VkPhysicalDevice physicalDevice = selectPhysicalDevice(instance);
// result.passed = true;

// result.testName = "Logical Device Creation";
// VkDevice device = createLogicalDevice(physicalDevice);
// result.passed = true;

// // Cleanup resources
// vkDestroyDevice(device, nullptr);
// vkDestroyInstance(instance, nullptr);
// } catch (const std::exception& e) {
// result.passed = false;
// result.errorMessage = e.what();
// logTestResult(result);
// }
// }

// int main() {
// runVulkanInitializationTests();
// return 0;
// }
#include "SlimeWindow.h"
#include <spdlog/spdlog.h>
#include <vector>
#include <stdexcept>
#include <iostream>


int main() {
SlimeWindow window = SlimeWindow({ .title = "Slime Odyssey", .width = 1920, .height = 1080, .resizable = true, .decorated = true, .fullscreen = false });

if (window.GetHeight() != 1080)
{
spdlog::error("Failed to set height correctly");
return 1;
}
else if (window.GetWidth() != 1920)
{
spdlog::error("Failed to set width correctly");
return 1;
}
else
{
spdlog::info("Created window successfully");
}
}

0 comments on commit d924598

Please sign in to comment.