From ad665fa664483667438a02aa8d535b064ffda76e Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Wed, 14 Sep 2016 17:00:00 -0700 Subject: [PATCH] Windows 10 RTM Release - September 2016 Update --- Samples/D2DCustomEffects/README.md | 38 +++++++++++++++++++ .../cpp/ComputeShader/App.cpp | 16 +++++++- .../cpp/ComputeShader/DeviceResources.cpp | 16 ++++++-- .../cpp/ComputeShader/DeviceResources.h | 2 + .../cpp/ComputeShader/DftEffect.cpp | 8 ++-- Samples/D2DGradientMesh/README.md | 31 +++++++++++++++ Samples/D2DPhotoAdjustment/README.md | 32 ++++++++++++++-- Samples/DWriteLineSpacingModes/README.md | 8 ++-- Samples/DWriteTextLayoutCloudFont/README.md | 12 +++--- SharedContent/js/default.html | 2 +- SharedContent/js/js/default.js | 13 +++++-- 11 files changed, 151 insertions(+), 27 deletions(-) diff --git a/Samples/D2DCustomEffects/README.md b/Samples/D2DCustomEffects/README.md index 8d0059adc8..25c782b0dc 100644 --- a/Samples/D2DCustomEffects/README.md +++ b/Samples/D2DCustomEffects/README.md @@ -19,6 +19,44 @@ To obtain information about Windows 10 development, go to the [Windows Dev Cente To obtain information about Microsoft Visual Studio 2015 and the tools for developing Windows apps, go to [Visual Studio 2015](http://go.microsoft.com/fwlink/?LinkID=532422) +## Sample project files + +This sample contains three separate projects, demonstrating a custom pixel, vertex, and compute shader effect. +Each project has a similar set of files that follow the same pattern. + +### Custom Direct2D effect implementation +The following files are the core effect implementation, i.e. the main educational content of the sample: + +- ***.hlsl:** The core shader routines that operate on image data. These are written using standard HLSL with some helper Direct2D intrinsics that enable the custom effect to take advantage of shader linking. +[TODO: link to the intrinsics/shader linking page] +- ***Effect.cpp/.h,** ***Transform.cpp/.h:** Implementation of the Direct2D effect interfaces, e.g. ID2D1EffectImpl. This code is called by the Direct2D renderer to setup and control the effect shader operation. + +### Demo app +A custom Direct2D effect does nothing on its own, as it must be loaded and executed by a calling app. The following files provide a simple demo environment to exercise the effect: + +- App.cpp/.h +- *Main.cpp/.h, *Renderer.cpp/.h + +### DirectX SDK sample common files +The following files provide common functionality needed by DirectX SDK samples: + +- **DeviceResources.cpp/.h:** Manages creation and lifetime of the core Direct3D and Direct2D device-dependent resources. Handles cases such as device lost and window size and orientation changes. +- **DirectXHelper.h:** Common inline helper functions, including ThrowIfFailed which converts HRESULT-based APIs into an exception model. +- **BasicReaderWriter.cpp/.h:** Basic file I/O functionality, needed for things like loading shaders, textures and geometry. +- **SampleOverlay.cpp/.h:** Renders the Windows SDK overlay badge on top of sample content. +- **BasicTimer.cpp/.h:** Wraps QueryPerformanceCounter to provide an accurate, low-overhead timer. + +All DX SDK samples and the Visual Studio template DX project contain a version of these files (some are not always needed). These common files demonstrate important best practices for DX UWP apps, and you are encouraged to use them in your own projects. + +### C++ UWP common files +Variants of the following files are found in every UWP app written in C++: + +- Package.appxmanifest +- pch.cpp/.h +- *.vcxproj +- *.vcxproj.filters +- *.sln + ## Related topics ### Feature areas diff --git a/Samples/D2DCustomEffects/cpp/ComputeShader/App.cpp b/Samples/D2DCustomEffects/cpp/ComputeShader/App.cpp index caa57a950d..9db6955424 100644 --- a/Samples/D2DCustomEffects/cpp/ComputeShader/App.cpp +++ b/Samples/D2DCustomEffects/cpp/ComputeShader/App.cpp @@ -62,9 +62,23 @@ void App::Initialize(_In_ CoreApplicationView^ applicationView) CoreApplication::Resuming += ref new EventHandler(this, &App::OnResuming); - // At this point we have access to the device. + // At this point we have access to the device. // We can create the device-dependent resources. m_deviceResources = std::make_shared(); + + auto device = m_deviceResources->GetD3DDevice(); + + // Check whether the graphics hardware supports compute shaders. If not, switch to a WARP device + // which is guaranteed to support at least D3D_FEATURE_LEVEL_11_0. + if (device->GetFeatureLevel() < D3D_FEATURE_LEVEL_11_0) + { + D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS hwopts = { 0 }; + DX::ThrowIfFailed(device->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &hwopts, sizeof(hwopts))); + if (!hwopts.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x) + { + m_deviceResources.reset(new DX::DeviceResources(true)); + } + } } // Called when the CoreWindow object is created (or re-created). diff --git a/Samples/D2DCustomEffects/cpp/ComputeShader/DeviceResources.cpp b/Samples/D2DCustomEffects/cpp/ComputeShader/DeviceResources.cpp index 5ed9298006..e015539727 100644 --- a/Samples/D2DCustomEffects/cpp/ComputeShader/DeviceResources.cpp +++ b/Samples/D2DCustomEffects/cpp/ComputeShader/DeviceResources.cpp @@ -59,7 +59,13 @@ namespace ScreenRotation }; // Constructor for DeviceResources. -DX::DeviceResources::DeviceResources() : +DX::DeviceResources::DeviceResources() : + DeviceResources(false /* _In_ bool forceWarpDevice */) +{} + +// Constructor for DeviceResources; allows the caller to force usage of the WARP software +// device which is useful if we need to use D3D features that are unsupported by the hardware. +DX::DeviceResources::DeviceResources(_In_ bool forceWarpDevice) : m_screenViewport(), m_d3dFeatureLevel(D3D_FEATURE_LEVEL_9_1), m_d3dRenderTargetSize(), @@ -68,7 +74,8 @@ DX::DeviceResources::DeviceResources() : m_nativeOrientation(DisplayOrientations::None), m_currentOrientation(DisplayOrientations::None), m_dpi(-1.0f), - m_deviceNotify(nullptr) + m_deviceNotify(nullptr), + m_forceWarpDevice(forceWarpDevice) { CreateDeviceIndependentResources(); CreateDeviceResources(); @@ -150,9 +157,12 @@ void DX::DeviceResources::CreateDeviceResources() ComPtr device; ComPtr context; + // Create a device using the hardware graphics driver, unless WARP override is set. + D3D_DRIVER_TYPE driverType = m_forceWarpDevice ? D3D_DRIVER_TYPE_WARP : D3D_DRIVER_TYPE_HARDWARE; + HRESULT hr = D3D11CreateDevice( nullptr, // Specify nullptr to use the default adapter. - D3D_DRIVER_TYPE_HARDWARE, // Create a device using the hardware graphics driver. + driverType, 0, // Should be 0 unless the driver is D3D_DRIVER_TYPE_SOFTWARE. creationFlags, // Set debug and Direct2D compatibility flags. featureLevels, // List of feature levels this app can support. diff --git a/Samples/D2DCustomEffects/cpp/ComputeShader/DeviceResources.h b/Samples/D2DCustomEffects/cpp/ComputeShader/DeviceResources.h index 4faeabbbc6..f62bca8488 100644 --- a/Samples/D2DCustomEffects/cpp/ComputeShader/DeviceResources.h +++ b/Samples/D2DCustomEffects/cpp/ComputeShader/DeviceResources.h @@ -25,6 +25,7 @@ namespace DX { public: DeviceResources(); + DeviceResources(_In_ bool forceWarpDevice); void SetWindow(Windows::UI::Core::CoreWindow^ window); void SetLogicalSize(Windows::Foundation::Size logicalSize); void SetCurrentOrientation(Windows::Graphics::Display::DisplayOrientations currentOrientation); @@ -95,6 +96,7 @@ namespace DX Windows::Graphics::Display::DisplayOrientations m_nativeOrientation; Windows::Graphics::Display::DisplayOrientations m_currentOrientation; float m_dpi; + bool m_forceWarpDevice; // Transforms used for display orientation. D2D1::Matrix3x2F m_orientationTransform2D; diff --git a/Samples/D2DCustomEffects/cpp/ComputeShader/DftEffect.cpp b/Samples/D2DCustomEffects/cpp/ComputeShader/DftEffect.cpp index 0a9e2f2c0b..7387006b6f 100644 --- a/Samples/D2DCustomEffects/cpp/ComputeShader/DftEffect.cpp +++ b/Samples/D2DCustomEffects/cpp/ComputeShader/DftEffect.cpp @@ -78,10 +78,10 @@ IFACEMETHODIMP DftEffect::Initialize( sizeof(hardwareOptions) ); - // As stated above, not all DX Feature Level 10_0 parts support compute shaders. In this app's case, - // it checks for compute shader support at device creation in DirectXBase.cpp. If support is missing, - // it uses a software fallback (WARP). All effects that use compute shaders should perform this - // check at instantiation. + // As stated above, not all DX Feature Level 10_0 parts support compute shaders. In this sample's case, + // it checks for compute shader support at device creation in DeviceResources. If support is missing, + // it uses the WARP software fallback, which is guaranteed to support compute. + // All effects that use compute shaders should perform this check at instantiation. if (SUCCEEDED(hr)) { if (!hardwareOptions.computeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x) diff --git a/Samples/D2DGradientMesh/README.md b/Samples/D2DGradientMesh/README.md index f270c20ec8..5aed7d5727 100644 --- a/Samples/D2DGradientMesh/README.md +++ b/Samples/D2DGradientMesh/README.md @@ -13,6 +13,37 @@ Some important APIs used in this sample are: - The [**ID2D1DeviceContext2::CreateGradientMesh**](http://msdn.microsoft.com/en-us/library/windows/desktop/dn890790) method, which creates an [**ID2D1GradientMesh**](http://msdn.microsoft.com/en-us/library/windows/desktop/dn900410) object on the Direct2D device. - The [**ID2D1DeviceContext2::DrawGradientMesh**](http://msdn.microsoft.com/en-us/library/windows/desktop/dn900378) method, which renders the ID2D1GradientMesh object to the device context. +## Sample project files + +The sample's project files fall into the following categories. + +### Sample-specific files +The following files exercise the gradient mesh APIs and form the main educational content of the sample: + +- App.cpp/.h +- D2DGradientMeshMain.cpp/.h +- D2DGradientMeshRenderer.cpp/.h + +D2DGradientMeshRenderer contains most of the gradient mesh-specific code. + +### DirectX SDK sample common files +The following files provide common functionality needed by DirectX SDK samples: + +- **DeviceResources.cpp/.h:** Manages creation and lifetime of the core Direct3D and Direct2D device-dependent resources. Handles cases such as device lost and window size and orientation changes. +- **DirectXHelper.h:** Common inline helper functions, including ThrowIfFailed which converts HRESULT-based APIs into an exception model. +- **SampleOverlay.cpp/.h:** Renders the Windows SDK overlay badge on top of sample content. + +All DX SDK samples and the Visual Studio template DX project contain a version of these files. These common files demonstrate important best practices for DX UWP apps, and you are encouraged to use them in your own projects. + +### C++ UWP common files +Variants of the following files are found in every UWP app written in C++: + +- Package.appxmanifest +- pch.cpp/.h +- D2DGradientMesh.vcxproj +- D2DGradientMesh.vcxproj.filters +- D2DGradientMesh.sln + ## Related topics [**D2D1\_GRADIENT\_MESH\_PATCH** structure](http://msdn.microsoft.com/en-us/library/windows/desktop/dn890726) diff --git a/Samples/D2DPhotoAdjustment/README.md b/Samples/D2DPhotoAdjustment/README.md index f6dda133f7..bbaf73891b 100644 --- a/Samples/D2DPhotoAdjustment/README.md +++ b/Samples/D2DPhotoAdjustment/README.md @@ -21,11 +21,35 @@ This sample uses the following Direct2D effects: - [Contrast](http://msdn.microsoft.com/en-us/library/windows/desktop/dn890716) - [Highlights and Shadows](http://msdn.microsoft.com/en-us/library/windows/desktop/dn890773) -**Note** The Windows universal samples require Visual Studio 2015 to build and Windows 10 to execute. - -To obtain information about Windows 10 development, go to the [Windows Dev Center](http://go.microsoft.com/fwlink/?LinkID=532421) +## Sample project files -To obtain information about Microsoft Visual Studio 2015 and the tools for developing Windows apps, go to [Visual Studio 2015](http://go.microsoft.com/fwlink/?LinkID=532422) +The sample's project files fall into the following categories. + +### Sample-specific files +The following files form the main educational content of the sample: + +- **DirectXPage.xaml/.cpp/.h/:** Implements a XAML-based UI to drive the photo pipeline. Hosts the DirectX content in a SwapChainPanel. +- **App.xaml/.cpp/.h:** The app's main entry point. +- **D2DPhotoAdjustmentRenderer.cpp/.h:** The core implementation of the Direct2D photo pipeline using effects. +- **D2DPhotoAdjustmentProperties.h:** Defines the struct used for databinding effect properties with the UI. + +### DirectX SDK sample common files +The following files provide common functionality needed by DirectX SDK samples: + +- **DeviceResources.cpp/.h:** Manages creation and lifetime of the core Direct3D and Direct2D device-dependent resources. Handles cases such as device lost and window size and orientation changes. +- **DirectXHelper.h:** Common inline helper functions, including ThrowIfFailed which converts HRESULT-based APIs into an exception model. +- **SampleOverlay.cpp/.h:** Renders the Windows SDK overlay badge on top of sample content. + +All DX SDK samples and the Visual Studio template DX project contain a version of these files. These common files demonstrate important best practices for DX UWP apps, and you are encouraged to use them in your own projects. + +### C++ UWP common files +Variants of the following files are found in every UWP app written in C++: + +- Package.appxmanifest +- pch.cpp/.h +- D2DPhotoAdjustment.vcxproj +- D2DPhotoAdjustment.vcxproj.filters +- D2DPhotoAdjustment.sln ## Related topics diff --git a/Samples/DWriteLineSpacingModes/README.md b/Samples/DWriteLineSpacingModes/README.md index 7c709c9ec2..3b4f0cca90 100644 --- a/Samples/DWriteLineSpacingModes/README.md +++ b/Samples/DWriteLineSpacingModes/README.md @@ -11,7 +11,7 @@ In previous versions, DirectWrite supported two different line spacing methods: Line metrics sound straightforward: line height, ascender and descender. But when you get into details of various scenarios, it's actually somewhat difficult to understand in the abstract. For that reason, in addition to demonstrating use of the DirectWrite APIs, this sample also allows you to explore and see visually how different input parameters affect the computed results. -##Sample project files +## Sample project files The sample is intended to demonstrate how to use the DirectWrite text layout line spacing APIs and the effects of the various input parameters. The app is comprised of two projects: * The DWriteTextLayoutImplementation project provides the implementation of DirectWrite APIs for text layout and line spacing that are the main focus of this sample. It is implemented as a Windows Runtime Component that wraps around DirectWrite and enables interop with the sample client app. It also uses other DirectX APIs to implement a XAML SurfaceImageSource as a means of displaying the text layout. @@ -19,13 +19,13 @@ The sample is intended to demonstrate how to use the DirectWrite text layout lin This organization suits the needs of this sample app, utilizing the simplicity of XAML for UI to navigate between scenarios while keeping the native DirectWrite code that's of primary interest separate and easier for you to focus on. -###DWriteTextLayoutImplementation project +### DWriteTextLayoutImplementation project Within the DWriteTextLayoutImplementation project, the following files are significant: * The TextLayout.h/.cpp files wrap the DirectWrite text layout and related line spacing APIs. * The TextLayoutImageSource.h/.cpp files implement a XAML SurfaceImageSource using DirectX APIs for rendering the text layout. -###DWriteTextLayoutCloudFont project +### DWriteTextLayoutCloudFont project Within the DWriteTextLayoutCloudFont project, the following files are significant: * The Scenario1\_DefaultSpacing.\*, Scenario2\_UniformSpacing.\* and Scenario3\_ProportionalSpacing.\* files each demonstrate a different line spacing method. @@ -34,7 +34,7 @@ Other files are boilerplate files used for UWP sample apps. -##Related topics +## Related topics [IDWriteTextLayout3 interface](https://msdn.microsoft.com/en-us/library/windows/desktop/dn900405) [IDWriteTextLayout3::SetLineSpacing method](https://msdn.microsoft.com/en-us/library/windows/desktop/dn900409) diff --git a/Samples/DWriteTextLayoutCloudFont/README.md b/Samples/DWriteTextLayoutCloudFont/README.md index 20b6375c68..59374e88ae 100644 --- a/Samples/DWriteTextLayoutCloudFont/README.md +++ b/Samples/DWriteTextLayoutCloudFont/README.md @@ -9,7 +9,7 @@ This sample demonstrates how to use DirectWrite downloadable fonts, a feature ad A new capability in DirectWrite for Windows 10 allows an app to format text content using fonts that may not be installed on a device, and for the font to be downloaded on demand from a Microsoft service. DirectWrite now includes low-level APIs for using downloadable fonts. An easy way to leverage the downloadable font mechanism is to use DirectWrite's text layout (IDWriteTextLayout3), which integrates the lower-level APIs and does part of the work for you. When a text layout is created with a Windows font that is not locally installed, the text layout will automatically add requests for the font data to a font download queue. You need to add code that initiates the download and that responds when the download is completed. -##Sample project files +## Sample project files The sample is intended to demonstrate how to use the DirectWrite downloadable font mechanism together with DirectWrite's text layout API. The app is comprised of two projects: * The DWriteTextLayoutCloudFontImplementation project provides the implementation of DirectWrite APIs for text layout and downloadable fonts that are the main focus of this sample. It is implemented as a Windows Runtime Component that wraps around DirectWrite and enables interop with the sample client app. It also uses other DirectX APIs to implement a XAML SurfaceImageSource as a means of displaying the text layout. @@ -17,7 +17,7 @@ The sample is intended to demonstrate how to use the DirectWrite downloadable fo This organization suits the needs of this sample app, utilizing the simplicity of XAML for UI to navigate between scenarios while keeping the native DirectWrite code that's of primary interest separate and easier for you to focus on. -###DWriteTextLayoutCloudFontImplementation project +### DWriteTextLayoutCloudFontImplementation project Within the DWriteTextLayoutCloudFontImplementation project, the following files are significant: * The TextLayout.h/.cpp files wrap the DirectWrite text layout API. @@ -25,7 +25,7 @@ Within the DWriteTextLayoutCloudFontImplementation project, the following files * The FontNameCollector.h/.cpp files wrap additional DirectWrite APIs to determine which fonts are actually used in text layout. They are not needed to use the font download mechanism but provide you more insight, while the sample app is running, into how the text layout and font download mechanisms are interacting. * The TextLayoutImageSource.h/.cpp files implement a XAML SurfaceImageSource using DirectX APIs for rendering the text layout. -###DWriteTextLayoutCloudFont project +### DWriteTextLayoutCloudFont project Within the DWriteTextLayoutCloudFont project, the following files are significant: * The Scenario\_Document1.\*, Scenario\_Document2.\* and Scenario\_Document3.\* files each invoke text layout using a different downloadable font, and then invoke and respond to the downloadable font mechanism. @@ -34,12 +34,10 @@ Within the DWriteTextLayoutCloudFont project, the following files are significan Other files are boilerplate files used for UWP sample apps. -###Other files +### Other files The ClearDownloadableFontCache.ps1 file is not part of the sample project itself, but is a PowerShell script that can be used to reset the state of the downloadable font mechanism (clearing cached data) before or after running the sample app. Instructions for using this script are given in the sample app. - - -##Related topics +## Related topics [IDWriteFactory3::GetSystemFontCollection method](https://msdn.microsoft.com/en-us/library/windows/desktop/dn890761) [IDWriteTextLayout3 interface](https://msdn.microsoft.com/en-us/library/windows/desktop/dn900405) diff --git a/SharedContent/js/default.html b/SharedContent/js/default.html index 6316fce840..ce88a06b4a 100644 --- a/SharedContent/js/default.html +++ b/SharedContent/js/default.html @@ -21,7 +21,7 @@ -
+
diff --git a/SharedContent/js/js/default.js b/SharedContent/js/js/default.js index e3eadcd403..5abeeba4c8 100644 --- a/SharedContent/js/js/default.js +++ b/SharedContent/js/js/default.js @@ -9,19 +9,20 @@ var splitView; WinJS.Namespace.define("SdkSample", { - paneHiddenInitially: false + paneOpenInitially: false }); function activated(eventObject) { var activationKind = eventObject.detail.kind; var activatedEventArgs = eventObject.detail.detail; - SdkSample.paneHiddenInitially = window.innerWidth <= 768; + SdkSample.paneOpenInitially = window.innerWidth > 768; var p = WinJS.UI.processAll(). then(function () { splitView = document.querySelector("#root").winControl; splitView.onbeforeclose = function () { WinJS.Utilities.addClass(splitView.element, "hiding"); }; splitView.onafterclose = function () { WinJS.Utilities.removeClass(splitView.element, "hiding"); }; + splitView.onafteropen = handleOpened; window.addEventListener("resize", handleResize); handleResize(); @@ -84,6 +85,12 @@ splitView.paneOpened = !splitView.paneOpened; } + function handleOpened() { + // Different SplitView openedDisplayModes handle focus differently when opened. + // Normalize them and always put focus onto the SplitView pane element when opened. + splitView.element.querySelector(".win-splitview-pane").focus(); + } + function handleResize() { if (window.innerWidth > 768) { splitView.closedDisplayMode = WinJS.UI.SplitView.ClosedDisplayMode.none; @@ -102,4 +109,4 @@ window.onerror = function (E) { debugger; -} \ No newline at end of file +}