JD2022-TU1/main/extern/UbiServices/custom/tests/ggp/vulkanTestHelper.h

73 lines
No EOL
2.2 KiB
C++

////////////////////////////////////////////////////////////////////////////////
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Harbour //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "tests/config.h"
#if defined(US_TARGET_GGP)
#include <ggp_c/frame_token_types.h>
#include <vulkan/vulkan.h>
const uint32_t SWAP_CHAIN_IMAGE_COUNT = 2;
typedef struct Buffer {
VkBuffer buffer;
VkDeviceSize size;
VkDeviceSize offset;
} Buffer;
class VulkanTestHelper
{
public:
VulkanTestHelper();
void init();
void uninit();
void updateFrameToken(const GgpFrameToken& frameToken);
void drawFrame();
private:
void initializeVulkan();
void setupEnvironment();
void createSwapchain();
void createBuffers();
void createGraphicsPipeline();
void recordCommands();
void createShaderModule(const char* relative_file_path, VkShaderModule* module);
typedef struct VulkanData {
VkInstance instance;
VkDebugReportCallbackEXT debug_callback;
VkSurfaceKHR surface;
VkDevice device;
VkQueue present_queue, graphics_queue;
int32_t graphics_queue_idx, present_queue_idx;
VkSemaphore image_available_semaphore, render_finished_semaphore;
VkCommandPool command_pool;
VkCommandBuffer command_buffers[SWAP_CHAIN_IMAGE_COUNT];
VkSurfaceCapabilitiesKHR surface_capabilities;
VkSwapchainKHR swapchain;
VkSwapchainCreateInfoKHR swapchain_create_info;
VkImage swapchain_images[SWAP_CHAIN_IMAGE_COUNT];
VkImageView swapchain_image_views[SWAP_CHAIN_IMAGE_COUNT];
VkFramebuffer swapchain_framebuffers[SWAP_CHAIN_IMAGE_COUNT];
VkPipeline graphics_pipeline;
VkPipelineLayout pipeline_layout;
VkRenderPass render_pass;
Buffer vertex_buffer;
VkDeviceMemory buffer_memory;
uint32_t memory_type_index;
GgpFrameToken m_frame_token;
} VulkanData;
VulkanData m_data;
};
#endif // defined(US_TARGET_GGP)