Commit 85035be3 by Nicolas Capens Committed by Nicolas Capens

Use VK_TRUE/VK_FALSE consistently

The spec states that "Applications must not pass any other values than VK_TRUE or VK_FALSE into a Vulkan implementation where a VkBool32 is expected." So we should avoid the use of C++ true/false and literal 0/1 when dealing with VkBool32 values. Note that we test for 'condition != VK_FALSE' to evaluate whether the condition should be interpreted as true. This is both more efficient than testing for 'condition == VK_TRUE' and follows the principle of least surprise in the event an application does provide another value. Bug: b/134584057 Change-Id: I219172a2c538b0f0cb3f173ffd905adb8814b932 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/32408 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 39f0247a
......@@ -123,7 +123,8 @@ VkResult Device::waitForFences(uint32_t fenceCount, const VkFence* pFences, VkBo
const uint64_t max_timeout = (LLONG_MAX - start.time_since_epoch().count());
bool infiniteTimeout = (timeout > max_timeout);
const time_point end_ns = start + std::chrono::nanoseconds(std::min(max_timeout, timeout));
if(waitAll) // All fences must be signaled
if(waitAll != VK_FALSE) // All fences must be signaled
{
for(uint32_t i = 0; i < fenceCount; i++)
{
......
......@@ -31,61 +31,61 @@ const VkPhysicalDeviceFeatures& PhysicalDevice::getFeatures() const
{
static const VkPhysicalDeviceFeatures features
{
true, // robustBufferAccess
false, // fullDrawIndexUint32
false, // imageCubeArray
false, // independentBlend
false, // geometryShader
false, // tessellationShader
false, // sampleRateShading
false, // dualSrcBlend
false, // logicOp
true, // multiDrawIndirect
true, // drawIndirectFirstInstance
false, // depthClamp
false, // depthBiasClamp
false, // fillModeNonSolid
false, // depthBounds
false, // wideLines
false, // largePoints
false, // alphaToOne
false, // multiViewport
false, // samplerAnisotropy
true, // textureCompressionETC2
false, // textureCompressionASTC_LDR
false, // textureCompressionBC
false, // occlusionQueryPrecise
false, // pipelineStatisticsQuery
false, // vertexPipelineStoresAndAtomics
false, // fragmentStoresAndAtomics
false, // shaderTessellationAndGeometryPointSize
false, // shaderImageGatherExtended
false, // shaderStorageImageExtendedFormats
false, // shaderStorageImageMultisample
false, // shaderStorageImageReadWithoutFormat
false, // shaderStorageImageWriteWithoutFormat
false, // shaderUniformBufferArrayDynamicIndexing
false, // shaderSampledImageArrayDynamicIndexing
false, // shaderStorageBufferArrayDynamicIndexing
false, // shaderStorageImageArrayDynamicIndexing
false, // shaderClipDistance
false, // shaderCullDistance
false, // shaderFloat64
false, // shaderInt64
false, // shaderInt16
false, // shaderResourceResidency
false, // shaderResourceMinLod
false, // sparseBinding
false, // sparseResidencyBuffer
false, // sparseResidencyImage2D
false, // sparseResidencyImage3D
false, // sparseResidency2Samples
false, // sparseResidency4Samples
false, // sparseResidency8Samples
false, // sparseResidency16Samples
false, // sparseResidencyAliased
false, // variableMultisampleRate
false, // inheritedQueries
VK_TRUE, // robustBufferAccess
VK_FALSE, // fullDrawIndexUint32
VK_FALSE, // imageCubeArray
VK_FALSE, // independentBlend
VK_FALSE, // geometryShader
VK_FALSE, // tessellationShader
VK_FALSE, // sampleRateShading
VK_FALSE, // dualSrcBlend
VK_FALSE, // logicOp
VK_TRUE, // multiDrawIndirect
VK_TRUE, // drawIndirectFirstInstance
VK_FALSE, // depthClamp
VK_FALSE, // depthBiasClamp
VK_FALSE, // fillModeNonSolid
VK_FALSE, // depthBounds
VK_FALSE, // wideLines
VK_FALSE, // largePoints
VK_FALSE, // alphaToOne
VK_FALSE, // multiViewport
VK_FALSE, // samplerAnisotropy
VK_TRUE, // textureCompressionETC2
VK_FALSE, // textureCompressionASTC_LDR
VK_FALSE, // textureCompressionBC
VK_FALSE, // occlusionQueryPrecise
VK_FALSE, // pipelineStatisticsQuery
VK_FALSE, // vertexPipelineStoresAndAtomics
VK_FALSE, // fragmentStoresAndAtomics
VK_FALSE, // shaderTessellationAndGeometryPointSize
VK_FALSE, // shaderImageGatherExtended
VK_FALSE, // shaderStorageImageExtendedFormats
VK_FALSE, // shaderStorageImageMultisample
VK_FALSE, // shaderStorageImageReadWithoutFormat
VK_FALSE, // shaderStorageImageWriteWithoutFormat
VK_FALSE, // shaderUniformBufferArrayDynamicIndexing
VK_FALSE, // shaderSampledImageArrayDynamicIndexing
VK_FALSE, // shaderStorageBufferArrayDynamicIndexing
VK_FALSE, // shaderStorageImageArrayDynamicIndexing
VK_FALSE, // shaderClipDistance
VK_FALSE, // shaderCullDistance
VK_FALSE, // shaderFloat64
VK_FALSE, // shaderInt64
VK_FALSE, // shaderInt16
VK_FALSE, // shaderResourceResidency
VK_FALSE, // shaderResourceMinLod
VK_FALSE, // sparseBinding
VK_FALSE, // sparseResidencyBuffer
VK_FALSE, // sparseResidencyImage2D
VK_FALSE, // sparseResidencyImage3D
VK_FALSE, // sparseResidency2Samples
VK_FALSE, // sparseResidency4Samples
VK_FALSE, // sparseResidency8Samples
VK_FALSE, // sparseResidency16Samples
VK_FALSE, // sparseResidencyAliased
VK_FALSE, // variableMultisampleRate
VK_FALSE, // inheritedQueries
};
return features;
......@@ -236,7 +236,7 @@ const VkPhysicalDeviceLimits& PhysicalDevice::getLimits() const
sampleCounts, // sampledImageStencilSampleCounts
VK_SAMPLE_COUNT_1_BIT, // storageImageSampleCounts (unsupported)
1, // maxSampleMaskWords
false, // timestampComputeAndGraphics
VK_FALSE, // timestampComputeAndGraphics
60, // timestampPeriod
8, // maxClipDistances
8, // maxCullDistances
......@@ -246,8 +246,8 @@ const VkPhysicalDeviceLimits& PhysicalDevice::getLimits() const
{ 1.0, 1.0 }, // lineWidthRange[2] (unsupported)
0.0, // pointSizeGranularity (unsupported)
0.0, // lineWidthGranularity (unsupported)
false, // strictLines
true, // standardSampleLocations
VK_FALSE, // strictLines
VK_TRUE, // standardSampleLocations
64, // optimalBufferCopyOffsetAlignment
64, // optimalBufferCopyRowPitchAlignment
256, // nonCoherentAtomSize
......@@ -268,7 +268,7 @@ const VkPhysicalDeviceProperties& PhysicalDevice::getProperties() const
SWIFTSHADER_DEVICE_NAME, // deviceName
SWIFTSHADER_UUID, // pipelineCacheUUID
getLimits(), // limits
{ 0 } // sparseProperties
{} // sparseProperties
};
return properties;
......
......@@ -303,7 +303,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
UNIMPLEMENTED("pCreateInfo->pInputAssemblyState settings");
}
primitiveRestartEnable = assemblyState->primitiveRestartEnable;
primitiveRestartEnable = (assemblyState->primitiveRestartEnable != VK_FALSE);
context.topology = assemblyState->topology;
const VkPipelineViewportStateCreateInfo* viewportState = pCreateInfo->pViewportState;
......@@ -329,7 +329,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
const VkPipelineRasterizationStateCreateInfo* rasterizationState = pCreateInfo->pRasterizationState;
if((rasterizationState->flags != 0) ||
(rasterizationState->depthClampEnable != 0) ||
(rasterizationState->depthClampEnable != VK_FALSE) ||
(rasterizationState->polygonMode != VK_POLYGON_MODE_FILL))
{
UNIMPLEMENTED("pCreateInfo->pRasterizationState settings");
......@@ -338,8 +338,8 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
context.rasterizerDiscard = (rasterizationState->rasterizerDiscardEnable == VK_TRUE);
context.cullMode = rasterizationState->cullMode;
context.frontFacingCCW = rasterizationState->frontFace == VK_FRONT_FACE_COUNTER_CLOCKWISE;
context.depthBias = (rasterizationState->depthBiasEnable ? rasterizationState->depthBiasConstantFactor : 0.0f);
context.slopeDepthBias = (rasterizationState->depthBiasEnable ? rasterizationState->depthBiasSlopeFactor : 0.0f);
context.depthBias = (rasterizationState->depthBiasEnable != VK_FALSE) ? rasterizationState->depthBiasConstantFactor : 0.0f;
context.slopeDepthBias = (rasterizationState->depthBiasEnable != VK_FALSE) ? rasterizationState->depthBiasSlopeFactor : 0.0f;
const VkPipelineMultisampleStateCreateInfo* multisampleState = pCreateInfo->pMultisampleState;
if(multisampleState)
......@@ -361,8 +361,8 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
context.alphaToCoverage = (multisampleState->alphaToCoverageEnable == VK_TRUE);
if((multisampleState->flags != 0) ||
(multisampleState->sampleShadingEnable != 0) ||
(multisampleState->alphaToOneEnable != 0))
(multisampleState->sampleShadingEnable != VK_FALSE) ||
(multisampleState->alphaToOneEnable != VK_FALSE))
{
UNIMPLEMENTED("multisampleState");
}
......@@ -376,7 +376,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
if(depthStencilState)
{
if((depthStencilState->flags != 0) ||
(depthStencilState->depthBoundsTestEnable != 0))
(depthStencilState->depthBoundsTestEnable != VK_FALSE))
{
UNIMPLEMENTED("depthStencilState");
}
......@@ -398,7 +398,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
if(colorBlendState)
{
if((colorBlendState->flags != 0) ||
((colorBlendState->logicOpEnable != 0)))
((colorBlendState->logicOpEnable != VK_FALSE)))
{
UNIMPLEMENTED("colorBlendState");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment