OSDN Git Service

anv: Allocate more push constant space.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 23 Feb 2016 01:28:22 +0000 (17:28 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 24 Feb 2016 19:22:05 +0000 (11:22 -0800)
Previously we allocated 4kB of push constant space for VS, GS, and PS
(for a total of 12kB) no matter what.  This works, but doesn't fully
utilize the space - we have 16kB or 32kB of space.

This makes anv use the same method as brw - divide up the space evenly
among all active shader stages.  This means HS and DS would get space,
if those shader stages existed.

In the future, we can probably do better by inspecting how many push
constants each shader stage uses, and weight things accordingly.  But
this is strictly better than the old code, and ideally we'd justify
a fancier solution with actual performance data.

src/intel/vulkan/anv_pipeline.c

index 6c8d4ad..92c5c35 100644 (file)
@@ -891,11 +891,17 @@ gen7_compute_urb_partition(struct anv_pipeline *pipeline)
    pipeline->urb.size[MESA_SHADER_TESS_EVAL] = 1;
    pipeline->urb.entries[MESA_SHADER_TESS_EVAL] = 0;
 
-   pipeline->urb.push_size[MESA_SHADER_VERTEX] = 4;
-   pipeline->urb.push_size[MESA_SHADER_TESS_CTRL] = 0;
-   pipeline->urb.push_size[MESA_SHADER_TESS_EVAL] = 0;
-   pipeline->urb.push_size[MESA_SHADER_GEOMETRY] = 4;
-   pipeline->urb.push_size[MESA_SHADER_FRAGMENT] = 4;
+   const unsigned stages =
+      _mesa_bitcount(pipeline->active_stages & VK_SHADER_STAGE_ALL_GRAPHICS);
+   const unsigned size_per_stage = push_constant_kb / stages;
+
+   for (int i = MESA_SHADER_VERTEX; i < MESA_SHADER_FRAGMENT; i++) {
+      pipeline->urb.push_size[i] =
+         (pipeline->active_stages & (1 << i)) ? size_per_stage : 1;
+   }
+
+   pipeline->urb.push_size[MESA_SHADER_FRAGMENT] =
+      push_constant_kb - size_per_stage * (stages - 1);
 }
 
 static void