<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 9, 2016 at 3:22 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="m_-9095902559268935855HOEnZb"><div class="m_-9095902559268935855h5">On Tue, Nov 08, 2016 at 06:07:41PM -0800, Jason Ekstrand wrote:<br>
> On Tue, Nov 8, 2016 at 5:16 PM, Nanley Chery <<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>> wrote:<br>
><br>
> > On Tue, Nov 08, 2016 at 05:02:29PM -0800, Jason Ekstrand wrote:<br>
> > > On Tue, Nov 8, 2016 at 5:00 PM, Nanley Chery <<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>><br>
> > wrote:<br>
> > ><br>
> > > > On Tue, Nov 08, 2016 at 04:24:48PM -0800, Jason Ekstrand wrote:<br>
> > > > > On Tue, Nov 8, 2016 at 3:13 PM, Nanley Chery <<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>><br>
> > > > wrote:<br>
> > > > ><br>
> > > > > > On Sat, Oct 22, 2016 at 10:50:37AM -0700, Jason Ekstrand wrote:<br>
> > > > > > > This commit moves the allocation and filling out of surface state<br>
> > > > from<br>
> > > > > > > CreateImageView time to BeginRenderPass time. Instead of<br>
> > allocating<br>
> > > > the<br>
> > > > > > > render target surface state as part of the image view, we<br>
> > allocate<br>
> > > > it in<br>
> > > > > > > the command buffer state at the same time that we set up<br>
> > clears. For<br>
> > > > > > > secondary command buffers, we allocate memory for the surface<br>
> > states<br>
> > > > in<br>
> > > > > > > BeginCommandBuffer but don't fill them out; instead, we use our<br>
> > new<br>
> > > > > > > SOL-based memcpy function to copy the surface states from the<br>
> > primary<br>
> > > > > > > command buffer. This allows us to handle secondary command<br>
> > buffers<br>
> > > > > > without<br>
> > > > > > > the user specifying the framebuffer ahead-of-time.<br>
> > > > > > > ---<br>
> > > > > > > src/intel/vulkan/anv_cmd_buffe<wbr>r.c | 56 ----------<br>
> > > > > > > src/intel/vulkan/anv_image.c | 22 ----<br>
> > > > > > > src/intel/vulkan/anv_private.<wbr>h | 24 ++++-<br>
> > > > > > > src/intel/vulkan/genX_cmd_buff<wbr>er.c | 204<br>
> > > > +++++++++++++++++++++++++++++-<br>
> > > > > > -------<br>
> > > > > > > 4 files changed, 180 insertions(+), 126 deletions(-)<br>
> > > > > > ><br>
> > > > > > > diff --git a/src/intel/vulkan/anv_cmd_buf<wbr>fer.c<br>
> > > > > > b/src/intel/vulkan/anv_cmd_buf<wbr>fer.c<br>
> > > > > > > index a652f9a..372030c 100644<br>
> > > > > > > --- a/src/intel/vulkan/anv_cmd_buf<wbr>fer.c<br>
> > > > > > > +++ b/src/intel/vulkan/anv_cmd_buf<wbr>fer.c<br>
> > > > > > > @@ -144,62 +144,6 @@ anv_cmd_state_reset(struct anv_cmd_buffer<br>
> > > > > > *cmd_buffer)<br>
> > > > > > > state->gen7.index_buffer = NULL;<br>
> > > > > > > }<br>
> > > > > > ><br>
> > > > > > > -/**<br>
> > > > > > > - * Setup anv_cmd_state::attachments for vkCmdBeginRenderPass.<br>
> > > > > > > - */<br>
> > > > > > > -void<br>
> > > > > > > -anv_cmd_state_setup_attachmen<wbr>ts(struct anv_cmd_buffer<br>
> > *cmd_buffer,<br>
> > > > > > > - const VkRenderPassBeginInfo<br>
> > *info)<br>
> > > > > > > -{<br>
> > > > > > > - struct anv_cmd_state *state = &cmd_buffer->state;<br>
> > > > > > > - ANV_FROM_HANDLE(anv_render_pa<wbr>ss, pass, info->renderPass);<br>
> > > > > > > -<br>
> > > > > > > - vk_free(&cmd_buffer->pool->al<wbr>loc, state->attachments);<br>
> > > > > > > -<br>
> > > > > > > - if (pass->attachment_count == 0) {<br>
> > > > > > > - state->attachments = NULL;<br>
> > > > > > > - return;<br>
> > > > > > > - }<br>
> > > > > > > -<br>
> > > > > > > - state->attachments = vk_alloc(&cmd_buffer->pool->al<wbr>loc,<br>
> > > > > > > - pass->attachment_count *<br>
> > > > > > > -<br>
> > > > sizeof(state->attachments[0]),<br>
> > > > > > > - 8, VK_SYSTEM_ALLOCATION_SCOPE_<br>
> > > > > > OBJECT);<br>
> > > > > > > - if (state->attachments == NULL) {<br>
> > > > > > > - /* FIXME: Propagate VK_ERROR_OUT_OF_HOST_MEMORY to<br>
> > > > > > vkEndCommandBuffer */<br>
> > > > > > > - abort();<br>
> > > > > > > - }<br>
> > > > > > > -<br>
> > > > > > > - for (uint32_t i = 0; i < pass->attachment_count; ++i) {<br>
> > > > > > > - struct anv_render_pass_attachment *att =<br>
> > > > &pass->attachments[i];<br>
> > > > > > > - VkImageAspectFlags att_aspects =<br>
> > > > vk_format_aspects(att->format)<wbr>;<br>
> > > > > > > - VkImageAspectFlags clear_aspects = 0;<br>
> > > > > > > -<br>
> > > > > > > - if (att_aspects == VK_IMAGE_ASPECT_COLOR_BIT) {<br>
> > > > > > > - /* color attachment */<br>
> > > > > > > - if (att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {<br>
> > > > > > > - clear_aspects |= VK_IMAGE_ASPECT_COLOR_BIT;<br>
> > > > > > > - }<br>
> > > > > > > - } else {<br>
> > > > > > > - /* depthstencil attachment */<br>
> > > > > > > - if ((att_aspects & VK_IMAGE_ASPECT_DEPTH_BIT) &&<br>
> > > > > > > - att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {<br>
> > > > > > > - clear_aspects |= VK_IMAGE_ASPECT_DEPTH_BIT;<br>
> > > > > > > - }<br>
> > > > > > > - if ((att_aspects & VK_IMAGE_ASPECT_STENCIL_BIT) &&<br>
> > > > > > > - att->stencil_load_op ==<br>
> > VK_ATTACHMENT_LOAD_OP_CLEAR) {<br>
> > > > > > > - clear_aspects |= VK_IMAGE_ASPECT_STENCIL_BIT;<br>
> > > > > > > - }<br>
> > > > > > > - }<br>
> > > > > > > -<br>
> > > > > > > - state->attachments[i].pending_<wbr>clear_aspects =<br>
> > clear_aspects;<br>
> > > > > > > - if (clear_aspects) {<br>
> > > > > > > - assert(info->clearValueCount > i);<br>
> > > > > > > - state->attachments[i].clear_v<wbr>alue =<br>
> > info->pClearValues[i];<br>
> > > > > > > - }<br>
> > > > > > > - }<br>
> > > > > > > -}<br>
> > > > > > > -<br>
> > > > > > > VkResult<br>
> > > > > > > anv_cmd_buffer_ensure_push_con<wbr>stants_size(struct anv_cmd_buffer<br>
> > > > > > *cmd_buffer,<br>
> > > > > > > gl_shader_stage stage,<br>
> > > > > > uint32_t size)<br>
> > > > > > > diff --git a/src/intel/vulkan/anv_image.c<br>
> > > > b/src/intel/vulkan/anv_image.c<br>
> > > > > > > index b7c2e99..b014985 100644<br>
> > > > > > > --- a/src/intel/vulkan/anv_image.c<br>
> > > > > > > +++ b/src/intel/vulkan/anv_image.c<br>
> > > > > > > @@ -504,23 +504,6 @@ anv_CreateImageView(VkDevice _device,<br>
> > > > > > > iview->sampler_surface_state.a<wbr>lloc_size = 0;<br>
> > > > > > > }<br>
> > > > > > ><br>
> > > > > > > - if (image->usage & VK_IMAGE_USAGE_COLOR_ATTACHMEN<wbr>T_BIT) {<br>
> > > > > > > - iview->color_rt_surface_state =<br>
> > alloc_surface_state(device);<br>
> > > > > > > -<br>
> > > > > > > - struct isl_view view = iview->isl;<br>
> > > > > > > - view.usage |= ISL_SURF_USAGE_RENDER_TARGET_B<wbr>IT;<br>
> > > > > > > - isl_surf_fill_state(&device->i<wbr>sl_dev,<br>
> > > > > > > - iview->color_rt_surface_state.<wbr>map,<br>
> > > > > > > - .surf = &surface->isl,<br>
> > > > > > > - .view = &view,<br>
> > > > > > > - .mocs = device->default_mocs);<br>
> > > > > > > -<br>
> > > > > > > - if (!device->info.has_llc)<br>
> > > > > > > - anv_state_clflush(iview->colo<wbr>r_rt_surface_state);<br>
> > > > > > > - } else {<br>
> > > > > > > - iview->color_rt_surface_state.<wbr>alloc_size = 0;<br>
> > > > > > > - }<br>
> > > > > > > -<br>
> > > > > > > /* NOTE: This one needs to go last since it may stomp<br>
> > > > > > isl_view.format */<br>
> > > > > > > if (image->usage & VK_IMAGE_USAGE_STORAGE_BIT) {<br>
> > > > > > > iview->storage_surface_state =<br>
> > alloc_surface_state(device);<br>
> > > > > > > @@ -565,11 +548,6 @@ anv_DestroyImageView(VkDevice _device,<br>
> > > > VkImageView<br>
> > > > > > _iview,<br>
> > > > > > > ANV_FROM_HANDLE(anv_device, device, _device);<br>
> > > > > > > ANV_FROM_HANDLE(anv_image_vie<wbr>w, iview, _iview);<br>
> > > > > > ><br>
> > > > > > > - if (iview->color_rt_surface_state<wbr>.alloc_size > 0) {<br>
> > > > > > > - anv_state_pool_free(&device->s<wbr>urface_state_pool,<br>
> > > > > > > - iview->color_rt_surface_state)<wbr>;<br>
> > > > > > > - }<br>
> > > > > > > -<br>
> > > > > > > if (iview->sampler_surface_state.<wbr>alloc_size > 0) {<br>
> > > > > > > anv_state_pool_free(&device->s<wbr>urface_state_pool,<br>
> > > > > > > iview->sampler_surface_state);<br>
> > > > > > > diff --git a/src/intel/vulkan/anv_private<wbr>.h<br>
> > b/src/intel/vulkan/anv_<br>
> > > > > > private.h<br>
> > > > > > > index a6611f1..2a98ea1 100644<br>
> > > > > > > --- a/src/intel/vulkan/anv_private<wbr>.h<br>
> > > > > > > +++ b/src/intel/vulkan/anv_private<wbr>.h<br>
> > > > > > > @@ -1059,6 +1059,8 @@ void anv_dynamic_state_copy(struct<br>
> > > > > > anv_dynamic_state *dest,<br>
> > > > > > > * The clear value is valid only if there exists a pending<br>
> > clear.<br>
> > > > > > > */<br>
> > > > > > > struct anv_attachment_state {<br>
> > > > > > > + struct anv_state color_rt_state;<br>
> > > > > > > +<br>
> > > > > > > VkImageAspectFlags<br>
> > > > pending_clear_aspects;<br>
> > > > > > > VkClearValue clear_value;<br>
> > > > > > > };<br>
> > > > > > > @@ -1099,6 +1101,19 @@ struct anv_cmd_state {<br>
> > > > > > > */<br>
> > > > > > > struct anv_attachment_state * attachments;<br>
> > > > > > ><br>
> > > > > > > + /**<br>
> > > > > > > + * Surface states for color render targets. These are<br>
> > stored in<br>
> > > > a<br>
> > > > > > single<br>
> > > > > > > + * flat array. For depth-stencil attachments, the surface<br>
> > state<br>
> > > > is<br>
> > > > > > simply<br>
> > > > > > > + * left blank.<br>
> > > > > > > + */<br>
> > > > > > > + struct anv_state<br>
> > render_pass_states;<br>
> > > > > > > +<br>
> > > > > > > + /**<br>
> > > > > > > + * A null surface state of the right size to match the<br>
> > > > framebuffer.<br>
> > > > > > This<br>
> > > > > > > + * is one of the states in render_pass_states.<br>
> > > > > > > + */<br>
> > > > > > > + struct anv_state<br>
> > null_surface_state;<br>
> > > > > > > +<br>
> > > > > > > struct {<br>
> > > > > > > struct anv_buffer * index_buffer;<br>
> > > > > > > uint32_t index_type; /**<<br>
> > > > > > 3DSTATE_INDEX_BUFFER.IndexForm<wbr>at */<br>
> > > > > > > @@ -1237,8 +1252,10 @@ void gen8_cmd_buffer_emit_depth_<br>
> > > > viewport(struct<br>
> > > > > > anv_cmd_buffer *cmd_buffer,<br>
> > > > > > > bool<br>
> > depth_clamp_enable);<br>
> > > > > > > void gen7_cmd_buffer_emit_scissor(s<wbr>truct anv_cmd_buffer<br>
> > > > *cmd_buffer);<br>
> > > > > > ><br>
> > > > > > > -void anv_cmd_state_setup_attachment<wbr>s(struct anv_cmd_buffer<br>
> > > > *cmd_buffer,<br>
> > > > > > > - const VkRenderPassBeginInfo<br>
> > > > *info);<br>
> > > > > > > +void anv_cmd_buffer_setup_attachmen<wbr>ts(struct anv_cmd_buffer<br>
> > > > > > *cmd_buffer,<br>
> > > > > > > + struct anv_render_pass<br>
> > *pass,<br>
> > > > > > > + struct anv_framebuffer<br>
> > > > > > *framebuffer,<br>
> > > > > > > + const VkClearValue<br>
> > > > *clear_values);<br>
> > > > > > ><br>
> > > > > > > struct anv_state<br>
> > > > > > > anv_cmd_buffer_push_constants(<wbr>struct anv_cmd_buffer<br>
> > *cmd_buffer,<br>
> > > > > > > @@ -1549,9 +1566,6 @@ struct anv_image_view {<br>
> > > > > > > VkFormat vk_format;<br>
> > > > > > > VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::<br>
> > > > baseMipLevel.<br>
> > > > > > */<br>
> > > > > > ><br>
> > > > > > > - /** RENDER_SURFACE_STATE when using image as a color render<br>
> > > > target.<br>
> > > > > > */<br>
> > > > > > > - struct anv_state color_rt_surface_state;<br>
> > > > > > > -<br>
> > > > > > > /** RENDER_SURFACE_STATE when using image as a sampler<br>
> > surface.<br>
> > > > */<br>
> > > > > > > struct anv_state sampler_surface_state;<br>
> > > > > > ><br>
> > > > > > > diff --git a/src/intel/vulkan/genX_cmd_bu<wbr>ffer.c<br>
> > > > > > b/src/intel/vulkan/genX_cmd_bu<wbr>ffer.c<br>
> > > > > > > index 8734389..78b9bcc 100644<br>
> > > > > > > --- a/src/intel/vulkan/genX_cmd_bu<wbr>ffer.c<br>
> > > > > > > +++ b/src/intel/vulkan/genX_cmd_bu<wbr>ffer.c<br>
> > > > > > > @@ -25,6 +25,7 @@<br>
> > > > > > > #include <stdbool.h><br>
> > > > > > ><br>
> > > > > > > #include "anv_private.h"<br>
> > > > > > > +#include "vk_format_info.h"<br>
> > > > > > ><br>
> > > > > > > #include "common/gen_l3_config.h"<br>
> > > > > > > #include "genxml/gen_macros.h"<br>
> > > > > > > @@ -150,6 +151,142 @@ genX(cmd_buffer_emit_state_<br>
> > > > base_address)(struct<br>
> > > > > > anv_cmd_buffer *cmd_buffer)<br>
> > > > > > > }<br>
> > > > > > > }<br>
> > > > > > ><br>
> > > > > > > +/**<br>
> > > > > > > + * Setup anv_cmd_state::attachments for vkCmdBeginRenderPass.<br>
> > > > > > > + */<br>
> > > > > > > +static void<br>
> > > > > > > +genX(cmd_buffer_setup_attachm<wbr>ents)(struct anv_cmd_buffer<br>
> > > > *cmd_buffer,<br>
> > > > > > > + struct anv_render_pass *pass,<br>
> > > > > > > + struct anv_framebuffer<br>
> > > > *framebuffer,<br>
> > > > > > > + const VkClearValue<br>
> > *clear_values)<br>
> > > > > > > +{<br>
> > > > > > > + const struct isl_device *isl_dev =<br>
> > &cmd_buffer->device->isl_dev;<br>
> > > > > > > + struct anv_cmd_state *state = &cmd_buffer->state;<br>
> > > > > > > +<br>
> > > > > > > + vk_free(&cmd_buffer->pool->al<wbr>loc, state->attachments);<br>
> > > > > > > +<br>
> > > > > > > + if (pass->attachment_count == 0) {<br>
> > > > > > > + state->attachments = NULL;<br>
> > > > > > > + return;<br>
> > > > > > > + }<br>
> > > > > > > +<br>
> > > > > > > + state->attachments = vk_alloc(&cmd_buffer->pool->al<wbr>loc,<br>
> > > > > > > + pass->attachment_count *<br>
> > > > > > > +<br>
> > sizeof(state->attachments[0]),<br>
> > > > > > > + 8, VK_SYSTEM_ALLOCATION_SCOPE_<br>
> > > > OBJECT);<br>
> > > > > > > + if (state->attachments == NULL) {<br>
> > > > > > > + /* FIXME: Propagate VK_ERROR_OUT_OF_HOST_MEMORY to<br>
> > > > > > vkEndCommandBuffer */<br>
> > > > > > > + abort();<br>
> > > > > > > + }<br>
> > > > > > > +<br>
> > > > > > > + bool need_null_state = false;<br>
> > > > > > > + for (uint32_t s = 0; s < pass->subpass_count; ++s) {<br>
> > > > > > > + if (pass->subpasses[s].color_coun<wbr>t == 0) {<br>
> > > > > > > + need_null_state = true;<br>
> > > > > > > + break;<br>
> > > > > > > + }<br>
> > > > > > > + }<br>
> > > > > > > +<br>
> > > > > > > + unsigned num_states = need_null_state;<br>
> > > > > > > + for (uint32_t i = 0; i < pass->attachment_count; ++i) {<br>
> > > > > > > + if (vk_format_is_color(pass->atta<wbr>chments[i].format))<br>
> > > > > > > + num_states++;<br>
> > > > > > > + }<br>
> > > > > > > +<br>
> > > > > > > + const uint32_t ss_stride = align_u32(isl_dev->ss.size,<br>
> > > > > > isl_dev->ss.align);<br>
> > > > > > > + state->render_pass_states =<br>
> > > > > > > + anv_state_stream_alloc(&cmd_bu<wbr>ffer->surface_state_stream,<br>
> > > > > > > + num_states * ss_stride,<br>
> > > > isl_dev->ss.align);<br>
> > > > > > > +<br>
> > > > > > > + struct anv_state next_state = state->render_pass_states;<br>
> > > > > > > + next_state.alloc_size = isl_dev->ss.size;<br>
> > > > > > > +<br>
> > > > > > > + if (need_null_state) {<br>
> > > > > > > + state->null_surface_state = next_state;<br>
> > > > > > > + next_state.offset += ss_stride;<br>
> > > > > > > + next_state.map += ss_stride;<br>
> > > > > > > + }<br>
> > > > > > > +<br>
> > > > > > > + for (uint32_t i = 0; i < pass->attachment_count; ++i) {<br>
> > > > > > > + if (vk_format_is_color(pass->atta<wbr>chments[i].format)) {<br>
> > > > > > > + state->attachments[i].color_r<wbr>t_state = next_state;<br>
> > > > > > > + next_state.offset += ss_stride;<br>
> > > > > > > + next_state.map += ss_stride;<br>
> > > > > > > + }<br>
> > > > > > > + }<br>
> > > > > > > + assert(next_state.offset == state->render_pass_states.offs<wbr>et<br>
> > +<br>
> > > > > > > + state->render_pass_states.<br>
> > > > alloc_size);<br>
> > > > > > > +<br>
> > > > > > > + if (framebuffer) {<br>
> > > > > > > + assert(pass->attachment_count ==<br>
> > > > framebuffer->attachment_count)<wbr>;<br>
> > > > > > > +<br>
> > > > > > > + if (need_null_state) {<br>
> > > > > > > + struct GENX(RENDER_SURFACE_STATE) null_ss = {<br>
> > > > > > > + .SurfaceType = SURFTYPE_NULL,<br>
> > > > > > > + .SurfaceArray = framebuffer->layers > 0,<br>
> > > > > > > + .SurfaceFormat = ISL_FORMAT_R8G8B8A8_UNORM,<br>
> > > > > > > +#if GEN_GEN >= 8<br>
> > > > > > > + .TileMode = YMAJOR,<br>
> > > > > > > +#else<br>
> > > > > > > + .TiledSurface = true,<br>
> > > > > > > +#endif<br>
> > > > > > > + .Width = framebuffer->width - 1,<br>
> > > > > > > + .Height = framebuffer->height - 1,<br>
> > > > > > > + .Depth = framebuffer->layers - 1,<br>
> > > > > > > + .RenderTargetViewExtent = framebuffer->layers - 1,<br>
> > > > > > > + };<br>
> > > > > > > + GENX(RENDER_SURFACE_STATE_pac<wbr>k)(NULL,<br>
> > > > > > state->null_surface_state.map,<br>
> > > > > > > + &null_ss);<br>
> > > > > > > + }<br>
> > > > > > > +<br>
> > > > > > > + for (uint32_t i = 0; i < pass->attachment_count; ++i) {<br>
> > > > > > > + struct anv_render_pass_attachment *att =<br>
> > > > &pass->attachments[i];<br>
> > > > > > > + VkImageAspectFlags att_aspects =<br>
> > > > vk_format_aspects(att->format)<br>
> > > > > > ;<br>
> > > > > > > + VkImageAspectFlags clear_aspects = 0;<br>
> > > > > > > +<br>
> > > > > > > + if (att_aspects == VK_IMAGE_ASPECT_COLOR_BIT) {<br>
> > > > > > > + /* color attachment */<br>
> > > > > > > + if (att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {<br>
> > > > > > > + clear_aspects |= VK_IMAGE_ASPECT_COLOR_BIT;<br>
> > > > > > > + }<br>
> > > > > > > + } else {<br>
> > > > > > > + /* depthstencil attachment */<br>
> > > > > > > + if ((att_aspects & VK_IMAGE_ASPECT_DEPTH_BIT) &&<br>
> > > > > > > + att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {<br>
> > > > > > > + clear_aspects |= VK_IMAGE_ASPECT_DEPTH_BIT;<br>
> > > > > > > + }<br>
> > > > > > > + if ((att_aspects & VK_IMAGE_ASPECT_STENCIL_BIT) &&<br>
> > > > > > > + att->stencil_load_op ==<br>
> > > > VK_ATTACHMENT_LOAD_OP_CLEAR) {<br>
> > > > > > > + clear_aspects |= VK_IMAGE_ASPECT_STENCIL_BIT;<br>
> > > > > > > + }<br>
> > > > > > > + }<br>
> > > > > > > +<br>
> > > > > > > + state->attachments[i].<wbr>pending_clear_aspects =<br>
> > > > clear_aspects;<br>
> > > > > > > + if (clear_aspects)<br>
> > > > > > > + state->attachments[i].clear_va<wbr>lue =<br>
> > clear_values[i];<br>
> > > > > > > +<br>
> > > > > > > + struct anv_image_view *iview =<br>
> > framebuffer->attachments[i];<br>
> > > > > > > + assert(iview->image->vk_<wbr>format == att->format);<br>
> > > > > ><br>
> > > > > > This assertion fails when running Dota 2 on your wip/anv-null-fb<br>
> > > > branch.<br>
> > > > > > I don't know if this branch is the most up-to-date version of this<br>
> > > > > > series, but it was the easiest way to test it (I couldn't get the<br>
> > > > mailing<br>
> > > > > > list patches to apply with git am). Are you able to reproduce this?<br>
> > > > > ><br>
> > > > ><br>
> > > > > That's odd... I haven't seen that and I have run dota2 with CCS on<br>
> > top of<br>
> > > > > this branch but may be not in a debug build. What are the two<br>
> > formats<br>
> > > > when<br>
> > > > > it fails? I suppose it's possible that it's ATTACHMENT_UNUSED or<br>
> > > > something.<br>
> > > > ><br>
> > > ><br>
> > > > (gdb) p iview->image->vk_format<br>
> > > > $1 = VK_FORMAT_B8G8R8A8_SRGB<br>
> > > > (gdb) p att->format<br>
> > > > $2 = VK_FORMAT_B8G8R8A8_UNORM<br>
> > > ><br>
> > ><br>
> > > Ugh... Looks like that assertion is invalid. The format of the view<br>
> > needs<br>
> > > to match but not necesaraly the format of the image. I'll change it to<br>
> > > "assert(iview->vk_format == att->format);"<br>
> > ><br>
> ><br>
> > I unfortunately still get a failure with the new assertion:<br>
> ><br>
> > (gdb) p iview->vk_format<br>
> > $1 = VK_FORMAT_D24_UNORM_S8_UINT<br>
> > (gdb) p att->format<br>
> > $2 = VK_FORMAT_D32_SFLOAT_S8_UINT<br>
> ><br>
><br>
> That looks a lot like a real dota2 bug... Those formats aren't even the<br>
> same size. If we can confirm that they're really giving us a mismatched<br>
> render pass and framebuffer, I'll talk to the guys at Valve. We should<br>
> also file a bug against the validation layers.<br>
><br>
<br>
</div></div>Yes, this looks like a bug indeed. The validation layer seems to catch a<br>
number of these errors. Here's one for example:<br>
<br>
DS(ERROR): object: 0x4e97 type: 19 location: 3207 msgCode: 50: At Draw<br>
time the active render pass (0x4e7d) is incompatible w/ gfx pipeline<br>
(0x4e97) that was created w/ render pass (0x3e84) due to: color<br>
attachments at index 0 of subpass index 0 are not compatible.<br>
<br>
My Dota2 may not be up-to-date however, so this problem still needs to<br>
be confirmed on the latest version.<span class="m_-9095902559268935855HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>I just ran Dota2 as of some time last week against my wip/anv-null-fb (this series) with the fixed assertion, and it triggered. I'll get a hold of my contact at Valve. For some reason, the validation layer isn't catching it for me. Maybe I don't have it turned on properly.<br><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="m_-9095902559268935855HOEnZb"><font color="#888888">
- Nanley<br>
</font></span><div class="m_-9095902559268935855HOEnZb"><div class="m_-9095902559268935855h5"><br>
> --Jason<br>
><br>
><br>
> > > --Jason<br>
> > ><br>
> > ><br>
> > > > ><br>
> > > > > > - Nanley<br>
> > > > > ><br>
> > > > > > > +<br>
> > > > > > > + if (att_aspects == VK_IMAGE_ASPECT_COLOR_BIT) {<br>
> > > > > > > + struct isl_view view = iview->isl;<br>
> > > > > > > + view.usage |= ISL_SURF_USAGE_RENDER_TARGET_B<wbr>IT;<br>
> > > > > > > + isl_surf_fill_state(isl_dev,<br>
> > > > > > > + state->attachments[i].color_<br>
> > > > > > rt_state.map,<br>
> > > > > > > + .surf =<br>
> > > > &iview->image->color_surface.<br>
> > > > > > isl,<br>
> > > > > > > + .view = &view,<br>
> > > > > > > + .mocs =<br>
> > cmd_buffer->device->default_<br>
> > > > > > mocs);<br>
> > > > > > > +<br>
> > > > > > > + anv_cmd_buffer_add_surface_sta<wbr>te_reloc(cmd_buffer,<br>
> > > > > > > + state->attachments[i].color_r<wbr>t_state, iview->bo,<br>
> > > > > > iview->offset);<br>
> > > > > > > + }<br>
> > > > > > > + }<br>
> > > > > > > +<br>
> > > > > > > + if (!cmd_buffer->device->info.has<wbr>_llc)<br>
> > > > > > > + anv_state_clflush(state->rend<wbr>er_pass_states);<br>
> > > > > > > + }<br>
> > > > > > > +}<br>
> > > > > > > +<br>
> > > > > > > VkResult<br>
> > > > > > > genX(BeginCommandBuffer)(<br>
> > > > > > > VkCommandBuffer commandBuffer,<br>
> > > > > > > @@ -189,6 +326,9 @@ genX(BeginCommandBuffer)(<br>
> > > > > > > cmd_buffer->state.subpass =<br>
> > > > > > > &cmd_buffer->state.pass->subp<wbr>asses[pBeginInfo-><br>
> > > > > > pInheritanceInfo->subpass];<br>
> > > > > > ><br>
> > > > > > > + genX(cmd_buffer_setup_attachme<wbr>nts)(cmd_buffer,<br>
> > > > > > cmd_buffer->state.pass,<br>
> > > > > > > + NULL, NULL);<br>
> > > > > > > +<br>
> > > > > > > cmd_buffer->state.dirty |= ANV_CMD_DIRTY_RENDER_TARGETS;<br>
> > > > > > > }<br>
> > > > > > ><br>
> > > > > > > @@ -232,6 +372,22 @@ genX(CmdExecuteCommands)(<br>
> > > > > > ><br>
> > > > > > > assert(secondary->level == VK_COMMAND_BUFFER_LEVEL_<br>
> > > > SECONDARY);<br>
> > > > > > ><br>
> > > > > > > + if (secondary->usage_flags &<br>
> > > > > > > + VK_COMMAND_BUFFER_USAGE_RENDER<wbr>_PASS_CONTINUE_BIT) {<br>
> > > > > > > + /* If we're continuing a render pass from the primary,<br>
> > we<br>
> > > > need<br>
> > > > > > to<br>
> > > > > > > + * copy the surface states for the current subpass<br>
> > into the<br>
> > > > > > storage<br>
> > > > > > > + * we allocated for them in BeginCommandBuffer.<br>
> > > > > > > + */<br>
> > > > > > > + struct anv_bo *ss_bo = &primary->device->surface_<br>
> > > > > > <a href="http://state_block_pool.bo" rel="noreferrer" target="_blank">state_block_pool.bo</a>;<br>
> > > > > > > + struct anv_state src_state =<br>
> > primary->state.render_pass_<br>
> > > > > > states;<br>
> > > > > > > + struct anv_state dst_state =<br>
> > secondary->state.render_pass_<br>
> > > > > > states;<br>
> > > > > > > + assert(src_state.alloc_size == dst_state.alloc_size);<br>
> > > > > > > +<br>
> > > > > > > + genX(cmd_buffer_gpu_memcpy)(p<wbr>rimary, ss_bo,<br>
> > > > dst_state.offset,<br>
> > > > > > > + ss_bo, src_state.offset,<br>
> > > > > > > + src_state.alloc_size);<br>
> > > > > > > + }<br>
> > > > > > > +<br>
> > > > > > > anv_cmd_buffer_add_secondary(p<wbr>rimary, secondary);<br>
> > > > > > > }<br>
> > > > > > ><br>
> > > > > > > @@ -628,43 +784,11 @@ cmd_buffer_alloc_push_constant<wbr>s(struct<br>
> > > > > > anv_cmd_buffer *cmd_buffer)<br>
> > > > > > > cmd_buffer->state.push_consta<wbr>nts_dirty |=<br>
> > > > > > VK_SHADER_STAGE_ALL_GRAPHICS;<br>
> > > > > > > }<br>
> > > > > > ><br>
> > > > > > > -static struct anv_state<br>
> > > > > > > -alloc_null_surface_state(stru<wbr>ct anv_cmd_buffer *cmd_buffer,<br>
> > > > > > > - struct anv_framebuffer *fb)<br>
> > > > > > > -{<br>
> > > > > > > - struct anv_state state =<br>
> > > > > > > - anv_cmd_buffer_alloc_surface_s<wbr>tate(cmd_buffer);<br>
> > > > > > > -<br>
> > > > > > > - struct GENX(RENDER_SURFACE_STATE) null_ss = {<br>
> > > > > > > - .SurfaceType = SURFTYPE_NULL,<br>
> > > > > > > - .SurfaceArray = fb->layers > 0,<br>
> > > > > > > - .SurfaceFormat = ISL_FORMAT_R8G8B8A8_UNORM,<br>
> > > > > > > -#if GEN_GEN >= 8<br>
> > > > > > > - .TileMode = YMAJOR,<br>
> > > > > > > -#else<br>
> > > > > > > - .TiledSurface = true,<br>
> > > > > > > -#endif<br>
> > > > > > > - .Width = fb->width - 1,<br>
> > > > > > > - .Height = fb->height - 1,<br>
> > > > > > > - .Depth = fb->layers - 1,<br>
> > > > > > > - .RenderTargetViewExtent = fb->layers - 1,<br>
> > > > > > > - };<br>
> > > > > > > -<br>
> > > > > > > - GENX(RENDER_SURFACE_STATE_pac<wbr>k)(NULL, state.map, &null_ss);<br>
> > > > > > > -<br>
> > > > > > > - if (!cmd_buffer->device->info.has<wbr>_llc)<br>
> > > > > > > - anv_state_clflush(state);<br>
> > > > > > > -<br>
> > > > > > > - return state;<br>
> > > > > > > -}<br>
> > > > > > > -<br>
> > > > > > > -<br>
> > > > > > > static VkResult<br>
> > > > > > > emit_binding_table(struct anv_cmd_buffer *cmd_buffer,<br>
> > > > > > > gl_shader_stage stage,<br>
> > > > > > > struct anv_state *bt_state)<br>
> > > > > > > {<br>
> > > > > > > - struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;<br>
> > > > > > > struct anv_subpass *subpass = cmd_buffer->state.subpass;<br>
> > > > > > > struct anv_pipeline *pipeline;<br>
> > > > > > > uint32_t bias, state_offset;<br>
> > > > > > > @@ -743,17 +867,10 @@ emit_binding_table(struct anv_cmd_buffer<br>
> > > > > > *cmd_buffer,<br>
> > > > > > > assert(stage == MESA_SHADER_FRAGMENT);<br>
> > > > > > > assert(binding->binding == 0);<br>
> > > > > > > if (binding->index < subpass->color_count) {<br>
> > > > > > > - const struct anv_image_view *iview =<br>
> > > > > > > - fb->attachments[subpass-><br>
> > color_attachments[binding-><br>
> > > > > > index]];<br>
> > > > > > > -<br>
> > > > > > > - assert(iview->color_rt_surface<wbr>_state.alloc_size);<br>
> > > > > > > - surface_state = iview->color_rt_surface_state;<br>
> > > > > > > - anv_cmd_buffer_add_surface_sta<wbr>te_reloc(cmd_buffer,<br>
> > > > > > surface_state,<br>
> > > > > > > - iview->bo,<br>
> > > > > > iview->offset);<br>
> > > > > > > + const unsigned att = subpass->color_attachments[<br>
> > > > > > binding->index];<br>
> > > > > > > + surface_state = cmd_buffer->state.attachments[<br>
> > > > > > att].color_rt_state;<br>
> > > > > > > } else {<br>
> > > > > > > - /* Null render target */<br>
> > > > > > > - struct anv_framebuffer *fb =<br>
> > > > cmd_buffer->state.framebuffer;<br>
> > > > > > > - surface_state = alloc_null_surface_state(cmd_<br>
> > buffer,<br>
> > > > fb);<br>
> > > > > > > + surface_state = cmd_buffer->state.null_<br>
> > surface_state;<br>
> > > > > > > }<br>
> > > > > > ><br>
> > > > > > > bt_map[bias + s] = surface_state.offset + state_offset;<br>
> > > > > > > @@ -1837,7 +1954,8 @@ void genX(CmdBeginRenderPass)(<br>
> > > > > > > cmd_buffer->state.framebuffer = framebuffer;<br>
> > > > > > > cmd_buffer->state.pass = pass;<br>
> > > > > > > cmd_buffer->state.render_area = pRenderPassBegin->renderArea;<br>
> > > > > > > - anv_cmd_state_setup_attachmen<wbr>ts(cmd_buffer,<br>
> > pRenderPassBegin);<br>
> > > > > > > + genX(cmd_buffer_setup_attachm<wbr>ents)(cmd_buffer, pass,<br>
> > > > framebuffer,<br>
> > > > > > > + pRenderPassBegin-><br>
> > > > pClearValues);<br>
> > > > > > ><br>
> > > > > > > genX(flush_pipeline_select_<wbr>3d)(cmd_buffer);<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" target="_blank">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>
> > > ><br>
> ><br>
</div></div></blockquote></div><br></div></div>