diff --git a/.pick_status.json b/.pick_status.json index 93e66c0b93e..ed546ec1217 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3271,7 +3271,7 @@ "description": "d3d12: Fail screen creation if a shader validator is needed and can't be created", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "2ea15cd661c8355e8e35624eba0bf10cbcd57f61" }, diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp b/src/gallium/drivers/d3d12/d3d12_compiler.cpp index aa73f8269c9..dd17fc80bea 100644 --- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp +++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp @@ -84,7 +84,11 @@ struct d3d12_validation_tools struct d3d12_validation_tools *d3d12_validator_create() { - return new d3d12_validation_tools(); + d3d12_validation_tools *tools = new d3d12_validation_tools(); + if (tools->validator) + return tools; + delete tools; + return nullptr; } void d3d12_validator_destroy(struct d3d12_validation_tools *validator) @@ -192,10 +196,12 @@ compile_nir(struct d3d12_context *ctx, struct d3d12_shader_selector *sel, shader->cb_bindings[shader->num_cb_bindings++].binding = i; } } - ctx->validation_tools->validate_and_sign(&tmp); + if (ctx->validation_tools) { + ctx->validation_tools->validate_and_sign(&tmp); - if (d3d12_debug & D3D12_DEBUG_DISASS) { - ctx->validation_tools->disassemble(&tmp); + if (d3d12_debug & D3D12_DEBUG_DISASS) { + ctx->validation_tools->disassemble(&tmp); + } } blob_finish_get_buffer(&tmp, &shader->bytecode, &shader->bytecode_length); @@ -1255,8 +1261,6 @@ bool d3d12_validation_tools::validate_and_sign(struct blob *dxil) ShaderBlob source(dxil); ComPtr result; - if (!validator) - return false; validator->Validate(&source, DxcValidatorFlags_InPlaceEdit, &result); HRESULT validationStatus; diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp index 944341b0169..90888814840 100644 --- a/src/gallium/drivers/d3d12/d3d12_context.cpp +++ b/src/gallium/drivers/d3d12/d3d12_context.cpp @@ -58,7 +58,8 @@ static void d3d12_context_destroy(struct pipe_context *pctx) { struct d3d12_context *ctx = d3d12_context(pctx); - d3d12_validator_destroy(ctx->validation_tools); + if (ctx->validation_tools) + d3d12_validator_destroy(ctx->validation_tools); if (ctx->timestamp_query) pctx->destroy_query(pctx, ctx->timestamp_query); diff --git a/src/gallium/drivers/d3d12/d3d12_screen.cpp b/src/gallium/drivers/d3d12/d3d12_screen.cpp index ab091af6f54..1bca970d5fa 100644 --- a/src/gallium/drivers/d3d12/d3d12_screen.cpp +++ b/src/gallium/drivers/d3d12/d3d12_screen.cpp @@ -715,11 +715,21 @@ create_device(IUnknown *adapter) } #ifdef _WIN32 - if (d3d12_debug & D3D12_DEBUG_EXPERIMENTAL) + if (!(d3d12_debug & D3D12_DEBUG_EXPERIMENTAL)) { + struct d3d12_validation_tools *validation_tools = d3d12_validator_create(); + if (!validation_tools) { + debug_printf("D3D12: failed to initialize validator with experimental shader models disabled\n"); + return nullptr; + } + d3d12_validator_destroy(validation_tools); + } else #endif { D3D12EnableExperimentalFeatures = (PFN_D3D12ENABLEEXPERIMENTALFEATURES)util_dl_get_proc_address(d3d12_mod, "D3D12EnableExperimentalFeatures"); - D3D12EnableExperimentalFeatures(1, &D3D12ExperimentalShaderModels, NULL, NULL); + if (FAILED(D3D12EnableExperimentalFeatures(1, &D3D12ExperimentalShaderModels, NULL, NULL))) { + debug_printf("D3D12: failed to enable experimental shader models\n"); + return nullptr; + } } D3D12CreateDevice = (PFN_D3D12CREATEDEVICE)util_dl_get_proc_address(d3d12_mod, "D3D12CreateDevice");