Code cleanup. fixes warnings
This commit is contained in:
parent
3a15ec4eb9
commit
ed4c4684c5
8 changed files with 28 additions and 41 deletions
|
|
@ -485,10 +485,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
VkDescriptorPoolCreateInfo descriptorPoolInfo =
|
VkDescriptorPoolCreateInfo descriptorPoolInfo =
|
||||||
vks::initializers::descriptorPoolCreateInfo(
|
vks::initializers::descriptorPoolCreateInfo(poolSizes, 3);
|
||||||
poolSizes.size(),
|
|
||||||
poolSizes.data(),
|
|
||||||
3);
|
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkCreateDescriptorPool(device, &descriptorPoolInfo, nullptr, &descriptorPool));
|
VK_CHECK_RESULT(vkCreateDescriptorPool(device, &descriptorPoolInfo, nullptr, &descriptorPool));
|
||||||
}
|
}
|
||||||
|
|
@ -539,7 +536,7 @@ public:
|
||||||
&textureComputeTarget.descriptor)
|
&textureComputeTarget.descriptor)
|
||||||
};
|
};
|
||||||
|
|
||||||
vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL);
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void preparePipelines()
|
void preparePipelines()
|
||||||
|
|
@ -586,10 +583,7 @@ public:
|
||||||
VK_DYNAMIC_STATE_SCISSOR
|
VK_DYNAMIC_STATE_SCISSOR
|
||||||
};
|
};
|
||||||
VkPipelineDynamicStateCreateInfo dynamicState =
|
VkPipelineDynamicStateCreateInfo dynamicState =
|
||||||
vks::initializers::pipelineDynamicStateCreateInfo(
|
vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables);
|
||||||
dynamicStateEnables.data(),
|
|
||||||
dynamicStateEnables.size(),
|
|
||||||
0);
|
|
||||||
|
|
||||||
// Display pipeline
|
// Display pipeline
|
||||||
std::array<VkPipelineShaderStageCreateInfo,2> shaderStages;
|
std::array<VkPipelineShaderStageCreateInfo,2> shaderStages;
|
||||||
|
|
@ -663,9 +657,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo descriptorLayout =
|
VkDescriptorSetLayoutCreateInfo descriptorLayout =
|
||||||
vks::initializers::descriptorSetLayoutCreateInfo(
|
vks::initializers::descriptorSetLayoutCreateInfo(setLayoutBindings);
|
||||||
setLayoutBindings.data(),
|
|
||||||
setLayoutBindings.size());
|
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &compute.descriptorSetLayout));
|
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &compute.descriptorSetLayout));
|
||||||
|
|
||||||
|
|
@ -712,7 +704,7 @@ public:
|
||||||
&compute.storageBuffers.planes.descriptor)
|
&compute.storageBuffers.planes.descriptor)
|
||||||
};
|
};
|
||||||
|
|
||||||
vkUpdateDescriptorSets(device, computeWriteDescriptorSets.size(), computeWriteDescriptorSets.data(), 0, NULL);
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(computeWriteDescriptorSets.size()), computeWriteDescriptorSets.data(), 0, nullptr);
|
||||||
|
|
||||||
// Create compute shader pipelines
|
// Create compute shader pipelines
|
||||||
VkComputePipelineCreateInfo computePipelineCreateInfo =
|
VkComputePipelineCreateInfo computePipelineCreateInfo =
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan Example - Compute shader image processing
|
* Vulkan Example - Compute shader image processing
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*/
|
*/
|
||||||
|
|
@ -174,7 +174,7 @@ public:
|
||||||
sampler.maxAnisotropy = 1.0f;
|
sampler.maxAnisotropy = 1.0f;
|
||||||
sampler.compareOp = VK_COMPARE_OP_NEVER;
|
sampler.compareOp = VK_COMPARE_OP_NEVER;
|
||||||
sampler.minLod = 0.0f;
|
sampler.minLod = 0.0f;
|
||||||
sampler.maxLod = tex->mipLevels;
|
sampler.maxLod = static_cast<float>(tex->mipLevels);
|
||||||
sampler.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
|
sampler.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
|
||||||
VK_CHECK_RESULT(vkCreateSampler(device, &sampler, nullptr, &tex->sampler));
|
VK_CHECK_RESULT(vkCreateSampler(device, &sampler, nullptr, &tex->sampler));
|
||||||
|
|
||||||
|
|
@ -347,9 +347,9 @@ public:
|
||||||
|
|
||||||
// Assign to vertex buffer
|
// Assign to vertex buffer
|
||||||
vertices.inputState = vks::initializers::pipelineVertexInputStateCreateInfo();
|
vertices.inputState = vks::initializers::pipelineVertexInputStateCreateInfo();
|
||||||
vertices.inputState.vertexBindingDescriptionCount = vertices.bindingDescriptions.size();
|
vertices.inputState.vertexBindingDescriptionCount = static_cast<uint32_t>(vertices.bindingDescriptions.size());
|
||||||
vertices.inputState.pVertexBindingDescriptions = vertices.bindingDescriptions.data();
|
vertices.inputState.pVertexBindingDescriptions = vertices.bindingDescriptions.data();
|
||||||
vertices.inputState.vertexAttributeDescriptionCount = vertices.attributeDescriptions.size();
|
vertices.inputState.vertexAttributeDescriptionCount = static_cast<uint32_t>(vertices.attributeDescriptions.size());
|
||||||
vertices.inputState.pVertexAttributeDescriptions = vertices.attributeDescriptions.data();
|
vertices.inputState.pVertexAttributeDescriptions = vertices.attributeDescriptions.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -394,7 +394,7 @@ public:
|
||||||
vks::initializers::writeDescriptorSet(graphics.descriptorSetPreCompute, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, &uniformBufferVS.descriptor),
|
vks::initializers::writeDescriptorSet(graphics.descriptorSetPreCompute, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, &uniformBufferVS.descriptor),
|
||||||
vks::initializers::writeDescriptorSet(graphics.descriptorSetPreCompute, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &textureColorMap.descriptor)
|
vks::initializers::writeDescriptorSet(graphics.descriptorSetPreCompute, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &textureColorMap.descriptor)
|
||||||
};
|
};
|
||||||
vkUpdateDescriptorSets(device, baseImageWriteDescriptorSets.size(), baseImageWriteDescriptorSets.data(), 0, nullptr);
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(baseImageWriteDescriptorSets.size()), baseImageWriteDescriptorSets.data(), 0, nullptr);
|
||||||
|
|
||||||
// Final image (after compute shader processing)
|
// Final image (after compute shader processing)
|
||||||
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &allocInfo, &graphics.descriptorSetPostCompute));
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &allocInfo, &graphics.descriptorSetPostCompute));
|
||||||
|
|
@ -402,7 +402,7 @@ public:
|
||||||
vks::initializers::writeDescriptorSet(graphics.descriptorSetPostCompute, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, &uniformBufferVS.descriptor),
|
vks::initializers::writeDescriptorSet(graphics.descriptorSetPostCompute, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, &uniformBufferVS.descriptor),
|
||||||
vks::initializers::writeDescriptorSet(graphics.descriptorSetPostCompute, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &textureComputeTarget.descriptor)
|
vks::initializers::writeDescriptorSet(graphics.descriptorSetPostCompute, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &textureComputeTarget.descriptor)
|
||||||
};
|
};
|
||||||
vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, nullptr);
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, nullptr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -450,10 +450,7 @@ public:
|
||||||
VK_DYNAMIC_STATE_SCISSOR
|
VK_DYNAMIC_STATE_SCISSOR
|
||||||
};
|
};
|
||||||
VkPipelineDynamicStateCreateInfo dynamicState =
|
VkPipelineDynamicStateCreateInfo dynamicState =
|
||||||
vks::initializers::pipelineDynamicStateCreateInfo(
|
vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables);
|
||||||
dynamicStateEnables.data(),
|
|
||||||
dynamicStateEnables.size(),
|
|
||||||
0);
|
|
||||||
|
|
||||||
// Rendering pipeline
|
// Rendering pipeline
|
||||||
// Load shaders
|
// Load shaders
|
||||||
|
|
@ -476,7 +473,7 @@ public:
|
||||||
pipelineCreateInfo.pViewportState = &viewportState;
|
pipelineCreateInfo.pViewportState = &viewportState;
|
||||||
pipelineCreateInfo.pDepthStencilState = &depthStencilState;
|
pipelineCreateInfo.pDepthStencilState = &depthStencilState;
|
||||||
pipelineCreateInfo.pDynamicState = &dynamicState;
|
pipelineCreateInfo.pDynamicState = &dynamicState;
|
||||||
pipelineCreateInfo.stageCount = shaderStages.size();
|
pipelineCreateInfo.stageCount = static_cast<uint32_t>(shaderStages.size());
|
||||||
pipelineCreateInfo.pStages = shaderStages.data();
|
pipelineCreateInfo.pStages = shaderStages.data();
|
||||||
pipelineCreateInfo.renderPass = renderPass;
|
pipelineCreateInfo.renderPass = renderPass;
|
||||||
|
|
||||||
|
|
@ -528,7 +525,7 @@ public:
|
||||||
vks::initializers::writeDescriptorSet(compute.descriptorSet, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 0, &textureColorMap.descriptor),
|
vks::initializers::writeDescriptorSet(compute.descriptorSet, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 0, &textureColorMap.descriptor),
|
||||||
vks::initializers::writeDescriptorSet(compute.descriptorSet, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, &textureComputeTarget.descriptor)
|
vks::initializers::writeDescriptorSet(compute.descriptorSet, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, &textureComputeTarget.descriptor)
|
||||||
};
|
};
|
||||||
vkUpdateDescriptorSets(device, computeWriteDescriptorSets.size(), computeWriteDescriptorSets.data(), 0, NULL);
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(computeWriteDescriptorSets.size()), computeWriteDescriptorSets.data(), 0, nullptr);
|
||||||
|
|
||||||
// Create compute shader pipelines
|
// Create compute shader pipelines
|
||||||
VkComputePipelineCreateInfo computePipelineCreateInfo =
|
VkComputePipelineCreateInfo computePipelineCreateInfo =
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ public:
|
||||||
&uniformBuffer.descriptor)
|
&uniformBuffer.descriptor)
|
||||||
};
|
};
|
||||||
|
|
||||||
vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL);
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void preparePipelines()
|
void preparePipelines()
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ public:
|
||||||
|
|
||||||
// Inner ring
|
// Inner ring
|
||||||
rho = sqrt((pow(ring0[1], 2.0f) - pow(ring0[0], 2.0f)) * uniformDist(rndGenerator) + pow(ring0[0], 2.0f));
|
rho = sqrt((pow(ring0[1], 2.0f) - pow(ring0[0], 2.0f)) * uniformDist(rndGenerator) + pow(ring0[0], 2.0f));
|
||||||
theta = 2.0f * M_PI * uniformDist(rndGenerator);
|
theta = static_cast<uint32_t>(2.0f * M_PI * uniformDist(rndGenerator));
|
||||||
instanceData[i].pos = glm::vec3(rho*cos(theta), uniformDist(rndGenerator) * 0.5f - 0.25f, rho*sin(theta));
|
instanceData[i].pos = glm::vec3(rho*cos(theta), uniformDist(rndGenerator) * 0.5f - 0.25f, rho*sin(theta));
|
||||||
instanceData[i].rot = glm::vec3(M_PI * uniformDist(rndGenerator), M_PI * uniformDist(rndGenerator), M_PI * uniformDist(rndGenerator));
|
instanceData[i].rot = glm::vec3(M_PI * uniformDist(rndGenerator), M_PI * uniformDist(rndGenerator), M_PI * uniformDist(rndGenerator));
|
||||||
instanceData[i].scale = 1.5f + uniformDist(rndGenerator) - uniformDist(rndGenerator);
|
instanceData[i].scale = 1.5f + uniformDist(rndGenerator) - uniformDist(rndGenerator);
|
||||||
|
|
@ -348,7 +348,7 @@ public:
|
||||||
|
|
||||||
// Outer ring
|
// Outer ring
|
||||||
rho = sqrt((pow(ring1[1], 2.0f) - pow(ring1[0], 2.0f)) * uniformDist(rndGenerator) + pow(ring1[0], 2.0f));
|
rho = sqrt((pow(ring1[1], 2.0f) - pow(ring1[0], 2.0f)) * uniformDist(rndGenerator) + pow(ring1[0], 2.0f));
|
||||||
theta = 2.0f * M_PI * uniformDist(rndGenerator);
|
theta = static_cast<uint32_t>(2.0f * M_PI * uniformDist(rndGenerator));
|
||||||
instanceData[i + INSTANCE_COUNT / 2].pos = glm::vec3(rho*cos(theta), uniformDist(rndGenerator) * 0.5f - 0.25f, rho*sin(theta));
|
instanceData[i + INSTANCE_COUNT / 2].pos = glm::vec3(rho*cos(theta), uniformDist(rndGenerator) * 0.5f - 0.25f, rho*sin(theta));
|
||||||
instanceData[i + INSTANCE_COUNT / 2].rot = glm::vec3(M_PI * uniformDist(rndGenerator), M_PI * uniformDist(rndGenerator), M_PI * uniformDist(rndGenerator));
|
instanceData[i + INSTANCE_COUNT / 2].rot = glm::vec3(M_PI * uniformDist(rndGenerator), M_PI * uniformDist(rndGenerator), M_PI * uniformDist(rndGenerator));
|
||||||
instanceData[i + INSTANCE_COUNT / 2].scale = 1.5f + uniformDist(rndGenerator) - uniformDist(rndGenerator);
|
instanceData[i + INSTANCE_COUNT / 2].scale = 1.5f + uniformDist(rndGenerator) - uniformDist(rndGenerator);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Note: Requires a device that supports VK_KHR_MAINTENANCE1
|
* Note: Requires a device that supports VK_KHR_MAINTENANCE1
|
||||||
*
|
*
|
||||||
* Copyright (C) by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*/
|
*/
|
||||||
|
|
@ -16,8 +16,8 @@ class VulkanExample : public VulkanExampleBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool negativeViewport = true;
|
bool negativeViewport = true;
|
||||||
int32_t offsety = 0;
|
float offsety = 0.0f;
|
||||||
int32_t offsetx = 0;
|
float offsetx = 0.0f;
|
||||||
int32_t windingOrder = 1;
|
int32_t windingOrder = 1;
|
||||||
int32_t cullMode = (int32_t)VK_CULL_MODE_BACK_BIT;
|
int32_t cullMode = (int32_t)VK_CULL_MODE_BACK_BIT;
|
||||||
int32_t quadType = 0;
|
int32_t quadType = 0;
|
||||||
|
|
@ -303,10 +303,10 @@ public:
|
||||||
if (overlay->checkBox("Negative viewport height", &negativeViewport)) {
|
if (overlay->checkBox("Negative viewport height", &negativeViewport)) {
|
||||||
buildCommandBuffers();
|
buildCommandBuffers();
|
||||||
}
|
}
|
||||||
if (overlay->sliderInt("offset x", &offsetx, -(int32_t)width, (int32_t)width)) {
|
if (overlay->sliderFloat("offset x", &offsetx, -(float)width, (float)width)) {
|
||||||
buildCommandBuffers();
|
buildCommandBuffers();
|
||||||
}
|
}
|
||||||
if (overlay->sliderInt("offset y", &offsety, -(int32_t)height, (int32_t)height)) {
|
if (overlay->sliderFloat("offset y", &offsety, -(float)height, (float)height)) {
|
||||||
buildCommandBuffers();
|
buildCommandBuffers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan Example - 3D texture loading (and generation using perlin noise) example
|
* Vulkan Example - 3D texture loading (and generation using perlin noise) example
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*/
|
*/
|
||||||
|
|
@ -306,11 +306,11 @@ public:
|
||||||
const float noiseScale = static_cast<float>(rand() % 10) + 4.0f;
|
const float noiseScale = static_cast<float>(rand() % 10) + 4.0f;
|
||||||
|
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
for (int32_t z = 0; z < texture.depth; z++)
|
for (int32_t z = 0; z < static_cast<int32_t>(texture.depth); z++)
|
||||||
{
|
{
|
||||||
for (int32_t y = 0; y < texture.height; y++)
|
for (int32_t y = 0; y < static_cast<int32_t>(texture.height); y++)
|
||||||
{
|
{
|
||||||
for (int32_t x = 0; x < texture.width; x++)
|
for (int32_t x = 0; x < static_cast<int32_t>(texture.width); x++)
|
||||||
{
|
{
|
||||||
float nx = (float)x / (float)texture.width;
|
float nx = (float)x / (float)texture.width;
|
||||||
float ny = (float)y / (float)texture.height;
|
float ny = (float)y / (float)texture.height;
|
||||||
|
|
|
||||||
|
|
@ -386,9 +386,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
VkDescriptorSetLayoutCreateInfo descriptorLayout =
|
VkDescriptorSetLayoutCreateInfo descriptorLayout =
|
||||||
vks::initializers::descriptorSetLayoutCreateInfo(
|
vks::initializers::descriptorSetLayoutCreateInfo(setLayoutBindings);
|
||||||
setLayoutBindings.data(),
|
|
||||||
setLayoutBindings.size());
|
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &descriptorSetLayout));
|
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &descriptorSetLayout));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ public:
|
||||||
// calculate num of mip maps
|
// calculate num of mip maps
|
||||||
// numLevels = 1 + floor(log2(max(w, h, d)))
|
// numLevels = 1 + floor(log2(max(w, h, d)))
|
||||||
// Calculated as log2(max(width, height, depth))c + 1 (see specs)
|
// Calculated as log2(max(width, height, depth))c + 1 (see specs)
|
||||||
texture.mipLevels = floor(log2(std::max(texture.width, texture.height))) + 1;
|
texture.mipLevels = static_cast<uint32_t>(floor(log2(std::max(texture.width, texture.height))) + 1);
|
||||||
|
|
||||||
// Get device properties for the requested texture format
|
// Get device properties for the requested texture format
|
||||||
VkFormatProperties formatProperties;
|
VkFormatProperties formatProperties;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue