vk: Always use a placeholder vertex shader in meta
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Fri, 21 Aug 2015 05:32:28 +0000 (22:32 -0700)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Mon, 24 Aug 2015 20:45:41 +0000 (13:45 -0700)
The clear pipeline didn't have a vertex shader and relied on the clear
shader being hardcoded by the compiler to accept one attribute. This
necessitated a few special cases in the 3DSTATE_VS setup. Instead,
always provide a vertex shader, even if we disable VS dispatch.

Signed-off-by: Kristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
src/vulkan/anv_meta.c
src/vulkan/gen8_pipeline.c

index 8f681230292f678014b60137e438feb16932517f..858a3daf11c7e31a76320134b3836c47e2cac7af 100644 (file)
@@ -34,8 +34,21 @@ static void
 anv_device_init_meta_clear_state(struct anv_device *device)
 {
    /* We don't use a vertex shader for clearing, but instead build and pass
-    * the VUEs directly to the rasterization backend.
+    * the VUEs directly to the rasterization backend.  However, we do need
+    * to provide GLSL source for the vertex shader so that the compiler
+    * does not dead-code our inputs.
     */
+   VkShaderModule vsm = GLSL_VK_SHADER_MODULE(device, VERTEX,
+      in vec2 a_pos;
+      in vec4 a_color;
+      flat out vec4 v_color;
+      void main()
+      {
+         v_color = a_color;
+         gl_Position = vec4(a_pos, 0, 1);
+      }
+   );
+
    VkShaderModule fsm = GLSL_VK_SHADER_MODULE(device, FRAGMENT,
       out vec4 f_color;
       flat in vec4 v_color;
@@ -45,6 +58,14 @@ anv_device_init_meta_clear_state(struct anv_device *device)
       }
    );
 
+   VkShader vs;
+   anv_CreateShader(anv_device_to_handle(device),
+      &(VkShaderCreateInfo) {
+         .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
+         .module = vsm,
+         .pName = "main",
+      }, &vs);
+
    VkShader fs;
    anv_CreateShader(anv_device_to_handle(device),
       &(VkShaderCreateInfo) {
@@ -103,12 +124,20 @@ anv_device_init_meta_clear_state(struct anv_device *device)
    anv_graphics_pipeline_create(anv_device_to_handle(device),
       &(VkGraphicsPipelineCreateInfo) {
          .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
-         .stageCount = 1,
-         .pStages = &(VkPipelineShaderStageCreateInfo) {
-            .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
-            .stage = VK_SHADER_STAGE_FRAGMENT,
-            .shader = fs,
-            .pSpecializationInfo = NULL,
+
+         .stageCount = 2,
+         .pStages = (VkPipelineShaderStageCreateInfo[]) {
+            {
+               .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
+               .stage = VK_SHADER_STAGE_VERTEX,
+               .shader = vs,
+               .pSpecializationInfo = NULL
+            }, {
+               .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
+               .stage = VK_SHADER_STAGE_FRAGMENT,
+               .shader = fs,
+               .pSpecializationInfo = NULL,
+            }
          },
          .pVertexInputState = &vi_create_info,
          .pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) {
@@ -153,6 +182,7 @@ anv_device_init_meta_clear_state(struct anv_device *device)
       &(struct anv_graphics_pipeline_create_info) {
          .use_repclear = true,
          .disable_viewport = true,
+         .disable_vs = true,
          .use_rectlist = true
       },
       &device->meta_state.clear.pipeline);
index 05091831b988b8d74e7deb96449603a448049c7e..220317c2d4895dc6fa03498124cb88c8f7fd544f 100644 (file)
@@ -527,12 +527,10 @@ gen8_graphics_pipeline_create(
    if (pipeline->vs_simd8 == NO_KERNEL || (extra && extra->disable_vs))
       anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VS,
                      .FunctionEnable = false,
-                     .VertexURBEntryOutputReadOffset = 1,
                      /* Even if VS is disabled, SBE still gets the amount of
-                      * vertex data to read from this field. We use attribute
-                      * count - 1, as we don't count the VUE header here. */
-                     .VertexURBEntryOutputLength =
-                        DIV_ROUND_UP(pCreateInfo->pVertexInputState->attributeCount - 1, 2));
+                      * vertex data to read from this field. */
+                     .VertexURBEntryOutputReadOffset = offset,
+                     .VertexURBEntryOutputLength = length);
    else
       anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VS,
                      .KernelStartPointer = pipeline->vs_simd8,