1 #include <msp/graphics/vulkancontext_platform.h>
3 #include "device_backend.h"
9 VulkanDevice::VulkanDevice(Graphics::Window &wnd, const Graphics::VulkanOptions &opts):
11 device(handle_cast<VkDevice>(context.get_private().device)),
12 graphics_queue(handle_cast<VkQueue>(context.get_private().graphics_queue)),
13 functions(new VulkanFunctions(context)),
14 allocator(*static_cast<Device *>(this)),
15 destroy_queue(*static_cast<Device *>(this)),
16 transfer_queue(*static_cast<Device *>(this)),
17 pipeline_cache(*static_cast<Device *>(this))
20 // Cause the destructor of RefPtr<VulkanFunctions> to be emitted here
21 VulkanDevice::~VulkanDevice()
24 Graphics::VulkanOptions VulkanDevice::create_default_options()
26 Graphics::VulkanOptions opts;
28 opts.enable_validation = true;
29 opts.enable_debug_report = true;
34 void VulkanDevice::fill_info()
36 DeviceInfo &info = static_cast<Device *>(this)->info;
38 VkPhysicalDeviceProperties props;
39 functions->GetPhysicalDeviceProperties(props);
41 info.api_version.major = (props.apiVersion>>22)&0x7F;
42 info.api_version.minor = (props.apiVersion>>12)&0x3FF;
44 DeviceLimits &limits = info.limits;
45 limits.max_clip_planes = props.limits.maxClipDistances;
46 limits.max_vertex_attributes = props.limits.maxVertexInputAttributes;
47 limits.max_texture_bindings = props.limits.maxDescriptorSetSampledImages;
48 limits.max_color_attachments = props.limits.maxColorAttachments;
49 unsigned samples = props.limits.framebufferColorSampleCounts&props.limits.framebufferDepthSampleCounts&props.limits.framebufferStencilSampleCounts;
50 if(samples&VK_SAMPLE_COUNT_64_BIT)
51 limits.max_samples = 64;
52 else if(samples&VK_SAMPLE_COUNT_32_BIT)
53 limits.max_samples = 32;
54 else if(samples&VK_SAMPLE_COUNT_16_BIT)
55 limits.max_samples = 16;
56 else if(samples&VK_SAMPLE_COUNT_8_BIT)
57 limits.max_samples = 8;
58 limits.max_uniform_bindings = props.limits.maxDescriptorSetUniformBuffers;
59 limits.uniform_buffer_alignment = props.limits.minUniformBufferOffsetAlignment;
60 limits.max_anisotropy = props.limits.maxSamplerAnisotropy;
62 info.glsl_features = SL::Features::from_api_version(info.api, info.api_version);