Skip to content

Commit 1cc6a1e

Browse files
committed
Remove 'replay-new' C wrapper, complete C++ wrapper, tweak build.rs
1 parent f585075 commit 1cc6a1e

File tree

15 files changed

+539
-91
lines changed

15 files changed

+539
-91
lines changed

renderdoc_sys/build.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ fn main() {
4141
.whitelist_type("pRENDERDOC_.*")
4242
.whitelist_type("ReplayStatus")
4343
.whitelist_type("Shader.*")
44-
.whitelist_type("TargetControl.*")
4544
.whitelist_type("Texture.*")
4645
.whitelist_type("Window.*")
4746
.whitelist_type("XCBWindowData")
@@ -50,9 +49,11 @@ fn main() {
5049
// Custom wrapper types.
5150
.whitelist_type("Camera")
5251
.whitelist_type("CaptureFile")
52+
.whitelist_type("RemoteServer")
5353
.whitelist_type("ReplayController")
54+
.whitelist_type("ReplayOutput")
5455
.whitelist_type("TargetControl")
55-
.opaque_type("Camera")
56+
// .opaque_type("Camera")
5657
.generate_inline_functions(true)
5758
.generate()
5859
.expect("Unable to generate replay bindings!");
@@ -63,8 +64,12 @@ fn main() {
6364

6465
cc::Build::new()
6566
.include("replay")
67+
.include("renderdoc")
6668
.file("replay/src/Camera.cpp")
6769
.file("replay/src/CaptureFile.cpp")
70+
.file("replay/src/RemoteServer.cpp")
71+
.file("replay/src/ReplayController.cpp")
72+
.file("replay/src/ReplayOutput.cpp")
6873
.file("replay/src/TargetControl.cpp")
6974
.define("RENDERDOC_PLATFORM_LINUX", None)
7075
.define("RENDERDOC_WINDOWING_XLIB", None)

renderdoc_sys/replay-new/include/camera.h

Lines changed: 0 additions & 42 deletions
This file was deleted.

renderdoc_sys/replay-new/include/float_vector.h

Lines changed: 0 additions & 23 deletions
This file was deleted.

renderdoc_sys/replay-new/wrapper.h

Lines changed: 0 additions & 6 deletions
This file was deleted.

renderdoc_sys/replay/include/CaptureFile.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55

66
#include "../../renderdoc/renderdoc/api/replay/basic_types.h"
77

8-
typedef uint8_t byte;
9-
10-
enum class FileType : uint32_t;
118
class ReplayController;
129
enum class ReplayStatus : uint32_t;
1310
enum class ReplaySupport : uint32_t;
@@ -24,7 +21,7 @@ class CaptureFile {
2421
const char *DriverName();
2522
const char *RecordedMachineIdent();
2623

27-
rdctype::pair<ReplayStatus, ReplayController> OpenCapture(float *progress);
24+
rdctype::pair<ReplayStatus, ReplayController*> OpenCapture(float *progress);
2825
rdctype::array<byte> GetThumbnail(FileType type, uint32_t maxsize);
2926

3027
private:
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#ifndef REMOTE_SERVER_H
2+
#define REMOTE_SERVER_H
3+
4+
#include <cstdint>
5+
6+
#include "../../renderdoc/renderdoc/api/replay/replay_enums.h"
7+
8+
struct CaptureOptions;
9+
struct EnvironmentModification;
10+
struct PathEntry;
11+
class ReplayController;
12+
13+
class RemoteServer {
14+
public:
15+
static void BecomeRemoteServer(const char *listenhost, uint32_t port,
16+
uint32_t *kill);
17+
18+
static uint32_t ExecuteAndInject(
19+
const char *app,
20+
const char *workingDir,
21+
const char *cmdLine,
22+
const rdctype::array<EnvironmentModification> &env,
23+
const char *logfile,
24+
const CaptureOptions &opts,
25+
bool32 waitForExit
26+
);
27+
28+
static uint32_t GetDefaultRemoteServerPort();
29+
30+
RemoteServer(const char *host, uint32_t port);
31+
~RemoteServer();
32+
33+
void ShutdownConnection();
34+
bool Ping();
35+
36+
rdctype::array<rdctype::str> LocalProxies();
37+
rdctype::array<rdctype::str> RemoteSupportedReplays();
38+
39+
rdctype::str GetHomeFolder();
40+
rdctype::array<PathEntry> ListFolder(const char *path);
41+
42+
void TakeOwnershipCapture(const char *filename);
43+
rdctype::str CopyCaptureToRemote(const char *filename, float *progress);
44+
void CopyCaptureFromRemote(const char *remotepath, const char *localpath,
45+
float *progress);
46+
47+
rdctype::pair<ReplayStatus, ReplayController*> OpenCapture(
48+
uint32_t proxyid,
49+
const char *logfile,
50+
float *progress
51+
);
52+
53+
void CloseCapture(ReplayController *ctrl);
54+
55+
static const uint32_t NoPreference = ~0U;
56+
57+
private:
58+
void ShutdownServerAndConnection();
59+
60+
class IRemoteServer *inner;
61+
};
62+
63+
#endif // REMOTE_SERVER_H

renderdoc_sys/replay/include/ReplayController.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33

44
#include <cstdint>
55

6-
#include "../../renderdoc/renderdoc/api/replay/basic_types.h"
7-
#include "../../renderdoc/renderdoc/api/replay/d3d11_pipestate.h"
8-
#include "../../renderdoc/renderdoc/api/replay/d3d12_pipestate.h"
9-
#include "../../renderdoc/renderdoc/api/replay/gl_pipestate.h"
10-
#include "../../renderdoc/renderdoc/api/replay/shader_types.h"
11-
#include "../../renderdoc/renderdoc/api/replay/vk_pipestate.h"
12-
136
class ReplayOutput;
147

158
class ReplayController {
@@ -117,6 +110,9 @@ class ReplayController {
117110
~ReplayController() = default;
118111

119112
private:
113+
friend class CaptureFile;
114+
friend class RemoteServer;
115+
120116
class IReplayController *inner;
121117
};
122118

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#ifndef REPLAY_OUTPUT_H
2+
#define REPLAY_OUTPUT_H
3+
4+
#include "../../renderdoc/renderdoc/api/replay/control_types.h"
5+
6+
class ReplayOutput {
7+
public:
8+
void SetTextureDisplay(const TextureDisplay &o);
9+
void SetMeshDisplay(const MeshDisplay &o);
10+
11+
void ClearThumbnails();
12+
bool AddThumbnail(WindowingSystem system, void *data, ResourceId texID,
13+
CompType typeHint);
14+
15+
void Display();
16+
17+
bool SetPixelContext(WindowingSystem system, void *data);
18+
void SetPixelContextLocation(uint32_t x, uint32_t y);
19+
void DisablePixelContext();
20+
21+
rdctype::pair<PixelValue, PixelValue> GetMinMax();
22+
rdctype::array<uint32_t> GetHistogram(float minval, float maxval,
23+
bool channels[4]);
24+
25+
ResourceId GetCustomShaderTexID();
26+
ResourceId GetDebugOverlayTexID();
27+
28+
PixelValue PickPixel(ResourceId texID, bool customShader, uint32_t x,
29+
uint32_t y, uint32_t sliceFace, uint32_t mip,
30+
uint32_t sample);
31+
32+
rdctype::pair<uint32_t, uint32_t> PickVertex(uint32_t eventID, uint32_t x,
33+
uint32_t y);
34+
35+
static const uint32_t NoResult = ~0U;
36+
37+
protected:
38+
friend class ReplayController;
39+
40+
ReplayOutput() = default;
41+
~ReplayOutput() = default;
42+
43+
private:
44+
class IReplayOutput *inner;
45+
};
46+
47+
#endif // REPLAY_OUTPUT_H

renderdoc_sys/replay/include/TargetControl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class TargetControlMessage;
77

88
class TargetControl {
99
public:
10+
static uint32_t EnumerateRemoteTargets(const char *host, uint32_t nextIdent);
11+
1012
TargetControl(const char *host, uint32_t ident, const char *clientName,
1113
bool forceConnection);
1214
~TargetControl();

renderdoc_sys/replay/src/CaptureFile.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ const char *CaptureFile::RecordedMachineIdent() {
3131
return this->inner->RecordedMachineIdent();
3232
}
3333

34-
rdctype::pair<ReplayStatus, ReplayController> CaptureFile::OpenCapture(float *progress) {
34+
rdctype::pair<ReplayStatus, ReplayController*> CaptureFile::OpenCapture(
35+
float *progress
36+
) {
3537
auto result = this->inner->OpenCapture(progress);
38+
3639
if (result.first == ReplayStatus::Succeeded) {
37-
40+
ReplayController *ctrl = new ReplayController;
41+
ctrl->inner = result.second;
42+
return { result.first, ctrl };
3843
}
44+
45+
return { result.first, NULL };
3946
}
4047

4148
rdctype::array<byte> CaptureFile::GetThumbnail(FileType type, uint32_t maxsize) {
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#include "../../renderdoc/renderdoc/api/replay/renderdoc_replay.h"
2+
3+
#include "../include/RemoteServer.h"
4+
#include "../include/ReplayController.h"
5+
6+
void RemoteServer::BecomeRemoteServer(
7+
const char *listenhost,
8+
uint32_t port,
9+
uint32_t *killReplay
10+
) {
11+
RENDERDOC_BecomeRemoteServer(listenhost, port, killReplay);
12+
}
13+
14+
uint32_t RemoteServer::ExecuteAndInject(
15+
const char *app,
16+
const char *workingDir,
17+
const char *cmdLine,
18+
const rdctype::array<EnvironmentModification> &env,
19+
const char *logfile,
20+
const CaptureOptions &opts,
21+
bool32 waitForExit
22+
) {
23+
return RENDERDOC_ExecuteAndInject(
24+
app, workingDir, cmdLine, env, logfile, opts, waitForExit
25+
);
26+
}
27+
28+
uint32_t RemoteServer::GetDefaultRemoteServerPort() {
29+
return RENDERDOC_GetDefaultRemoteServerPort();
30+
}
31+
32+
RemoteServer::RemoteServer(const char *host, uint32_t port) {
33+
RENDERDOC_CreateRemoteServerConnection(host, port, &this->inner);
34+
}
35+
36+
RemoteServer::~RemoteServer() {
37+
this->inner->ShutdownServerAndConnection();
38+
}
39+
40+
void RemoteServer::ShutdownConnection() {
41+
this->inner->ShutdownConnection();
42+
}
43+
44+
bool RemoteServer::Ping() {
45+
return this->inner->Ping();
46+
}
47+
48+
rdctype::array<rdctype::str> RemoteServer::LocalProxies() {
49+
return this->inner->LocalProxies();
50+
}
51+
52+
rdctype::array<rdctype::str> RemoteServer::RemoteSupportedReplays() {
53+
return this->inner->RemoteSupportedReplays();
54+
}
55+
56+
rdctype::str RemoteServer::GetHomeFolder() {
57+
return this->inner->GetHomeFolder();
58+
}
59+
60+
rdctype::array<PathEntry> RemoteServer::ListFolder(const char *path) {
61+
return this->inner->ListFolder(path);
62+
}
63+
64+
void RemoteServer::TakeOwnershipCapture(const char *filename) {
65+
this->inner->TakeOwnershipCapture(filename);
66+
}
67+
68+
rdctype::str RemoteServer::CopyCaptureToRemote(const char *filename,
69+
float *progress)
70+
{
71+
return this->inner->CopyCaptureToRemote(filename, progress);
72+
}
73+
74+
void RemoteServer::CopyCaptureFromRemote(
75+
const char *remotepath,
76+
const char *localpath,
77+
float *progress
78+
) {
79+
this->inner->CopyCaptureFromRemote(remotepath, localpath, progress);
80+
}
81+
82+
rdctype::pair<ReplayStatus, ReplayController*> RemoteServer::OpenCapture(
83+
uint32_t proxyid,
84+
const char *logfile,
85+
float *progress
86+
) {
87+
auto result = this->inner->OpenCapture(proxyid, logfile, progress);
88+
89+
if (result.first == ReplayStatus::Succeeded) {
90+
ReplayController *ctrl = new ReplayController;
91+
ctrl->inner = result.second;
92+
return { result.first, ctrl };
93+
}
94+
95+
return { result.first, NULL };
96+
}
97+
98+
void RemoteServer::CloseCapture(ReplayController *ctrl) {
99+
this->inner->CloseCapture(ctrl->inner);
100+
}
101+
102+
void RemoteServer::ShutdownServerAndConnection() {
103+
this->inner->ShutdownServerAndConnection();
104+
}

0 commit comments

Comments
 (0)