Open kvark opened 7 years ago
The SwapChain implementation I wrote uses an API that is considered private by Apple on iOS prior to the upcoming iOS 11. If we want to support Metal 1 on iOS that's another sticking point.
Events will probably be hard to implement for both APIs, requiring to split command buffers.
I think we should migrate all the points from #1241 here, describe them in great detail, and close the other issue as a duplicate.
Not sure if this is the right place to share some of our findings so let me know if I should move this.
vkQueueWaitIdle
that can be translated to D3D12 by adding a Signal to a queue, linking it to an Event object and waiting on the event. In Metal you can have a callback when a command buffer finishes executing, and have that trigger a condition variable. glFinish for OpenGL.@Kangz Thanks for chiming in! I split your comment into corresponding issues (#1383 and #1352). I'd prefer to leave this space for more general concerns.
Aspects where vulkan portability is not straightforward. In particular, hard to map towards D3D12, which exposes a smaller and more restricted API surface:
Summary: Vulkan allows to map arbitrary slices of Heap
/DeviceMemory
. in other APIs mapping is coupled with (sub)resources.
Heap
/DeviceMemory
via AllocateMemory
, which can be bound to Buffer
or Image
.DeviceMemory
via (Un)MapBuffer
to read/write data to buffers or images.DeviceMemory
can be only mapped once until it's unmapped again.ID3D12Resource::Map
to map the underlying memory of a resource.(Metal uses contents
for mapping MTLBuffer
afaik, whicb basically maps the whole buffer.)
We currently follow D3D12 in core
by mapping Buffers
instead of directly memory, which is a clear restriction compared to vulkans model.
Summary:
BufferViews
and ImageViews
.SurfaceType
and ChannelType
(+ some restrictions for depth-stencil formats)ChannelType
but not in SurfaceType
, SurfaceType
can only be changed for UAVsWe currently follow D3D12 in core
by exposing SRV/CBV/UAV/RTV/DSV and use enums on Vulkan.
Triangle fans seem like they should be easy to implement just with strips or lists; if I remember I should someday do a good rummage around and see if I can write something that handles them.
Khronos - Vulkan Portability Initiative
Here is a rough list of areas where Vulkan translation to other next-gen APIs is not straightforward. Related to #1226,
#1241, and #1102 cc @msiglreith @JohnColanduoniThe following Vulkan pipeline states are not represented in D3D12 and Metal (see https://github.com/gpuweb/gpuweb/issues/26 for detailed PSO comparison):
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN
Direct3D 12
1376:
vkDescriptorPool
can't be mapped toID3D12DescriptorHeap
, because only one of the latter can be active (for each type: samplers and non-samplers) at any given time during command encoding.1379:
CreateHeap
requires the resource type specified in advance on Tier-1 hardware, whilevkAllocateMemory
is typeless.1352:
CopyTextureRegion
from a source buffer requires minimum alignment of 0x100 for the rows and 0x200 for the depth slices, while Vulkan supports tight packing.vkCmdSetStencil*
supports face selection, whileOMSetStencilRef
and stencil descriptors only support a single value for the reference and masks.vkCmdBlitImage
unsupported, only 1:1 copying possiblevkCmdClearColorImage
/vkCmdClearDepthStencilImage
: Only clearing via RenderTargetView/DepthStencilViews possiblevkCmdFillBuffer
: Only clearing via UAVs possiblevkCmdUpdateBuffer
: Unsupported, d3d12 only allows map/unmap and copyingvkCmdResolveImage
:ResolveSubresource
doens't allow to specify offset+extent for subresources, only whole subresources can be resolved. Format compatibility needs to be enforced.ID3D12GraphicsCommandList
can be recorded at same time for eachID3D12CommandAllocator
(source: https://msdn.microsoft.com/en-us/library/windows/desktop/dn899205(v=vs.85).aspx#recording_command_lists)Metal
1384: Metal heaps do not give us much control over allocations, other than specifying what heap to make the allocation within.
vkCmdClearColorImage
/vkCmdClearDepthStencilImage
: Clearing seems to be only possible via renderpasses. Potential issue with clearing multiple subregions.vkCmdUpdateBuffer
: Unsupported2026:
vkCmdCopyImage
doesn't work with non-equal but compatible formats2050: 1D textures can't have mipmaps
2054: vertex attributes can't have offset exceeding the stride
2077: vertex buffer stride has to be a multiple of 4
TODO
Sort the remaining of #1241:
Suggested new feature flags