Graphics‎ > ‎Graphic API‎ > ‎DirectX12‎ > ‎


Only two of them now

There are two types of resources, buffers and textures. They are created by filling in a D3D12_RESOURCE_DESC and calling a Create*Resource function. The function to call depends on how the memory managment for the resource will be done. The result of the create function is a ID3D12Resource.

Buffers are used to provide the GPU with an array of data elements. To create a buffer set the _DESC dimension field to D3D12_RESOURCE_DIMENSION_BUFFER and width to the size of the buffer in bytes.

For textures set .Dimension to D3D12_RESOURCE_DIMENSION_TEXTURE*D depending on the dimension of the texture. Width, Height, and DepthOrArraySize must all be set to the size of the texture. If a value is not used for a texture dimension it should be set to 1. For 1D/2D textures the DepthOrArraySize is interpreted as array size.

Create Functions
Creates a resource and also creates a heap with the memory for it. You can not access the heap in any other way and when you release the resource the heap will also be relased.

Creates a resource at a choosen offset in a given heap. It's up to the caller to make sure that the size of the resource does not spill out of the heap. These type of resources is the most light weight ones and the fastest to create and destroy.

This type of resource can only be used if the adapter supports tiled resources. It creates the resource only but allocate no physical memory for it, only virtual memory. ID3D12CommandQueue::UpdateTileMappings() and ID3D12CommandQueue::CopyTileMappings().

How to load the data into a resource depends on what heap it is in.

Upload Heap
If the resource is in an upload heap the CPU can access it. Use map to get a pointer to the data then copy the data to that address.

Default Heap
A resource in the default heap can not be accessed by the CPU. So it first need to be put into a upload heap and then copied over to the default heap with ID3D12GraphicsCommandList::Copy* functions.

To read a resource back to the CPU a special readback heap is used. Use the copy functions to copy the it from default to the readback heap and when done use map to read it from the CPU.