DirectX12 | Various DirectX12 examples | Runtime Evironment library
kandi X-RAY | DirectX12 Summary
kandi X-RAY | DirectX12 Summary
A comprehensive collection of open source C++ examples for DirectX12, the new generation graphics and compute API from Microsoft.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of DirectX12
DirectX12 Key Features
DirectX12 Examples and Code Snippets
Community Discussions
Trending Discussions on DirectX12
QUESTION
I am learning DirectX12 from this guide here and one thing that has me confused is when they are resizing the depth buffer. This is how they do it below:
...ANSWER
Answered 2022-Mar-28 at 07:12The SRV, CBV, UAV, RTV, and DSV "Views" in DirectX 12 are in memory 'owned' by the heaps they are allocated into. You can just reuse those slots if you want. The Create*View
methods just fill out data into that memory. The memory itself is freed when the associated heap is freed.
Vertex Buffer and Index Buffer Views are just simple structures as well.
The ref-counted part you need to make sure you release are the ID3D12Resource and ID3D12Heap objects.
In addition to that tutorial, you may want to take a look at DirectX Tool Kit for DX12.
QUESTION
I am learning DirectX12 programming. And one thing that has me confused is in all the tutorials I read, they only create a single depth/stencil buffer even when triple/double buffering is used with the swap chain. Wouldn't you need a depth/stencil buffer for each frame?
Code in question:
...ANSWER
Answered 2022-Mar-15 at 12:27Generally speaking, "intermediate resources" (such as depth stencils and intermediate render targets) are not presented on the screen.
So when one swapchain is ready to present (and you start recording next frame commands), those resources can be safely overridden, since the content is ready within the swap chain.
The only exception for those resources are generally buffers that are uploaded from cpu, for them it is needed to have one per frame (since you will start to copy data while another command list is still executing).
QUESTION
So I am creating a fullscreen function in win32 c++ doing:
...ANSWER
Answered 2022-Feb-07 at 16:34Updated Answer:
The Win32 API allows you to modify parameters of the window one at a time. When a parameter is modified, the API may or may not update the window and trigger a WM_SIZE that will be the size of the window given the current parameters.
Since to have a complete full screen window you need to make at least 2 calls, one to update GWL_STYLE and another to update GWL_EXSTYLE, you have a big chance of getting 2 WM_SIZE calls. One of them will give you the window size without the menu, and the other the full screen window size. It depends in which order you call SetWindowLongPtr
, but you'll probably get 2 WM_SIZE and only the second one is "correct", i.e. the one you want in the end.
The more reliable solution to your problem is to use a variable at the top of Main.cpp:
int isTogglingFullScreen = false;
Then inside your full screen toggle code (note where isTogglingFullScreen
is being set):
QUESTION
So I am attempting to dive into DirectX12 synchronization. And I am having a hard time trying to understand why some programs need multiple fences for GPU/CPU synchronization, instead of just one.
In this guide, they have only a single fence and single fence value (that is stored per frame, so that the the value can be checked for a certain frame).
While in this guide they have a a fence for each frame and an array of current values for each frame. (This guide doesn't explain its reasoning for have a fence for each frame)
What is the correct way to do this? (For simplicity just assume it is a single threaded program with 3 back buffers in the swap chain, but if you have the knowledge for a multithreaded program too, that additional information would be helpful). What are the pros and cons of each way if they are both valid approaches?
Also why is it that we use a single fence event instead of one for each frame as well? Like in the below:
...ANSWER
Answered 2022-Feb-07 at 10:48#directxtk does it with a single fence, and a fence value for each frame.
I believe you need fence values for each frame, because you want to know when the next frame is ready, not when the previous frame is completely finished (which would let you use a single global fence value). The call to a fence's GetCompletedValue()
will tell you if the fence reached the fence value necessary to consider the next frame ready to be rendered.
Since the frames rotate with the back buffers, you want as many fence values as back buffers. But you don't necessarily need multiple fences. You can make it work with a single fence for a given command allocator.
Any time you need something fenced, you get the current fence value which you'd previously stored for the current back buffer in m_fenceValues[m_backBufferIndex]
.
Then you increment by 1, and tell the GPU via Signal()
to please set the fence to this fence value when all current commands are executed. When you want to check that they've been executed, you compare to this fence value. If it's gone to the new number, then the GPU has done what it needed.
Store that new fence value back in m_fenceValues[m_backBufferIndex]
and you're done.
This can be done at any time, within a frame or for moving to the next frame. When you want to move to the next frame, you do the same thing, except that you store the (fence value +1) in the fence value of the current back buffer which, by now, has become the new back buffer.
Here's the relevant code for moving to the next frame:
QUESTION
I trying to create a bloom effect for my vulkan game-engine. To implement this I use several bulring pass, in each one I read from one image and render/write a slightly more blurry picture to a other. After each draw pass i swap the role of these images(And using barriers), That means - the one was a render target became a shader resource and the one used as a shader resource became a target. I bind both of these images on same descriptor set to save unnecessary 'VkBindDescriptorSet' calls, but the validation layer tell me that if I want to bind a descriptors of images those all image's layout must be 'VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL' even if the shader used/read only from one of them at any given time(The shader read only from The one that currently in the 'VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL' state). Is this over-caution of the validationlayer? or the bindung is actually failed.
When i worked with DirectX12 I not had this debuger isue!
I would be happy for an answer or an idea for a solution, and I am sorry about my English.
...ANSWER
Answered 2022-Jan-13 at 03:08Assuming your shader actually doesn't use the sampler when its image is bound to it, the validation layer is incorrect (not that it can know). The Vulkan standard only requires that the attached image subresources are not used:
Image subresources used as attachments in the current render pass must not be accessed in any way other than as an attachment by [a rendering command], ...
"Access" is defined by the Vulkan memory model, which for a bound image, involves invoking an image access command. So long as you don't do that to the descriptor, it is not "accessed", and thus does not violate this rule.
That being said, ping-ponging between images without using input attachments requires stopping and starting a render pass, not to mention the execution barriers between each pass. The cost of VkBindDescriptorSet
will be a rounding error in your GPU profiling data next to all of that.
So you should just change descriptor sets and shut the validation layer up.
QUESTION
Today I was just testing around with VisualStudio (C++) and wanted to try an UWP App project (with DirectX12). On creating the project I got asked for the target Windows version and minimum supported Windows version for this UWP app. However the newest target version I can select is Windows 2004 (build 19041).
The own docs from MS also stop at this version: https://docs.microsoft.com/en-us/windows/uwp/updates-and-versions/choose-a-uwp-version?ocid=VSClient_VerX_NewProject_version
I have the newest WindowsSDK installed (10.0.19041) and it seems like there just isn't a new Version for Windows 2009 and newer (I've got 21H1 installed): https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/
So why is that so? I really don't get why there is no new WinSDK for the corresponding Windows builds and why the highest selectable target for UWP apps is 2004. I guess it's fine, the UWP app runs on my 21H1 machine, but still confusing MS stuff... Or maybe I'm missing some info.
Thanks
...ANSWER
Answered 2021-Jul-26 at 01:59Based on the webstie-Windows 10 SDK, there is a note: Windows 10, version 21H1 is a scoped set of features for select performance improvements and quality enhancements. Developers should be aware of this release, but no action is necessary at this time.
A new Windows SDK will not be issued to accompany this version of Windows because this release doesn’t introduce new APIs. That means there’s no need to modify your project files or target a new version of Windows, and you should continue to use the Windows 10 SDK for Windows 10, version 2004. When setting the target version for your Windows app, Windows 10 build 19041 is still the most recent target version.
That's why you still need to select the build 19041 as the newest target version.
QUESTION
I am experimenting with bindless hlsl resource binding in my directx12 project and I can see why bindless is useful for binding textures, since you can do the following:
...ANSWER
Answered 2021-Jul-14 at 12:12If you need to switch between buffers of the same type, dynamic indexing is indeed useful, but as you mention you need to declare resources of the same type (that said, it is the same with textures, I have common use cases for things like Texture2d for example, so it is not limited to StructuredBuffer).
So yeah, you will have to declare a different array for each typed buffer, which is not super convenient.
If you want to have full dynamic access to your resource (no matter the type), Shader Model 6.6 introduces direct access to heap (code name: ultimate bindless ;)
So you have a global variable called ResourceDescriptorHeap (which represents the currently bound resource Heap)
and SamplerDescriptorHeap (same but for samplers).
Now from there you can do (for example):
QUESTION
So I looked into some tutorials for DirectX12 and when I copied the code that I downloaded from here it worked but when I brought them into a class and wanted to use it, it just crashes in UpdateRenderTargetView method at the m_BackBuffers[i] = backBuffer;
It says: Exception thrown at 0x00007FF831C65FA1 (d3d10warp.dll) in Hazelnut.exe: 0xC0000005: Access violation writing location
The Code:
...ANSWER
Answered 2021-Jan-27 at 20:35Well after you provided some more source code, I am pretty sure the mistake is here:
QUESTION
I am trying to have the DirectX12 pipeline render to only part of the window, not the full window. Is that even possible? I can manually translate the vertices, or set the screenViewport to be a smaller size, but the renderer still renders to the whole window, setting a background color to that which is unrendered.
Even if I set the backbuffers size to be the smaller size, the target view is still the whole window. How can I change the target view to be just a part of the window?
I must be missing something about CreateRenderTargetView()
ANSWER
Answered 2021-Jan-12 at 19:09You can pass D3D12_RECT
to ClearRenderTargetView
to specify what portion of a render target to clear. So set your viewport of smaller size, clear only that part and you should be good to go.
QUESTION
I would like to use DirectX 12 to load each frame of an H264 file into a texture and render it. There is however little to no information on doing this, and the Microsoft website has limited superficial documentation.
Media Foundation has plenty of examples and offers Hardware Enabled decoding. Is the Media Foundation a wrapper around DirectX or is it doing something else?
If not, how much less optimised would the Media Foundation equivalent be in comparison to a DX 12 approach?
Essentially, what are the big differences between Media Foundation and DirectX12 Video Decoding?
I am already using DirectX 12 in my engine so this is specifically regarding DX12.
Thanks in advance.
...ANSWER
Answered 2020-Nov-11 at 09:40Hardware video decoding comes from DXVA (DXVA2) API. It's DirectX 11 evolution is D3D11 Video Device part of D3D11 API. Microsoft provides wrappers over hardware accelerated decoders in the format of Media Foundation API primitives, such as H.264 Video Decoder. This decoder is offering use of hardware decoding capabilities as well as fallback to software decoding scenario.
Note that even though Media Foundation is available for UWP development, your options are limited and you are not offered primitives like mentioned transform directly. However if you use higher level APIs (Media Foundation Source Reader API in particular) you can leverage hardware accelerated video decoding in your UWP application.
Media Foundation implementation offers interoperability with Direct3D 11, in the part of video encoding/decoding in particular, but not Direct3D 12. You will not be able to use Media Foundation and DirectX 12 together out of the box. You will either have to implement Direct3D 11/12 interop to transfer the data between the APIs (or, where applicable, use shared access to the same GPU data).
Or alternatively you will have to step down to underlying ID3D12VideoDevice::CreateVideoDecoder
which is further evolution of mentioned DXVA2 and Direct3D 11 video decoding APIs with similar usage.
Unfortunately if Media Foundation is notoriously known for poor documentation and hard-to-start development, Direct3D 12 video decoding has zero information and you will have to enjoy a feeling of a pioneer.
Either way all the mentioned are relatively thin wrappers over hardware assisted video decoding implementation with the same great performance. I would recommend taking Media Foundation path and implement 11/12 interop if/when it becomes necessary.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install DirectX12
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page