commit
27d5abc038
27 changed files with 58 additions and 230 deletions
|
|
@ -294,23 +294,6 @@ namespace vks
|
||||||
exitFatal(message, (int32_t)resultCode);
|
exitFatal(message, (int32_t)resultCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string readTextFile(const char *fileName)
|
|
||||||
{
|
|
||||||
std::string fileContent;
|
|
||||||
std::ifstream fileStream(fileName, std::ios::in);
|
|
||||||
if (!fileStream.is_open()) {
|
|
||||||
printf("File %s not found\n", fileName);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
std::string line = "";
|
|
||||||
while (!fileStream.eof()) {
|
|
||||||
getline(fileStream, line);
|
|
||||||
fileContent.append(line + "\n");
|
|
||||||
}
|
|
||||||
fileStream.close();
|
|
||||||
return fileContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
// Android shaders are stored as assets in the apk
|
// Android shaders are stored as assets in the apk
|
||||||
// So they need to be loaded via the asset manager
|
// So they need to be loaded via the asset manager
|
||||||
|
|
|
||||||
|
|
@ -110,18 +110,6 @@ std::string VulkanExampleBase::getWindowTitle()
|
||||||
return windowTitle;
|
return windowTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VulkanExampleBase::checkCommandBuffers()
|
|
||||||
{
|
|
||||||
for (auto& cmdBuffer : drawCmdBuffers)
|
|
||||||
{
|
|
||||||
if (cmdBuffer == VK_NULL_HANDLE)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VulkanExampleBase::createCommandBuffers()
|
void VulkanExampleBase::createCommandBuffers()
|
||||||
{
|
{
|
||||||
// Create one command buffer for each swap chain image and reuse for rendering
|
// Create one command buffer for each swap chain image and reuse for rendering
|
||||||
|
|
@ -141,51 +129,6 @@ void VulkanExampleBase::destroyCommandBuffers()
|
||||||
vkFreeCommandBuffers(device, cmdPool, static_cast<uint32_t>(drawCmdBuffers.size()), drawCmdBuffers.data());
|
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()
|
void VulkanExampleBase::createPipelineCache()
|
||||||
{
|
{
|
||||||
VkPipelineCacheCreateInfo pipelineCacheCreateInfo = {};
|
VkPipelineCacheCreateInfo pipelineCacheCreateInfo = {};
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,8 @@ private:
|
||||||
void createSynchronizationPrimitives();
|
void createSynchronizationPrimitives();
|
||||||
void initSwapchain();
|
void initSwapchain();
|
||||||
void setupSwapChain();
|
void setupSwapChain();
|
||||||
|
void createCommandBuffers();
|
||||||
|
void destroyCommandBuffers();
|
||||||
protected:
|
protected:
|
||||||
// Frame counter to display fps
|
// Frame counter to display fps
|
||||||
uint32_t frameCounter = 0;
|
uint32_t frameCounter = 0;
|
||||||
|
|
@ -332,18 +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 */
|
/** @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();
|
virtual void getEnabledFeatures();
|
||||||
|
|
||||||
/** @brief Checks if command buffers are valid (!= VK_NULL_HANDLE) */
|
|
||||||
bool checkCommandBuffers();
|
|
||||||
/** @brief Creates the per-frame command buffers */
|
|
||||||
void createCommandBuffers();
|
|
||||||
/** @brief Destroy all command buffers and set their handles to VK_NULL_HANDLE */
|
|
||||||
void destroyCommandBuffers();
|
|
||||||
|
|
||||||
/** @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 */
|
/** @brief Prepares all Vulkan resources and functions required to run the sample */
|
||||||
virtual void prepare();
|
virtual void prepare();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -231,13 +231,6 @@ public:
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
// Destroy command buffers if already present
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
||||||
VkClearValue clearValues[2];
|
VkClearValue clearValues[2];
|
||||||
|
|
@ -417,7 +410,7 @@ public:
|
||||||
storageBufferSize);
|
storageBufferSize);
|
||||||
|
|
||||||
// Copy from staging buffer
|
// 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 = {};
|
VkBufferCopy copyRegion = {};
|
||||||
copyRegion.size = storageBufferSize;
|
copyRegion.size = storageBufferSize;
|
||||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffers.input.buffer, 1, ©Region);
|
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffers.input.buffer, 1, ©Region);
|
||||||
|
|
@ -426,7 +419,7 @@ public:
|
||||||
// so that when the compute command buffer executes for the first time
|
// 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"
|
// it doesn't complain about a lack of a corresponding "release" to its "acquire"
|
||||||
addGraphicsToComputeBarriers(copyCmd);
|
addGraphicsToComputeBarriers(copyCmd);
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
stagingBuffer.destroy();
|
stagingBuffer.destroy();
|
||||||
|
|
||||||
|
|
@ -457,11 +450,11 @@ public:
|
||||||
indexBufferSize);
|
indexBufferSize);
|
||||||
|
|
||||||
// Copy from staging buffer
|
// Copy from staging buffer
|
||||||
copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
copyCmd = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||||
copyRegion = {};
|
copyRegion = {};
|
||||||
copyRegion.size = indexBufferSize;
|
copyRegion.size = indexBufferSize;
|
||||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, graphics.indices.buffer, 1, ©Region);
|
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, graphics.indices.buffer, 1, ©Region);
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
stagingBuffer.destroy();
|
stagingBuffer.destroy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,13 +135,6 @@ public:
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
// Destroy command buffers if already present
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
||||||
VkClearValue clearValues[2];
|
VkClearValue clearValues[2];
|
||||||
|
|
@ -416,7 +409,7 @@ public:
|
||||||
storageBufferSize);
|
storageBufferSize);
|
||||||
|
|
||||||
// Copy from staging buffer to storage buffer
|
// 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 = {};
|
VkBufferCopy copyRegion = {};
|
||||||
copyRegion.size = storageBufferSize;
|
copyRegion.size = storageBufferSize;
|
||||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffer.buffer, 1, ©Region);
|
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffer.buffer, 1, ©Region);
|
||||||
|
|
@ -445,7 +438,7 @@ public:
|
||||||
1, &buffer_barrier,
|
1, &buffer_barrier,
|
||||||
0, nullptr);
|
0, nullptr);
|
||||||
}
|
}
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
stagingBuffer.destroy();
|
stagingBuffer.destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -327,7 +327,7 @@ public:
|
||||||
storageBufferSize);
|
storageBufferSize);
|
||||||
|
|
||||||
// Copy from staging buffer to storage buffer
|
// 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 = {};
|
VkBufferCopy copyRegion = {};
|
||||||
copyRegion.size = storageBufferSize;
|
copyRegion.size = storageBufferSize;
|
||||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffer.buffer, 1, ©Region);
|
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffer.buffer, 1, ©Region);
|
||||||
|
|
@ -356,7 +356,7 @@ public:
|
||||||
1, &buffer_barrier,
|
1, &buffer_barrier,
|
||||||
0, nullptr);
|
0, nullptr);
|
||||||
}
|
}
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
stagingBuffer.destroy();
|
stagingBuffer.destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ public:
|
||||||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &tex->deviceMemory));
|
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &tex->deviceMemory));
|
||||||
VK_CHECK_RESULT(vkBindImageMemory(device, tex->image, tex->deviceMemory, 0));
|
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;
|
tex->imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
vks::tools::setImageLayout(
|
vks::tools::setImageLayout(
|
||||||
|
|
@ -172,7 +172,7 @@ public:
|
||||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
tex->imageLayout);
|
tex->imageLayout);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||||
|
|
||||||
// Create sampler
|
// Create sampler
|
||||||
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
||||||
|
|
@ -208,13 +208,6 @@ public:
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
// Destroy command buffers if already present
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
||||||
VkClearValue clearValues[2];
|
VkClearValue clearValues[2];
|
||||||
|
|
@ -344,11 +337,11 @@ public:
|
||||||
storageBufferSize);
|
storageBufferSize);
|
||||||
|
|
||||||
// Copy to staging buffer
|
// 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 = {};
|
VkBufferCopy copyRegion = {};
|
||||||
copyRegion.size = storageBufferSize;
|
copyRegion.size = storageBufferSize;
|
||||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffers.spheres.buffer, 1, ©Region);
|
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffers.spheres.buffer, 1, ©Region);
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
stagingBuffer.destroy();
|
stagingBuffer.destroy();
|
||||||
|
|
||||||
|
|
@ -379,10 +372,10 @@ public:
|
||||||
storageBufferSize);
|
storageBufferSize);
|
||||||
|
|
||||||
// Copy to staging buffer
|
// 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;
|
copyRegion.size = storageBufferSize;
|
||||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffers.planes.buffer, 1, ©Region);
|
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.storageBuffers.planes.buffer, 1, ©Region);
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
stagingBuffer.destroy();
|
stagingBuffer.destroy();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ public:
|
||||||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &tex->deviceMemory));
|
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &tex->deviceMemory));
|
||||||
VK_CHECK_RESULT(vkBindImageMemory(device, tex->image, tex->deviceMemory, 0));
|
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;
|
tex->imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
vks::tools::setImageLayout(
|
vks::tools::setImageLayout(
|
||||||
|
|
@ -161,7 +161,7 @@ public:
|
||||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
tex->imageLayout);
|
tex->imageLayout);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||||
|
|
||||||
// Create sampler
|
// Create sampler
|
||||||
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
||||||
|
|
@ -203,13 +203,6 @@ public:
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
// Destroy command buffers if already present
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
||||||
VkClearValue clearValues[2];
|
VkClearValue clearValues[2];
|
||||||
|
|
|
||||||
|
|
@ -438,7 +438,7 @@ public:
|
||||||
{
|
{
|
||||||
if (offScreenCmdBuffer == VK_NULL_HANDLE)
|
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
|
// Create a semaphore used to synchronize offscreen rendering and usage
|
||||||
|
|
@ -529,16 +529,6 @@ public:
|
||||||
textures.floor.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor01_normal" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue);
|
textures.floor.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor01_normal" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reBuildCommandBuffers()
|
|
||||||
{
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
buildCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
|
||||||
|
|
@ -450,7 +450,7 @@ public:
|
||||||
void buildDeferredCommandBuffer()
|
void buildDeferredCommandBuffer()
|
||||||
{
|
{
|
||||||
if (offScreenCmdBuffer == VK_NULL_HANDLE) {
|
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
|
// Create a semaphore used to synchronize offscreen rendering and usage
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ public:
|
||||||
{
|
{
|
||||||
if (commandBuffers.deferred == VK_NULL_HANDLE)
|
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
|
// Create a semaphore used to synchronize offscreen rendering and usage
|
||||||
|
|
@ -467,16 +467,6 @@ public:
|
||||||
textures.background.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor02_normal" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue);
|
textures.background.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor02_normal" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reBuildCommandBuffers()
|
|
||||||
{
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
buildCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
|
||||||
|
|
@ -201,16 +201,6 @@ public:
|
||||||
textures.fontBitmap.loadFromFile(getAssetPath() + "textures/font_bitmap_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
|
textures.fontBitmap.loadFromFile(getAssetPath() + "textures/font_bitmap_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reBuildCommandBuffers()
|
|
||||||
{
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
buildCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
|
||||||
|
|
@ -107,16 +107,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reBuildCommandBuffers()
|
|
||||||
{
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
buildCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
|
||||||
|
|
@ -520,7 +520,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
vks::tools::exitFatal("Could not open the glTF file\n\nThe file is part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
|
vks::tools::exitFatal("Could not open the glTF file.\n\nThe file is part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -569,7 +569,7 @@ public:
|
||||||
&glTFModel.indices.memory));
|
&glTFModel.indices.memory));
|
||||||
|
|
||||||
// Copy data from staging buffers (host) do device local buffer (gpu)
|
// 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 = {};
|
VkBufferCopy copyRegion = {};
|
||||||
|
|
||||||
copyRegion.size = vertexBufferSize;
|
copyRegion.size = vertexBufferSize;
|
||||||
|
|
@ -588,7 +588,7 @@ public:
|
||||||
1,
|
1,
|
||||||
©Region);
|
©Region);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
// Free staging resources
|
// Free staging resources
|
||||||
vkDestroyBuffer(device, vertexStaging.buffer, nullptr);
|
vkDestroyBuffer(device, vertexStaging.buffer, nullptr);
|
||||||
|
|
|
||||||
|
|
@ -504,7 +504,7 @@ public:
|
||||||
&instanceBuffer.memory));
|
&instanceBuffer.memory));
|
||||||
|
|
||||||
// Copy to staging buffer
|
// 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 = { };
|
VkBufferCopy copyRegion = { };
|
||||||
copyRegion.size = instanceBuffer.size;
|
copyRegion.size = instanceBuffer.size;
|
||||||
|
|
@ -515,7 +515,7 @@ public:
|
||||||
1,
|
1,
|
||||||
©Region);
|
©Region);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
instanceBuffer.descriptor.range = instanceBuffer.size;
|
instanceBuffer.descriptor.range = instanceBuffer.size;
|
||||||
instanceBuffer.descriptor.buffer = instanceBuffer.buffer;
|
instanceBuffer.descriptor.buffer = instanceBuffer.buffer;
|
||||||
|
|
|
||||||
|
|
@ -778,14 +778,14 @@ public:
|
||||||
fbufCreateInfo.layers = 1;
|
fbufCreateInfo.layers = 1;
|
||||||
VK_CHECK_RESULT(vkCreateFramebuffer(device, &fbufCreateInfo, nullptr, &offscreen.framebuffer));
|
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(
|
vks::tools::setImageLayout(
|
||||||
layoutCmd,
|
layoutCmd,
|
||||||
offscreen.image,
|
offscreen.image,
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Descriptors
|
// Descriptors
|
||||||
|
|
@ -1173,14 +1173,14 @@ public:
|
||||||
fbufCreateInfo.layers = 1;
|
fbufCreateInfo.layers = 1;
|
||||||
VK_CHECK_RESULT(vkCreateFramebuffer(device, &fbufCreateInfo, nullptr, &offscreen.framebuffer));
|
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(
|
vks::tools::setImageLayout(
|
||||||
layoutCmd,
|
layoutCmd,
|
||||||
offscreen.image,
|
offscreen.image,
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Descriptors
|
// Descriptors
|
||||||
|
|
|
||||||
|
|
@ -719,14 +719,14 @@ public:
|
||||||
fbufCreateInfo.layers = 1;
|
fbufCreateInfo.layers = 1;
|
||||||
VK_CHECK_RESULT(vkCreateFramebuffer(device, &fbufCreateInfo, nullptr, &offscreen.framebuffer));
|
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(
|
vks::tools::setImageLayout(
|
||||||
layoutCmd,
|
layoutCmd,
|
||||||
offscreen.image,
|
offscreen.image,
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Descriptors
|
// Descriptors
|
||||||
|
|
@ -1114,14 +1114,14 @@ public:
|
||||||
fbufCreateInfo.layers = 1;
|
fbufCreateInfo.layers = 1;
|
||||||
VK_CHECK_RESULT(vkCreateFramebuffer(device, &fbufCreateInfo, nullptr, &offscreen.framebuffer));
|
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(
|
vks::tools::setImageLayout(
|
||||||
layoutCmd,
|
layoutCmd,
|
||||||
offscreen.image,
|
offscreen.image,
|
||||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Descriptors
|
// Descriptors
|
||||||
|
|
|
||||||
|
|
@ -91,16 +91,6 @@ public:
|
||||||
uniformBuffer.destroy();
|
uniformBuffer.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reBuildCommandBuffers()
|
|
||||||
{
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
buildCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
@ -457,7 +447,7 @@ public:
|
||||||
draw();
|
draw();
|
||||||
if (!paused)
|
if (!paused)
|
||||||
{
|
{
|
||||||
reBuildCommandBuffers();
|
buildCommandBuffers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -822,7 +822,7 @@ public:
|
||||||
|
|
||||||
void loadScene()
|
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);
|
scene = new Scene(vulkanDevice, queue);
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ public:
|
||||||
VkMemoryAllocateInfo memAllocInfo = vks::initializers::memoryAllocateInfo();
|
VkMemoryAllocateInfo memAllocInfo = vks::initializers::memoryAllocateInfo();
|
||||||
VkMemoryRequirements memReqs;
|
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
|
// Create cube map image
|
||||||
VK_CHECK_RESULT(vkCreateImage(device, &imageCreateInfo, nullptr, &shadowCubeMap.image));
|
VK_CHECK_RESULT(vkCreateImage(device, &imageCreateInfo, nullptr, &shadowCubeMap.image));
|
||||||
|
|
@ -220,7 +220,7 @@ public:
|
||||||
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
||||||
subresourceRange);
|
subresourceRange);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||||
|
|
||||||
// Create sampler
|
// Create sampler
|
||||||
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
||||||
|
|
@ -298,7 +298,7 @@ public:
|
||||||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAlloc, nullptr, &offscreenPass.color.mem));
|
VK_CHECK_RESULT(vkAllocateMemory(device, &memAlloc, nullptr, &offscreenPass.color.mem));
|
||||||
VK_CHECK_RESULT(vkBindImageMemory(device, offscreenPass.color.image, offscreenPass.color.mem, 0));
|
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(
|
vks::tools::setImageLayout(
|
||||||
layoutCmd,
|
layoutCmd,
|
||||||
|
|
@ -339,7 +339,7 @@ public:
|
||||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(layoutCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(layoutCmd, queue, true);
|
||||||
|
|
||||||
depthStencilView.image = offscreenPass.depth.image;
|
depthStencilView.image = offscreenPass.depth.image;
|
||||||
VK_CHECK_RESULT(vkCreateImageView(device, &depthStencilView, nullptr, &offscreenPass.depth.view));
|
VK_CHECK_RESULT(vkCreateImageView(device, &depthStencilView, nullptr, &offscreenPass.depth.view));
|
||||||
|
|
|
||||||
|
|
@ -636,7 +636,7 @@ public:
|
||||||
indexBufferSize));
|
indexBufferSize));
|
||||||
|
|
||||||
// Copy from staging buffers
|
// 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 = {};
|
VkBufferCopy copyRegion = {};
|
||||||
|
|
||||||
|
|
@ -656,7 +656,7 @@ public:
|
||||||
1,
|
1,
|
||||||
©Region);
|
©Region);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
vkDestroyBuffer(device, vertexStaging.buffer, nullptr);
|
vkDestroyBuffer(device, vertexStaging.buffer, nullptr);
|
||||||
vkFreeMemory(device, vertexStaging.memory, nullptr);
|
vkFreeMemory(device, vertexStaging.memory, nullptr);
|
||||||
|
|
|
||||||
|
|
@ -305,16 +305,6 @@ public:
|
||||||
textures.terrainArray.descriptor.sampler = textures.terrainArray.sampler;
|
textures.terrainArray.descriptor.sampler = textures.terrainArray.sampler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reBuildCommandBuffers()
|
|
||||||
{
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
buildCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
@ -562,7 +552,7 @@ public:
|
||||||
&models.terrain.indices.memory));
|
&models.terrain.indices.memory));
|
||||||
|
|
||||||
// Copy from staging buffers
|
// 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 = {};
|
VkBufferCopy copyRegion = {};
|
||||||
|
|
||||||
|
|
@ -582,7 +572,7 @@ public:
|
||||||
1,
|
1,
|
||||||
©Region);
|
©Region);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
models.terrain.device = device;
|
models.terrain.device = device;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ public:
|
||||||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &texture.deviceMemory));
|
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &texture.deviceMemory));
|
||||||
VK_CHECK_RESULT(vkBindImageMemory(device, texture.image, texture.deviceMemory, 0));
|
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
|
// Image memory barriers for the texture image
|
||||||
|
|
||||||
|
|
@ -321,7 +321,7 @@ public:
|
||||||
// Store current layout for later reuse
|
// Store current layout for later reuse
|
||||||
texture.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
texture.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
// Clean up staging resources
|
// Clean up staging resources
|
||||||
vkFreeMemory(device, stagingMemory, nullptr);
|
vkFreeMemory(device, stagingMemory, nullptr);
|
||||||
|
|
@ -368,7 +368,7 @@ public:
|
||||||
texture.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
texture.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
|
|
||||||
// Setup image memory barrier transfer image to shader read layout
|
// 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
|
// The sub resource range describes the regions of the image we will be transition
|
||||||
VkImageSubresourceRange subresourceRange = {};
|
VkImageSubresourceRange subresourceRange = {};
|
||||||
|
|
@ -398,7 +398,7 @@ public:
|
||||||
0, nullptr,
|
0, nullptr,
|
||||||
1, &imageMemoryBarrier);
|
1, &imageMemoryBarrier);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ktxTexture_Destroy(ktxTexture);
|
ktxTexture_Destroy(ktxTexture);
|
||||||
|
|
|
||||||
|
|
@ -381,7 +381,7 @@ public:
|
||||||
memcpy(mapped, data, texMemSize);
|
memcpy(mapped, data, texMemSize);
|
||||||
vkUnmapMemory(device, stagingMemory);
|
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
|
// The sub resource range describes the regions of the image we will be transitioned
|
||||||
VkImageSubresourceRange subresourceRange = {};
|
VkImageSubresourceRange subresourceRange = {};
|
||||||
|
|
@ -428,7 +428,7 @@ public:
|
||||||
texture.imageLayout,
|
texture.imageLayout,
|
||||||
subresourceRange);
|
subresourceRange);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
// Clean up staging resources
|
// Clean up staging resources
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ public:
|
||||||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &textureArray.deviceMemory));
|
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &textureArray.deviceMemory));
|
||||||
VK_CHECK_RESULT(vkBindImageMemory(device, textureArray.image, textureArray.deviceMemory, 0));
|
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)
|
// Image barrier for optimal image (target)
|
||||||
// Set initial layout for all array layers (faces) of the optimal (target) tiled texture
|
// Set initial layout for all array layers (faces) of the optimal (target) tiled texture
|
||||||
|
|
@ -252,7 +252,7 @@ public:
|
||||||
textureArray.imageLayout,
|
textureArray.imageLayout,
|
||||||
subresourceRange);
|
subresourceRange);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
// Create sampler
|
// Create sampler
|
||||||
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ public:
|
||||||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &cubeMap.deviceMemory));
|
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &cubeMap.deviceMemory));
|
||||||
VK_CHECK_RESULT(vkBindImageMemory(device, cubeMap.image, cubeMap.deviceMemory, 0));
|
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
|
// Setup buffer copy regions for each face including all of its miplevels
|
||||||
std::vector<VkBufferImageCopy> bufferCopyRegions;
|
std::vector<VkBufferImageCopy> bufferCopyRegions;
|
||||||
|
|
@ -276,7 +276,7 @@ public:
|
||||||
cubeMap.imageLayout,
|
cubeMap.imageLayout,
|
||||||
subresourceRange);
|
subresourceRange);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
// Create sampler
|
// Create sampler
|
||||||
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
VkSamplerCreateInfo sampler = vks::initializers::samplerCreateInfo();
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ public:
|
||||||
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &texture.deviceMemory));
|
VK_CHECK_RESULT(vkAllocateMemory(device, &memAllocInfo, nullptr, &texture.deviceMemory));
|
||||||
VK_CHECK_RESULT(vkBindImageMemory(device, texture.image, texture.deviceMemory, 0));
|
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 = {};
|
VkImageSubresourceRange subresourceRange = {};
|
||||||
subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
|
@ -247,7 +247,7 @@ public:
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
subresourceRange);
|
subresourceRange);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(copyCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||||
|
|
||||||
// Clean up staging resources
|
// Clean up staging resources
|
||||||
vkFreeMemory(device, stagingMemory, nullptr);
|
vkFreeMemory(device, stagingMemory, nullptr);
|
||||||
|
|
@ -258,7 +258,7 @@ public:
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// We copy down the whole mip chain doing a blit from mip-1 to mip
|
// 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
|
// 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
|
// Copy down mips from n-1 to n
|
||||||
for (int32_t i = 1; i < texture.mipLevels; i++)
|
for (int32_t i = 1; i < texture.mipLevels; i++)
|
||||||
|
|
@ -336,7 +336,7 @@ public:
|
||||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
subresourceRange);
|
subresourceRange);
|
||||||
|
|
||||||
VulkanExampleBase::flushCommandBuffer(blitCmd, queue, true);
|
vulkanDevice->flushCommandBuffer(blitCmd, queue, true);
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
// Create samplers
|
// Create samplers
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue