diff --git a/gapis/api/vulkan/api/bitfields.api b/gapis/api/vulkan/api/bitfields.api index 90863598a..011fec0bd 100644 --- a/gapis/api/vulkan/api/bitfields.api +++ b/gapis/api/vulkan/api/bitfields.api @@ -596,3 +596,6 @@ bitfield VkSemaphoreWaitFlagBits { VK_SEMAPHORE_WAIT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } type VkFlags VkSemaphoreWaitFlags + +//@extension("VK_KHR_depth_stencil_resolve") +type VkFlags VkResolveModeFlags diff --git a/gapis/api/vulkan/api/enums.api b/gapis/api/vulkan/api/enums.api index 9c4613201..43c6c2491 100644 --- a/gapis/api/vulkan/api/enums.api +++ b/gapis/api/vulkan/api/enums.api @@ -382,6 +382,8 @@ enum VkStructureType: u32 { VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO = 1000108003, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES = 1000130000, VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO = 1000130001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES = 1000199000, + VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE = 1000199001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES = 1000241000, VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT = 1000241001, VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT = 1000241002, @@ -1183,3 +1185,12 @@ enum VkTessellationDomainOrigin: u32 { VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT = 0, VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT = 1, } + +// Vulkan 1.2 core +enum VkResolveModeFlagBits: u32 { + VK_RESOLVE_MODE_NONE = 0x00000000, + VK_RESOLVE_MODE_SAMPLE_ZERO_BIT = 0x00000001, + VK_RESOLVE_MODE_AVERAGE_BIT = 0x00000002, + VK_RESOLVE_MODE_MIN_BIT = 0x00000004, + VK_RESOLVE_MODE_MAX_BIT = 0x00000008, +} diff --git a/gapis/api/vulkan/api/physical_device.api b/gapis/api/vulkan/api/physical_device.api index 5fc928188..3076f73f5 100644 --- a/gapis/api/vulkan/api/physical_device.api +++ b/gapis/api/vulkan/api/physical_device.api @@ -57,6 +57,7 @@ // Vulkan 1.2 core @unused ref!PhysicalDeviceSamplerFilterMinmaxProperties PhysicalDeviceSamplerFilterMinmaxProperties + @unused ref!PhysicalDeviceDepthStencilResolveProperties PhysicalDeviceDepthStencilResolveProperties // Extensions @unused ref!PhysicalDevicePCIBusInfoPropertiesEXT PhysicalDevicePCIBusInfoPropertiesEXT diff --git a/gapis/api/vulkan/api/properties_features_requirements.api b/gapis/api/vulkan/api/properties_features_requirements.api index dba1005c6..de02ed35e 100644 --- a/gapis/api/vulkan/api/properties_features_requirements.api +++ b/gapis/api/vulkan/api/properties_features_requirements.api @@ -695,6 +695,10 @@ sub void GetPhysicalDeviceProperties2( case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES: { _ = as!VkPhysicalDeviceSamplerFilterMinmaxProperties*(next.Ptr)[0] } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES: { + _ = as!VkPhysicalDeviceDepthStencilResolveProperties*(next.Ptr)[0] + } + } next.Ptr = as!VulkanStructHeader*(next.Ptr)[0].PNext } @@ -877,6 +881,15 @@ sub void GetPhysicalDeviceProperties2( FilterMinmaxImageComponentMapping: ext.filterMinmaxImageComponentMapping, ) } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES: { + ext := as!VkPhysicalDeviceDepthStencilResolveProperties*(next.Ptr)[0] + phyDev.PhysicalDeviceDepthStencilResolveProperties = new!PhysicalDeviceDepthStencilResolveProperties( + SupportedDepthResolveModes: ext.supportedDepthResolveModes, + SupportedStencilResolveModes: ext.supportedStencilResolveModes, + IndependentResolveNone: ext.independentResolveNone, + IndependentResolve: ext.independentResolve, + ) + } } next.Ptr = as!VulkanStructHeader*(next.Ptr)[0].PNext } diff --git a/gapis/api/vulkan/api/renderpass_framebuffer.api b/gapis/api/vulkan/api/renderpass_framebuffer.api index 9c05b58fc..78d120739 100644 --- a/gapis/api/vulkan/api/renderpass_framebuffer.api +++ b/gapis/api/vulkan/api/renderpass_framebuffer.api @@ -165,16 +165,16 @@ Thefore there is no need to repeat the KHR structs } @internal class AttachmentDescription { - VkAttachmentDescriptionFlags Flags - VkFormat Format - VkSampleCountFlagBits Samples - VkAttachmentLoadOp LoadOp - VkAttachmentStoreOp StoreOp - VkAttachmentLoadOp StencilLoadOp - VkAttachmentStoreOp StencilStoreOp - VkImageLayout InitialLayout - VkImageLayout FinalLayout - ref!AttachmentDescriptionStencilLayout StencilLayout + VkAttachmentDescriptionFlags Flags + VkFormat Format + VkSampleCountFlagBits Samples + VkAttachmentLoadOp LoadOp + VkAttachmentStoreOp StoreOp + VkAttachmentLoadOp StencilLoadOp + VkAttachmentStoreOp StencilStoreOp + VkImageLayout InitialLayout + VkImageLayout FinalLayout + ref!AttachmentDescriptionStencilLayout StencilLayout } @internal class AttachmentReferenceStencilLayout { @@ -188,15 +188,22 @@ Thefore there is no need to repeat the KHR structs ref!AttachmentReferenceStencilLayout StencilLayout } +@internal class SubpassDescriptionDepthStencilResolve { + VkResolveModeFlagBits DepthResolveMode + VkResolveModeFlagBits StencilResolveMode + AttachmentReference DepthStencilResolveAttachment +} + @internal class SubpassDescription { - VkSubpassDescriptionFlags Flags - u32 ViewMask - VkPipelineBindPoint PipelineBindPoint - map!(u32, AttachmentReference) InputAttachments - map!(u32, AttachmentReference) ColorAttachments - map!(u32, AttachmentReference) ResolveAttachments - ref!AttachmentReference DepthStencilAttachment - map!(u32, u32) PreserveAttachments + VkSubpassDescriptionFlags Flags + u32 ViewMask + VkPipelineBindPoint PipelineBindPoint + map!(u32, AttachmentReference) InputAttachments + map!(u32, AttachmentReference) ColorAttachments + map!(u32, AttachmentReference) ResolveAttachments + ref!AttachmentReference DepthStencilAttachment + map!(u32, u32) PreserveAttachments + ref!SubpassDescriptionDepthStencilResolve DepthStencilResolve } @internal class SubpassDependency { @@ -319,6 +326,26 @@ sub SubpassDescription createSubpassDescriptionObjectFrom2(VkSubpassDescription2 PipelineBindPoint: subpassDescription2.pipelineBindPoint, ) + if subpassDescription2.pNext != null { + numPNext := numberOfPNext(subpassDescription2.pNext) + next := MutableVoidPtr(as!void*(subpassDescription2.pNext)) + for j in (0 .. numPNext) { + sType := as!const VkStructureType*(next.Ptr)[0] + switch sType { + case VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE: { + ext := as!VkSubpassDescriptionDepthStencilResolve*(next.Ptr)[0] + internalSubpassDescription.DepthStencilResolve = new!SubpassDescriptionDepthStencilResolve( + DepthResolveMode: ext.depthResolveMode, + StencilResolveMode: ext.stencilResolveMode, + ) + attachmentReference2 := ext.pDepthStencilResolveAttachment[0] + internalSubpassDescription.DepthStencilResolve.DepthStencilResolveAttachment = + createAttachmentReferenceObjectFrom2(attachmentReference2) + } + } + } + } + inputAttachments := subpassDescription2.pInputAttachments[0:subpassDescription2.inputAttachmentCount] for j in (0 .. subpassDescription2.inputAttachmentCount) { attachmentReference2 := inputAttachments[j] diff --git a/gapis/api/vulkan/api/vk12structs.api b/gapis/api/vulkan/api/vk12structs.api index 7b175aaf2..90c9db7ea 100644 --- a/gapis/api/vulkan/api/vk12structs.api +++ b/gapis/api/vulkan/api/vk12structs.api @@ -235,3 +235,28 @@ class VkRenderPassAttachmentBeginInfo { u32 attachmentCount const VkImageView* pAttachments } + +class VkPhysicalDeviceDepthStencilResolveProperties { + VkStructureType sType + void* pNext + VkResolveModeFlags supportedDepthResolveModes + VkResolveModeFlags supportedStencilResolveModes + VkBool32 independentResolveNone + VkBool32 independentResolve +} + +@internal +class PhysicalDeviceDepthStencilResolveProperties { + VkResolveModeFlags SupportedDepthResolveModes + VkResolveModeFlags SupportedStencilResolveModes + VkBool32 IndependentResolveNone + VkBool32 IndependentResolve +} + +class VkSubpassDescriptionDepthStencilResolve { + VkStructureType sType + const void* pNext + VkResolveModeFlagBits depthResolveMode + VkResolveModeFlagBits stencilResolveMode + const VkAttachmentReference2* pDepthStencilResolveAttachment +} diff --git a/gapis/api/vulkan/extensions/khr_depth_stencil_resolve.api b/gapis/api/vulkan/extensions/khr_depth_stencil_resolve.api new file mode 100644 index 000000000..bb195f04d --- /dev/null +++ b/gapis/api/vulkan/extensions/khr_depth_stencil_resolve.api @@ -0,0 +1,45 @@ +// Copyright (C) 2022 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Based off of the original vulkan.h header file which has the following +// license. + +// Copyright (c) 2015 The Khronos Group Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and/or associated documentation files (the +// "Materials"), to deal in the Materials without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Materials, and to +// permit persons to whom the Materials are furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Materials. +// +// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. + +/////////////// +// Constants // +/////////////// + +@extension("VK_KHR_depth_stencil_resolve") define VK_KHR_DEPTH_STENCIL_RESOLVE_SPEC_VERSION 1 +@extension("VK_KHR_depth_stencil_resolve") define VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME "VK_KHR_depth_stencil_resolve" + diff --git a/gapis/api/vulkan/state_rebuilder.go b/gapis/api/vulkan/state_rebuilder.go index 9520e461f..c1d71688f 100644 --- a/gapis/api/vulkan/state_rebuilder.go +++ b/gapis/api/vulkan/state_rebuilder.go @@ -2441,6 +2441,42 @@ func (sb *stateBuilder) createRenderPass2(rp RenderPassObjectʳ) { subpassDescriptions := []VkSubpassDescription2{} for _, k := range rp.SubpassDescriptions().Keys() { sd := rp.SubpassDescriptions().Get(k) + sdPnext := NewVoidᶜᵖ(memory.Nullptr) + + if !sd.DepthStencilResolve().IsNil() { + depthStencilResolve := sd.DepthStencilResolve().Get() + arPnext := NewVoidᶜᵖ(memory.Nullptr) + if !depthStencilResolve.DepthStencilResolveAttachment().StencilLayout().IsNil() { + slPnext := NewVoidᶜᵖ(memory.Nullptr) + arPnext = NewVoidᶜᵖ(sb.MustAllocReadData( + NewVkAttachmentReferenceStencilLayout( + VkStructureType_VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT, + NewVoidᵖ(slPnext), + depthStencilResolve.DepthStencilResolveAttachment().StencilLayout().StencilLayout(), + ), + ).Ptr()) + } + + dsrAttachmentRef := NewVkAttachmentReference2ᶜᵖ(sb.MustAllocReadData( + NewVkAttachmentReference2( + VkStructureType_VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2, + arPnext, + depthStencilResolve.DepthStencilResolveAttachment().Attachment(), + depthStencilResolve.DepthStencilResolveAttachment().Layout(), + depthStencilResolve.DepthStencilResolveAttachment().AspectMask(), + ), + ).Ptr()) + + sdPnext = NewVoidᶜᵖ(sb.MustAllocReadData( + NewVkSubpassDescriptionDepthStencilResolve( + VkStructureType_VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE, + NewVoidᶜᵖ(memory.Nullptr), + depthStencilResolve.DepthResolveMode(), + depthStencilResolve.StencilResolveMode(), + dsrAttachmentRef, + ), + ).Ptr()) + } depthStencil := NewVkAttachmentReference2ᶜᵖ(memory.Nullptr) if !sd.DepthStencilAttachment().IsNil() { @@ -2529,7 +2565,7 @@ func (sb *stateBuilder) createRenderPass2(rp RenderPassObjectʳ) { subpassDescriptions = append(subpassDescriptions, NewVkSubpassDescription2( VkStructureType_VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2, - NewVoidᶜᵖ(memory.Nullptr), + sdPnext, sd.Flags(), // flags sd.PipelineBindPoint(), // pipelineBindPoint sd.ViewMask(), // viewMask diff --git a/gapis/api/vulkan/vulkan.api b/gapis/api/vulkan/vulkan.api index cd348445e..6311cf967 100644 --- a/gapis/api/vulkan/vulkan.api +++ b/gapis/api/vulkan/vulkan.api @@ -317,6 +317,7 @@ sub ref!ExtensionSet supportedDeviceExtensions() { supported.ExtensionNames["VK_QCOM_render_pass_store_ops"] = true supported.ExtensionNames["VK_EXT_load_store_op_none"] = true supported.ExtensionNames["VK_KHR_imageless_framebuffer"] = true + supported.ExtensionNames["VK_KHR_depth_stencil_resolve"] = true return supported }