Commit 8fff8c3b by Nicolas Capens Committed by Nicolas Capens

Don't use VK_TRUE comparisons

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." However, in case applications do use other values, the least surprising behavior is for non-0 values to be interpreted as true. Bug: b/134584057 Change-Id: I861691442683d534b4e34bd55deb18643adb3a99 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40448 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent b766e5e7
...@@ -80,9 +80,9 @@ SpirvShader::ImageSampler *SpirvShader::getImageSampler(uint32_t inst, vk::Sampl ...@@ -80,9 +80,9 @@ SpirvShader::ImageSampler *SpirvShader::getImageSampler(uint32_t inst, vk::Sampl
samplerState.mipmapFilter = convertMipmapMode(sampler); samplerState.mipmapFilter = convertMipmapMode(sampler);
samplerState.compareEnable = (sampler->compareEnable == VK_TRUE); samplerState.compareEnable = (sampler->compareEnable != VK_FALSE);
samplerState.compareOp = sampler->compareOp; samplerState.compareOp = sampler->compareOp;
samplerState.unnormalizedCoordinates = (sampler->unnormalizedCoordinates == VK_TRUE); samplerState.unnormalizedCoordinates = (sampler->unnormalizedCoordinates != VK_FALSE);
if(sampler->ycbcrConversion) if(sampler->ycbcrConversion)
{ {
...@@ -224,7 +224,7 @@ std::shared_ptr<rr::Routine> SpirvShader::emitSamplerRoutine(ImageInstruction in ...@@ -224,7 +224,7 @@ std::shared_ptr<rr::Routine> SpirvShader::emitSamplerRoutine(ImageInstruction in
sw::FilterType SpirvShader::convertFilterMode(const vk::Sampler *sampler) sw::FilterType SpirvShader::convertFilterMode(const vk::Sampler *sampler)
{ {
if(sampler->anisotropyEnable == VK_TRUE) if(sampler->anisotropyEnable != VK_FALSE)
{ {
return FILTER_ANISOTROPIC; return FILTER_ANISOTROPIC;
} }
......
...@@ -450,7 +450,7 @@ bool PhysicalDevice::hasFeatures(const VkPhysicalDeviceFeatures &requestedFeatur ...@@ -450,7 +450,7 @@ bool PhysicalDevice::hasFeatures(const VkPhysicalDeviceFeatures &requestedFeatur
for(unsigned int i = 0; i < featureCount; i++) for(unsigned int i = 0; i < featureCount; i++)
{ {
if((requestedFeature[i] == VK_TRUE) && (supportedFeature[i] != VK_TRUE)) if((requestedFeature[i] != VK_FALSE) && (supportedFeature[i] == VK_FALSE))
{ {
return false; return false;
} }
......
...@@ -251,7 +251,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateIn ...@@ -251,7 +251,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateIn
UNIMPLEMENTED("pCreateInfo->pRasterizationState settings"); UNIMPLEMENTED("pCreateInfo->pRasterizationState settings");
} }
context.rasterizerDiscard = (rasterizationState->rasterizerDiscardEnable == VK_TRUE); context.rasterizerDiscard = (rasterizationState->rasterizerDiscardEnable != VK_FALSE);
context.cullMode = rasterizationState->cullMode; context.cullMode = rasterizationState->cullMode;
context.frontFace = rasterizationState->frontFace; context.frontFace = rasterizationState->frontFace;
context.polygonMode = rasterizationState->polygonMode; context.polygonMode = rasterizationState->polygonMode;
...@@ -307,7 +307,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateIn ...@@ -307,7 +307,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateIn
context.sampleMask = multisampleState->pSampleMask[0]; context.sampleMask = multisampleState->pSampleMask[0];
} }
context.alphaToCoverage = (multisampleState->alphaToCoverageEnable == VK_TRUE); context.alphaToCoverage = (multisampleState->alphaToCoverageEnable != VK_FALSE);
if((multisampleState->flags != 0) || if((multisampleState->flags != 0) ||
(multisampleState->sampleShadingEnable != VK_FALSE) || (multisampleState->sampleShadingEnable != VK_FALSE) ||
...@@ -330,12 +330,12 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateIn ...@@ -330,12 +330,12 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateIn
UNIMPLEMENTED("depthStencilState"); UNIMPLEMENTED("depthStencilState");
} }
context.depthBoundsTestEnable = (depthStencilState->depthBoundsTestEnable == VK_TRUE); context.depthBoundsTestEnable = (depthStencilState->depthBoundsTestEnable != VK_FALSE);
context.depthBufferEnable = (depthStencilState->depthTestEnable == VK_TRUE); context.depthBufferEnable = (depthStencilState->depthTestEnable != VK_FALSE);
context.depthWriteEnable = (depthStencilState->depthWriteEnable == VK_TRUE); context.depthWriteEnable = (depthStencilState->depthWriteEnable != VK_FALSE);
context.depthCompareMode = depthStencilState->depthCompareOp; context.depthCompareMode = depthStencilState->depthCompareOp;
context.stencilEnable = (depthStencilState->stencilTestEnable == VK_TRUE); context.stencilEnable = (depthStencilState->stencilTestEnable != VK_FALSE);
if(context.stencilEnable) if(context.stencilEnable)
{ {
context.frontStencil = depthStencilState->front; context.frontStencil = depthStencilState->front;
...@@ -365,7 +365,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateIn ...@@ -365,7 +365,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateIn
const VkPipelineColorBlendAttachmentState &attachment = colorBlendState->pAttachments[i]; const VkPipelineColorBlendAttachmentState &attachment = colorBlendState->pAttachments[i];
context.colorWriteMask[i] = attachment.colorWriteMask; context.colorWriteMask[i] = attachment.colorWriteMask;
context.setBlendState(i, { (attachment.blendEnable == VK_TRUE), context.setBlendState(i, { (attachment.blendEnable != VK_FALSE),
attachment.srcColorBlendFactor, attachment.dstColorBlendFactor, attachment.colorBlendOp, attachment.srcColorBlendFactor, attachment.dstColorBlendFactor, attachment.colorBlendOp,
attachment.srcAlphaBlendFactor, attachment.dstAlphaBlendFactor, attachment.alphaBlendOp }); attachment.srcAlphaBlendFactor, attachment.dstAlphaBlendFactor, attachment.alphaBlendOp });
} }
......
...@@ -561,10 +561,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c ...@@ -561,10 +561,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
{ {
const VkPhysicalDevice16BitStorageFeatures *storage16BitFeatures = reinterpret_cast<const VkPhysicalDevice16BitStorageFeatures *>(extensionCreateInfo); const VkPhysicalDevice16BitStorageFeatures *storage16BitFeatures = reinterpret_cast<const VkPhysicalDevice16BitStorageFeatures *>(extensionCreateInfo);
if(storage16BitFeatures->storageBuffer16BitAccess == VK_TRUE || if(storage16BitFeatures->storageBuffer16BitAccess != VK_FALSE ||
storage16BitFeatures->uniformAndStorageBuffer16BitAccess == VK_TRUE || storage16BitFeatures->uniformAndStorageBuffer16BitAccess != VK_FALSE ||
storage16BitFeatures->storagePushConstant16 == VK_TRUE || storage16BitFeatures->storagePushConstant16 != VK_FALSE ||
storage16BitFeatures->storageInputOutput16 == VK_TRUE) storage16BitFeatures->storageInputOutput16 != VK_FALSE)
{ {
return VK_ERROR_FEATURE_NOT_PRESENT; return VK_ERROR_FEATURE_NOT_PRESENT;
} }
...@@ -574,8 +574,8 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c ...@@ -574,8 +574,8 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
{ {
const VkPhysicalDeviceVariablePointerFeatures *variablePointerFeatures = reinterpret_cast<const VkPhysicalDeviceVariablePointerFeatures *>(extensionCreateInfo); const VkPhysicalDeviceVariablePointerFeatures *variablePointerFeatures = reinterpret_cast<const VkPhysicalDeviceVariablePointerFeatures *>(extensionCreateInfo);
if(variablePointerFeatures->variablePointersStorageBuffer == VK_TRUE || if(variablePointerFeatures->variablePointersStorageBuffer != VK_FALSE ||
variablePointerFeatures->variablePointers == VK_TRUE) variablePointerFeatures->variablePointers != VK_FALSE)
{ {
return VK_ERROR_FEATURE_NOT_PRESENT; return VK_ERROR_FEATURE_NOT_PRESENT;
} }
...@@ -616,10 +616,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c ...@@ -616,10 +616,10 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT: case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT:
{ {
const VkPhysicalDeviceLineRasterizationFeaturesEXT *lineRasterizationFeatures = reinterpret_cast<const VkPhysicalDeviceLineRasterizationFeaturesEXT *>(extensionCreateInfo); const VkPhysicalDeviceLineRasterizationFeaturesEXT *lineRasterizationFeatures = reinterpret_cast<const VkPhysicalDeviceLineRasterizationFeaturesEXT *>(extensionCreateInfo);
if((lineRasterizationFeatures->smoothLines == VK_TRUE) || if((lineRasterizationFeatures->smoothLines != VK_FALSE) ||
(lineRasterizationFeatures->stippledBresenhamLines == VK_TRUE) || (lineRasterizationFeatures->stippledBresenhamLines != VK_FALSE) ||
(lineRasterizationFeatures->stippledRectangularLines == VK_TRUE) || (lineRasterizationFeatures->stippledRectangularLines != VK_FALSE) ||
(lineRasterizationFeatures->stippledSmoothLines == VK_TRUE)) (lineRasterizationFeatures->stippledSmoothLines != VK_FALSE))
{ {
return VK_ERROR_FEATURE_NOT_PRESENT; return VK_ERROR_FEATURE_NOT_PRESENT;
} }
......
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