vkd3d: Get rid of pipeline variant flags.

These only existed for VRS attachment, which is no longer
necessary with VK_KHR_dynamic_rendering.

Signed-off-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
This commit is contained in:
Philip Rebohle 2021-11-15 17:19:52 +01:00 committed by Hans-Kristian Arntzen
parent 1a68267962
commit 94f82d1085
3 changed files with 28 additions and 121 deletions

View File

@ -4561,16 +4561,6 @@ static void d3d12_command_list_check_vbo_alignment(struct d3d12_command_list *li
}
}
static uint32_t d3d12_command_list_variant_flags(struct d3d12_command_list *list)
{
uint32_t flags = 0;
if (list->vrs_image)
flags |= VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_VRS_ATTACHMENT;
return flags;
}
static bool d3d12_command_list_update_graphics_pipeline(struct d3d12_command_list *list)
{
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
@ -4578,7 +4568,6 @@ static bool d3d12_command_list_update_graphics_pipeline(struct d3d12_command_lis
VkRenderPass vk_render_pass;
uint32_t new_active_flags;
VkPipeline vk_pipeline;
uint32_t variant_flags;
uint32_t i;
if (list->current_pipeline != VK_NULL_HANDLE)
@ -4590,17 +4579,14 @@ static bool d3d12_command_list_update_graphics_pipeline(struct d3d12_command_lis
return false;
}
variant_flags = d3d12_command_list_variant_flags(list);
/* Try to grab the pipeline we compiled ahead of time. If we cannot do so, fall back. */
if (!(vk_pipeline = d3d12_pipeline_state_get_pipeline(list->state,
&list->dynamic_state, list->rtv_nonnull_mask, list->dsv.format,
&render_pass_compat, &new_active_flags,
variant_flags)))
&render_pass_compat, &new_active_flags)))
{
if (!(vk_pipeline = d3d12_pipeline_state_get_or_create_pipeline(list->state,
&list->dynamic_state, list->rtv_nonnull_mask, list->dsv.format,
&render_pass_compat, &new_active_flags, variant_flags)))
&render_pass_compat, &new_active_flags)))
return false;
}

View File

