Commit b5522869 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Create Vulkan pipeline objects.

parent f4e0ca21
...@@ -398,12 +398,80 @@ static const struct wined3d_allocator_ops wined3d_allocator_vk_ops = ...@@ -398,12 +398,80 @@ static const struct wined3d_allocator_ops wined3d_allocator_vk_ops =
.allocator_destroy_chunk = wined3d_allocator_vk_destroy_chunk, .allocator_destroy_chunk = wined3d_allocator_vk_destroy_chunk,
}; };
static const struct
{
const char *name;
unsigned int core_since_version;
}
vulkan_device_extensions[] =
{
{VK_KHR_MAINTENANCE1_EXTENSION_NAME, VK_API_VERSION_1_1},
{VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_API_VERSION_1_1},
};
static bool enable_vulkan_device_extensions(VkPhysicalDevice physical_device, uint32_t *extension_count,
const char *enabled_extensions[], const struct wined3d_vk_info *vk_info)
{
VkExtensionProperties *extensions = NULL;
bool success = false, found;
unsigned int i, j, count;
VkResult vr;
*extension_count = 0;
if ((vr = VK_CALL(vkEnumerateDeviceExtensionProperties(physical_device, NULL, &count, NULL))) < 0)
{
ERR("Failed to enumerate device extensions, vr %s.\n", wined3d_debug_vkresult(vr));
goto done;
}
if (!(extensions = heap_calloc(count, sizeof(*extensions))))
{
WARN("Out of memory.\n");
goto done;
}
if ((vr = VK_CALL(vkEnumerateDeviceExtensionProperties(physical_device, NULL, &count, extensions))) < 0)
{
ERR("Failed to enumerate device extensions, vr %s.\n", wined3d_debug_vkresult(vr));
goto done;
}
for (i = 0; i < ARRAY_SIZE(vulkan_device_extensions); ++i)
{
if (vulkan_device_extensions[i].core_since_version <= vk_info->api_version)
continue;
for (j = 0, found = false; j < count; ++j)
{
if (!strcmp(extensions[j].extensionName, vulkan_device_extensions[i].name))
{
found = true;
break;
}
}
if (!found)
{
WARN("Required extension '%s' is not available.\n", vulkan_device_extensions[i].name);
goto done;
}
TRACE("Enabling instance extension '%s'.\n", vulkan_device_extensions[i].name);
enabled_extensions[(*extension_count)++] = vulkan_device_extensions[i].name;
}
success = true;
done:
heap_free(extensions);
return success;
}
static HRESULT adapter_vk_create_device(struct wined3d *wined3d, const struct wined3d_adapter *adapter, static HRESULT adapter_vk_create_device(struct wined3d *wined3d, const struct wined3d_adapter *adapter,
enum wined3d_device_type device_type, HWND focus_window, unsigned int flags, BYTE surface_alignment, enum wined3d_device_type device_type, HWND focus_window, unsigned int flags, BYTE surface_alignment,
const enum wined3d_feature_level *levels, unsigned int level_count, const enum wined3d_feature_level *levels, unsigned int level_count,
struct wined3d_device_parent *device_parent, struct wined3d_device **device) struct wined3d_device_parent *device_parent, struct wined3d_device **device)
{ {
const struct wined3d_adapter_vk *adapter_vk = wined3d_adapter_vk_const(adapter); const struct wined3d_adapter_vk *adapter_vk = wined3d_adapter_vk_const(adapter);
const char *enabled_device_extensions[ARRAY_SIZE(vulkan_device_extensions)];
const struct wined3d_vk_info *vk_info = &adapter_vk->vk_info; const struct wined3d_vk_info *vk_info = &adapter_vk->vk_info;
static const float priorities[] = {1.0f}; static const float priorities[] = {1.0f};
struct wined3d_device_vk *device_vk; struct wined3d_device_vk *device_vk;
...@@ -441,8 +509,13 @@ static HRESULT adapter_vk_create_device(struct wined3d *wined3d, const struct wi ...@@ -441,8 +509,13 @@ static HRESULT adapter_vk_create_device(struct wined3d *wined3d, const struct wi
device_info.pQueueCreateInfos = &queue_info; device_info.pQueueCreateInfos = &queue_info;
device_info.enabledLayerCount = 0; device_info.enabledLayerCount = 0;
device_info.ppEnabledLayerNames = NULL; device_info.ppEnabledLayerNames = NULL;
device_info.enabledExtensionCount = 0; device_info.ppEnabledExtensionNames = enabled_device_extensions;
device_info.ppEnabledExtensionNames = NULL; if (!enable_vulkan_device_extensions(physical_device,
&device_info.enabledExtensionCount, enabled_device_extensions, vk_info))
{
hr = E_FAIL;
goto fail;
}
device_info.pEnabledFeatures = &features; device_info.pEnabledFeatures = &features;
if ((vr = VK_CALL(vkCreateDevice(physical_device, &device_info, NULL, &vk_device))) < 0) if ((vr = VK_CALL(vkCreateDevice(physical_device, &device_info, NULL, &vk_device))) < 0)
......
...@@ -2320,6 +2320,34 @@ struct wined3d_pipeline_layout_vk ...@@ -2320,6 +2320,34 @@ struct wined3d_pipeline_layout_vk
VkDescriptorSetLayout vk_set_layout; VkDescriptorSetLayout vk_set_layout;
}; };
struct wined3d_graphics_pipeline_key_vk
{
VkPipelineShaderStageCreateInfo stages[WINED3D_SHADER_TYPE_GRAPHICS_COUNT];
VkVertexInputAttributeDescription attributes[MAX_ATTRIBS];
VkVertexInputBindingDescription bindings[MAX_ATTRIBS];
VkViewport viewport;
VkRect2D scissor;
VkPipelineColorBlendAttachmentState blend_attachments[WINED3D_MAX_RENDER_TARGETS];
VkPipelineVertexInputStateCreateInfo input_desc;
VkPipelineInputAssemblyStateCreateInfo ia_desc;
VkPipelineViewportStateCreateInfo vp_desc;
VkPipelineRasterizationStateCreateInfo rs_desc;
VkPipelineMultisampleStateCreateInfo ms_desc;
VkPipelineDepthStencilStateCreateInfo ds_desc;
VkPipelineColorBlendStateCreateInfo blend_desc;
VkPipelineDynamicStateCreateInfo dynamic_desc;
VkGraphicsPipelineCreateInfo pipeline_desc;
};
struct wined3d_graphics_pipeline_vk
{
struct wine_rb_entry entry;
struct wined3d_graphics_pipeline_key_vk key;
VkPipeline vk_pipeline;
};
enum wined3d_shader_descriptor_type enum wined3d_shader_descriptor_type
{ {
WINED3D_SHADER_DESCRIPTOR_TYPE_CBV, WINED3D_SHADER_DESCRIPTOR_TYPE_CBV,
...@@ -2363,6 +2391,7 @@ struct wined3d_context_vk ...@@ -2363,6 +2391,7 @@ struct wined3d_context_vk
struct struct
{ {
VkShaderModule vk_modules[WINED3D_SHADER_TYPE_GRAPHICS_COUNT]; VkShaderModule vk_modules[WINED3D_SHADER_TYPE_GRAPHICS_COUNT];
struct wined3d_graphics_pipeline_key_vk pipeline_key_vk;
VkPipeline vk_pipeline; VkPipeline vk_pipeline;
VkPipelineLayout vk_pipeline_layout; VkPipelineLayout vk_pipeline_layout;
VkDescriptorSetLayout vk_set_layout; VkDescriptorSetLayout vk_set_layout;
...@@ -2395,10 +2424,12 @@ struct wined3d_context_vk ...@@ -2395,10 +2424,12 @@ struct wined3d_context_vk
VkDescriptorPool vk_descriptor_pool; VkDescriptorPool vk_descriptor_pool;
VkSampleCountFlagBits sample_count; VkSampleCountFlagBits sample_count;
unsigned int rt_count;
struct wined3d_retired_objects_vk retired; struct wined3d_retired_objects_vk retired;
struct wine_rb_tree render_passes; struct wine_rb_tree render_passes;
struct wine_rb_tree pipeline_layouts; struct wine_rb_tree pipeline_layouts;
struct wine_rb_tree graphics_pipelines;
struct wine_rb_tree bo_slab_available; struct wine_rb_tree bo_slab_available;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment