vkd3d: Add workaround to allow identifiers to be queried from library.

CP77 relies on this to work somehow ...
The DXR spec seems to suggest this is allowed, but there is no direct
concept for this in Vulkan.

This seems to work on NVIDIA at least, but we're on very shaky ground
here ...

Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
This commit is contained in:
Hans-Kristian Arntzen 2022-05-11 15:34:31 +02:00
parent e6046b3dce
commit 8507a94757
3 changed files with 17 additions and 0 deletions

View File

@ -87,6 +87,7 @@ extern "C" {
#define VKD3D_CONFIG_FLAG_BREADCRUMBS (1ull << 25)
#define VKD3D_CONFIG_FLAG_PIPELINE_LIBRARY_APP_CACHE_ONLY (1ull << 26)
#define VKD3D_CONFIG_FLAG_SHADER_CACHE_SYNC (1ull << 27)
#define VKD3D_CONFIG_FLAG_ALLOW_SBT_COLLECTION (1ull << 28)
typedef HRESULT (*PFN_vkd3d_signal_event)(HANDLE event);

View File

@ -511,6 +511,8 @@ static const struct vkd3d_instance_application_meta application_override[] = {
/* Serious Sam 4 (257420).
* Invariant workarounds cause graphical glitches when rendering foliage on NV. */
{ VKD3D_STRING_COMPARE_EXACT, "Sam4.exe", VKD3D_CONFIG_FLAG_FORCE_NO_INVARIANT_POSITION, 0 },
/* Cyberpunk 2077 (1091500). */
{ VKD3D_STRING_COMPARE_EXACT, "Cyberpunk2077.exe", VKD3D_CONFIG_FLAG_ALLOW_SBT_COLLECTION, 0 },
{ VKD3D_STRING_COMPARE_NEVER, NULL, 0, 0 }
};

View File

@ -2143,6 +2143,20 @@ static HRESULT d3d12_state_object_init(struct d3d12_state_object *object,
object->internal_refcount = 1;
object->device = device;
object->type = desc->Type;
if (object->type == D3D12_STATE_OBJECT_TYPE_COLLECTION &&
(vkd3d_config_flags & VKD3D_CONFIG_FLAG_ALLOW_SBT_COLLECTION))
{
/* It seems to be valid to query shader identifiers from a COLLECTION which is pure insanity.
* We can fake this behavior if we pretend we have ALLOW_STATE_OBJECT_ADDITIONS and RTPSO.
* We will validate that the "COLLECTION" matches the consuming RTPSO.
* If the collection does not contain an RGEN shader, we're technically out of spec here,
* but there is nothing we can do for now without further spec improvements. */
INFO("Promoting COLLECTION to RAYTRACING_PIPELINE as workaround.\n");
object->type = D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE;
object->flags |= D3D12_STATE_OBJECT_FLAG_ALLOW_STATE_OBJECT_ADDITIONS;
}
memset(&data, 0, sizeof(data));
if (FAILED(hr = d3d12_state_object_parse_subobjects(object, desc, parent, &data)))