Giter VIP home page Giter VIP logo

directx-graphics-samples's Introduction

DirectX-Graphics-Samples

This repo contains the DirectX 12 Graphics samples that demonstrate how to build graphics intensive applications for Windows 10.

We invite you to join us at our discord server. See our YouTube channel for tutorials, our spec repo for engineering specs of our features and devblogs for blog posts. Follow us on Twitter @DirectX12 for the latest! See the related links section for our full list of DX12-related links.

Finally, make sure that you visit the DirectX Landing Page for more resources for DirectX developers.

API Samples

In the Samples directory, you will find samples that attempt to break off specific features and specific usage scenarios into bite-sized chunks. For example, the ExecuteIndirect sample will show you just enough about execute indirect to get started with that feature without diving too deep into multiengine whereas the nBodyGravity sample will delve into multiengine without touching on the execute indirect feature etc. By doing this, we hope to make it easier to get started with DirectX 12.

DirectX 12 Ultimate samples

  1. D3D12 Mesh Shaders: This sample demonstrates how Mesh shaders can be used to increase the flexibility and performance of the geometry pipeline.

    D3D12 Meshlet Render preview
  2. D3D12 Variable Rate Shading: This sample demonstrates how shading rate can be reduced with little or no reduction in visual quality, leading to β€œfree” performance.

    D3D12 Variable Rate Shading GUI
  3. D3D12 Raytracing: This sample demonstrates how DirectX Raytracing (DXR) brings a new level of graphics realism to video games, previously only achievable in the movie industry.

    D3D12 Raytracing Real-Time Denoised Ambient Occlusion preview

MiniEngine: A DirectX 12 Engine Starter Kit

In addition to the samples, we are announcing the first DirectX 12 preview release of the MiniEngine.

It came from a desire to quickly dive into graphics and performance experiments. We knew we would need some basic building blocks whenever starting a new 3D app, and we had already written these things at countless previous gigs. We got tired of reinventing the wheel, so we established our own core library of helper classes and platform abstractions. We wanted to be able to create a new app by writing just the Init(), Update(), and Render() functions and leveraging as much reusable code as possible. Today our core library has been redesigned for DirectX 12 and aims to serve as an example of efficient API usage. It is obviously not exhaustive of what a game engine needs, but it can serve as the cornerstone of something new. You can also borrow whatever useful code you find.

Some features of MiniEngine

  • High-quality anti-aliased text rendering
  • Real-time CPU and GPU profiling
  • User-controlled variables
  • Game controller, mouse, and keyboard input
  • A friendly DirectXMath wrapper
  • Perspective camera supporting traditional and reversed Z matrices
  • Asynchronous DDS texture loading and ZLib decompression
  • Large library of shaders
  • Easy shader embedding via a compile-to-header system
  • Easy render target, depth target, and unordered access view creation
  • A thread-safe GPU command context system (WIP)
  • Easy-to-use dynamic constant buffers and descriptor tables

Requirements

Some samples require support for DirectX 12 Ultimate, see this post for details.

Master branch

This branch is intended for the latest released Windows 10 version.

Develop branch

This branch is intended for features available in the latest Windows Insider Preview

Contributing

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.

Troubleshooting information for this repository can be found in the site Wiki.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Related links

directx-graphics-samples's People

Contributors

amarpmsft avatar amarptest avatar anyeung avatar austinkinross avatar bobbrow avatar braaad avatar clandrew avatar gashar avatar haydntrigg avatar jacquesvanrhynmsft avatar jenatali avatar kevgee avatar kingofthebongo2008 avatar londey avatar mhurliman avatar missmah avatar nadaouf avatar nicom1 avatar rgerd avatar robbiesri avatar sebmerry avatar shuweihsu avatar soeom avatar stanard avatar stevewhims avatar theraddestbro avatar tyfkda avatar walbourn avatar wallisc avatar xiangtin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

directx-graphics-samples's Issues

passing macro def to D3DCompileFromFile causes access violation error

Hi

I am wondering whether dx12 D3DCompileFromFile function work with passing in macro def? I have the following code not working (crash at that point)

D3D_SHADER_MACRO macroDef[1] = { "COMPUTESHADER", "1" };

VRET( CompileShaderFromFile( GetAssetFullPath( _T( "VolumetricAnimation_shader.hlsl" ) ).c_str(), macroDef, D3D_COMPILE_STANDARD_FILE_INCLUDE, "vsmain", "vs_5_0", compileFlags, 0, &vertexShader ) );

Similar code work in dx11, and the D3D_SHADER_MACRO usage is exactly like the msdn. So does dx12 uses different way to pass in macro def? or there are other flag I have to set to achieve that?

Thanks

PIX event name not show up in GPU usage

For ModelViewer sample, even with PIXBeginEvent(...) get called in the right place, GPUusage panel only shows unknown for evey events. Does the pix stuff not working currently?

C++14 std-like directx 12 wrapper?

Hello. I suggest make C++14 std-like Directx 12 wrapper.

For example. Declaring UAV:

D3D12::Buffer<sometype>  uavbuffer(... );

Creating program (function) :

D3D12::Program prog(....);
D3D12::RootTable root;
root[0] = D3D12::Register(... /* 0 as UAV,  in pixel shader */);
auto func = make_compute(program, root, etc... );

Calling:

func(D3D12::EnqueueArg(queue, count), uavbuffer) //accumulate calls
queue.execute() //execute
queue.finish()

Question about multithreading shader

Hello,

this is a short question about the shader attached in multithreading sample:

in CalcUnshadowedAmountPCF2x2 function (line 104 of shaders.hlsl)

the following lines:

// Find sub-pixel weights
float2 vShadowMapDims = float2(1280.0f / 2, 720.0f / 2); // need to keep in sync with .cpp file
float4 vSubPixelCoords = float4(1.0f, 1.0f, 1.0f, 1.0f);
vSubPixelCoords.xy = frac(vShadowMapDims * vShadowTexCoord);
vSubPixelCoords.zw = 1.0f - vSubPixelCoords.xy;
float4 vBilinearWeights = vSubPixelCoords.zxzx * vSubPixelCoords.wwyy;

doesn't do anything to the result or i'm missing something?

the return code is:

return (txShadow.Sample(sampleClamp, vShadowTexCoord).r >= vLightSpaceDepth) ? 1.0 : 0.0f;

the shadow map sampler is using
D3D12_FILTER_MIN_MAG_MIP_POINT

it looks like hard shadows and not percentage close filtering or i'm wrong?

thanks

Marc

Cannot build ModelViewer with Release configure

Core project (Build_VS14\x64\Release\Output\Core\Core.lib) failed to build for ModelViewer in Release configuration using Visual Studio 2015 Update1 with the following error message (while Debug configuration is correct):

1>  FXAA.cpp
1>  GameInput.cpp
1>  GameCore.cpp
1>  GpuBuffer.cpp
1>  GpuTimeManager.cpp
1>  GraphicsCore.cpp
1>  Generating Code...
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0(909): fatal error C1001: An internal error has occurred in the compiler.
1>  (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 246)
1>   To work around this problem, try simplifying or changing the program near the locations listed above.
1>  Please choose the Technical Support command on the Visual C++
1>   Help menu, or open the Technical Support help file for more information
1>    CL!InvokeCompilerPass()+0x2d4bd
1>    CL!DllGetC2Telemetry()+0xae663
1>

And this is my visual studio version information:

Microsoft Visual Studio Professional 2015
Version 14.0.24720.00 Update 1
Microsoft .NET Framework
Version 4.6.01038

Installed Version: Professional

LightSwitch for Visual Studio 2015   00322-40000-00000-AA238
Microsoft LightSwitch for Visual Studio 2015

Visual Basic 2015   00322-40000-00000-AA238
Microsoft Visual Basic 2015

Visual C# 2015   00322-40000-00000-AA238
Microsoft Visual C# 2015

Visual C++ 2015   00322-40000-00000-AA238
Microsoft Visual C++ 2015

Visual F# 2015   00322-40000-00000-AA238
Microsoft Visual F# 2015

Windows Phone SDK 8.0 - ENU   00322-40000-00000-AA238
Windows Phone SDK 8.0 - ENU

AnalyzePackage   1.0
OpenCL Analyze package

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015.1 (Beta8)   14.1.11106.0
ASP.NET and Web Tools 2015.1 (Beta8)

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.30624.0
For additional information, visit http://www.asp.net/

Code Builder - API Debugger   4.0.0.1
Enables various API debugging facilities for OpenCL applications. These include (among other features): tracing, dumping buffers & images and visualizing the active OpenCL objects during debug session and afterwards.

CodeBuilderSessionManager   1.0.0.0
This package is in charge of managing all code builder sessions in the VS instance. A session is made of 1 or more cl files.

CodeBuilderTopMenu   1.0
This package is the top menu item in VS for Code Builder. This is the parent object for all other menu items in other packages.

Common Azure Tools   1.5
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GitHub.VisualStudio   1.0
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

KofePackagePackage Extension   1.0
KofePackagePackage Visual Studio Extension Detailed Info

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

NuGet Package Manager   3.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

OCLDebugConfig   1.0
Information about my package

Office Developer Tools for Visual Studio 2015 ENU   14.0.23025
Microsoft Office Developer Tools for Visual Studio 2015 ENU

