diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index 2449915754..aeb214f48d 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -29,7 +29,7 @@ namespace DXIL { const unsigned kDxilMajor = 1; /* hctdb_instrhelp.get_dxil_version_minor()*/ // VALRULE-TEXT:BEGIN -const unsigned kDxilMinor = 8; +const unsigned kDxilMinor = 9; // VALRULE-TEXT:END inline unsigned MakeDxilVersion(unsigned DxilMajor, unsigned DxilMinor) { diff --git a/include/dxc/DXIL/DxilShaderModel.h b/include/dxc/DXIL/DxilShaderModel.h index 293797ba12..a08f6f0ba4 100644 --- a/include/dxc/DXIL/DxilShaderModel.h +++ b/include/dxc/DXIL/DxilShaderModel.h @@ -35,6 +35,17 @@ class ShaderModel { static const unsigned kHighestMajor = 6; static const unsigned kHighestMinor = 8; // VALRULE-TEXT:END + + // PreRelease shader model versions + // clang-format off + // Python lines need to be not formatted. + /* hctdb_instrhelp.get_prerelease_shader_model()*/ + // clang-format on + // VALRULE-TEXT:BEGIN + static const unsigned kPreReleaseMajor = 6; + static const unsigned kPreReleaseMinor = 9; + // VALRULE-TEXT:END + static const unsigned kOfflineMinor = 0xF; bool IsPS() const { return m_Kind == Kind::Pixel; } @@ -85,6 +96,9 @@ class ShaderModel { static const ShaderModel *Get(Kind Kind, unsigned Major, unsigned Minor); static const ShaderModel *GetByName(llvm::StringRef Name); static const char *GetKindName(Kind kind); + static bool IsPreReleaseShaderModel(int Major, int Minor); + static const ShaderModel *GetPreReleaseShaderModel(llvm::StringRef name); + static const Kind GetKindFromName(llvm::StringRef Name); static DXIL::ShaderKind KindFromFullName(llvm::StringRef Name); static const llvm::StringRef FullNameFromKind(DXIL::ShaderKind sk); static const char *GetNodeLaunchTypeName(DXIL::NodeLaunchType launchTy); @@ -121,7 +135,7 @@ class ShaderModel { bool m_bTypedUavs, unsigned m_UAVRegsLim); /* hctdb_instrhelp.get_num_shader_models()*/ // VALRULE-TEXT:BEGIN - static const unsigned kNumShaderModels = 92; + static const unsigned kNumShaderModels = 101; // VALRULE-TEXT:END static const ShaderModel ms_ShaderModels[kNumShaderModels]; diff --git a/include/dxc/Support/HLSLOptions.td b/include/dxc/Support/HLSLOptions.td index b7bf232070..130e19a525 100644 --- a/include/dxc/Support/HLSLOptions.td +++ b/include/dxc/Support/HLSLOptions.td @@ -430,7 +430,7 @@ def fvk_bind_counter_heap : MultiArg<["-"], "fvk-bind-counter-heap", 2>, MetaVar def target_profile : JoinedOrSeparate<["-", "/"], "T">, Flags<[CoreOption]>, Group, MetaVarName<"">, /* hctdb_instrhelp.get_target_profiles()*/ // VALRULE-TEXT:BEGIN - HelpText<"Set target profile. \n\t: ps_6_0, ps_6_1, ps_6_2, ps_6_3, ps_6_4, ps_6_5, ps_6_6, ps_6_7, ps_6_8, \n\t\t vs_6_0, vs_6_1, vs_6_2, vs_6_3, vs_6_4, vs_6_5, vs_6_6, vs_6_7, vs_6_8, \n\t\t gs_6_0, gs_6_1, gs_6_2, gs_6_3, gs_6_4, gs_6_5, gs_6_6, gs_6_7, gs_6_8, \n\t\t hs_6_0, hs_6_1, hs_6_2, hs_6_3, hs_6_4, hs_6_5, hs_6_6, hs_6_7, hs_6_8, \n\t\t ds_6_0, ds_6_1, ds_6_2, ds_6_3, ds_6_4, ds_6_5, ds_6_6, ds_6_7, ds_6_8, \n\t\t cs_6_0, cs_6_1, cs_6_2, cs_6_3, cs_6_4, cs_6_5, cs_6_6, cs_6_7, cs_6_8, \n\t\t lib_6_1, lib_6_2, lib_6_3, lib_6_4, lib_6_5, lib_6_6, lib_6_7, lib_6_8, \n\t\t ms_6_5, ms_6_6, ms_6_7, ms_6_8, \n\t\t as_6_5, as_6_6, as_6_7, as_6_8, \n\t\t ">; + HelpText<"Set target profile. \n\t: ps_6_0, ps_6_1, ps_6_2, ps_6_3, ps_6_4, ps_6_5, ps_6_6, ps_6_7, ps_6_8, ps_6_9, \n\t\t vs_6_0, vs_6_1, vs_6_2, vs_6_3, vs_6_4, vs_6_5, vs_6_6, vs_6_7, vs_6_8, vs_6_9, \n\t\t gs_6_0, gs_6_1, gs_6_2, gs_6_3, gs_6_4, gs_6_5, gs_6_6, gs_6_7, gs_6_8, gs_6_9, \n\t\t hs_6_0, hs_6_1, hs_6_2, hs_6_3, hs_6_4, hs_6_5, hs_6_6, hs_6_7, hs_6_8, hs_6_9, \n\t\t ds_6_0, ds_6_1, ds_6_2, ds_6_3, ds_6_4, ds_6_5, ds_6_6, ds_6_7, ds_6_8, ds_6_9, \n\t\t cs_6_0, cs_6_1, cs_6_2, cs_6_3, cs_6_4, cs_6_5, cs_6_6, cs_6_7, cs_6_8, cs_6_9, \n\t\t lib_6_1, lib_6_2, lib_6_3, lib_6_4, lib_6_5, lib_6_6, lib_6_7, lib_6_8, lib_6_9, \n\t\t ms_6_5, ms_6_6, ms_6_7, ms_6_8, ms_6_9, \n\t\t as_6_5, as_6_6, as_6_7, as_6_8, as_6_9, \n\t\t ">; // VALRULE-TEXT:END def entrypoint : JoinedOrSeparate<["-", "/"], "E">, Flags<[CoreOption, RewriteOption]>, Group, HelpText<"Entry point name">; diff --git a/lib/DXIL/DxilMetadataHelper.cpp b/lib/DXIL/DxilMetadataHelper.cpp index fdd6d6b946..2cbfd34bc0 100644 --- a/lib/DXIL/DxilMetadataHelper.cpp +++ b/lib/DXIL/DxilMetadataHelper.cpp @@ -284,13 +284,19 @@ void DxilMDHelper::LoadDxilShaderModel(const ShaderModel *&pSM) { "_" + std::to_string(Major) + "_" + (Minor == ShaderModel::kOfflineMinor ? "x" : std::to_string(Minor)); pSM = ShaderModel::GetByName(ShaderModelName.c_str()); - if (!pSM->IsValidForDxil()) { - char ErrorMsgTxt[40]; - StringCchPrintfA(ErrorMsgTxt, _countof(ErrorMsgTxt), - "Unknown shader model '%s'", ShaderModelName.c_str()); - string ErrorMsg(ErrorMsgTxt); - throw hlsl::Exception(DXC_E_INCORRECT_DXIL_METADATA, ErrorMsg); + // check to see if the provided shader model is the pre-release version + if (ShaderModel::IsPreReleaseShaderModel(Major, Minor)) { + pSM = ShaderModel::GetPreReleaseShaderModel(ShaderModelName); + } else { + if (!pSM->IsValidForDxil()) { + char ErrorMsgTxt[40]; + StringCchPrintfA(ErrorMsgTxt, _countof(ErrorMsgTxt), + "Unknown shader model '%s'", ShaderModelName.c_str()); + string ErrorMsg(ErrorMsgTxt); + throw hlsl::Exception(DXC_E_INCORRECT_DXIL_METADATA, ErrorMsg); + } } + SetShaderModel(pSM); } diff --git a/lib/DXIL/DxilShaderModel.cpp b/lib/DXIL/DxilShaderModel.cpp index 22bf5f545b..825b345059 100644 --- a/lib/DXIL/DxilShaderModel.cpp +++ b/lib/DXIL/DxilShaderModel.cpp @@ -64,6 +64,7 @@ bool ShaderModel::IsValidForDxil() const { case 6: case 7: case 8: + case 9: // VALRULE-TEXT:END return true; case kOfflineMinor: @@ -91,85 +92,94 @@ const ShaderModel *ShaderModel::Get(Kind Kind, unsigned Major, unsigned Minor) { {1542, 10}, // ps_6_6 {1543, 11}, // ps_6_7 {1544, 12}, // ps_6_8 - {66560, 13}, // vs_4_0 - {66561, 14}, // vs_4_1 - {66816, 15}, // vs_5_0 - {66817, 16}, // vs_5_1 - {67072, 17}, // vs_6_0 - {67073, 18}, // vs_6_1 - {67074, 19}, // vs_6_2 - {67075, 20}, // vs_6_3 - {67076, 21}, // vs_6_4 - {67077, 22}, // vs_6_5 - {67078, 23}, // vs_6_6 - {67079, 24}, // vs_6_7 - {67080, 25}, // vs_6_8 - {132096, 26}, // gs_4_0 - {132097, 27}, // gs_4_1 - {132352, 28}, // gs_5_0 - {132353, 29}, // gs_5_1 - {132608, 30}, // gs_6_0 - {132609, 31}, // gs_6_1 - {132610, 32}, // gs_6_2 - {132611, 33}, // gs_6_3 - {132612, 34}, // gs_6_4 - {132613, 35}, // gs_6_5 - {132614, 36}, // gs_6_6 - {132615, 37}, // gs_6_7 - {132616, 38}, // gs_6_8 - {197888, 39}, // hs_5_0 - {197889, 40}, // hs_5_1 - {198144, 41}, // hs_6_0 - {198145, 42}, // hs_6_1 - {198146, 43}, // hs_6_2 - {198147, 44}, // hs_6_3 - {198148, 45}, // hs_6_4 - {198149, 46}, // hs_6_5 - {198150, 47}, // hs_6_6 - {198151, 48}, // hs_6_7 - {198152, 49}, // hs_6_8 - {263424, 50}, // ds_5_0 - {263425, 51}, // ds_5_1 - {263680, 52}, // ds_6_0 - {263681, 53}, // ds_6_1 - {263682, 54}, // ds_6_2 - {263683, 55}, // ds_6_3 - {263684, 56}, // ds_6_4 - {263685, 57}, // ds_6_5 - {263686, 58}, // ds_6_6 - {263687, 59}, // ds_6_7 - {263688, 60}, // ds_6_8 - {328704, 61}, // cs_4_0 - {328705, 62}, // cs_4_1 - {328960, 63}, // cs_5_0 - {328961, 64}, // cs_5_1 - {329216, 65}, // cs_6_0 - {329217, 66}, // cs_6_1 - {329218, 67}, // cs_6_2 - {329219, 68}, // cs_6_3 - {329220, 69}, // cs_6_4 - {329221, 70}, // cs_6_5 - {329222, 71}, // cs_6_6 - {329223, 72}, // cs_6_7 - {329224, 73}, // cs_6_8 - {394753, 74}, // lib_6_1 - {394754, 75}, // lib_6_2 - {394755, 76}, // lib_6_3 - {394756, 77}, // lib_6_4 - {394757, 78}, // lib_6_5 - {394758, 79}, // lib_6_6 - {394759, 80}, // lib_6_7 - {394760, 81}, // lib_6_8 + {1545, 13}, // ps_6_9 + {66560, 14}, // vs_4_0 + {66561, 15}, // vs_4_1 + {66816, 16}, // vs_5_0 + {66817, 17}, // vs_5_1 + {67072, 18}, // vs_6_0 + {67073, 19}, // vs_6_1 + {67074, 20}, // vs_6_2 + {67075, 21}, // vs_6_3 + {67076, 22}, // vs_6_4 + {67077, 23}, // vs_6_5 + {67078, 24}, // vs_6_6 + {67079, 25}, // vs_6_7 + {67080, 26}, // vs_6_8 + {67081, 27}, // vs_6_9 + {132096, 28}, // gs_4_0 + {132097, 29}, // gs_4_1 + {132352, 30}, // gs_5_0 + {132353, 31}, // gs_5_1 + {132608, 32}, // gs_6_0 + {132609, 33}, // gs_6_1 + {132610, 34}, // gs_6_2 + {132611, 35}, // gs_6_3 + {132612, 36}, // gs_6_4 + {132613, 37}, // gs_6_5 + {132614, 38}, // gs_6_6 + {132615, 39}, // gs_6_7 + {132616, 40}, // gs_6_8 + {132617, 41}, // gs_6_9 + {197888, 42}, // hs_5_0 + {197889, 43}, // hs_5_1 + {198144, 44}, // hs_6_0 + {198145, 45}, // hs_6_1 + {198146, 46}, // hs_6_2 + {198147, 47}, // hs_6_3 + {198148, 48}, // hs_6_4 + {198149, 49}, // hs_6_5 + {198150, 50}, // hs_6_6 + {198151, 51}, // hs_6_7 + {198152, 52}, // hs_6_8 + {198153, 53}, // hs_6_9 + {263424, 54}, // ds_5_0 + {263425, 55}, // ds_5_1 + {263680, 56}, // ds_6_0 + {263681, 57}, // ds_6_1 + {263682, 58}, // ds_6_2 + {263683, 59}, // ds_6_3 + {263684, 60}, // ds_6_4 + {263685, 61}, // ds_6_5 + {263686, 62}, // ds_6_6 + {263687, 63}, // ds_6_7 + {263688, 64}, // ds_6_8 + {263689, 65}, // ds_6_9 + {328704, 66}, // cs_4_0 + {328705, 67}, // cs_4_1 + {328960, 68}, // cs_5_0 + {328961, 69}, // cs_5_1 + {329216, 70}, // cs_6_0 + {329217, 71}, // cs_6_1 + {329218, 72}, // cs_6_2 + {329219, 73}, // cs_6_3 + {329220, 74}, // cs_6_4 + {329221, 75}, // cs_6_5 + {329222, 76}, // cs_6_6 + {329223, 77}, // cs_6_7 + {329224, 78}, // cs_6_8 + {329225, 79}, // cs_6_9 + {394753, 80}, // lib_6_1 + {394754, 81}, // lib_6_2 + {394755, 82}, // lib_6_3 + {394756, 83}, // lib_6_4 + {394757, 84}, // lib_6_5 + {394758, 85}, // lib_6_6 + {394759, 86}, // lib_6_7 + {394760, 87}, // lib_6_8 + {394761, 88}, // lib_6_9 // lib_6_x is for offline linking only, and relaxes restrictions - {394767, 82}, // lib_6_x - {853509, 83}, // ms_6_5 - {853510, 84}, // ms_6_6 - {853511, 85}, // ms_6_7 - {853512, 86}, // ms_6_8 - {919045, 87}, // as_6_5 - {919046, 88}, // as_6_6 - {919047, 89}, // as_6_7 - {919048, 90}, // as_6_8 + {394767, 89}, // lib_6_x + {853509, 90}, // ms_6_5 + {853510, 91}, // ms_6_6 + {853511, 92}, // ms_6_7 + {853512, 93}, // ms_6_8 + {853513, 94}, // ms_6_9 + {919045, 95}, // as_6_5 + {919046, 96}, // as_6_6 + {919047, 97}, // as_6_7 + {919048, 98}, // as_6_8 + {919049, 99}, // as_6_9 }; unsigned hash = (unsigned)Kind << 16 | Major << 8 | Minor; auto pred = [](const std::pair &elem, unsigned val) { @@ -183,11 +193,17 @@ const ShaderModel *ShaderModel::Get(Kind Kind, unsigned Major, unsigned Minor) { // VALRULE-TEXT:END } -const ShaderModel *ShaderModel::GetByName(llvm::StringRef Name) { - // [ps|vs|gs|hs|ds|cs|ms|as]_[major]_[minor] +bool ShaderModel::IsPreReleaseShaderModel(int major, int minor) { + if (major == kPreReleaseMajor && minor == kPreReleaseMinor) { + return true; + } + return false; +} + +const ShaderModel::Kind ShaderModel::GetKindFromName(llvm::StringRef Name) { Kind kind; if (Name.empty()) { - return GetInvalid(); + return Kind::Invalid; } switch (Name[0]) { @@ -219,8 +235,22 @@ const ShaderModel *ShaderModel::GetByName(llvm::StringRef Name) { kind = Kind::Amplification; break; default: - return GetInvalid(); + return Kind::Invalid; } + return kind; +} + +const ShaderModel *ShaderModel::GetPreReleaseShaderModel(llvm::StringRef name) { + Kind kind = GetKindFromName(name); + return Get(kind, kPreReleaseMajor, kPreReleaseMinor); +} + +const ShaderModel *ShaderModel::GetByName(llvm::StringRef Name) { + // [ps|vs|gs|hs|ds|cs|ms|as]_[major]_[minor] + Kind kind = GetKindFromName(Name); + if (kind == Kind::Invalid) + return GetInvalid(); + unsigned Idx = 3; if (kind != Kind::Library) { if (Name[1] != 's' || Name[2] != '_') @@ -354,8 +384,11 @@ void ShaderModel::GetDxilVersion(unsigned &DxilMajor, case 8: DxilMinor = 8; break; + case 9: + DxilMinor = 9; + break; case kOfflineMinor: // Always update this to highest dxil version - DxilMinor = 8; + DxilMinor = 9; break; // VALRULE-TEXT:END default: @@ -401,6 +434,9 @@ void ShaderModel::GetMinValidatorVersion(unsigned &ValMajor, case 8: ValMinor = 8; break; + case 9: + ValMinor = 9; + break; // VALRULE-TEXT:END case kOfflineMinor: ValMajor = 0; @@ -541,6 +577,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Pixel, 6, 6, "ps_6_6", 32, 8, true, true, UINT_MAX), SM(Kind::Pixel, 6, 7, "ps_6_7", 32, 8, true, true, UINT_MAX), SM(Kind::Pixel, 6, 8, "ps_6_8", 32, 8, true, true, UINT_MAX), + SM(Kind::Pixel, 6, 9, "ps_6_9", 32, 8, true, true, UINT_MAX), SM(Kind::Vertex, 4, 0, "vs_4_0", 16, 16, false, false, 0), SM(Kind::Vertex, 4, 1, "vs_4_1", 32, 32, false, false, 0), SM(Kind::Vertex, 5, 0, "vs_5_0", 32, 32, true, true, 64), @@ -554,6 +591,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Vertex, 6, 6, "vs_6_6", 32, 32, true, true, UINT_MAX), SM(Kind::Vertex, 6, 7, "vs_6_7", 32, 32, true, true, UINT_MAX), SM(Kind::Vertex, 6, 8, "vs_6_8", 32, 32, true, true, UINT_MAX), + SM(Kind::Vertex, 6, 9, "vs_6_9", 32, 32, true, true, UINT_MAX), SM(Kind::Geometry, 4, 0, "gs_4_0", 16, 32, false, false, 0), SM(Kind::Geometry, 4, 1, "gs_4_1", 32, 32, false, false, 0), SM(Kind::Geometry, 5, 0, "gs_5_0", 32, 32, true, true, 64), @@ -567,6 +605,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Geometry, 6, 6, "gs_6_6", 32, 32, true, true, UINT_MAX), SM(Kind::Geometry, 6, 7, "gs_6_7", 32, 32, true, true, UINT_MAX), SM(Kind::Geometry, 6, 8, "gs_6_8", 32, 32, true, true, UINT_MAX), + SM(Kind::Geometry, 6, 9, "gs_6_9", 32, 32, true, true, UINT_MAX), SM(Kind::Hull, 5, 0, "hs_5_0", 32, 32, true, true, 64), SM(Kind::Hull, 5, 1, "hs_5_1", 32, 32, true, true, 64), SM(Kind::Hull, 6, 0, "hs_6_0", 32, 32, true, true, UINT_MAX), @@ -578,6 +617,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Hull, 6, 6, "hs_6_6", 32, 32, true, true, UINT_MAX), SM(Kind::Hull, 6, 7, "hs_6_7", 32, 32, true, true, UINT_MAX), SM(Kind::Hull, 6, 8, "hs_6_8", 32, 32, true, true, UINT_MAX), + SM(Kind::Hull, 6, 9, "hs_6_9", 32, 32, true, true, UINT_MAX), SM(Kind::Domain, 5, 0, "ds_5_0", 32, 32, true, true, 64), SM(Kind::Domain, 5, 1, "ds_5_1", 32, 32, true, true, 64), SM(Kind::Domain, 6, 0, "ds_6_0", 32, 32, true, true, UINT_MAX), @@ -589,6 +629,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Domain, 6, 6, "ds_6_6", 32, 32, true, true, UINT_MAX), SM(Kind::Domain, 6, 7, "ds_6_7", 32, 32, true, true, UINT_MAX), SM(Kind::Domain, 6, 8, "ds_6_8", 32, 32, true, true, UINT_MAX), + SM(Kind::Domain, 6, 9, "ds_6_9", 32, 32, true, true, UINT_MAX), SM(Kind::Compute, 4, 0, "cs_4_0", 0, 0, false, false, 0), SM(Kind::Compute, 4, 1, "cs_4_1", 0, 0, false, false, 0), SM(Kind::Compute, 5, 0, "cs_5_0", 0, 0, true, true, 64), @@ -602,6 +643,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Compute, 6, 6, "cs_6_6", 0, 0, true, true, UINT_MAX), SM(Kind::Compute, 6, 7, "cs_6_7", 0, 0, true, true, UINT_MAX), SM(Kind::Compute, 6, 8, "cs_6_8", 0, 0, true, true, UINT_MAX), + SM(Kind::Compute, 6, 9, "cs_6_9", 0, 0, true, true, UINT_MAX), SM(Kind::Library, 6, 1, "lib_6_1", 32, 32, true, true, UINT_MAX), SM(Kind::Library, 6, 2, "lib_6_2", 32, 32, true, true, UINT_MAX), SM(Kind::Library, 6, 3, "lib_6_3", 32, 32, true, true, UINT_MAX), @@ -610,6 +652,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Library, 6, 6, "lib_6_6", 32, 32, true, true, UINT_MAX), SM(Kind::Library, 6, 7, "lib_6_7", 32, 32, true, true, UINT_MAX), SM(Kind::Library, 6, 8, "lib_6_8", 32, 32, true, true, UINT_MAX), + SM(Kind::Library, 6, 9, "lib_6_9", 32, 32, true, true, UINT_MAX), // lib_6_x is for offline linking only, and relaxes restrictions SM(Kind::Library, 6, kOfflineMinor, "lib_6_x", 32, 32, true, true, UINT_MAX), @@ -617,10 +660,12 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = { SM(Kind::Mesh, 6, 6, "ms_6_6", 0, 0, true, true, UINT_MAX), SM(Kind::Mesh, 6, 7, "ms_6_7", 0, 0, true, true, UINT_MAX), SM(Kind::Mesh, 6, 8, "ms_6_8", 0, 0, true, true, UINT_MAX), + SM(Kind::Mesh, 6, 9, "ms_6_9", 0, 0, true, true, UINT_MAX), SM(Kind::Amplification, 6, 5, "as_6_5", 0, 0, true, true, UINT_MAX), SM(Kind::Amplification, 6, 6, "as_6_6", 0, 0, true, true, UINT_MAX), SM(Kind::Amplification, 6, 7, "as_6_7", 0, 0, true, true, UINT_MAX), SM(Kind::Amplification, 6, 8, "as_6_8", 0, 0, true, true, UINT_MAX), + SM(Kind::Amplification, 6, 9, "as_6_9", 0, 0, true, true, UINT_MAX), // Values before Invalid must remain sorted by Kind, then Major, then Minor. SM(Kind::Invalid, 0, 0, "invalid", 0, 0, false, false, 0), // VALRULE-TEXT:END diff --git a/tools/clang/test/HLSLFileCheck/validation/prerelase-hash.ll b/tools/clang/test/HLSLFileCheck/validation/prerelase-hash.ll new file mode 100644 index 0000000000..f868279bd2 --- /dev/null +++ b/tools/clang/test/HLSLFileCheck/validation/prerelase-hash.ll @@ -0,0 +1,39 @@ +; RUN: %dxilver 1.9 | %dxv %s | FileCheck %s + +; This tests the validator signs the PREVIEW_BYPASS hash, 02020202020202020202020202020202, +; upon seeing that the dxil container contains a shader model that is higher than the latest +; released shader model. + +target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64" +target triple = "dxil-ms-dx" + +define void @node01() { + ret void +} + +!llvm.ident = !{!0} +!dx.version = !{!1} +!dx.valver = !{!1} +!dx.shaderModel = !{!2} +!dx.typeAnnotations = !{!3} +!dx.entryPoints = !{!7, !8} + +!0 = !{!"dxc(private) 1.7.0.4390 (dxil_validation_on_sv_value_node_launch, 6a52940e2258)"} +!1 = !{i32 1, i32 9} +!2 = !{!"lib", i32 6, i32 9} +!3 = !{i32 1, void ()* @node01, !4} +!4 = !{!5} +!5 = !{i32 0, !6, !6} +!6 = !{} +!7 = !{null, !"", null, null, null} +!8 = !{void ()* @node01, !"node01", null, null, !9} +!9 = !{i32 8, i32 15, i32 13, i32 1, i32 23, !10, i32 15, !11, i32 16, i32 -1, i32 22, !12, i32 20, !13, i32 4, !17, i32 5, !18} +!10 = !{i32 16, i32 16, i32 0} +!11 = !{!"node01", i32 0} +!12 = !{i32 32, i32 1, i32 1} +!13 = !{!14} +!14 = !{i32 1, i32 97, i32 2, !15} +!15 = !{i32 0, i32 12, i32 1, !16} +!16 = !{i32 0, i32 5, i32 1} +!17 = !{i32 1, i32 1, i32 1} +!18 = !{i32 0} diff --git a/tools/clang/tools/dxcompiler/dxcassembler.cpp b/tools/clang/tools/dxcompiler/dxcassembler.cpp index 0ff2abe26c..d7972a01df 100644 --- a/tools/clang/tools/dxcompiler/dxcassembler.cpp +++ b/tools/clang/tools/dxcompiler/dxcassembler.cpp @@ -68,7 +68,7 @@ class DxcAssembler : public IDxcAssembler { // Assemble dxil in ll or llvm bitcode to dxbc container. HRESULT STDMETHODCALLTYPE DxcAssembler::AssembleToContainer( IDxcBlob *pShader, // Shader to assemble. - IDxcOperationResult **ppResult // Assemble output status, buffer, and errors + IDxcOperationResult **ppResult // Assemble output status, buffer, and errors) { // inputs used to assemble the container ) { if (pShader == nullptr || ppResult == nullptr) return E_POINTER; @@ -166,6 +166,7 @@ HRESULT STDMETHODCALLTYPE DxcAssembler::AssembleToContainer( flags |= SerializeDxilFlags::IncludeDebugNamePart; flags |= SerializeDxilFlags::DebugNameDependOnSource; } + dxcutil::AssembleInputs inputs(std::move(M), pResultBlob, TM.GetInstalledAllocator(), flags, pOutputStream); diff --git a/tools/clang/tools/dxcvalidator/dxcvalidator.cpp b/tools/clang/tools/dxcvalidator/dxcvalidator.cpp index b8b71ece62..f53a535a39 100644 --- a/tools/clang/tools/dxcvalidator/dxcvalidator.cpp +++ b/tools/clang/tools/dxcvalidator/dxcvalidator.cpp @@ -24,6 +24,8 @@ #include "dxc/Support/FileIOHelper.h" #include "dxc/Support/Global.h" #include "dxc/Support/dxcapi.impl.h" +#include "dxc/DXIL/DxilShaderModel.h" + #ifdef _WIN32 #include "dxcetw.h" @@ -32,7 +34,13 @@ using namespace llvm; using namespace hlsl; -static void HashAndUpdate(DxilContainerHeader *Container) { +static void HashAndUpdate(DxilContainerHeader *Container, bool isPreRelease) { + if (isPreRelease) { + // If preview bypass is enabled, use the preview hash. + UINT previewHash[4] = {0x02020202, 0x02020202, 0x02020202, 0x02020202}; + memcpy(Container->Hash.Digest, previewHash, sizeof(previewHash)); + return; + } // Compute hash and update stored hash. // Hash the container from this offset to the end. static const uint32_t DXBCHashStartOffset = @@ -41,12 +49,30 @@ static void HashAndUpdate(DxilContainerHeader *Container) { (const unsigned char *)Container + DXBCHashStartOffset; unsigned AmountToHash = Container->ContainerSizeInBytes - DXBCHashStartOffset; ComputeHashRetail(DataToHash, AmountToHash, Container->Hash.Digest); + } static void HashAndUpdateOrCopy(uint32_t Flags, IDxcBlob *Shader, - IDxcBlob **Hashed) { + IDxcBlob **Hashed, + llvm::Module *DebugModule) { + bool isPreRelease = false; + const DxilContainerHeader *DxilContainer = + IsDxilContainerLike(Shader->GetBufferPointer(), Shader->GetBufferSize()); + if (!DxilContainer) + return; + + const DxilProgramHeader *ProgramHeader = + GetDxilProgramHeader(DxilContainer, DFCC_DXIL); + + if (ProgramHeader) { + int PV = ProgramHeader->ProgramVersion; + int major = (PV >> 4) & 0xF; // Extract the major version (next 4 bits) + int minor = PV & 0xF; // Extract the minor version (lowest 4 bits) + isPreRelease = ShaderModel::IsPreReleaseShaderModel(major, minor); + } + if (Flags & DxcValidatorFlags_InPlaceEdit) { - HashAndUpdate((DxilContainerHeader *)Shader->GetBufferPointer()); + HashAndUpdate((DxilContainerHeader *)Shader->GetBufferPointer(), isPreRelease); *Hashed = Shader; Shader->AddRef(); } else { @@ -55,7 +81,7 @@ static void HashAndUpdateOrCopy(uint32_t Flags, IDxcBlob *Shader, unsigned long CB; IFT(HashedBlobStream->Write(Shader->GetBufferPointer(), Shader->GetBufferSize(), &CB)); - HashAndUpdate((DxilContainerHeader *)HashedBlobStream->GetPtr()); + HashAndUpdate((DxilContainerHeader *)HashedBlobStream->GetPtr(), isPreRelease); IFT(HashedBlobStream.QueryInterface(Hashed)); } } @@ -233,7 +259,7 @@ uint32_t hlsl::validateWithOptDebugModule( hr = DxcCreateBlobWithEncodingSet(DiagBlob, CP_UTF8, &DiagBlobEnconding); if (FAILED(hr)) throw hlsl::Exception(hr); - HashAndUpdateOrCopy(Flags, Shader, &HashedBlob); + HashAndUpdateOrCopy(Flags, Shader, &HashedBlob, DebugModule); hr = DxcResult::Create( validationStatus, DXC_OUT_OBJECT, {DxcOutputObject::DataOutput(DXC_OUT_OBJECT, HashedBlob), diff --git a/utils/hct/hctdb_instrhelp.py b/utils/hct/hctdb_instrhelp.py index 919610e420..5ed19191ee 100644 --- a/utils/hct/hctdb_instrhelp.py +++ b/utils/hct/hctdb_instrhelp.py @@ -1538,8 +1538,9 @@ def get_interpretation_table(): highest_major = 6 highest_minor = 8 -highest_shader_models = {4: 1, 5: 1, 6: highest_minor} - +prerelease_major = 6 +prerelease_minor = 9 +highest_shader_models = {4: 1, 5: 1, 6: prerelease_minor} def getShaderModels(): shader_models = [] @@ -1558,9 +1559,16 @@ def get_highest_shader_model(): ) return result +def get_prerelease_shader_model(): + result = """static const unsigned kPreReleaseMajor = %d; +static const unsigned kPreReleaseMinor = %d;""" % ( + prerelease_major, + prerelease_minor, + ) + return result def get_dxil_version_minor(): - return "const unsigned kDxilMinor = %d;" % highest_minor + return "const unsigned kDxilMinor = %d;" % prerelease_minor def get_dxil_version_minor_int(): @@ -1778,7 +1786,7 @@ def get_validation_version(): *pMajor = 1; *pMinor = %d; """ - % highest_minor + % prerelease_minor ) return result @@ -1806,7 +1814,7 @@ def get_target_profiles(): def get_min_validator_version(): result = "" - for i in range(0, highest_minor + 1): + for i in range(0, prerelease_minor + 1): result += "case %d:\n" % i result += " ValMinor = %d;\n" % i result += " break;\n" @@ -1815,12 +1823,12 @@ def get_min_validator_version(): def get_dxil_version(): result = "" - for i in range(0, highest_minor + 1): + for i in range(0, prerelease_minor + 1): result += "case %d:\n" % i result += " DxilMinor = %d;\n" % i result += " break;\n" result += "case kOfflineMinor: // Always update this to highest dxil version\n" - result += " DxilMinor = %d;\n" % highest_minor + result += " DxilMinor = %d;\n" % prerelease_minor result += " break;\n" return result @@ -1852,7 +1860,7 @@ def get_shader_model_by_name(): def get_is_valid_for_dxil(): result = "" - for i in range(0, highest_minor + 1): + for i in range(0, prerelease_minor + 1): result += "case %d:\n" % i return result