Skip to content

Commit

Permalink
Merge pull request microsoft#271 from Microsoft/develop
Browse files Browse the repository at this point in the history
Add DepthBoundsTest and SM6WaveIntrinsics samples
  • Loading branch information
shuweihsu committed Sep 8, 2017
2 parents de88800 + 55afbfa commit f61c63d
Show file tree
Hide file tree
Showing 90 changed files with 18,179 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Samples/Desktop/D3D12DepthBoundsTest/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Depth Bounds Test Sample
This sample demonstrates the depth bound test in Direct3D 12.
Depth-bounds testing allows pixels to be discarded if the currently-stored depth value is outside the range specified by Min and Max, inclusive.

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
458 changes: 458 additions & 0 deletions Samples/Desktop/D3D12DepthBoundsTest/src/D3D12DepthBoundsTest.cpp

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions Samples/Desktop/D3D12DepthBoundsTest/src/D3D12DepthBoundsTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

#pragma once

#include "DXSample.h"

using namespace DirectX;

// Note that while ComPtr is used to manage the lifetime of resources on the CPU,
// it has no understanding of the lifetime of resources on the GPU. Apps must account
// for the GPU lifetime of resources to avoid destroying objects that may still be
// referenced by the GPU.
// An example of this can be found in the class method: OnDestroy().
using Microsoft::WRL::ComPtr;

class D3D12DepthBoundsTest : public DXSample
{
public:
D3D12DepthBoundsTest(UINT width, UINT height, std::wstring name);

virtual void OnInit();
virtual void OnUpdate();
virtual void OnRender();
virtual void OnDestroy();

private:
static const UINT FrameCount = 2;

struct Vertex
{
XMFLOAT3 position;
XMFLOAT4 color;
};

// Pipeline objects.
CD3DX12_VIEWPORT m_viewport;
CD3DX12_RECT m_scissorRect;
ComPtr<IDXGISwapChain3> m_swapChain;
ComPtr<ID3D12Device2> m_device;
ComPtr<ID3D12Resource> m_depthStencil;
ComPtr<ID3D12Resource> m_renderTargets[FrameCount];
ComPtr<ID3D12CommandAllocator> m_commandAllocator;
ComPtr<ID3D12CommandQueue> m_commandQueue;
ComPtr<ID3D12RootSignature> m_rootSignature;
ComPtr<ID3D12DescriptorHeap> m_rtvHeap;
ComPtr<ID3D12DescriptorHeap> m_dsvHeap;
ComPtr<ID3D12PipelineState> m_pipelineState;
ComPtr<ID3D12PipelineState> m_depthOnlyPipelineState;
ComPtr<ID3D12GraphicsCommandList1> m_commandList;
UINT m_rtvDescriptorSize;
bool DepthBoundsTestSupported;

// App resources.
ComPtr<ID3D12Resource> m_vertexBuffer;
D3D12_VERTEX_BUFFER_VIEW m_vertexBufferView;

// Synchronization objects.
UINT m_frameIndex;
UINT m_frameNumber;
HANDLE m_fenceEvent;
ComPtr<ID3D12Fence> m_fence;
UINT64 m_fenceValue;

void LoadPipeline();
void LoadAssets();
void PopulateCommandList();
void WaitForPreviousFrame();
};
22 changes: 22 additions & 0 deletions Samples/Desktop/D3D12DepthBoundsTest/src/D3D12DepthBoundsTest.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "D3D12DepthBoundsTest", "D3D12DepthBoundsTest.vcxproj", "{A6DB1D1C-E2EE-462D-AC61-0E3100C010DF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A6DB1D1C-E2EE-462D-AC61-0E3100C010DF}.Debug|x64.ActiveCfg = Debug|x64
{A6DB1D1C-E2EE-462D-AC61-0E3100C010DF}.Debug|x64.Build.0 = Debug|x64
{A6DB1D1C-E2EE-462D-AC61-0E3100C010DF}.Release|x64.ActiveCfg = Release|x64
{A6DB1D1C-E2EE-462D-AC61-0E3100C010DF}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
144 changes: 144 additions & 0 deletions Samples/Desktop/D3D12DepthBoundsTest/src/D3D12DepthBoundsTest.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A6DB1D1C-E2EE-462D-AC61-0E3100C010DF}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>D3D12DepthBoundsTest</RootNamespace>
<ProjectName>D3D12DepthBoundsTest</ProjectName>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>obj\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories></AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>dxgi.lib;d3d12.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>d3d12.dll</DelayLoadDLLs>
</Link>
<CustomBuildStep>
<TreatOutputAsContent>true</TreatOutputAsContent>
</CustomBuildStep>
<CustomBuild>
<Command>copy %(Identity) "$(OutDir)" &gt; NUL</Command>
<Outputs>$(OutDir)\%(Identity)</Outputs>
<TreatOutputAsContent>true</TreatOutputAsContent>
</CustomBuild>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories></AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>dxgi.lib;d3d12.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>d3d12.dll</DelayLoadDLLs>
</Link>
<CustomBuildStep>
<TreatOutputAsContent>true</TreatOutputAsContent>
</CustomBuildStep>
<CustomBuild>
<Command>copy %(Identity) "$(OutDir)" &gt; NUL</Command>
<Outputs>$(OutDir)\%(Identity)</Outputs>
<TreatOutputAsContent>true</TreatOutputAsContent>
</CustomBuild>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Win32Application.h" />
<ClInclude Include="D3D12DepthBoundsTest.h" />
<ClInclude Include="d3dx12.h" />
<ClInclude Include="DXSampleHelper.h" />
<ClInclude Include="DXSample.h" />
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Win32Application.cpp" />
<ClCompile Include="D3D12DepthBoundsTest.cpp" />
<ClCompile Include="DXSample.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="shaders.hlsl">
<FileType>Document</FileType>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(SolutionDir)packages\WinPixEventRuntime.1.0.161208001\build\WinPixEventRuntime.targets" Condition="Exists('$(SolutionDir)packages\WinPixEventRuntime.1.0.161208001\build\WinPixEventRuntime.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)packages\WinPixEventRuntime.1.0.161208001\build\WinPixEventRuntime.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)packages\WinPixEventRuntime.1.0.161208001\build\WinPixEventRuntime.targets'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Assets">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Assets\Shaders">
<UniqueIdentifier>{87788291-3613-4c42-91dc-3db92926ea4b}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Util">
<UniqueIdentifier>{397dbb21-1402-469f-ac27-57434b027744}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Util">
<UniqueIdentifier>{10f3c935-7b57-4931-a129-46f6b9c57fa9}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="d3dx12.h">
<Filter>Header Files\Util</Filter>
</ClInclude>
<ClInclude Include="DXSample.h">
<Filter>Header Files\Util</Filter>
</ClInclude>
<ClInclude Include="DXSampleHelper.h">
<Filter>Header Files\Util</Filter>
</ClInclude>
<ClInclude Include="D3D12DepthBoundsTest.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Win32Application.h">
<Filter>Header Files\Util</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DXSample.cpp">
<Filter>Source Files\Util</Filter>
</ClCompile>
<ClCompile Include="D3D12DepthBoundsTest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Win32Application.cpp">
<Filter>Source Files\Util</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="shaders.hlsl">
<Filter>Assets\Shaders</Filter>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>
Loading

0 comments on commit f61c63d

Please sign in to comment.