OpenCL Debug Engine   1
Intel(R) OpenCL Debug Engine

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Python Tools for Visual Studio   2.2.31105.00
Python Tools for Visual Studio provides IntelliSense, projects, templates, Interactive windows, and other support for Python developers.

Python Tools for Visual Studio - Django Integration   2.2.31105.00
Provides templates and integration for the Django web framework.

Python Tools for Visual Studio - Profiling Support   2.2.31105.00
Profiling support for Python projects.

SQL Server Data Tools   14.0.50616.0
Microsoft SQL Server Data Tools

Visual Assist   
For more information about Visual Assist, see the Whole Tomato Software website at http://www.WholeTomato.com. Copyright (c) 1997-2015 Whole Tomato Software, Inc.

Visual C++ for Cross Platform Mobile Development   1.0
Visual C++ for Cross Platform Mobile Development

Visual C++ for Cross Platform Mobile Development   1.0
Visual C++ for Cross Platform Mobile Development

Visual Studio Tools for Universal Windows Apps   14.0.24720.00
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   4.0.0.1717 (1390b70)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   6.0.0.35 (d300845)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   9.3.99.33 (ea30b32)
Visual Studio extension to enable development for Xamarin.iOS.

Fatal error in Visual Studio Compiler after VS Update 1

Last week I updated to VS Update 1 RC and after which the Core project in MiniEngine fails to compile the "Profile" and "Release" targets with the following error:

1>  Generating Code...
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\memory(1618): fatal error C1001: An internal error has occurred in the compiler.
1>  (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 246)
1>   To work around this problem, try simplifying or changing the program near the locations listed above.
1>  Please choose the Technical Support command on the Visual C++
1>   Help menu, or open the Technical Support help file for more information
1>    CL!InvokeCompilerPass()+0x2d4bd
1>    CL!DllGetC2Telemetry()+0xae663

The error is not specific to a particular file in the project but it always happens in the Generating Code... stage of compilation.

I thought this had something to do with changes I made to the codebase and perhaps the issue would be fixed after an update to Update 1 (official, and not RC). Well I applied the official Update 1 today and the issue persists. Also to eliminate the chance that it had something to do with something I was doing, I downloaded the GitHub repo again to another folder and tried to compile but the issue persists so I hope this issue is easily reproducible.

Consequently, the "Debug" target compiles without error so to allow the Profile and Release targets to build, I simply disabled optimizations (/Od) and this works, but would I would prefer to have optimizations enabled for these builds.

Has anyone else experienced this issue after updating to VS 2015 Update 1 and knows of a better fix/workaround?

nVidia driver crashes on window resize on hybrid laptop

Just add the following line to the code to enable NVidia high performance GPU on laptops.
Works fine until you want to resize the window. Then black magic happens and dx12 device is being removed with error code: DXGI_ERROR_DRIVER_INTERNAL_ERROR

// http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
// The following line is to favor the high performance NVIDIA GPU if there are multiple GPUs
extern "C" { _declspec(dllexport) unsigned int NvOptimusEnablement = 0x00000001; }

Any chance to fix it? NVidia knows about it?
Of course transition fullscreen<->windowed works ok.

CreateEventEx parameters are misleading

All examples use CreateEventEx(nullptr, FALSE, FALSE, EVENT_ALL_ACCESS) but the types used do not match the types in the method declaration. It still works with these exact parameters because FALSE == NULL == 0 but is misleading to the reader.

It should be either CreateEventEx(nullptr, nulltrp, 0, EVENT_ALL_ACCESS) or CreateEvent(nullptr, FALSE, FALSE, nullptr)

What is the maximum value of SyncInterval value in IDXGISwapChain::Present()?

Hi.

I'm trying to understand how Present() work and for this reason I'm tweaking some parameters. I'm using DXGI_SWAP_CHAIN_DESC1 with DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL when creating a swap chain and documentation says that for flip model SyncInterval > 0 - Synchronize presentation for at least n vertical blanks. But the maximum value is 4 (DXGI ERROR: IDXGISwapChain::Present: SyncInterval must be less than or equal to 4.), as for the bitblt.

Resizing swapchain with D3D11On12

Sorry if I am missing something obvious, but I modified the 11On12 sample to respond to WM_SIZE messages. The problem I am having is that I always get this error message:

