PC Games for Windows 10 Chuck Walbourn Senior Software Engineer Advanced Technology Group (ATG)

Download Report

Transcript PC Games for Windows 10 Chuck Walbourn Senior Software Engineer Advanced Technology Group (ATG)

PC Games for Windows 10
Chuck Walbourn
Senior Software Engineer
Advanced Technology Group (ATG)
Windows 10
Next version of Windows, available as a
Technical Preview now
• Windows 7 & Windows 8 users with
individual licenses get a free upgrade
•
• In the first year after release
•
Windows as a service
• Kept current for the lifetime of the device at
no cost
http://blogs.windows.com/
Windows 10
•
•
•
•
•
DirectX 12 runtime
The Start menu lives!
Better multiple desktop support
Improved command prompt (no, seriously!)
Windows universal platform to target all Windows 10 devices
• PCs, tablets, phones, and Xbox One
•
Still runs your Windows desktop applications, too!
Agenda
Windows 10 AppCompat
• Win32 game development
• WinRT in Windows desktop applications
• Developer tools
•
Windows 10 system requirements
•
Same system requirements as Windows 8.1
•
•
•
•
•
1 GHz+ CPU
1 GB RAM (32-bit) / 2 GB RAM (64-bit)
DirectX 9 graphics device with WDDM driver
32-bit requires PAE, NX, and SSE/SSE2
64-bit requires CMPXCHG16b, PrefetchW, and LAHF/SAHF
DirectX on Windows 10
•
Same compatibility as Windows 7 / Windows 8.x
• DirectX 9.0c
• Direct3D 10.x
• Direct3D 11.x
• DirectPlay is an optional feature
Assuming you aren’t using undocumented/internal behavior or APIs…
Version checking
•
Ideally, check for the feature directly
•
Normally should be limited to:
• Don’t tie it implicitly to a version
“you must be this high to ride this ride”
VerifyVersionInfo to do a “>=“ version check
Use VersionHelpers.h in the Windows SDK
http://aka.ms/kkc5m0
You must be this high to ride this ride…
bool IsWindowsVistaSP2OrGreater()
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 };
DWORDLONG const dwlConditionMask = VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
osvi.dwMajorVersion = HIBYTE(_WIN32_WINNT_VISTA);
osvi.dwMinorVersion = LOBYTE(_WIN32_WINNT_VISTA);
osvi.wServicePackMajor = 2;
return VerifyVersionInfoW(&osvi,
VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR,
dwlConditionMask) != FALSE;
}
GetVersion(Ex)
•
Deprecated API!
warning C4996: 'GetVersionExW': was declared deprecated
•
Always a problematic API for future compatibility
• Lots of bad version checks out there
•
As of Windows 8.1 and Windows 10
• The version number returned is not necessarily the true OS version
• Effectively an OSVersionLie shim is always in place…
• Unless you add a <compatibility> section in an embedded EXE manifest
High-DPI
125%, 150%, 200%, 250% scaling
• DirectX games should signal they are “Per Monitor High DPI Aware”
•
• Full-screen games have been handling resolution scaling of UI for a long time…
• Otherwise, might be subjected to various compatibility behaviors
•
Important to test this scenario for any installers/launchers/utilities, too!
•
•
•
•
•
Clipped UI
Unreadable text
Blurry images
Bad text layout
Misaligned input fields
http://go.microsoft.com/fwlink/?LinkID=129586
Embedded Manifests!
•
Visual Studio settings handle User Account Control
• Linker -> Manifest File
• “Enable User Account Control (UAC)” set to “Yes (/MANIFESTUAC:)”
• “UAC Execution Level” set to “asInvoker (/level='asInvoker')”
• Or rarely “requireAdministrator (/level='requireAdministrator')”
•
High-DPI aware
• Manifest Tool -> Input and Output
• “DPI Awareness” set to “Per Monitor High DPI Aware”
•
OS Compatibility
• Add a .manifest file to your project
http://aka.ms/i6kdnw
myfile.manifest
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
Windows Family Safety
•
Windows 10 supports the following game rating systems
• CERO, COB-AU, CSRR, DJCTQ, ESRB, FPB, GRB, PCBP, PEGI, USK
•
Windows desktop applications use GDFs and tools to provide ratings
metadata
http://aka.ms/kp7864
Microsoft basic render driver
•
You always have a Direct3D device on a Windows system
• It could be a software fallback…
• Replaces the old “VGA driver”
•
You might want to detect this case and warn the user about potential
performance issues
http://aka.ms/k5c74x
Win32 game development
Windows 10 “DirectX runtime” built into OS
•
•
•
•
•
Direct3D 12.0
Direct3D 11.0 - 11.3
XAudio
XInput
D3DCompiler (HLSL compiler)
Win32 APIs for use by all C++ applications
Direct3D 12
Console-like API on the PC
• Minimize CPU overhead
• Direct3D 12 supported across all Windows 10 devices
•
Better Power, Better Performance: Your Game on DirectX12
Advanced DirectX12 Graphics and Performance
Direct3D 11
•
•
•
Core graphics technology for Windows 7, Windows 8, and Xbox One
Supported on Windows 10
Broad hardware support through feature levels
Feature
Level
Shader
Model
Notes
Feature Level
Shader
Model
Notes
11.0
5.0
ATI Radeon HD 5000-7000
NVIDIA GeForce GTX 400-700
Intel “Ivy Bridge”
Surface Pro
9.3
2.X
Windows phone 8
Windows phone 8.1
10.1
4.1
ATI Radeon HD 3000/4000
NVIDIA GeForce GTX 300
Intel “Sandy Bridge”
9.2
2.0
10.0
4.0
ATI Radeon HD 2000
NVIDIA GeForce 8/9
Intel 965M
9.1
2.0
Surface RT
Surface 2
Direct3D 11.1 / DXGI 1.2
Device interop for 10.x <-> 11.x
• Direct2D/DirectWrite supports 11.x devices
• Direct3D hardware support in session 0
• Support for hardware feature level 11.1
•
Feature Level
Shader Model
Notes
11.1
5.0
ATI Radeon HD 8000
NVIDIA GeForce GTX 900
Intel “Haswell”, “Broadwell”
Surface Pro 2
Surface Pro 3
Xbox One
Direct3D 11.1 / DXGI 1.2
Optional hardware features
• Logical ops for output merger
• Constant Buffer partial updates
• Constant Buffer offsetting
• Clear View
• UAVs at every stage
• UAV only rendering
• Extended double-precision shaders
• Minimum precision HLSL shaders
Applications
 Faster
