vkd3d: Handle default global root signature in RTPSO.

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
This commit is contained in:
Hans-Kristian Arntzen 2022-05-06 16:54:24 +02:00
parent 2defbd51e8
commit cc0e34084e
3 changed files with 43 additions and 9 deletions

View File

@ -1073,6 +1073,7 @@ static HRESULT d3d12_state_object_compile_pipeline(struct d3d12_state_object *ob
struct vkd3d_shader_interface_local_info shader_interface_local_info;
VkRayTracingPipelineInterfaceCreateInfoKHR interface_create_info;
VkDescriptorSetLayoutBinding *local_static_sampler_bindings;
struct d3d12_root_signature *default_global_root_signature;
struct vkd3d_shader_interface_info shader_interface_info;
VkRayTracingPipelineCreateInfoKHR pipeline_create_info;
struct vkd3d_shader_resource_binding *local_bindings;
@ -1129,6 +1130,19 @@ static HRESULT d3d12_state_object_compile_pipeline(struct d3d12_state_object *ob
shader_interface_info.descriptor_qa_global_binding = &global_signature->descriptor_qa_global_info;
shader_interface_info.descriptor_qa_heap_binding = &global_signature->descriptor_qa_heap_binding;
#endif
d3d12_root_signature_inc_ref(object->global_root_signature = global_signature);
}
else
{
/* We have to create a dummy root signature in this scenario.
* Add a special entry point for this since otherwise we have to serialize root signatures
* to dummy blobs and stuff which is only defined in d3d12.dll and the outer modules that
* we shouldn't have access to. */
if (FAILED(hr = d3d12_root_signature_create_empty(object->device, &default_global_root_signature)))
return E_OUTOFMEMORY;
global_signature = default_global_root_signature;
d3d12_root_signature_inc_ref(object->global_root_signature = global_signature);
ID3D12RootSignature_Release(&default_global_root_signature->ID3D12RootSignature_iface);
}
shader_interface_local_info.descriptor_size = VKD3D_RESOURCE_DESC_INCREMENT;
@ -1439,13 +1453,6 @@ static HRESULT d3d12_state_object_compile_pipeline(struct d3d12_state_object *ob
(object->flags & D3D12_STATE_OBJECT_FLAG_ALLOW_STATE_OBJECT_ADDITIONS)) ?
VK_PIPELINE_CREATE_LIBRARY_BIT_KHR : 0;
/* FIXME: What if we have no global root signature? */
if (!global_signature)
{
FIXME("No global root signature was found. Is this allowed?\n");
return E_INVALIDARG;
}
/* TODO: What happens here if we have local static samplers with COLLECTIONS? :| */
if (object->local_static_sampler.pipeline_layout)
pipeline_create_info.layout = object->local_static_sampler.pipeline_layout;
@ -1540,8 +1547,6 @@ static HRESULT d3d12_state_object_compile_pipeline(struct d3d12_state_object *ob
data->exports_size = 0;
data->exports_count = 0;
d3d12_root_signature_inc_ref(object->global_root_signature = global_signature);
object->shader_config = *data->shader_config;
object->pipeline_config = data->pipeline_config;

View File

@ -1469,6 +1469,33 @@ fail:
return hr;
}
HRESULT d3d12_root_signature_create_empty(struct d3d12_device *device,
struct d3d12_root_signature **root_signature)
{
struct d3d12_root_signature *object;
D3D12_ROOT_SIGNATURE_DESC1 desc;
HRESULT hr;
if (!(object = vkd3d_malloc(sizeof(*object))))
return E_OUTOFMEMORY;
memset(&desc, 0, sizeof(desc));
hr = d3d12_root_signature_init(object, device, &desc);
/* For pipeline libraries, (and later DXR to some degree), we need a way to
* compare root signature objects. */
object->compatibility_hash = 0;
if (FAILED(hr))
{
vkd3d_free(object);
return hr;
}
*root_signature = object;
return S_OK;
}
HRESULT d3d12_root_signature_create(struct d3d12_device *device,
const void *bytecode, size_t bytecode_length, struct d3d12_root_signature **root_signature)
{

View File

@ -1397,6 +1397,8 @@ struct d3d12_root_signature
HRESULT d3d12_root_signature_create(struct d3d12_device *device, const void *bytecode,
size_t bytecode_length, struct d3d12_root_signature **root_signature);
HRESULT d3d12_root_signature_create_empty(struct d3d12_device *device,
struct d3d12_root_signature **root_signature);
/* Private ref counts, for pipeline library. */
void d3d12_root_signature_inc_ref(struct d3d12_root_signature *state);
void d3d12_root_signature_dec_ref(struct d3d12_root_signature *state);