Kyty/source/emulator/include/Emulator/Graphics/GraphicContext.h

119 lines
3.1 KiB
C
Raw Normal View History

2021-12-01 09:29:27 +00:00
#ifndef EMULATOR_INCLUDE_EMULATOR_GRAPHICS_GRAPHICCONTEXT_H_
#define EMULATOR_INCLUDE_EMULATOR_GRAPHICS_GRAPHICCONTEXT_H_
#include "Kyty/Core/Common.h"
#include "Kyty/Core/Threads.h"
#include "Emulator/Common.h"
#include <vulkan/vulkan_core.h>
#ifdef KYTY_EMU_ENABLED
namespace Kyty::Libs::Graphics {
2022-03-21 09:23:27 +00:00
class CommandBuffer;
2021-12-01 09:29:27 +00:00
struct VulkanSwapchain
{
VkSwapchainKHR swapchain = nullptr;
VkFormat swapchain_format = VK_FORMAT_UNDEFINED;
VkExtent2D swapchain_extent = {};
VkImage* swapchain_images = nullptr;
VkImageView* swapchain_image_views = nullptr;
uint32_t swapchain_images_count = 0;
VkSemaphore present_complete_semaphore = nullptr;
VkFence present_complete_fence = nullptr;
uint32_t current_index = 0;
};
struct VulkanCommandPool
{
Core::Mutex mutex;
VkCommandPool pool = nullptr;
VkCommandBuffer* buffers = nullptr;
VkFence* fences = nullptr;
VkSemaphore* semaphores = nullptr;
bool* busy = nullptr;
uint32_t buffers_count = 0;
};
struct GraphicContext
{
static constexpr int QUEUES_NUM = 11;
static constexpr int QUEUE_GFX = 8;
static constexpr int QUEUE_UTIL = 9;
static constexpr int QUEUE_PRESENT = 10;
static constexpr int QUEUE_COMPUTE_START = 0;
static constexpr int QUEUE_COMPUTE_NUM = 8;
uint32_t screen_width = 0;
uint32_t screen_height = 0;
VkInstance instance = nullptr;
VkDebugUtilsMessengerEXT debug_messenger = nullptr;
VkPhysicalDevice physical_device = nullptr;
VkDevice device = nullptr;
uint32_t queue_family_index = static_cast<uint32_t>(-1);
VkQueue queue[QUEUES_NUM] = {};
};
struct VulkanMemory
{
VkMemoryRequirements requirements = {};
VkMemoryPropertyFlags property = 0;
VkDeviceMemory memory = nullptr;
VkDeviceSize offset = 0;
uint32_t type = 0;
uint64_t unique_id = 0;
};
2022-02-14 01:58:44 +00:00
struct VulkanImage
2021-12-01 09:29:27 +00:00
{
VkFormat format = VK_FORMAT_UNDEFINED;
VkExtent2D extent = {};
VkImage image = nullptr;
VkImageView image_view = nullptr;
2022-02-14 01:58:44 +00:00
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
2021-12-01 09:29:27 +00:00
Graphics::VulkanMemory memory;
};
2022-02-14 01:58:44 +00:00
struct VideoOutVulkanImage: public VulkanImage
2021-12-01 09:29:27 +00:00
{
};
2022-02-14 01:58:44 +00:00
struct DepthStencilVulkanImage: public VulkanImage
{
2022-04-01 05:42:43 +00:00
bool compressed = false;
VkImageView texture_view = nullptr;
2022-02-14 01:58:44 +00:00
};
struct TextureVulkanImage: public VulkanImage
{
};
2022-02-20 10:04:12 +00:00
struct StorageTextureVulkanImage: public VulkanImage
{
};
2022-02-14 01:58:44 +00:00
struct RenderTextureVulkanImage: public VulkanImage
2021-12-01 09:29:27 +00:00
{
};
struct VulkanBuffer
{
VkBuffer buffer = nullptr;
VulkanMemory memory;
VkBufferUsageFlags usage = 0;
};
2022-03-21 09:23:27 +00:00
struct StorageVulkanBuffer: public VulkanBuffer
{
CommandBuffer* cmd_buffer = nullptr;
};
2021-12-01 09:29:27 +00:00
} // namespace Kyty::Libs::Graphics
#endif // KYTY_EMU_ENABLED
#endif /* EMULATOR_INCLUDE_EMULATOR_GRAPHICS_GRAPHICCONTEXT_H_ */