anv: Share scratch_space helper between gen7 and gen8+
authorKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Fri, 5 Feb 2016 20:47:02 +0000 (12:47 -0800)
committerKristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
Sat, 6 Feb 2016 00:13:52 +0000 (16:13 -0800)
The gen7 pipeline has a useful helper function for this, let's use it in
gen8_pipeline.c too.  The gen7 function has an off-by-one bug though: we
have to compute log2(size / 1024) - 1, but we divide by 2048 instead so
as to avoid the case where size is less than 1024 and we'd return -1.

src/vulkan/gen7_pipeline.c
src/vulkan/gen8_pipeline.c
src/vulkan/genX_pipeline_util.h

index bf30f59be7b2282f971e70a14c65b9c3f2da6d73..3fedd74f1ea9ca0f8b2f9f6f1e82a59c924be8a2 100644 (file)
@@ -176,12 +176,6 @@ gen7_emit_cb_state(struct anv_pipeline *pipeline,
                   .BlendStatePointer = pipeline->blend_state.offset);
 }
 
-static inline uint32_t
-scratch_space(const struct brw_stage_prog_data *prog_data)
-{
-   return ffs(prog_data->total_scratch / 1024);
-}
-
 GENX_FUNC(GEN7, GEN75) VkResult
 genX(graphics_pipeline_create)(
     VkDevice                                    _device,
index c1295a0b83a19c31d18eb31d7588f82e9a7fa027..4097de177ae3fc3f2b051b4503be4c853e6e38f7 100644 (file)
@@ -406,7 +406,7 @@ genX(graphics_pipeline_create)(
                      .ExpectedVertexCount = pipeline->gs_vertex_count,
 
                      .ScratchSpaceBasePointer = pipeline->scratch_start[MESA_SHADER_GEOMETRY],
-                     .PerThreadScratchSpace = ffs(gs_prog_data->base.base.total_scratch / 2048),
+                     .PerThreadScratchSpace = scratch_space(&gs_prog_data->base.base),
 
                      .OutputVertexSize = gs_prog_data->output_vertex_size_hwords * 2 - 1,
                      .OutputTopology = gs_prog_data->output_topology,
@@ -468,7 +468,7 @@ genX(graphics_pipeline_create)(
                      .SoftwareExceptionEnable = false,
 
                      .ScratchSpaceBasePointer = pipeline->scratch_start[MESA_SHADER_VERTEX],
-                     .PerThreadScratchSpace = ffs(vue_prog_data->base.total_scratch / 2048),
+                     .PerThreadScratchSpace = scratch_space(&vue_prog_data->base),
 
                      .DispatchGRFStartRegisterForURBData =
                      vue_prog_data->base.dispatch_grf_start_reg,
@@ -601,7 +601,7 @@ genX(graphics_pipeline_create)(
                      .SamplerCount = 1,
 
                      .ScratchSpaceBasePointer = pipeline->scratch_start[MESA_SHADER_FRAGMENT],
-                     .PerThreadScratchSpace = ffs(wm_prog_data->base.total_scratch / 2048),
+                     .PerThreadScratchSpace = scratch_space(&wm_prog_data->base),
 
                      .MaximumNumberofThreadsPerPSD = 64 - num_thread_bias,
                      .PositionXYOffsetSelect = wm_prog_data->uses_pos_offset ?
index 059b72514a7fb06dff730a86bee3755b39f6759d..9e0f82e716700a6e64e86f3ea75a0a22ac604aea 100644 (file)
@@ -230,6 +230,12 @@ emit_urb_setup(struct anv_pipeline *pipeline)
       .DSNumberofURBEntries                     = 0);
 }
 
+static inline uint32_t
+scratch_space(const struct brw_stage_prog_data *prog_data)
+{
+   return ffs(prog_data->total_scratch / 2048);
+}
+
 static const uint32_t vk_to_gen_cullmode[] = {
    [VK_CULL_MODE_NONE]                       = CULLMODE_NONE,
    [VK_CULL_MODE_FRONT_BIT]                  = CULLMODE_FRONT,