Introduce structure constructors using ArrayProxyNoTemporaries
This commit is contained in:
@@ -77,7 +77,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
{ { vk::DescriptorType::eUniformBuffer, 1, vk::ShaderStageFlagBits::eVertex },
|
||||
{ vk::DescriptorType::eCombinedImageSampler, 1, vk::ShaderStageFlagBits::eFragment } } );
|
||||
vk::UniquePipelineLayout pipelineLayout = device->createPipelineLayoutUnique(
|
||||
vk::PipelineLayoutCreateInfo( vk::PipelineLayoutCreateFlags(), 1, &descriptorSetLayout.get() ) );
|
||||
vk::PipelineLayoutCreateInfo( vk::PipelineLayoutCreateFlags(), *descriptorSetLayout ) );
|
||||
|
||||
vk::UniqueRenderPass renderPass = vk::su::createRenderPass(
|
||||
device,
|
||||
@@ -129,21 +129,19 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::UniqueDescriptorPool descriptorPool = vk::su::createDescriptorPool(
|
||||
device, { { vk::DescriptorType::eUniformBuffer, 2 }, { vk::DescriptorType::eCombinedImageSampler, 2 } } );
|
||||
|
||||
vk::DescriptorSetLayout layouts[] = { descriptorSetLayout.get(), descriptorSetLayout.get() };
|
||||
std::vector<vk::UniqueDescriptorSet> descriptorSets =
|
||||
device->allocateDescriptorSetsUnique( vk::DescriptorSetAllocateInfo( descriptorPool.get(), 2, layouts ) );
|
||||
std::array<vk::DescriptorSetLayout, 2> layouts = { descriptorSetLayout.get(), descriptorSetLayout.get() };
|
||||
std::vector<vk::UniqueDescriptorSet> descriptorSets =
|
||||
device->allocateDescriptorSetsUnique( vk::DescriptorSetAllocateInfo( descriptorPool.get(), layouts ) );
|
||||
assert( descriptorSets.size() == 2 );
|
||||
|
||||
vk::su::updateDescriptorSets(
|
||||
device,
|
||||
descriptorSets[0],
|
||||
{ { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } },
|
||||
greenTextureData );
|
||||
vk::su::updateDescriptorSets(
|
||||
device,
|
||||
descriptorSets[1],
|
||||
{ { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } },
|
||||
checkeredTextureData );
|
||||
vk::su::updateDescriptorSets( device,
|
||||
descriptorSets[0],
|
||||
{ { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } },
|
||||
greenTextureData );
|
||||
vk::su::updateDescriptorSets( device,
|
||||
descriptorSets[1],
|
||||
{ { vk::DescriptorType::eUniformBuffer, uniformBufferData.buffer, {} } },
|
||||
checkeredTextureData );
|
||||
|
||||
/* VULKAN_KEY_START */
|
||||
|
||||
@@ -191,14 +189,13 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
secondaryCommandBuffers[i]->end();
|
||||
}
|
||||
|
||||
vk::ClearValue clearValues[2];
|
||||
std::array<vk::ClearValue, 2> clearValues;
|
||||
clearValues[0].color = vk::ClearColorValue( std::array<float, 4>( { { 0.2f, 0.2f, 0.2f, 0.2f } } ) );
|
||||
clearValues[1].depthStencil = vk::ClearDepthStencilValue( 1.0f, 0 );
|
||||
|
||||
vk::RenderPassBeginInfo renderPassBeginInfo( renderPass.get(),
|
||||
framebuffers[currentBuffer.value].get(),
|
||||
vk::Rect2D( vk::Offset2D( 0, 0 ), surfaceData.extent ),
|
||||
2,
|
||||
clearValues );
|
||||
// specifying VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS means this render pass may ONLY call
|
||||
// vkCmdExecuteCommands
|
||||
@@ -226,14 +223,13 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
vk::UniqueFence drawFence = device->createFenceUnique( vk::FenceCreateInfo() );
|
||||
|
||||
vk::PipelineStageFlags waitDestinationStageMask( vk::PipelineStageFlagBits::eColorAttachmentOutput );
|
||||
vk::SubmitInfo submitInfo( 1, &imageAcquiredSemaphore.get(), &waitDestinationStageMask, 1, &commandBuffer.get() );
|
||||
vk::SubmitInfo submitInfo( *imageAcquiredSemaphore, waitDestinationStageMask, *commandBuffer );
|
||||
graphicsQueue.submit( submitInfo, drawFence.get() );
|
||||
|
||||
while ( vk::Result::eTimeout == device->waitForFences( drawFence.get(), VK_TRUE, vk::su::FenceTimeout ) )
|
||||
;
|
||||
|
||||
presentQueue.presentKHR(
|
||||
vk::PresentInfoKHR( 0, nullptr, 1, &swapChainData.swapChain.get(), ¤tBuffer.value ) );
|
||||
presentQueue.presentKHR( vk::PresentInfoKHR( {}, *swapChainData.swapChain, currentBuffer.value ) );
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 1000 ) );
|
||||
|
||||
/* VULKAN_KEY_END */
|
||||
@@ -245,9 +241,9 @@ int main( int /*argc*/, char ** /*argv*/ )
|
||||
std::cout << "vk::SystemError: " << err.what() << std::endl;
|
||||
exit( -1 );
|
||||
}
|
||||
catch ( std::runtime_error & err )
|
||||
catch ( std::exception & err )
|
||||
{
|
||||
std::cout << "std::runtime_error: " << err.what() << std::endl;
|
||||
std::cout << "std::exception: " << err.what() << std::endl;
|
||||
exit( -1 );
|
||||
}
|
||||
catch ( ... )
|
||||
|
||||
Reference in New Issue
Block a user