1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
|
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
#include "RenderDebugTyped.h"
#include "RenderDebugImpl.h"
#include "ClientServer.h"
#include "ProcessRenderDebug.h"
#include "InternalRenderDebug.h"
#include "FileRenderDebug.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "PsUserAllocated.h"
#include "PsMutex.h"
#include "PsString.h"
#include "PxErrorCallback.h"
#include "PxAllocatorCallback.h"
#include "PsArray.h"
#include "PsFoundation.h"
namespace RENDER_DEBUG
{
class RenderDebugIImpl;
void finalRelease(RenderDebugIImpl *nv);
}
#include "GetArgs.h"
#include "PsFileBuffer.h"
#if PX_WINDOWS_FAMILY
#pragma warning(disable:4986)
#endif
#define SERVER_FILE_SIZE sizeof(ServerHeader)+(1024*1024)
class EchoRemoteCommand
{
public:
char mCommand[16384];
};
typedef physx::shdfnd::Array< EchoRemoteCommand > EchoRemoteCommandVector;
#ifdef USE_PX_FOUNDATION
#else
class DefaultErrorCallback : public physx::PxErrorCallback
{
public:
DefaultErrorCallback(void)
{
}
virtual void reportError(physx::PxErrorCode::Enum code, const char* message, const char* file, int line)
{
PX_UNUSED(code);
PX_UNUSED(file);
PX_UNUSED(line);
printf("PhysX: %s\r\n", message );
}
private:
};
#if PX_WINDOWS_FAMILY
// on win32 we only have 8-byte alignment guaranteed, but the CRT provides special aligned allocation
// fns
#include <malloc.h>
#include <crtdbg.h>
static void* platformAlignedAlloc(size_t size)
{
return _aligned_malloc(size, 16);
}
static void platformAlignedFree(void* ptr)
{
_aligned_free(ptr);
}
#elif PX_LINUX || PX_ANDROID
static void* platformAlignedAlloc(size_t size)
{
return ::memalign(16, size);
}
static void platformAlignedFree(void* ptr)
{
::free(ptr);
}
#elif PX_WIIU
static void* platformAlignedAlloc(size_t size)
{
size_t pad = 15 + sizeof(size_t); // store offset for delete.
uint8_t* base = (uint8_t*)::malloc(size+pad);
if(!base)
return NULL;
uint8_t* ptr = (uint8_t*)(size_t(base + pad) & ~(15)); // aligned pointer
((size_t*)ptr)[-1] = ptr - base; // store offset
return ptr;
}
static void platformAlignedFree(void* ptr)
{
if(ptr == NULL)
return;
uint8_t* base = ((uint8_t*)ptr) - ((size_t*)ptr)[-1];
::free(base);
}
#else
// on PS3, XBox and Win64 we get 16-byte alignment by default
static void* platformAlignedAlloc(size_t size)
{
void *ptr = ::malloc(size);
PX_ASSERT((reinterpret_cast<size_t>(ptr) & 15)==0);
return ptr;
}
static void platformAlignedFree(void* ptr)
{
::free(ptr);
}
#endif
class DefaultAllocator : public physx::PxAllocatorCallback
{
public:
DefaultAllocator(void)
{
}
~DefaultAllocator(void)
{
}
virtual void* allocate(size_t size, const char* typeName, const char* filename, int line)
{
PX_UNUSED(typeName);
PX_UNUSED(filename);
PX_UNUSED(line);
void *ret = platformAlignedAlloc(size);
return ret;
}
virtual void deallocate(void* ptr)
{
platformAlignedFree(ptr);
}
private:
};
DefaultAllocator gDefaultAllocator;
DefaultErrorCallback gDefaultErrorCallback;
#endif
#define RECORD_REMOTE_COMMANDS_VERSION 100
static char magic[4] = { 'R', 'R', 'C', 'V' };
static uint32_t isBigEndian(void)
{
int32_t i = 1;
bool b = *(reinterpret_cast<char*>(&i))==0;
return b ? uint32_t(1) : uint32_t(0);
}
namespace RENDER_DEBUG
{
class PlaybackRemoteCommand
{
public:
PlaybackRemoteCommand(void)
{
mFrameNumber = 0;
mArgc = 0;
for (uint32_t i=0; i<256; i++)
{
mArgv[i] = NULL;
}
}
void release(void)
{
mFrameNumber = 0;
for (uint32_t i=0; i<mArgc; i++)
{
PX_FREE(static_cast<void *>(const_cast<char *>(mArgv[i])));
mArgv[i] = NULL;
}
mArgc = 0;
}
uint32_t mFrameNumber;
uint32_t mArgc;
const char *mArgv[256];
};
class RenderDebugIImpl : public physx::shdfnd::UserAllocated, public RenderDebugHook
{
PX_NOCOPY(RenderDebugIImpl)
public:
RenderDebugIImpl(RENDER_DEBUG::RenderDebug::Desc &desc) :
mEchoRemoteCommandBuffer(PX_DEBUG_EXP("PxRenderDebug::mEchoRemoteCommandBuffer"))
{
mEndianSwap = false;
mRecordRemoteCommands = NULL;
mPlaybackRemoteCommands = NULL;
mCurrentFrame = 0;
mMeshId = 0;
mFileRenderDebug = NULL;
mIsValid = true;
mApexRenderDebug = NULL;
mInternalProcessRenderDebug = NULL;
mRenderDebug = NULL;
mClientServer = NULL;
mReadNext = false;
switch ( desc.runMode )
{
case RenderDebug::RM_CLIENT:
case RenderDebug::RM_CLIENT_OR_FILE:
case RenderDebug::RM_SERVER:
{
if ( desc.runMode == RenderDebug::RM_SERVER ) // if running in server mode.
{
mClientServer = createClientServer(desc);
}
else
{
mClientServer = createClientServer(desc);
if ( mClientServer == NULL )
{
if ( desc.runMode != RenderDebug::RM_CLIENT_OR_FILE )
{
desc.errorCode = "Unable to locate server";
}
else
{
desc.errorCode = NULL;
}
}
}
}
break;
case RenderDebug::RM_LOCAL:
break;
case RenderDebug::RM_FILE:
break;
}
if ( desc.runMode == RenderDebug::RM_FILE || desc.runMode == RenderDebug::RM_CLIENT_OR_FILE || desc.runMode == RENDER_DEBUG::RenderDebug::RM_CLIENT )
{
if ( desc.echoFileLocally )
{
mInternalProcessRenderDebug = RENDER_DEBUG::createProcessRenderDebug();
}
mFileRenderDebug = RENDER_DEBUG::createFileRenderDebug(desc.recordFileName,false,desc.echoFileLocally ? mInternalProcessRenderDebug : NULL, mClientServer);
if ( mFileRenderDebug == NULL )
{
mIsValid = false;
desc.errorCode = "Failed to open recording file";
}
}
if ( mIsValid )
{
if ( mFileRenderDebug )
{
mMeshId = 1000000; //
mRenderDebug = RENDER_DEBUG::createInternalRenderDebug(mFileRenderDebug,this);
}
else
{
if ( mInternalProcessRenderDebug == NULL )
{
mInternalProcessRenderDebug = RENDER_DEBUG::createProcessRenderDebug();
}
mRenderDebug = RENDER_DEBUG::createInternalRenderDebug(mInternalProcessRenderDebug,this);
}
}
if ( desc.errorCode )
{
mIsValid = false;
}
if ( mIsValid && desc.recordRemoteCommands )
{
mRecordRemoteCommands = PX_NEW(physx::PsFileBuffer)(desc.recordRemoteCommands, physx::PsFileBuffer::OPEN_WRITE_ONLY);
if ( mRecordRemoteCommands->isOpen() )
{
mRecordRemoteCommands->write(magic, 4 );
mRecordRemoteCommands->storeDword(RECORD_REMOTE_COMMANDS_VERSION);
uint32_t bigEndian = isBigEndian();
mRecordRemoteCommands->storeDword(bigEndian);
mRecordRemoteCommands->flush();
}
else
{
delete mRecordRemoteCommands;
mRecordRemoteCommands = NULL;
}
}
if ( mIsValid && desc.playbackRemoteCommands )
{
mPlaybackRemoteCommands = PX_NEW(physx::PsFileBuffer)(desc.playbackRemoteCommands, physx::PsFileBuffer::OPEN_READ_ONLY);
if ( mPlaybackRemoteCommands->isOpen() )
{
char temp[4];
uint32_t r = mPlaybackRemoteCommands->read(temp,4);
uint32_t version = mPlaybackRemoteCommands->readDword();
uint32_t bigEndian = mPlaybackRemoteCommands->readDword();
if ( r == 4 && magic[0] == temp[0] && magic[1] == temp[1] && magic[2] == temp[2] && magic[3] == temp[3] && version == RECORD_REMOTE_COMMANDS_VERSION )
{
if ( bigEndian != isBigEndian() )
{
mEndianSwap = true;
}
mReadNext = true;
}
else
{
delete mPlaybackRemoteCommands;
mPlaybackRemoteCommands = NULL;
}
}
else
{
delete mPlaybackRemoteCommands;
mPlaybackRemoteCommands = NULL;
}
}
mDesc = desc;
}
virtual ~RenderDebugIImpl(void)
{
delete mRecordRemoteCommands;
delete mPlaybackRemoteCommands;
mPlaybackRemoteCommand.release();
if ( mFileRenderDebug )
{
mFileRenderDebug->release();
}
if ( mClientServer )
{
mClientServer->release();
}
if ( mRenderDebug )
{
mRenderDebug->releaseRenderDebug();
}
if ( mInternalProcessRenderDebug )
{
mInternalProcessRenderDebug->release();
}
}
virtual bool render(float dtime,RENDER_DEBUG::RenderDebugInterface *iface)
{
bool ret = true;
mCurrentFrame++;
mApexRenderDebug = iface;
if ( mFileRenderDebug && mFileRenderDebug->getFrameCount() )
{
mFileRenderDebug->processReadFrame(iface);
}
if ( mClientServer && mDesc.runMode == RENDER_DEBUG::RenderDebug::RM_SERVER )
{
mClientServer->processFrame(mInternalProcessRenderDebug,iface);
}
ret = mRenderDebug->renderImpl(dtime,iface);
return ret;
}
virtual void release(void)
{
finalRelease(this);
}
bool isValid(void) const
{
return mIsValid;
}
virtual uint32_t setFilePlayback(const char *fileName)
{
uint32_t ret = 0;
if ( mFileRenderDebug )
{
mFileRenderDebug->release();
mFileRenderDebug = NULL;
}
mFileRenderDebug = RENDER_DEBUG::createFileRenderDebug(fileName,true,mInternalProcessRenderDebug, NULL);
if ( mFileRenderDebug )
{
mFileRenderDebug->setFrame(0);
ret = mFileRenderDebug->getFrameCount();
}
return ret;
}
virtual bool setPlaybackFrame(uint32_t playbackFrame)
{
bool ret = false;
if ( mFileRenderDebug && playbackFrame < mFileRenderDebug->getFrameCount() )
{
ret = true;
mFileRenderDebug->setFrame(playbackFrame);
}
return ret;
}
virtual uint32_t getPlaybackFrameCount(void) const
{
uint32_t ret = 0;
if ( mFileRenderDebug )
{
ret = mFileRenderDebug->getFrameCount();
}
return ret;
}
virtual void stopPlayback(void)
{
if ( mFileRenderDebug )
{
mFileRenderDebug->release();
mFileRenderDebug = NULL;
}
}
virtual bool trylock(void)
{
return mMutex.trylock();
}
virtual void lock(void)
{
mMutex.lock();
}
virtual void unlock(void)
{
mMutex.unlock();
}
/**
\brief Convenience method to return a unique mesh id number (simply a global counter to avoid clashing with other ids
*/
virtual uint32_t getMeshId(void)
{
mMeshId++;
return mMeshId;
}
/**
\brief Transmit an actual input event to the remote client
\param ev The input event data to transmit
*/
virtual void sendInputEvent(const InputEvent &ev)
{
if ( mClientServer )
{
mClientServer->sendInputEvent(ev);
}
}
virtual bool sendRemoteCommand(const char *fmt,...)
{
bool ret = false;
EchoRemoteCommand c;
va_list arg;
va_start( arg, fmt );
physx::shdfnd::vsnprintf(c.mCommand,sizeof(c.mCommand)-1, fmt, arg);
va_end(arg);
if ( mClientServer )
{
ret = mClientServer->sendCommand(c.mCommand);
}
else
{
mEchoRemoteCommandBuffer.pushBack(c);
}
return ret;
}
virtual const char ** getRemoteCommand(uint32_t &argc)
{
const char **ret = NULL;
argc = 0;
if ( mClientServer )
{
ret = mClientServer->getCommand(argc);
}
else if ( !mEchoRemoteCommandBuffer.empty() )
{
mCurrentCommand = mEchoRemoteCommandBuffer[0];
mEchoRemoteCommandBuffer.remove(0);
ret = mParser.getArgs(mCurrentCommand.mCommand,argc);
}
if ( mReadNext )
{
readNextRemoteCommand();
mReadNext = false;
}
if ( mPlaybackRemoteCommands )
{
ret = NULL;
argc = 0;
if ( mPlaybackRemoteCommand.mFrameNumber == mCurrentFrame )
{
argc = mPlaybackRemoteCommand.mArgc;
ret = mPlaybackRemoteCommand.mArgv;
mReadNext = true;
}
}
if ( mRecordRemoteCommands && ret && argc < 256 )
{
mRecordRemoteCommands->storeDword(mCurrentFrame);
mRecordRemoteCommands->storeDword(argc);
for (uint32_t i=0; i<argc; i++)
{
const char *str = ret[i];
uint32_t len = uint32_t(strlen(str))+1;
mRecordRemoteCommands->storeDword(len);
mRecordRemoteCommands->write(str,len);
}
mRecordRemoteCommands->flush();
}
return ret;
}
/**
\brief Transmits an arbitrary block of binary data to the remote machine. The block of data can have a command and id associated with it.
It is important to note that due to the fact the RenderDebug system is synchronized every single frame, it is strongly recommended
that you only use this feature for relatively small data items; probably on the order of a few megabytes at most. If you try to do
a very large transfer, in theory it would work, but it might take a very long time to complete and look like a hang since it will
essentially be blocking.
\param command An arbitrary command associated with this data transfer, for example this could indicate a remote file request.
\param id An arbitrary id associated with this data transfer, for example the id could be the file name of a file transfer request.
\param data The block of binary data to transmit, you are responsible for maintaining endian correctness of the internal data if necessary.
\param dlen The length of the lock of data to transmit.
\return Returns true if the data was queued to be transmitted, false if it failed.
*/
virtual bool sendRemoteResource(const char *command,
const char *id,
const void *data,
uint32_t dlen)
{
bool ret = false;
if ( mClientServer )
{
ret = mClientServer->sendRemoteResource(command,id,data,dlen);
}
return ret;
}
/**
\brief This function allows you to request a file from the remote machine by name. If successful it will be returned via 'getRemoteData'
\param command The command field associated with this request which will be returned by 'getRemoteData'
\param fileName The filename being requested from the remote machine.
\return Returns true if the request was queued to be transmitted, false if it failed.
*/
virtual bool requestRemoteResource(const char *command,
const char *fileName)
{
bool ret = false;
if ( mClientServer )
{
ret = mClientServer->requestRemoteResource(command,fileName);
}
return ret;
}
/**
\brief Retrieves a block of remotely transmitted binary data.
\param command A a reference to a pointer which will store the arbitrary command associated with this data transfer, for example this could indicate a remote file request.
\param id A reference to a pointer which will store an arbitrary id associated with this data transfer, for example the id could be the file name of a file transfer request.
\param dlen A reference that will contain length of the lock of data received.
\param remoteIsBigEndian A reference to a boolean which will be set to true if the remote machine that sent this data is big endian format.
\retrun A pointer to the block of data received.
*/
virtual const void * getRemoteResource(const char *&command,
const char *&id,
uint32_t &dlen,
bool &remoteIsBigEndian)
{
const void *ret = NULL;
if ( mClientServer )
{
ret = mClientServer->getRemoteResource(command,id,dlen,remoteIsBigEndian);
}
return ret;
}
virtual RENDER_DEBUG::RenderDebug::RunMode getRunMode(void)
{
RENDER_DEBUG::RenderDebug::RunMode ret = RENDER_DEBUG::RenderDebug::RM_LOCAL;
if ( mClientServer )
{
if ( mClientServer->isServer() )
{
ret = RENDER_DEBUG::RenderDebug::RM_SERVER;
}
else
{
ret = RENDER_DEBUG::RenderDebug::RM_CLIENT;
}
}
else if ( mFileRenderDebug )
{
ret = RENDER_DEBUG::RenderDebug::RM_FILE;
}
return ret;
}
virtual bool isConnected(void) const
{
bool ret = false;
if ( mClientServer )
{
ret = mClientServer->isConnected();
}
return ret;
}
virtual uint32_t getCommunicationsFrame(void) const
{
return mClientServer ? mClientServer->getCommunicationsFrame() : 0;
}
virtual const char *getRemoteApplicationName(void)
{
const char *ret = NULL;
if ( mClientServer )
{
ret = mClientServer->getRemoteApplicationName();
}
return ret;
}
virtual RenderDebugTyped *getRenderDebugTyped(void)
{
return static_cast< RenderDebugTyped *>(mRenderDebug);
}
void readNextRemoteCommand(void)
{
if ( mPlaybackRemoteCommands == NULL ) return;
mPlaybackRemoteCommand.release(); // release previous command
mPlaybackRemoteCommand.mFrameNumber = mPlaybackRemoteCommands->readDword();
if ( mPlaybackRemoteCommand.mFrameNumber == 0 )
{
mPlaybackRemoteCommand.release();
delete mPlaybackRemoteCommands;
mPlaybackRemoteCommands = NULL;
}
else
{
mPlaybackRemoteCommand.mArgc = mPlaybackRemoteCommands->readDword();
for (uint32_t i=0; i<mPlaybackRemoteCommand.mArgc; i++)
{
uint32_t len = mPlaybackRemoteCommands->readDword();
mPlaybackRemoteCommand.mArgv[i] = static_cast<const char *>(PX_ALLOC(len,"PlaybackRemoteCommand"));
uint32_t rbytes = mPlaybackRemoteCommands->read(reinterpret_cast<void *>(const_cast<char*>(mPlaybackRemoteCommand.mArgv[i])),len);
if ( rbytes != len )
{
mPlaybackRemoteCommand.release();
delete mPlaybackRemoteCommands;
mPlaybackRemoteCommands = NULL;
}
}
}
}
/**
\brief Returns any incoming input event for processing purposes
*/
virtual const InputEvent *getInputEvent(bool flush)
{
const InputEvent *ret = NULL;
if ( mClientServer )
{
ret = mClientServer->getInputEvent(flush);
}
return ret;
}
/**
\brief Set the base file name to record communications stream; or NULL to disable it.
\param fileName The base name of the file to record the communications channel stream to, or NULL to disable it.
*/
virtual bool setStreamFilename(const char *fileName)
{
bool ret = false;
if ( mClientServer )
{
ret = mClientServer->setStreamFilename(fileName);
}
return ret;
}
/**
\brief Begin playing back a communications stream recording
\param fileName The name of the previously captured communications stream file
*/
virtual bool setStreamPlayback(const char *fileName)
{
bool ret = false;
if ( mClientServer )
{
ret = mClientServer->setStreamPlayback(fileName);
}
return ret;
}
uint32_t mCurrentFrame;
uint32_t mMeshId;
physx::shdfnd::Mutex mMutex;
ClientServer *mClientServer;
RenderDebug::Desc mDesc;
bool mIsValid;
RENDER_DEBUG::RenderDebugInterface *mApexRenderDebug;
RENDER_DEBUG::RenderDebugImpl *mRenderDebug;
RENDER_DEBUG::FileRenderDebug *mFileRenderDebug;
RENDER_DEBUG::ProcessRenderDebug *mInternalProcessRenderDebug;
EchoRemoteCommand mCurrentCommand;
EchoRemoteCommandVector mEchoRemoteCommandBuffer;
GetArgs mParser;
physx::PsFileBuffer *mRecordRemoteCommands;
bool mEndianSwap;
physx::PsFileBuffer *mPlaybackRemoteCommands;
bool mReadNext;
PlaybackRemoteCommand mPlaybackRemoteCommand;
};
RENDER_DEBUG::RenderDebug *createRenderDebug(RENDER_DEBUG::RenderDebug::Desc &desc)
{
RENDER_DEBUG::RenderDebug *ret = NULL;
if ( desc.versionNumber != RENDER_DEBUG_VERSION || desc.foundation == NULL)
{
return NULL;
}
RENDER_DEBUG::RenderDebugIImpl *c = PX_NEW(RENDER_DEBUG::RenderDebugIImpl)(desc);
if ( !c->isValid() )
{
c->release();
c = NULL;
}
else
{
ret = static_cast< RENDER_DEBUG::RenderDebug *>(c->getRenderDebugTyped());
}
return ret;
}
void finalRelease(RENDER_DEBUG::RenderDebugIImpl *nv)
{
delete nv;
}
} // end of namespace
|