- switch to binary search for ShaderModel::Get
This commit is contained in:
Tex Riddell 2018-11-27 23:30:12 -08:00
Родитель d91935d19d
Коммит 51db8e386d
5 изменённых файлов: 82 добавлений и 48 удалений

Просмотреть файл

@ -27,7 +27,7 @@ import hctdb_instrhelp
namespace DXIL {
// DXIL version.
const unsigned kDxilMajor = 1;
const unsigned kDxilMinor = 4;
const unsigned kDxilMinor = 5;
inline unsigned MakeDxilVersion(unsigned DxilMajor, unsigned DxilMinor) {
return 0 | (DxilMajor << 8) | (DxilMinor);

Просмотреть файл

@ -29,7 +29,7 @@ public:
// Major/Minor version of highest shader model
static const unsigned kHighestMajor = 6;
static const unsigned kHighestMinor = 4;
static const unsigned kHighestMinor = 5;
static const unsigned kOfflineMinor = 0xF;
bool IsPS() const { return m_Kind == Kind::Pixel; }
@ -58,6 +58,8 @@ public:
bool IsSM61Plus() const { return IsSMAtLeast(6, 1); }
bool IsSM62Plus() const { return IsSMAtLeast(6, 2); }
bool IsSM63Plus() const { return IsSMAtLeast(6, 3); }
bool IsSM64Plus() const { return IsSMAtLeast(6, 4); }
bool IsSM65Plus() const { return IsSMAtLeast(6, 5); }
const char *GetName() const { return m_pszName; }
const char *GetKindName() const;
unsigned GetNumTempRegs() const { return DXIL::kMaxTempRegCount; }
@ -94,7 +96,7 @@ private:
unsigned m_NumInputRegs, unsigned m_NumOutputRegs,
bool m_bUAVs, bool m_bTypedUavs, unsigned m_UAVRegsLim);
static const unsigned kNumShaderModels = 56;
static const unsigned kNumShaderModels = 63;
static const ShaderModel ms_ShaderModels[kNumShaderModels];
static const ShaderModel *GetInvalid();

Просмотреть файл

@ -289,7 +289,7 @@ def Oconfig : CommaJoined<["-"], "Oconfig=">, Group<spirv_Group>, Flags<[CoreOpt
// fxc-based flags that don't match those previously defined.
def target_profile : JoinedOrSeparate<["-", "/"], "T">, Flags<[CoreOption]>, Group<hlslcomp_Group>, MetaVarName<"<profile>">,
HelpText<"Set target profile. \n\t<profile>: ps_6_0, ps_6_1, ps_6_2, ps_6_3, ps_6_4, \n\t\t vs_6_0, vs_6_1, vs_6_2, vs_6_3, vs_6_4, \n\t\t cs_6_0, cs_6_1, cs_6_2, cs_6_3, cs_6_4, \n\t\t gs_6_0, gs_6_1, gs_6_2, gs_6_3, gs_6_4, \n\t\t ds_6_0, ds_6_1, ds_6_2, ds_6_3, ds_6_4, \n\t\t hs_6_0, hs_6_1, hs_6_2, hs_6_3, hs_6_4, \n\t\t lib_6_3, lib_6_4">;
HelpText<"Set target profile. \n\t<profile>: ps_6_0, ps_6_1, ps_6_2, ps_6_3, ps_6_4, ps_6_5, \n\t\t vs_6_0, vs_6_1, vs_6_2, vs_6_3, vs_6_4, vs_6_5, \n\t\t cs_6_0, cs_6_1, cs_6_2, cs_6_3, cs_6_4, cs_6_5, \n\t\t gs_6_0, gs_6_1, gs_6_2, gs_6_3, gs_6_4, gs_6_5, \n\t\t ds_6_0, ds_6_1, ds_6_2, ds_6_3, ds_6_4, ds_6_5, \n\t\t hs_6_0, hs_6_1, hs_6_2, hs_6_3, hs_6_4, hs_6_5, \n\t\t lib_6_3, lib_6_4, lib_6_5">;
def entrypoint : JoinedOrSeparate<["-", "/"], "E">, Flags<[CoreOption]>, Group<hlslcomp_Group>,
HelpText<"Entry point name">;
// /I <include> - already defined above

Просмотреть файл

@ -59,6 +59,7 @@ bool ShaderModel::IsValidForDxil() const {
case 2:
case 3:
case 4:
case 5:
return true;
case kOfflineMinor:
return m_Kind == Kind::Library;
@ -83,12 +84,20 @@ const ShaderModel *ShaderModel::Get(unsigned Idx) {
}
const ShaderModel *ShaderModel::Get(Kind Kind, unsigned Major, unsigned Minor) {
// Linear search. Replaced by binary search if necessary.
for (unsigned i = 0; i < kNumShaderModels; i++) {
const ShaderModel *pSM = &ms_ShaderModels[i];
if (pSM->m_Kind == Kind && pSM->m_Major == Major && pSM->m_Minor == Minor)
const ShaderModel *pSM = std::lower_bound(
&ms_ShaderModels[0], &ms_ShaderModels[kNumShaderModels - 1],
ShaderModel(Kind, Major, Minor, "", 0, 0, false, false, 0),
[](const ShaderModel& a, const ShaderModel& b) -> bool {
if (a.m_Kind < b.m_Kind) return 1;
if (b.m_Kind < a.m_Kind) return 0;
if (a.m_Major < b.m_Major) return 1;
if (b.m_Major < a.m_Major) return 0;
if (a.m_Minor < b.m_Minor) return 1;
return 0;
});
if (pSM && pSM < ms_ShaderModels + kNumShaderModels &&
pSM->m_Kind == Kind && pSM->m_Major == Major && pSM->m_Minor == Minor)
return pSM;
}
return GetInvalid();
}
@ -148,6 +157,12 @@ const ShaderModel *ShaderModel::GetByName(const char *pszName) {
break;
}
else return GetInvalid();
case '5':
if (Major == 6) {
Minor = 5;
break;
}
else return GetInvalid();
case 'x':
if (kind == Kind::Library && Major == 6) {
Minor = kOfflineMinor;
@ -179,9 +194,12 @@ void ShaderModel::GetDxilVersion(unsigned &DxilMajor, unsigned &DxilMinor) const
DxilMinor = 3;
break;
case 4:
case kOfflineMinor: // Always update this to highest dxil version
DxilMinor = 4;
break;
case 5:
case kOfflineMinor: // Always update this to highest dxil version
DxilMinor = 5;
break;
default:
DXASSERT(0, "IsValidForDxil() should have caught this.");
break;
@ -207,6 +225,9 @@ void ShaderModel::GetMinValidatorVersion(unsigned &ValMajor, unsigned &ValMinor)
case 4:
ValMinor = 4;
break;
case 5:
ValMinor = 5;
break;
case kOfflineMinor:
ValMajor = 0;
ValMinor = 0;
@ -239,42 +260,6 @@ typedef ShaderModel SM;
typedef Semantic SE;
const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = {
// IR OR UAV? TyUAV? UAV base
SM(Kind::Compute, 4, 0, "cs_4_0", 0, 0, true, false, 1),
SM(Kind::Compute, 4, 1, "cs_4_1", 0, 0, true, false, 1),
SM(Kind::Compute, 5, 0, "cs_5_0", 0, 0, true, true, 64),
SM(Kind::Compute, 5, 1, "cs_5_1", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 0, "cs_6_0", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 1, "cs_6_1", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 2, "cs_6_2", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 3, "cs_6_3", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 4, "cs_6_4", 0, 0, 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, UINT_MAX),
SM(Kind::Domain, 6, 0, "ds_6_0", 32, 32, true, true, UINT_MAX),
SM(Kind::Domain, 6, 1, "ds_6_1", 32, 32, true, true, UINT_MAX),
SM(Kind::Domain, 6, 2, "ds_6_2", 32, 32, true, true, UINT_MAX),
SM(Kind::Domain, 6, 3, "ds_6_3", 32, 32, true, true, UINT_MAX),
SM(Kind::Domain, 6, 4, "ds_6_4", 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),
SM(Kind::Geometry, 5, 1, "gs_5_1", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 0, "gs_6_0", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 1, "gs_6_1", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 2, "gs_6_2", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 3, "gs_6_3", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 4, "gs_6_4", 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, UINT_MAX),
SM(Kind::Hull, 6, 0, "hs_6_0", 32, 32, true, true, UINT_MAX),
SM(Kind::Hull, 6, 1, "hs_6_1", 32, 32, true, true, UINT_MAX),
SM(Kind::Hull, 6, 2, "hs_6_2", 32, 32, true, true, UINT_MAX),
SM(Kind::Hull, 6, 3, "hs_6_3", 32, 32, true, true, UINT_MAX),
SM(Kind::Hull, 6, 4, "hs_6_4", 32, 32, true, true, UINT_MAX),
SM(Kind::Pixel, 4, 0, "ps_4_0", 32, 8, false, false, 0),
SM(Kind::Pixel, 4, 1, "ps_4_1", 32, 8, false, false, 0),
SM(Kind::Pixel, 5, 0, "ps_5_0", 32, 8, true, true, 64),
@ -284,6 +269,7 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = {
SM(Kind::Pixel, 6, 2, "ps_6_2", 32, 8, true, true, UINT_MAX),
SM(Kind::Pixel, 6, 3, "ps_6_3", 32, 8, true, true, UINT_MAX),
SM(Kind::Pixel, 6, 4, "ps_6_4", 32, 8, true, true, UINT_MAX),
SM(Kind::Pixel, 6, 5, "ps_6_5", 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),
@ -294,15 +280,59 @@ const ShaderModel ShaderModel::ms_ShaderModels[kNumShaderModels] = {
SM(Kind::Vertex, 6, 2, "vs_6_2", 32, 32, true, true, UINT_MAX),
SM(Kind::Vertex, 6, 3, "vs_6_3", 32, 32, true, true, UINT_MAX),
SM(Kind::Vertex, 6, 4, "vs_6_4", 32, 32, true, true, UINT_MAX),
SM(Kind::Vertex, 6, 5, "vs_6_5", 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),
SM(Kind::Geometry, 5, 1, "gs_5_1", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 0, "gs_6_0", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 1, "gs_6_1", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 2, "gs_6_2", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 3, "gs_6_3", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 4, "gs_6_4", 32, 32, true, true, UINT_MAX),
SM(Kind::Geometry, 6, 5, "gs_6_5", 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, UINT_MAX),
SM(Kind::Hull, 6, 0, "hs_6_0", 32, 32, true, true, UINT_MAX),
SM(Kind::Hull, 6, 1, "hs_6_1", 32, 32, true, true, UINT_MAX),
SM(Kind::Hull, 6, 2, "hs_6_2", 32, 32, true, true, UINT_MAX),
SM(Kind::Hull, 6, 3, "hs_6_3", 32, 32, true, true, UINT_MAX),
SM(Kind::Hull, 6, 4, "hs_6_4", 32, 32, true, true, UINT_MAX),
SM(Kind::Hull, 6, 5, "hs_6_5", 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, UINT_MAX),
SM(Kind::Domain, 6, 0, "ds_6_0", 32, 32, true, true, UINT_MAX),
SM(Kind::Domain, 6, 1, "ds_6_1", 32, 32, true, true, UINT_MAX),
SM(Kind::Domain, 6, 2, "ds_6_2", 32, 32, true, true, UINT_MAX),
SM(Kind::Domain, 6, 3, "ds_6_3", 32, 32, true, true, UINT_MAX),
SM(Kind::Domain, 6, 4, "ds_6_4", 32, 32, true, true, UINT_MAX),
SM(Kind::Domain, 6, 5, "ds_6_5", 32, 32, true, true, UINT_MAX),
SM(Kind::Compute, 4, 0, "cs_4_0", 0, 0, true, false, 1),
SM(Kind::Compute, 4, 1, "cs_4_1", 0, 0, true, false, 1),
SM(Kind::Compute, 5, 0, "cs_5_0", 0, 0, true, true, 64),
SM(Kind::Compute, 5, 1, "cs_5_1", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 0, "cs_6_0", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 1, "cs_6_1", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 2, "cs_6_2", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 3, "cs_6_3", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 4, "cs_6_4", 0, 0, true, true, UINT_MAX),
SM(Kind::Compute, 6, 5, "cs_6_5", 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),
SM(Kind::Library, 6, 4, "lib_6_4", 32, 32, true, true, UINT_MAX),
SM(Kind::Library, 6, 5, "lib_6_5", 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),
// Values before Invalid must remain sorted by Kind, then Major, then Minor.
SM(Kind::Invalid, 0, 0, "invalid", 0, 0, false, false, 0),
};

Просмотреть файл

@ -5084,8 +5084,10 @@ void GetValidationVersion(_Out_ unsigned *pMajor, _Out_ unsigned *pMinor) {
// 1.4 adds:
// - packed u8x4/i8x4 dot with accumulate to i32
// - half dot2 with accumulate to float
// 1.5 adds:
// TODO: Fill this in.
*pMajor = 1;
*pMinor = 4;
*pMinor = 5;
}
_Use_decl_annotations_ HRESULT