powerpoint presentation · // uniforms: vkcmdbinddescriptorsets(commandbuffer,...

35

Upload: others

Post on 12-Jun-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 2: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 3: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 4: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 5: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 6: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

vkDeviceWaitIdle();

vkDestroySwapchainKHR();

vkCreateSwapchainKHR();

for () {vkDestroyImageView();vkDestroyFramebuffer();

}for () {vkCreateImageView();vkCreateFramebuffer();

}

Page 7: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

// Create imageimageCreateInfo.samples = VK_SAMPLE_COUNT_4_BIT;

// Create render targetrenderPassCreateInfo.attachmentDescription.samples = VK_SAMPLE_COUNT_4_BIT;

// Pipeline creationpipelineMultisampleStateCreateInfo.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT;

// Have to resolve at some pointvkCmdResolveImage();

// Or viasubpassDescription.pResolveAttachments = ...;

// Sample shadingpipelineMultisampleStateCreateInfo.sampleShadingEnable = VK_TRUE;pipelineMultisampleStateCreateInfo.minSampleShading = 0.0f - 1.0f;

Page 8: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

samplerCreateInfo.anisotropyEnable = VK_TRUE;

samplerCreateInfo.maxAnisotropy = 1.0f – 16.0f;

Page 9: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 10: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 11: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 12: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

Page 13: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 14: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 15: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 16: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

Page 17: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

Page 18: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

0,0

10,0

20,0

30,0

40,0

50,0

60,0

70,0

80,0

Nexus 5X Galaxy S7 Google Pixel XL

OpenGL ES 3 Vulkan

Page 19: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

vkDeviceWaitIdle() vkQueueWaitIdle()

VK_IMAGE_TILING_OPTIMAL

VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT

Page 20: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

// 1. SetupvkCreateQueryPool(...);

// 2. At beginning of command buffervkCmdResetQueryPool(commadBuffer, queryPool, firstQuery, 2);vkCmdWriteTimestamp(commadBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, queryPool, query);

// 3. At end of command buffervkCmdWriteTimestamp(commadBuffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, queryPool, query + 1);

// 4. Get resultsuint64_t timestamps[2];res = vkGetQueryPoolResults(device, queryPool, firstQuery, 2,

sizeof(uint64_t) * 2, timestamps, sizeof(uint64_t), VK_QUERY_RESULT_64_BIT);// in msfloat timeInMs = (timestamps[1] - timestamps[0])/ 1000.0f;

Page 21: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

// Uniforms:vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset);

struct DescriptorSetCacheEntry{

VkDescriptorSet set;uint32_t lastFrameUsed;

};

HashMap<Hasher::Value, DescriptorSetCacheEntry> descriptorSetCache_;

// If found in cache:vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &textureSet, 0, nullptr);

// If not found in cache:vkAllocateDescriptorSets(device, &allocateInfo, &textureSet);vkUpdateDescriptorSets(device, writeCount, writeTextures, 0, nullptr);vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &textureSet, 0, nullptr);

Page 22: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

// Enable extension on vkCreateDevice()VK_NV_DEDICATED_ALLOCATION_EXTENSION_NAME

// Use it for an allocationVkDedicatedAllocationMemoryAllocateInfoNV dedicatedInfo = {};dedicatedInfo.sType = VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV;dedicatedInfo.pNext = nullptr;dedicatedInfo.image = image;dedicatedInfo.buffer = VK_NULL_HANDLE;

VkMemoryAllocateInfo allocateInfo = {};allocateInfo.pNext = &dedicatedInfo;

Page 23: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 24: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 25: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 26: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 27: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 28: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 29: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 30: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 31: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

×1000

60≈

Page 32: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry

Page 33: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry
Page 34: PowerPoint Presentation · // Uniforms: vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, layout, firstSet, 1, &uniformSet, 1, &dynamicOffset); struct DescriptorSetCacheEntry