@@ -203,6 +203,12 @@ std::string GetCaptureTrigger()
203203#endif // defined(ANGLE_PLATFORM_ANDROID)
204204}
205205
206+ std::ostream &operator <<(std::ostream &os, gl::ContextID contextId)
207+ {
208+ os << static_cast <int >(contextId.value );
209+ return os;
210+ }
211+
206212struct FmtCapturePrefix
207213{
208214 FmtCapturePrefix (gl::ContextID contextIdIn, const std::string &captureLabelIn)
@@ -222,7 +228,7 @@ std::ostream &operator<<(std::ostream &os, const FmtCapturePrefix &fmt)
222228 {
223229 os << fmt.captureLabel ;
224230 }
225- os << " _capture_context" << static_cast < int >( fmt.contextId ) ;
231+ os << " _capture_context" << fmt.contextId ;
226232 return os;
227233}
228234
@@ -249,7 +255,7 @@ struct FmtReplayFunction
249255
250256std::ostream &operator <<(std::ostream &os, const FmtReplayFunction &fmt)
251257{
252- os << " ReplayContext" << static_cast < int >( fmt.contextId ) << " Frame" << fmt.frameIndex ;
258+ os << " ReplayContext" << fmt.contextId << " Frame" << fmt.frameIndex ;
253259 if (fmt.partId != kNoPartId )
254260 {
255261 os << " Part" << fmt.partId ;
@@ -270,7 +276,7 @@ struct FmtSetupFunction
270276
271277std::ostream &operator <<(std::ostream &os, const FmtSetupFunction &fmt)
272278{
273- os << " SetupContext" << Str ( static_cast < int >( fmt.contextId )) << " Replay" ;
279+ os << " SetupContext" << fmt.contextId << " Replay" ;
274280 if (fmt.partId != kNoPartId )
275281 {
276282 os << " Part" << fmt.partId ;
@@ -288,7 +294,7 @@ struct FmtResetFunction
288294
289295std::ostream &operator <<(std::ostream &os, const FmtResetFunction &fmt)
290296{
291- os << " ResetContext" << Str ( static_cast < int >( fmt.contextId )) << " Replay()" ;
297+ os << " ResetContext" << fmt.contextId << " Replay()" ;
292298 return os;
293299}
294300
@@ -331,19 +337,18 @@ std::ostream &operator<<(std::ostream &os, const FmtFunction &fmt)
331337 return os;
332338}
333339
334- struct FmtGetSerializedContextStateDataFunction
340+ struct FmtGetSerializedContextStateFunction
335341{
336- FmtGetSerializedContextStateDataFunction (gl::ContextID contextIdIn, uint32_t frameIndexIn)
342+ FmtGetSerializedContextStateFunction (gl::ContextID contextIdIn, uint32_t frameIndexIn)
337343 : contextId(contextIdIn), frameIndex(frameIndexIn)
338344 {}
339345 gl::ContextID contextId;
340346 uint32_t frameIndex;
341347};
342348
343- std::ostream &operator <<(std::ostream &os, const FmtGetSerializedContextStateDataFunction &fmt)
349+ std::ostream &operator <<(std::ostream &os, const FmtGetSerializedContextStateFunction &fmt)
344350{
345- os << " GetSerializedContext" << static_cast <int >(fmt.contextId ) << " StateFrame"
346- << fmt.frameIndex << " Data()" ;
351+ os << " GetSerializedContext" << fmt.contextId << " StateFrame" << fmt.frameIndex << " Data()" ;
347352 return os;
348353}
349354
@@ -1148,14 +1153,10 @@ void WriteCppReplay(bool compression,
11481153 binaryData->resize (serializedContextOffset + serializedContextLength);
11491154 memcpy (binaryData->data () + serializedContextOffset, serializedContextData.data (),
11501155 serializedContextLength);
1151- out << " std::vector< uint8_t> "
1152- << FmtGetSerializedContextStateDataFunction (context->id (), frameIndex) << " \n " ;
1156+ out << " const uint8_t * "
1157+ << FmtGetSerializedContextStateFunction (context->id (), frameIndex) << " \n " ;
11531158 out << " {\n " ;
1154- out << " std::vector<uint8_t> serializedContextData(" << serializedContextLength
1155- << " );\n " ;
1156- out << " memcpy(serializedContextData.data(), &gBinaryData["
1157- << serializedContextOffset << " ], " << serializedContextLength << " );\n " ;
1158- out << " return serializedContextData;\n " ;
1159+ out << " return &gBinaryData[" << serializedContextOffset << " ];\n " ;
11591160 out << " }\n " ;
11601161 out << " \n " ;
11611162 }
@@ -1249,14 +1250,13 @@ void WriteCppReplayIndexFiles(bool compression,
12491250 << " ;\n " ;
12501251 header << " // End Trace Metadata\n " ;
12511252 header << " \n " ;
1252- header << " void SetupContext" << static_cast <int >(contextId) << " Replay();\n " ;
1253- header << " void ReplayContext" << static_cast <int >(contextId)
1254- << " Frame(uint32_t frameIndex);\n " ;
1255- header << " void ResetContext" << static_cast <int >(contextId) << " Replay();\n " ;
1253+ header << " void SetupContext" << contextId << " Replay();\n " ;
1254+ header << " void ReplayContext" << contextId << " Frame(uint32_t frameIndex);\n " ;
1255+ header << " void ResetContext" << contextId << " Replay();\n " ;
12561256 if (serializeStateEnabled)
12571257 {
1258- header << " std::vector< uint8_t> GetSerializedContext" << static_cast < int >( contextId)
1259- << " StateData (uint32_t frameIndex);\n " ;
1258+ header << " const uint8_t * GetSerializedContext" << contextId
1259+ << " State (uint32_t frameIndex);\n " ;
12601260 }
12611261 header << " \n " ;
12621262 for (uint32_t frameIndex = 1 ; frameIndex <= frameCount; ++frameIndex)
@@ -1268,8 +1268,8 @@ void WriteCppReplayIndexFiles(bool compression,
12681268 {
12691269 for (uint32_t frameIndex = 1 ; frameIndex <= frameCount; ++frameIndex)
12701270 {
1271- header << " std::vector< uint8_t> "
1272- << FmtGetSerializedContextStateDataFunction (contextId, frameIndex) << " ;\n " ;
1271+ header << " const uint8_t * "
1272+ << FmtGetSerializedContextStateFunction (contextId, frameIndex) << " ;\n " ;
12731273 }
12741274 header << " \n " ;
12751275 }
@@ -1383,15 +1383,14 @@ void WriteCppReplayIndexFiles(bool compression,
13831383 header << " \n " ;
13841384
13851385 source << " \n " ;
1386- source << " void ReplayContext" << static_cast < int >( contextId) << " Frame(uint32_t frameIndex)\n " ;
1386+ source << " void ReplayContext" << contextId << " Frame(uint32_t frameIndex)\n " ;
13871387 source << " {\n " ;
13881388 source << " switch (frameIndex)\n " ;
13891389 source << " {\n " ;
13901390 for (uint32_t frameIndex = 1 ; frameIndex <= frameCount; ++frameIndex)
13911391 {
13921392 source << " case " << frameIndex << " :\n " ;
1393- source << " ReplayContext" << static_cast <int >(contextId) << " Frame"
1394- << frameIndex << " ();\n " ;
1393+ source << " ReplayContext" << contextId << " Frame" << frameIndex << " ();\n " ;
13951394 source << " break;\n " ;
13961395 }
13971396 source << " default:\n " ;
@@ -1402,7 +1401,7 @@ void WriteCppReplayIndexFiles(bool compression,
14021401
14031402 if (writeResetContextCall)
14041403 {
1405- source << " void ResetContext" << Str ( static_cast < int >( contextId)) << " Replay()\n " ;
1404+ source << " void ResetContext" << contextId << " Replay()\n " ;
14061405 source << " {\n " ;
14071406 source << " // Reset context is empty because context is destroyed before end "
14081407 " frame is reached\n " ;
@@ -1412,16 +1411,16 @@ void WriteCppReplayIndexFiles(bool compression,
14121411
14131412 if (serializeStateEnabled)
14141413 {
1415- source << " std::vector< uint8_t> GetSerializedContext" << static_cast < int >( contextId)
1416- << " StateData (uint32_t frameIndex)\n " ;
1414+ source << " const uint8_t * GetSerializedContext" << contextId
1415+ << " State (uint32_t frameIndex)\n " ;
14171416 source << " {\n " ;
14181417 source << " switch (frameIndex)\n " ;
14191418 source << " {\n " ;
14201419 for (uint32_t frameIndex = 1 ; frameIndex <= frameCount; ++frameIndex)
14211420 {
14221421 source << " case " << frameIndex << " :\n " ;
14231422 source << " return "
1424- << FmtGetSerializedContextStateDataFunction (contextId, frameIndex) << " ;\n " ;
1423+ << FmtGetSerializedContextStateFunction (contextId, frameIndex) << " ;\n " ;
14251424 }
14261425 source << " default:\n " ;
14271426 source << " return {};\n " ;
0 commit comments