Jump to content
  • Advertisement

Search the Community

Showing results for tags 'DX12' in content posted in Graphics and GPU Programming.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • Audio
    • Music and Sound FX
  • Business
    • Business and Law
    • Career Development
    • Production and Management
  • Game Design
    • Game Design and Theory
    • Writing for Games
    • UX for Games
  • Industry
    • Interviews
    • Event Coverage
  • Programming
    • Artificial Intelligence
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Engines and Middleware
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
  • Archive

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • Game Dev Loadout
  • Game Dev Unchained

Categories

  • Game Developers Conference
    • GDC 2017
    • GDC 2018
  • Power-Up Digital Games Conference
    • PDGC I: Words of Wisdom
    • PDGC II: The Devs Strike Back
    • PDGC III: Syntax Error

Forums

  • Audio
    • Music and Sound FX
  • Business
    • Games Career Development
    • Production and Management
    • Games Business and Law
  • Game Design
    • Game Design and Theory
    • Writing for Games
  • Programming
    • Artificial Intelligence
    • Engines and Middleware
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
    • 2D and 3D Art
    • Critique and Feedback
  • Community
    • GameDev Challenges
    • GDNet+ Member Forum
    • GDNet Lounge
    • GDNet Comments, Suggestions, and Ideas
    • Coding Horrors
    • Your Announcements
    • Hobby Project Classifieds
    • Indie Showcase
    • Article Writing
  • Affiliates
    • NeHe Productions
    • AngelCode
  • Topical
    • Virtual and Augmented Reality
    • News
  • Workshops
    • C# Workshop
    • CPP Workshop
    • Freehand Drawing Workshop
    • Hands-On Interactive Game Development
    • SICP Workshop
    • XNA 4.0 Workshop
  • Archive
    • Topical
    • Affiliates
    • Contests
    • Technical
  • GameDev Challenges's Topics
  • For Beginners's Forum

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams
  • GameDev Challenges's Schedule

Blogs

There are no results to display.

There are no results to display.

Product Groups

  • Advertisements
  • GameDev Gear

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


Website


Role


Twitter


Github


Twitch


Steam

Found 285 results

  1. I'm checking out Microsoft's DirectX Graphics Samples and having some issues with D3D12HelloConstBuffers sample. I run the sample and, as expected, there is a single triangle sliding across the screen. Problem is that triangle seems to jerk a little bit. I thought it could be synchronization issue but demo seems to be straightforward with just a single frame so that should not be the case. This does not seem to occur in Release build. Only Debug build has this issue. Is there an issue with the sample or perhaps something else is at fault? I have attached mp4 video recorded at 60 fps which shows the issue. debug.mp4
  2. Hello! I would like to introduce Diligent Engine, a project that I've been recently working on. Diligent Engine is a light-weight cross-platform abstraction layer between the application and the platform-specific graphics API. Its main goal is to take advantages of the next-generation APIs such as Direct3D12 and Vulkan, but at the same time provide support for older platforms via Direct3D11, OpenGL and OpenGLES. Diligent Engine exposes common front-end for all supported platforms and provides interoperability with underlying native API. Shader source code converter allows shaders authored in HLSL to be translated to GLSL and used on all platforms. Diligent Engine supports integration with Unity and is designed to be used as a graphics subsystem in a standalone game engine, Unity native plugin or any other 3D application. It is distributed under Apache 2.0 license and is free to use. Full source code is available for download on GitHub. Features: True cross-platform Exact same client code for all supported platforms and rendering backends No #if defined(_WIN32) ... #elif defined(LINUX) ... #elif defined(ANDROID) ... No #if defined(D3D11) ... #elif defined(D3D12) ... #elif defined(OPENGL) ... Exact same HLSL shaders run on all platforms and all backends Modular design Components are clearly separated logically and physically and can be used as needed Only take what you need for your project (do not want to keep samples and tutorials in your codebase? Simply remove Samples submodule. Only need core functionality? Use only Core submodule) No 15000 lines-of-code files Clear object-based interface No global states Key graphics features: Automatic shader resource binding designed to leverage the next-generation rendering APIs Multithreaded command buffer generation 50,000 draw calls at 300 fps with D3D12 backend Descriptor, memory and resource state management Modern c++ features to make code fast and reliable The following platforms and low-level APIs are currently supported: Windows Desktop: Direct3D11, Direct3D12, OpenGL Universal Windows: Direct3D11, Direct3D12 Linux: OpenGL Android: OpenGLES MacOS: OpenGL iOS: OpenGLES API Basics Initialization The engine can perform initialization of the API or attach to already existing D3D11/D3D12 device or OpenGL/GLES context. For instance, the following code shows how the engine can be initialized in D3D12 mode: #include "RenderDeviceFactoryD3D12.h" using namespace Diligent; // ... GetEngineFactoryD3D12Type GetEngineFactoryD3D12 = nullptr; // Load the dll and import GetEngineFactoryD3D12() function LoadGraphicsEngineD3D12(GetEngineFactoryD3D12); auto *pFactoryD3D11 = GetEngineFactoryD3D12(); EngineD3D12Attribs EngD3D12Attribs; EngD3D12Attribs.CPUDescriptorHeapAllocationSize[0] = 1024; EngD3D12Attribs.CPUDescriptorHeapAllocationSize[1] = 32; EngD3D12Attribs.CPUDescriptorHeapAllocationSize[2] = 16; EngD3D12Attribs.CPUDescriptorHeapAllocationSize[3] = 16; EngD3D12Attribs.NumCommandsToFlushCmdList = 64; RefCntAutoPtr<IRenderDevice> pRenderDevice; RefCntAutoPtr<IDeviceContext> pImmediateContext; SwapChainDesc SwapChainDesc; RefCntAutoPtr<ISwapChain> pSwapChain; pFactoryD3D11->CreateDeviceAndContextsD3D12( EngD3D12Attribs, &pRenderDevice, &pImmediateContext, 0 ); pFactoryD3D11->CreateSwapChainD3D12( pRenderDevice, pImmediateContext, SwapChainDesc, hWnd, &pSwapChain ); Creating Resources Device resources are created by the render device. The two main resource types are buffers, which represent linear memory, and textures, which use memory layouts optimized for fast filtering. To create a buffer, you need to populate BufferDesc structure and call IRenderDevice::CreateBuffer(). The following code creates a uniform (constant) buffer: BufferDesc BuffDesc; BufferDesc.Name = "Uniform buffer"; BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; BuffDesc.Usage = USAGE_DYNAMIC; BuffDesc.uiSizeInBytes = sizeof(ShaderConstants); BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; m_pDevice->CreateBuffer( BuffDesc, BufferData(), &m_pConstantBuffer ); Similar, to create a texture, populate TextureDesc structure and call IRenderDevice::CreateTexture() as in the following example: TextureDesc TexDesc; TexDesc.Name = "My texture 2D"; TexDesc.Type = TEXTURE_TYPE_2D; TexDesc.Width = 1024; TexDesc.Height = 1024; TexDesc.Format = TEX_FORMAT_RGBA8_UNORM; TexDesc.Usage = USAGE_DEFAULT; TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS; TexDesc.Name = "Sample 2D Texture"; m_pRenderDevice->CreateTexture( TexDesc, TextureData(), &m_pTestTex ); Initializing Pipeline State Diligent Engine follows Direct3D12 style to configure the graphics/compute pipeline. One big Pipelines State Object (PSO) encompasses all required states (all shader stages, input layout description, depth stencil, rasterizer and blend state descriptions etc.) Creating Shaders To create a shader, populate ShaderCreationAttribs structure. An important member is ShaderCreationAttribs::SourceLanguage. The following are valid values for this member: SHADER_SOURCE_LANGUAGE_DEFAULT - The shader source format matches the underlying graphics API: HLSL for D3D11 or D3D12 mode, and GLSL for OpenGL and OpenGLES modes. SHADER_SOURCE_LANGUAGE_HLSL - The shader source is in HLSL. For OpenGL and OpenGLES modes, the source code will be converted to GLSL. See shader converter for details. SHADER_SOURCE_LANGUAGE_GLSL - The shader source is in GLSL. There is currently no GLSL to HLSL converter. To allow grouping of resources based on the frequency of expected change, Diligent Engine introduces classification of shader variables: Static variables (SHADER_VARIABLE_TYPE_STATIC) are variables that are expected to be set only once. They may not be changed once a resource is bound to the variable. Such variables are intended to hold global constants such as camera attributes or global light attributes constant buffers. Mutable variables (SHADER_VARIABLE_TYPE_MUTABLE) define resources that are expected to change on a per-material frequency. Examples may include diffuse textures, normal maps etc. Dynamic variables (SHADER_VARIABLE_TYPE_DYNAMIC) are expected to change frequently and randomly. This post describes the resource binding model in Diligent Engine. The following is an example of shader initialization: ShaderCreationAttribs Attrs; Attrs.Desc.Name = "MyPixelShader"; Attrs.FilePath = "MyShaderFile.fx"; Attrs.SearchDirectories = "shaders;shaders\\inc;"; Attrs.EntryPoint = "MyPixelShader"; Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL; Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; BasicShaderSourceStreamFactory BasicSSSFactory(Attrs.SearchDirectories); Attrs.pShaderSourceStreamFactory = &BasicSSSFactory; ShaderVariableDesc ShaderVars[] = { {"g_StaticTexture", SHADER_VARIABLE_TYPE_STATIC}, {"g_MutableTexture", SHADER_VARIABLE_TYPE_MUTABLE}, {"g_DynamicTexture", SHADER_VARIABLE_TYPE_DYNAMIC} }; Attrs.Desc.VariableDesc = ShaderVars; Attrs.Desc.NumVariables = _countof(ShaderVars); Attrs.Desc.DefaultVariableType = SHADER_VARIABLE_TYPE_STATIC; StaticSamplerDesc StaticSampler; StaticSampler.Desc.MinFilter = FILTER_TYPE_LINEAR; StaticSampler.Desc.MagFilter = FILTER_TYPE_LINEAR; StaticSampler.Desc.MipFilter = FILTER_TYPE_LINEAR; StaticSampler.TextureName = "g_MutableTexture"; Attrs.Desc.NumStaticSamplers = 1; Attrs.Desc.StaticSamplers = &StaticSampler; ShaderMacroHelper Macros; Macros.AddShaderMacro("USE_SHADOWS", 1); Macros.AddShaderMacro("NUM_SHADOW_SAMPLES", 4); Macros.Finalize(); Attrs.Macros = Macros; RefCntAutoPtr<IShader> pShader; m_pDevice->CreateShader( Attrs, &pShader ); Creating the Pipeline State Object To create a pipeline state object, define instance of PipelineStateDesc structure. The structure defines the pipeline specifics such as if the pipeline is a compute pipeline, number and format of render targets as well as depth-stencil format: // This is a graphics pipeline PSODesc.IsComputePipeline = false; PSODesc.GraphicsPipeline.NumRenderTargets = 1; PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM_SRGB; PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_D32_FLOAT; The structure also defines depth-stencil, rasterizer, blend state, input layout and other parameters. For instance, rasterizer state can be defined as in the code snippet below: // Init rasterizer state RasterizerStateDesc &RasterizerDesc = PSODesc.GraphicsPipeline.RasterizerDesc; RasterizerDesc.FillMode = FILL_MODE_SOLID; RasterizerDesc.CullMode = CULL_MODE_NONE; RasterizerDesc.FrontCounterClockwise = True; RasterizerDesc.ScissorEnable = True; //RSDesc.MultisampleEnable = false; // do not allow msaa (fonts would be degraded) RasterizerDesc.AntialiasedLineEnable = False; When all fields are populated, call IRenderDevice::CreatePipelineState() to create the PSO: m_pDev->CreatePipelineState(PSODesc, &m_pPSO); Binding Shader Resources Shader resource binding in Diligent Engine is based on grouping variables in 3 different groups (static, mutable and dynamic). Static variables are variables that are expected to be set only once. They may not be changed once a resource is bound to the variable. Such variables are intended to hold global constants such as camera attributes or global light attributes constant buffers. They are bound directly to the shader object: PixelShader->GetShaderVariable( "g_tex2DShadowMap" )->Set( pShadowMapSRV ); Mutable and dynamic variables are bound via a new object called Shader Resource Binding (SRB), which is created by the pipeline state: m_pPSO->CreateShaderResourceBinding(&m_pSRB); Dynamic and mutable resources are then bound through SRB object: m_pSRB->GetVariable(SHADER_TYPE_VERTEX, "tex2DDiffuse")->Set(pDiffuseTexSRV); m_pSRB->GetVariable(SHADER_TYPE_VERTEX, "cbRandomAttribs")->Set(pRandomAttrsCB); The difference between mutable and dynamic resources is that mutable ones can only be set once for every instance of a shader resource binding. Dynamic resources can be set multiple times. It is important to properly set the variable type as this may affect performance. Static variables are generally most efficient, followed by mutable. Dynamic variables are most expensive from performance point of view. This post explains shader resource binding in more details. Setting the Pipeline State and Invoking Draw Command Before any draw command can be invoked, all required vertex and index buffers as well as the pipeline state should be bound to the device context: // Clear render target const float zero[4] = {0, 0, 0, 0}; m_pContext->ClearRenderTarget(nullptr, zero); // Set vertex and index buffers IBuffer *buffer[] = {m_pVertexBuffer}; Uint32 offsets[] = {0}; Uint32 strides[] = {sizeof(MyVertex)}; m_pContext->SetVertexBuffers(0, 1, buffer, strides, offsets, SET_VERTEX_BUFFERS_FLAG_RESET); m_pContext->SetIndexBuffer(m_pIndexBuffer, 0); m_pContext->SetPipelineState(m_pPSO); Also, all shader resources must be committed to the device context: m_pContext->CommitShaderResources(m_pSRB, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES); When all required states and resources are bound, IDeviceContext::Draw() can be used to execute draw command or IDeviceContext::DispatchCompute() can be used to execute compute command. Note that for a draw command, graphics pipeline must be bound, and for dispatch command, compute pipeline must be bound. Draw() takes DrawAttribs structure as an argument. The structure members define all attributes required to perform the command (primitive topology, number of vertices or indices, if draw call is indexed or not, if draw call is instanced or not, if draw call is indirect or not, etc.). For example: DrawAttribs attrs; attrs.IsIndexed = true; attrs.IndexType = VT_UINT16; attrs.NumIndices = 36; attrs.Topology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; pContext->Draw(attrs); Tutorials and Samples The GitHub repository contains a number of tutorials and sample applications that demonstrate the API usage. Tutorial 01 - Hello Triangle This tutorial shows how to render a simple triangle using Diligent Engine API. Tutorial 02 - Cube This tutorial demonstrates how to render an actual 3D object, a cube. It shows how to load shaders from files, create and use vertex, index and uniform buffers. Tutorial 03 - Texturing This tutorial demonstrates how to apply a texture to a 3D object. It shows how to load a texture from file, create shader resource binding object and how to sample a texture in the shader. Tutorial 04 - Instancing This tutorial demonstrates how to use instancing to render multiple copies of one object using unique transformation matrix for every copy. Tutorial 05 - Texture Array This tutorial demonstrates how to combine instancing with texture arrays to use unique texture for every instance. Tutorial 06 - Multithreading This tutorial shows how to generate command lists in parallel from multiple threads. Tutorial 07 - Geometry Shader This tutorial shows how to use geometry shader to render smooth wireframe. Tutorial 08 - Tessellation This tutorial shows how to use hardware tessellation to implement simple adaptive terrain rendering algorithm. Tutorial_09 - Quads This tutorial shows how to render multiple 2D quads, frequently swithcing textures and blend modes. AntTweakBar sample demonstrates how to use AntTweakBar library to create simple user interface. Atmospheric scattering sample is a more advanced example. It demonstrates how Diligent Engine can be used to implement various rendering tasks: loading textures from files, using complex shaders, rendering to textures, using compute shaders and unordered access views, etc. The repository includes Asteroids performance benchmark based on this demo developed by Intel. It renders 50,000 unique textured asteroids and lets compare performance of D3D11 and D3D12 implementations. Every asteroid is a combination of one of 1000 unique meshes and one of 10 unique textures. Integration with Unity Diligent Engine supports integration with Unity through Unity low-level native plugin interface. The engine relies on Native API Interoperability to attach to the graphics API initialized by Unity. After Diligent Engine device and context are created, they can be used us usual to create resources and issue rendering commands. GhostCubePlugin shows an example how Diligent Engine can be used to render a ghost cube only visible as a reflection in a mirror.
  3. Hi, I'm curious about why CreateSwapChainForHwnd in DX12 takes a CmdQueue? 😅 It's far from the DirectX philosophy: Device: Create Things CmdQueue: Take Actions Does anyone know more about this?
  4. Hi I'm currently going through microsoft online documentation and I came across information that I'm not sure I have a grasp on , particularly concerning command queues. The documentation at some point says a command queue can write to the same resource simultanouesly at the same time if the appropriate flag to the resource is set. My question is.. Upon work submission to the command queues. Can it be a requirement for these command queues represent one gpu adapter, in cases were I define two that is. If yes , Does the gpu process both queues in parallel? My other question would be does a gpu have to finish processing commands from compute queue before processing commands from a graphics queue ? I understand that the queue stores command submitted from an application and the order of execution is first in first out execution by the gpu.
  5. Hello everyone, I have a little question about depth resource and D3D12. I need to have mip levels of the depth buffer(as described in some SSR techniques). What I thought I could do was run the geometry pass to get the depth, then use a compute shader to generate the mip levels of the depth buffer, in the same resource as the depth buffer. So I created a resource, with D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL, but as I needed it in the compute shader, I also had to set the ALLOW_UNORDERED_ACCES flag... which is not compatible with the first one . My question is do I need to create another resource, copy the depth buffer to it and generate the mip levels on that copied resource ? or am I missing something and there's a way to do it directly in the depth buffer resource ? Thanks
  6. I have a few questions about DirectX 12 memory management: 1) When you call the ID3D12Device::Evict() function, how do you specify that the contents of the resource is no longer needed and therefor can be discarded? For example, if I have a resource that I am done with, but will need it again later as a render target, I don't want the contents to be swapped out and restored because that would just be a waste of bandwidth. 2) When you call the QueryVideoMemoryInfo() function and find that your memory budget has been reduced and that you are now over budget, how much time do you have to rectify the situation? 3) Am I correct when saying that Placed Resources cannot be used when you want to use a resource as both a render target and a shader resource? (The reason being that you cannot create a heap that support both uses on heap tier 1 hardware (almost all current NVidia hardware). )
  7. In d3d12 the docs seem to push you to allocate large buffers that can store multiple resources (suballocation), whereas in d3d11 you might do one allocation per texture/mesh. Is there a performance benefit to this? It seems with the fast resource binding model of d3d12 you could do an allocation per texture/mesh and still have good performance over d3d11. Why does the GPU care if the memory is from one large buffer or scattered?
  8. I'm reading about memory management in d3d12. The docs basically say that a "committed resource" it like how past versions of Direct3D allocated a resource where you get virtual address and physical address. I understand reserved resources to do things that tiled resources in d3d11 were used for, but when would you use placed resources over committed resources?
  9. I am wondering if it would be viable to transfer the SH coefficients calculation to a compute shader instead of doing it on CPU which for our engine requires a readback of the cube map texture. I am not entirely sure how to go about this since it will be hard to parallelize as each thread will be writing to all the coefficients. A lame implementation would be to have one thread running the entire shader but I think that's going into TDR territory. Currently, I am generating an irradiance map but I am planning on switching to storing it inside a spherical harmonics because of the smaller footprint. Does anyone have any ideas on how we can move this to the GPU or its just not a viable option?
  10. Hi, I am currently hosting my DX12 renderer in WPF application by using a System.Windows.Form.Panel into a WindowsFormHost (WindowsFormIntegration). It work but it feel like a dirty trick and I am not sure if I am going to encounter problems this way. I can't seem to find anyone or any sample on internet of someone who has been able to host DX12 into WPF. I know WPFDXInterop can do it with DX11 but it doesn't seem to be updated anymore to support DX12. Does anyone has achieved it ? Thank you.
  11. Hi everybody ! I have a problem with the VS Graphics Debugger and a D3D12 desktop application. When I create my depth stencil resource, I create two descriptor heaps, one with HEAP_TYPE_DSV, and one with HEAP_TYPE_CBV_SRV_UAV (to rebuild position from depth map), both calls to CreateDescriptorHeap succeed. Then I create a shader-resource view, and a depth-stencil view. Things go well with and without the debugger, but when I use the graphics debugger, the application crashes stating that the CPU descriptor handles does not refer to a location in a descriptor heap when I call either CreateDepthStencilView or CreateShaderResourceView. Here is my code : { D3D12_DESCRIPTOR_HEAP_DESC heap_desc = {}; heap_desc.NumDescriptors = 1; heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; ThrowIfFailed(device->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&m_SRVDescriptorHeap))); heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; ThrowIfFailed(device->CreateDescriptorHeap(&heap_desc, IID_PPV_ARGS(&m_DSVDescriptorHeap))); } DXGI_FORMAT depth_format = DXGI_FORMAT_D24_UNORM_S8_UINT; DXGI_FORMAT depth_format_SRV = DXGI_FORMAT_R24_UNORM_X8_TYPELESS; D3D12_CLEAR_VALUE depth_clear = {}; depth_clear.Format = depth_format; depth_clear.DepthStencil.Depth = 1.0f; depth_clear.DepthStencil.Stencil = 0; ThrowIfFailed(device->CreateCommittedResource( &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT), D3D12_HEAP_FLAG_NONE, &CD3DX12_RESOURCE_DESC::Tex2D( depth_format, width, height, 1, 0, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL), D3D12_RESOURCE_STATE_DEPTH_WRITE, &depth_clear, IID_PPV_ARGS(&m_Resource) )); { D3D12_DEPTH_STENCIL_VIEW_DESC dstencil_desc = {}; dstencil_desc.Format = depth_format; dstencil_desc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; dstencil_desc.Flags = D3D12_DSV_FLAG_NONE; // this call causes a crash device->CreateDepthStencilView(m_Resource, &dstencil_desc, m_DSVDescriptorHeap->GetCPUDescriptorHandleForHeapStart()); } { D3D12_SHADER_RESOURCE_VIEW_DESC srv_desc = {}; srv_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; srv_desc.Format = depth_format_SRV; srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; srv_desc.Texture2D.MipLevels = 1; // this call causes a crash device->CreateShaderResourceView(m_Resource, &srv_desc, m_SRVDescriptorHeap->GetCPUDescriptorHandleForHeapStart()); } This is the message I get from the DebugLayer : D3D12 ERROR: ID3D12Device::CreateShaderResourceView: Specified CPU descriptor handle ptr=0x0000000000008781 does not refer to a location in a descriptor heap. [ EXECUTION ERROR #646: INVALID_DESCRIPTOR_HANDLE] I have no more information with the GPUBasedValidation. The only thing different I noticed with the graphics debugger is that the handle has a much smaller ptr (and always the same) than without it, but I suppose it's only due to the fact that the application is run in some kind of environment with the graphics debugger, right ? PIX gives me the same error (E_PIX_INVALID_DESCRIPTOR_HANDLE). Can anyone help me understand or give me a clue why I have this problem, please :| ? Many Thanks
  12. Totally no information about this error on the internet, so I'm sharing the solution: The same (one) back buffer resource is used in consecutive frames. Most probable cause of this is using only the first descriptor from render target descriptor heap in all frames, so every frame doing this D3D12_CPU_DESCRIPTOR_HANDLE handle( rtvDescriptorHeap->GetCPUDescriptorHandleForHeapStart() ); commandList->OMSetRenderTargets( 1, &handle, false, nullptr ); instead of this D3D12_CPU_DESCRIPTOR_HANDLE handle( rtvDescriptorHeap->GetCPUDescriptorHandleForHeapStart() ); handle.ptr += backBufferId * rtvDescriptorSize; commandList->OMSetRenderTargets( 1, &handle, false, nullptr );
  13. What it the difference between Heap-allocating, stack-allocating UpdateSubresources API for uploading data from UPLOAD heap to DEFAULT heap? Is it just a wrapper around plain UpdateSubresource function? Also, I assume copying happens in GPU timeline when CommandQueue is executed, but there are two copies at work; one from system memory to UPLOAD heap and other from UPLOAD heap to DEFAULT heap. Do both of them happen at GPU timeline or system memory data can be re-used immediately after calling UpdateSubresource?
  14. Hello, I am stuck on a problem since 24h and it's driving me crazy. I have my original DX12 renderer which is written under ShaprDX and now, I have ported it in C++ /CLI. But my draw calls with the C++ renderer doesn’t produce anything at VS stage (at least at depth pass). Here are two screenshot of PIX, the OK.jpg is the VS stage output of my working .NET renderer and the NOK.jpg is what I get with the native one. The depth map is left empty as geometry seem far far away or bugged. I have compared everything in PIX and I cannot find what’s the difference. Vertex buffer, index buffer, constant buffer data, all states (rasterizer, depth, blend, ...) are identical. It look like a simple projection problem but how is it possible with the same matrices, the same vertices and the same vertex shader. I join two PIX frames if someone can help me out. Just look at the first draw call which is the draw call to render a shadow map from a spot light. This is a ultra minimalist scene to reduce thing to their simplest state. Thank a lot if someone can tell me what’s wrong I am doing. OK.pix3 NOK.pix3
  15. Hello. Basically I recently upgraded to Visual Studio 2017, and I wanted to experiment with DirectX12 for a change. But before I can even begin explaining the problem, I just wanna let you know ahead of time that I have the latest Windows 10 Home, the latest Visual Studio 2017 version 15.8.2, Game Development with C++ installed from Tools and Features, and according to my DirectX Diagnostic Tool, I have DirectX12 on my machine with Direct3D DDI: 11.2 and D3D Feature Levels 11_0, 10_1, 10_0, 9_3, 9_2, and 9_1. Ok, now with that said, I made an extremely simple app with no overhead what-so-ever. It gets a list of adaptors, and displays them in the command prompt showing if it enabled directx or not. #include <iostream> #include <vector> #include <string> #include <d3d12.h> #include <dxgi1_6.h> using namespace std; #include <wrl.h> using namespace Microsoft::WRL; #pragma comment(lib, "d3d12.lib") #pragma comment(lib, "dxgi.lib") #pragma comment(lib, "d3dcompiler.lib") void GetAdaptors() { HRESULT hr; UINT adaptorIndex = 0; ComPtr<IDXGIFactory4> dxgiFactory = nullptr; ComPtr<IDXGIAdapter1> adapter = nullptr; vector<ComPtr<IDXGIAdapter1>> adapterList; hr = CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory)); if FAILED(hr) { cout << "Failed to CreateDXGIFactory1" << endl; return; } while (dxgiFactory->EnumAdapters1(adaptorIndex, &adapter) != DXGI_ERROR_NOT_FOUND) { DXGI_ADAPTER_DESC1 desc; adapter->GetDesc1(&desc); wstring s = desc.Description; wcout << adaptorIndex << L": " << s.c_str() << endl; hr = D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), nullptr); if (SUCCEEDED(hr)){ cout << "D3D12CreateDevice succeeded" << endl; adapterList.push_back(adapter); ++adaptorIndex; return; } else cout << "D3D12CreateDevice failed" << endl; adapterList.push_back(adapter); ++adaptorIndex; } } int main() { GetAdaptors(); system("pause"); return 0; } When I run the app, I get this: 0: AMD Mobility Radeon HD 5800 Series D3D12CreateDevice failed 1: Microsoft Basic Render Driver D3D12CreateDevice succeeded Press any key to continue . . . So basically my main gaming video card, the AMD Mobility Radeon HD 5800 Series, fails in creating directx12, but my software renderer only Microsoft Basic Render Driver succeeds? Could anyone explain how I might be able to get DirectX12 to successfully create using my AMD Mobility Radeon HD 5800 Series? There should be no reason for this to fail. Thanks in advance.
  16. MSDN says CommandAllocator is used for storing GPU commands. But doesn't answer where it's stored. On the graphics card's VRAM or on the RAM. If it's stored on the CPU side, then every time we call execute, is it copied to graphics card? Or copied to GPU when we add new command to list and executed after? I think storing on the gpu side is better, because with this way we can cache commands and dont create every frame.
  17. Hi, I am looking for HLSL shader sample on PCSS shadowing. My current implementation is quite buggy and doesn't produce a soft shadow. I really have hard time with shader programming. If someone could lead me to a working sample I could try to implement in my learning 3D engine, it would be really cool. Here is my current shader, just for info : // // Compute PCSS shadow. // float PCSS_Shadow(float3 uvd, Texture2D shadowMap, float pixelSize, float lightSize) { // Search for blockers float avgBlockerDepth = 0; float blockerCount = 0; for (int i = 0; i < SEARCH_POISSON_COUNT; ++i) { float2 offset = SEARCH_POISSON[i]; float d4 = shadowMap.SampleLevel(PointWrapSampler, uvd.xy + offset, 0); float4 b4 = (uvd.z <= d4) ? 0.0 : 1.0; blockerCount += dot(b4, 1.0); avgBlockerDepth += dot(d4, b4); } // Check if we can early out if (blockerCount <= 0.0) return 1.0; else if (blockerCount == SEARCH_POISSON_COUNT) return 0.0; // Penumbra width calculation avgBlockerDepth /= blockerCount; float fRatio = 1 + (((uvd.z - avgBlockerDepth) * lightSize) / avgBlockerDepth); fRatio *= fRatio; // Apply the filter float att = 0; for (i = 0; i < PCF_POISSON_COUNT; i++) { float2 offset = fRatio * pixelSize.xx * PCF_POISSON[i]; att += shadowMap.SampleCmpLevelZero(PCFSampler, uvd.xy + offset, uvd.z); } // Devide to normalize return att / PCF_POISSON_COUNT; } // // PCSS Shadow for a spot light // float SpotShadowPCSS(float4 position, float4x4 lightViewProj, Texture2D shadowMap, float pixelSize, float lightSize) { // Transform the world position to shadow projected space float4 posShadowMap = mul(position, lightViewProj); // Transform the position to shadow clip space float3 uvd = posShadowMap.xyz / posShadowMap.w; // Convert to shadow map UV values uvd.xy = 0.5 * uvd.xy + 0.5; uvd.y = 1.0 - uvd.y; return PCSS_Shadow(uvd, shadowMap, pixelSize, lightSize); }
  18. Hi, I am trying to learn D3D12 programming by programming a small engine but I have a strange behavior that I cannot understand. Basically, I am drawing 200 cubes each frame and between each draw call I use a root 32 bits constant to determine the cube color in my shader. It work fine for a couple of seconds then the root constant seem to stop to be updated and so my shader can't determine color anymore. I don't know why it work and suddenly stop without any debug error. Here is the pseudo code of what I am doing : Init() { ... - Define a float value - Create a pointer to this float value - Add a root constant to my root signature parameters. ... } RenderLoop() { ... For 0 to 200 { - Update my float value - CommandList->SetGraphicsRoot32BitConstants(floatPtr) - Draw cube } } Thank for help.
  19. Hello, By digging a bit more in my DX12 learning, I am hitting a problem and I am not certain if my way to handle it, is correct. I will try to explain myself the best I can Basics DX12 samples and tutorials are generally using 2 Descriptor Heap (CBV / Sampler) and all constant buffer resource creation are generally multiplied by the amount of backbuffer. So when double buffering, I have one descHeap (CBV) allocating two slots for each constant buffer (to avoid conflict when modifying data). But now I'd like to play around with Root Signature Descriptor Table, so I need my CB heap slots to be continuous, however if each time I initialize a CB my descHeap allocate two room to it, I end up with discontinuous CB. So to avoid this problem, I was thinking of having one CBV/SRV/UAV DescriptorHeap per back buffer and one common Sample DescriptorHeap. So when allocating several CB, they are all continuous in their own heap. Is that a common practice ? And additionally, for stuffs like textures, I don't want to create two commited resource for them because it will mean upload them 2 times in GPU memory while they are "read only" resource (most of the time). So with my multiple DescHeap system, it will mean multiple heap pointing on the same resource. Is that a problem ? Hope I've been understandable Thank you.
  20. In DX12 API, we have this definition: typedef struct D3D12_CPU_DESCRIPTOR_HANDLE { SIZE_T ptr; } D3D12_CPU_DESCRIPTOR_HANDLE; As the title says, what is the reason for it to be a struct? Is there any reason apart from being type safe? In my engine, I store size_t handles for my graphics types instead of this, because I am not including dx12 headers in the rest of the code base. I go out of my way to convert my size_t handles to D3D12_CPU_DESCRIPTOR_HANDLE like this: typedef size_t wiCPUHandle; // My own handle type inline D3D12_CPU_DESCRIPTOR_HANDLE ToNativeHandle(wiCPUHandle handle) { D3D12_CPU_DESCRIPTOR_HANDLE native; native.ptr = handle; return native; } And this function gets copied before every native API call to retrieve the native handle from my handle type. Doesn't seem like a very nice solution, maybe I am not realizing something obvious? In Vulkan, they simply typedef the handles to pointer type or uint64.
  21. I finally started tackling a proper management of the views in my DX12 project. So far I implemented a ring buffer to manage a big offline and online descriptor heap to which I copy descriptors in a contiguous way as required by my resource binding (I already have plan to improve on the ring buffer idea to manage fragmentation a little better as I don't want to copy descriptors on every draw call if they are already copied contiguously from a previous call). This concept has been well explained by @Hodgman in this comment : For SRV / UAV I have no problem so far, everything work just as I understood the concept. For CBV I apparently cannot reference them with a descriptor table in the root signature. The debug layer report an error saying that a descriptor table is invalid for a CBV root signature parameter even if my root signature was indeed created as a CBV descriptor table at this location so until this question is clear to me I moved all my CBV directly in a root descriptor which seem to be the only option left. The reported error is this one : D3D12 ERROR: CGraphicsCommandList::SetGraphicsRootDescriptorTable: The currently set root signature declares parameter [0] with type CBV, so it is invalid to set a descriptor table here. [ EXECUTION ERROR #708: SET_DESCRIPTOR_TABLE_INVALID] Now as I noticed, binding a CBV as root descriptor don't even require the CBV to be in a descriptor heap and you don't even need to call ID3D12Device::CreateConstantBufferView at all. You simply pass the GPU virtual address of the resource to ID3D12GraphicsCommandList::SetGraphicsRootConstantBufferView and it all work without complaining. I'm a bit confused because from how I understand it so far a descriptor heap should only be used when you are going to work with descriptor tables. Why would the type D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV even exist and allow CBVs in it if CBVs can only be referenced as a root descriptor? I'm also wondering why the ID3D12Device::CreateConstantBufferView call exists at all in that case. There's obviously few details that I didn't catch. Could someone enlighten me on this. Thanks
  22. Hi everyone : ) I'm trying to implement SSAO with D3D12 (using the implementation found on learnopengl.com https://learnopengl.com/Advanced-Lighting/SSAO), but I seem to have a performance problem... Here is a part of the code of the SSAO pixel shader : Texture2D PositionMap : register(t0); Texture2D NormalMap : register(t1); Texture2D NoiseMap : register(t2); SamplerState s1 : register(s0); // I hard coded the variables just for the test const static int kernel_size = 64; const static float2 noise_scale = float2(632.0 / 4.0, 449.0 / 4.0); const static float radius = 0.5; const static float bias = 0.025; cbuffer ssao_cbuf : register(b0) { float4x4 gProjectionMatrix; float3 SSAO_SampleKernel[64]; } float main(VS_OUTPUT input) : SV_TARGET { [....] float occlusion = 0.0; for (int i = 0; i < kernel_size; i++) { float3 ksample = mul(TBN, SSAO_SampleKernel[i]); ksample = pos + ksample * radius; float4 offset = float4(ksample, 1.0); offset = mul(gProjectionMatrix, offset); offset.xyz /= offset.w; offset.xyz = offset.xyz * 0.5 + 0.5; float sampleDepth = PositionMap.Sample(s1, offset.xy).z; float rangeCheck = smoothstep(0.0, 1.0, radius / abs(pos.z - sampleDepth)); occlusion += (sampleDepth >= ksample.z + bias ? 1.0 : 0.0) * rangeCheck; } [....] } The problem is this for loop. When I run it, it takes around 140 ms to draw the frame (a simple torus knot...) on a GTX 770. Without this loop, it's 5ms. Running it without the PositionMap sampling and the matrix multiplication takes around 25ms. I understand that matrix multiplication and sampling are "expensive", but I don't think it's enough to justify the sluggish drawing time. I suppose the shader code from the tutorial is working, so unless I've made something terribly stupid that I don't see I suppose my problem comes from something I did wrong with D3D12 that I'm not aware of (I just started learning D3D2). Both PositionMap and NormalMap are render targets from the gbuffer, for each one I created two DescriptorHeap : one as D3D12_DESCRIPTOR_HEAP_TYPE_RTV and one as D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, and called both CreateRenderTargetView and CreateShaderResourceView. The NoiseMap only has one descriptor heap of type D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV. Before calling DrawIndexedInstanced for the SSAO pass, I copy the relevant to a descriptor heap that I then bind, like so : CD3DX12_CPU_DESCRIPTOR_HANDLE ssao_heap_hdl(_pSSAOPassDesciptorHeap->GetCPUDescriptorHandleForHeapStart()); device->CopyDescriptorsSimple(1, ssao_heap_hdl, _gBuffer.PositionMap().GetDescriptorHeap()->GetCPUDescriptorHandleForHeapStart(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); ssao_heap_hdl.Offset(CBV_descriptor_inc_size); device->CopyDescriptorsSimple(1, ssao_heap_hdl, _gBuffer.NormalMap().GetDescriptorHeap()->GetCPUDescriptorHandleForHeapStart(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); ssao_heap_hdl.Offset(CBV_descriptor_inc_size); device->CopyDescriptorsSimple(1, ssao_heap_hdl, _ssaoPass.GetNoiseTexture().GetDescriptorHeap()->GetCPUDescriptorHandleForHeapStart(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); ID3D12DescriptorHeap* descriptor_heaps[] = { _pSSAOPassDesciptorHeap }; pCommandList->SetDescriptorHeaps(1, descriptor_heaps); pCommandList->SetGraphicsRootDescriptorTable(0, _pSSAOPassDesciptorHeap->GetGPUDescriptorHandleForHeapStart()); pCommandList->SetGraphicsRootConstantBufferView(1, _cBuffSamplesKernel[0].GetVirtualAddress()); Debug/Release build give me the same results, so do shader compilation flags with/without optimisation. So does anyone see something weird in my code that would cause the slowness ? By the way, when I run the pixel shader in the graphics debugger, this line : offset.xyz /= offset.w; does not seem to produce the expected results, the two lines in the following table are the values in the debugger before and after the execution of that line of code Name Value Type offset offset x = -1.631761000, y = 1.522913000, z = 2.634875000, w = 2.634875000 x = -0.619293700, y = 0.577983000, z = 2.634875000, w = 2.634875000 float4 float4 so X and Y are okay, not Z. Please tell me if you need more info/code. Thank you for your help !
  23. I want to stress my application by rendering lots of polygons. I use DX12 (SharpDX) and I upload all vertices to GPU memory via an upload buffer. In normal cases everything works fine, but when I try to create a large upload buffer (CreateCommittedResource) I get a non-informative exception from SharpDX, and the device is being removed. GetDeviceRemovedReason (DeviceRemovedReason in SharpDX) returns 0x887A0020: DXGI_ERROR_DRIVER_INTERNAL_ERROR. I'm guessing it's all because it can't find a consecutive chunk of memory big enough to create the buffer (I have 6GB on the card and I'm currently trying to allocate a buffer smaller than 1GB). So how do I deal with this? I guess I could create several smaller buffers instead, but I can't just put the CreateCommittedResource call in a try-catch section. The exception is serious enough to remove my device, so any further attempts will fail after the first try. Can I somehow know beforehand what size is OK to allocate?
  24. I have a problem synchronizing data between shared resources. On the input I receive a D3D11 2D texture, which itself is enabled for sharing and has D3D11_RESOURCE_MISC_SHARED_NTHANDLE in its description. Having a D3D12 device created on the same adapter I open a resource through sharing a handle. const CComQIPtr<IDXGIResource1> pDxgiResource1 = pTexture; // <<--- Input texture on 11 device HANDLE hTexture; pDxgiResource1->CreateSharedHandle(NULL, GENERIC_ALL, NULL, &hTexture); CComPtr<ID3D12Resource> pResource; // <<--- Counterparty resource on 12 device pDevice->OpenSharedHandle(hTexture, __uuidof(ID3D12Resource), (VOID**) &pResource); I tend to keep the mapping between the 11 texture and 12 resource further as they are re-filled with data, but in context of the current problem it does not matter if I reuse the mapping or I do OpenSharedHandle on every iteration. Further on I have a command list on 12 device where I use 12 resource (pResource) as a copy source. It is an argument in further CopyResource or CopyTextureRegion calls. I don't have any resource barriers in the command list (including that my attempts to use any don't change the behavior). My problem is that I can't have the data synchronized. Sometimes and especially initially the resource has the correct data, however further iterations have issues such as resource having stale/old data. I tried to flush immediate context on 11 device to make sure that preceding commands are completed. I tried to insert resource barriers at the beginning of command list to possibly make sure that source resource has time to receive the correct data. Same time I have other code paths which don't do OpenSharedHandle mapping and instead do additional texture copying and mapping between original 11 device and 11on12 device, and the code including the rest of the logic works well there. This makes me think that I fail to synchronize the data on the step I mentioned above, even though I am lost how do I synchronize exactly outside of command list. I originally thought that 12 resource has a IDXGIKeyedMutex implementation which is the case with sharing-enabled 11 textures, but I don't have the IDXGIKeyedMutex and I don't see what is the D3D12 equivalent, if any. Could you please advise where to look at to fix the sync?
  25. Recently I read that the APIs are faking some behaviors, giving to the user false impressions. I assume Shader Model 6 issues the wave instructions to the hardware for real, not faking them. Is Shader Model 6, mature enough? Can I expect the same level of optimization form Model 6 as from Model 5? Should I expect more bugs from 6 than 5? Would the extensions of the manufacturer provide better overall code than the Model 6, because, let say, they know their own hardware better? What would you prefer to use for your project- Shader Model 6 or GCN Shader Extensions for DirectX? Which of them is easier to set up and use in Visual Studio(practically)?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!