@@ -1174,6 +1174,58 @@ TEST(GraphicsTypesXTest, SpecializationConstants)
11741174 EXPECT_EQ (DescX, Ref);
11751175 }
11761176
1177+ // Test AddSpecializationConstant deep-copies raw bytes.
1178+ {
1179+ Uint8 MutableData[] = {10 , 20 , 30 , 40 , 50 };
1180+ const Uint8 RefData[] = {10 , 20 , 30 , 40 , 50 };
1181+
1182+ ComputePipelineStateCreateInfoX DescX;
1183+ DescX.AddSpecializationConstant ({" SC_Bytes" , SHADER_TYPE_PIXEL, static_cast <Uint32>(_countof (MutableData)), MutableData});
1184+
1185+ for (auto & Byte : MutableData)
1186+ Byte = 0 ;
1187+
1188+ ASSERT_EQ (DescX.NumSpecializationConstants , 1u );
1189+ const auto & SpecConst = DescX.pSpecializationConstants [0 ];
1190+ ASSERT_NE (SpecConst.pData , nullptr );
1191+ EXPECT_EQ (SpecConst.Size , static_cast <Uint32>(_countof (RefData)));
1192+
1193+ const auto * pData = static_cast <const Uint8*>(SpecConst.pData );
1194+ for (size_t i = 0 ; i < _countof (RefData); ++i)
1195+ EXPECT_EQ (pData[i], RefData[i]);
1196+ }
1197+
1198+ // Test create-info wrapper constructor deep-copies raw bytes.
1199+ {
1200+ const Uint8 RefData[] = {1 , 2 , 3 , 4 };
1201+ ComputePipelineStateCreateInfoX DescX;
1202+ {
1203+ Uint8 MutableData[] = {1 , 2 , 3 , 4 };
1204+ const SpecializationConstant SpecConst{
1205+ " SC_CtorBytes" ,
1206+ SHADER_TYPE_COMPUTE,
1207+ static_cast <Uint32>(_countof (MutableData)),
1208+ MutableData};
1209+
1210+ ComputePipelineStateCreateInfo SrcCI;
1211+ SrcCI.NumSpecializationConstants = 1 ;
1212+ SrcCI.pSpecializationConstants = &SpecConst;
1213+ DescX = ComputePipelineStateCreateInfoX{SrcCI};
1214+
1215+ for (auto & Byte : MutableData)
1216+ Byte = 0 ;
1217+ }
1218+
1219+ ASSERT_EQ (DescX.NumSpecializationConstants , 1u );
1220+ const auto & SpecConst = DescX.pSpecializationConstants [0 ];
1221+ ASSERT_NE (SpecConst.pData , nullptr );
1222+ EXPECT_EQ (SpecConst.Size , static_cast <Uint32>(_countof (RefData)));
1223+
1224+ const auto * pData = static_cast <const Uint8*>(SpecConst.pData );
1225+ for (size_t i = 0 ; i < _countof (RefData); ++i)
1226+ EXPECT_EQ (pData[i], RefData[i]);
1227+ }
1228+
11771229 // Test ClearSpecializationConstants
11781230 {
11791231 ComputePipelineStateCreateInfoX DescX;
0 commit comments