anv/gen7: Properly handle missing color-blend state
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 9 Nov 2015 23:58:19 +0000 (15:58 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 10 Nov 2015 00:04:06 +0000 (16:04 -0800)
src/vulkan/gen7_pipeline.c

index affe04c526f03c888bd6e4d76080fbd1af8eaac9..3622071ead29eae885d77b73cb0184d05edc0662 100644 (file)
@@ -253,54 +253,66 @@ gen7_emit_cb_state(struct anv_pipeline *pipeline,
 {
    struct anv_device *device = pipeline->device;
 
-   /* FIXME-GEN7: All render targets share blend state settings on gen7, we
-    * can't implement this.
-    */
-   const VkPipelineColorBlendAttachmentState *a = &info->pAttachments[0];
-
    uint32_t num_dwords = GEN7_BLEND_STATE_length;
    pipeline->blend_state =
       anv_state_pool_alloc(&device->dynamic_state_pool, num_dwords * 4, 64);
 
-   struct GEN7_BLEND_STATE blend_state = {
-      .ColorBufferBlendEnable = a->blendEnable,
-      .IndependentAlphaBlendEnable = true, /* FIXME: yes? */
-      .AlphaBlendFunction = vk_to_gen_blend_op[a->blendOpAlpha],
-
-      .SourceAlphaBlendFactor = vk_to_gen_blend[a->srcBlendAlpha],
-      .DestinationAlphaBlendFactor = vk_to_gen_blend[a->destBlendAlpha],
-
-      .ColorBlendFunction = vk_to_gen_blend_op[a->blendOpColor],
-      .SourceBlendFactor = vk_to_gen_blend[a->srcBlendColor],
-      .DestinationBlendFactor = vk_to_gen_blend[a->destBlendColor],
-      .AlphaToCoverageEnable = info->alphaToCoverageEnable,
-
-#if 0
-   bool                                         AlphaToOneEnable;
-   bool                                         AlphaToCoverageDitherEnable;
-#endif
-
-      .WriteDisableAlpha = !(a->channelWriteMask & VK_CHANNEL_A_BIT),
-      .WriteDisableRed = !(a->channelWriteMask & VK_CHANNEL_R_BIT),
-      .WriteDisableGreen = !(a->channelWriteMask & VK_CHANNEL_G_BIT),
-      .WriteDisableBlue = !(a->channelWriteMask & VK_CHANNEL_B_BIT),
-
-      .LogicOpEnable = info->logicOpEnable,
-      .LogicOpFunction = vk_to_gen_logic_op[info->logicOp],
+   if (info->pAttachments == NULL) {
+      struct GEN7_BLEND_STATE blend_state = {
+         .ColorBufferBlendEnable = false,
+         .WriteDisableAlpha = false,
+         .WriteDisableRed = false,
+         .WriteDisableGreen = false,
+         .WriteDisableBlue = false,
+      };
 
-#if 0
-   bool                                         AlphaTestEnable;
-   uint32_t                                     AlphaTestFunction;
-   bool                                         ColorDitherEnable;
-   uint32_t                                     XDitherOffset;
-   uint32_t                                     YDitherOffset;
-   uint32_t                                     ColorClampRange;
-   bool                                         PreBlendColorClampEnable;
-   bool                                         PostBlendColorClampEnable;
-#endif
-   };
+      GEN7_BLEND_STATE_pack(NULL, pipeline->blend_state.map, &blend_state);
+   } else {
+      /* FIXME-GEN7: All render targets share blend state settings on gen7, we
+       * can't implement this.
+       */
+      const VkPipelineColorBlendAttachmentState *a = &info->pAttachments[0];
+
+      struct GEN7_BLEND_STATE blend_state = {
+         .ColorBufferBlendEnable = a->blendEnable,
+         .IndependentAlphaBlendEnable = true, /* FIXME: yes? */
+         .AlphaBlendFunction = vk_to_gen_blend_op[a->blendOpAlpha],
+
+         .SourceAlphaBlendFactor = vk_to_gen_blend[a->srcBlendAlpha],
+         .DestinationAlphaBlendFactor = vk_to_gen_blend[a->destBlendAlpha],
+
+         .ColorBlendFunction = vk_to_gen_blend_op[a->blendOpColor],
+         .SourceBlendFactor = vk_to_gen_blend[a->srcBlendColor],
+         .DestinationBlendFactor = vk_to_gen_blend[a->destBlendColor],
+         .AlphaToCoverageEnable = info->alphaToCoverageEnable,
+
+#     if 0
+         bool                                         AlphaToOneEnable;
+         bool                                         AlphaToCoverageDitherEnable;
+#     endif
+
+         .WriteDisableAlpha = !(a->channelWriteMask & VK_CHANNEL_A_BIT),
+         .WriteDisableRed = !(a->channelWriteMask & VK_CHANNEL_R_BIT),
+         .WriteDisableGreen = !(a->channelWriteMask & VK_CHANNEL_G_BIT),
+         .WriteDisableBlue = !(a->channelWriteMask & VK_CHANNEL_B_BIT),
+
+         .LogicOpEnable = info->logicOpEnable,
+         .LogicOpFunction = vk_to_gen_logic_op[info->logicOp],
+
+#     if 0
+         bool                                         AlphaTestEnable;
+         uint32_t                                     AlphaTestFunction;
+         bool                                         ColorDitherEnable;
+         uint32_t                                     XDitherOffset;
+         uint32_t                                     YDitherOffset;
+         uint32_t                                     ColorClampRange;
+         bool                                         PreBlendColorClampEnable;
+         bool                                         PostBlendColorClampEnable;
+#     endif
+      };
 
-   GEN7_BLEND_STATE_pack(NULL, pipeline->blend_state.map, &blend_state);
+      GEN7_BLEND_STATE_pack(NULL, pipeline->blend_state.map, &blend_state);
+    }
 
    anv_batch_emit(&pipeline->batch, GEN7_3DSTATE_BLEND_STATE_POINTERS,
                   .BlendStatePointer = pipeline->blend_state.offset);