shader constant updates
 Enhanced
HLSL debugging
 Improved
perf on low-spec GPUs
Direct3D 11.1 / DXGI 1.2
•
•
ID3D11Device1
ID3D11DeviceContext1
•
•
•
•
•
•
CopySubresourceRegion1
UpdateSubresource1
??Get/SetConstantBuffers1
SwapDeviceContextState
ClearView
DiscardView1
•
ID3D11BlendState1
•
ID3D11RasterizerState1
•
ID3DUserDefinedAnnotation
• Logical ops
• Forced sample count
Direct3D 11.2 / DXGI 1.3
Optional hardware features
Tiled Resources (Tier 1 / Tier 2)
• Map DEFAULT buffers
• Clear View for depth buffers
• Min/Max Filtering
•
• D3D11_FILTER_MINIMUM_*
• D3D11_FILTER_MAXIMUM_*
Applications
 Virtual texturing
 Improved DirectCompute read-back
Direct3D 11.2 / DXGI 1.3
ID3D11Device2
• ID3D11DeviceContext2
•
•
•
•
•
•
•
•
•
•
UpdateTileMappings
CopyTileMappings
CopyTiles
UpdateTiles
ResizeTilePool
SetMarkerInt
BeginEventInt
EndEvent
IDXGISwapChain2::GetFrameLatencyWaitableObject
Direct3D 11.3 / DXGI 1.4
Optional hardware features
•
•
•
•
•
•
•
Tiled Resources (Tier 3)
Map DEFAULT textures
ASTC texture compression
JPEG H/W codec
Conservative rasterization
Rasterizer ordered views
Pixel Shader specified stencil
ref
Applications
 Faster
