turnip: parse VkPipelineDynamicStateCreateInfo
authorChia-I Wu <olvaffe@gmail.com>
Thu, 21 Feb 2019 17:41:49 +0000 (09:41 -0800)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 11 Mar 2019 17:02:13 +0000 (10:02 -0700)
src/freedreno/vulkan/tu_pipeline.c

index 9df7c20b45503d44a79d225cac6bb24dab86f1d7..50b3a02e6226b386d4a415252fd87ef255de5fef 100644 (file)
@@ -47,6 +47,34 @@ struct tu_pipeline_builder
    const VkGraphicsPipelineCreateInfo *create_info;
 };
 
+static enum tu_dynamic_state_bits
+tu_dynamic_state_bit(VkDynamicState state)
+{
+   switch (state) {
+   case VK_DYNAMIC_STATE_VIEWPORT:
+      return TU_DYNAMIC_VIEWPORT;
+   case VK_DYNAMIC_STATE_SCISSOR:
+      return TU_DYNAMIC_SCISSOR;
+   case VK_DYNAMIC_STATE_LINE_WIDTH:
+      return TU_DYNAMIC_LINE_WIDTH;
+   case VK_DYNAMIC_STATE_DEPTH_BIAS:
+      return TU_DYNAMIC_DEPTH_BIAS;
+   case VK_DYNAMIC_STATE_BLEND_CONSTANTS:
+      return TU_DYNAMIC_BLEND_CONSTANTS;
+   case VK_DYNAMIC_STATE_DEPTH_BOUNDS:
+      return TU_DYNAMIC_DEPTH_BOUNDS;
+   case VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK:
+      return TU_DYNAMIC_STENCIL_COMPARE_MASK;
+   case VK_DYNAMIC_STATE_STENCIL_WRITE_MASK:
+      return TU_DYNAMIC_STENCIL_WRITE_MASK;
+   case VK_DYNAMIC_STATE_STENCIL_REFERENCE:
+      return TU_DYNAMIC_STENCIL_REFERENCE;
+   default:
+      unreachable("invalid dynamic state");
+      return 0;
+   }
+}
+
 static VkResult
 tu_pipeline_builder_create_pipeline(struct tu_pipeline_builder *builder,
                                     struct tu_pipeline **out_pipeline)
@@ -73,6 +101,22 @@ tu_pipeline_builder_create_pipeline(struct tu_pipeline_builder *builder,
    return VK_SUCCESS;
 }
 
+static void
+tu_pipeline_builder_parse_dynamic(struct tu_pipeline_builder *builder,
+                                  struct tu_pipeline *pipeline)
+{
+   const VkPipelineDynamicStateCreateInfo *dynamic_info =
+      builder->create_info->pDynamicState;
+
+   if (!dynamic_info)
+      return;
+
+   for (uint32_t i = 0; i < dynamic_info->dynamicStateCount; i++) {
+      pipeline->dynamic_state.mask |=
+         tu_dynamic_state_bit(dynamic_info->pDynamicStates[i]);
+   }
+}
+
 static void
 tu_pipeline_finish(struct tu_pipeline *pipeline,
                    struct tu_device *dev,
@@ -89,6 +133,8 @@ tu_pipeline_builder_build(struct tu_pipeline_builder *builder,
    if (result != VK_SUCCESS)
       return result;
 
+   tu_pipeline_builder_parse_dynamic(builder, *pipeline);
+
    /* we should have reserved enough space upfront such that the CS never
     * grows
     */