Skip to content

Commit 0c16fb3

Browse files
committed
Merge remote-tracking branch 'upstream/master' into meshcomponent-renderlayer
2 parents d8e62de + 529b8b8 commit 0c16fb3

1,089 files changed

Lines changed: 97674 additions & 19448 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,7 @@ dotnet_naming_style.s_camelcase.word_separator =
375375
dotnet_naming_style.s_camelcase.capitalization = camel_case
376376

377377
# RS2008: Enable analyzer release tracking
378-
dotnet_diagnostic.RS2008.severity = suggestion
378+
dotnet_diagnostic.RS2008.severity = suggestion
379+
dotnet_diagnostic.CA2000.severity = error
380+
# Ugh... but trying to enforce this on textures is a lost cause
381+
dotnet_code_quality.CA2000.excluded_symbol_names = Texture

.github/workflows/pull_request.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
with:
1414
github-token: ${{ secrets.GITHUB_TOKEN }}
1515
script: |
16-
const requiredChecks = ['Tests', 'Formatting'];
16+
const requiredChecks = ['format', 'tests'];
1717
1818
const pr = context.payload.pull_request;
1919
if (!pr) {
@@ -33,16 +33,8 @@ jobs:
3333
3434
if (!match || match.conclusion !== 'success') {
3535
const status = match ? (match.conclusion ?? match.status ?? 'unknown') : 'missing';
36-
core.warning(`Required check '${requiredCheck}' did not pass (${status}). Removing triaged label.`);
37-
38-
await github.rest.issues.removeLabel({
39-
owner: context.repo.owner,
40-
repo: context.repo.repo,
41-
issue_number: pr.number,
42-
name: 'triaged'
43-
});
44-
45-
throw new Error('Cannot triage until required checks succeed.');
36+
core.warning(`Required check '${requiredCheck}' did not pass (${status}).`);
37+
throw new Error('Cannot triage until required checks succeed. Remove and re-add the triaged label to retry.');
4638
}
4739
}
4840

.github/workflows/pull_request_checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ permissions:
88
contents: read
99

1010
jobs:
11-
format:
11+
tests:
1212
runs-on: [ windows-latest ]
1313
steps:
1414
- name: Full Checkout

engine/Benchmark/Benchmarks/ByteStream.cs

Lines changed: 213 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,87 @@
88

99

1010
[MemoryDiagnoser]
11-
[ThreadingDiagnoser]
1211
public class ByteStreamTest
1312
{
1413
Guid Guid = Guid.NewGuid();
1514
byte[] byteBuffer = new byte[34];
16-
int initialBuffer = 512;
15+
byte[] readByteBuffer = new byte[34];
16+
int initialBuffer = 4096;
17+
byte[] intData = Array.Empty<byte>();
18+
byte[] byteData = Array.Empty<byte>();
19+
byte[] guidData = Array.Empty<byte>();
20+
byte[] stringData = Array.Empty<byte>();
1721

1822
[GlobalSetup]
1923
public void Setup()
2024
{
25+
{
26+
var writer = ByteStream.Create( initialBuffer );
27+
try
28+
{
29+
for ( int i = 0; i < 512; i++ )
30+
{
31+
writer.Write( i );
32+
}
33+
34+
intData = writer.ToArray();
35+
}
36+
finally
37+
{
38+
writer.Dispose();
39+
}
40+
}
41+
42+
{
43+
var writer = ByteStream.Create( initialBuffer );
44+
try
45+
{
46+
for ( int i = 0; i < 512; i++ )
47+
{
48+
writer.Write( byteBuffer );
49+
}
50+
51+
byteData = writer.ToArray();
52+
}
53+
finally
54+
{
55+
writer.Dispose();
56+
}
57+
}
58+
59+
{
60+
var writer = ByteStream.Create( initialBuffer );
61+
try
62+
{
63+
for ( int i = 0; i < 512; i++ )
64+
{
65+
writer.Write( Guid );
66+
}
2167

68+
guidData = writer.ToArray();
69+
}
70+
finally
71+
{
72+
writer.Dispose();
73+
}
74+
}
75+
76+
{
77+
var writer = ByteStream.Create( initialBuffer );
78+
try
79+
{
80+
for ( int i = 0; i < 512; i++ )
81+
{
82+
writer.Write( "Hello there" );
83+
}
84+
85+
stringData = writer.ToArray();
86+
}
87+
finally
88+
{
89+
writer.Dispose();
90+
}
91+
}
2292
}
2393

2494
[Benchmark]
@@ -65,6 +135,63 @@ public void ByteStreamString()
65135
}
66136
}
67137

138+
[Benchmark]
139+
public int ByteStreamReadInt()
140+
{
141+
using var reader = ByteStream.CreateReader( intData );
142+
int sum = 0;
143+
144+
for ( int i = 0; i < 512; i++ )
145+
{
146+
sum += reader.Read<int>();
147+
}
148+
149+
return sum;
150+
}
151+
152+
[Benchmark]
153+
public int ByteStreamReadByte()
154+
{
155+
using var reader = ByteStream.CreateReader( byteData );
156+
int sum = 0;
157+
for ( int i = 0; i < 512; i++ )
158+
{
159+
reader.Read( readByteBuffer, 0, readByteBuffer.Length );
160+
sum += readByteBuffer[0];
161+
}
162+
163+
return sum;
164+
}
165+
166+
[Benchmark]
167+
public int ByteStreamReadGuid()
168+
{
169+
using var reader = ByteStream.CreateReader( guidData );
170+
int hash = 0;
171+
172+
for ( int i = 0; i < 512; i++ )
173+
{
174+
hash ^= reader.Read<Guid>().GetHashCode();
175+
}
176+
177+
return hash;
178+
}
179+
180+
[Benchmark]
181+
public int ByteStreamReadString()
182+
{
183+
using var reader = ByteStream.CreateReader( stringData );
184+
int totalLength = 0;
185+
186+
for ( int i = 0; i < 512; i++ )
187+
{
188+
var value = reader.Read<string>();
189+
totalLength += value?.Length ?? 0;
190+
}
191+
192+
return totalLength;
193+
}
194+
68195
[Benchmark]
69196
public void PooledMemoryStreamInt()
70197
{
@@ -173,3 +300,87 @@ protected override void Dispose( bool disposing )
173300
}
174301

175302
}
303+
304+
[MemoryDiagnoser]
305+
public class ByteStreamPoolingBenchmarks
306+
{
307+
const int BatchSize = 100;
308+
readonly int[] randomInitialSizes = new int[BatchSize];
309+
readonly byte[][] payloads = new byte[BatchSize][];
310+
readonly byte[] mediumPayload = new byte[4096];
311+
readonly byte[] largePayload = new byte[64 * 1024];
312+
313+
[GlobalSetup]
314+
public void Setup()
315+
{
316+
var rng = new Random( 42 );
317+
318+
for ( int i = 0; i < BatchSize; i++ )
319+
{
320+
// Keep sizes inside typical pool buckets to surface contention
321+
var size = rng.Next( 64, 64 * 1024 );
322+
randomInitialSizes[i] = size;
323+
324+
var payloadLength = rng.Next( 16, 512 );
325+
var payload = new byte[payloadLength];
326+
rng.NextBytes( payload );
327+
payloads[i] = payload;
328+
}
329+
330+
rng.NextBytes( mediumPayload );
331+
rng.NextBytes( largePayload );
332+
}
333+
334+
[Benchmark( Description = "Create 100 random streams sequentially" )]
335+
public void CreateRandomBatchSequential()
336+
{
337+
for ( int i = 0; i < BatchSize; i++ )
338+
{
339+
using var stream = ByteStream.Create( randomInitialSizes[i] );
340+
stream.Write( payloads[i] );
341+
}
342+
}
343+
344+
[Benchmark( Description = "Hold 100 random streams simultaneously" )]
345+
public void CreateRandomBatchHeld()
346+
{
347+
CreateBatchRecursive( 0 );
348+
}
349+
350+
[Benchmark( Description = "Stress growth with large payload writes" )]
351+
public int LargePayloadWriteAndCopy()
352+
{
353+
using var stream = ByteStream.Create( 128 );
354+
355+
for ( int i = 0; i < 8; i++ )
356+
{
357+
stream.Write( largePayload );
358+
}
359+
360+
return stream.ToArray().Length;
361+
}
362+
363+
[Benchmark( Description = "Rapid reuse of pooled buffers" )]
364+
public void RapidReuseMixedSizes()
365+
{
366+
for ( int i = 0; i < BatchSize; i++ )
367+
{
368+
using var stream = ByteStream.Create( 256 );
369+
stream.Write( mediumPayload );
370+
stream.Write( payloads[i] );
371+
}
372+
}
373+
374+
void CreateBatchRecursive( int index )
375+
{
376+
if ( index >= BatchSize )
377+
{
378+
return;
379+
}
380+
381+
using var stream = ByteStream.Create( randomInitialSizes[index] );
382+
stream.Write( payloads[index] );
383+
384+
CreateBatchRecursive( index + 1 );
385+
}
386+
}

engine/Benchmark/Benchmarks/MemoryAlloc.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,4 @@ public void NativeMemoryAlloc()
4343
var data = NativeMemory.Alloc( allocSize );
4444
NativeMemory.Free( data );
4545
}
46-
47-
[Benchmark]
48-
public void NativeMemoryBlock()
49-
{
50-
using var ptr = Sandbox.NativeMemoryBlock.GetOrCreatePooled( allocSize );
51-
}
52-
5346
}

engine/Definitions/common/Physics/IPhysicsBody.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,8 @@ native class IPhysicsBody as NativeEngine.IPhysicsBody
123123
bool IsTouching( IPhysicsShape pShape, bool bTriggers );
124124

125125
void SetTrigger( bool trigger );
126+
127+
void ResetProxy();
128+
129+
void SetBullet( bool bEnabled );
126130
}

engine/Definitions/common/Physics/IPhysicsShape.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,6 @@ native class IPhysicsShape as NativeEngine.IPhysicsShape
8383
}
8484

8585
bool IsTouching( IPhysicsShape pShape, bool bTriggers );
86+
87+
void ResetProxy();
8688
}

engine/Definitions/common/Physics/IPhysicsWorld.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ native class IPhysicsWorld
4444
IPhysicsJoint AddSphericalJoint( IPhysicsBody pBody1, IPhysicsBody pBody2, Transform localFrame1, Transform localFrame2 );
4545
IPhysicsJoint AddMotorJoint( IPhysicsBody pBody1, IPhysicsBody pBody2, Transform localFrame1, Transform localFrame2 );
4646
IPhysicsJoint AddWheelJoint( IPhysicsBody pBody1, IPhysicsBody pBody2, Transform localFrame1, Transform localFrame2 );
47+
IPhysicsJoint AddFilterJoint( IPhysicsBody pBody1, IPhysicsBody pBody2 );
4748

4849
//
4950
// Sets the collision rules using a json serialized Sandbox.Internal.CollisionRules

engine/Definitions/common/Render/Graphics.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ managed static class Sandbox.Rendering.RenderPipeline
2020
{
2121
void InternalAddLayersToView( ISceneView view, RenderViewport viewport, HSceneViewRenderTarget hColor, HSceneViewRenderTarget hDepth, RenderMultisampleType nMSAA, CRenderAttributes pipelineAttributes, RenderViewport screenDimensions );
2222
void InternalPipelineEnd( ISceneView view, RenderViewport viewport, HSceneViewRenderTarget hColor, HSceneViewRenderTarget hDepth, RenderMultisampleType nMSAA, CRenderAttributes pipelineAttributes, RenderViewport screenDimensions );
23+
}
24+
25+
managed static class Sandbox.Rendering.Skybox3DPipeline
26+
{
27+
void InternalAddLayersToView( ISceneView view, RenderViewport viewport, HSceneViewRenderTarget hColor, HSceneViewRenderTarget hDepth, CRenderAttributes pipelineAttributes );
2328
}

engine/Definitions/common/SceneSystem/ISceneLayer.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ native class ISceneLayer as NativeEngine.ISceneLayer
3131
}
3232

3333
void SetAttr( StringToken nTokenID, HSceneViewRenderTarget hRenderTarget, SceneLayerMSAAMode_t msaa, uint flags );
34+
void SetLayerNoCull( bool enabled );
3435

3536
void SetBoundingVolumeSizeCullThresholdInPercent( float flSizeCullThreshold );
3637

0 commit comments

Comments
 (0)