Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions runtime/shims/d3d12_vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7589,35 +7589,42 @@ class Device final
return d3d12_trace::result(method, S_OK);
}
case D3D12_FEATURE_D3D12_OPTIONS: {
if (size != sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS)) return d3d12_trace::result(method, E_INVALIDARG);
auto* opts = static_cast<D3D12_FEATURE_DATA_D3D12_OPTIONS*>(data);
*opts = {};
constexpr UINT kConsoleOptionsSize = sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS) + sizeof(UINT);
if (size != sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS) && size != kConsoleOptionsSize)
return d3d12_trace::result(method, E_INVALIDARG);
D3D12_FEATURE_DATA_D3D12_OPTIONS pc_opts{};
// Answer what the layer will actually honour, not what the GPU offers: docs/d3d12_vulkan.md 4.1 says a
// false "supported" is worse than a false "unsupported" at boot, and the PSO paths refuse these same
// features when they are missing (logic ops, per the mapping vkd3d-proton's
// d3d12_device_caps_init_feature_options uses).
opts->DoublePrecisionFloatShaderOps = state_.info.features.shaderFloat64;
opts->OutputMergerLogicOp = state_.info.features.logicOp;
opts->MinPrecisionSupport = D3D12_SHADER_MIN_PRECISION_SUPPORT_NONE;
opts->TiledResourcesTier = D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED;
opts->ResourceBindingTier = D3D12_RESOURCE_BINDING_TIER_3; // Bindless descriptor indexing supported
pc_opts.DoublePrecisionFloatShaderOps = state_.info.features.shaderFloat64;
pc_opts.OutputMergerLogicOp = state_.info.features.logicOp;
pc_opts.MinPrecisionSupport = D3D12_SHADER_MIN_PRECISION_SUPPORT_NONE;
pc_opts.TiledResourcesTier = D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED;
pc_opts.ResourceBindingTier = D3D12_RESOURCE_BINDING_TIER_3; // Bindless descriptor indexing supported
// No VK_EXT_shader_stencil_export is enabled and the translator emits no stencil-ref write, so a pixel
// shader that writes the stencil ref would be refused: answer unsupported, the direction 4.1 prefers.
opts->PSSpecifiedStencilRefSupported = FALSE;
opts->TypedUAVLoadAdditionalFormats = TRUE;
pc_opts.PSSpecifiedStencilRefSupported = FALSE;
pc_opts.TypedUAVLoadAdditionalFormats = TRUE;
// POPS: the translator only declares PixelInterlockOrderedEXT, enabled exactly when the GPU offers
// VK_EXT_fragment_shader_interlock and its fragmentShaderPixelInterlock feature.
opts->ROVsSupported = state_.info.fragment_shader_interlock;
opts->ConservativeRasterizationTier = state_.conservative_raster_tier;
opts->MaxGPUVirtualAddressBitsPerResource = 40;
opts->StandardSwizzle64KBSupported = FALSE;
opts->CrossNodeSharingTier = D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED;
opts->CrossAdapterRowMajorTextureSupported = FALSE;
pc_opts.ROVsSupported = state_.info.fragment_shader_interlock;
pc_opts.ConservativeRasterizationTier = state_.conservative_raster_tier;
pc_opts.MaxGPUVirtualAddressBitsPerResource = 40;
pc_opts.StandardSwizzle64KBSupported = FALSE;
pc_opts.CrossNodeSharingTier = D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED;
pc_opts.CrossAdapterRowMajorTextureSupported = FALSE;
// A translated vertex shader writing a layer or viewport index needs both Vulkan 1.2 features enabled
// (vkCreateShaderModule refuses the module without them, VUID-...-pCode-08740).
opts->VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation =
pc_opts.VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation =
state_.info.shader_output_layer && state_.info.shader_output_viewport_index;
opts->ResourceHeapTier = D3D12_RESOURCE_HEAP_TIER_1;
pc_opts.ResourceHeapTier = D3D12_RESOURCE_HEAP_TIER_1;
std::memcpy(data, &pc_opts, sizeof(pc_opts));
if (size == kConsoleOptionsSize) {
// Console titles query D3D12_FEATURE_D3D12_OPTIONS with a 0x40-byte (16-dword) buffer
// (docs/d3d12_xs_surface.md §7.1): fill the 0x3C-byte PC prefix and zero the trailing 4 bytes.
std::memset(static_cast<std::uint8_t*>(data) + sizeof(pc_opts), 0, sizeof(UINT));
}
return d3d12_trace::result(method, S_OK);
}
case D3D12_FEATURE_D3D12_OPTIONS1: {
Expand Down
6 changes: 6 additions & 0 deletions runtime/test/d3d12_vulkan_device_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5163,6 +5163,12 @@ int main() {
EXPECT(SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options))));
EXPECT(options.ResourceBindingTier == D3D12_RESOURCE_BINDING_TIER_3);
EXPECT(options.MaxGPUVirtualAddressBitsPerResource == 40);
// Console 0x40-byte (16-dword) D3D12_OPTIONS query (docs/d3d12_xs_surface.md §7.1): 0x3C PC prefix + zero tail.
UINT console_opts[16]{};
console_opts[15] = 0xdeadbeefu;
EXPECT(SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, console_opts, sizeof(console_opts))));
EXPECT(std::memcmp(console_opts, &options, sizeof(options)) == 0);
EXPECT(console_opts[15] == 0);

D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT va_support{};
EXPECT(SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT, &va_support, sizeof(va_support))));
Expand Down
Loading