当前位置: 首页>>代码示例>>C++>>正文


C++ VkLayerDispatchTable::BindBufferMemory方法代码示例

本文整理汇总了C++中VkLayerDispatchTable::BindBufferMemory方法的典型用法代码示例。如果您正苦于以下问题:C++ VkLayerDispatchTable::BindBufferMemory方法的具体用法?C++ VkLayerDispatchTable::BindBufferMemory怎么用?C++ VkLayerDispatchTable::BindBufferMemory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VkLayerDispatchTable的用法示例。


在下文中一共展示了VkLayerDispatchTable::BindBufferMemory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: vkGetSwapchainImagesKHR


//.........这里部分代码省略.........
            ivci.format = data->format;
            ivci.components.r = VK_COMPONENT_SWIZZLE_R;
            ivci.components.g = VK_COMPONENT_SWIZZLE_G;
            ivci.components.b = VK_COMPONENT_SWIZZLE_B;
            ivci.components.a = VK_COMPONENT_SWIZZLE_A;
            ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
            ivci.subresourceRange.baseMipLevel = 0;
            ivci.subresourceRange.levelCount = 1;
            ivci.subresourceRange.baseArrayLayer = 0;
            ivci.subresourceRange.layerCount = 1;
            ivci.image = pImages[i];
            ivci.flags = 0;

            VkImageView v;
            pTable->CreateImageView(device, &ivci, nullptr, &v);

            /* Create framebuffer for each */
            VkFramebufferCreateInfo fci;
            fci.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
            fci.pNext = nullptr;
            fci.flags = 0;
            fci.renderPass = data->render_pass;
            fci.attachmentCount = 1;
            fci.pAttachments = &v;
            fci.width = data->width;
            fci.height = data->height;
            fci.layers = 1;

            VkFramebuffer fb;
            pTable->CreateFramebuffer(device, &fci, nullptr, &fb);

            /* Create command buffer for each */
            VkCommandBufferAllocateInfo cbai;
            cbai.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
            cbai.pNext = nullptr;
            cbai.commandPool = my_data->pool;
            cbai.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
            cbai.commandBufferCount = 1;

            VkCommandBuffer cmd;
            pTable->AllocateCommandBuffers(device, &cbai, &cmd);

            /* We have just created a dispatchable object, but the dispatch
             * table has not been placed in the object yet.
             * When a "normal" application creates a command buffer,
             * the dispatch table is installed by the top-level binding
             * (trampoline.c).
             * But here, we have to do it ourselves. */

            if (!my_data->pfn_dev_init) {
                *((const void **)cmd) = *(void **)device;
            } else {
                err = my_data->pfn_dev_init(device, (void *)cmd);
                assert(!err);
            }

            /* Create vertex buffer */
            VkBufferCreateInfo bci;
            memset(&bci, 0, sizeof(bci));
            bci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
            bci.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
            bci.size = sizeof(vertex) * MAX_TEXT_VERTICES;

            VkBuffer buf;
            err = pTable->CreateBuffer(device, &bci, nullptr, &buf);
            assert(!err);

            VkMemoryRequirements mem_reqs;
            pTable->GetBufferMemoryRequirements(device, buf, &mem_reqs);
            assert(!err);

            VkMemoryAllocateInfo mem_alloc;
            memset(&mem_alloc, 0, sizeof(mem_alloc));
            mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
            mem_alloc.allocationSize = mem_reqs.size;
            mem_alloc.memoryTypeIndex = choose_memory_type(
                my_data->gpu, mem_reqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);

            VkDeviceMemory mem;
            err = pTable->AllocateMemory(device, &mem_alloc, nullptr, &mem);
            assert(!err);

            err = pTable->BindBufferMemory(device, buf, mem, 0);
            assert(!err);

            auto imageData = new WsiImageData;
            imageData->image = pImages[i];
            imageData->view = v;
            imageData->framebuffer = fb;
            imageData->cmd = cmd;
            imageData->vertexBuffer = buf;
            imageData->vertexBufferMemory = mem;
            imageData->numVertices = 0;
            imageData->vertexBufferSize = mem_alloc.allocationSize;

            data->presentableImages.push_back(imageData);
        }
    }
    return result;
}
开发者ID:LunarG,项目名称:VulkanSamples,代码行数:101,代码来源:overlay.cpp


注:本文中的VkLayerDispatchTable::BindBufferMemory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。