DXGI ERROR: IDXGISwapChain::ResizeBuffers: Swapchain cannot be resized unless all outstanding buffer references have been released. [ MISCELLANEOUS ERROR #19: ]

Here is the code:

void D3D1211on12::Resize(UINT width, UINT height)
{
    for(UINT n = 0; n < FrameCount; n++)
    {
        m_renderTargets[n].Reset();
        m_wrappedBackBuffers[n].Reset();
        m_d2dRenderTargets[n].Reset();
        m_commandAllocators[n].Reset();
    }

    m_d3d11DeviceContext->Flush();

    m_swapChain->ResizeBuffers(FrameCount, width, height, DXGI_FORMAT_R8G8B8A8_UNORM, 0);

    m_viewport.Width = static_cast<float>(width);
    m_viewport.Height = static_cast<float>(height);

    m_scissorRect.right = static_cast<LONG>(width);
    m_scissorRect.bottom = static_cast<LONG>(height);

    // Query the desktop's dpi settings, which will be used to create
    // D2D's render targets.
    float dpiX;
    float dpiY;
    m_d2dFactory->GetDesktopDpi(&dpiX, &dpiY);
    D2D1_BITMAP_PROPERTIES1 bitmapProperties = D2D1::BitmapProperties1(
        D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW,
        D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
        dpiX,
        dpiY
        );

    // Create frame resources.
    {
        CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_rtvHeap->GetCPUDescriptorHandleForHeapStart());

        // Create a RTV, D2D render target, and a command allocator for each frame.
        for(UINT n = 0; n < FrameCount; n++)
        {
            ThrowIfFailed(m_swapChain->GetBuffer(n, IID_PPV_ARGS(&m_renderTargets[n])));
            m_d3d12Device->CreateRenderTargetView(m_renderTargets[n].Get(), nullptr, rtvHandle);

            // Create a wrapped 11On12 resource of this back buffer. Since we are 
            // rendering all D3D12 content first and then all D2D content, we specify 
            // the In resource state as RENDER_TARGET - because D3D12 will have last 
            // used it in this state - and the Out resource state as PRESENT. When 
            // ReleaseWrappedResources() is called on the 11On12 device, the resource 
            // will be transitioned to the PRESENT state.
            D3D11_RESOURCE_FLAGS d3d11Flags = { D3D11_BIND_RENDER_TARGET };
            ThrowIfFailed(m_d3d11On12Device->CreateWrappedResource(
                m_renderTargets[n].Get(),
                &d3d11Flags,
                D3D12_RESOURCE_STATE_RENDER_TARGET,
                D3D12_RESOURCE_STATE_PRESENT,
                IID_PPV_ARGS(&m_wrappedBackBuffers[n])
                ));

            // Create a render target for D2D to draw directly to this back buffer.
            ComPtr<IDXGISurface> surface;
            ThrowIfFailed(m_wrappedBackBuffers[n].As(&surface));
            ThrowIfFailed(m_d2dDeviceContext->CreateBitmapFromDxgiSurface(
                surface.Get(),
                &bitmapProperties,
                &m_d2dRenderTargets[n]
                ));

            rtvHandle.Offset(1, m_rtvDescriptorSize);

            ThrowIfFailed(m_d3d12Device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m_commandAllocators[n])));
        }
    }
}

I've also tried destroying and recreating the swapchain, but I always get an exception at

ThrowIfFailed(System::GetDXGIFactory()->CreateSwapChain(m_commandQueue.Get(), &swapchainDesc, &swapchain));

which returns

E_ACCESSDENIED General access denied error.

Exception thrown at 0x767D3E28 in TestClient.exe: Microsoft C++ exception: _com_error at memory location 0x00ACEF80.
Exception thrown at 0x767D3E28 in TestClient.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
Unhandled exception at 0x767D3E28 (KernelBase.dll) in TestClient.exe: 0xC000041D: An unhandled exception was encountered during a user callback.

along with often making Visual Studio unresponsive. I also get the same error if I try to create multiple swapchains.

Textured triangle sample?

How about a simple texture on a triangle sample? Wanted to see how one might load texture data in D3D12.

D3D1211On12 sample exception

The debug version of the 11On12 sample produces the exception:

Exception thrown at 0x00007FFE21AEA1C8 in D3D1211On12.exe: Microsoft C++ exception: _com_error at memory location 0x000000609DD8E3C0.

at the line 407 of D3D1211On12.cpp:

ThrowIfFailed(m_d2dDeviceContext->EndDraw());

but not on the first call.

This unfortunately spams the debug output so a fix would be appreciated.

Link error C2375, redefinition when including WinSock2.h

Redefinition error occurring when doing networking through WinSock2. Fixed with Mini Engine file "pch.h" modified to have WIN32_LEAN_AND_MEAN moved earlier in file and defined before any other header files:

pragma once

define WIN32_LEAN_AND_MEAN

...
BTW, your team has done awesome work! Thank you so much for this repository and great examples.

Win32 vs UWP

I wasn't sure where else to ask this so feel free to remove if this isn't the appropriate place. I noticed the samples are all using Win32 instead of the new UWP API's. Is that the recommended approach of making DX12 applications? Or was it just an arbitrary decision for the samples?

Examples won't run if first adapter doesn't support DX12

