From 207ee2b6a9d0d0976c6d3b0f2e0a1e8c0763f50d Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 14 Dec 2020 11:11:59 +0200 Subject: [PATCH] isl: add external parameter to isl_mocs() Signed-off-by: Lionel Landwerlin Reviewed-by: Jason Ekstrand Part-of: --- src/gallium/drivers/iris/iris_resource.h | 2 +- src/gallium/drivers/iris/iris_state.c | 8 ++++---- src/intel/isl/isl.c | 6 +++++- src/intel/isl/isl.h | 3 ++- src/intel/vulkan/anv_blorp.c | 2 +- src/intel/vulkan/anv_device.c | 3 ++- src/intel/vulkan/anv_private.h | 5 +---- src/intel/vulkan/genX_blorp_exec.c | 2 +- src/intel/vulkan/genX_cmd_buffer.c | 10 +++++----- 9 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/iris/iris_resource.h b/src/gallium/drivers/iris/iris_resource.h index 0f58a53..8da587f 100644 --- a/src/gallium/drivers/iris/iris_resource.h +++ b/src/gallium/drivers/iris/iris_resource.h @@ -291,7 +291,7 @@ iris_mocs(const struct iris_bo *bo, const struct isl_device *dev, 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 *, diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 159a37b..53120f4 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -698,7 +698,7 @@ static void init_state_base_address(struct iris_batch *batch) { 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); /* We program most base addresses once at context initialization time. @@ -5264,7 +5264,7 @@ iris_update_surface_base_address(struct iris_batch *batch, return; 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); @@ -5445,7 +5445,7 @@ emit_push_constant_packets(struct iris_context *ice, iris_emit_cmd(batch, GENX(3DSTATE_CONSTANT_VS), pkt) { pkt._3DCommandSubOpcode = push_constant_opcodes[stage]; #if GEN_GEN >= 12 - pkt.MOCS = isl_mocs(isl_dev, 0); + pkt.MOCS = isl_mocs(isl_dev, 0, false); #endif if (prog_data) { /* The Skylake PRM contains the following restriction: @@ -5496,7 +5496,7 @@ emit_push_constant_packet_all(struct iris_context *ice, assert(n <= max_pointers); iris_pack_command(GENX(3DSTATE_CONSTANT_ALL), dw, all) { 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.PointerBufferMask = (1 << n) - 1; } diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c index e5d324a..fa822bb 100644 --- a/src/intel/isl/isl.c +++ b/src/intel/isl/isl.c @@ -161,8 +161,12 @@ isl_device_setup_mocs(struct isl_device *dev) * Return an appropriate MOCS entry for the given usage flags. */ 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 (usage & ISL_SURF_USAGE_STAGING_BIT) return dev->mocs.internal; diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h index 376703d..aa6a4e7 100644 --- a/src/intel/isl/isl.h +++ b/src/intel/isl/isl.h @@ -2027,7 +2027,8 @@ isl_swizzle_compose(struct isl_swizzle first, struct isl_swizzle second); struct isl_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, ...) \ isl_surf_init_s((dev), (surf), \ diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c index 087fd55..315007e 100644 --- a/src/intel/vulkan/anv_blorp.c +++ b/src/intel/vulkan/anv_blorp.c @@ -892,7 +892,7 @@ void anv_CmdUpdateBuffer( .buffer = cmd_buffer->device->dynamic_state_pool.block_pool.bo, .offset = tmp_data.offset, .mocs = isl_mocs(&cmd_buffer->device->isl_dev, - ISL_SURF_USAGE_TEXTURE_BIT) + ISL_SURF_USAGE_TEXTURE_BIT, false) }; struct blorp_address dst = { .buffer = dst_buffer->address.bo, diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 8fd476f..04fce55 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -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, .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, .format = format, .swizzle = ISL_SWIZZLE_IDENTITY, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index b235b2a..ef09765 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1373,10 +1373,7 @@ anv_mocs(const struct anv_device *device, const struct anv_bo *bo, isl_surf_usage_flags_t usage) { - if (bo->is_external) - return device->isl_dev.mocs.external; - - return isl_mocs(&device->isl_dev, usage); + return isl_mocs(&device->isl_dev, usage, bo && bo->is_external); } void anv_device_init_blorp(struct anv_device *device); diff --git a/src/intel/vulkan/genX_blorp_exec.c b/src/intel/vulkan/genX_blorp_exec.c index 396e0c9..7fa2361 100644 --- a/src/intel/vulkan/genX_blorp_exec.c +++ b/src/intel/vulkan/genX_blorp_exec.c @@ -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, .offset = vb_state.offset, .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; diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index f9cdb96..6236e14 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -61,7 +61,7 @@ genX(cmd_buffer_emit_state_base_address)(struct anv_cmd_buffer *cmd_buffer) { struct anv_device *device = cmd_buffer->device; 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 * 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 * 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 #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) { anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CONSTANT_ALL), c) { 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; } @@ -3267,7 +3267,7 @@ cmd_buffer_emit_push_constant_all(struct anv_cmd_buffer *cmd_buffer, GENX(3DSTATE_CONSTANT_ALL), .ShaderUpdateEnable = shader_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++) { 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 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, xfb->offset); #if GEN_GEN >= 8 -- 2.7.4