From 1acebeb1910b5fb29195acf132bbb88ebeebfb8b Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 21 Oct 2016 10:40:58 -0700 Subject: [PATCH] intel/blorp: Make the number of samples an explicit parameter Previously, we always inferred it from params->dst which meant that references to params->dst were scattered all throughout the state upload code. Signed-off-by: Jason Ekstrand Reviewed-by: Topi Pohjolainen --- src/intel/blorp/blorp.c | 2 ++ src/intel/blorp/blorp_blit.c | 2 ++ src/intel/blorp/blorp_clear.c | 7 +++++++ src/intel/blorp/blorp_genX_exec.h | 16 +++++++--------- src/intel/blorp/blorp_priv.h | 1 + 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/intel/blorp/blorp.c b/src/intel/blorp/blorp.c index 402282f0ff0..c26490531b3 100644 --- a/src/intel/blorp/blorp.c +++ b/src/intel/blorp/blorp.c @@ -141,6 +141,7 @@ void blorp_params_init(struct blorp_params *params) { memset(params, 0, sizeof(*params)); + params->num_samples = 1; params->num_draw_buffers = 1; params->num_layers = 1; } @@ -265,6 +266,7 @@ blorp_gen6_hiz_op(struct blorp_batch *batch, params.dst.surf.samples = params.depth.surf.samples; params.dst.surf.logical_level0_px = params.depth.surf.logical_level0_px; params.depth_format = isl_format_get_depth_format(surf->surf->format, false); + params.num_samples = params.depth.surf.samples; batch->blorp->exec(batch, ¶ms); } diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c index c0b56c38192..bce4b973956 100644 --- a/src/intel/blorp/blorp_blit.c +++ b/src/intel/blorp/blorp_blit.c @@ -1609,6 +1609,8 @@ do_blorp_blit(struct blorp_batch *batch, wm_prog_key->persample_msaa_dispatch = true; } + params->num_samples = params->dst.surf.samples; + if (params->src.tile_x_sa || params->src.tile_y_sa) { assert(wm_prog_key->need_src_offset); surf_get_intratile_offset_px(¶ms->src, diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c index 981c94dfec9..c59040e0313 100644 --- a/src/intel/blorp/blorp_clear.c +++ b/src/intel/blorp/blorp_clear.c @@ -234,6 +234,7 @@ blorp_fast_clear(struct blorp_batch *batch, brw_blorp_surface_info_init(batch->blorp, ¶ms.dst, surf, level, start_layer, format, true); + params.num_samples = params.dst.surf.samples; batch->blorp->exec(batch, ¶ms); } @@ -293,6 +294,8 @@ blorp_clear(struct blorp_batch *batch, start_layer, format, true); params.dst.view.swizzle = swizzle; + params.num_samples = params.dst.surf.samples; + /* We may be restricted on the number of layers we can bind at any one * time. In particular, Sandy Bridge has a maximum number of layers of * 512 but a maximum 3D texture size is much larger. @@ -338,6 +341,8 @@ blorp_clear_depth_stencil(struct blorp_batch *batch, params.stencil.surf.logical_level0_px; params.dst.view = params.depth.view; + params.num_samples = params.stencil.surf.samples; + /* We may be restricted on the number of layers we can bind at any * one time. In particular, Sandy Bridge has a maximum number of * layers of 512 but a maximum 3D texture size is much larger. @@ -359,6 +364,8 @@ blorp_clear_depth_stencil(struct blorp_batch *batch, params.depth.surf.logical_level0_px; params.dst.view = params.depth.view; + params.num_samples = params.depth.surf.samples; + /* We may be restricted on the number of layers we can bind at any * one time. In particular, Sandy Bridge has a maximum number of * layers of 512 but a maximum 3D texture size is much larger. diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h index 86da7892eaf..66d53ec2137 100644 --- a/src/intel/blorp/blorp_genX_exec.h +++ b/src/intel/blorp/blorp_genX_exec.h @@ -456,7 +456,7 @@ blorp_emit_sf_config(struct blorp_batch *batch, sf.FrontFaceFillMode = FILL_MODE_SOLID; sf.BackFaceFillMode = FILL_MODE_SOLID; - sf.MultisampleRasterizationMode = params->dst.surf.samples > 1 ? + sf.MultisampleRasterizationMode = params->num_samples > 1 ? MSRASTMODE_ON_PATTERN : MSRASTMODE_OFF_PIXEL; #if GEN_GEN == 7 @@ -482,7 +482,7 @@ blorp_emit_sf_config(struct blorp_batch *batch, sf.FrontFaceFillMode = FILL_MODE_SOLID; sf.BackFaceFillMode = FILL_MODE_SOLID; - sf.MultisampleRasterizationMode = params->dst.surf.samples > 1 ? + sf.MultisampleRasterizationMode = params->num_samples > 1 ? MSRASTMODE_ON_PATTERN : MSRASTMODE_OFF_PIXEL; sf.VertexURBEntryReadOffset = 1; @@ -610,7 +610,7 @@ blorp_emit_ps_config(struct blorp_batch *batch, if (params->src.enabled) wm.PixelShaderKillsPixel = true; - if (params->dst.surf.samples > 1) { + if (params->num_samples > 1) { wm.MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN; wm.MultisampleDispatchMode = (prog_data && prog_data->persample_dispatch) ? @@ -712,7 +712,7 @@ blorp_emit_ps_config(struct blorp_batch *batch, wm.PixelShaderKillsPixel = true; /* TODO: temporarily smash on */ } - if (params->dst.surf.samples > 1) { + if (params->num_samples > 1) { wm.MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN; wm.MultisampleDispatchMode = (prog_data && prog_data->persample_dispatch) ? @@ -1165,10 +1165,8 @@ static void blorp_emit_3dstate_multisample(struct blorp_batch *batch, const struct blorp_params *params) { - const unsigned samples = params->dst.surf.samples; - blorp_emit(batch, GENX(3DSTATE_MULTISAMPLE), ms) { - ms.NumberofMultisamples = __builtin_ffs(samples) - 1; + ms.NumberofMultisamples = __builtin_ffs(params->num_samples) - 1; #if GEN_GEN >= 8 /* The PRM says that this bit is valid only for DX9: @@ -1181,7 +1179,7 @@ blorp_emit_3dstate_multisample(struct blorp_batch *batch, #elif GEN_GEN >= 7 ms.PixelLocation = PIXLOC_CENTER; - switch (samples) { + switch (params->num_samples) { case 1: GEN_SAMPLE_POS_1X(ms.Sample); break; @@ -1303,7 +1301,7 @@ blorp_exec(struct blorp_batch *batch, const struct blorp_params *params) blorp_emit_3dstate_multisample(batch, params); blorp_emit(batch, GENX(3DSTATE_SAMPLE_MASK), mask) { - mask.SampleMask = (1 << params->dst.surf.samples) - 1; + mask.SampleMask = (1 << params->num_samples) - 1; } /* From the BSpec, 3D Pipeline > Geometry > Vertex Shader > State, diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h index 710479f7b02..9666a9b11bd 100644 --- a/src/intel/blorp/blorp_priv.h +++ b/src/intel/blorp/blorp_priv.h @@ -169,6 +169,7 @@ struct blorp_params enum blorp_fast_clear_op fast_clear_op; bool color_write_disable[4]; struct brw_blorp_wm_inputs wm_inputs; + unsigned num_samples; unsigned num_draw_buffers; unsigned num_layers; uint32_t wm_prog_kernel; -- 2.30.2