All examples pass nullptr as the first argument to D3D12CreateDevice. The implementation of D3D12CreateDevice is flawed in that it will pick the first adapter, regardless of whether it supports DX12 or not. This will result in device creation failing if the first adapter doesn't support DX12 but the second adapter does.

D3D12CreateDevice either needs to be fixed to pick the first working adapter (probably too late for that?), or the samples should be fixed to autodetect the first working adapter. Nobody should use the current flawed implementation of passing nullptr as first argument, because that means the application/game won't run on random machines which are unlucky enough to have their DX12 adapter in second position.

Weird frame rate sometimes locked to 125fps even do just present with 3 backbuffers with vsync off

Hi,
I have noticed some wired perf drop when running some of the samples with 3 backbuffer and present(0,0): after keeping resizing the window for a while, the fps is locked to 125(8ms/frame) for a while. But when you have 5 backbuffer, this doesn't happen.

I have observed the same issue for D3D12HelloConstBuffers on multiple machines (change backbuffer count to 3, and use present(0,0) instead of present(1,0), and keeping resizing the window until that happen). And this even happen when we just have present(0,0) on OnRender() func.

One interesting thing I noticed is that whenever the fps lock happened, the dwm.exe cpu time drops from 7.5% to 5.2%. So I am not sure whether its the dwm causes that drop or it's the reverse way...

Anyway, this confuses me a lot, I have tried change the swapchain params, dxgi present modes, but non of them helps

D3D12 online docs: bug in D3D12_GPU/CPU_DESCRIPTOR_HANDLE

[Update: fixed link]

A minor, but quite confusing doc bug in D3D12_GPU_DESCRIPTOR_HANDLE and D3D12_CPU_DESCRIPTOR_HANDLE, says that the ptr element is "The size, in bytes, of the block of memory that the GPU descriptor handle points to."

Shouldn't this be something like "a cpu/gpu accessible opaque pointer to a descriptor in a descriptor heap"?

See:

https://msdn.microsoft.com/en-us/library/windows/desktop/dn859391(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/desktop/dn859369(v=vs.85).aspx

Is there a better place for reporting doc bugs?

Is it a good practice to set GPU read only resource state to just GENERIC_READ?

As mentioned in the title, I have noticed that for most GPU read only resources MiniEngine set their states to GENERIC_READ (like the linearAllocator for vertex buffer, index buffer, constant buffer...). So my question is that: is there any downside for giving all read only resource GENERIC_READ state instead of being more specific?

Also I am curious why the GENERIC_READ flag hasn't include DEPTH_READ flag which by its name should be a read state...

Thanks

Merry Xmas

Request: ASSIMP integration

This weekend I plan to try and incorporate the Assimp library into one of my test projects that is also using the mini-engine. I noticed that there is already a stub in the code for loading from ASSIMP library, was this code actually created? if so, are there any plans to release it?

Thank you for all the time you all have put into this, it has really helped!!!

unhandled exception

When i start debug application thrown exception
122
My system:
Windows 10 Pro Insider Preview 10162
Visual Studio 2015
Windows SDK 10240
Videocard: nVidia GeForce GT 630 (353.62 driver version)

Device removal has been triggered

I'm using MiniEngine core library to create a DX12 experiment for my master thesis.

In my experiment, I am creating a StructuredBuffer for the dynamic lights in the scene. I want to be able to resize the StructuredBuffer if I add lights (or reduce the StructuredBuffer if I remove lights). In my implementation of the IGameApp class, I override the Update function and in that function the light buffer will be resized if the user presses a key on the keyboard. To resize the buffer, the GpuBuffer::Create method is used on the StructuredBuffer object. The StructuredBuffer object is not destroyed, only the Create method is used to recreate the buffer resource.

The problem is that (seemingly randomly but is more easily reproducible with larger buffers) a device removal is triggered:

