isl: add external parameter to isl_mocs()

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9127>
This commit is contained in:
Lionel Landwerlin
2020-12-14 11:11:59 +02:00
parent e484478727
commit 207ee2b6a9
9 changed files with 22 additions and 19 deletions

View File

@@ -291,7 +291,7 @@ iris_mocs(const struct iris_bo *bo,
const struct isl_device *dev, const struct isl_device *dev,
isl_surf_usage_flags_t usage) isl_surf_usage_flags_t usage)
{ {
return bo && bo->external ? dev->mocs.external : isl_mocs(dev, usage); return isl_mocs(dev, usage, bo && bo->external);
} }
struct iris_format_info iris_format_for_usage(const struct gen_device_info *, struct iris_format_info iris_format_for_usage(const struct gen_device_info *,

View File

@@ -698,7 +698,7 @@ static void
init_state_base_address(struct iris_batch *batch) init_state_base_address(struct iris_batch *batch)
{ {
struct isl_device *isl_dev = &batch->screen->isl_dev; struct isl_device *isl_dev = &batch->screen->isl_dev;
uint32_t mocs = isl_mocs(isl_dev, 0); uint32_t mocs = isl_mocs(isl_dev, 0, false);
flush_before_state_base_change(batch); flush_before_state_base_change(batch);
/* We program most base addresses once at context initialization time. /* We program most base addresses once at context initialization time.
@@ -5264,7 +5264,7 @@ iris_update_surface_base_address(struct iris_batch *batch,
return; return;
struct isl_device *isl_dev = &batch->screen->isl_dev; struct isl_device *isl_dev = &batch->screen->isl_dev;
uint32_t mocs = isl_mocs(isl_dev, 0); uint32_t mocs = isl_mocs(isl_dev, 0, false);
iris_batch_sync_region_start(batch); iris_batch_sync_region_start(batch);
@@ -5445,7 +5445,7 @@ emit_push_constant_packets(struct iris_context *ice,
iris_emit_cmd(batch, GENX(3DSTATE_CONSTANT_VS), pkt) { iris_emit_cmd(batch, GENX(3DSTATE_CONSTANT_VS), pkt) {
pkt._3DCommandSubOpcode = push_constant_opcodes[stage]; pkt._3DCommandSubOpcode = push_constant_opcodes[stage];
#if GEN_GEN >= 12 #if GEN_GEN >= 12
pkt.MOCS = isl_mocs(isl_dev, 0); pkt.MOCS = isl_mocs(isl_dev, 0, false);
#endif #endif
if (prog_data) { if (prog_data) {
/* The Skylake PRM contains the following restriction: /* The Skylake PRM contains the following restriction:
@@ -5496,7 +5496,7 @@ emit_push_constant_packet_all(struct iris_context *ice,
assert(n <= max_pointers); assert(n <= max_pointers);
iris_pack_command(GENX(3DSTATE_CONSTANT_ALL), dw, all) { iris_pack_command(GENX(3DSTATE_CONSTANT_ALL), dw, all) {
all.DWordLength = num_dwords - 2; all.DWordLength = num_dwords - 2;
all.MOCS = isl_mocs(isl_dev, 0); all.MOCS = isl_mocs(isl_dev, 0, false);
all.ShaderUpdateEnable = shader_mask; all.ShaderUpdateEnable = shader_mask;
all.PointerBufferMask = (1 << n) - 1; all.PointerBufferMask = (1 << n) - 1;
} }

View File

@@ -161,8 +161,12 @@ isl_device_setup_mocs(struct isl_device *dev)
* Return an appropriate MOCS entry for the given usage flags. * Return an appropriate MOCS entry for the given usage flags.
*/ */
uint32_t uint32_t
isl_mocs(const struct isl_device *dev, isl_surf_usage_flags_t usage) isl_mocs(const struct isl_device *dev, isl_surf_usage_flags_t usage,
bool external)
{ {
if (external)
return dev->mocs.external;
if (dev->info->gen >= 12 && !dev->info->is_dg1) { if (dev->info->gen >= 12 && !dev->info->is_dg1) {
if (usage & ISL_SURF_USAGE_STAGING_BIT) if (usage & ISL_SURF_USAGE_STAGING_BIT)
return dev->mocs.internal; return dev->mocs.internal;

View File

@@ -2027,7 +2027,8 @@ isl_swizzle_compose(struct isl_swizzle first, struct isl_swizzle second);
struct isl_swizzle struct isl_swizzle
isl_swizzle_invert(struct isl_swizzle swizzle); isl_swizzle_invert(struct isl_swizzle swizzle);
uint32_t isl_mocs(const struct isl_device *dev, isl_surf_usage_flags_t usage); uint32_t isl_mocs(const struct isl_device *dev, isl_surf_usage_flags_t usage,
bool external);
#define isl_surf_init(dev, surf, ...) \ #define isl_surf_init(dev, surf, ...) \
isl_surf_init_s((dev), (surf), \ isl_surf_init_s((dev), (surf), \

View File

@@ -892,7 +892,7 @@ void anv_CmdUpdateBuffer(
.buffer = cmd_buffer->device->dynamic_state_pool.block_pool.bo, .buffer = cmd_buffer->device->dynamic_state_pool.block_pool.bo,
.offset = tmp_data.offset, .offset = tmp_data.offset,
.mocs = isl_mocs(&cmd_buffer->device->isl_dev, .mocs = isl_mocs(&cmd_buffer->device->isl_dev,
ISL_SURF_USAGE_TEXTURE_BIT) ISL_SURF_USAGE_TEXTURE_BIT, false)
}; };
struct blorp_address dst = { struct blorp_address dst = {
.buffer = dst_buffer->address.bo, .buffer = dst_buffer->address.bo,

View File

@@ -4486,7 +4486,8 @@ anv_fill_buffer_surface_state(struct anv_device *device, struct anv_state state,
{ {
isl_buffer_fill_state(&device->isl_dev, state.map, isl_buffer_fill_state(&device->isl_dev, state.map,
.address = anv_address_physical(address), .address = anv_address_physical(address),
.mocs = isl_mocs(&device->isl_dev, usage), .mocs = isl_mocs(&device->isl_dev, usage,
address.bo && address.bo->is_external),
.size_B = range, .size_B = range,
.format = format, .format = format,
.swizzle = ISL_SWIZZLE_IDENTITY, .swizzle = ISL_SWIZZLE_IDENTITY,

View File

@@ -1373,10 +1373,7 @@ anv_mocs(const struct anv_device *device,
const struct anv_bo *bo, const struct anv_bo *bo,
isl_surf_usage_flags_t usage) isl_surf_usage_flags_t usage)
{ {
if (bo->is_external) return isl_mocs(&device->isl_dev, usage, bo && bo->is_external);
return device->isl_dev.mocs.external;
return isl_mocs(&device->isl_dev, usage);
} }
void anv_device_init_blorp(struct anv_device *device); void anv_device_init_blorp(struct anv_device *device);

View File

@@ -155,7 +155,7 @@ blorp_alloc_vertex_buffer(struct blorp_batch *batch, uint32_t size,
.buffer = cmd_buffer->device->dynamic_state_pool.block_pool.bo, .buffer = cmd_buffer->device->dynamic_state_pool.block_pool.bo,
.offset = vb_state.offset, .offset = vb_state.offset,
.mocs = isl_mocs(&cmd_buffer->device->isl_dev, .mocs = isl_mocs(&cmd_buffer->device->isl_dev,
ISL_SURF_USAGE_VERTEX_BUFFER_BIT), ISL_SURF_USAGE_VERTEX_BUFFER_BIT, false),
}; };
return vb_state.map; return vb_state.map;

View File

@@ -61,7 +61,7 @@ genX(cmd_buffer_emit_state_base_address)(struct anv_cmd_buffer *cmd_buffer)
{ {
struct anv_device *device = cmd_buffer->device; struct anv_device *device = cmd_buffer->device;
UNUSED const struct gen_device_info *devinfo = &device->info; UNUSED const struct gen_device_info *devinfo = &device->info;
uint32_t mocs = isl_mocs(&device->isl_dev, 0); uint32_t mocs = isl_mocs(&device->isl_dev, 0, false);
/* If we are emitting a new state base address we probably need to re-emit /* If we are emitting a new state base address we probably need to re-emit
* binding tables. * binding tables.
@@ -3171,7 +3171,7 @@ cmd_buffer_emit_push_constant(struct anv_cmd_buffer *cmd_buffer,
* same bit of memory for both scanout and a UBO is nuts. Let's not * same bit of memory for both scanout and a UBO is nuts. Let's not
* bother and assume it's all internal. * bother and assume it's all internal.
*/ */
c.MOCS = isl_mocs(&cmd_buffer->device->isl_dev, 0); c.MOCS = isl_mocs(&cmd_buffer->device->isl_dev, 0, false);
#endif #endif
#if GEN_GEN >= 8 || GEN_IS_HASWELL #if GEN_GEN >= 8 || GEN_IS_HASWELL
@@ -3235,7 +3235,7 @@ cmd_buffer_emit_push_constant_all(struct anv_cmd_buffer *cmd_buffer,
if (buffer_count == 0) { if (buffer_count == 0) {
anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CONSTANT_ALL), c) { anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CONSTANT_ALL), c) {
c.ShaderUpdateEnable = shader_mask; c.ShaderUpdateEnable = shader_mask;
c.MOCS = isl_mocs(&cmd_buffer->device->isl_dev, 0); c.MOCS = isl_mocs(&cmd_buffer->device->isl_dev, 0, false);
} }
return; return;
} }
@@ -3267,7 +3267,7 @@ cmd_buffer_emit_push_constant_all(struct anv_cmd_buffer *cmd_buffer,
GENX(3DSTATE_CONSTANT_ALL), GENX(3DSTATE_CONSTANT_ALL),
.ShaderUpdateEnable = shader_mask, .ShaderUpdateEnable = shader_mask,
.PointerBufferMask = buffer_mask, .PointerBufferMask = buffer_mask,
.MOCS = isl_mocs(&cmd_buffer->device->isl_dev, 0)); .MOCS = isl_mocs(&cmd_buffer->device->isl_dev, 0, false));
for (int i = 0; i < buffer_count; i++) { for (int i = 0; i < buffer_count; i++) {
const struct anv_push_range *range = &bind_map->push_ranges[i]; const struct anv_push_range *range = &bind_map->push_ranges[i];
@@ -3563,7 +3563,7 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer)
#endif #endif
if (cmd_buffer->state.xfb_enabled && xfb->buffer && xfb->size != 0) { if (cmd_buffer->state.xfb_enabled && xfb->buffer && xfb->size != 0) {
sob.MOCS = isl_mocs(&cmd_buffer->device->isl_dev, 0); sob.MOCS = anv_mocs(cmd_buffer->device, xfb->buffer->address.bo, 0);
sob.SurfaceBaseAddress = anv_address_add(xfb->buffer->address, sob.SurfaceBaseAddress = anv_address_add(xfb->buffer->address,
xfb->offset); xfb->offset);
#if GEN_GEN >= 8 #if GEN_GEN >= 8