Skip to content

Commit 57f5c5a

Browse files
committed
Many other places with C++ code
1 parent 61b2e8c commit 57f5c5a

File tree

12 files changed

+343
-51
lines changed

12 files changed

+343
-51
lines changed

articles/remote-rendering/concepts/graphics-bindings.md

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ RemoteManagerStatic.StartupRemoteRendering(managerInit);
3939
```
4040

4141
```cpp
42-
TODO
42+
RemoteRenderingInitialization managerInit;
43+
managerInit.graphicsApi = GraphicsApiType::WmrD3D11;
44+
managerInit.connectionType = ConnectionType::General;
45+
managerInit.right = ///...
46+
StartupRemoteRendering(managerInit); // static function in namespace Microsoft::Azure::RemoteRendering
4347
```
4448
4549
The call above is necessary to initialize Azure Remote Rendering into the holographic APIs. This function must be called before any holographic API is called and before any other Remote Rendering APIs are accessed. Similarly, the corresponding de-init function `RemoteManagerStatic.ShutdownRemoteRendering();` should be called after no holographic APIs are being called anymore.
@@ -49,19 +53,27 @@ The call above is necessary to initialize Azure Remote Rendering into the hologr
4953
Once a client is set up, the basic graphics binding can be accessed with the `AzureSession.GraphicsBinding` getter. As an example, the last frame statistics can be retrieved like this:
5054
5155
```cs
52-
AzureSession currentSesson = ...;
53-
if (currentSesson.GraphicsBinding)
56+
AzureSession currentSession = ...;
57+
if (currentSession.GraphicsBinding)
5458
{
5559
FrameStatistics frameStatistics;
56-
if (session.GraphicsBinding.GetLastFrameStatistics(out frameStatistics) == Result.Success)
60+
if (currentSession.GraphicsBinding.GetLastFrameStatistics(out frameStatistics) == Result.Success)
5761
{
5862
...
5963
}
6064
}
6165
```
6266

6367
```cpp
64-
TODO
68+
ApiHandle<AzureSession> currentSession = ...;
69+
if (ApiHandle<GraphicsBinding> binding = currentSession->GetGraphicsBinding())
70+
{
71+
FrameStatistics frameStatistics;
72+
if (*binding->GetLastFrameStatistics(&frameStatistics) == Result::Success)
73+
{
74+
...
75+
}
76+
}
6577
```
6678

6779
## Graphic APIs
@@ -78,17 +90,23 @@ There are two things that need to be done to use the WMR binding:
7890
#### Inform Remote Rendering of the used coordinate system
7991

8092
```cs
81-
AzureSession currentSesson = ...;
93+
AzureSession currentSession = ...;
8294
IntPtr ptr = ...; // native pointer to ISpatialCoordinateSystem
8395
GraphicsBindingWmrD3d11 wmrBinding = (currentSession.GraphicsBinding as GraphicsBindingWmrD3d11);
84-
if (binding.UpdateUserCoordinateSystem(ptr) == Result.Success)
96+
if (wmrBinding.UpdateUserCoordinateSystem(ptr) == Result.Success)
8597
{
8698
...
8799
}
88100
```
89101

90102
```cpp
91-
TODO
103+
ApiHandle<AzureSession> currentSession = ...;
104+
void* ptr = ...; // native pointer to ISpatialCoordinateSystem
105+
ApiHandle<GraphicsBindingWmrD3d11> wmrBinding = currentSession->GetGraphicsBinding().as<GraphicsBindingWmrD3d11>();
106+
if (*wmrBinding->UpdateUserCoordinateSystem(ptr) == Result::Success)
107+
{
108+
//...
109+
}
92110
```
93111
94112
@@ -99,13 +117,15 @@ Where the above `ptr` must be a pointer to a native `ABI::Windows::Perception::S
99117
At the start of each frame the remote frame needs to be rendered into the back buffer. This is done by calling `BlitRemoteFrame`, which will fill both color and depth information into the currently bound render target. Thus it is important that this is done after binding the back buffer as a render target.
100118
101119
```cs
102-
AzureSession currentSesson = ...;
120+
AzureSession currentSession = ...;
103121
GraphicsBindingWmrD3d11 wmrBinding = (currentSession.GraphicsBinding as GraphicsBindingWmrD3d11);
104-
binding.BlitRemoteFrame();
122+
wmrBinding.BlitRemoteFrame();
105123
```
106124