D3D12: Removing Device.
D3D12 ERROR: ID3D12Device::RemoveDevice: Device removal has been triggered for the following reason (DXGI_ERROR_DEVICE_HUNG: The Device took an unreasonable amount of time to execute its commands, or the hardware crashed/hung. As a result, the TDR (Timeout Detection and Recovery) mechanism has been triggered. The current Device Context was executing commands when the hang occurred. The application may want to respawn and fallback to less aggressive use of the display hardware). [ EXECUTION ERROR #232: DEVICE_REMOVAL_PROCESS_AT_FAULT]
D3D12: **BREAK** enabled for the previous message, which was: [ ERROR EXECUTION #232: DEVICE_REMOVAL_PROCESS_AT_FAULT ]

The error occurs 100% in the CommandListManager::ExecuteCommandList method when the m_CommandQueue->ExecuteCommandLists gets invoked.

The size of the StructuredBuffer doesn't seem to matter. It happens if I only have 10 lights (1 KB) or 32 lights (3.5 KB) but the more lights, the more likely the timeout will occur. I suspect it's a threading issue as device removal should not occur when uploading only a few KB to a structured buffer.

Any ideas?

Hello World Samples Not Working

When I ran the hello world samples in VS 2015 Community I was getting cryptic exception messages everywhere and the program was failing to run. I was using the D3D12HelloWorld.sln found at Samples\D3D12HelloWorld\src. If needed I can give the exact error message

Add Copies of the Visual Studio DX12 templates to GitHub

Suggested in the conversation of issue #7. Splitting it out as a separate issue since I do not intend to close issue #7. I expect that question to come up again otherwise.

This issue covers adding both the CoreWindow DX12 template, and a preview of the XAML DX12 template. These will go into a folder called "Templates", but note that they will not be in the format Visual Studio recognizes as a "template". They will be in a consumable "sample" format, essentially what you get when you create a new project in Visual Studio using the template.

Multiple DirectX12 contexts in one application

Hello! I've been trying to set up DirectX12 so that multiple device contexts can be run from different threads. However, this only seems to work when driving all the contexts from the same thread, otherwise ->Present() seems to deadlock. I've tried the same thing on a DirectX11 demo, where it does work.

Also, this seems to happen with either the WARP device, or my NVIDIA card, making me suspect something's going on in DXGI. I also made a minimal reproducable testcase, if you wish I could share my modifications to the Hello World example to create multiple contexts run at different threads.

Am I doing something wrong here, or is this a limitation/known issue right now?

MiniEngine crash on the Nvidia Optimus platform

Hi
Function failed when D3D12CreateDevice(...) method take NULL as it first parameter,after D3D12CreateDevice(...) method finished i found that output pointer (ID3D12Device device) still NULL,
It seems like that device initialization works incorrectly on the multi gpu platforms.
Explicit enumerate available gpu and take them as first parameter sequentially to initialize device with D3D12CreateDevice(...) works correctly on my laptop.

ps: It can enumerate three device(intel hd 4000,nv gt645m,and microsoft base renderer) on my laptop,and every device can accomplish it works.

Graphics card version: gt645m
Nvidia driver version:353.62
sdk version: 10.0.10240.0 with IDE :vs 2015
Is Driver problems? Or i missed some command line / options that can change device?

In GraphicsCore.cpp:

image

Question/Request: Deferred rendering on dx12

Hello,

this is first of all a question, i'm trying to understand how i can use multiple render targets on dx12 to get one single vertex shader pass and then n pixel shader executions to different gbuffers

currently i'm studding miniengine, and now i can do one vertex and one pixel shader to a gbuffer that can be redirected as shader resource view to another pixel shader

in the pipeline state descriptor you can add NumRenderTargets but i didn't get where i can set the different pixel shader output and also OMSetRenderTargets in command buffer

maybe another sample include this question or in the programming guide (https://msdn.microsoft.com/en-us/library/windows/desktop/Dn899121(v=VS.85).aspx) but i didn't find apart on the miniengine but the codebase is really large and i'm not sure if it's solved here

in any case, if you are busy and only answer the question i can share the result work in a pull request later

maybe this is an obvious question and it's solved in these samples but my opengl background is getting some conflicts to switch to dx12 :)

edit:
maybe isn't possible to get one vertex to n different pixel shaders?

Thanks,

Marc

dxgi crash on ModelViewer close

I receive a crash (details below) upon closing the ModelViewer. Notes:

  • I'm on a laptop and the sample does not crash if I force the integrated Intel GPU; i.e. this occurs only when on the NVidia GPU. (Although with the integrated GPU I see other weirdness - only the particles render)
  • Other samples run fine

Perhaps a driver-related bug?

Error:

Exception thrown at 0x00007FFC87B8795D (dxgi.dll) in ModelViewer.exe: 0xC0000005: Access violation reading location 0x00007FFC87FFAA00.

Callstack:

    dxgi.dll!00007ffc87b8795d() Unknown
    dxgi.dll!00007ffc87b74de4() Unknown
    dxgi.dll!00007ffc87b79689() Unknown
    dxgi.dll!00007ffc87b5e7f9() Unknown
    dxgi.dll!00007ffc87b3a0c4() Unknown
    dxgi.dll!00007ffc87b34cd3() Unknown
    dxgi.dll!00007ffc87b3a220() Unknown
    dxgi.dll!00007ffc87b33626() Unknown
>   ModelViewer.exe!Microsoft::WRL::ComPtr<ID3D12Resource>::InternalRelease() Line 196  C++
    ModelViewer.exe!Microsoft::WRL::ComPtr<ID3D12Resource>::operator=(void * __formal) Line 259 C++
    ModelViewer.exe!GpuResource::Destroy() Line 43  C++
    ModelViewer.exe!Graphics::Shutdown() Line 475   C++
    ModelViewer.exe!GameCore::RunApplication(GameCore::IGameApp & app, const wchar_t * className) Line 148  C++
    ModelViewer.exe!wmain(int argc, wchar_t * * argv) Line 80   C++

System Information:

[Display]
Operating System:   Windows 10 Home, 64-bit
DirectX version:    12.0 
GPU processor:      GeForce GTX 970M
Driver version:     353.62
Direct3D API version:   12
Direct3D feature level: 12_1
CUDA Cores:     1280 
Core clock:     924 MHz 
Memory data rate:   5010 MHz
Memory interface:   192-bit 
Memory bandwidth:   120.24 GB/s
Total available graphics memory:    7110 MB
Dedicated video memory: 3072 MB GDDR5
System video memory:    0 MB
Shared system memory:   4038 MB
Video BIOS version: 84.04.29.00.17
IRQ:            Not used
Bus:            PCI Express x8 Gen3
Device Id:      10DE 13D8 06881028
Part Number:        2724 0010

Why using mutex instead of lightweight CRITICAL_SECTION ?

Hi

After looking through miniEngine for awhile, I noticed you guys exclusively using std::mutex to enforce correctness in multi-thread scenarios. IIRC mutex have heavier overhead when compare to CRITICAL_SECTION, so I just wondering what's the specific reason to use mutex in miniEngine?

Thanks

MiniEngine crashes on compile

Compiler crashes when building MiniEngine (VS2015Update1 default cmplr.).

"1> GraphicsCore.cpp
1> Generating Code...
1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0(909): fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 246)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1> Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information
1> CL!InvokeCompilerPass()+0x2d4bd
1> CL!DllGetC2Telemetry()+0xae663
1>
"

All samples crash (user error?)

Getting the following error with every sample.
"hr 0x887a0004 : The specified device interface or feature level is not supported on this system. HRESULT"

Using Windows 10 Home on a laptop with an Intel i7-3610QM and an nVidia GTX 670M with latest 64 bit drivers.

No problems with DirectX 11 stuff.

Thanks.

Multiple window problems

Sorry to bother, but I have been having trouble with multiple windows. I put each window into its own thread to aid with debugging and regardless of whether they share a command queue, or have their own, the window threads always seem to hang at one of these 3 lines:

m_d3dCommandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists);

> Test.exe!Microsoft::WRL::ComPtr<ID3D12CommandQueue>::InternalRelease() Line 196 C++ (called from ThrowIfFailed(m_swapChain->Present(1, 0));)

m_swapChain->ResizeBuffers(FrameCount, 0, 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0);

One window works perfectly but uploaded the code just in-case I've done something stupid.
http://pastebin.com/wALUNaz4

Any help you can give would be greatly appreciated. Thank you.

D3D12HeterogeneousMultiadapter not working

Hi,
I have the D3D12HeterogeneousMultiadapter sample always fail on
D3D12CreateDevice(ppAdapters[i], D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_devices[i])),
no meaningful message. The machine I ran into this has dual Nvidia 680m (but the sample fail even on creating device from the first adapter) with drive version 358.91(the latest driver I can get up to today). The same issue occurred with both SLI enabled and disabled.

