Skip to content

Commit

Permalink
Windows 10 RTM Release - September 2016 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnewthing committed Sep 15, 2016
1 parent 1b89412 commit ad665fa
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 27 deletions.
38 changes: 38 additions & 0 deletions Samples/D2DCustomEffects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion Samples/D2DCustomEffects/cpp/ComputeShader/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,23 @@ void App::Initialize(_In_ CoreApplicationView^ applicationView)
CoreApplication::Resuming +=
ref new EventHandler<Platform::Object^>(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<DX::DeviceResources>();

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).
Expand Down
16 changes: 13 additions & 3 deletions Samples/D2DCustomEffects/cpp/ComputeShader/DeviceResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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();
Expand Down Expand Up @@ -150,9 +157,12 @@ void DX::DeviceResources::CreateDeviceResources()
ComPtr<ID3D11Device> device;
ComPtr<ID3D11DeviceContext> 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.
Expand Down
2 changes: 2 additions & 0 deletions Samples/D2DCustomEffects/cpp/ComputeShader/DeviceResources.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions Samples/D2DCustomEffects/cpp/ComputeShader/DftEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions Samples/D2DGradientMesh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 28 additions & 4 deletions Samples/D2DPhotoAdjustment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions Samples/DWriteLineSpacingModes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ 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.
* The DWriteLineSpacing Modes project provides the sample app shell, implemented using XAML, that functions as a client of the the DirectWrite APIs being demonstrated.

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.
Expand All @@ -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)
Expand Down
12 changes: 5 additions & 7 deletions Samples/DWriteTextLayoutCloudFont/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ 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.
* The DWriteTextLayoutCloudFont project provides the sample app shell, implemented using XAML, that functions as a client of the the DirectWrite APIs being demonstrated.

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.
* The FontDownloadListener.h/.cpp files wrap around DirectWrite lower-level APIs for interacting with the font download mechanism, and provide an implementation of the IDWriteFontDownloadListener interface, needed for responding to the download mechanism.
* 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.
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion SharedContent/js/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script src="/js/default.js"></script>
</head>
<body role="application" class="win-type-body">
<div id="root" data-win-control="WinJS.UI.SplitView" data-win-options="{ paneHidden: SdkSample.paneHiddenInitially }">
<div id="root" data-win-control="WinJS.UI.SplitView" data-win-options="{ paneOpened: SdkSample.paneOpenInitially }">
<div>
<button type="button" class="splitViewButton win-button"></button>
<div id="header" role="contentinfo" data-win-control="WinJS.UI.HtmlControl" data-win-options="{uri: '/sample-utils/header.html'}"></div>
Expand Down
Loading

0 comments on commit ad665fa

Please sign in to comment.