From 381d85545a433e194610ed1af672cf7b5c1d07fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg=20Kristensen?= Date: Fri, 5 Feb 2016 12:47:02 -0800 Subject: [PATCH] anv: Share scratch_space helper between gen7 and gen8+ 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 | 6 ------ src/vulkan/gen8_pipeline.c | 6 +++--- src/vulkan/genX_pipeline_util.h | 6 ++++++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/vulkan/gen7_pipeline.c b/src/vulkan/gen7_pipeline.c index bf30f59be7b..3fedd74f1ea 100644 --- a/src/vulkan/gen7_pipeline.c +++ b/src/vulkan/gen7_pipeline.c @@ -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, diff --git a/src/vulkan/gen8_pipeline.c b/src/vulkan/gen8_pipeline.c index c1295a0b83a..4097de177ae 100644 --- a/src/vulkan/gen8_pipeline.c +++ b/src/vulkan/gen8_pipeline.c @@ -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 ? diff --git a/src/vulkan/genX_pipeline_util.h b/src/vulkan/genX_pipeline_util.h index 059b72514a7..9e0f82e7167 100644 --- a/src/vulkan/genX_pipeline_util.h +++ b/src/vulkan/genX_pipeline_util.h @@ -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, -- 2.30.2