One thing need noting is that when I run dxcap -info I got

Feature Support : No
D3D9 Driver Support : Fail
D3D10+ Driver Support : Fail
OS Version Check : Pass
Driver Version Check : Fail

for SLI disabled, but

Feature Support : No
D3D9 Driver Support : Pass
D3D10+ Driver Support : Pass
OS Version Check : Pass
Driver Version Check : Fail

for SLI enabled.

2 cases where D3D11_PRIMITIVE_TOPOLOGY enum is used

There are 2 cases in D3D12PipelineStateCache.cpp where a D3D11 enum is used:

This is especially confusing since there's also an unrelated D3D12_PRIMITIVE_TOPOLOGY_TYPE, and the D3D12 documentation has a bug in ID3D12GraphicsCommandList::IASetPrimitiveTopology, where the link to D3D12_PRIMITIVE_TOPOLOGY actually points to D3D12_PRIMITIVE_TOPOLOGY_TYPE! (https://msdn.microsoft.com/en-us/library/windows/desktop/dn770385(v=vs.85).aspx)

Request: a D3D12 stereo sample

Hi,
Would be nice if you can add a simple stereoscopic sample using D3D12 using recommended best practices for creating the 2 back buffers,etc..
Thanks..

D3D12Multithreading has a D3D12 ERROR

I started to get this error in D3D12Multithreading the sample every time the index buffer is binded.

