<p dir="ltr"></p>
<p dir="ltr">On Oct 25, 2016 2:18 AM, "Pohjolainen, Topi" <<a href="mailto:topi.pohjolainen@gmail.com">topi.pohjolainen@gmail.com</a>> wrote:<br>
><br>
> On Sat, Oct 22, 2016 at 10:50:32AM -0700, Jason Ekstrand wrote:<br>
> > Signed-off-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
> > ---<br>
> > src/intel/blorp/blorp_genX_exec.h | 33 ++++----------<br>
> > src/intel/isl/isl.c | 19 ++++++++<br>
> > src/intel/isl/isl.h | 11 +++++<br>
> > src/intel/vulkan/anv_batch_chain.c | 4 +-<br>
> > src/intel/vulkan/genX_cmd_buffer.c | 8 +---<br>
> > src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 56 +++++++++++-------------<br>
> > 6 files changed, 69 insertions(+), 62 deletions(-)<br>
> ><br>
> > diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h<br>
> > index ec0d022..d455714 100644<br>
> > --- a/src/intel/blorp/blorp_genX_exec.h<br>
> > +++ b/src/intel/blorp/blorp_genX_exec.h<br>
> > @@ -995,28 +995,13 @@ blorp_emit_depth_stencil_state(struct blorp_batch *batch,<br>
> > return offset;<br>
> > }<br>
> ><br>
> > -struct surface_state_info {<br>
> > - unsigned num_dwords;<br>
> > - unsigned ss_align; /* Required alignment of RENDER_SURFACE_STATE in bytes */<br>
> > - unsigned reloc_dw;<br>
> > - unsigned aux_reloc_dw;<br>
> > -};<br>
> > -<br>
> > -static const struct surface_state_info surface_state_infos[] = {<br>
> > - [6] = {6, 32, 1, 0},<br>
> > - [7] = {8, 32, 1, 6},<br>
> > - [8] = {13, 64, 8, 10},<br>
> > - [9] = {16, 64, 8, 10},<br>
> > -};<br>
> > -<br>
> > static void<br>
> > blorp_emit_surface_state(struct blorp_batch *batch,<br>
> > const struct brw_blorp_surface_info *surface,<br>
> > - uint32_t *state, uint32_t state_offset,<br>
> > + void *state, uint32_t state_offset,<br>
> > bool is_render_target)<br>
> > {<br>
> > - const struct surface_state_info ss_info = surface_state_infos[GEN_GEN];<br>
> > -<br>
> > + const struct isl_device *isl_dev = batch->blorp->isl_dev;<br>
> > struct isl_surf surf = surface->surf;<br>
> ><br>
> > if (surf.dim == ISL_SURF_DIM_1D &&<br>
> > @@ -1038,7 +1023,7 @@ blorp_emit_surface_state(struct blorp_batch *batch,<br>
> > .aux_surf = &surface->aux_surf, .aux_usage = aux_usage,<br>
> > .mocs = mocs, .clear_color = surface->clear_color);<br>
> ><br>
> > - blorp_surface_reloc(batch, state_offset + ss_info.reloc_dw * 4,<br>
> > + blorp_surface_reloc(batch, state_offset + isl_dev->ss.addr_offset,<br>
> > surface->addr, 0);<br>
> ><br>
> > if (aux_usage != ISL_AUX_USAGE_NONE) {<br>
> > @@ -1047,8 +1032,9 @@ blorp_emit_surface_state(struct blorp_batch *batch,<br>
> > * surface buffer addresses are always 4K page alinged.<br>
> > */<br>
> > assert((surface->aux_addr.offset & 0xfff) == 0);<br>
> > - blorp_surface_reloc(batch, state_offset + ss_info.aux_reloc_dw * 4,<br>
> > - surface->aux_addr, state[ss_info.aux_reloc_dw]);<br>
> > + uint32_t *aux_addr = state + isl_dev->ss.aux_addr_offset;<br>
><br>
> Previously 'state' got indexed in dwords (ss_info.aux_reloc_dw). Now this<br>
> uses 'isl_dev->ss.aux_addr_offset' instead (which is in number of bytes).<br>
> Aren't we offsetting four times too far?</p>
<p dir="ltr">No. State is now a void* (See above)</p>
<p dir="ltr">> > + blorp_surface_reloc(batch, state_offset + isl_dev->ss.aux_addr_offset,<br>
> > + surface->aux_addr, *aux_addr);<br>
> > }<br>
> > }<br>
> ><br>
> > @@ -1086,14 +1072,13 @@ static void<br>
> > blorp_emit_surface_states(struct blorp_batch *batch,<br>
> > const struct blorp_params *params)<br>
> > {<br>
> > + const struct isl_device *isl_dev = batch->blorp->isl_dev;<br>
> > uint32_t bind_offset, surface_offsets[2];<br>
> > void *surface_maps[2];<br>
> ><br>
> > - const unsigned ss_size = GENX(RENDER_SURFACE_STATE_length) * 4;<br>
> > - const unsigned ss_align = GENX(RENDER_SURFACE_STATE_length) > 8 ? 64 : 32;<br>
> > -<br>
> > unsigned num_surfaces = 1 + params->src.enabled;<br>
> > - blorp_alloc_binding_table(batch, num_surfaces, ss_size, ss_align,<br>
> > + blorp_alloc_binding_table(batch, num_surfaces,<br>
> > + isl_dev->ss.size, isl_dev->ss.align,<br>
> > &bind_offset, surface_offsets, surface_maps);<br>
> ><br>
> > if (params->dst.enabled) {<br>
> > diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c<br>
> > index 7831c5e..ec53072 100644<br>
> > --- a/src/intel/isl/isl.c<br>
> > +++ b/src/intel/isl/isl.c<br>
> > @@ -46,6 +46,20 @@ __isl_finishme(const char *file, int line, const char *fmt, ...)<br>
> > fprintf(stderr, "%s:%d: FINISHME: %s\n", file, line, buf);<br>
> > }<br>
> ><br>
> > +static const struct {<br>
> > + uint8_t size;<br>
> > + uint8_t align;<br>
> > + uint8_t addr_offset;<br>
> > + uint8_t aux_addr_offset;<br>
> > +} ss_infos[] = {<br>
> > + [4] = {24, 32, 4},<br>
> > + [5] = {24, 32, 4},<br>
> > + [6] = {24, 32, 4},<br>
> > + [7] = {32, 32, 4, 24},<br>
> > + [8] = {52, 64, 32, 40},<br>
> > + [9] = {64, 64, 32, 40},<br>
> > +};<br>
> > +<br>
> > void<br>
> > isl_device_init(struct isl_device *dev,<br>
> > const struct gen_device_info *info,<br>
> > @@ -67,6 +81,11 @@ isl_device_init(struct isl_device *dev,<br>
> > assert(info->has_hiz_and_separate_stencil);<br>
> > if (info->must_use_separate_stencil)<br>
> > assert(ISL_DEV_USE_SEPARATE_STENCIL(dev));<br>
> > +<br>
> > + dev->ss.size = ss_infos[ISL_DEV_GEN(dev)].size;<br>
> > + dev->ss.align = ss_infos[ISL_DEV_GEN(dev)].align;<br>
> > + dev->ss.addr_offset = ss_infos[ISL_DEV_GEN(dev)].addr_offset;<br>
> > + dev->ss.aux_addr_offset = ss_infos[ISL_DEV_GEN(dev)].aux_addr_offset;<br>
> > }<br>
> ><br>
> > /**<br>
> > diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h<br>
> > index 11ad891..07368f9 100644<br>
> > --- a/src/intel/isl/isl.h<br>
> > +++ b/src/intel/isl/isl.h<br>
> > @@ -671,6 +671,17 @@ struct isl_device {<br>
> > const struct gen_device_info *info;<br>
> > bool use_separate_stencil;<br>
> > bool has_bit6_swizzling;<br>
> > +<br>
> > + /**<br>
> > + * Describes the layout of a RENDER_SURFACE_STATE structure for the<br>
> > + * current gen.<br>
> > + */<br>
> > + struct {<br>
> > + uint8_t size;<br>
> > + uint8_t align;<br>
> > + uint8_t addr_offset;<br>
> > + uint8_t aux_addr_offset;<br>
> > + } ss;<br>
> > };<br>
> ><br>
> > struct isl_extent2d {<br>
> > diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c<br>
> > index dfa9abf..93425f0 100644<br>
> > --- a/src/intel/vulkan/anv_batch_chain.c<br>
> > +++ b/src/intel/vulkan/anv_batch_chain.c<br>
> > @@ -550,7 +550,9 @@ anv_cmd_buffer_alloc_binding_table(struct anv_cmd_buffer *cmd_buffer,<br>
> > struct anv_state<br>
> > anv_cmd_buffer_alloc_surface_state(struct anv_cmd_buffer *cmd_buffer)<br>
> > {<br>
> > - return anv_state_stream_alloc(&cmd_buffer->surface_state_stream, 64, 64);<br>
> > + struct isl_device *isl_dev = &cmd_buffer->device->isl_dev;<br>
> > + return anv_state_stream_alloc(&cmd_buffer->surface_state_stream,<br>
> > + isl_dev->ss.size, isl_dev->ss.align);<br>
> > }<br>
> ><br>
> > struct anv_state<br>
> > diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c<br>
> > index 24e0012..ce53526 100644<br>
> > --- a/src/intel/vulkan/genX_cmd_buffer.c<br>
> > +++ b/src/intel/vulkan/genX_cmd_buffer.c<br>
> > @@ -633,14 +633,10 @@ add_surface_state_reloc(struct anv_cmd_buffer *cmd_buffer,<br>
> > struct anv_state state, struct anv_bo *bo,<br>
> > uint32_t offset)<br>
> > {<br>
> > - /* The address goes in SURFACE_STATE dword 1 for gens < 8 and dwords 8 and<br>
> > - * 9 for gen8+. We only write the first dword for gen8+ here and rely on<br>
> > - * the initial state to set the high bits to 0. */<br>
> > -<br>
> > - const uint32_t dword = GEN_GEN < 8 ? 1 : 8;<br>
> > + const struct isl_device *isl_dev = &cmd_buffer->device->isl_dev;<br>
> ><br>
> > anv_reloc_list_add(&cmd_buffer->surface_relocs, &cmd_buffer->pool->alloc,<br>
> > - state.offset + dword * 4, bo, offset);<br>
> > + state.offset + isl_dev->ss.addr_offset, bo, offset);<br>
> > }<br>
> ><br>
> > static struct anv_state<br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
> > index b774294..df59541 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
> > @@ -60,22 +60,16 @@ enum {<br>
> > INTEL_AUX_BUFFER_DISABLED = 1 << 1,<br>
> > };<br>
> ><br>
> > -struct surface_state_info {<br>
> > - unsigned num_dwords;<br>
> > - unsigned ss_align; /* Required alignment of RENDER_SURFACE_STATE in bytes */<br>
> > - unsigned reloc_dw;<br>
> > - unsigned aux_reloc_dw;<br>
> > - unsigned tex_mocs;<br>
> > - unsigned rb_mocs;<br>
> > +uint32_t tex_mocs[] = {<br>
> > + [7] = GEN7_MOCS_L3,<br>
> > + [8] = BDW_MOCS_WB,<br>
> > + [9] = SKL_MOCS_WB,<br>
> > };<br>
> ><br>
> > -static const struct surface_state_info surface_state_infos[] = {<br>
> > - [4] = {6, 32, 1, 0},<br>
> > - [5] = {6, 32, 1, 0},<br>
> > - [6] = {6, 32, 1, 0},<br>
> > - [7] = {8, 32, 1, 6, GEN7_MOCS_L3, GEN7_MOCS_L3},<br>
> > - [8] = {13, 64, 8, 10, BDW_MOCS_WB, BDW_MOCS_PTE},<br>
> > - [9] = {16, 64, 8, 10, SKL_MOCS_WB, SKL_MOCS_PTE},<br>
> > +uint32_t rb_mocs[] = {<br>
> > + [7] = GEN7_MOCS_L3,<br>
> > + [8] = BDW_MOCS_PTE,<br>
> > + [9] = SKL_MOCS_PTE,<br>
> > };<br>
> ><br>
> > static void<br>
> > @@ -85,7 +79,6 @@ brw_emit_surface_state(struct brw_context *brw,<br>
> > uint32_t mocs, uint32_t *surf_offset, int surf_index,<br>
> > unsigned read_domains, unsigned write_domains)<br>
> > {<br>
> > - const struct surface_state_info ss_info = surface_state_infos[brw->gen];<br>
> > uint32_t tile_x = mt->level[0].slice[0].x_offset;<br>
> > uint32_t tile_y = mt->level[0].slice[0].y_offset;<br>
> > uint32_t offset = mt->offset;<br>
> > @@ -155,11 +148,12 @@ brw_emit_surface_state(struct brw_context *brw,<br>
> > clear_color = intel_miptree_get_isl_clear_color(brw, mt);<br>
> > }<br>
> ><br>
> > - uint32_t *dw = __brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,<br>
> > - ss_info.num_dwords * 4, ss_info.ss_align,<br>
> > - surf_index, surf_offset);<br>
> > + void *state = __brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,<br>
> > + brw->isl_dev.ss.size,<br>
> > + brw->isl_dev.ss.align,<br>
> > + surf_index, surf_offset);<br>
> ><br>
> > - isl_surf_fill_state(&brw->isl_dev, dw, .surf = &surf, .view = &view,<br>
> > + isl_surf_fill_state(&brw->isl_dev, state, .surf = &surf, .view = &view,<br>
> > .address = mt->bo->offset64 + offset,<br>
> > .aux_surf = aux_surf, .aux_usage = aux_usage,<br>
> > .aux_address = aux_offset,<br>
> > @@ -167,7 +161,7 @@ brw_emit_surface_state(struct brw_context *brw,<br>
> > .x_offset_sa = tile_x, .y_offset_sa = tile_y);<br>
> ><br>
> > drm_intel_bo_emit_reloc(brw-><a href="http://batch.bo">batch.bo</a>,<br>
> > - *surf_offset + 4 * ss_info.reloc_dw,<br>
> > + *surf_offset + brw->isl_dev.ss.addr_offset,<br>
> > mt->bo, offset,<br>
> > read_domains, write_domains);<br>
> ><br>
> > @@ -179,9 +173,10 @@ brw_emit_surface_state(struct brw_context *brw,<br>
> > * an ordinary reloc to do the necessary address translation.<br>
> > */<br>
> > assert((aux_offset & 0xfff) == 0);<br>
> > + uint32_t *aux_addr = state + brw->isl_dev.ss.aux_addr_offset;<br>
><br>
> Same question here.<br>
><br>
> > drm_intel_bo_emit_reloc(brw-><a href="http://batch.bo">batch.bo</a>,<br>
> > - *surf_offset + 4 * ss_info.aux_reloc_dw,<br>
> > - mt->mcs_mt->bo, dw[ss_info.aux_reloc_dw] & 0xfff,<br>
> > + *surf_offset + brw->isl_dev.ss.aux_addr_offset,<br>
> > + mt->mcs_mt->bo, *aux_addr & 0xfff,<br>
> > read_domains, write_domains);<br>
> > }<br>
> > }<br>
> > @@ -226,7 +221,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw,<br>
> ><br>
> > uint32_t offset;<br>
> > brw_emit_surface_state(brw, mt, flags, mt->target, view,<br>
> > - surface_state_infos[brw->gen].rb_mocs,<br>
> > + rb_mocs[brw->gen],<br>
> > &offset, surf_index,<br>
> > I915_GEM_DOMAIN_RENDER,<br>
> > I915_GEM_DOMAIN_RENDER);<br>
> > @@ -627,7 +622,7 @@ brw_update_texture_surface(struct gl_context *ctx,<br>
> > const int flags =<br>
> > brw_disable_aux_surface(brw, mt) ? INTEL_AUX_BUFFER_DISABLED : 0;<br>
> > brw_emit_surface_state(brw, mt, flags, mt->target, view,<br>
> > - surface_state_infos[brw->gen].tex_mocs,<br>
> > + tex_mocs[brw->gen],<br>
> > surf_offset, surf_index,<br>
> > I915_GEM_DOMAIN_SAMPLER, 0);<br>
> > }<br>
> > @@ -643,10 +638,9 @@ brw_emit_buffer_surface_state(struct brw_context *brw,<br>
> > unsigned pitch,<br>
> > bool rw)<br>
> > {<br>
> > - const struct surface_state_info ss_info = surface_state_infos[brw->gen];<br>
> > -<br>
> > uint32_t *dw = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE,<br>
> > - ss_info.num_dwords * 4, ss_info.ss_align,<br>
> > + brw->isl_dev.ss.size,<br>
> > + brw->isl_dev.ss.align,<br>
> > out_offset);<br>
> ><br>
> > isl_buffer_fill_state(&brw->isl_dev, dw,<br>
> > @@ -654,11 +648,11 @@ brw_emit_buffer_surface_state(struct brw_context *brw,<br>
> > .size = buffer_size,<br>
> > .format = surface_format,<br>
> > .stride = pitch,<br>
> > - .mocs = ss_info.tex_mocs);<br>
> > + .mocs = tex_mocs[brw->gen]);<br>
> ><br>
> > if (bo) {<br>
> > drm_intel_bo_emit_reloc(brw-><a href="http://batch.bo">batch.bo</a>,<br>
> > - *out_offset + 4 * ss_info.reloc_dw,<br>
> > + *out_offset + brw->isl_dev.ss.addr_offset,<br>
> > bo, buffer_offset,<br>
> > I915_GEM_DOMAIN_SAMPLER,<br>
> > (rw ? I915_GEM_DOMAIN_SAMPLER : 0));<br>
> > @@ -1202,7 +1196,7 @@ update_renderbuffer_read_surfaces(struct brw_context *brw)<br>
> > const int flags = brw->draw_aux_buffer_disabled[i] ?<br>
> > INTEL_AUX_BUFFER_DISABLED : 0;<br>
> > brw_emit_surface_state(brw, irb->mt, flags, target, view,<br>
> > - surface_state_infos[brw->gen].tex_mocs,<br>
> > + tex_mocs[brw->gen],<br>
> > surf_offset, surf_index,<br>
> > I915_GEM_DOMAIN_SAMPLER, 0);<br>
> ><br>
> > @@ -1759,7 +1753,7 @@ update_image_surface(struct brw_context *brw,<br>
> > mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_RESOLVED ?<br>
> > INTEL_AUX_BUFFER_DISABLED : 0;<br>
> > brw_emit_surface_state(brw, mt, flags, mt->target, view,<br>
> > - surface_state_infos[brw->gen].tex_mocs,<br>
> > + tex_mocs[brw->gen],<br>
> > surf_offset, surf_index,<br>
> > I915_GEM_DOMAIN_SAMPLER,<br>
> > access == GL_READ_ONLY ? 0 :<br>
> > --<br>
> > 2.5.0.400.gff86faf<br>
> ><br>
> > _______________________________________________<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">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br></p>