<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 18, 2016 at 5:37 PM, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 04/18/2016 05:10 PM, Jason Ekstrand wrote:<br>
> ---<br>
> src/intel/vulkan/genX_cmd_buffer.c | 76 +++++++++++++++++++++-----------------<br>
> 1 file changed, 42 insertions(+), 34 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c<br>
> index 932ba65..713de82 100644<br>
> --- a/src/intel/vulkan/genX_cmd_buffer.c<br>
> +++ b/src/intel/vulkan/genX_cmd_buffer.c<br>
> @@ -924,28 +924,34 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)<br>
><br>
> /* Emit 3DSTATE_DEPTH_BUFFER */<br>
> if (has_depth) {<br>
> - anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_DEPTH_BUFFER),<br>
> - .SurfaceType = SURFTYPE_2D,<br>
> - .DepthWriteEnable = true,<br>
> - .StencilWriteEnable = has_stencil,<br>
> - .HierarchicalDepthBufferEnable = false,<br>
> - .SurfaceFormat = isl_surf_get_depth_format(&device->isl_dev,<br>
> - &image->depth_surface.isl),<br>
> - .SurfacePitch = image->depth_surface.isl.row_pitch - 1,<br>
> - .SurfaceBaseAddress = {<br>
> + anv_batch_emit_blk(&cmd_buffer->batch, GENX(3DSTATE_DEPTH_BUFFER), db) {<br>
> + db.SurfaceType = SURFTYPE_2D;<br>
> + db.DepthWriteEnable = true;<br>
> + db.StencilWriteEnable = has_stencil;<br>
> + db.HierarchicalDepthBufferEnable = false;<br>
> +<br>
> + db.SurfaceFormat = isl_surf_get_depth_format(&device->isl_dev,<br>
> + &image->depth_surface.isl);<br>
> +<br>
> + db.SurfaceBaseAddress = (struct anv_address) {<br>
> .bo = image->bo,<br>
> .offset = image->offset + image->depth_surface.offset,<br>
> - },<br>
> - .Height = fb->height - 1,<br>
> - .Width = fb->width - 1,<br>
> - .LOD = 0,<br>
> - .Depth = 1 - 1,<br>
> - .MinimumArrayElement = 0,<br>
> - .DepthBufferObjectControlState = GENX(MOCS),<br>
> + };<br>
> + db.DepthBufferObjectControlState = GENX(MOCS),<br>
> +<br>
> + db.SurfacePitch = image->depth_surface.isl.row_pitch - 1;<br>
> + db.Height = fb->height - 1;<br>
> + db.Width = fb->width - 1;<br>
> + db.LOD = 0;<br>
> + db.Depth = 1 - 1;<br>
> + db.MinimumArrayElement = 0;<br>
> +<br>
> #if GEN_GEN >= 8<br>
> - .SurfaceQPitch = isl_surf_get_array_pitch_el_rows(&image->depth_surface.isl) >> 2,<br>
> + db.SurfaceQPitch =<br>
> + isl_surf_get_array_pitch_el_rows(&image->depth_surface.isl) >> 2,<br>
> #endif<br>
> - .RenderTargetViewExtent = 1 - 1);<br>
> + db.RenderTargetViewExtent = 1 - 1;<br>
> + }<br>
> } else {<br>
> /* Even when no depth buffer is present, the hardware requires that<br>
> * 3DSTATE_DEPTH_BUFFER be programmed correctly. The Broadwell PRM says:<br>
> @@ -965,45 +971,47 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer)<br>
> * nor stencil buffer is present. Also, D16_UNORM is not allowed to<br>
> * be combined with a stencil buffer so we use D32_FLOAT instead.<br>
> */<br>
> - anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_DEPTH_BUFFER),<br>
> - .SurfaceType = SURFTYPE_2D,<br>
> - .SurfaceFormat = D32_FLOAT,<br>
> - .Width = fb->width - 1,<br>
> - .Height = fb->height - 1,<br>
> - .StencilWriteEnable = has_stencil);<br>
> + anv_batch_emit_blk(&cmd_buffer->batch, GENX(3DSTATE_DEPTH_BUFFER), db) {<br>
> + db.SurfaceType = SURFTYPE_2D;<br>
> + db.SurfaceFormat = D32_FLOAT;<br>
> + db.Width = fb->width - 1;<br>
> + db.Height = fb->height - 1;<br>
> + db.StencilWriteEnable = has_stencil;<br>
> + }<br>
> }<br>
><br>
> /* Emit 3DSTATE_STENCIL_BUFFER */<br>
> if (has_stencil) {<br>
> - anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_STENCIL_BUFFER),<br>
> + anv_batch_emit_blk(&cmd_buffer->batch, GENX(3DSTATE_STENCIL_BUFFER), sb) {<br>
<br>
</div></div>I think all the code that follows violates the style guide. This is<br>
part of the reason I think we may regret this style choice. To be<br>
clear... I'll go with the crowd, but I just want to be sure the crowd<br>
fully has 2n eyes open.<br></blockquote><div><br></div><div>Right. This is a classic example of where the hard "vertical align" rule breaks down. The code below is so broken up by comments and #if's that each of the 4 assignments is in it's own visual section of the code and aligning them doesn't make as much sense.<br><br></div><div>At the end of the day, a hard "align things" rule won't really work. It needs to be more of a "sometimes we align things to make them look nicer" which, as has been pointed out isn't something you can make indent, vim, or emacs do for you. Honestly, I'm not *that* much of a fan of aligning things and, if it were only up to me, I probably wouldn't bother.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">
> #if GEN_GEN >= 8 || GEN_IS_HASWELL<br>
> - .StencilBufferEnable = true,<br>
> + sb.StencilBufferEnable = true,<br>
> #endif<br>
> - .StencilBufferObjectControlState = GENX(MOCS),<br>
> + sb.StencilBufferObjectControlState = GENX(MOCS),<br>
><br>
> /* Stencil buffers have strange pitch. The PRM says:<br>
> *<br>
> * The pitch must be set to 2x the value computed based on width,<br>
> * as the stencil buffer is stored with two rows interleaved.<br>
> */<br>
> - .SurfacePitch = 2 * image->stencil_surface.isl.row_pitch - 1,<br>
> + sb.SurfacePitch = 2 * image->stencil_surface.isl.row_pitch - 1,<br>
><br>
> #if GEN_GEN >= 8<br>
> - .SurfaceQPitch = isl_surf_get_array_pitch_el_rows(&image->stencil_surface.isl) >> 2,<br>
> + sb.SurfaceQPitch = isl_surf_get_array_pitch_el_rows(&image->stencil_surface.isl) >> 2,<br>
> #endif<br>
> - .SurfaceBaseAddress = {<br>
> + sb.SurfaceBaseAddress = (struct anv_address) {<br>
> .bo = image->bo,<br>
> .offset = image->offset + image->stencil_surface.offset,<br>
> - });<br>
> + };<br>
> + }<br>
> } else {<br>
> - anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_STENCIL_BUFFER));<br>
> + anv_batch_emit_blk(&cmd_buffer->batch, GENX(3DSTATE_STENCIL_BUFFER), sb);<br>
> }<br>
><br>
> /* Disable hierarchial depth buffers. */<br>
> - anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_HIER_DEPTH_BUFFER));<br>
> + anv_batch_emit_blk(&cmd_buffer->batch, GENX(3DSTATE_HIER_DEPTH_BUFFER), hz);<br>
><br>
> /* Clear the clear params. */<br>
> - anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CLEAR_PARAMS));<br>
> + anv_batch_emit_blk(&cmd_buffer->batch, GENX(3DSTATE_CLEAR_PARAMS), cp);<br>
> }<br>
><br>
> /**<br>
><br>
<br>
</div></div></blockquote></div><br></div></div>