Commit d89ff712 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Implement multiple viewports for the Vulkan adapter.

parent 347c8303
...@@ -2255,6 +2255,7 @@ static bool feature_level_9_3_supported(const struct wined3d_physical_device_inf ...@@ -2255,6 +2255,7 @@ static bool feature_level_9_3_supported(const struct wined3d_physical_device_inf
static bool feature_level_10_supported(const struct wined3d_physical_device_info *info, unsigned int shader_model) static bool feature_level_10_supported(const struct wined3d_physical_device_info *info, unsigned int shader_model)
{ {
return shader_model >= 4 return shader_model >= 4
&& info->features2.features.multiViewport
&& info->vertex_divisor_features.vertexAttributeInstanceRateDivisor && info->vertex_divisor_features.vertexAttributeInstanceRateDivisor
&& info->vertex_divisor_features.vertexAttributeInstanceRateZeroDivisor; && info->vertex_divisor_features.vertexAttributeInstanceRateZeroDivisor;
} }
...@@ -2290,6 +2291,7 @@ static enum wined3d_feature_level feature_level_from_caps(const struct wined3d_p ...@@ -2290,6 +2291,7 @@ static enum wined3d_feature_level feature_level_from_caps(const struct wined3d_p
static void wined3d_adapter_vk_init_d3d_info(struct wined3d_adapter_vk *adapter_vk, uint32_t wined3d_creation_flags) static void wined3d_adapter_vk_init_d3d_info(struct wined3d_adapter_vk *adapter_vk, uint32_t wined3d_creation_flags)
{ {
struct wined3d_d3d_info *d3d_info = &adapter_vk->a.d3d_info; struct wined3d_d3d_info *d3d_info = &adapter_vk->a.d3d_info;
struct wined3d_vk_info *vk_info = &adapter_vk->vk_info;
struct wined3d_physical_device_info device_info; struct wined3d_physical_device_info device_info;
struct wined3d_vertex_caps vertex_caps; struct wined3d_vertex_caps vertex_caps;
struct fragment_caps fragment_caps; struct fragment_caps fragment_caps;
...@@ -2356,6 +2358,8 @@ static void wined3d_adapter_vk_init_d3d_info(struct wined3d_adapter_vk *adapter_ ...@@ -2356,6 +2358,8 @@ static void wined3d_adapter_vk_init_d3d_info(struct wined3d_adapter_vk *adapter_
d3d_info->filling_convention_offset = 0.0f; d3d_info->filling_convention_offset = 0.0f;
d3d_info->multisample_draw_location = WINED3D_LOCATION_TEXTURE_RGB; d3d_info->multisample_draw_location = WINED3D_LOCATION_TEXTURE_RGB;
vk_info->multiple_viewports = device_info.features2.features.multiViewport;
} }
static bool wined3d_adapter_vk_init_device_extensions(struct wined3d_adapter_vk *adapter_vk) static bool wined3d_adapter_vk_init_device_extensions(struct wined3d_adapter_vk *adapter_vk)
......
...@@ -1985,10 +1985,9 @@ static int wined3d_graphics_pipeline_vk_compare(const void *key, const struct wi ...@@ -1985,10 +1985,9 @@ static int wined3d_graphics_pipeline_vk_compare(const void *key, const struct wi
if ((ret = wined3d_uint32_compare(a->ts_desc.patchControlPoints, b->ts_desc.patchControlPoints))) if ((ret = wined3d_uint32_compare(a->ts_desc.patchControlPoints, b->ts_desc.patchControlPoints)))
return ret; return ret;
if ((ret = memcmp(&a->viewport, &b->viewport, sizeof(a->viewport)))) if ((ret = memcmp(a->viewports, b->viewports, sizeof(a->viewports))))
return ret; return ret;
if ((ret = memcmp(a->scissors, b->scissors, sizeof(a->scissors))))
if ((ret = memcmp(&a->scissor, &b->scissor, sizeof(a->scissor))))
return ret; return ret;
if ((ret = memcmp(&a->rs_desc, &b->rs_desc, sizeof(a->rs_desc)))) if ((ret = memcmp(&a->rs_desc, &b->rs_desc, sizeof(a->rs_desc))))
...@@ -2066,10 +2065,8 @@ static void wined3d_context_vk_init_graphics_pipeline_key(struct wined3d_context ...@@ -2066,10 +2065,8 @@ static void wined3d_context_vk_init_graphics_pipeline_key(struct wined3d_context
key->ts_desc.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; key->ts_desc.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
key->vp_desc.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; key->vp_desc.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
key->vp_desc.viewportCount = 1; key->vp_desc.pViewports = key->viewports;
key->vp_desc.pViewports = &key->viewport; key->vp_desc.pScissors = key->scissors;
key->vp_desc.scissorCount = 1;
key->vp_desc.pScissors = &key->scissor;
key->rs_desc.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; key->rs_desc.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
key->rs_desc.lineWidth = 1.0f; key->rs_desc.lineWidth = 1.0f;
...@@ -2418,36 +2415,65 @@ static bool wined3d_context_vk_update_graphics_pipeline_key(struct wined3d_conte ...@@ -2418,36 +2415,65 @@ static bool wined3d_context_vk_update_graphics_pipeline_key(struct wined3d_conte
|| wined3d_context_is_graphics_state_dirty(&context_vk->c, STATE_SCISSORRECT) || wined3d_context_is_graphics_state_dirty(&context_vk->c, STATE_SCISSORRECT)
|| wined3d_context_is_graphics_state_dirty(&context_vk->c, STATE_RASTERIZER)) || wined3d_context_is_graphics_state_dirty(&context_vk->c, STATE_RASTERIZER))
{ {
key->viewport.x = state->viewports[0].x; key->vp_desc.viewportCount = (context_vk->vk_info->multiple_viewports ? WINED3D_MAX_VIEWPORTS : 1);
key->viewport.y = state->viewports[0].y; key->vp_desc.scissorCount = key->vp_desc.viewportCount;
key->viewport.width = state->viewports[0].width;
key->viewport.height = state->viewports[0].height;
key->viewport.minDepth = state->viewports[0].min_z;
key->viewport.maxDepth = state->viewports[0].max_z;
if (state->rasterizer_state && state->rasterizer_state->desc.scissor) for (i = 0; i < key->vp_desc.viewportCount; ++i)
{ {
const RECT *r = &state->scissor_rects[0]; const struct wined3d_viewport *src_viewport = &state->viewports[i];
VkViewport *viewport = &key->viewports[i];
VkRect2D *scissor = &key->scissors[i];
key->scissor.offset.x = r->left; if (i >= state->viewport_count)
key->scissor.offset.y = r->top; {
key->scissor.extent.width = r->right - r->left; viewport->x = 0.0f;
key->scissor.extent.height = r->bottom - r->top; viewport->y = 0.0f;
} viewport->width = 1.0f;
else viewport->height = 1.0f;
{ viewport->minDepth = 0.0f;
key->scissor.offset.x = key->viewport.x; viewport->maxDepth = 0.0f;
key->scissor.offset.y = key->viewport.y;
key->scissor.extent.width = key->viewport.width; memset(scissor, 0, sizeof(*scissor));
key->scissor.extent.height = key->viewport.height; continue;
}
viewport->x = src_viewport->x;
viewport->y = src_viewport->y;
viewport->width = src_viewport->width;
viewport->height = src_viewport->height;
viewport->minDepth = src_viewport->min_z;
viewport->maxDepth = src_viewport->max_z;
if (state->rasterizer_state && state->rasterizer_state->desc.scissor)
{
const RECT *r = &state->scissor_rects[i];
if (i >= state->scissor_rect_count)
{
memset(scissor, 0, sizeof(*scissor));
continue;
}
scissor->offset.x = r->left;
scissor->offset.y = r->top;
scissor->extent.width = r->right - r->left;
scissor->extent.height = r->bottom - r->top;
}
else
{
scissor->offset.x = viewport->x;
scissor->offset.y = viewport->y;
scissor->extent.width = viewport->width;
scissor->extent.height = viewport->height;
}
/* Scissor offsets need to be non-negative (VUID-VkPipelineViewportStateCreateInfo-x-02821) */
if (scissor->offset.x < 0)
scissor->offset.x = 0;
if (scissor->offset.y < 0)
scissor->offset.y = 0;
viewport->y += viewport->height;
viewport->height = -viewport->height;
} }
/* Scissor offsets need to be non-negative (VUID-VkPipelineViewportStateCreateInfo-x-02821) */
if (key->scissor.offset.x < 0)
key->scissor.offset.x = 0;
if (key->scissor.offset.y < 0)
key->scissor.offset.y = 0;
key->viewport.y += key->viewport.height;
key->viewport.height = -key->viewport.height;
update = true; update = true;
} }
......
...@@ -2608,8 +2608,8 @@ struct wined3d_graphics_pipeline_key_vk ...@@ -2608,8 +2608,8 @@ struct wined3d_graphics_pipeline_key_vk
VkVertexInputBindingDivisorDescriptionEXT divisors[MAX_ATTRIBS]; VkVertexInputBindingDivisorDescriptionEXT divisors[MAX_ATTRIBS];
VkVertexInputAttributeDescription attributes[MAX_ATTRIBS]; VkVertexInputAttributeDescription attributes[MAX_ATTRIBS];
VkVertexInputBindingDescription bindings[MAX_ATTRIBS]; VkVertexInputBindingDescription bindings[MAX_ATTRIBS];
VkViewport viewport; VkViewport viewports[WINED3D_MAX_VIEWPORTS];
VkRect2D scissor; VkRect2D scissors[WINED3D_MAX_VIEWPORTS];
VkSampleMask sample_mask; VkSampleMask sample_mask;
VkPipelineColorBlendAttachmentState blend_attachments[WINED3D_MAX_RENDER_TARGETS]; VkPipelineColorBlendAttachmentState blend_attachments[WINED3D_MAX_RENDER_TARGETS];
......
...@@ -223,6 +223,8 @@ struct wined3d_vk_info ...@@ -223,6 +223,8 @@ struct wined3d_vk_info
BOOL supported[WINED3D_VK_EXT_COUNT]; BOOL supported[WINED3D_VK_EXT_COUNT];
HMODULE vulkan_lib; HMODULE vulkan_lib;
unsigned int multiple_viewports : 1;
}; };
#define VK_CALL(f) (vk_info->vk_ops.f) #define VK_CALL(f) (vk_info->vk_ops.f)
......
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