Skip to content

Commit ab453c0

Browse files
authored
Merge pull request #669 from microsoft/master
Bring bug fixes and readme updates to the develop branch
2 parents 73271c9 + 69c728e commit ab453c0

File tree

54 files changed

+1103
-323
lines changed

Some content is hidden

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

54 files changed

+1103
-323
lines changed

.gitignore

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,20 @@
11
################################################################################
2-
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
2+
# This .gitignore file is manually maintained
33
################################################################################
44

55
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingMiniEngineSample/dxcompiler.dll
66
/Libraries/D3D12RaytracingFallback/src/FallbackLayerUnitTests/x64/
77
/Packages
8-
/Samples/Desktop/D3D12Raytracing/src/.vs/D3D12Raytracing/v16
9-
/Samples/Desktop/D3D12xGPU/src/D3D12xGPU.vcxproj.user
10-
/.vs/VSWorkspaceState.json
11-
/.vs/slnx.sqlite
12-
/.vs/ProjectSettings.json
13-
/.vs/DirectX-Graphics-Samples/v16/Browse.VC.db
14-
/.vs/DirectX-Graphics-Samples/v16/.suo
15-
/.vs/DirectX-Graphics-Samples/v16
16-
/.vs
17-
/MiniEngine/ModelViewer/.vs/ModelViewer_VS16/v16/Browse.VC.opendb
18-
/MiniEngine/Build_VS16/x64/Release/Intermediate
19-
/MiniEngine/Build_VS16/x64/Release/Output
20-
/MiniEngine/Build_VS16/x64
21-
/Samples/Desktop/D3D12Raytracing/Build_VS16/x64
22-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingHelloWorld/obj/x64
23-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingHelloWorld/D3D12RaytracingHelloWorld.vcxproj.user
24-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingHelloWorld/bin/x64
25-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingLibrarySubobjects/obj/x64
26-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingLibrarySubobjects/D3D12RaytracingLibrarySubobjects.vcxproj.user
27-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingLibrarySubobjects/bin/x64
28-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingMiniEngineSample/ModelViewer_VS16.vcxproj.user
29-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingProceduralGeometry/obj/x64
30-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingProceduralGeometry/D3D12RaytracingProceduralGeometry.vcxproj.user
31-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingProceduralGeometry/bin/x64
32-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingRealTimeDenoisedAmbientOcclusion/Profile.csv
33-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingRealTimeDenoisedAmbientOcclusion/obj/x64
34-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingRealTimeDenoisedAmbientOcclusion/D3D12RaytracingRealTimeDenoisedAmbientOcclusion.vcxproj.user
35-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingRealTimeDenoisedAmbientOcclusion/bin/x64
36-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingSimpleLighting/obj/x64
37-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingSimpleLighting/D3D12RaytracingSimpleLighting.vcxproj.user
38-
/Samples/Desktop/D3D12Raytracing/src/D3D12RaytracingSimpleLighting/bin/x64
39-
/Samples/Desktop/D3D12Raytracing/src/.vs/D3D12Raytracing/v15
8+
9+
**/bin/x64
10+
**/obj/x64
11+
**/src/packages
12+
**/src/bin
13+
**/src/obj
14+
**/.vs
15+
16+
*.hlsl.h
17+
**/Build_VS16
18+
19+
*.vcxproj.user
20+
*.opendb

Libraries/D3DX12/d3dx12.h

Lines changed: 152 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,29 @@ inline void MemcpySubresource(
20002000
}
20012001
}
20022002

