本文整理汇总了C++中VkLayerDispatchTable::CreateRenderPass方法的典型用法代码示例。如果您正苦于以下问题:C++ VkLayerDispatchTable::CreateRenderPass方法的具体用法?C++ VkLayerDispatchTable::CreateRenderPass怎么用?C++ VkLayerDispatchTable::CreateRenderPass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VkLayerDispatchTable
的用法示例。
在下文中一共展示了VkLayerDispatchTable::CreateRenderPass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vkCreateSwapchainKHR
VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkSwapchainKHR *pSwapChain) {
layer_data *my_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
VkLayerDispatchTable *pTable = my_data->device_dispatch_table;
VkResult result = my_data->pfnCreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapChain);
if (result == VK_SUCCESS) {
auto &data = (*my_data->swapChains)[*pSwapChain];
data = new SwapChainData;
data->width = pCreateInfo->imageExtent.width;
data->height = pCreateInfo->imageExtent.height;
data->format = pCreateInfo->imageFormat;
#ifdef OVERLAY_DEBUG
printf(
"Creating resources for scribbling on swapchain format %u width "
"%u height %u\n",
data->format, data->width, data->height);
#endif
/* Create a renderpass for drawing into this swapchain */
VkAttachmentDescription ad;
ad.flags = 0;
ad.format = data->format;
ad.samples = VK_SAMPLE_COUNT_1_BIT;
ad.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
ad.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
ad.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
ad.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
/* TODO: deal with the image possibly being in a different
* layout - we need to care about general,
* VK_IMAGE_LAYOUT_PRESENT_SOURCE_WSI,
* etc etc
*/
ad.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
ad.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
VkAttachmentReference ar;
ar.attachment = 0;
/* TODO: see previous layout comment */
ar.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkAttachmentReference dr;
dr.attachment = VK_ATTACHMENT_UNUSED;
dr.layout = VK_IMAGE_LAYOUT_UNDEFINED;
VkSubpassDescription sd;
sd.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
sd.flags = 0;
sd.inputAttachmentCount = 0;
sd.pInputAttachments = nullptr;
sd.colorAttachmentCount = 1;
sd.pColorAttachments = &ar;
sd.pResolveAttachments = nullptr;
sd.pDepthStencilAttachment = &dr;
/* TODO: do we need to mark the color attachment here? */
sd.preserveAttachmentCount = 0;
sd.pPreserveAttachments = nullptr;
VkRenderPassCreateInfo rpci;
rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
rpci.pNext = nullptr;
rpci.flags = 0;
rpci.attachmentCount = 1;
rpci.pAttachments = &ad;
rpci.subpassCount = 1;
rpci.pSubpasses = &sd;
rpci.dependencyCount = 0;
rpci.pDependencies = nullptr;
pTable->CreateRenderPass(device, &rpci, nullptr, &data->render_pass);
/* Create the pipeline to use in this renderpass */
VkPipelineShaderStageCreateInfo stages[2];
stages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
stages[0].pNext = nullptr;
stages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
stages[0].module = my_data->vsShaderModule;
stages[0].pName = "main";
stages[0].flags = 0;
stages[0].pSpecializationInfo = nullptr;
stages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
stages[1].pNext = nullptr;
stages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
stages[1].module = my_data->fsShaderModule;
stages[1].pName = "main";
stages[1].flags = 0;
stages[1].pSpecializationInfo = nullptr;
VkPipelineInputAssemblyStateCreateInfo piasci;
memset(&piasci, 0, sizeof(piasci));
piasci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
piasci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
VkViewport viewport;
memset(&viewport, 0, sizeof(viewport));
viewport.width = (float)data->width;
viewport.height = (float)data->height;
//.........这里部分代码省略.........