Merge branch 'master' into libktx

This commit is contained in:
Sascha Willems 2019-09-06 19:20:35 +02:00
commit d33fc23e0b
10 changed files with 30 additions and 21 deletions

View file

@ -63,7 +63,7 @@ task copyTask {
copy {
from '../../../data/textures'
into 'assets/textures'
include 'rocks_normal_height_rgba.dds'
include 'rocks_normal_height_rgba.ktx'
}
copy {

View file

@ -250,7 +250,7 @@ void VulkanExampleBase::renderFrame()
timer -= 1.0f;
}
}
float fpsTimer = std::chrono::duration<double, std::milli>(tEnd - lastTimestamp).count();
float fpsTimer = (float)(std::chrono::duration<double, std::milli>(tEnd - lastTimestamp).count());
if (fpsTimer > 1000.0f)
{
lastFPS = static_cast<uint32_t>((float)frameCounter * (1000.0f / fpsTimer));
@ -621,26 +621,26 @@ void VulkanExampleBase::drawUI(const VkCommandBuffer commandBuffer)
void VulkanExampleBase::prepareFrame()
{
// Acquire the next image from the swap chain
VkResult err = swapChain.acquireNextImage(semaphores.presentComplete, &currentBuffer);
VkResult result = swapChain.acquireNextImage(semaphores.presentComplete, &currentBuffer);
// Recreate the swapchain if it's no longer compatible with the surface (OUT_OF_DATE) or no longer optimal for presentation (SUBOPTIMAL)
if ((err == VK_ERROR_OUT_OF_DATE_KHR) || (err == VK_SUBOPTIMAL_KHR)) {
if ((result == VK_ERROR_OUT_OF_DATE_KHR) || (result == VK_SUBOPTIMAL_KHR)) {
windowResize();
}
else {
VK_CHECK_RESULT(err);
VK_CHECK_RESULT(result);
}
}
void VulkanExampleBase::submitFrame()
{
VkResult res = swapChain.queuePresent(queue, currentBuffer, semaphores.renderComplete);
if (!((res == VK_SUCCESS) || (res == VK_SUBOPTIMAL_KHR))) {
if (res == VK_ERROR_OUT_OF_DATE_KHR) {
VkResult result = swapChain.queuePresent(queue, currentBuffer, semaphores.renderComplete);
if (!((result == VK_SUCCESS) || (result == VK_SUBOPTIMAL_KHR))) {
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
// Swap chain is no longer compatible with the surface and needs to be recreated
windowResize();
return;
} else {
VK_CHECK_RESULT(res);
VK_CHECK_RESULT(result);
}
}
VK_CHECK_RESULT(vkQueueWaitIdle(queue));

Binary file not shown.

View file

@ -577,13 +577,17 @@ public:
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.MSAA));
// MSAA with sample shading pipeline
// Sample shading enables per-sample shading to avoid shader aliasing and smooth out e.g. high frequency texture maps
// Note: This will trade performance for are more stable image
multisampleState.sampleShadingEnable = VK_TRUE; // Enable per-sample shading (instead of per-fragment)
multisampleState.minSampleShading = 0.25f; // Minimum fraction for sample shading
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.MSAASampleShading));
if (vulkanDevice->features.sampleRateShading)
{
// MSAA with sample shading pipeline
// Sample shading enables per-sample shading to avoid shader aliasing and smooth out e.g. high frequency texture maps
// Note: This will trade performance for are more stable image
multisampleState.sampleShadingEnable = VK_TRUE; // Enable per-sample shading (instead of per-fragment)
multisampleState.minSampleShading = 0.25f; // Minimum fraction for sample shading
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.MSAASampleShading));
}
}
// Prepare and initialize uniform buffer containing shader uniforms

View file

@ -121,9 +121,9 @@ public:
models.quad.loadFromFile(getAssetPath() + "models/plane_z.obj", vertexLayout, 0.1f, vulkanDevice, queue);
// Textures
textures.normalHeightMap.loadFromFile(getAssetPath() + "textures/rocks_normal_height_rgba.dds", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
textures.normalHeightMap.loadFromFile(getAssetPath() + "textures/rocks_normal_height_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
if (vulkanDevice->features.textureCompressionBC) {
textures.colorMap.loadFromFile(getAssetPath() + "textures/rocks_color_bc3_unorm.dds", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
textures.colorMap.loadFromFile(getAssetPath() + "textures/rocks_color_bc3_unorm.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
}
else if (vulkanDevice->features.textureCompressionASTC_LDR) {
textures.colorMap.loadFromFile(getAssetPath() + "textures/rocks_color_astc_8x8_unorm.ktx", VK_FORMAT_ASTC_8x8_UNORM_BLOCK, vulkanDevice, queue);

View file

@ -374,9 +374,14 @@ public:
samplerCreateInfo.minLod = 0.0f;
// Both particle textures have the same number of mip maps
samplerCreateInfo.maxLod = float(textures.particles.fire.mipLevels);
// Enable anisotropic filtering
samplerCreateInfo.maxAnisotropy = 8.0f;
samplerCreateInfo.anisotropyEnable = VK_TRUE;
if (vulkanDevice->features.samplerAnisotropy)
{
// Enable anisotropic filtering
samplerCreateInfo.maxAnisotropy = 8.0f;
samplerCreateInfo.anisotropyEnable = VK_TRUE;
}
// Use a different border color (than the normal texture loader) for additive blending
samplerCreateInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
VK_CHECK_RESULT(vkCreateSampler(device, &samplerCreateInfo, nullptr, &textures.particles.sampler));