2003+
//------------------------------------------------------------------------------------------------
2004+
// Row-by-row memcpy
2005+
inline void MemcpySubresource(
2006+
_In_ const D3D12_MEMCPY_DEST* pDest,
2007+
_In_ const void* pResourceData,
2008+
_In_ const D3D12_SUBRESOURCE_INFO* pSrc,
2009+
SIZE_T RowSizeInBytes,
2010+
UINT NumRows,
2011+
UINT NumSlices) noexcept
2012+
{
2013+
for (UINT z = 0; z < NumSlices; ++z)
2014+
{
2015+
auto pDestSlice = static_cast<BYTE*>(pDest->pData) + pDest->SlicePitch * z;
2016+
auto pSrcSlice = (static_cast<const BYTE*>(pResourceData) + pSrc->Offset) + pSrc->DepthPitch * LONG_PTR(z);
2017+
for (UINT y = 0; y < NumRows; ++y)
2018+
{
2019+
memcpy(pDestSlice + pDest->RowPitch * y,
2020+
pSrcSlice + pSrc->RowPitch * LONG_PTR(y),
2021+
RowSizeInBytes);
2022+
}
2023+
}
2024+
}
2025+
20032026
//------------------------------------------------------------------------------------------------
20042027
// Returns required size of a buffer to be used for data upload
20052028
inline UINT64 GetRequiredIntermediateSize(
@@ -2076,6 +2099,65 @@ inline UINT64 UpdateSubresources(
20762099
return RequiredSize;
20772100
}
20782101

2102+
//------------------------------------------------------------------------------------------------
2103+
// All arrays must be populated (e.g. by calling GetCopyableFootprints)
2104+
inline UINT64 UpdateSubresources(
2105+
_In_ ID3D12GraphicsCommandList* pCmdList,
2106+
_In_ ID3D12Resource* pDestinationResource,
2107+
_In_ ID3D12Resource* pIntermediate,
2108+
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
2109+
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources,
2110+
UINT64 RequiredSize,
2111+
_In_reads_(NumSubresources) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts,
2112+
_In_reads_(NumSubresources) const UINT* pNumRows,
2113+
_In_reads_(NumSubresources) const UINT64* pRowSizesInBytes,
2114+
_In_ const void* pResourceData,
2115+
_In_reads_(NumSubresources) const D3D12_SUBRESOURCE_INFO* pSrcData) noexcept
2116+
{
2117+
// Minor validation
2118+
auto IntermediateDesc = pIntermediate->GetDesc();
2119+
auto DestinationDesc = pDestinationResource->GetDesc();
2120+
if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER ||
2121+
IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset ||
2122+
RequiredSize > SIZE_T(-1) ||
2123+
(DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER &&
2124+
(FirstSubresource != 0 || NumSubresources != 1)))
2125+
{
2126+
return 0;
2127+
}
2128+
2129+
BYTE* pData;
2130+
HRESULT hr = pIntermediate->Map(0, nullptr, reinterpret_cast<void**>(&pData));
2131+
if (FAILED(hr))
2132+
{
2133+
return 0;
2134+
}
2135+
2136+
for (UINT i = 0; i < NumSubresources; ++i)
2137+
{
2138+
if (pRowSizesInBytes[i] > SIZE_T(-1)) return 0;
2139+
D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, SIZE_T(pLayouts[i].Footprint.RowPitch) * SIZE_T(pNumRows[i]) };
2140+
MemcpySubresource(&DestData, pResourceData, &pSrcData[i], static_cast<SIZE_T>(pRowSizesInBytes[i]), pNumRows[i], pLayouts[i].Footprint.Depth);
2141+
}
2142+
pIntermediate->Unmap(0, nullptr);
2143+
2144+
if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
2145+
{
2146+
pCmdList->CopyBufferRegion(
2147+
pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width);
2148+
}
2149+
else
2150+
{
2151+
for (UINT i = 0; i < NumSubresources; ++i)
2152+
{
2153+
CD3DX12_TEXTURE_COPY_LOCATION Dst(pDestinationResource, i + FirstSubresource);
2154+
CD3DX12_TEXTURE_COPY_LOCATION Src(pIntermediate, pLayouts[i]);
2155+
pCmdList->CopyTextureRegion(&Dst, 0, 0, 0, &Src, nullptr);
2156+
}
2157+
}
2158+
return RequiredSize;
2159+
}
2160+
20792161
//------------------------------------------------------------------------------------------------
20802162
// Heap-allocating UpdateSubresources implementation
20812163
inline UINT64 UpdateSubresources(
@@ -2088,7 +2170,7 @@ inline UINT64 UpdateSubresources(
20882170
_In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept
20892171
{
20902172
UINT64 RequiredSize = 0;
2091-
UINT64 MemToAlloc = static_cast<UINT64>(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources;
2173+
auto MemToAlloc = static_cast<UINT64>(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources;
20922174
if (MemToAlloc > SIZE_MAX)
20932175
{
20942176
return 0;
@@ -2099,8 +2181,8 @@ inline UINT64 UpdateSubresources(
20992181
return 0;
21002182
}
21012183
auto pLayouts = static_cast<D3D12_PLACED_SUBRESOURCE_FOOTPRINT*>(pMem);
2102-
UINT64* pRowSizesInBytes = reinterpret_cast<UINT64*>(pLayouts + NumSubresources);
2103-
UINT* pNumRows = reinterpret_cast<UINT*>(pRowSizesInBytes + NumSubresources);
2184+
auto pRowSizesInBytes = reinterpret_cast<UINT64*>(pLayouts + NumSubresources);
2185+
auto pNumRows = reinterpret_cast<UINT*>(pRowSizesInBytes + NumSubresources);
21042186

21052187
auto Desc = pDestinationResource->GetDesc();
21062188
ID3D12Device* pDevice = nullptr;
@@ -2113,6 +2195,44 @@ inline UINT64 UpdateSubresources(
21132195
return Result;
21142196
}
21152197

2198+
//------------------------------------------------------------------------------------------------
2199+
// Heap-allocating UpdateSubresources implementation
2200+
inline UINT64 UpdateSubresources(
2201+
_In_ ID3D12GraphicsCommandList* pCmdList,
2202+
_In_ ID3D12Resource* pDestinationResource,
2203+
_In_ ID3D12Resource* pIntermediate,
2204+
UINT64 IntermediateOffset,
2205+
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
2206+
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources,
2207+
_In_ const void* pResourceData,
2208+
_In_reads_(NumSubresources) D3D12_SUBRESOURCE_INFO* pSrcData) noexcept
2209+
{
2210+
UINT64 RequiredSize = 0;
2211+
auto MemToAlloc = static_cast<UINT64>(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources;
2212+
if (MemToAlloc > SIZE_MAX)
2213+
{
2214+
return 0;
2215+
}
2216+
void* pMem = HeapAlloc(GetProcessHeap(), 0, static_cast<SIZE_T>(MemToAlloc));
2217+
if (pMem == nullptr)
2218+
{
2219+
return 0;
2220+
}
2221+
auto pLayouts = reinterpret_cast<D3D12_PLACED_SUBRESOURCE_FOOTPRINT*>(pMem);
2222+
auto pRowSizesInBytes = reinterpret_cast<UINT64*>(pLayouts + NumSubresources);
2223+
auto pNumRows = reinterpret_cast<UINT*>(pRowSizesInBytes + NumSubresources);
2224+
2225+
auto Desc = pDestinationResource->GetDesc();
2226+
ID3D12Device* pDevice = nullptr;
2227+
pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice));
2228+
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize);
2229+
pDevice->Release();
2230+
2231+
UINT64 Result = UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pResourceData, pSrcData);
2232+
HeapFree(GetProcessHeap(), 0, pMem);
2233+
return Result;
2234+
}
2235+
21162236
//------------------------------------------------------------------------------------------------
21172237
// Stack-allocating UpdateSubresources implementation
21182238
template <UINT MaxSubresources>
@@ -2121,8 +2241,8 @@ inline UINT64 UpdateSubresources(
21212241
_In_ ID3D12Resource* pDestinationResource,
21222242
_In_ ID3D12Resource* pIntermediate,
21232243
UINT64 IntermediateOffset,
2124-
_In_range_(0, MaxSubresources) UINT FirstSubresource,
2125-
_In_range_(1, MaxSubresources - FirstSubresource) UINT NumSubresources,
2244+
_In_range_(0,MaxSubresources) UINT FirstSubresource,
2245+
_In_range_(1,MaxSubresources-FirstSubresource) UINT NumSubresources,
21262246
_In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept
21272247
{
21282248
UINT64 RequiredSize = 0;
@@ -2139,6 +2259,33 @@ inline UINT64 UpdateSubresources(
21392259
return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pSrcData);
21402260
}
21412261

2262+
//------------------------------------------------------------------------------------------------
2263+
// Stack-allocating UpdateSubresources implementation
2264+
template <UINT MaxSubresources>
2265+
inline UINT64 UpdateSubresources(
2266+
_In_ ID3D12GraphicsCommandList* pCmdList,
2267+
_In_ ID3D12Resource* pDestinationResource,
2268+
_In_ ID3D12Resource* pIntermediate,
2269+
UINT64 IntermediateOffset,
2270+
_In_range_(0,MaxSubresources) UINT FirstSubresource,
2271+
_In_range_(1,MaxSubresources-FirstSubresource) UINT NumSubresources,
2272+
_In_ const void* pResourceData,
2273+
_In_reads_(NumSubresources) D3D12_SUBRESOURCE_INFO* pSrcData) noexcept
2274+
{
2275+
UINT64 RequiredSize = 0;
2276+
D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources];
2277+
UINT NumRows[MaxSubresources];
2278+
UINT64 RowSizesInBytes[MaxSubresources];
2279+
2280+
auto Desc = pDestinationResource->GetDesc();
2281+
ID3D12Device* pDevice = nullptr;
2282+
pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(&pDevice));
2283+
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize);
2284+
pDevice->Release();
2285+
2286+
return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pResourceData, pSrcData);
2287+
}
2288+
21422289
//------------------------------------------------------------------------------------------------
21432290
inline constexpr bool D3D12IsLayoutOpaque( D3D12_TEXTURE_LAYOUT Layout ) noexcept
21442291
{ return Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN || Layout == D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE; }

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ It came from a desire to quickly dive into graphics and performance experiments.
3636
## Requirements
3737
### Master branch
3838
This branch is intended for the latest [released](https://docs.microsoft.com/en-us/windows/release-information/) Windows 10 version.
39-
* Windows 10 version 2004
39+
* Windows 10 version 20H2
4040
* [Visual Studio 2019](https://www.visualstudio.com/) with the [Windows 10 SDK version 2004(19041)](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk)
4141
### Develop branch
4242
This branch is intented for features available in the latest Windows Insider Preview
43-
* [Windows 10 Insider Preview builds](https://insider.windows.com/en-us/how-to-pc/#install-windows-10-insider-preview) ([Fast ring](https://insider.windows.com/en-us/how-to-pc/#working-with-rings))
43+
* [Windows 10 Insider Preview builds](https://docs.microsoft.com/en-us/windows-insider/developers/get-started) ([Dev Channel](https://docs.microsoft.com/en-us/windows-insider/flighting))
4444
* [Visual Studio 2019](https://www.visualstudio.com/) with the [Windows 10 Insider Preview SDK](https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewSDK)
4545

4646
## Contributing
4747
We're always looking for your help to fix bugs and improve the samples. File those pull requests and we'll be happy to take a look.
4848

49-
Find more information on DirectX 12 on our blog: http://blogs.msdn.com/b/directx/
49+
Find more information on DirectX 12 on our blog: https://devblogs.microsoft.com/directx/
5050

5151
Troubleshooting information for this repository can be found in the site [Wiki](https://github.com/Microsoft/DirectX-Graphics-Samples/wiki).
5252

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
# 11 on 12 Sample
1+
---
2+
page_type: sample
3+
languages:
4+
- cpp
5+
products:
6+
- windows-api-win32
7+
name: Direct3D 12 11-on-12 sample
8+
urlFragment: d3d12-11-on-12-sample-win32
9+
description: Demonstrates how to use Direct3D 11-based rendering in combination with Direct3D 12.
10+
extendedZipContent:
11+
- path: LICENSE
12+
target: LICENSE
13+
---
14+
15+
# Direct3D 12 11-on-12 sample
16+
217
![11On12 GUI](src/D3D1211On12.png)
318

4-
This sample demonstrates how to use Direct3D 11 based rendering in combination with Direct3D 12 by sharing devices, command queues and resources between the 2 API versions. The sample illustrates this by using Direct2D to render a UI over Direct3D 12 content. This ability to share resources between runtimes makes porting apps/engines to 12 simpler as entire 11-based components, such as a UI system, can remain virtually untouched.
19+
This sample demonstrates how to use Direct3D 11 based rendering in combination with Direct3D 12 by sharing devices, command queues and resources between the 2 API versions. The sample illustrates this by using Direct2D to render a UI over Direct3D 12 content. This ability to share resources between runtimes makes porting apps/engines to 12 simpler as entire 11-based components, such as a UI system, can remain virtually untouched.
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1-
# Bundles Sample
1+
---
2+
page_type: sample
3+
languages:
4+
- cpp
5+
products:
6+
- windows-api-win32
7+
name: Direct3D 12 bundles sample
8+
urlFragment: d3d12-bundles-sample-win32
9+
description: Demonstrates the use of Direct3D 12 bundles.
10+
extendedZipContent:
11+
- path: LICENSE
12+
target: LICENSE
13+
---
14+
15+
# Direct3D 12 bundles sample
16+
217
![Bundles GUI](src/D3D12Bundles.png)
318

4-
This sample demonstrates the use of Direct3D 12 Bundles. An app can use Bundles to group a small number of API commands together for execution later. When a Bundle is created, the driver will perform as much pre-processing as possible to make it inexpensive to execute the Bundle later. Part of this pre-processing means that there are certain restrictions on what operations can be performed within a Bundle.
19+
This sample demonstrates the use of Direct3D 12 bundles. An app can use bundles to group a small number of API commands together for execution later. When a bundle is created, the driver will perform as much pre-processing as possible to make it inexpensive to execute the bundle later. Part of this pre-processing means that there are certain restrictions on what operations can be performed within a bundle.
20+
21+
## Optional features
522

6-
### Optional Features
7-
This sample has been updated to build against the Windows 10 Anniversary Update SDK. In this SDK a new revision of Root Signatures is available for Direct3D 12 apps to use. Root Signature 1.1 allows for apps to declare when descriptors in a descriptor heap won't change or the data descriptors point to won't change. This allows the option for drivers to make optimizations that might be possible knowing that something (like a descriptor or the memory it points to) is static for some period of time.
23+
This sample has been updated to build against the Windows 10 Anniversary Update SDK. In this SDK a new revision of Root Signatures is available for Direct3D 12 apps to use. Root Signature 1.1 allows for apps to declare when descriptors in a descriptor heap won't change or the data descriptors point to won't change. This allows the option for drivers to make optimizations that might be possible knowing that something (like a descriptor or the memory it points to) is static for some period of time.
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
# Depth Bounds Test Sample
1+
---
2+
page_type: sample
3+
languages:
4+
- cpp
5+
products:
6+
- windows-api-win32
7+
name: Direct3D 12 depth bounds test sample
8+
urlFragment: d3d12-depth-bounds-test-sample-win32
9+
description: Demonstrates the depth bound test in Direct3D 12.
10+
extendedZipContent:
11+
- path: LICENSE
12+
target: LICENSE
13+
---
14+
15+
# Direct3D 12 depth bounds test sample
216
![DepthBounds GUI](src/D3D12DepthBoundsTest.png)
317

418
This sample demonstrates the depth bound test in Direct3D 12.
519
Depth-bounds testing allows pixels to be discarded if the currently-stored depth value is outside the range specified by Min and Max, inclusive.
620

7-
See more detail about depth bounds test in the following page. https://msdn.microsoft.com/en-us/library/windows/desktop/mt492658(v=vs.85).aspx
21+
For more detail about depth bounds test, see [**ID3D12GraphicsCommandList1::OMSetDepthBounds**](https://docs.microsoft.com/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist1-omsetdepthbounds).

0 commit comments

Comments
 (0)