()).Success;
}
}
///
/// Creates a command queue.
///
/// Specifies a that describes the command queue.
/// A reference to a memory block that receives a reference to the interface for the command queue.
///
/// dn788657
/// HRESULT ID3D12Device::CreateCommandQueue([In] const D3D12_COMMAND_QUEUE_DESC* pDesc,[In] const GUID& riid,[Out] ID3D12CommandQueue** ppCommandQueue)
/// ID3D12Device::CreateCommandQueue
public SharpDX.Direct3D12.CommandQueue CreateCommandQueue(SharpDX.Direct3D12.CommandQueueDescription description)
{
return CreateCommandQueue(description, Utilities.GetGuidFromType(typeof(CommandQueue)));
}
///
/// Creates a command queue.
///
/// The that describes the command queue.
/// A reference to a memory block that receives a reference to the interface for the command queue.
public SharpDX.Direct3D12.CommandQueue CreateCommandQueue(SharpDX.Direct3D12.CommandListType type)
{
return CreateCommandQueue(new SharpDX.Direct3D12.CommandQueueDescription(type), Utilities.GetGuidFromType(typeof(CommandQueue)));
}
///
/// Creates a command queue.
///
/// The that describes the command queue.
/// Multi GPU node mask.
/// A reference to a memory block that receives a reference to the interface for the command queue.
public SharpDX.Direct3D12.CommandQueue CreateCommandQueue(SharpDX.Direct3D12.CommandListType type, int nodeMask)
{
return CreateCommandQueue(new SharpDX.Direct3D12.CommandQueueDescription(type, nodeMask), Utilities.GetGuidFromType(typeof(CommandQueue)));
}
///
/// Creates a command allocator object.
///
/// A -typed value that specifies the type of command allocator to create. The type of command allocator can be the type that records either direct command lists or bundles.
/// A reference to a memory block that receives a reference to the interface for the command allocator.
///
/// The device creates command lists from the command allocator.
///
///
/// dn788655
/// HRESULT ID3D12Device::CreateCommandAllocator([In] D3D12_COMMAND_LIST_TYPE type,[In] const GUID& riid,[Out] ID3D12CommandAllocator** ppCommandAllocator)
/// ID3D12Device::CreateCommandAllocator
public SharpDX.Direct3D12.CommandAllocator CreateCommandAllocator(SharpDX.Direct3D12.CommandListType type)
{
return CreateCommandAllocator(type, Utilities.GetGuidFromType(typeof(CommandAllocator)));
}
///
/// Creates a new graphics command list object.
///
/// A value that specifies the type of command list to create.
/// A object that the device creates command lists from.
/// A object that contains the initial pipeline state for the command list.
/// A new instance of .
public GraphicsCommandList CreateCommandList(
SharpDX.Direct3D12.CommandListType type,
SharpDX.Direct3D12.CommandAllocator commandAllocator,
SharpDX.Direct3D12.PipelineState initialState)
{
return CreateCommandList(0, type, commandAllocator, initialState);
}
///
/// Creates a new graphics command list object.
///
///
/// For single GPU operation, set this to zero.
/// If there are multiple GPU nodes, set a bit to identify the node (the device's physical adapter) for which to create the command list.
/// Each bit in the mask corresponds to a single node. Only 1 bit must be set.
///
/// A value that specifies the type of command list to create.
/// A object that the device creates command lists from.
/// A object that contains the initial pipeline state for the command list.
/// A new instance of .
/// dn788656
///
/// HRESULT ID3D12Device::CreateCommandList([In] unsigned int nodeMask,[In] D3D12_COMMAND_LIST_TYPE type,[In] ID3D12CommandAllocator* pCommandAllocator,[In, Optional] ID3D12PipelineState* pInitialState,[In] const GUID& riid,[Out] void** ppCommandList)
/// ID3D12Device::CreateCommandList
public GraphicsCommandList CreateCommandList(int nodeMask,
SharpDX.Direct3D12.CommandListType type,
SharpDX.Direct3D12.CommandAllocator commandAllocator,
SharpDX.Direct3D12.PipelineState initialState)
{
var nativePointer = CreateCommandList(
nodeMask,
type,
commandAllocator,
initialState,
Utilities.GetGuidFromType(typeof(GraphicsCommandList)));
return new GraphicsCommandList(nativePointer);
}
///
/// This method creates a command signature.
///
/// Describes the command signature to be created with the structure.
/// Specifies the that the command signature applies to.
/// The globally unique identifier () for the command signature interface (). The REFIID, or , of the interface to the command signature can be obtained by using the __uuidof() macro. For example, __uuidof() will get the of the interface to a command signature.
/// Specifies a reference, that on successful completion of the method will point to the created command signature ().
///
/// dn903827
/// HRESULT ID3D12Device::CreateCommandSignature([In] const void* pDesc,[In, Optional] ID3D12RootSignature* pRootSignature,[In] const GUID& riid,[Out] ID3D12CommandSignature** ppvCommandSignature)
/// ID3D12Device::CreateCommandSignature
public unsafe CommandSignature CreateCommandSignature(SharpDX.Direct3D12.CommandSignatureDescription descRef, SharpDX.Direct3D12.RootSignature rootSignatureRef)
{
var nativeDesc = new CommandSignatureDescription.__Native();
descRef.__MarshalTo(ref nativeDesc);
fixed (void* pIndirectArguments = descRef.IndirectArguments)
{
if (descRef.IndirectArguments != null)
{
nativeDesc.ArgumentDescCount = descRef.IndirectArguments.Length;
nativeDesc.ArgumentDescsPointer = new IntPtr(pIndirectArguments);
}
return CreateCommandSignature(new IntPtr(&nativeDesc), rootSignatureRef, Utilities.GetGuidFromType(typeof(CommandSignature)));
}
}
///
/// Creates both a resource and an implicit heap, such that the heap is big enough to contain the entire resource and the resource is mapped to the heap.
///
/// A reference to a structure that provides properties for the resource's heap.
/// Heap options, as a bitwise-OR'd combination of enumeration constants.
/// A reference to a structure that describes the resource.
/// The initial state of the resource, as a bitwise-OR'd combination of enumeration constants.
When a resource is created together with a _UPLOAD heap, InitialResourceState must be D3D12_RESOURCE_STATE_GENERIC_READ. When a resource is created together with a heap, InitialResourceState must be .
/// Specifies a that describes the default value for a clear color.
pOptimizedClearValue specifies a value for which clear operations are most optimal. When the created resource is a texture with either the D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET or flags, applications should choose the value that the clear operation will most commonly be called with. Clear operations can be called with other values, but those operations will not be as efficient as when the value matches the one passed into resource creation. pOptimizedClearValue must be null when used with _BUFFER.
/// The globally unique identifier () for the resource interface. This is an input parameter. The REFIID, or , of the interface to the resource can be obtained by using the __uuidof() macro. For example, __uuidof() will get the of the interface to a resource.
While riidResource is, most commonly, the for , it may be any for any interface. If the resource object doesn't support the interface for this , creation will fail with E_NOINTERFACE.
/// A reference to memory that receives the requested interface reference to the created resource object. ppvResource can be null, to enable capability testing. When ppvResource is null, no object will be created and S_FALSE will be returned when pResourceDesc is valid.
///
/// This method creates both a resource and a heap, such that the heap is big enough to contain the entire resource and the resource is mapped to the heap. The created heap is known as an implicit heap, because the heap object cannot be obtained by the application. The application must ensure the GPU will no longer read or write to this resource before releasing the final reference on the resource.
The implicit heap is made resident for GPU access before the method returns to the application. See Residency.
The resource GPU VA mapping cannot be changed. See and Volume Tiled Resources.
This method may be called by multiple threads concurrently.
///
///
/// dn899178
/// HRESULT ID3D12Device::CreateCommittedResource([In] const D3D12_HEAP_PROPERTIES* pHeapProperties,[In] D3D12_HEAP_FLAGS HeapFlags,[In, Value] const D3D12_RESOURCE_DESC* pResourceDesc,[In] D3D12_RESOURCE_STATES InitialResourceState,[In, Optional] const D3D12_CLEAR_VALUE* pOptimizedClearValue,[In] const GUID& riidResource,[Out] ID3D12Resource** ppvResource)
/// ID3D12Device::CreateCommittedResource
public SharpDX.Direct3D12.Resource CreateCommittedResource(SharpDX.Direct3D12.HeapProperties heapPropertiesRef, SharpDX.Direct3D12.HeapFlags heapFlags, SharpDX.Direct3D12.ResourceDescription resourceDescRef, SharpDX.Direct3D12.ResourceStates initialResourceState, SharpDX.Direct3D12.ClearValue? optimizedClearValueRef = null)
{
return CreateCommittedResource(ref heapPropertiesRef, heapFlags, ref resourceDescRef, initialResourceState, optimizedClearValueRef, Utilities.GetGuidFromType(typeof(Resource)));
}
///
/// Creates a compute pipeline state object.
///
/// A reference to a structure that describes compute pipeline state.
/// The globally unique identifier () for the pipeline state interface (). The REFIID, or , of the interface to the pipeline state can be obtained by using the __uuidof() macro. For example, __uuidof() will get the of the interface to a pipeline state.
/// A reference to a memory block that receives a reference to the interface for the pipeline state object. The pipeline state object is an immutable state object. It contains no methods.
///
/// dn788658
/// HRESULT ID3D12Device::CreateComputePipelineState([In] const void* pDesc,[In] const GUID& riid,[Out] ID3D12PipelineState** ppPipelineState)
/// ID3D12Device::CreateComputePipelineState
public unsafe SharpDX.Direct3D12.PipelineState CreateComputePipelineState(SharpDX.Direct3D12.ComputePipelineStateDescription descRef)
{
// Use a custom marshalling routine for this class
var nativeDesc = new ComputePipelineStateDescription.__Native();
descRef.__MarshalTo(ref nativeDesc);
fixed (void* pComputeShader = descRef.ComputeShader.Buffer)
{
descRef.ComputeShader.UpdateNative(ref nativeDesc.ComputeShader, (IntPtr)pComputeShader);
return CreateComputePipelineState(new IntPtr(&nativeDesc), Utilities.GetGuidFromType(typeof(PipelineState)));
}
}
///
/// Creates a root signature layout.
///
/// No documentation.
/// No documentation.
/// No documentation.
/// No documentation.
/// No documentation.
///
/// dn788658
/// HRESULT ID3D12Device::CreateRootSignature([In] unsigned int nodeMask,[In, Buffer] const void* pBlobWithRootSignature,[In] SIZE_T blobLengthInBytes,[In] const GUID& riid,[Out] ID3D12RootSignature** ppvRootSignature)
/// ID3D12Device::CreateRootSignature
public SharpDX.Direct3D12.RootSignature CreateRootSignature(DataPointer rootSignaturePointer)
{
return CreateRootSignature(0, rootSignaturePointer);
}
///
/// Creates a root signature layout.
///
/// No documentation.
/// No documentation.
/// No documentation.
/// No documentation.
/// No documentation.
///
/// dn788658
/// HRESULT ID3D12Device::CreateRootSignature([In] unsigned int nodeMask,[In, Buffer] const void* pBlobWithRootSignature,[In] SIZE_T blobLengthInBytes,[In] const GUID& riid,[Out] ID3D12RootSignature** ppvRootSignature)
/// ID3D12Device::CreateRootSignature
public SharpDX.Direct3D12.RootSignature CreateRootSignature(int nodeMask, DataPointer rootSignaturePointer)
{
return CreateRootSignature(nodeMask, rootSignaturePointer.Pointer, rootSignaturePointer.Size, Utilities.GetGuidFromType(typeof(RootSignature)));
}
///
/// Creates a root signature layout.
///
/// No documentation.
/// No documentation.
/// No documentation.
/// No documentation.
/// No documentation.
///
/// dn788658
/// HRESULT ID3D12Device::CreateRootSignature([In] unsigned int nodeMask,[In, Buffer] const void* pBlobWithRootSignature,[In] SIZE_T blobLengthInBytes,[In] const GUID& riid,[Out] ID3D12RootSignature** ppvRootSignature)
/// ID3D12Device::CreateRootSignature
public unsafe SharpDX.Direct3D12.RootSignature CreateRootSignature(byte[] byteCode)
{
if (byteCode == null)
throw new ArgumentNullException("byteCode");
fixed (byte* ptr = &byteCode[0])
{
return CreateRootSignature(new DataPointer(new IntPtr(ptr), byteCode.Length));
}
}
///
/// Creates a descriptor heap object.
///
/// No documentation.
/// New instance of .
/// dn788662
/// HRESULT ID3D12Device::CreateDescriptorHeap([In] const D3D12_DESCRIPTOR_HEAP_DESC* pDescriptorHeapDesc,[In] const GUID& riid,[Out] ID3D12DescriptorHeap** ppvHeap)
/// ID3D12Device::CreateDescriptorHeap
public SharpDX.Direct3D12.DescriptorHeap CreateDescriptorHeap(SharpDX.Direct3D12.DescriptorHeapDescription descriptorHeapDesc)
{
return CreateDescriptorHeap(descriptorHeapDesc, Utilities.GetGuidFromType(typeof(DescriptorHeap)));
}
///
/// Creates a descriptor heap object.
///
/// The heap type.
/// The descriptor count.
/// The optional heap flags.
/// Multi GPU node mask.
/// New instance of .
/// dn788662
/// HRESULT ID3D12Device::CreateDescriptorHeap([In] const D3D12_DESCRIPTOR_HEAP_DESC* pDescriptorHeapDesc,[In] const GUID& riid,[Out] ID3D12DescriptorHeap** ppvHeap)
/// ID3D12Device::CreateDescriptorHeap
public SharpDX.Direct3D12.DescriptorHeap CreateDescriptorHeap(DescriptorHeapType type, int descriptorCount, DescriptorHeapFlags flags = DescriptorHeapFlags.None, int nodeMask = 0)
{
DescriptorHeapDescription description = new DescriptorHeapDescription
{
Type = type,
DescriptorCount = descriptorCount,
Flags = flags,
NodeMask = nodeMask,
};
return CreateDescriptorHeap(description, Utilities.GetGuidFromType(typeof(DescriptorHeap)));
}
///
/// Creates a fence object.
///
/// No documentation.
/// No documentation.
/// No documentation.
/// No documentation.
///
/// dn899179
/// HRESULT ID3D12Device::CreateFence([In] unsigned longlong InitialValue,[In] D3D12_FENCE_FLAGS Flags,[In] const GUID& riid,[Out] ID3D12Fence** ppFence)
/// ID3D12Device::CreateFence
public Fence CreateFence(long initialValue, SharpDX.Direct3D12.FenceFlags flags)
{
return CreateFence(initialValue, flags, Utilities.GetGuidFromType(typeof(Fence)));
}
///
/// Creates a graphics pipeline state object.
///
/// No documentation.
/// No documentation.
/// No documentation.
///
/// dn788663
/// HRESULT ID3D12Device::CreateGraphicsPipelineState([In] const void* pDesc,[In] const GUID& riid,[Out] ID3D12PipelineState** ppPipelineState)
/// ID3D12Device::CreateGraphicsPipelineState
public unsafe SharpDX.Direct3D12.PipelineState CreateGraphicsPipelineState(SharpDX.Direct3D12.GraphicsPipelineStateDescription desc)
{
// Use a custom marshalling routine for this class
var nativeDesc = new GraphicsPipelineStateDescription.__Native();
desc.__MarshalTo(ref nativeDesc);
// Pin buffers if necessary
fixed (void* pVertexShader = desc.VertexShader.Buffer)
fixed (void* pGeometryShader = desc.GeometryShader.Buffer)
fixed (void* pDomainShader = desc.DomainShader.Buffer)
fixed (void* pHullShader = desc.HullShader.Buffer)
fixed (void* pPixelShader = desc.PixelShader.Buffer)
{
// Transfer pin buffer address to marshal
desc.VertexShader.UpdateNative(ref nativeDesc.VertexShader, (IntPtr)pVertexShader);
desc.GeometryShader.UpdateNative(ref nativeDesc.GeometryShader, (IntPtr)pGeometryShader);
desc.DomainShader.UpdateNative(ref nativeDesc.DomainShader, (IntPtr)pDomainShader);
desc.HullShader.UpdateNative(ref nativeDesc.HullShader, (IntPtr)pHullShader);
desc.PixelShader.UpdateNative(ref nativeDesc.PixelShader, (IntPtr)pPixelShader);
// Marshal input elements
var elements = desc.InputLayout != null ? desc.InputLayout.Elements : null;
var nativeElements = (InputElement.__Native*)0;
if (elements != null && elements.Length > 0)
{
var ptr = stackalloc InputElement.__Native[elements.Length];
nativeElements = ptr;
for (int i = 0; i < elements.Length; i++)
{
elements[i].__MarshalTo(ref nativeElements[i]);
}
nativeDesc.InputLayout.InputElementsPointer = new IntPtr(nativeElements);
nativeDesc.InputLayout.ElementCount = elements.Length;
}
//Marshal stream output elements
var streamOutElements = desc.StreamOutput != null ? desc.StreamOutput.Elements : null;
var nativeStreamOutElements = (StreamOutputElement.__Native*)0;
if (streamOutElements != null && streamOutElements.Length > 0)
{
var ptr = stackalloc StreamOutputElement.__Native[streamOutElements.Length];
nativeStreamOutElements = ptr;
for (int i = 0; i < streamOutElements.Length; i++)
{
streamOutElements[i].__MarshalTo(ref nativeStreamOutElements[i]);
}
nativeDesc.StreamOutput.StreamOutputEntriesPointer = new IntPtr(nativeStreamOutElements);
nativeDesc.StreamOutput.EntrieCount = streamOutElements.Length;
}
try
{
// Create the pipeline state
return CreateGraphicsPipelineState(new IntPtr(&nativeDesc), Utilities.GetGuidFromType(typeof(PipelineState)));
}
finally
{
if (elements != null)
{
for (int i = 0; i < elements.Length; i++)
{
elements[i].__MarshalFree(ref nativeElements[i]);
}
}
if (streamOutElements != null)
{
for (int i = 0; i < streamOutElements.Length; i++)
{
streamOutElements[i].__MarshalFree(ref nativeStreamOutElements[i]);
}
}
}
}
}
///
/// Creates a heap that can be used with placed resources and reserved resources.
///
/// A reference to a structure that describes the heap.
/// The globally unique identifier () for the heap interface. This is an input parameter. The REFIID, or , of the interface to the heap can be obtained by using the __uuidof() macro. For example, __uuidof() will get the of the interface to a heap. riid is, most commonly, the for , but it may be any for any interface. If the resource object does not support the interface for the specified , creation will fail with E_NOINTERFACE.
/// A reference to a memory block that receives a reference to the heap. ppvHeap can be null, to enable capability testing. When ppvHeap is null, no object will be created and S_FALSE will be returned when pDesc is valid.
///
/// CreateHeap creates a heap that can be used with placed resources and reserved resources. Before releasing the final reference on the heap, the application must ensure that the GPU will no longer read or write to this heap. Placed resource objects will hold a reference on the heap they are created on, but reserved resources will not hold a reference for each mapping made to a heap.
///
///
/// dn788664
/// HRESULT ID3D12Device::CreateHeap([In] const D3D12_HEAP_DESC* pDesc,[In] const GUID& riid,[Out] ID3D12Heap** ppvHeap)
/// ID3D12Device::CreateHeap
public SharpDX.Direct3D12.Heap CreateHeap(SharpDX.Direct3D12.HeapDescription descRef)
{
return CreateHeap(ref descRef, Utilities.GetGuidFromType(typeof(Heap)));
}
///
/// Creates a query heap. A query heap contains an array of queries.
///
/// Specifies the query heap in a structure.
/// Specifies a REFIID that uniquely identifies the heap.
/// Specifies a reference to the heap, that will be returned on successful completion of the method. ppvHeap can be null, to enable capability testing. When ppvHeap is null, no object will be created and S_FALSE will be returned when pDesc is valid.
///
/// Refer to Queries for more information.
///
///
/// dn903828
/// HRESULT ID3D12Device::CreateQueryHeap([In] const D3D12_QUERY_HEAP_DESC* pDesc,[In] const GUID& riid,[Out] ID3D12QueryHeap** ppvHeap)
/// ID3D12Device::CreateQueryHeap
public SharpDX.Direct3D12.QueryHeap CreateQueryHeap(SharpDX.Direct3D12.QueryHeapDescription descRef)
{
return CreateQueryHeap(descRef, Utilities.GetGuidFromType(typeof(QueryHeap)));
}
///
/// Creates a resource that is placed in a specific heap. Placed resources are the lightest weight resource objects available, and are the fastest to create and destroy.
///
/// A reference to the interface that represents the heap in which the resource is placed.
/// The offset, in bytes, to the resource. The HeapOffset must be a multiple of the resource's alignment, and HeapOffset plus the resource size must be smaller than or equal to the heap size. GetResourceAllocationInfo must be used to understand the sizes of texture resources.
/// A reference to a structure that describes the resource.
/// The initial state of the resource, as a bitwise-OR'd combination of enumeration constants.
When a resource is created together with a heap, InitialState must be . When a resource is created together with a heap, InitialState must be .
/// Specifies a that describes the default value for a clear color.
pOptimizedClearValue specifies a value for which clear operations are most optimal. When the created resource is a texture with either the or flags, applications should choose the value that the clear operation will most commonly be called with. Clear operations can be called with other values, but those operations will not be as efficient as when the value matches the one passed into resource creation. pOptimizedClearValue must be null when used with .
/// The globally unique identifier () for the resource interface. This is an input parameter.
The REFIID, or , of the interface to the resource can be obtained by using the __uuidof() macro. For example, __uuidof() will get the of the interface to a resource. Although riid is, most commonly, the for , it may be any for any interface. If the resource object doesn't support the interface for this , creation will fail with E_NOINTERFACE.
/// A reference to a memory block that receives a reference to the resource. ppvResource can be null, to enable capability testing. When ppvResource is null, no object will be created and S_FALSE will be returned when pResourceDesc and other parameters are valid.
///
/// CreatePlacedResource is similar to fully mapping a reserved resource to an offset within a heap; but the virtual address space associated with a heap may be reused as well.
Placed resources are lighter weight than committed resources to create and destroy, because no heap is created or destroyed during this operation. However, placed resources enable an even lighter weight technique to reuse memory than resource creation and destruction: reuse through aliasing and aliasing barriers. Multiple placed resources may simultaneously overlap each other on the same heap, but only a single overlapping resource can be used at a time.
There are two placed resource usage semantics, a simple model and an advanced model. The simple model is recommended, and is the most likely model for tool support, until the advanced model is proven to be required by the app.
///
///
/// dn899180
/// HRESULT ID3D12Device::CreatePlacedResource([In] ID3D12Heap* pHeap,[In] unsigned longlong HeapOffset,[In] const D3D12_RESOURCE_DESC* pDesc,[In] D3D12_RESOURCE_STATES InitialState,[In, Optional] const D3D12_CLEAR_VALUE* pOptimizedClearValue,[In] const GUID& riid,[Out] ID3D12Resource** ppvResource)
/// ID3D12Device::CreatePlacedResource
public SharpDX.Direct3D12.Resource CreatePlacedResource(SharpDX.Direct3D12.Heap heapRef,
long heapOffset,
SharpDX.Direct3D12.ResourceDescription descRef,
SharpDX.Direct3D12.ResourceStates initialState,
SharpDX.Direct3D12.ClearValue? optimizedClearValueRef = null)
{
return CreatePlacedResource(heapRef, heapOffset, ref descRef, initialState, optimizedClearValueRef, Utilities.GetGuidFromType(typeof(Resource)));
}
///
/// Creates a resource that is reserved, which is not yet mapped to any pages in a heap.
///
/// No documentation.
/// No documentation.
/// No documentation.
/// No documentation.
/// No documentation.
/// dn899181
///
/// HRESULT ID3D12Device::CreateReservedResource([In] const D3D12_RESOURCE_DESC* pDesc,[In] D3D12_RESOURCE_STATES InitialState,[In, Optional] const D3D12_CLEAR_VALUE* pOptimizedClearValue,[In] const GUID& riid,[Out] ID3D12Resource** ppvResource)
/// ID3D12Device::CreateReservedResource
public SharpDX.Direct3D12.Resource CreateReservedResource(SharpDX.Direct3D12.ResourceDescription descRef,
SharpDX.Direct3D12.ResourceStates initialState,
SharpDX.Direct3D12.ClearValue? optimizedClearValueRef = null)
{
return CreateReservedResource(ref descRef, initialState, optimizedClearValueRef, Utilities.GetGuidFromType(typeof(Resource)));
}
///
/// Gets the size and alignment of memory required for a collection of resources on this adapter.
///
/// For single GPU operation, set this to zero. If there are multiple GPU nodes, set bits to identify the nodes (the device's physical adapters). Each bit in the mask corresponds to a single node. Refer to Multi-Adapter.
/// The number of resource descriptors in the pResourceDescs array.
/// An array of structures that described the resources to get info about.
/// Returns a structure that provides info about video memory allocated for the specified array of resources.
///
/// When using CreatePlacedResource, the application must use this method to understand the size and alignment characteristics of texture resources. The results of this method vary depending on the particular adapter, and must be treated as unique to this adapter and driver version.
Applications cannot use the output of GetResourceAllocationInfo to understand packed mip properties of textures. To understand packed mip properties of textures, applications must use GetResourceTiling. Texture resource sizes significantly differ from the information returned by GetResourceTiling, because some adapter architectures allocate extra memory for textures to reduce the effective bandwidth during common rendering scenarios. This even includes textures that have constraints on their texture layouts or have standardized texture layouts. That extra memory cannot be sparsely mapped or remapped by an application using CreateReservedResource and UpdateTileMappings, so it isn't reported in GetResourceTiling.
Applications can forgo using GetResourceAllocationInfo for buffer resources (_BUFFER). Buffers have the same size on all adapters, which is merely the smallest multiple of 64KB which is greater or equal to ::Width.
When multiple resource descriptions are passed in, the C++ algorithm for calculating a structure size and alignment are used. For example, a three-element array with two tiny 64KB-aligned resources and a tiny 4MB-aligned resource reports differing sizes based on the order of the array. If the 4MB aligned resource is in the middle, the resulting Size is 12MB. Otherwise, the resulting Size is 8MB. The Alignment returned would always be 4MB, as it is the superset of all alignments in the resource array.
///
///
/// dn788680
/// D3D12_RESOURCE_ALLOCATION_INFO ID3D12Device::GetResourceAllocationInfo([In] unsigned int visibleMask,[In] unsigned int numResourceDescs,[In, Buffer] const D3D12_RESOURCE_DESC* pResourceDescs)
/// ID3D12Device::GetResourceAllocationInfo
public SharpDX.Direct3D12.ResourceAllocationInformation GetResourceAllocationInfo(int visibleMask, SharpDX.Direct3D12.ResourceDescription resourceDesc)
{
return GetResourceAllocationInfo(visibleMask, 1, new ResourceDescription[] { resourceDesc });
}
///
/// Gets information about the features that are supported by the current graphics driver.
///
/// A -typed value that describes the feature to query for support.
/// The passed structure is filled with data that describes the feature support. To see the structure types, see the Remarks section in enumeration.
/// The size of the structure passed to the pFeatureSupportData parameter.
/// Returns if successful; otherwise, returns E_INVALIDARG if an unsupported data type is passed to the pFeatureSupportData parameter or a size mismatch is detected for the FeatureSupportDataSize parameter.
///
/// Refer to Capability Querying.
///
///
/// dn788653
/// HRESULT ID3D12Device::CheckFeatureSupport([In] D3D12_FEATURE Feature,[Out, Buffer] void* pFeatureSupportData,[In] unsigned int FeatureSupportDataSize)
/// ID3D12Device::CheckFeatureSupport
public unsafe FeatureDataD3D12Options D3D12Options
{
get
{
FeatureDataD3D12Options options = new FeatureDataD3D12Options();
this.CheckFeatureSupport(Feature.D3D12Options, new IntPtr(&options), Utilities.SizeOf());
return options;
}
}
public unsafe FeatureDataD3D12Options1 D3D12Options1
{
get
{
FeatureDataD3D12Options1 options = new FeatureDataD3D12Options1();
this.CheckFeatureSupport(Feature.D3D12Options1, new IntPtr(&options), Utilities.SizeOf());
return options;
}
}
public unsafe FeatureDataD3D12Options2 D3D12Options2
{
get
{
FeatureDataD3D12Options2 options = new FeatureDataD3D12Options2();
this.CheckFeatureSupport(Feature.D3D12Options2, new IntPtr(&options), Utilities.SizeOf());
return options;
}
}
public unsafe FeatureDataD3D12Options3 D3D12Options3
{
get
{
FeatureDataD3D12Options3 options = new FeatureDataD3D12Options3();
this.CheckFeatureSupport(Feature.D3D12Options3, new IntPtr(&options), Utilities.SizeOf());
return options;
}
}
public unsafe FeatureDataD3D12Options4 D3D12Options4
{
get
{
FeatureDataD3D12Options4 options = new FeatureDataD3D12Options4();
this.CheckFeatureSupport(Feature.D3D12Options4, new IntPtr(&options), Utilities.SizeOf());
return options;
}
}
///
/// Gets information about the features that are supported by the current graphics driver.
///
/// A -typed value that describes the feature to query for support.
/// The passed structure is filled with data that describes the feature support. To see the structure types, see the Remarks section in enumeration.
/// The size of the structure passed to the pFeatureSupportData parameter.
/// Returns if successful; otherwise, returns E_INVALIDARG if an unsupported data type is passed to the pFeatureSupportData parameter or a size mismatch is detected for the FeatureSupportDataSize parameter.
///
/// Refer to Capability Querying.
///
///
/// dn788653
/// HRESULT ID3D12Device::CheckFeatureSupport([In] D3D12_FEATURE Feature,[Out, Buffer] void* pFeatureSupportData,[In] unsigned int FeatureSupportDataSize)
/// ID3D12Device::CheckFeatureSupport
public unsafe FeatureDataArchitecture Architecture
{
get
{
FeatureDataArchitecture options = new FeatureDataArchitecture();
this.CheckFeatureSupport(Feature.Architecture, new IntPtr(&options), Utilities.SizeOf());
return options;
}
}
public unsafe FeatureDataGpuVirtualAddressSupport GpuVirtualAddressSupport
{
get
{
FeatureDataGpuVirtualAddressSupport options = new FeatureDataGpuVirtualAddressSupport();
this.CheckFeatureSupport(Feature.GpuVirtualAddressSupport, new IntPtr(&options), Utilities.SizeOf());
return options;
}
}
public unsafe FeatureDataShaderModel CheckShaderModel(ShaderModel highestShaderModel)
{
var options = new FeatureDataShaderModel
{
HighestShaderModel = highestShaderModel
};
this.CheckFeatureSupport(Feature.ShaderModel, new IntPtr(&options), Utilities.SizeOf());
return options;
}
public unsafe FeatureLevel CheckMaxSupportedFeatureLevel(params FeatureLevel[] levels)
{
fixed (FeatureLevel* levelsPtr = &levels[0])
{
var featureLevels = new FeatureDataFeatureLevels
{
FeatureLevelCount = levels.Length,
FeatureLevelsRequestedPointer = new IntPtr(levelsPtr)
};
this.CheckFeatureSupport(Feature.FeatureLevels, new IntPtr(&featureLevels), Utilities.SizeOf());
return featureLevels.MaxSupportedFeatureLevel;
}
}
private static void CreateDevice(Adapter adapter, FeatureLevel minFeatureLevel, Device instance)
{
D3D12.CreateDevice(adapter, minFeatureLevel, Utilities.GetGuidFromType(typeof(Device)), instance).CheckError();
}
}
}