Skip to content

Commit

Permalink
Support D3D12_2 via WARP
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Nov 19, 2024
1 parent a64d716 commit e31c3ef
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Backends/Graphics5/Direct3D12/Sources/kope/direct3d12/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,29 @@ void kope_d3d12_device_create(kope_g5_device *device, const kope_g5_device_wishl

IDXGIAdapter *adapter;
dxgi_factory->EnumWarpAdapter(IID_PPV_ARGS(&adapter));
kinc_microsoft_affirm(D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_12_1, IID_PPV_ARGS(&device->d3d12.device)));

result = D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_12_2, IID_PPV_ARGS(&device->d3d12.device));
if (result == S_OK) {
kinc_log(KINC_LOG_LEVEL_INFO, "%s", "Direct3D running on feature level 12.2.");
}

if (result != S_OK) {
result = D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_12_1, IID_PPV_ARGS(&device->d3d12.device));
if (result == S_OK) {
kinc_log(KINC_LOG_LEVEL_INFO, "%s", "Direct3D running on feature level 12.1.");
}
}

if (result != S_OK) {
result = D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_12_0, IID_PPV_ARGS(&device->d3d12.device));
if (result == S_OK) {
kinc_log(KINC_LOG_LEVEL_INFO, "%s", "Direct3D running on feature level 12.0.");
}
}
}

assert(result == S_OK);

#if defined(KOPE_NVAPI) && !defined(NDEBUG)
NvAPI_Initialize();
NvAPI_D3D12_EnableRaytracingValidation(device->d3d12.device, NVAPI_D3D12_RAYTRACING_VALIDATION_FLAG_NONE);
Expand Down Expand Up @@ -797,7 +817,7 @@ void kope_d3d12_device_create_raytracing_hierarchy(kope_g5_device *device, kope_
kope_g5_device_create_buffer(device, &scratch_params, &hierarchy->d3d12.scratch_buffer); // TODO: delete later

kope_g5_buffer_parameters update_scratch_params;
update_scratch_params.size = prebuild_info.UpdateScratchDataSizeInBytes;
update_scratch_params.size = prebuild_info.UpdateScratchDataSizeInBytes > 0 ? prebuild_info.UpdateScratchDataSizeInBytes : 1;
update_scratch_params.usage_flags = KOPE_G5_BUFFER_USAGE_READ_WRITE;
kope_g5_device_create_buffer(device, &update_scratch_params, &hierarchy->d3d12.update_scratch_buffer);

Expand Down

0 comments on commit e31c3ef

Please sign in to comment.