@ -1543,7 +1543,6 @@ static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pa
VkAttachmentReference2KHR attachment_references[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 2];
VkAttachmentDescription2KHR attachments[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 2];
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
VkFragmentShadingRateAttachmentInfoKHR vrs_attachment_info;
struct vkd3d_render_pass_entry *entry;
unsigned int index, attachment_index;
VkSubpassDependency2KHR dependencies[2];
@ -1632,39 +1631,6 @@ static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pa
index++;
}
if (key->flags & VKD3D_RENDER_PASS_KEY_VRS_ATTACHMENT)
{
attachments[attachment_index].sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2_KHR;
attachments[attachment_index].pNext = NULL;
attachments[attachment_index].flags = 0;
attachments[attachment_index].format = VK_FORMAT_R8_UINT;
attachments[attachment_index].samples = 1;
attachments[attachment_index].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
attachments[attachment_index].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
attachments[attachment_index].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
attachments[attachment_index].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
attachments[attachment_index].initialLayout = VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR;
attachments[attachment_index].finalLayout = VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR;
attachment_references[index].sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR;
attachment_references[index].pNext = NULL;
attachment_references[index].attachment = attachment_index;
attachment_references[index].layout = VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR;
attachment_references[index].aspectMask = 0;
vrs_attachment_info.sType = VK_STRUCTURE_TYPE_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR;
vrs_attachment_info.pNext = NULL;
vrs_attachment_info.pFragmentShadingRateAttachment = &attachment_references[index];
vrs_attachment_info.shadingRateAttachmentTexelSize = (VkExtent2D) {
device->d3d12_caps.options6.ShadingRateImageTileSize,
device->d3d12_caps.options6.ShadingRateImageTileSize
};
stages |= VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR;
attachment_index++;
index++;
}
/* HACK: Stage masks should technically not be 0 */
dependencies[0].sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2_KHR;
dependencies[0].pNext = NULL;
@ -1704,10 +1670,6 @@ static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pa
sub_pass_desc.preserveAttachmentCount = 0;
sub_pass_desc.pPreserveAttachments = NULL;
/* Prepend the additional attachment details here. */
if (key->flags & VKD3D_RENDER_PASS_KEY_VRS_ATTACHMENT)
vk_prepend_struct(&sub_pass_desc, &vrs_attachment_info);
pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR;
pass_info.pNext = NULL;
pass_info.flags = 0;
@ -2125,7 +2087,6 @@ static void d3d12_pipeline_state_destroy_graphics(struct d3d12_pipeline_state *s
struct d3d12_graphics_pipeline_state *graphics = &state->graphics;
const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
struct vkd3d_compiled_pipeline *current, *e;
unsigned int i;
d3d12_pipeline_state_destroy_shader_modules(state, device);
@ -2135,8 +2096,7 @@ static void d3d12_pipeline_state_destroy_graphics(struct d3d12_pipeline_state *s
vkd3d_free(current);
}
for (i = 0; i < VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_COUNT; i++)
VK_CALL(vkDestroyPipeline(device->vk_device, graphics->pipeline[i], NULL));
VK_CALL(vkDestroyPipeline(device->vk_device, graphics->pipeline, NULL));
}
static void d3d12_pipeline_state_set_name(struct d3d12_pipeline_state *state, const char *name)
@ -3022,8 +2982,7 @@ static HRESULT d3d12_graphics_pipeline_state_create_render_pass_for_plane_mask(
uint32_t rtv_active_mask, const struct vkd3d_format *dynamic_dsv_format,
uint32_t plane_optimal_mask,
VkRenderPass *vk_render_pass,
uint32_t *out_plane_optimal_mask,
uint32_t variant_flags)
uint32_t *out_plane_optimal_mask)
{
VkFormat dsv_format = VK_FORMAT_UNDEFINED;
struct vkd3d_render_pass_key key;
@ -3111,9 +3070,6 @@ static HRESULT d3d12_graphics_pipeline_state_create_render_pass_for_plane_mask(
key.vk_formats[key.attachment_count++] = dsv_format;
}
if (variant_flags & VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_VRS_ATTACHMENT)
key.flags |= VKD3D_RENDER_PASS_KEY_VRS_ATTACHMENT;
if (key.attachment_count != ARRAY_SIZE(key.vk_formats))
key.vk_formats[ARRAY_SIZE(key.vk_formats) - 1] = VK_FORMAT_UNDEFINED;
for (i = key.attachment_count; i < ARRAY_SIZE(key.vk_formats); ++i)
@ -3135,8 +3091,7 @@ static HRESULT d3d12_graphics_pipeline_state_create_render_pass(
struct d3d12_graphics_pipeline_state *graphics, struct d3d12_device *device,
uint32_t rtv_active_mask, const struct vkd3d_format *dynamic_dsv_format,
struct vkd3d_render_pass_compatibility *render_pass_compat,
uint32_t *out_plane_optimal_mask,
uint32_t variant_flags)
uint32_t *out_plane_optimal_mask)
{
uint32_t plane_optimal_mask;
HRESULT hr;
@ -3147,7 +3102,7 @@ static HRESULT d3d12_graphics_pipeline_state_create_render_pass(
if (FAILED(hr = d3d12_graphics_pipeline_state_create_render_pass_for_plane_mask(
graphics, device, rtv_active_mask, dynamic_dsv_format,
plane_optimal_mask, &render_pass_compat->dsv_layouts[plane_optimal_mask],
plane_optimal_mask == 0 ? out_plane_optimal_mask : NULL, variant_flags)))
plane_optimal_mask == 0 ? out_plane_optimal_mask : NULL)))
{
return hr;
}
@ -3261,15 +3216,6 @@ static uint32_t d3d12_graphics_pipeline_state_init_dynamic_state(struct d3d12_pi
return dynamic_state_flags;
}
static bool d3d12_is_valid_pipeline_variant(struct d3d12_device *device, uint32_t variant_flags)
{
if ((variant_flags & VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_VRS_ATTACHMENT) &&
!device->device_info.fragment_shading_rate_features.attachmentFragmentShadingRate)
return false;
return true;
}
static HRESULT d3d12_pipeline_state_validate_blend_state(struct d3d12_pipeline_state *state,
const struct d3d12_device *device,
const struct d3d12_pipeline_state_desc *desc, const struct vkd3d_shader_signature *sig)
@ -3917,8 +3863,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
desc->primitive_topology_type != D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED;
graphics->pipeline_layout = root_signature->graphics.vk_pipeline_layout;
for (i = 0; i < VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_COUNT; i++)
graphics->pipeline[i] = VK_NULL_HANDLE;
graphics->pipeline = VK_NULL_HANDLE;
state->device = device;
if (supports_extended_dynamic_state)
@ -3934,29 +3879,17 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
}
}
for (i = 0; i < VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_COUNT; i++)
{
if (!d3d12_is_valid_pipeline_variant(device, i))
continue;
if (!(graphics->pipeline[i] = d3d12_pipeline_state_create_pipeline_variant(state, NULL, graphics->dsv_format,
state->vk_pso_cache ? state->vk_pso_cache : device->global_pipeline_cache,
&graphics->render_pass[i], &graphics->dynamic_state_flags, i)))
goto fail;
}
if (!(graphics->pipeline = d3d12_pipeline_state_create_pipeline_variant(state, NULL, graphics->dsv_format,
state->vk_pso_cache ? state->vk_pso_cache : device->global_pipeline_cache,
&graphics->render_pass, &graphics->dynamic_state_flags)))
goto fail;
}
else
{
for (i = 0; i < VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_COUNT; i++)
{
if (!d3d12_is_valid_pipeline_variant(device, i))
continue;
if (FAILED(hr = d3d12_graphics_pipeline_state_create_render_pass(graphics,
device, graphics->rtv_active_mask, NULL,
&graphics->render_pass[i], &graphics->dsv_plane_optimal_mask, i)))
goto fail;
}
if (FAILED(hr = d3d12_graphics_pipeline_state_create_render_pass(graphics,
device, graphics->rtv_active_mask, NULL,
&graphics->render_pass, &graphics->dsv_plane_optimal_mask)))
goto fail;
}
list_init(&graphics->compiled_fallback_pipelines);
@ -4266,7 +4199,7 @@ static bool d3d12_pipeline_state_put_pipeline_to_cache(struct d3d12_pipeline_sta
VkPipeline d3d12_pipeline_state_create_pipeline_variant(struct d3d12_pipeline_state *state,
const struct vkd3d_pipeline_key *key, const struct vkd3d_format *dsv_format, VkPipelineCache vk_cache,
struct vkd3d_render_pass_compatibility *render_pass_compat,
uint32_t *dynamic_state_flags, uint32_t variant_flags)
uint32_t *dynamic_state_flags)
{
VkVertexInputBindingDescription bindings[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
const struct vkd3d_vk_device_procs *vk_procs = &state->device->vk_procs;
@ -4413,7 +4346,7 @@ VkPipeline d3d12_pipeline_state_create_pipeline_variant(struct d3d12_pipeline_st
if (FAILED(hr = d3d12_graphics_pipeline_state_create_render_pass(graphics, device,
rtv_active_mask, dsv_format,
render_pass_compat, &graphics->dsv_plane_optimal_mask, variant_flags)))
render_pass_compat, &graphics->dsv_plane_optimal_mask)))
return VK_NULL_HANDLE;
if (key)
@ -4512,11 +4445,11 @@ VkPipeline d3d12_pipeline_state_get_pipeline(struct d3d12_pipeline_state *state,
const struct vkd3d_dynamic_state *dyn_state,
uint32_t rtv_nonnull_mask, const struct vkd3d_format *dsv_format,
const struct vkd3d_render_pass_compatibility **render_pass_compat,
uint32_t *dynamic_state_flags, uint32_t variant_flags)
uint32_t *dynamic_state_flags)
{
struct d3d12_graphics_pipeline_state *graphics = &state->graphics;
if (!graphics->pipeline[variant_flags])
if (!graphics->pipeline)
return VK_NULL_HANDLE;
/* Unknown DSV format workaround. */
@ -4559,16 +4492,16 @@ VkPipeline d3d12_pipeline_state_get_pipeline(struct d3d12_pipeline_state *state,
return VK_NULL_HANDLE;
}
*render_pass_compat = &state->graphics.render_pass[variant_flags];
*render_pass_compat = &state->graphics.render_pass;
*dynamic_state_flags = state->graphics.dynamic_state_flags;
return state->graphics.pipeline[variant_flags];
return state->graphics.pipeline;
}
VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_state *state,
const struct vkd3d_dynamic_state *dyn_state,
uint32_t rtv_nonnull_mask, const struct vkd3d_format *dsv_format,
const struct vkd3d_render_pass_compatibility **render_pass_compat,
uint32_t *dynamic_state_flags, uint32_t variant_flags)
uint32_t *dynamic_state_flags)
{
const struct vkd3d_vk_device_procs *vk_procs = &state->device->vk_procs;
struct d3d12_graphics_pipeline_state *graphics = &state->graphics;
@ -4621,7 +4554,6 @@ VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_sta
pipeline_key.dsv_format = dsv_format ? dsv_format->vk_format : VK_FORMAT_UNDEFINED;
pipeline_key.rtv_active_mask = state->graphics.rtv_active_mask & rtv_nonnull_mask;
pipeline_key.variant_flags = variant_flags;
if ((vk_pipeline = d3d12_pipeline_state_find_compiled_pipeline(state, &pipeline_key, render_pass_compat,
dynamic_state_flags)))
@ -4633,8 +4565,7 @@ VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_sta
FIXME("Extended dynamic state is supported, but compiling a fallback pipeline late!\n");
vk_pipeline = d3d12_pipeline_state_create_pipeline_variant(state,
&pipeline_key, dsv_format, VK_NULL_HANDLE, &new_render_pass_compat, dynamic_state_flags,
variant_flags);
&pipeline_key, dsv_format, VK_NULL_HANDLE, &new_render_pass_compat, dynamic_state_flags);
if (!vk_pipeline)
{

View File

@ -331,7 +331,6 @@ enum vkd3d_render_pass_key_flag
VKD3D_RENDER_PASS_KEY_STENCIL_ENABLE = (1u << 1),
VKD3D_RENDER_PASS_KEY_DEPTH_WRITE = (1u << 2),
VKD3D_RENDER_PASS_KEY_STENCIL_WRITE = (1u << 3),
VKD3D_RENDER_PASS_KEY_VRS_ATTACHMENT = (1u << 4),
VKD3D_RENDER_PASS_KEY_DEPTH_STENCIL_ENABLE = (VKD3D_RENDER_PASS_KEY_DEPTH_ENABLE | VKD3D_RENDER_PASS_KEY_STENCIL_ENABLE),
VKD3D_RENDER_PASS_KEY_DEPTH_STENCIL_WRITE = (VKD3D_RENDER_PASS_KEY_DEPTH_WRITE | VKD3D_RENDER_PASS_KEY_STENCIL_WRITE),
@ -1482,12 +1481,6 @@ struct vkd3d_shader_debug_ring_spec_info
VkSpecializationInfo spec_info;
};
enum vkd3d_graphics_pipeline_static_variant_flag
{
VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_VRS_ATTACHMENT = (1u << 0),
VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_LAST_BIT = (1u << 1),
};
/* One render pass for each plane optimal mask. */
#define VKD3D_RENDER_PASS_COMPATIBILITY_VARIANT_COUNT 4
struct vkd3d_render_pass_compatibility
@ -1501,8 +1494,6 @@ enum vkd3d_plane_optimal_flag
VKD3D_STENCIL_PLANE_OPTIMAL = (1 << 1),
};
#define VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_COUNT ((uint32_t)VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_LAST_BIT)
struct d3d12_graphics_pipeline_state
{
struct vkd3d_shader_debug_ring_spec_info spec_info[VKD3D_MAX_SHADER_STAGES];
@ -1530,7 +1521,7 @@ struct d3d12_graphics_pipeline_state
const struct vkd3d_format *dsv_format;
VkFormat rtv_formats[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT];
uint32_t dsv_plane_optimal_mask;
struct vkd3d_render_pass_compatibility render_pass[VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_COUNT];
struct vkd3d_render_pass_compatibility render_pass;
D3D12_INDEX_BUFFER_STRIP_CUT_VALUE index_buffer_strip_cut_value;
VkPipelineRasterizationStateCreateInfo rs_desc;
@ -1546,7 +1537,7 @@ struct d3d12_graphics_pipeline_state
uint32_t dynamic_state_flags; /* vkd3d_dynamic_state_flag */
VkPipelineLayout pipeline_layout;
VkPipeline pipeline[VKD3D_GRAPHICS_PIPELINE_STATIC_VARIANT_COUNT];
VkPipeline pipeline;
struct list compiled_fallback_pipelines;
bool xfb_enabled;
@ -1657,7 +1648,6 @@ struct vkd3d_pipeline_key
uint32_t viewport_count;
uint32_t strides[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
uint32_t rtv_active_mask;
uint32_t variant_flags;
VkFormat dsv_format;
bool dynamic_stride;
@ -1672,16 +1662,16 @@ VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_sta
const struct vkd3d_dynamic_state *dyn_state,
uint32_t rtv_nonnull_mask, const struct vkd3d_format *dsv_format,
const struct vkd3d_render_pass_compatibility **render_pass_compat,
uint32_t *dynamic_state_flags, uint32_t variant_flags);
uint32_t *dynamic_state_flags);
VkPipeline d3d12_pipeline_state_get_pipeline(struct d3d12_pipeline_state *state,
const struct vkd3d_dynamic_state *dyn_state,
uint32_t rtv_nonnull_mask, const struct vkd3d_format *dsv_format,
const struct vkd3d_render_pass_compatibility **render_pass_compat,
uint32_t *dynamic_state_flags, uint32_t variant_flags);
uint32_t *dynamic_state_flags);
VkPipeline d3d12_pipeline_state_create_pipeline_variant(struct d3d12_pipeline_state *state,
const struct vkd3d_pipeline_key *key, const struct vkd3d_format *dsv_format, VkPipelineCache vk_cache,
struct vkd3d_render_pass_compatibility *render_pass_compat,
uint32_t *dynamic_state_flags, uint32_t variant_flags);
uint32_t *dynamic_state_flags);
static inline struct d3d12_pipeline_state *impl_from_ID3D12PipelineState(ID3D12PipelineState *iface)
{