#ifndef EMULATOR_SRC_GRAPHICS_HOST_GPU_RENDERER_RENDERTARGET_H_ #define EMULATOR_SRC_GRAPHICS_HOST_GPU_RENDERER_RENDERTARGET_H_ #include "graphics/host_gpu/vulkanCommon.h" #include #include namespace Libs::Graphics { static constexpr uint32_t RENDER_COLOR_ATTACHMENTS_MAX = 8; struct RenderAttachment { vk::ImageView image_view = nullptr; vk::ImageLayout image_layout = vk::ImageLayout::eUndefined; std::array clear_value = {}; bool is_clear = false; bool has_depth = false; bool depth_clear = false; bool has_stencil = false; bool stencil_clear = false; bool operator==(const RenderAttachment&) const = default; }; struct RenderState { std::array color_attachments; RenderAttachment depth_stencil_attachment; uint32_t width = 0; uint32_t height = 0; uint32_t num_layers = 1; uint32_t num_color_attachments = 0; bool operator==(const RenderState&) const = default; }; [[nodiscard]] inline constexpr uint32_t render_sample_count(uint32_t encoded_samples) { return encoded_samples <= 3 ? 1u << encoded_samples : 0; } [[nodiscard]] inline constexpr vk::SampleCountFlagBits vulkan_sample_count(uint32_t samples) { switch (samples) { case 1: return vk::SampleCountFlagBits::e1; case 2: return vk::SampleCountFlagBits::e2; case 4: return vk::SampleCountFlagBits::e4; case 8: return vk::SampleCountFlagBits::e8; default: return {}; } } enum class TargetViewType : uint8_t { Image2D, Image2DArray, Unsupported }; struct TargetViewInfo { TargetViewType type = TargetViewType::Unsupported; uint32_t base_layer = 0; uint32_t layer_count = 0; uint32_t image_layers = 0; }; inline constexpr TargetViewInfo ResolveTargetViewInfo(uint32_t base_layer, uint32_t last_layer, uint32_t draw_layer_offset = 0) { if (base_layer > last_layer || draw_layer_offset != 0) { return {}; } return {base_layer == last_layer ? TargetViewType::Image2D : TargetViewType::Image2DArray, base_layer, last_layer - base_layer + 1u, last_layer + 1u}; } } // namespace Libs::Graphics #endif // EMULATOR_SRC_GRAPHICS_HOST_GPU_RENDERER_RENDERTARGET_H_