Dealing with "logicOpEnable-00606" validation error

Howdy!

First off, thanks for such a promising API. Perfect for my purpose.

I have been confronted with this unusual concern by our very own Validation Layer

[07:38:22][error] KARMA: Validation Layer: Validation Error: [ VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00606 ] Object 0: handle = 0x1060b6218, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x234f6296 | Invalid Pipeline CreateInfo[0]: If logic operations feature not enabled, logicOpEnable must be VK_FALSE. The Vulkan spec states: If the logic operations feature is not enabled, logicOpEnable must be VK_FALSE (https://vulkan.lunarg.com/doc/view/1.3.211.0/mac/1.3-extensions/vkspec.html#VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00606)

The relevant code is like so (someplace)

// Combine the old and new value using a bitwise operation
VkPipelineColorBlendStateCreateInfo colorBlending{};
colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
colorBlending.logicOpEnable = VK_TRUE;
colorBlending.logicOp = VK_LOGIC_OP_COPY;
colorBlending.attachmentCount = 1;
...

What I fail to comprehend is that if logicOpEnable is the switch to enable logical operations (written here (some link)) then which “logical operations” is the layer talking about?

Is it something, some extension to be pedantic, that I am missing, that needs be initialised in the VulkanContext (some link). Sorry for being this stupid!!

Thanks and Regards,
The_Cowboy

Vulkan has a number of optional features called… “features”. They are part of the core API, but implementations are allowed to not allow you to use them. Which means that you must, at device-creation time, declare you intent to use them (after checking if the physical device supports it to begin with).

The error “If logic operations feature not enabled” is telling you that logic operations is such a feature. You didn’t enable it at device-creation time, so therefore you cannot activate it on a pipeline.

“Extensions” are different from “features” in that they have components of them which are not part of the core Vulkan API. If logic operations were an extension, the struct VkPipelineColorBlendStateCreateInfo wouldn’t have a logicOpEnable flag at all. Instead, the logic operations extension would define an extension struct which would have the enable flag (and other logic op parameters) in it. You would then shove a pointer to that struct into VkPipelineColorBlendStateCreateInfo's pNext pointer to supply that flag to the pipeline.

1 Like

Aha, that sounds convincing.

I am following the official Vulkan tutorial (vulkan-tutorial dot com) and I don’t think they mention anything about the -subject- features despite the fact of mentioning the concept of “Blending” in the fixed function section. I remember someone commenting on the issue, but it was not resolved.

Time to do some research on core!!!

Yes Sir! You are absolutely right.

The following code sorted it out

VkPhysicalDeviceFeatures deviceFeatures{};
deviceFeatures.samplerAnisotropy = VK_TRUE;
deviceFeatures.logicOp = VK_TRUE;
...

Also thanks a lot for clearing up the difference between extensions and features!! It is very useful!!!