#DotNet2018
Desarrollando un motor
gráfico en C# para
Virtual Reality y
Augmented Reality
ORGANIZATION
SPONSORS
#DotNet2018
Thank you!
#DotNet2018
@jcant0n
jcanton@plainconcepts.com
Javier is a Computer Science Engineer who has always had a passion for
3D graphics and software architecture. His professional achievements
include being MVP for Windows DirectX and DirectX XNA for the last
nine years, Xbox Ambassador, as well as Microsoft Student Partner and
Microsoft Most Valuable Student during his years at college. Currently
he works at Plainconcepts as Research Team Lead.
Javier Cantón
Research Team Lead
#DotNet2018
Wave Engine on VR,
AR and MR
#DotNet2018
Wave Engine
• 7 years ago
• Latest C# features
• Unified cross-platform API
• Component-based engine
#DotNet2018
Video
#DotNet2018
C# features to keep in
mind
#DotNet2018
Access Modifiers
• Public
Assembly 1
Assembly 2
Class 1
Class 2
Class 3
#DotNet2018
Access Modifiers
• Public
• Protected
Assembly 1
Assembly 2
Class 1
Class 2
Class 3
#DotNet2018
Access Modifiers
• Public
• Protected
• Internal
Assembly 1
Assembly 2
Class 1
Class 2
Class 3
#DotNet2018
Access Modifiers
• Public
• Protected
• Internal
• Private
Assembly 1
Assembly 2
Class 1
Class 2
Class 3
#DotNet2018
Access Modifiers
• Public
• Protected
• Internal
• Private
• Protected Internal
Assembly 1
Assembly 2
Class 1
Class 2
Class 3
#DotNet2018
Access Modifiers
• Public
• Protected
• Internal
• Private
• Protected Internal
• Private protected
Assembly 1
Assembly 2
Class 3
Class 2
Class 1
#DotNet2018
Explicit interface implementation
#DotNet2018
Explicit interface implementation
#DotNet2018
Stack Heap
Value Type vs Reference Type
Reference Type
Memory Location
Int var = 10
Value Type
Int var = 10
#DotNet2018
Boxing and Unboxing
Stack Heap
#DotNet2018
Stack Heap
Boxing and Unboxing
i (Reference type)
Int i = 4
#DotNet2018
Boxing and Unboxing
Stack Heap
i (Reference type)
4
o (Reference Type)
Memory Location
4
Boxing
Value to Reference
#DotNet2018
Stack Heap
Boxing and Unboxing
i (Value type)
4
o (Reference Type)
Memory Location
4
Unboxing
Reference to value
j (Value type)
4
#DotNet2018
Attributes
• System.Runtime.CompilerServices
• Custom attributes
#DotNet2018
Lazy evaluation or deferred execution
• Not all values needed
• Useful for other datastructs
• Easy to code
#DotNet2018
Writing C# code when
performance is the
most important thing
#DotNet2018
Micro-optimization are for
• BCL and Runtime
• You expect it
• Real Time applications
• Graphics development
• 16 ms per frame
#DotNet2018
Benchmarking best practices
@andrey_akinshin
JetBrainsRider developer
• Warmup
• Cleanup
• Enable compiler optimizations (Release Mode)
• Run benchmarks without an attached debugger
• Run benchmark several times
#DotNet2018
Simple example
• 1920x1080 resolution
• 4x4 nearpixels
• 30 frames per second
• 995.328.000 ~ 1 billion
#DotNet2018
Simple example
119 times faster
#DotNet2018
Loops
#DotNet2018
Loops
#DotNet2018
Loops
#DotNet2018
Inlining
• Do not use throw new
• Do not use virtual
• Less than 32 bytes of IL
• Up to 20% performance
#DotNet2018
#DotNet2018
#DotNet2018
Structs (fields order)
40 bytes 24 bytes
#DotNet2018
Object memory Layout
Byte
Byte
Byte
Double
Double
Byte Byte Byte
Double
Double
#DotNet2018
Repository and builds
#DotNet2018
Repository
• Visual Studio Online
• Git based repository
• Git Flow
• SourceTree
• GitKraken
• Branch Policies
• Develop needs Pull Requests
• Partial Github mirror
#DotNet2018
Builds
• TeamCity connected to VS online
• Agents
• Azure (Linux, Windows)
• MiniMacs (MacOS)
• Fake using F#
• Continue Integration
• New Release
• Nightly builds
• Samples builds
#DotNet2018
Testing
• Visual Tests
• Custom tool
• Pixel based comparison
• Unit tests
• Performance Tests
• DotnetBenchmarks
#DotNet2018
VR/AR/MR devices
#DotNet2018
VR devices
Oculus Rift
HTC Vive Pro
HTC Vive
PlayStation
#DotNet2018
Name Resolution Field Of View Weight Refresh Pricing
Oculus Rift 2160x1200 110 470 grams 90hz $399
HTC Vive 2160x1200 110 555 grams 90hz $439
HTC Vive Pro 2880 x 1600
(615 PPI)
110 470 grams 90hz $799
PlayStation 1920x1080 100 610 grams 90 – 120 hz $329
VR devices
#DotNet2018
Windows 10 VR devices
#DotNet2018
Name Resolution Field Of View Weight Release date Pricing
Acer WMR headset 2880x1440 95 350 grams October 17, 2017 $299-$399
ASUS HC102 2880x1440 95 400 grams Spring 2018 $449
Dell Visor 2880x1440 110 834 grams October 17, 2017 $329-$449
HP WMR headset 2880x1440 95 380 grams October 17, 2017 $349-$399
Lenovo Explorer 2880x1440 105 Unspecified October 17, 2017 $349-$449
Samsung Odyssey 2880x1600 110 645 grams November 6, 2017 $499
Windows 10 VR devices
#DotNet2018
VR standalone devices
Oculus Go
DayDream
Gear VR
Google VR180
#DotNet2018
MR devices
HoloLens Meta 2 Magic Leap
#DotNet2018
AR devices
ARKit
ARCore
• Iphone 6S
• Iphone 6S Plus
• Iphone SE
• Iphone 7 / 7 Plus
• Iphone 8 / 8 Plus
• Iphone X
• Asus Zenfone AR / Zenfone Ares
• Google Pixel 2 / 2 XL / Pixel / Pixel XL / Nexus 5X / Nexus 6P
• Huawei P20 / P20 pro
• Motorola Z2 Force / G6 Plus
• OnePlus 5 / 3T
• Samsung A5 / A7 / A8 / A8+ / Note 8 / S7 / S7 Edge / S8 / S8+ / S9 / S9+
• Sony XZ Premium / Xperia XZ1
• Xiaomi Mi Mix 2S
#DotNet2018
Questions & Answers
#DotNet2018
Thanks and …
See you soon!
Thanks also to the sponsors.
Without whom this would not have been posible.

WaveEngine Dotnet 2018

Editor's Notes

  • #9 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/access-modifiers
  • #10 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/access-modifiers
  • #11 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/access-modifiers
  • #12 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/access-modifiers
  • #13 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/access-modifiers
  • #14 https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/access-modifiers
  • #17 ¿Donde se almacenan los arrays? Struct no permiten herencia 192 Bytes en las guias de Windows phone. Stack = static memory Heap = Dynamic memory
  • #26 .NET foundation
  • #32 https://github.com/dotnet/corefx/commit/8c3a1bac543c7654b37a9506e3382f184849ba16#diff-f1285172a2a161542ccf657778f0852c
  • #33 SharpLab
  • #34 https://marketplace.visualstudio.com/items?itemName=StephanZehetner.InliningAnalyzer
  • #36 https://github.com/SergeyTeplyakov/ObjectLayoutInspector