D3D12 ERROR: ID3D12CommandList::IASetIndexBuffer: pDesc->BufferLocation + SizeInBytes - 1 (0x000000020514a4cb) exceeds end of the virtual address range of Resource (0x0000000000000000, Debug Name: '(nullptr)', GPU VA Range: 0x0000000204e5d000 - 0x0000000204e6cfff). This is OK as out of bounds access is guarded by the GPU (writes are discarded and reads return 0). However the developer probably did not intend to make use of this behavior. [ STATE_CREATION ERROR #725: SET_INDEX_BUFFER_INVALID]

I wasn't having any error messages with this sample before and I have not modified it. I'm using version 361.43 of nvidias driver.

Thanks.

Profiling with MiniEngine

I noticed there are profiling features built-in to MiniEngine. I'm fairly new to profiling graphics applications in Visual Studio so I was wondering if there is any documentation or examples showing how to use the profiling tools that are made available in MiniEngine?

I was looking for some documentation in the GitHub Wiki for MiniEngine but there is no documentation there.

Specifically I would like to perform a comparative performance analysis on the various stages of rendering. For example, determine the average time to perform a specific post-process effects over several seconds of rendering. There doesn't seem to be an easy way to determine this information using the GPU profiling tools in Visual Studio (or I have not found an easy way to do this).

Multithreading sample

this is a really minor error, when compiling from

define SINGLETHREADED FALSE

to

define SINGLETHREADED TRUE

the reinterpret_cast(i) fails with:

d3d12multithreading.cpp(698): error C2664: 'void D3D12Multithreading::WorkerThread(int)': cannot convert argument 1 from 'LPVOID' to 'int'

this is only for test purposes because i'm looking the performance hit of single threaded vs multi threaded command list generation

Regards

Marc

White Space Alignment

Not in the master branch yet but there are a lot of alignment issues, tabs used where spaces should be used and vice versa.

When using tabs, tabs should only be used in the margin, spaces should be used everywhere else for alignment to ensure that alignment stays regardless of tab size.

[-- tabs --] ClassType [-- spaces --] name;

[tab] [s]  if(condition) something();
[tab] else if(condition) somethingElse();
[tab] else [spaces]      somethingElseElse();

etc...

That or simply use spaces across for everything. Not that big of a deal just horrible viewing experience since github uses 8 tab size and everything is formatted to use tab size 4.

https://github.com/Microsoft/DirectX-Graphics-Samples/blob/feature_miniengine/MiniEngine/Core/GraphicsCore.h#L35
https://github.com/Microsoft/DirectX-Graphics-Samples/blob/feature_miniengine/MiniEngine/Core/TextureManager.cpp#L54

Edit: Issue #13... I'm a bit paranoid now...

Why commandlist reuse seems not been encouraged

It seems lots of samples have the following iteration pattern every frame:
commandallocator.reset() -> commandlist.reset() -> buildcommandlist -> commandlist.close().....
even though there are only 3-5 different commands sequence(depend on the backbuffer count). but most samples will recreate the whole commandlist every frame instead of create these commandlist a head of time and reuse them every frame.

So I have modified the D3D12HelloConstBuffers code, I create 3 (backbuffer count) commandlist objects from one allocator, and build 3 different command lists for them, and the difference is only the OMSetRenderTargets function where 3 commandlist use different backbuffer. Then in OnRender function, I get rid of the allocator reset, commandlist build.... and just execute the right commandlist based on current backbuffer index. And it turned out it works as expected.

So my question here is why this pattern is not encouraged(or maybe I am wrong?), it seems by doing so we can save lots of cpu cycles

D3D1211On12 doesn't build

VS2015 debug x64 on Win 10 gives the following build errors:

1>------ Build started: Project: D3D1211On12, Configuration: Debug x64 ------
1>  Performing Custom Build Tools
1>  stdafx.cpp
1>  Main.cpp
1>  DXSample.cpp
1>  D3D1211On12.cpp
1>  Win32Application.cpp
1>  Generating Code...
1>LINK : fatal error LNK1104: cannot open file 'd3d11.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The closest location of a d3d11.lib is in C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64, which is not in the default Windows 10 build paths.

However, if I add $(WindowsSDKDir_81)Lib\winv6.3\um$(PlatformTarget) to the build paths, we now get:

1>D3D1211On12.obj : error LNK2019: unresolved external symbol D3D11On12CreateDevice referenced in function "private: void __cdecl D3D1211on12::LoadPipeline(void)" (?LoadPipeline@D3D1211on12@@AEAAXXZ)
1>D:\Users\<USERNAME>\Git\github\DirectX-Graphics-Samples\Samples\D3D1211On12\src\x64\Debug\D3D1211On12.exe : fatal error LNK1120: 1 unresolved externals

AFAICT this shouldn't happen because according to https://msdn.microsoft.com/en-us/library/windows/desktop/dn933209%28v=vs.85%29.aspx, D3D11On12CreateDevice should be in d3d12.lib.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.