gen8/pipeline: Properly handle MIN/MAX blend ops
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 20 Nov 2015 19:53:10 +0000 (11:53 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 20 Nov 2015 19:53:10 +0000 (11:53 -0800)
src/vulkan/gen8_pipeline.c

index 618774eda6ec996206026c38138eb6d2c559a352..6e2e65d63442f99dfd1e87452a941ddf1308e2d3 100644 (file)
@@ -229,6 +229,23 @@ emit_cb_state(struct anv_pipeline *pipeline,
          .WriteDisableGreen = !(a->channelWriteMask & VK_CHANNEL_G_BIT),
          .WriteDisableBlue = !(a->channelWriteMask & VK_CHANNEL_B_BIT),
       };
+
+      /* Our hardware applies the blend factor prior to the blend function
+       * regardless of what function is used.  Technically, this means the
+       * hardware can do MORE than GL or Vulkan specify.  However, it also
+       * means that, for MIN and MAX, we have to stomp the blend factor to
+       * ONE to make it a no-op.
+       */
+      if (a->blendOpColor == VK_BLEND_OP_MIN ||
+          a->blendOpColor == VK_BLEND_OP_MAX) {
+         blend_state.Entry[i].SourceBlendFactor = BLENDFACTOR_ONE;
+         blend_state.Entry[i].DestinationBlendFactor = BLENDFACTOR_ONE;
+      }
+      if (a->blendOpAlpha == VK_BLEND_OP_MIN ||
+          a->blendOpAlpha == VK_BLEND_OP_MAX) {
+         blend_state.Entry[i].SourceAlphaBlendFactor = BLENDFACTOR_ONE;
+         blend_state.Entry[i].DestinationAlphaBlendFactor = BLENDFACTOR_ONE;
+      }
    }
 
    GEN8_BLEND_STATE_pack(NULL, pipeline->blend_state.map, &blend_state);