107125
```cpp
108-
TODO
126+
ApiHandle<AzureSession> currentSession = ...;
127+
ApiHandle<GraphicsBindingWmrD3d11> wmrBinding = currentSession->GetGraphicsBinding().as<GraphicsBindingWmrD3d11>();
128+
wmrBinding->BlitRemoteFrame();
109129
```
110130

111131
### Simulation
@@ -119,7 +139,7 @@ Remote and local content needs to be rendered to an offscreen color / depth rend
119139
the proxy camera data provided by the `GraphicsBindingSimD3d11.Update` function. The proxy must match the resolution of the back buffer. Once a session is ready, `GraphicsBindingSimD3d11.InitSimulation` needs to be called before connecting to it:
120140

121141
```cs
122-
AzureSession currentSesson = ...;
142+
AzureSession currentSession = ...;
123143
IntPtr d3dDevice = ...; // native pointer to ID3D11Device
124144
IntPtr color = ...; // native pointer to ID3D11Texture2D
125145
IntPtr depth = ...; // native pointer to ID3D11Texture2D
@@ -131,7 +151,15 @@ simBinding.InitSimulation(d3dDevice, depth, color, refreshRate, flipBlitRemoteFr
131151
```
132152

133153
```cpp
134-
TODO
154+
ApiHandle<AzureSession> currentSession = ...;
155+
void* d3dDevice = ...; // native pointer to ID3D11Device
156+
void* color = ...; // native pointer to ID3D11Texture2D
157+
void* depth = ...; // native pointer to ID3D11Texture2D
158+
float refreshRate = 60.0f; // Monitor refresh rate up to 60hz.
159+
bool flipBlitRemoteFrameTextureVertically = false;
160+
bool flipReprojectTextureVertically = false;
161+
ApiHandle<GraphicsBindingSimD3d11> simBinding = currentSession->GetGraphicsBinding().as<GraphicsBindingSimD3d11>();
162+
simBinding->InitSimulation(d3dDevice, depth, color, refreshRate, flipBlitRemoteFrameTextureVertically, flipReprojectTextureVertically);
135163
```
136164
137165
The init function needs to be provided with pointers to the native d3d-device as well as to the color and depth texture of the proxy render target. Once initialized, `AzureSession.ConnectToRuntime` and `DisconnectFromRuntime` can be called multiple times but when switching to a different session, `GraphicsBindingSimD3d11.DeinitSimulation` needs to be called first on the old session before `GraphicsBindingSimD3d11.InitSimulation` can be called on another session.
@@ -146,7 +174,7 @@ If the returned proxy update `SimulationUpdate.frameId` is null, there is no rem
146174
1. Next, the back buffer needs to be bound as a render target and `GraphicsBindingSimD3d11.ReprojectProxy` called at which point the back buffer can be presented.
147175
148176
```cs
149-
AzureSession currentSesson = ...;
177+
AzureSession currentSession = ...;
150178
GraphicsBindingSimD3d11 simBinding = (currentSession.GraphicsBinding as GraphicsBindingSimD3d11);
151179
SimulationUpdate update = new SimulationUpdate();
152180
// Fill out camera data with current camera data
@@ -172,7 +200,30 @@ else
172200
```
173201

174202
```cpp
175-
TODO
203+
ApiHandle<AzureSession> currentSession;
204+
ApiHandle<GraphicsBindingSimD3d11> simBinding = currentSession->GetGraphicsBinding().as<GraphicsBindingSimD3d11>();
205+
206+
SimulationUpdate update;
207+
// Fill out camera data with current camera data
208+
...
209+
SimulationUpdate proxyUpdate;
210+
simBinding->Update(update, &proxyUpdate);
211+
// Is the frame data valid?
212+
if (proxyUpdate.frameId != 0)
213+
{
214+
// Bind proxy render target
215+
simBinding->BlitRemoteFrameToProxy();
216+
// Use proxy camera data to render local content
217+
...
218+
// Bind back buffer
219+
simBinding->ReprojectProxy();
220+
}
221+
else
222+
{
223+
// Bind back buffer
224+
// Use current camera data to render local content
225+
...
226+
}
176227
```
177228
178229
## Next steps

