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: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index a009c5e..cdf4873 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -251,7 +251,7 @@
UNIMPLEMENTED("pCreateInfo->pRasterizationState settings");
}
- context.rasterizerDiscard = (rasterizationState->rasterizerDiscardEnable == VK_TRUE);
+ context.rasterizerDiscard = (rasterizationState->rasterizerDiscardEnable != VK_FALSE);
context.cullMode = rasterizationState->cullMode;
context.frontFace = rasterizationState->frontFace;
context.polygonMode = rasterizationState->polygonMode;
@@ -307,7 +307,7 @@
context.sampleMask = multisampleState->pSampleMask[0];
}
- context.alphaToCoverage = (multisampleState->alphaToCoverageEnable == VK_TRUE);
+ context.alphaToCoverage = (multisampleState->alphaToCoverageEnable != VK_FALSE);
if((multisampleState->flags != 0) ||
(multisampleState->sampleShadingEnable != VK_FALSE) ||
@@ -330,12 +330,12 @@
UNIMPLEMENTED("depthStencilState");
}
- context.depthBoundsTestEnable = (depthStencilState->depthBoundsTestEnable == VK_TRUE);
- context.depthBufferEnable = (depthStencilState->depthTestEnable == VK_TRUE);
- context.depthWriteEnable = (depthStencilState->depthWriteEnable == VK_TRUE);
+ context.depthBoundsTestEnable = (depthStencilState->depthBoundsTestEnable != VK_FALSE);
+ context.depthBufferEnable = (depthStencilState->depthTestEnable != VK_FALSE);
+ context.depthWriteEnable = (depthStencilState->depthWriteEnable != VK_FALSE);
context.depthCompareMode = depthStencilState->depthCompareOp;
- context.stencilEnable = (depthStencilState->stencilTestEnable == VK_TRUE);
+ context.stencilEnable = (depthStencilState->stencilTestEnable != VK_FALSE);
if(context.stencilEnable)
{
context.frontStencil = depthStencilState->front;
@@ -365,7 +365,7 @@
const VkPipelineColorBlendAttachmentState &attachment = colorBlendState->pAttachments[i];
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.srcAlphaBlendFactor, attachment.dstAlphaBlendFactor, attachment.alphaBlendOp });
}