From: Chia-I Wu Date: Thu, 5 Mar 2015 20:27:16 +0000 (+0800) Subject: ilo: clean up SURFACE_STATE and BINDING_TABLE_STATE X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e7c74ef43d7dc9c8e6791e8a4083b0776abdcfc6;p=mesa.git ilo: clean up SURFACE_STATE and BINDING_TABLE_STATE Add ilo_builder_surface_pointer() to replace ilo_builder_surface_write(). Make Gen8+ take a different path in gen6_SURFACE_STATE(). --- diff --git a/src/gallium/drivers/ilo/ilo_builder.h b/src/gallium/drivers/ilo/ilo_builder.h index c902a8f3cf2..cb639d1bf12 100644 --- a/src/gallium/drivers/ilo/ilo_builder.h +++ b/src/gallium/drivers/ilo/ilo_builder.h @@ -350,21 +350,22 @@ ilo_builder_dynamic_used(const struct ilo_builder *builder) } /** - * Write a surface state to the surface buffer. The offset, in bytes, of the - * state is returned. + * Reserve a region from the surface buffer. Both the offset, in bytes, and + * the pointer to the reserved region are returned. The pointer is only valid + * until the next reserve call. * * Note that \p alignment is in bytes and \p len is in DWords. */ static inline uint32_t -ilo_builder_surface_write(struct ilo_builder *builder, - enum ilo_builder_item_type item, - unsigned alignment, unsigned len, - const uint32_t *dw) +ilo_builder_surface_pointer(struct ilo_builder *builder, + enum ilo_builder_item_type item, + unsigned alignment, unsigned len, + uint32_t **dw) { assert(item == ILO_BUILDER_ITEM_SURFACE || item == ILO_BUILDER_ITEM_BINDING_TABLE); - return ilo_builder_dynamic_write(builder, item, alignment, len, dw); + return ilo_builder_dynamic_pointer(builder, item, alignment, len, dw); } /** diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_top.h b/src/gallium/drivers/ilo/ilo_builder_3d_top.h index d359252aa8c..ab1374a4d2b 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_top.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_top.h @@ -1585,11 +1585,12 @@ gen7_3DSTATE_CONSTANT_GS(struct ilo_builder *builder, static inline uint32_t gen6_BINDING_TABLE_STATE(struct ilo_builder *builder, - uint32_t *surface_states, + const uint32_t *surface_states, int num_surface_states) { const int state_align = 32; const int state_len = num_surface_states; + uint32_t state_offset, *dw; ILO_DEV_ASSERT(builder->dev, 6, 8); @@ -1603,8 +1604,11 @@ gen6_BINDING_TABLE_STATE(struct ilo_builder *builder, if (!num_surface_states) return 0; - return ilo_builder_surface_write(builder, ILO_BUILDER_ITEM_BINDING_TABLE, - state_align, state_len, surface_states); + state_offset = ilo_builder_surface_pointer(builder, + ILO_BUILDER_ITEM_BINDING_TABLE, state_align, state_len, &dw); + memcpy(dw, surface_states, state_len << 2); + + return state_offset; } static inline uint32_t @@ -1612,23 +1616,32 @@ gen6_SURFACE_STATE(struct ilo_builder *builder, const struct ilo_view_surface *surf, bool for_render) { - const int state_align = - (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 64 : 32; - const int state_len = - (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 13 : - (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? 8 : 6; - uint32_t state_offset; + int state_align, state_len; + uint32_t state_offset, *dw; ILO_DEV_ASSERT(builder->dev, 6, 8); - state_offset = ilo_builder_surface_write(builder, ILO_BUILDER_ITEM_SURFACE, - state_align, state_len, surf->payload); + if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { + state_align = 64; + state_len = 13; - if (surf->bo) { - if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) { + state_offset = ilo_builder_surface_pointer(builder, + ILO_BUILDER_ITEM_SURFACE, state_align, state_len, &dw); + memcpy(dw, surf->payload, state_len << 2); + + if (surf->bo) { ilo_builder_surface_reloc64(builder, state_offset, 8, surf->bo, surf->payload[8], (for_render) ? INTEL_RELOC_WRITE : 0); - } else { + } + } else { + state_align = 32; + state_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? 8 : 6; + + state_offset = ilo_builder_surface_pointer(builder, + ILO_BUILDER_ITEM_SURFACE, state_align, state_len, &dw); + memcpy(dw, surf->payload, state_len << 2); + + if (surf->bo) { ilo_builder_surface_reloc(builder, state_offset, 1, surf->bo, surf->payload[1], (for_render) ? INTEL_RELOC_WRITE : 0); }