texture loading
 Very-low-bit-rate compression
 GPGPU
applications
 Order-Independent Transparency
Direct3D 11.3 / DXGI 1.4
ID3D11Device3
• ID3D11DeviceContext3
• ID3D11RasterizerState2
•
• Conservative rasterization
•
ID3D11Texture2D1 / ID3D11Texture3D1
•
ID3D11ShaderResourceView1 / ID3D11RenderTargetView1 /
ID3D11UnorderedAccessView1
• Texture layout
• Planar resource support
•
ID3D11Query1
• Query context setting
Direct3D debug device support
Traditionally installed by Windows SDK / legacy DirectX SDK
• For Windows 10, it’s an optional feature
•
• Start -> Settings -> System -> Optional features -> Add a feature
• Select Graphics Tools
XAudio
Game audio API for real-time mixing, audio effects, and so on.
• XAudio 2.8 included in the OS
•
http://aka.ms/f2xp1a
XInput
Xbox 360 Common Controller gamepad API
• Driver support for
•
• Xbox 360 Common Controller
• Xbox 360 Wireless Receiver for Windows
• Xbox One Controller
•
XInput 1.4 included in the OS
http://aka.ms/mu9kn7
Direct3D compiler
•
D3DCompiler_47.dll included with the OS
• D3DCompileFromFile
• D3DReflect
•
Supports HLSL Function Linking (“lib_*” profiles)
• D3DCreateFunctionLinkingGraph
• ID3D11FunctionLinkingGraph
http://aka.ms/tuoxjd
DirectXMath
C++ math library for vectors, matrices, quaternions, bounding volumes
• SSE2 / ARM-NEON optimized
• Replaces D3DXMath and “XNAMath” C++ Library
•
See the SimpleMath wrapper in the DirectX Tool Kit
http://aka.ms/kjp2dz
CodePlex projects
•
Shared source helper/utility code for DirectX
• Windows, Windows Phone, and Xbox One
•
DirectX Tool Kit - SpriteBatch, Model, SimpleMath, Texture Loaders, DirectX
Tool Kit for Audio, and so on.
https://directxtk.codeplex.com/
•
DirectXTex – Texture content processing (mipmaps, block-compression codecs,
format conversion)
https://directxtex.codeplex.com/
•
DirectXMesh – Mesh content processing (generating tangent frames, vertex
cache) optimization)
https://directxmesh.codeplex.com/
Share code with Windows apps
•
All these Win32 APIs and libraries also work with apps for the
Windows universal platform
• XInput will be replaced with GamePad WinRT API
Dual-use Coding Techniques for Games
http://aka.ms/fo3su4
WinRT in Windows desktop
applications
WinRT vs. Win32 APIs
•
WinRT is just a style of API design
• vs Win32 APIs (“Flat” C functions or COM-based)
• Underlying technology is an extension of COM
•
COM (IUnknown) + Metadata (IInspectable)
• IUnknown provides reference-counting
• IInspectable extends IUnknown with metadata and namespaces
• Metadata is stored in .winmd files
• Primary used for language projection (JavaScript, C#)
• .winmd files use the .NET metadata format (ECMA-335 – Partition II - CLI)
•
Many WinRT APIs are callable from Windows desktop applications
C++/CX
C++/CX are language extensions to simplify WinRT programming
• Syntax and keywords is similar to Managed C++ (/CLR)
•
•
•
•
•
•
•
ref class, ref struct
value class, value struct
interface class, interface struct
property
delegate
event
C++/CX (/ZW) is not managed C++(/CLR)
There is no CLR framework or garbage collector running
• Not compatible with managed assemblies
• This is just the compiler creating plumbing code for WinRT types
• Requires C++ Exception Handling (/EHsc) be enabled
•
• vs. Managed C++ (/CLR) requiring asynchronous exceptions (/EHa)
• C++ Exception handling is efficiently implemented for x64 native and ARM
• A bit quirky for x86, but much more efficient than /EHa
•
Does not require Run-Time Type Information – RTTI (/GR)
Windows Runtime C++ Template Library (WRL)
Alternative to using C++/CX (/ZW) language extensions
• Similar design to the Active Template Library (ATL)
• Low-level way to author and consume WinRT components
•
• Authoring requires use of IDL which is tricky and requires manual syncing
• Consuming WinRT components is straight-forward
Microsoft::WRL::ComPtr
Standard COM smart-pointer
• Similar to ATL’s CComPtr but without the ATL dependency
•
• ATL isn’t in Visual Studio Express editions
•
Works for Windows desktop applications, too!
• The rest of Windows Runtime Library (WRL) is for working with WinRT
myfile.h
#include <wrl.h>
-or#include <wrl/client.h>
class A
{
…
private:
Microsoft::WRL::ComPtr<ID3D11Device> m_device;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_context;
}
myfile.cpp
#include "myfile.h"
using Microsoft::WRL::ComPtr;
…
HRESULT hr = D3D11CreateDevice( …, &m_device, …, &m_context );
// -orHRESULT hr = D3D11CreateDevice( …,
m_device.ReleaseAndGetAddressOf(), …,
m_context.ReleaseAndGetAddressOf() );
myfile.cpp
ComPtr<ID3D11Debug> d3dDebug;
hr = m_device.As( &d3dDebug );
if (SUCCEEDED(hr))
{
…
}
…
ID3D11Device* ptr = m_device.Get();
…
m_device.Reset();
m_context.Reset();
Challenges with using WinRT from Win32
•
Many only work for Windows Store apps
• “Windows Store apps only” vs. “Windows Store apps, desktop apps” on MSDN
• More will be supported for Windows 10
•
No significant samples or documentation currently
• Particularly using WRL
•
Many require the “Single-Threaded” COM (STA) memory model
• DirectX applications use the “Multi-Threaded” COM (MTA) memory model
• Can work around this by creating a helper thread with STA set
Setup
#include <wrl.h>
#include <ShObjIdl.h>
#include "Windows.ApplicationModel.DataTransfer.h"
#pragma comment(lib,"runtimeobject.lib")
using namespace ABI::Windows::ApplicationModel::DataTransfer;
using namespace ABI::Windows::Foundation;
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
RoInitializeWrapper initialize(RO_INIT_MULTITHREADED);
if (FAILED(initialize))
…
Getting the base object
auto rtc = HStringReference(
RuntimeClass_Windows_ApplicationModel_DataTransfer_DataTransferManager
);
ComPtr<IDataTransferManagerStatics> statics;
HRESULT hr = GetActivationFactory(rtc.Get(), statics.GetAddressOf());
if (FAILED(hr))
…
Microsoft::WRL::ComPtr<IDataTransferManagerInterop> interop;
hr = statics.As(&interop);
if (FAILED(hr))
…
ComPtr<IDataTransferManager> manager;
hr = interop->GetForWindow( hWnd, IID_PPV_ARGS( manager.GetAddressOf() ) );
if (FAILED(hr))
…
Registering the callback/Triggering the UI
typedef
ITypedEventHandler<DataTransferManager*, DataRequestedEventArgs*>
handler_t;
auto callback = Callback<handler_t>(
[](IDataTransferManager *, IDataRequestedEventArgs* args) -> HRESULT
{
… // next slide
});
hr = manager->add_DataRequested( callback.Get(), &mRequestToken);
if (FAILED(hr))
…
interop->ShowShareUIForWindow( hWnd );
Callback implementation
ComPtr<IDataRequest> request;
HRESULT hr = args->get_Request( request.GetAddressOf() );
if (SUCCEEDED(hr))
{
ComPtr<IDataPackage> package;
hr = request->get_Data( package.GetAddressOf() );
if (SUCCEEDED(hr))
{
ComPtr<IDataPackagePropertySet> props;
hr = package->get_Properties( props.GetAddressOf() );
if (SUCCEEDED(hr))
{
props->put_Title( HStringReference( L"Share example" ).Get() );
props->put_Description(…);
…
}
}
}
return hr;
Developer tools
Where is the DirectX SDK?
•
The legacy DirectX SDK is no more
• Integrated into the Windows SDK as of Windows 8
•
All versions of D3DX (D3DX9, D3DX10, D3DX11) and XACT are deprecated
• The shared-source projects on CodePlex borrow heavily from D3DX functionality
See Living without D3DX,
DirectX SDK Tools Catalog,
DirectX SDKs of a certain age,
DirectX SDK Samples Catalog @ http://aka.ms/dxsdk
Visual C++ / Windows SDK
DirectX headers/libs
• XAudio headers/libs
• XInput headers/libs
• D3DCompiler header/lib/DLL
•
• That is, the HLSL compiler
DirectXMath
• FXC.EXE, GDFMaker.exe, DxCapsViewer.exe
•
•
Also supports writing Windows desktop applications for all DirectX 11
capable versions of Windows
Visual Studio Community
•
Visual Studio 2013 Update 4 introduced a new Community edition
• Professional feature set for indies, students, hobbyists, and individuals
http://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx
Graphics debugger
Visual Studio 2013 Community, Visual Studio 2013 Pro+, Visual Studio 2015
• Capture engine best on Windows 8.1 or Windows 10
•
Solve the Tough Graphics Problems with Your Game Using DirectX Tools
Visual Studio 2015
•
•
•
•
•
•
•
Tools for Windows Store, Windows Phone, and Windows desktop
Platform Toolset “v140”
Improved C++11 / C++14 / C99 conformance
Better build and link performance
Improved auto-vectorizer / auto-parallelizer
<atomics>, <mutex> performance and correctness improvements
<chrono> high_resolution_clock / steady_clock works!
Visual Studio 2015 notable changes
•
New warnings on by default
•
•
•
•
•
•
•
•
•
C4317:
C4422:
C4426:
C2082:
C4456:
C4457:
C4458:
C4459:
C4838:
not enough arguments passed for format string
too many arguments passed for format string
‘%*’ is not allowed in format string of function ‘printf_s’
redefinition of formal parameter ‘X’
declaration of ‘X’ hides previous local declaration
declaration of ‘X’ hides function parameter
declaration of ‘X’ hides class member
declaration of 'X' hides global declaration
conversion from ‘X’ to ‘Y’ requires a narrowing conversion
Visual Studio 2015 notable changes
•
Legacy vs. C99 Conformance mode for printf / wprintf
• “%s” vs “%S”
• Consider using “%ls” and “%hs” instead
•
Can’t have your own typedef for char16_t or char32_t anymore
C2632: ‘X’ followed by ‘char16_t’ is illegal
C2632: ‘X’ followed by ‘char32_t’ is illegal
•
Support for user-defined literals can break existing strings
• "foo"_bar -> "foo" _bar
• L"Hello"L"World" -> L"Hello" L"World"
Call to action
Install the Windows 10 Technical Preview
• Install the Visual Studio 2015 Technical Preview
• If you are using Visual Studio 2013 Express for Windows desktop, take a
look at using Visual Studio 2013 Community instead
• Stop using the legacy DirectX SDK (as much as possible)
•
• See Where is the DirectX SDK? - http://aka.ms/dxsdk
•
Stop using DXSETUP (aka DirectX End User Runtime)
• See Not So DirectSetup - http://aka.ms/dxsetup
Questions?
© 2015 Microsoft Corporation.
All rights reserved. Microsoft, Xbox, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The
information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must
respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any
information provided after the date of this presentation.
MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.