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 ...@@ -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()); const uint64_t max_timeout = (LLONG_MAX - start.time_since_epoch().count());
bool infiniteTimeout = (timeout > max_timeout); bool infiniteTimeout = (timeout > max_timeout);
const time_point end_ns = start + std::chrono::nanoseconds(std::min(max_timeout, 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++) for(uint32_t i = 0; i < fenceCount; i++)
{ {
......
...@@ -31,61 +31,61 @@ const VkPhysicalDeviceFeatures& PhysicalDevice::getFeatures() const ...@@ -31,61 +31,61 @@ const VkPhysicalDeviceFeatures& PhysicalDevice::getFeatures() const
{ {
static const VkPhysicalDeviceFeatures features static const VkPhysicalDeviceFeatures features
{ {
true, // robustBufferAccess VK_TRUE, // robustBufferAccess
false, // fullDrawIndexUint32 VK_FALSE, // fullDrawIndexUint32
false, // imageCubeArray VK_FALSE, // imageCubeArray
false, // independentBlend VK_FALSE, // independentBlend
false, // geometryShader VK_FALSE, // geometryShader
false, // tessellationShader VK_FALSE, // tessellationShader
false, // sampleRateShading VK_FALSE, // sampleRateShading
false, // dualSrcBlend VK_FALSE, // dualSrcBlend
false, // logicOp VK_FALSE, // logicOp
true, // multiDrawIndirect VK_TRUE, // multiDrawIndirect
true, // drawIndirectFirstInstance VK_TRUE, // drawIndirectFirstInstance
false, // depthClamp VK_FALSE, // depthClamp
false, // depthBiasClamp VK_FALSE, // depthBiasClamp
false, // fillModeNonSolid VK_FALSE, // fillModeNonSolid
false, // depthBounds VK_FALSE, // depthBounds
false, // wideLines VK_FALSE, // wideLines
false, // largePoints VK_FALSE, // largePoints
false, // alphaToOne VK_FALSE, // alphaToOne
false, // multiViewport VK_FALSE, // multiViewport
false, // samplerAnisotropy VK_FALSE, // samplerAnisotropy
true, // textureCompressionETC2 VK_TRUE, // textureCompressionETC2
false, // textureCompressionASTC_LDR VK_FALSE, // textureCompressionASTC_LDR
false, // textureCompressionBC VK_FALSE, // textureCompressionBC
false, // occlusionQueryPrecise VK_FALSE, // occlusionQueryPrecise
false, // pipelineStatisticsQuery VK_FALSE, // pipelineStatisticsQuery
false, // vertexPipelineStoresAndAtomics VK_FALSE, // vertexPipelineStoresAndAtomics
false, // fragmentStoresAndAtomics VK_FALSE, // fragmentStoresAndAtomics
false, // shaderTessellationAndGeometryPointSize VK_FALSE, // shaderTessellationAndGeometryPointSize
false, // shaderImageGatherExtended VK_FALSE, // shaderImageGatherExtended
false, // shaderStorageImageExtendedFormats VK_FALSE, // shaderStorageImageExtendedFormats
false, // shaderStorageImageMultisample VK_FALSE, // shaderStorageImageMultisample
false, // shaderStorageImageReadWithoutFormat VK_FALSE, // shaderStorageImageReadWithoutFormat
false, // shaderStorageImageWriteWithoutFormat VK_FALSE, // shaderStorageImageWriteWithoutFormat
false, // shaderUniformBufferArrayDynamicIndexing VK_FALSE, // shaderUniformBufferArrayDynamicIndexing
false, // shaderSampledImageArrayDynamicIndexing VK_FALSE, // shaderSampledImageArrayDynamicIndexing
false, // shaderStorageBufferArrayDynamicIndexing VK_FALSE, // shaderStorageBufferArrayDynamicIndexing
false, // shaderStorageImageArrayDynamicIndexing VK_FALSE, // shaderStorageImageArrayDynamicIndexing
false, // shaderClipDistance VK_FALSE, // shaderClipDistance
false, // shaderCullDistance VK_FALSE, // shaderCullDistance
false, // shaderFloat64 VK_FALSE, // shaderFloat64
false, // shaderInt64 VK_FALSE, // shaderInt64
false, // shaderInt16 VK_FALSE, // shaderInt16
false, // shaderResourceResidency VK_FALSE, // shaderResourceResidency
false, // shaderResourceMinLod VK_FALSE, // shaderResourceMinLod
false, // sparseBinding VK_FALSE, // sparseBinding
false, // sparseResidencyBuffer VK_FALSE, // sparseResidencyBuffer
false, // sparseResidencyImage2D VK_FALSE, // sparseResidencyImage2D
false, // sparseResidencyImage3D VK_FALSE, // sparseResidencyImage3D
false, // sparseResidency2Samples VK_FALSE, // sparseResidency2Samples
false, // sparseResidency4Samples VK_FALSE, // sparseResidency4Samples
false, // sparseResidency8Samples VK_FALSE, // sparseResidency8Samples
false, // sparseResidency16Samples VK_FALSE, // sparseResidency16Samples
false, // sparseResidencyAliased VK_FALSE, // sparseResidencyAliased
false, // variableMultisampleRate VK_FALSE, // variableMultisampleRate
false, // inheritedQueries VK_FALSE, // inheritedQueries
}; };
return features; return features;
...@@ -236,7 +236,7 @@ const VkPhysicalDeviceLimits& PhysicalDevice::getLimits() const ...@@ -236,7 +236,7 @@ const VkPhysicalDeviceLimits& PhysicalDevice::getLimits() const
sampleCounts, // sampledImageStencilSampleCounts sampleCounts, // sampledImageStencilSampleCounts
VK_SAMPLE_COUNT_1_BIT, // storageImageSampleCounts (unsupported) VK_SAMPLE_COUNT_1_BIT, // storageImageSampleCounts (unsupported)
1, // maxSampleMaskWords 1, // maxSampleMaskWords
false, // timestampComputeAndGraphics VK_FALSE, // timestampComputeAndGraphics
60, // timestampPeriod 60, // timestampPeriod
8, // maxClipDistances 8, // maxClipDistances
8, // maxCullDistances 8, // maxCullDistances
...@@ -246,8 +246,8 @@ const VkPhysicalDeviceLimits& PhysicalDevice::getLimits() const ...@@ -246,8 +246,8 @@ const VkPhysicalDeviceLimits& PhysicalDevice::getLimits() const
{ 1.0, 1.0 }, // lineWidthRange[2] (unsupported) { 1.0, 1.0 }, // lineWidthRange[2] (unsupported)
0.0, // pointSizeGranularity (unsupported) 0.0, // pointSizeGranularity (unsupported)
0.0, // lineWidthGranularity (unsupported) 0.0, // lineWidthGranularity (unsupported)
false, // strictLines VK_FALSE, // strictLines
true, // standardSampleLocations VK_TRUE, // standardSampleLocations
64, // optimalBufferCopyOffsetAlignment 64, // optimalBufferCopyOffsetAlignment
64, // optimalBufferCopyRowPitchAlignment 64, // optimalBufferCopyRowPitchAlignment
256, // nonCoherentAtomSize 256, // nonCoherentAtomSize
...@@ -268,7 +268,7 @@ const VkPhysicalDeviceProperties& PhysicalDevice::getProperties() const ...@@ -268,7 +268,7 @@ const VkPhysicalDeviceProperties& PhysicalDevice::getProperties() const
SWIFTSHADER_DEVICE_NAME, // deviceName SWIFTSHADER_DEVICE_NAME, // deviceName
SWIFTSHADER_UUID, // pipelineCacheUUID SWIFTSHADER_UUID, // pipelineCacheUUID
getLimits(), // limits getLimits(), // limits
{ 0 } // sparseProperties {} // sparseProperties
}; };
return properties; return properties;
......
...@@ -303,7 +303,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn ...@@ -303,7 +303,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
UNIMPLEMENTED("pCreateInfo->pInputAssemblyState settings"); UNIMPLEMENTED("pCreateInfo->pInputAssemblyState settings");
} }
primitiveRestartEnable = assemblyState->primitiveRestartEnable; primitiveRestartEnable = (assemblyState->primitiveRestartEnable != VK_FALSE);
context.topology = assemblyState->topology; context.topology = assemblyState->topology;
const VkPipelineViewportStateCreateInfo* viewportState = pCreateInfo->pViewportState; const VkPipelineViewportStateCreateInfo* viewportState = pCreateInfo->pViewportState;
...@@ -329,7 +329,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn ...@@ -329,7 +329,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
const VkPipelineRasterizationStateCreateInfo* rasterizationState = pCreateInfo->pRasterizationState; const VkPipelineRasterizationStateCreateInfo* rasterizationState = pCreateInfo->pRasterizationState;
if((rasterizationState->flags != 0) || if((rasterizationState->flags != 0) ||
(rasterizationState->depthClampEnable != 0) || (rasterizationState->depthClampEnable != VK_FALSE) ||
(rasterizationState->polygonMode != VK_POLYGON_MODE_FILL)) (rasterizationState->polygonMode != VK_POLYGON_MODE_FILL))
{ {
UNIMPLEMENTED("pCreateInfo->pRasterizationState settings"); UNIMPLEMENTED("pCreateInfo->pRasterizationState settings");
...@@ -338,8 +338,8 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn ...@@ -338,8 +338,8 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
context.rasterizerDiscard = (rasterizationState->rasterizerDiscardEnable == VK_TRUE); context.rasterizerDiscard = (rasterizationState->rasterizerDiscardEnable == VK_TRUE);
context.cullMode = rasterizationState->cullMode; context.cullMode = rasterizationState->cullMode;
context.frontFacingCCW = rasterizationState->frontFace == VK_FRONT_FACE_COUNTER_CLOCKWISE; context.frontFacingCCW = rasterizationState->frontFace == VK_FRONT_FACE_COUNTER_CLOCKWISE;
context.depthBias = (rasterizationState->depthBiasEnable ? rasterizationState->depthBiasConstantFactor : 0.0f); context.depthBias = (rasterizationState->depthBiasEnable != VK_FALSE) ? rasterizationState->depthBiasConstantFactor : 0.0f;
context.slopeDepthBias = (rasterizationState->depthBiasEnable ? rasterizationState->depthBiasSlopeFactor : 0.0f); context.slopeDepthBias = (rasterizationState->depthBiasEnable != VK_FALSE) ? rasterizationState->depthBiasSlopeFactor : 0.0f;
const VkPipelineMultisampleStateCreateInfo* multisampleState = pCreateInfo->pMultisampleState; const VkPipelineMultisampleStateCreateInfo* multisampleState = pCreateInfo->pMultisampleState;
if(multisampleState) if(multisampleState)
...@@ -361,8 +361,8 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn ...@@ -361,8 +361,8 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
context.alphaToCoverage = (multisampleState->alphaToCoverageEnable == VK_TRUE); context.alphaToCoverage = (multisampleState->alphaToCoverageEnable == VK_TRUE);
if((multisampleState->flags != 0) || if((multisampleState->flags != 0) ||
(multisampleState->sampleShadingEnable != 0) || (multisampleState->sampleShadingEnable != VK_FALSE) ||
(multisampleState->alphaToOneEnable != 0)) (multisampleState->alphaToOneEnable != VK_FALSE))
{ {
UNIMPLEMENTED("multisampleState"); UNIMPLEMENTED("multisampleState");
} }
...@@ -376,7 +376,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn ...@@ -376,7 +376,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
if(depthStencilState) if(depthStencilState)
{ {
if((depthStencilState->flags != 0) || if((depthStencilState->flags != 0) ||
(depthStencilState->depthBoundsTestEnable != 0)) (depthStencilState->depthBoundsTestEnable != VK_FALSE))
{ {
UNIMPLEMENTED("depthStencilState"); UNIMPLEMENTED("depthStencilState");
} }
...@@ -398,7 +398,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn ...@@ -398,7 +398,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
if(colorBlendState) if(colorBlendState)
{ {
if((colorBlendState->flags != 0) || if((colorBlendState->flags != 0) ||
((colorBlendState->logicOpEnable != 0))) ((colorBlendState->logicOpEnable != VK_FALSE)))
{ {
UNIMPLEMENTED("colorBlendState"); 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