<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 8, 2016 at 2:26 PM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</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 Tue, Nov 08, 2016 at 01:52:15PM -0800, Jason Ekstrand wrote:<br>
> On Tue, Nov 8, 2016 at 1:36 PM, Nanley Chery <<a href="mailto:nanleychery@gmail.com">nanleychery@gmail.com</a>> wrote:<br>
><br>
> > On Sat, Oct 22, 2016 at 10:50:31AM -0700, Jason Ekstrand wrote:<br>
> > > This series does some fairly major surgery on color attachment surface<br>
> > > state allocation and fill-out in the Intel Vulkan driver. This is in<br>
> > > preparation for doing color compression, fast-clears, and HiZ-capable<br>
> > input<br>
> > > attachments. Naturally, as with everything else I've done in the last 2<br>
> > > months, it also involves some non-trivial blorp work.<br>
> > ><br>
> > > Let's start off at the beginning... For a variety of reasons, we can't<br>
> > > really know 100% of the details of an attachment's surface state at any<br>
> > > other places than vkCmdBeginRenderPass and vkCmdNextSubpss. The same<br>
> > > applies for depth buffers if you consider 3DSTATE_DEPTH_BUFFER and<br>
> > friends<br>
> > > to be the depth and stencil buffer's "surface state". That's a fairly<br>
> > > strong statement, but there are a couple of reasons for this:<br>
> > ><br>
> > > 1) In order for fast-clears to work, the surface state has to contain<br>
> > the<br>
> > > clear color. (This is it's own packet for HiZ but not for color.)<br>
> > We<br>
> > > don't know the clear value until BeginRenderPass. This means we<br>
> > can't<br>
> > > fully fill out the surface state in vkCmdCreateImageView.<br>
> > ><br>
> ><br>
> > We could alternatively merge the view's surface state packet into<br>
> > another that only contains the clear color(s) right?<br>
> ><br>
><br>
> Potentially, yes. However that adds a good bit of complication because we<br>
> now have to emit render target surfaces on-the-fly because you may be<br>
> building two different batches simultaneously that use the same VkImageView<br>
> as a render target with two different clear colors. It also doesn't solve<br>
> the null framebuffer problem.<br>
><br>
<br>
</div></div>I'm not suggesting that this optimization solves the null framebuffer<br>
problem, nor that we could add the clear color to the VkImageView's<br>
surface state. I'm trying to confirm that we could allocate the block<br>
of states (as is done in this series), then assign a block entry the<br>
VkImageView's surface state + a surface state struct that only<br>
contains the clear colors.<br></blockquote><div><br></div><div>Yes, that might work and would let us keep the isl_surf_fill_state call in anv_image.c. We would also have to deal with at least the AuxUsage field in the OR-in as well. I think we could set up the other aux buffer information in isl_surf_fill_state and the hardware *should* ignore if we set AuxUsage to AUX_USAGE_NONE.<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">
><br>
> > - Nanley<br>
> ><br>
> > > 2) The Vulkan spec requires that you be able to call<br>
> > vkBeginCommandBuffer<br>
> > > on a secondary command buffer with USAGE_RENDER_PASS_CONTINUE_BIT set<br>
> > > but with a null framebuffer. In this case, the secondary is supposed<br>
> > > to inherit the framebuffer from the primary. (This is not something<br>
> > we<br>
> > > have properly implemented until now.) This means that anything that<br>
> > is<br>
> > > callable from a render-pass-continuing secondary command buffer has<br>
> > to<br>
> > > be able to operate without knowing any surface details that aren't<br>
> > part<br>
> > > of the VkRenderPass object. Basically, all you know is the Vulkan<br>
> > > format (not the isl format) and the sample count.<br>
> > ><br>
> > > Between the two of those, about the only two entrypoints left at which we<br>
> > > actually know surface details are vkCmdBeginRenderPass and<br>
> > vkCmdNextSubpass<br>
> > > so we have to figure out how to do everything there. As it turns out,<br>
> > this<br>
> > > works out surprisingly well. The format and the sample count turn out to<br>
> > > be exactly the data we actually need in order to do all of our pipeline<br>
> > > programming. The only hard part is refactoring things so that it pulls<br>
> > the<br>
> > > data from the render pass instead of the framebuffer. There are a number<br>
> > > of places where we were grabbing the image view for an attachment because<br>
> > > we either wanted to shove something into blorp or because we wanted the<br>
> > > format and we were lazy.<br>
> > ><br>
> > > The approach taken in this patch series is the following:<br>
> > ><br>
> > > 1) Instead of allocating render target surface states in<br>
> > vkCreateImageView,<br>
> > > we allocate them as part of render pass setup in<br>
> > vkCmdBeginRenderPass.<br>
> > > All of the surface states we will ever need (including a null surface<br>
> > > state) are allocated up-front out of a single contiguous block.<br>
> > ><br>
> > > 2) For secondary command buffers with USAGE_RENDER_PASS_CONTINUE_BIT<br>
> > set,<br>
> > > we allocate storage for all of the surface states but don't actually<br>
> > > fill them out. In the secondary command buffer, all binding tables<br>
> > > refer to these surface states rather than the ones in the primary.<br>
> > ><br>
> > > 3) A blorp entrypoint is added that performs a clear operation without<br>
> > > touching the depth/stencil buffer state and with a color attachment<br>
> > > binding table explicitly provided by the caller. This means that<br>
> > even<br>
> > > our blorp clears are using the surface states allocated in<br>
> > > vkCmdBeginRenderPass. Unfortunately, this turned out to be more work<br>
> > > than expected because I had to add vertex shader support to blorp<br>
> > along<br>
> > > the way.<br>
> > ><br>
> > > 4) Here's the tricky bit. When vkCmdExecuteCommands is called during a<br>
> > > render pass, we use transform feedback (yeah, crazy) to copy the<br>
> > block<br>
> > > of surface states from the primary into the secondary right before<br>
> > > executing the secondary.<br>
> > ><br>
> > > It's kind of a crazy scheme but I like the end result quite a bit.<br>
> > ><br>
> > > Cc: Kristian Høgsberg Kristensen <<a href="mailto:krh@bitplanet.net">krh@bitplanet.net</a>><br>
> > > Cc: Chad Versace <<a href="mailto:chadversary@chromium.org">chadversary@chromium.org</a>><br>
> > > Cc: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
> > > Cc: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><br>
> > ><br>
> > > Jason Ekstrand (25):<br>
> > > intel/isl: Add some basic info about RENDER_SURFACE_STATE to<br>
> > > isl_device<br>
> > > intel/genxml: Add SO_WRITE_OFFSET registers for gen7-9<br>
> > > anv: Add a helper for doing buffer copies with nothing but VF and SOL.<br>
> > > anv/cmd_buffer: Use the surface state alloc helper in<br>
> > > null_surface_state<br>
> > > anv/cmd_buffer: Expose add_surface_state_reloc as an inline helper<br>
> > > anv: Rework the way render target surfaces are allocated<br>
> > > anv/cmd_buffer: Stop relying on the framebuffer for 3DSTATE_SF on gen7<br>
> > > intel/genxml: Make some VS/GS fields consistent across gens<br>
> > > intel/blorp: Make the number of samples an explicit parameter<br>
> > > intel/blorp: Add a shader type to make keys more unique<br>
> > > intel/blorp: Remove NIR support for uniforms<br>
> > > intel/blorp: Rename compile_nir_shader to compile_fs<br>
> > > intel/blorp: Rework our usage of ralloc when compiling shaders<br>
> > > intel/blorp: Handle NIR clear inputs the same way as blit inputs<br>
> > > blorp/exec: Use uint32_t for copying varying data<br>
> > > intel/blorp: Use an actual chunk of vertex buffer for the VUE header<br>
> > > intel/blorp: Add support for vertex shaders<br>
> > > intel/blorp: Add capability to use pre-baked binding tables<br>
> > > intel/blorp: Add a clear_attachments entrypoint<br>
> > > anv: Bring back anv_cmd_buffer_emit_state_<wbr>base_address<br>
> > > anv/blorp: Break the guts of alloc_binding_table into a shared helper<br>
> > > anv/blorp: Use the new clear_attachments entrypoint for attachment<br>
> > > clears<br>
> > > anv: Set framebuffer to NULL in secondary command buffers<br>
> > > Allocate a null state whenever there is depth/stencil<br>
> > > anv/blorp: Handle VK_ATTACHMENT_UNUSED in CmdClearAttachments<br>
> > ><br>
> > > src/intel/blorp/blorp.c | 74 ++++----<br>
> > > src/intel/blorp/blorp.h | 11 ++<br>
> > > src/intel/blorp/blorp_blit.c | 34 ++--<br>
> > > src/intel/blorp/blorp_clear.c | 189<br>
> > +++++++++++++++++--<br>
> > > src/intel/blorp/blorp_genX_<wbr>exec.h | 196<br>
> > ++++++++++---------<br>
> > > src/intel/blorp/blorp_priv.h | 52 ++++-<br>
> > > src/intel/genxml/gen6.xml | 6 +-<br>
> > > src/intel/genxml/gen7.xml | 22 ++-<br>
> > > src/intel/genxml/gen75.xml | 22 ++-<br>
> > > src/intel/genxml/gen8.xml | 16 ++<br>
> > > src/intel/genxml/gen9.xml | 16 ++<br>
> > > src/intel/isl/isl.c | 19 ++<br>
> > > src/intel/isl/isl.h | 11 ++<br>
> > > src/intel/vulkan/Makefile.<wbr>sources | 4 +<br>
> > > src/intel/vulkan/anv_batch_<wbr>chain.c | 4 +-<br>
> > > src/intel/vulkan/anv_blorp.c | 125 +++++++++----<br>
> > > src/intel/vulkan/anv_cmd_<wbr>buffer.c | 74 ++------<br>
> > > src/intel/vulkan/anv_genX.h | 5 +<br>
> > > src/intel/vulkan/anv_image.c | 22 ---<br>
> > > src/intel/vulkan/anv_private.h | 42 ++++-<br>
> > > src/intel/vulkan/gen7_cmd_<wbr>buffer.c | 43 +++--<br>
> > > src/intel/vulkan/gen7_<wbr>pipeline.c | 6 +-<br>
> > > src/intel/vulkan/genX_blorp_<wbr>exec.c | 18 +-<br>
> > > src/intel/vulkan/genX_cmd_<wbr>buffer.c | 229<br>
> > +++++++++++++++++------<br>
> > > src/intel/vulkan/genX_gpu_<wbr>memcpy.c | 223<br>
> > ++++++++++++++++++++++<br>
> > > src/mesa/drivers/dri/i965/brw_<wbr>wm_surface_state.c | 56 +++---<br>
> > > 26 files changed, 1105 insertions(+), 414 deletions(-)<br>
> > > create mode 100644 src/intel/vulkan/genX_gpu_<wbr>memcpy.c<br>
> > ><br>
> > > --<br>
> > > 2.5.0.400.gff86faf<br>
> > ><br>
> > > ______________________________<wbr>_________________<br>
> > > mesa-dev mailing list<br>
> > > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > > <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
> ><br>
</div></div></blockquote></div><br></div></div>