@@ -1713,6 +1713,75 @@ TEST_F(ConvertToHalfTest, PreserveImageOperandPrecision) {
1713
1713
SinglePassRunAndMatch<ConvertToHalfPass>(test, true );
1714
1714
}
1715
1715
1716
+ TEST_F (ConvertToHalfTest, DontRelaxDecoratedOpCompositeExtract) {
1717
+ // This test checks that a OpCompositeExtract with a Struct operand won't be
1718
+ // relaxed, even if it is explicitly decorated with RelaxedPrecision.
1719
+ const std::string test =
1720
+ R"( OpCapability Shader
1721
+ OpMemoryModel Logical GLSL450
1722
+ OpEntryPoint Fragment %1 "main"
1723
+ OpExecutionMode %1 OriginUpperLeft
1724
+ OpDecorate %9 RelaxedPrecision
1725
+ %void = OpTypeVoid
1726
+ %3 = OpTypeFunction %void
1727
+ %float = OpTypeFloat 32
1728
+ %v4float = OpTypeVector %float 4
1729
+ %_struct_6 = OpTypeStruct %v4float
1730
+ %7 = OpUndef %_struct_6
1731
+ %1 = OpFunction %void None %3
1732
+ %8 = OpLabel
1733
+ %9 = OpCompositeExtract %float %7 0 3
1734
+ OpReturn
1735
+ OpFunctionEnd
1736
+ )" ;
1737
+
1738
+ const std::string expected =
1739
+ R"( OpCapability Shader
1740
+ OpMemoryModel Logical GLSL450
1741
+ OpEntryPoint Fragment %1 "main"
1742
+ OpExecutionMode %1 OriginUpperLeft
1743
+ %void = OpTypeVoid
1744
+ %3 = OpTypeFunction %void
1745
+ %float = OpTypeFloat 32
1746
+ %v4float = OpTypeVector %float 4
1747
+ %_struct_6 = OpTypeStruct %v4float
1748
+ %7 = OpUndef %_struct_6
1749
+ %1 = OpFunction %void None %3
1750
+ %8 = OpLabel
1751
+ %9 = OpCompositeExtract %float %7 0 3
1752
+ OpReturn
1753
+ OpFunctionEnd
1754
+ )" ;
1755
+
1756
+ SetAssembleOptions (SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
1757
+ SinglePassRunAndCheck<ConvertToHalfPass>(test, expected, true );
1758
+ }
1759
+
1760
+ TEST_F (ConvertToHalfTest, DontRelaxOpCompositeExtract) {
1761
+ // This test checks that a OpCompositeExtract with a Struct operand won't be
1762
+ // relaxed, even if its result has no uses.
1763
+ const std::string test =
1764
+ R"( OpCapability Shader
1765
+ OpMemoryModel Logical GLSL450
1766
+ OpEntryPoint Fragment %1 "main"
1767
+ OpExecutionMode %1 OriginUpperLeft
1768
+ %void = OpTypeVoid
1769
+ %3 = OpTypeFunction %void
1770
+ %float = OpTypeFloat 32
1771
+ %v4float = OpTypeVector %float 4
1772
+ %_struct_6 = OpTypeStruct %v4float
1773
+ %7 = OpUndef %_struct_6
1774
+ %1 = OpFunction %void None %3
1775
+ %8 = OpLabel
1776
+ %9 = OpCompositeExtract %float %7 0 3
1777
+ OpReturn
1778
+ OpFunctionEnd
1779
+ )" ;
1780
+
1781
+ SetAssembleOptions (SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
1782
+ SinglePassRunAndCheck<ConvertToHalfPass>(test, test, true );
1783
+ }
1784
+
1716
1785
} // namespace
1717
1786
} // namespace opt
1718
1787
} // namespace spvtools
0 commit comments