Assign subobjects.

Hans-Kristian Arntzen 2 months ago
parent c9c8bf8ac1
commit 2851910bf5
  1. 8
      include/vkd3d_shader.h
  2. 15
      libs/vkd3d-shader/dxil.c
  3. 136
      libs/vkd3d/raytracing_pipeline.c

@ -814,19 +814,13 @@ struct vkd3d_shader_library_subobject
/* Duped strings because API wants wide strings for no good reason. */
D3D12_HIT_GROUP_DESC hit_group;
D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION association;
struct
{
const void *data;
size_t size;
} payload;
struct
{
const char *subobject;
const char **exports; /* Array of const char * is dynamically allocated. */
size_t num_exports;
} association;
} data;
};

@ -1318,13 +1318,16 @@ void vkd3d_shader_dxil_free_library_entry_points(struct vkd3d_shader_library_ent
void vkd3d_shader_dxil_free_library_subobjects(struct vkd3d_shader_library_subobject *subobjects, size_t count)
{
size_t i;
size_t i, j;
for (i = 0; i < count; i++)
{
if (subobjects[i].kind == VKD3D_SHADER_SUBOBJECT_KIND_SUBOBJECT_TO_EXPORTS_ASSOCIATION)
{
vkd3d_free(subobjects[i].data.association.exports);
for (j = 0; j < subobjects[i].data.association.NumExports; j++)
vkd3d_free((void*)subobjects[i].data.association.pExports[j]);
vkd3d_free((void*)subobjects[i].data.association.pExports);
vkd3d_free((void*)subobjects[i].data.association.SubobjectToAssociate);
}
else if (subobjects[i].kind == VKD3D_SHADER_SUBOBJECT_KIND_HIT_GROUP)
{
@ -1439,11 +1442,11 @@ static void vkd3d_shader_dxil_copy_subobject(unsigned int identifier,
case DXIL_SPV_RDAT_SUBOBJECT_KIND_SUBOBJECT_TO_EXPORTS_ASSOCIATION:
assert(dxil_subobject->num_exports >= 1);
subobject->data.association.subobject = dxil_subobject->exports[0];
subobject->data.association.exports = vkd3d_malloc((dxil_subobject->num_exports - 1) * sizeof(const char *));
subobject->data.association.num_exports = dxil_subobject->num_exports - 1;
subobject->data.association.SubobjectToAssociate = vkd3d_dup_entry_point(dxil_subobject->exports[0]);
subobject->data.association.pExports = vkd3d_malloc((dxil_subobject->num_exports - 1) * sizeof(LPCWSTR));
subobject->data.association.NumExports = dxil_subobject->num_exports - 1;
for (i = 1; i < dxil_subobject->num_exports; i++)
subobject->data.association.exports[i - 1] = dxil_subobject->exports[i];
subobject->data.association.pExports[i - 1] = vkd3d_dup_entry_point(dxil_subobject->exports[i]);
break;
default:

@ -688,9 +688,81 @@ static HRESULT d3d12_state_object_parse_subobject(struct d3d12_state_object *obj
break;
}
case D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION:
{
const D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION *association = obj->pDesc;
unsigned int num_associations = max(association->NumExports, 1);
const struct vkd3d_shader_library_subobject *subobject;
unsigned int root_signature_index = 0;
for (i = 0; i < data->subobjects_count; i++)
{
if (vkd3d_export_strequal_mixed(association->SubobjectToAssociate, data->subobjects[i].name))
break;
if (data->subobjects[i].kind == VKD3D_SHADER_SUBOBJECT_KIND_GLOBAL_ROOT_SIGNATURE ||
data->subobjects[i].kind == VKD3D_SHADER_SUBOBJECT_KIND_LOCAL_ROOT_SIGNATURE)
{
root_signature_index++;
}
}
if (i == data->subobjects_count)
{
ERR("Cannot find subobject %s.\n", debugstr_w(association->SubobjectToAssociate));
return E_INVALIDARG;
}
subobject = &data->subobjects[i];
vkd3d_array_reserve((void **)&data->associations, &data->associations_size,
data->associations_count + num_associations,
sizeof(*data->associations));
for (i = 0; i < num_associations; i++)
{
switch (subobject->kind)
{
case VKD3D_SHADER_SUBOBJECT_KIND_GLOBAL_ROOT_SIGNATURE:
case VKD3D_SHADER_SUBOBJECT_KIND_LOCAL_ROOT_SIGNATURE:
data->associations[data->associations_count].root_signature =
data->subobject_root_signatures[root_signature_index];
break;
case VKD3D_SHADER_SUBOBJECT_KIND_RAYTRACING_PIPELINE_CONFIG1:
data->associations[data->associations_count].pipeline_config = subobject->data.pipeline_config;
break;
case VKD3D_SHADER_SUBOBJECT_KIND_RAYTRACING_SHADER_CONFIG:
data->associations[data->associations_count].shader_config = subobject->data.shader_config;
break;
default:
ERR("Unexpected type %u for DXIL -> object association.\n", subobject->kind);
return E_INVALIDARG;
}
data->associations[data->associations_count].kind = subobject->kind;
data->associations[data->associations_count].export =
association->NumExports ? association->pExports[i] : NULL;
data->associations[data->associations_count].priority =
association_priority == VKD3D_ASSOCIATION_PRIORITY_DECLARED_STATE_OBJECT ?
VKD3D_ASSOCIATION_PRIORITY_EXPLICIT :
VKD3D_ASSOCIATION_PRIORITY_DXIL_SUBOBJECT_ASSIGNMENT;
data->associations_count++;
}
break;
}
case D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION:
{
const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION *association = obj->pDesc;
unsigned int num_associations = max(association->NumExports, 1);
vkd3d_array_reserve((void **)&data->associations, &data->associations_size,
data->associations_count + num_associations,
sizeof(*data->associations));
switch (association->pSubobjectToAssociate->Type)
{
@ -700,32 +772,13 @@ static HRESULT d3d12_state_object_parse_subobject(struct d3d12_state_object *obj
case D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE:
case D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE:
{
if (association->NumExports)
{
vkd3d_array_reserve((void **)&data->associations, &data->associations_size,
data->associations_count + association->NumExports,
sizeof(*data->associations));
for (i = 0; i < association->NumExports; i++)
{
data->associations[data->associations_count].export = association->pExports[i];
d3d12_state_object_set_association_data(&data->associations[data->associations_count],
association->pSubobjectToAssociate);
data->associations[data->associations_count].priority = VKD3D_ASSOCIATION_PRIORITY_EXPLICIT;
data->associations_count++;
}
}
else
for (i = 0; i < num_associations; i++)
{
vkd3d_array_reserve((void **)&data->associations, &data->associations_size,
data->associations_count + 1,
sizeof(*data->associations));
/* Local root signatures being exported to NULL takes priority as the default local RS. */
data->associations[data->associations_count].export = NULL;
data->associations[data->associations_count].export =
association->NumExports ? association->pExports[i] : NULL;
d3d12_state_object_set_association_data(&data->associations[data->associations_count],
association->pSubobjectToAssociate);
data->associations[data->associations_count].priority = VKD3D_ASSOCIATION_PRIORITY_EXPLICIT_DEFAULT;
data->associations[data->associations_count].priority = VKD3D_ASSOCIATION_PRIORITY_EXPLICIT;
data->associations_count++;
}
break;
@ -775,13 +828,18 @@ static HRESULT d3d12_state_object_parse_subobjects(struct d3d12_state_object *ob
if (parent && FAILED(hr = d3d12_state_object_add_collection(parent, data, NULL, 0)))
return hr;
/* First, parse the DXIL libraries so every subobject is parsed. */
/* Make sure all state has been parsed. Ignore DXIL subobject associations for now. We'll have to parse subobjects
* first. */
for (i = 0; i < desc->NumSubobjects; i++)
{
const D3D12_STATE_SUBOBJECT *obj = &desc->pSubobjects[i];
if (obj->Type == D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY)
if (FAILED(hr = d3d12_state_object_parse_subobject(object, obj, data, VKD3D_ASSOCIATION_PRIORITY_DECLARED_STATE_OBJECT)))
if (obj->Type != D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION &&
obj->Type != D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK)
{
if (FAILED(hr = d3d12_state_object_parse_subobject(object, obj, data,
VKD3D_ASSOCIATION_PRIORITY_DECLARED_STATE_OBJECT)))
return hr;
}
}
/* Make sure all child state has been parsed. */
@ -841,6 +899,32 @@ static HRESULT d3d12_state_object_parse_subobjects(struct d3d12_state_object *ob
return hr;
}
for (i = 0; i < desc->NumSubobjects; i++)
{
const D3D12_STATE_SUBOBJECT *obj = &desc->pSubobjects[i];
/* Now we can parse DXIL subobject -> export associations. */
if (obj->Type == D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION)
{
if (FAILED(hr = d3d12_state_object_parse_subobject(object, obj, data,
VKD3D_ASSOCIATION_PRIORITY_DECLARED_STATE_OBJECT)))
return hr;
}
}
/* Finally, parse subobject version of DXIL subobject to export. */
for (i = 0; i < data->subobjects_count; i++)
{
if (data->subobjects[i].kind == VKD3D_SHADER_SUBOBJECT_KIND_SUBOBJECT_TO_EXPORTS_ASSOCIATION)
{
D3D12_STATE_SUBOBJECT obj;
obj.Type = D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION;
obj.pDesc = &data->subobjects[i].data.association;
if (FAILED(hr = d3d12_state_object_parse_subobject(object, &obj, data,
VKD3D_ASSOCIATION_PRIORITY_DXIL_SUBOBJECT)))
return hr;
}
}
return S_OK;
}

Loading…
Cancel
Save