Code cleanup
This commit is contained in:
parent
4b9f10d644
commit
53846d8b1d
23 changed files with 54 additions and 104 deletions
|
|
@ -129,51 +129,6 @@ void VulkanExampleBase::destroyCommandBuffers()
|
|||
vkFreeCommandBuffers(device, cmdPool, static_cast<uint32_t>(drawCmdBuffers.size()), drawCmdBuffers.data());
|
||||
}
|
||||
|
||||
VkCommandBuffer VulkanExampleBase::createCommandBuffer(VkCommandBufferLevel level, bool begin)
|
||||
{
|
||||
VkCommandBuffer cmdBuffer;
|
||||
|
||||
VkCommandBufferAllocateInfo cmdBufAllocateInfo =
|
||||
vks::initializers::commandBufferAllocateInfo(
|
||||
cmdPool,
|
||||
level,
|
||||
1);
|
||||
|
||||
VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, &cmdBuffer));
|
||||
|
||||
// If requested, also start the new command buffer
|
||||
if (begin)
|
||||
{
|
||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||
VK_CHECK_RESULT(vkBeginCommandBuffer(cmdBuffer, &cmdBufInfo));
|
||||
}
|
||||
|
||||
return cmdBuffer;
|
||||
}
|
||||
|
||||
void VulkanExampleBase::flushCommandBuffer(VkCommandBuffer commandBuffer, VkQueue queue, bool free)
|
||||
{
|
||||
if (commandBuffer == VK_NULL_HANDLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VK_CHECK_RESULT(vkEndCommandBuffer(commandBuffer));
|
||||
|
||||
VkSubmitInfo submitInfo = {};
|
||||
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||
submitInfo.commandBufferCount = 1;
|
||||
submitInfo.pCommandBuffers = &commandBuffer;
|
||||
|
||||
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
|
||||
VK_CHECK_RESULT(vkQueueWaitIdle(queue));
|
||||
|
||||
if (free)
|
||||
{
|
||||
vkFreeCommandBuffers(device, cmdPool, 1, &commandBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanExampleBase::createPipelineCache()
|
||||
{
|
||||
VkPipelineCacheCreateInfo pipelineCacheCreateInfo = {};
|
||||
|
|
|
|||
|
|
@ -334,11 +334,6 @@ public:
|
|||
/** @brief (Virtual) Called after the physical device features have been read, can be used to set features to enable on the device */
|
||||
virtual void getEnabledFeatures();
|
||||
|
||||
/** @brief Creates and returns a new command buffer */
|
||||
VkCommandBuffer createCommandBuffer(VkCommandBufferLevel level, bool begin);
|
||||
/** @brief End the command buffer, submit it to the queue and free (if requested) */
|
||||
void flushCommandBuffer(VkCommandBuffer commandBuffer, VkQueue queue, bool free);
|
||||
|
||||
/** @brief Prepares all Vulkan resources and functions required to run the sample */
|
||||
virtual void prepare();
|
||||
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ public:
|
|||
storageBufferSize);
|
||||
|
||||
// Copy from staging buffer
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkBufferCopy copyRegion = {};
|
||||
copyRegion.size = storageBufferSize;
|
||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffers.input.buffer, 1, ©Region);
|
||||
|
|
@ -419,7 +419,7 @@ public:
|
|||
// so that when the compute command buffer executes for the first time
|
||||
// it doesn't complain about a lack of a corresponding "release" to its "acquire"
|
||||
addGraphicsToComputeBarriers(copyCmd);
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
stagingBuffer.destroy();
|
||||
|
||||
|
|
@ -450,11 +450,11 @@ public:
|
|||
indexBufferSize);
|
||||
|
||||
// Copy from staging buffer
|
||||
copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
copyRegion = {};
|
||||
copyRegion.size = indexBufferSize;
|
||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, graphics.indices.buffer, 1, ©Region);
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
stagingBuffer.destroy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ public:
|
|||
storageBufferSize);
|
||||
|
||||
// Copy from staging buffer to storage buffer
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkBufferCopy copyRegion = {};
|
||||
copyRegion.size = storageBufferSize;
|
||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffer.buffer, 1, ©Region);
|
||||
|
|
@ -438,7 +438,7 @@ public:
|
|||
1, &buffer_barrier,
|
||||
0, nullptr);
|
||||
}
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
stagingBuffer.destroy();
|
||||
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ public:
|
|||
storageBufferSize);
|
||||
|
||||
// Copy from staging buffer to storage buffer
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkBufferCopy copyRegion = {};
|
||||
copyRegion.size = storageBufferSize;
|
||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffer.buffer, 1, ©Region);
|
||||
|
|
@ -356,7 +356,7 @@ public:
|
|||
1, &buffer_barrier,
|
||||
0, nullptr);
|
||||
}
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
stagingBuffer.destroy();
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ public:
|
|||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &tex->deviceMemory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(device, tex->image, tex->deviceMemory, 0));
|
||||
|
||||
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer layoutCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
tex->imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
vks::tools::setImageLayout(
|
||||
|
|
@ -172,7 +172,7 @@ public:
|
|||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
tex->imageLayout);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||
|
||||
// Create sampler
|
||||
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
||||
|
|
@ -337,11 +337,11 @@ public:
|
|||
storageBufferSize);
|
||||
|
||||
// Copy to staging buffer
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkBufferCopy copyRegion = {};
|
||||
copyRegion.size = storageBufferSize;
|
||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffers.spheres.buffer, 1, ©Region);
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
stagingBuffer.destroy();
|
||||
|
||||
|
|
@ -372,10 +372,10 @@ public:
|
|||
storageBufferSize);
|
||||
|
||||
// Copy to staging buffer
|
||||
copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
copyRegion.size = storageBufferSize;
|
||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffers.planes.buffer, 1, ©Region);
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
stagingBuffer.destroy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ public:
|
|||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &tex->deviceMemory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(device, tex->image, tex->deviceMemory, 0));
|
||||
|
||||
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer layoutCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
tex->imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
vks::tools::setImageLayout(
|
||||
|
|
@ -161,7 +161,7 @@ public:
|
|||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
tex->imageLayout);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||
|
||||
// Create sampler
|
||||
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ public:
|
|||
{
|
||||
if (offScreenCmdBuffer == VK_NULL_HANDLE)
|
||||
{
|
||||
offScreenCmdBuffer = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
||||
offScreenCmdBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
||||
}
|
||||
|
||||
// Create a semaphore used to synchronize offscreen rendering and usage
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ public:
|
|||
void buildDeferredCommandBuffer()
|
||||
{
|
||||
if (offScreenCmdBuffer == VK_NULL_HANDLE) {
|
||||
offScreenCmdBuffer = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
||||
offScreenCmdBuffer = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
||||
}
|
||||
|
||||
// Create a semaphore used to synchronize offscreen rendering and usage
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ public:
|
|||
{
|
||||
if (commandBuffers.deferred == VK_NULL_HANDLE)
|
||||
{
|
||||
commandBuffers.deferred = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
||||
commandBuffers.deferred = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
||||
}
|
||||
|
||||
// Create a semaphore used to synchronize offscreen rendering and usage
|
||||
|
|
|
|||
|
|
@ -569,7 +569,7 @@ public:
|
|||
&glTFModel.indices.memory));
|
||||
|
||||
// Copy data from staging buffers (host) do device local buffer (gpu)
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkBufferCopy copyRegion = {};
|
||||
|
||||
copyRegion.size = vertexBufferSize;
|
||||
|
|
@ -588,7 +588,7 @@ public:
|
|||
1,
|
||||
©Region);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
// Free staging resources
|
||||
vkDestroyBuffer(device, vertexStaging.buffer, nullptr);
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ public:
|
|||
&instanceBuffer.memory));
|
||||
|
||||
// Copy to staging buffer
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
VkBufferCopy copyRegion = { };
|
||||
copyRegion.size = instanceBuffer.size;
|
||||
|
|
@ -515,7 +515,7 @@ public:
|
|||
1,
|
||||
©Region);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
instanceBuffer.descriptor.range = instanceBuffer.size;
|
||||
instanceBuffer.descriptor.buffer = instanceBuffer.buffer;
|
||||
|
|
|
|||
|
|
@ -778,14 +778,14 @@ public:
|
|||
fbufCreateInfo.layers = 1;
|
||||
VK_CHECK_RESULT(vkCreateFramebuffer(device, &fbufCreateInfo, nullptr, &offscreen.framebuffer));
|
||||
|
||||
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer layoutCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
vks::tools::setImageLayout(
|
||||
layoutCmd,
|
||||
offscreen.image,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||
}
|
||||
|
||||
// Descriptors
|
||||
|
|
@ -1173,14 +1173,14 @@ public:
|
|||
fbufCreateInfo.layers = 1;
|
||||
VK_CHECK_RESULT(vkCreateFramebuffer(device, &fbufCreateInfo, nullptr, &offscreen.framebuffer));
|
||||
|
||||
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer layoutCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
vks::tools::setImageLayout(
|
||||
layoutCmd,
|
||||
offscreen.image,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||
}
|
||||
|
||||
// Descriptors
|
||||
|
|
|
|||
|
|
@ -719,14 +719,14 @@ public:
|
|||
fbufCreateInfo.layers = 1;
|
||||
VK_CHECK_RESULT(vkCreateFramebuffer(device, &fbufCreateInfo, nullptr, &offscreen.framebuffer));
|
||||
|
||||
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer layoutCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
vks::tools::setImageLayout(
|
||||
layoutCmd,
|
||||
offscreen.image,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||
}
|
||||
|
||||
// Descriptors
|
||||
|
|
@ -1114,14 +1114,14 @@ public:
|
|||
fbufCreateInfo.layers = 1;
|
||||
VK_CHECK_RESULT(vkCreateFramebuffer(device, &fbufCreateInfo, nullptr, &offscreen.framebuffer));
|
||||
|
||||
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer layoutCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
vks::tools::setImageLayout(
|
||||
layoutCmd,
|
||||
offscreen.image,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||
}
|
||||
|
||||
// Descriptors
|
||||
|
|
|
|||
|
|
@ -822,7 +822,7 @@ public:
|
|||
|
||||
void loadScene()
|
||||
{
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
||||
scene = new Scene(vulkanDevice, queue);
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public:
|
|||
VkMemoryAllocateInfo memAllocInfo = vks::initializers::memoryAllocateInfo();
|
||||
VkMemoryRequirements memReqs;
|
||||
|
||||
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer layoutCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
// Create cube map image
|
||||
VK_CHECK_RESULT(vkCreateImage(device, &imageCreateInfo, nullptr, &shadowCubeMap.image));
|
||||
|
|
@ -220,7 +220,7 @@ public:
|
|||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||
subresourceRange);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||
|
||||
// Create sampler
|
||||
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
||||
|
|
@ -298,7 +298,7 @@ public:
|
|||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAlloc, nullptr, &offscreenPass.color.mem));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(device, offscreenPass.color.image, offscreenPass.color.mem, 0));
|
||||
|
||||
VkCommandBuffer layoutCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer layoutCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
vks::tools::setImageLayout(
|
||||
layoutCmd,
|
||||
|
|
@ -339,7 +339,7 @@ public:
|
|||
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||
|
||||
depthStencilView.image = offscreenPass.depth.image;
|
||||
VK_CHECK_RESULT(vkCreateImageView(device, &depthStencilView, nullptr, &offscreenPass.depth.view));
|
||||
|
|
|
|||
|
|
@ -636,7 +636,7 @@ public:
|
|||
indexBufferSize));
|
||||
|
||||
// Copy from staging buffers
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
VkBufferCopy copyRegion = {};
|
||||
|
||||
|
|
@ -656,7 +656,7 @@ public:
|
|||
1,
|
||||
©Region);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
vkDestroyBuffer(device, vertexStaging.buffer, nullptr);
|
||||
vkFreeMemory(device, vertexStaging.memory, nullptr);
|
||||
|
|
|
|||
|
|
@ -552,7 +552,7 @@ public:
|
|||
&models.terrain.indices.memory));
|
||||
|
||||
// Copy from staging buffers
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
VkBufferCopy copyRegion = {};
|
||||
|
||||
|
|
@ -572,7 +572,7 @@ public:
|
|||
1,
|
||||
©Region);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
models.terrain.device = device;
|
||||
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ public:
|
|||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &texture.deviceMemory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(device, texture.image, texture.deviceMemory, 0));
|
||||
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
// Image memory barriers for the texture image
|
||||
|
||||
|
|
@ -321,7 +321,7 @@ public:
|
|||
// Store current layout for later reuse
|
||||
texture.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
// Clean up staging resources
|
||||
vkFreeMemory(device, stagingMemory, nullptr);
|
||||
|
|
@ -368,7 +368,7 @@ public:
|
|||
texture.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
|
||||
// Setup image memory barrier transfer image to shader read layout
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
// The sub resource range describes the regions of the image we will be transition
|
||||
VkImageSubresourceRange subresourceRange = {};
|
||||
|
|
@ -398,7 +398,7 @@ public:
|
|||
0, nullptr,
|
||||
1, &imageMemoryBarrier);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
}
|
||||
|
||||
ktxTexture_Destroy(ktxTexture);
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ public:
|
|||
memcpy(mapped, data, texMemSize);
|
||||
vkUnmapMemory(device, stagingMemory);
|
||||
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
// The sub resource range describes the regions of the image we will be transitioned
|
||||
VkImageSubresourceRange subresourceRange = {};
|
||||
|
|
@ -428,7 +428,7 @@ public:
|
|||
texture.imageLayout,
|
||||
subresourceRange);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
// Clean up staging resources
|
||||
delete[] data;
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ public:
|
|||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &textureArray.deviceMemory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(device, textureArray.image, textureArray.deviceMemory, 0));
|
||||
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
// Image barrier for optimal image (target)
|
||||
// Set initial layout for all array layers (faces) of the optimal (target) tiled texture
|
||||
|
|
@ -252,7 +252,7 @@ public:
|
|||
textureArray.imageLayout,
|
||||
subresourceRange);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
// Create sampler
|
||||
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ public:
|
|||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &cubeMap.deviceMemory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(device, cubeMap.image, cubeMap.deviceMemory, 0));
|
||||
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
// Setup buffer copy regions for each face including all of its miplevels
|
||||
std::vector<VkBufferImageCopy> bufferCopyRegions;
|
||||
|
|
@ -276,7 +276,7 @@ public:
|
|||
cubeMap.imageLayout,
|
||||
subresourceRange);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
// Create sampler
|
||||
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ public:
|
|||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &texture.deviceMemory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(device, texture.image, texture.deviceMemory, 0));
|
||||
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
VkImageSubresourceRange subresourceRange = {};
|
||||
subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
|
|
@ -247,7 +247,7 @@ public:
|
|||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
subresourceRange);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
// Clean up staging resources
|
||||
vkFreeMemory(device, stagingMemory, nullptr);
|
||||
|
|
@ -258,7 +258,7 @@ public:
|
|||
// ---------------------------------------------------------------
|
||||
// We copy down the whole mip chain doing a blit from mip-1 to mip
|
||||
// An alternative way would be to always blit from the first mip level and sample that one down
|
||||
VkCommandBuffer blitCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer blitCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
||||
// Copy down mips from n-1 to n
|
||||
for (int32_t i = 1; i < texture.mipLevels; i++)
|
||||
|
|
@ -336,7 +336,7 @@ public:
|
|||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||
subresourceRange);
|
||||
|
||||
VulkanExampleBase::flushCommandBuffer(blitCmd, queue, true);
|
||||
vulkanDevice->flushCommandBuffer(blitCmd, queue, true);
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
// Create samplers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue