mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 20:04:31 +01:00
Add helper for Vulkan struct chaining
This commit is contained in:
1 parent
ec4f0d0eac
commit
7c817f3ecd
6 files changed
+27
-27
No files matched your search
@@ -278,12 +278,12 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) {
|
||||
VkPhysicalDevicePushDescriptorPropertiesKHR pushProps{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR};
|
||||
VkPhysicalDeviceExternalMemoryHostPropertiesEXT extHostMemProps{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT};
|
||||
VkPhysicalDeviceDepthStencilResolveProperties depthStencilResolveProps{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES};
|
||||
|
||||
props2.pNext = &pushProps;
|
||||
pushProps.pNext = &extHostMemProps;
|
||||
extHostMemProps.pNext = &depthStencilResolveProps;
|
||||
ChainStruct(props2, &pushProps);
|
||||
ChainStruct(props2, &extHostMemProps);
|
||||
ChainStruct(props2, &depthStencilResolveProps);
|
||||
vkGetPhysicalDeviceProperties2(physical_devices_[i], &props2);
|
||||
// Don't want bad pointers sitting around.
|
||||
|
||||
// Don't want bad pointers sitting around. Probably not really necessary.
|
||||
props2.pNext = nullptr;
|
||||
pushProps.pNext = nullptr;
|
||||
extHostMemProps.pNext = nullptr;
|
||||
@@ -702,21 +702,20 @@ VkResult VulkanContext::CreateDevice(int physical_device) {
|
||||
VkPhysicalDevicePresentIdFeaturesKHR presentIdFeatures{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR };
|
||||
VkPhysicalDeviceProvokingVertexFeaturesEXT provokingVertexFeatures{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT };
|
||||
|
||||
features2.pNext = &multiViewFeatures;
|
||||
multiViewFeatures.pNext = &presentWaitFeatures;
|
||||
presentWaitFeatures.pNext = &presentIdFeatures;
|
||||
ChainStruct(features2, &multiViewFeatures);
|
||||
ChainStruct(features2, &presentWaitFeatures);
|
||||
ChainStruct(features2, &presentIdFeatures);
|
||||
if (extensionsLookup_.EXT_provoking_vertex) {
|
||||
presentIdFeatures.pNext = &provokingVertexFeatures;
|
||||
provokingVertexFeatures.pNext = nullptr;
|
||||
} else {
|
||||
presentIdFeatures.pNext = nullptr;
|
||||
ChainStruct(features2, &provokingVertexFeatures);
|
||||
}
|
||||
vkGetPhysicalDeviceFeatures2(physical_devices_[physical_device_], &features2);
|
||||
deviceFeatures_.available.standard = features2.features;
|
||||
deviceFeatures_.available.multiview = multiViewFeatures;
|
||||
deviceFeatures_.available.presentWait = presentWaitFeatures;
|
||||
deviceFeatures_.available.presentId = presentIdFeatures;
|
||||
deviceFeatures_.available.provokingVertex = provokingVertexFeatures;
|
||||
if (extensionsLookup_.EXT_provoking_vertex) {
|
||||
deviceFeatures_.available.provokingVertex = provokingVertexFeatures;
|
||||
}
|
||||
} else {
|
||||
vkGetPhysicalDeviceFeatures(physical_devices_[physical_device_], &deviceFeatures_.available.standard);
|
||||
deviceFeatures_.available.multiview = {};
|
||||
@@ -772,15 +771,11 @@ VkResult VulkanContext::CreateDevice(int physical_device) {
|
||||
if (extensionsLookup_.KHR_get_physical_device_properties2) {
|
||||
device_info.pNext = &features2;
|
||||
features2.features = deviceFeatures_.enabled.standard;
|
||||
features2.pNext = &deviceFeatures_.enabled.multiview;
|
||||
deviceFeatures_.enabled.multiview.pNext = &deviceFeatures_.enabled.presentWait;
|
||||
deviceFeatures_.enabled.presentWait.pNext = &deviceFeatures_.enabled.presentId;
|
||||
ChainStruct(features2, &deviceFeatures_.enabled.multiview);
|
||||
ChainStruct(features2, &deviceFeatures_.enabled.presentWait);
|
||||
ChainStruct(features2, &deviceFeatures_.enabled.presentId);
|
||||
if (extensionsLookup_.EXT_provoking_vertex) {
|
||||
// TODO: Write some proper chaining thing.
|
||||
deviceFeatures_.enabled.presentId.pNext = &deviceFeatures_.enabled.provokingVertex;
|
||||
deviceFeatures_.enabled.provokingVertex.pNext = nullptr;
|
||||
} else {
|
||||
deviceFeatures_.enabled.presentId.pNext = nullptr;
|
||||
ChainStruct(features2, &deviceFeatures_.enabled.provokingVertex);
|
||||
}
|
||||
} else {
|
||||
device_info.pEnabledFeatures = &deviceFeatures_.enabled.standard;
|
||||
@@ -1833,7 +1828,7 @@ void VulkanContext::GetImageMemoryRequirements(VkImage image, VkMemoryRequiremen
|
||||
|
||||
VkMemoryRequirements2KHR memReq2 = {VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR};
|
||||
VkMemoryDedicatedRequirementsKHR memDedicatedReq{VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR};
|
||||
memReq2.pNext = &memDedicatedReq;
|
||||
ChainStruct(memReq2, &memDedicatedReq);
|
||||
|
||||
vkGetImageMemoryRequirements2(GetDevice(), &memReqInfo2, &memReq2);
|
||||
|
||||
|
||||
@@ -44,6 +44,11 @@ VK_DEFINE_HANDLE(VmaAllocation);
|
||||
|
||||
std::string VulkanVendorString(uint32_t vendorId);
|
||||
|
||||
template<class R, class T> inline void ChainStruct(R &root, T *newStruct) {
|
||||
newStruct->pNext = root.pNext;
|
||||
root.pNext = newStruct;
|
||||
}
|
||||
|
||||
// Not all will be usable on all platforms, of course...
|
||||
enum WindowSystem {
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -132,13 +132,13 @@ VkResult FrameData::QueuePresent(VulkanContext *vulkan, FrameDataShared &shared)
|
||||
|
||||
if (shared.measurePresentTime) {
|
||||
if (vulkan->Extensions().KHR_present_id && vulkan->GetDeviceFeatures().enabled.presentId.presentId) {
|
||||
ChainStruct(present, &presentID);
|
||||
presentID.pPresentIds = &frameId;
|
||||
presentID.swapchainCount = 1;
|
||||
present.pNext = &presentID;
|
||||
} else if (vulkan->Extensions().GOOGLE_display_timing) {
|
||||
ChainStruct(present, &presentGOOGLE);
|
||||
presentGOOGLE.pTimes = &presentTimeGOOGLE;
|
||||
presentGOOGLE.swapchainCount = 1;
|
||||
present.pNext = &presentGOOGLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -505,7 +505,7 @@ VkRenderPass CreateRenderPass(VulkanContext *vulkan, const RPKey &key, RenderPas
|
||||
VkAttachmentReference2KHR depthResolveReference2{ VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR };
|
||||
VkSubpassDescriptionDepthStencilResolveKHR depthStencilResolve{ VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR };
|
||||
if (hasDepth && multisample) {
|
||||
subpass2.pNext = &depthStencilResolve;
|
||||
ChainStruct(subpass2, &depthStencilResolve);
|
||||
depthResolveReference2.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
depthResolveReference2.attachment = 1;
|
||||
depthResolveReference2.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||
|
||||
@@ -1246,7 +1246,7 @@ Pipeline *VKContext::CreateGraphicsPipeline(const PipelineDesc &desc, const char
|
||||
raster->ToVulkan(&gDesc.rs);
|
||||
|
||||
if (renderManager_.GetVulkanContext()->GetDeviceFeatures().enabled.provokingVertex.provokingVertexLast) {
|
||||
gDesc.rs.pNext = &gDesc.rs_provoking;
|
||||
ChainStruct(gDesc.rs, &gDesc.rs_provoking);
|
||||
gDesc.rs_provoking.provokingVertexMode = VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT;
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ static VulkanPipeline *CreateVulkanPipeline(VulkanRenderManager *renderManager,
|
||||
rs.depthClampEnable = key.depthClampEnable;
|
||||
|
||||
if (renderManager->GetVulkanContext()->GetDeviceFeatures().enabled.provokingVertex.provokingVertexLast) {
|
||||
rs.pNext = &desc->rs_provoking;
|
||||
ChainStruct(rs, &desc->rs_provoking);
|
||||
desc->rs_provoking.provokingVertexMode = VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user