articles/remote-rendering/concepts/materials.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,31 @@ void SetMaterialColorToGreen(Material material)
4545
}
4646

4747
PbrMaterial pbrMat = material as PbrMaterial;
48-
if( pbrMat!= null )
48+
if (pbrMat != null)
4949
{
50-
PbrMaterial pbrMaterial = material.PbrMaterial.Value;
51-
pbrMaterial.AlbedoColor = new Color4(0, 1, 0, 1);
50+
pbrMat.AlbedoColor = new Color4(0, 1, 0, 1);
5251
return;
5352
}
5453
}
5554
```
5655

5756
```cpp
58-
TODO
57+
void SetMaterialColorToGreen(ApiHandle<Material> material)
58+
{
59+
if (*material->MaterialSubType() == MaterialType::Color)
60+
{
61+
ApiHandle<ColorMaterial> colorMaterial = material.as<ColorMaterial>();
62+
colorMaterial->AlbedoColor({ 0, 1, 0, 1 });
63+
return;
64+
}
65+
66+
if (*material->MaterialSubType() == MaterialType::Pbr)
67+
{
68+
ApiHandle<PbrMaterial> pbrMat = material.as<PbrMaterial>();
69+
pbrMat->AlbedoColor({ 0, 1, 0, 1 });
70+
return;
71+
}
72+
}
5973
```
6074
6175

articles/remote-rendering/concepts/object-bounds.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,21 @@ public void GetBounds(Entity entity)
3838
```
3939

4040
```cpp
41-
TODO
41+
void GetBounds(ApiHandle<Entity> entity)
42+
{
43+
ApiHandle<BoundsQueryAsync> boundsQuery = *entity->QueryWorldBoundsAsync();
44+
boundsQuery->Completed([](ApiHandle<BoundsQueryAsync> bounds)
45+
{
46+
if (bounds->IsRanToCompletion())
47+
{
48+
Double3 aabbMin = bounds->Result()->min;
49+
Double3 aabbMax = bounds->Result()->max;
50+
// ...
51+
}
52+
});
53+
}
4254
```
4355
44-
4556
## Next steps
4657
4758
* [Spatial queries](../overview/features/spatial-queries.md)

articles/remote-rendering/concepts/sessions.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ await session.StopAsync().AsTask();
131131
RemoteManagerStatic.ShutdownRemoteRendering();
132132
```
133133

134-
```cpp
135-
TODO
136-
```
137-
138-
139134
Multiple `AzureFrontend` and `AzureSession` instances can be maintained, manipulated, and queried from code. But only a single device may connect to an `AzureSession` at a time.
140135

141136
The lifetime of a virtual machine isn't tied to the `AzureFrontend` instance or the `AzureSession` instance. `AzureSession.StopAsync` must be called to stop a session.

articles/remote-rendering/concepts/textures.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The following sample code shows how to load a texture via its SAS URI (or built-
3838
LoadTextureAsync _textureLoad = null;
3939
void LoadMyTexture(AzureSession session, string textureUri)
4040
{
41-
_textureLoad = session.Actions.LoadTextureAsync(new LoadTextureParams(textureUri, TextureType.Texture2D));
41+
_textureLoad = session.Actions.LoadTextureFromSASAsync(new LoadTextureFromSASParams(textureUri, TextureType.Texture2D));
4242
_textureLoad.Completed +=
4343
(LoadTextureAsync res) =>
4444
{
@@ -56,7 +56,24 @@ void LoadMyTexture(AzureSession session, string textureUri)
5656
```
5757

5858
```cpp
59-
TODO
59+
void LoadMyTexture(ApiHandle<AzureSession> session, std::string textureUri)
60+
{
61+
LoadTextureFromSASParams params;
62+
params.TextureType = TextureType::Texture2D;
63+
params.TextureUrl = std::move(textureUri);
64+
ApiHandle<LoadTextureAsync> textureLoad = *session->Actions()->LoadTextureFromSASAsync(params);
65+
textureLoad->Completed([](ApiHandle<LoadTextureAsync> res)
66+
{
67+
if (res->IsRanToCompletion())
68+
{
69+
//use res->Result()
70+
}
71+
else
72+
{
73+
printf("Texture loading failed!");
74+
}
75+
});
76+
}
6077
```
6178
6279

0 commit comments

Comments
 (0)