As shown at https://vulkan-tutorial.com/code/23_texture_image.cpp:
Calling createGraphicsPipeline()
to recreate the Pipeline when changing the window size, the dimensions are set in the code below.
VkViewport viewport = {};
viewport.x = 0.0f;
viewport.y = 0.0f;
viewport.width = (float) swapChainExtent.width;
viewport.height = (float) swapChainExtent.height;
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
VkRect2D scissor = {};
scissor.offset = {0, 0};
scissor.extent = swapChainExtent;
VkPipelineViewportStateCreateInfo viewportState = {};
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewportState.viewportCount = 1;
viewportState.pViewports = &viewport;
viewportState.scissorCount = 1;
viewportState.pScissors = &scissor;
If the scene contains lots of materials, changing the window size will recreate all materials, which is very time consuming. Can I modify their VkRect2D
and VkViewport
directly without recreate the pipeline?