Code cleanup
Fixed remaining warnings (MSVC VS2022)
This commit is contained in:
parent
f6e77be11f
commit
ac957ef8af
6 changed files with 30 additions and 25 deletions
|
|
@ -441,5 +441,11 @@ namespace vks
|
|||
return (value + alignment - 1) & ~(alignment - 1);
|
||||
}
|
||||
|
||||
|
||||
VkDeviceSize alignedVkSize(VkDeviceSize value, VkDeviceSize alignment)
|
||||
{
|
||||
return (value + alignment - 1) & ~(alignment - 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,5 +133,6 @@ namespace vks
|
|||
bool fileExists(const std::string &filename);
|
||||
|
||||
uint32_t alignedSize(uint32_t value, uint32_t alignment);
|
||||
VkDeviceSize alignedVkSize(VkDeviceSize value, VkDeviceSize alignment);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,8 +204,8 @@ public:
|
|||
vkGetDescriptorSetLayoutBindingOffsetEXT(device, combinedImageDescriptor.setLayout, 0, &combinedImageDescriptor.layoutOffset);
|
||||
|
||||
// In order to copy resource descriptors to the correct place, we need to calculate aligned sizes
|
||||
uniformDescriptor.layoutSize = vks::tools::alignedSize(uniformDescriptor.layoutSize, descriptorBufferProperties.descriptorBufferOffsetAlignment);
|
||||
combinedImageDescriptor.layoutSize = vks::tools::alignedSize(combinedImageDescriptor.layoutSize, descriptorBufferProperties.descriptorBufferOffsetAlignment);
|
||||
uniformDescriptor.layoutSize = vks::tools::alignedVkSize(uniformDescriptor.layoutSize, descriptorBufferProperties.descriptorBufferOffsetAlignment);
|
||||
combinedImageDescriptor.layoutSize = vks::tools::alignedVkSize(combinedImageDescriptor.layoutSize, descriptorBufferProperties.descriptorBufferOffsetAlignment);
|
||||
|
||||
// This buffer will contain resource descriptors for all the uniform buffers (one per cube and one with global matrices)
|
||||
VK_CHECK_RESULT(vulkanDevice->createBuffer(
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public:
|
|||
for (size_t i = 0; i < textures.size(); i++) {
|
||||
std::random_device rndDevice;
|
||||
std::default_random_engine rndEngine(rndDevice());
|
||||
std::uniform_int_distribution<short> rndDist(50, 255);
|
||||
std::uniform_int_distribution<> rndDist(50, UCHAR_MAX);
|
||||
const int32_t dim = 3;
|
||||
const size_t bufferSize = dim * dim * 4;
|
||||
std::vector<uint8_t> texture(bufferSize);
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public:
|
|||
void setupMultisampleTarget()
|
||||
{
|
||||
// Check if device supports requested sample count for color and depth frame buffer
|
||||
assert((deviceProperties.limits.framebufferColorSampleCounts >= sampleCount) && (deviceProperties.limits.framebufferDepthSampleCounts >= sampleCount));
|
||||
assert((deviceProperties.limits.framebufferColorSampleCounts & sampleCount) && (deviceProperties.limits.framebufferDepthSampleCounts & sampleCount));
|
||||
|
||||
// Color target
|
||||
VkImageCreateInfo info = vks::initializers::imageCreateInfo();
|
||||
|
|
@ -503,20 +503,31 @@ public:
|
|||
void draw()
|
||||
{
|
||||
VulkanExampleBase::prepareFrame();
|
||||
|
||||
// Command buffer to be sumitted to the queue
|
||||
submitInfo.commandBufferCount = 1;
|
||||
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
||||
|
||||
// Submit to queue
|
||||
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
|
||||
|
||||
VulkanExampleBase::submitFrame();
|
||||
}
|
||||
|
||||
// Select the highest sample count usable by the platform
|
||||
// In a realworld application, this would be a user setting instead
|
||||
VkSampleCountFlagBits getMaxAvailableSampleCount()
|
||||
{
|
||||
VkSampleCountFlags supportedSampleCount = std::min(deviceProperties.limits.framebufferColorSampleCounts, deviceProperties.limits.framebufferDepthSampleCounts);
|
||||
std::vector< VkSampleCountFlagBits> possibleSampleCounts {
|
||||
VK_SAMPLE_COUNT_64_BIT, VK_SAMPLE_COUNT_32_BIT, VK_SAMPLE_COUNT_16_BIT, VK_SAMPLE_COUNT_8_BIT, VK_SAMPLE_COUNT_4_BIT, VK_SAMPLE_COUNT_2_BIT
|
||||
};
|
||||
for (auto& possibleSampleCount : possibleSampleCounts) {
|
||||
if (supportedSampleCount & possibleSampleCount) {
|
||||
return possibleSampleCount;
|
||||
}
|
||||
}
|
||||
return VK_SAMPLE_COUNT_1_BIT;
|
||||
}
|
||||
|
||||
void prepare()
|
||||
{
|
||||
sampleCount = getMaxUsableSampleCount();
|
||||
sampleCount = getMaxAvailableSampleCount();
|
||||
UIOverlay.rasterizationSamples = sampleCount;
|
||||
VulkanExampleBase::prepare();
|
||||
loadAssets();
|
||||
|
|
@ -544,19 +555,6 @@ public:
|
|||
updateUniformBuffers();
|
||||
}
|
||||
|
||||
// Returns the maximum sample count usable by the platform
|
||||
VkSampleCountFlagBits getMaxUsableSampleCount()
|
||||
{
|
||||
VkSampleCountFlags counts = std::min(deviceProperties.limits.framebufferColorSampleCounts, deviceProperties.limits.framebufferDepthSampleCounts);
|
||||
if (counts & VK_SAMPLE_COUNT_64_BIT) { return VK_SAMPLE_COUNT_64_BIT; }
|
||||
if (counts & VK_SAMPLE_COUNT_32_BIT) { return VK_SAMPLE_COUNT_32_BIT; }
|
||||
if (counts & VK_SAMPLE_COUNT_16_BIT) { return VK_SAMPLE_COUNT_16_BIT; }
|
||||
if (counts & VK_SAMPLE_COUNT_8_BIT) { return VK_SAMPLE_COUNT_8_BIT; }
|
||||
if (counts & VK_SAMPLE_COUNT_4_BIT) { return VK_SAMPLE_COUNT_4_BIT; }
|
||||
if (counts & VK_SAMPLE_COUNT_2_BIT) { return VK_SAMPLE_COUNT_2_BIT; }
|
||||
return VK_SAMPLE_COUNT_1_BIT;
|
||||
}
|
||||
|
||||
virtual void OnUpdateUIOverlay(vks::UIOverlay *overlay)
|
||||
{
|
||||
if (vulkanDevice->features.sampleRateShading) {
|
||||
|
|
|
|||
|
|
@ -609,7 +609,7 @@ public:
|
|||
VkPipelineViewportStateCreateInfo viewportState = vks::initializers::pipelineViewportStateCreateInfo(1, 1, 0);
|
||||
VkPipelineMultisampleStateCreateInfo multisampleState = vks::initializers::pipelineMultisampleStateCreateInfo(VK_SAMPLE_COUNT_1_BIT, 0);
|
||||
std::vector<VkDynamicState> dynamicStateEnables = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
|
||||
VkPipelineDynamicStateCreateInfo dynamicState = vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables.data(), dynamicStateEnables.size(), 0);
|
||||
VkPipelineDynamicStateCreateInfo dynamicState = vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables);
|
||||
|
||||
// 3D scene pipeline
|
||||
// Load shaders
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue