本文整理汇总了C++中VkLayerDispatchTable::CreateCommandPool方法的典型用法代码示例。如果您正苦于以下问题:C++ VkLayerDispatchTable::CreateCommandPool方法的具体用法?C++ VkLayerDispatchTable::CreateCommandPool怎么用?C++ VkLayerDispatchTable::CreateCommandPool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VkLayerDispatchTable
的用法示例。
在下文中一共展示了VkLayerDispatchTable::CreateCommandPool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateCommandPool
VKAPI_ATTR VkResult VKAPI_CALL CreateCommandPool(
VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool) {
DeviceMapStruct *devMap = get_dev_info(device);
assert(devMap);
VkLayerDispatchTable *pDisp = devMap->device_dispatch_table;
VkResult result =
pDisp->CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool);
// Save the command pool on a map if we are taking screenshots.
loader_platform_thread_lock_mutex(&globalLock);
if (screenshotEnvQueried && screenshotFrames.empty()) {
// No screenshots in the list to take
loader_platform_thread_unlock_mutex(&globalLock);
return result;
}
// Create a mapping from a device to a commandPool
devMap->commandPool = *pCommandPool;
loader_platform_thread_unlock_mutex(&globalLock);
return result;
}
示例2: after_device_create
static void after_device_create(VkPhysicalDevice gpu, VkDevice device, layer_data *data) {
VkResult U_ASSERT_ONLY err;
data->gpu = gpu;
data->dev = device;
data->frame = 0;
data->cmdBuffersThisFrame = 0;
VkLayerDispatchTable *pTable = data->device_dispatch_table;
/* Get our WSI hooks in. */
data->pfnCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)pTable->GetDeviceProcAddr(device, "vkCreateSwapchainKHR");
data->pfnGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)pTable->GetDeviceProcAddr(device, "vkGetSwapchainImagesKHR");
data->pfnQueuePresentKHR = (PFN_vkQueuePresentKHR)pTable->GetDeviceProcAddr(device, "vkQueuePresentKHR");
data->pfnDestroySwapchainKHR = (PFN_vkDestroySwapchainKHR)pTable->GetDeviceProcAddr(device, "vkDestroySwapchainKHR");
data->swapChains = new std::unordered_map<VkSwapchainKHR, SwapChainData *>;
/* Command pool */
VkCommandPoolCreateInfo cpci;
cpci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
cpci.pNext = nullptr;
cpci.queueFamilyIndex = data->graphicsQueueFamilyIndex;
cpci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
err = pTable->CreateCommandPool(device, &cpci, nullptr, &data->pool);
assert(!err);
/* Create the objects we need */
/* Compile the shaders */
compile_shader(device, VULKAN_SAMPLES_BASE_DIR "/Layer-Samples/data/overlay-vert.spv", &data->vsShaderModule);
compile_shader(device, VULKAN_SAMPLES_BASE_DIR "/Layer-Samples/data/overlay-frag.spv", &data->fsShaderModule);
/* Upload the font bitmap */
VkImageCreateInfo ici;
memset(&ici, 0, sizeof(ici));
ici.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
ici.imageType = VK_IMAGE_TYPE_2D;
ici.format = VK_FORMAT_R8_UNORM;
ici.extent.width = FONT_ATLAS_SIZE;
ici.extent.height = FONT_ATLAS_SIZE;
ici.extent.depth = 1;
ici.mipLevels = 1;
ici.arrayLayers = 1;
ici.samples = VK_SAMPLE_COUNT_1_BIT;
ici.tiling = VK_IMAGE_TILING_LINEAR;
ici.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
ici.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
err = pTable->CreateImage(device, &ici, nullptr, &data->fontGlyphsImage);
assert(!err);
VkMemoryRequirements mem_reqs;
pTable->GetImageMemoryRequirements(device, data->fontGlyphsImage, &mem_reqs);
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(gpu, mem_reqs.memoryTypeBits,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
err = pTable->AllocateMemory(device, &mem_alloc, nullptr, &data->fontGlyphsMemory);
assert(!err);
err = pTable->BindImageMemory(device, data->fontGlyphsImage, data->fontGlyphsMemory, 0);
assert(!err);
VkImageSubresource subres;
subres.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
subres.mipLevel = 0;
subres.arrayLayer = 0;
VkSubresourceLayout layout;
void *bits;
pTable->GetImageSubresourceLayout(device, data->fontGlyphsImage, &subres, &layout);
/* ensure we can directly upload into this layout */
assert(!layout.offset);
assert(layout.size >= FONT_ATLAS_SIZE * FONT_ATLAS_SIZE);
assert(layout.rowPitch == FONT_ATLAS_SIZE);
err = pTable->MapMemory(device, data->fontGlyphsMemory, 0, VK_WHOLE_SIZE, 0, &bits);
assert(!err);
/* Load the font glyphs directly into the mapped buffer */
std::vector<unsigned char> fontData;
get_file_contents(VULKAN_SAMPLES_BASE_DIR "/Layer-Samples/data/FreeSans.ttf", fontData);
stbtt_BakeFontBitmap(&fontData[0], 0, FONT_SIZE_PIXELS, (unsigned char *)bits, FONT_ATLAS_SIZE, FONT_ATLAS_SIZE, 32, 96,
data->glyphs);
pTable->UnmapMemory(device, data->fontGlyphsMemory);
VkImageViewCreateInfo ivci;
ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
ivci.viewType = VK_IMAGE_VIEW_TYPE_2D;
ivci.pNext = nullptr;
ivci.format = ici.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;
//.........这里部分代码省略.........