Skip to content

Commit 7d66a5d

Browse files
committed
Non-functional (almost): Refactor when 'extensionRequested' is called.
This detangles incorrect conflation of HLSL with GLSL extensions, defers asking expensive questions until it's time to ask, and removes some dead code.
1 parent bdf9e64 commit 7d66a5d

File tree

1 file changed

+35
-62
lines changed

1 file changed

+35
-62
lines changed

glslang/MachineIndependent/Intermediate.cpp

Lines changed: 35 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -819,22 +819,25 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
819819
node->getBasicType() == EbtFloat ||
820820
node->getBasicType() == EbtDouble);
821821

822-
if (! getArithemeticInt8Enabled()) {
823-
if (((convertTo == EbtInt8 || convertTo == EbtUint8) && ! convertFromIntTypes) ||
824-
((node->getBasicType() == EbtInt8 || node->getBasicType() == EbtUint8) && ! convertToIntTypes))
822+
if (((convertTo == EbtInt8 || convertTo == EbtUint8) && ! convertFromIntTypes) ||
823+
((node->getBasicType() == EbtInt8 || node->getBasicType() == EbtUint8) && ! convertToIntTypes)) {
824+
if (! getArithemeticInt8Enabled()) {
825825
return nullptr;
826+
}
826827
}
827828

828-
if (! getArithemeticInt16Enabled()) {
829-
if (((convertTo == EbtInt16 || convertTo == EbtUint16) && ! convertFromIntTypes) ||
830-
((node->getBasicType() == EbtInt16 || node->getBasicType() == EbtUint16) && ! convertToIntTypes))
829+
if (((convertTo == EbtInt16 || convertTo == EbtUint16) && ! convertFromIntTypes) ||
830+
((node->getBasicType() == EbtInt16 || node->getBasicType() == EbtUint16) && ! convertToIntTypes)) {
831+
if (! getArithemeticInt16Enabled()) {
831832
return nullptr;
833+
}
832834
}
833835

834-
if (! getArithemeticFloat16Enabled()) {
835-
if ((convertTo == EbtFloat16 && ! convertFromFloatTypes) ||
836-
(node->getBasicType() == EbtFloat16 && ! convertToFloatTypes))
836+
if ((convertTo == EbtFloat16 && ! convertFromFloatTypes) ||
837+
(node->getBasicType() == EbtFloat16 && ! convertToFloatTypes)) {
838+
if (! getArithemeticFloat16Enabled()) {
837839
return nullptr;
840+
}
838841
}
839842
#endif
840843

@@ -1650,64 +1653,45 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
16501653
}
16511654
}
16521655

1653-
bool explicitTypesEnabled = extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
1654-
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int8) ||
1655-
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int16) ||
1656-
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int32) ||
1657-
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int64) ||
1658-
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float16) ||
1659-
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float32) ||
1660-
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float64);
1661-
1662-
if (explicitTypesEnabled) {
1663-
// integral promotions
1664-
if (isIntegralPromotion(from, to)) {
1665-
return true;
1666-
}
1667-
1668-
// floating-point promotions
1669-
if (isFPPromotion(from, to)) {
1670-
return true;
1671-
}
1672-
1673-
// integral conversions
1674-
if (isIntegralConversion(from, to)) {
1656+
if (getSource() == EShSourceHlsl) {
1657+
// HLSL
1658+
if (from == EbtBool && (to == EbtInt || to == EbtUint || to == EbtFloat))
16751659
return true;
1676-
}
1677-
1678-
// floating-point conversions
1679-
if (isFPConversion(from, to)) {
1680-
return true;
1681-
}
1682-
1683-
// floating-integral conversions
1684-
if (isFPIntegralConversion(from, to)) {
1685-
return true;
1686-
}
1687-
1688-
// hlsl supported conversions
1689-
if (getSource() == EShSourceHlsl) {
1690-
if (from == EbtBool && (to == EbtInt || to == EbtUint || to == EbtFloat))
1660+
} else {
1661+
// GLSL
1662+
if (isIntegralPromotion(from, to) ||
1663+
isFPPromotion(from, to) ||
1664+
isIntegralConversion(from, to) ||
1665+
isFPConversion(from, to) ||
1666+
isFPIntegralConversion(from, to)) {
1667+
1668+
if (extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
1669+
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int8) ||
1670+
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int16) ||
1671+
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int32) ||
1672+
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int64) ||
1673+
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float16) ||
1674+
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float32) ||
1675+
extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float64)) {
16911676
return true;
1677+
}
16921678
}
1693-
} else if (isEsProfile()) {
1679+
}
1680+
1681+
if (isEsProfile()) {
16941682
switch (to) {
16951683
case EbtFloat:
16961684
switch (from) {
16971685
case EbtInt:
16981686
case EbtUint:
16991687
return extensionRequested(E_GL_EXT_shader_implicit_conversions);
1700-
case EbtFloat:
1701-
return true;
17021688
default:
17031689
return false;
17041690
}
17051691
case EbtUint:
17061692
switch (from) {
17071693
case EbtInt:
17081694
return extensionRequested(E_GL_EXT_shader_implicit_conversions);
1709-
case EbtUint:
1710-
return true;
17111695
default:
17121696
return false;
17131697
}
@@ -1723,7 +1707,6 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
17231707
case EbtInt64:
17241708
case EbtUint64:
17251709
case EbtFloat:
1726-
case EbtDouble:
17271710
return version >= 400 || extensionRequested(E_GL_ARB_gpu_shader_fp64);
17281711
case EbtInt16:
17291712
case EbtUint16:
@@ -1739,7 +1722,6 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
17391722
switch (from) {
17401723
case EbtInt:
17411724
case EbtUint:
1742-
case EbtFloat:
17431725
return true;
17441726
case EbtBool:
17451727
return getSource() == EShSourceHlsl;
@@ -1756,8 +1738,6 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
17561738
switch (from) {
17571739
case EbtInt:
17581740
return version >= 400 || getSource() == EShSourceHlsl;
1759-
case EbtUint:
1760-
return true;
17611741
case EbtBool:
17621742
return getSource() == EShSourceHlsl;
17631743
case EbtInt16:
@@ -1768,8 +1748,6 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
17681748
}
17691749
case EbtInt:
17701750
switch (from) {
1771-
case EbtInt:
1772-
return true;
17731751
case EbtBool:
17741752
return getSource() == EShSourceHlsl;
17751753
case EbtInt16:
@@ -1782,7 +1760,6 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
17821760
case EbtInt:
17831761
case EbtUint:
17841762
case EbtInt64:
1785-
case EbtUint64:
17861763
return true;
17871764
case EbtInt16:
17881765
case EbtUint16:
@@ -1793,7 +1770,6 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
17931770
case EbtInt64:
17941771
switch (from) {
17951772
case EbtInt:
1796-
case EbtInt64:
17971773
return true;
17981774
case EbtInt16:
17991775
return extensionRequested(E_GL_AMD_gpu_shader_int16);
@@ -1805,16 +1781,13 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
18051781
case EbtInt16:
18061782
case EbtUint16:
18071783
return extensionRequested(E_GL_AMD_gpu_shader_int16);
1808-
case EbtFloat16:
1809-
return extensionRequested(E_GL_AMD_gpu_shader_half_float);
18101784
default:
18111785
break;
18121786
}
18131787
return false;
18141788
case EbtUint16:
18151789
switch (from) {
18161790
case EbtInt16:
1817-
case EbtUint16:
18181791
return extensionRequested(E_GL_AMD_gpu_shader_int16);
18191792
default:
18201793
break;

0 commit comments

Comments
 (0)