Mesa (main): iris: Force device local memory for u_upload_mgr buffers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jul 7 20:32:34 UTC 2021
Module: Mesa
Branch: main
Commit: aefba29cd34d0b0ff5c253a875425de4d43ba6c0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aefba29cd34d0b0ff5c253a875425de4d43ba6c0
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Thu Jul 1 14:49:49 2021 -0700
iris: Force device local memory for u_upload_mgr buffers
We try to place persistent/coherent buffers from the application in
system memory, because they want the CPU-GPU coherency.
However, our internal u_upload_mgr buffers are also flagged persistent +
coherent, but we absolutely want most of them in device local memory.
Mark had done this correctly in an earlier patch series, but I made a
mistake when refactoring things during upstreaming, and accidentally
put these in SMEM again. This fixes that mistake.
Tested-by: Luis Felipe Strano Moraes <luis.strano at intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11681>
---
src/gallium/drivers/iris/iris_context.c | 12 ++++++++----
src/gallium/drivers/iris/iris_program_cache.c | 6 ++++--
src/gallium/drivers/iris/iris_resource.c | 3 +++
src/gallium/drivers/iris/iris_resource.h | 1 +
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/gallium/drivers/iris/iris_context.c b/src/gallium/drivers/iris/iris_context.c
index 274d0c0f02d..45d82b94519 100644
--- a/src/gallium/drivers/iris/iris_context.c
+++ b/src/gallium/drivers/iris/iris_context.c
@@ -295,7 +295,8 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
}
ctx->const_uploader = u_upload_create(ctx, 1024 * 1024,
PIPE_BIND_CONSTANT_BUFFER,
- PIPE_USAGE_IMMUTABLE, 0);
+ PIPE_USAGE_IMMUTABLE,
+ IRIS_RESOURCE_FLAG_DEVICE_MEM);
if (!ctx->const_uploader) {
u_upload_destroy(ctx->stream_uploader);
free(ctx);
@@ -330,13 +331,16 @@ iris_create_context(struct pipe_screen *pscreen, void *priv, unsigned flags)
ice->state.surface_uploader =
u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
- IRIS_RESOURCE_FLAG_SURFACE_MEMZONE);
+ IRIS_RESOURCE_FLAG_SURFACE_MEMZONE |
+ IRIS_RESOURCE_FLAG_DEVICE_MEM);
ice->state.bindless_uploader =
u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
- IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE);
+ IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE |
+ IRIS_RESOURCE_FLAG_DEVICE_MEM);
ice->state.dynamic_uploader =
u_upload_create(ctx, 64 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
- IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE);
+ IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE |
+ IRIS_RESOURCE_FLAG_DEVICE_MEM);
ice->query_buffer_uploader =
u_upload_create(ctx, 16 * 1024, PIPE_BIND_CUSTOM, PIPE_USAGE_STAGING,
diff --git a/src/gallium/drivers/iris/iris_program_cache.c b/src/gallium/drivers/iris/iris_program_cache.c
index 36faeefd91f..254cc2709fb 100644
--- a/src/gallium/drivers/iris/iris_program_cache.c
+++ b/src/gallium/drivers/iris/iris_program_cache.c
@@ -272,10 +272,12 @@ iris_init_program_cache(struct iris_context *ice)
ice->shaders.uploader_driver =
u_upload_create(&ice->ctx, 16384, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
- IRIS_RESOURCE_FLAG_SHADER_MEMZONE);
+ IRIS_RESOURCE_FLAG_SHADER_MEMZONE |
+ IRIS_RESOURCE_FLAG_DEVICE_MEM);
ice->shaders.uploader_unsync =
u_upload_create(&ice->ctx, 16384, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
- IRIS_RESOURCE_FLAG_SHADER_MEMZONE);
+ IRIS_RESOURCE_FLAG_SHADER_MEMZONE |
+ IRIS_RESOURCE_FLAG_DEVICE_MEM);
}
void
diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 6e624993c80..95af0d131ed 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -409,6 +409,9 @@ static uint32_t
iris_resource_alloc_flags(const struct iris_screen *screen,
const struct pipe_resource *templ)
{
+ if (templ->flags & IRIS_RESOURCE_FLAG_DEVICE_MEM)
+ return 0;
+
uint32_t flags = 0;
switch (templ->usage) {
diff --git a/src/gallium/drivers/iris/iris_resource.h b/src/gallium/drivers/iris/iris_resource.h
index ff4ce11374d..763fdb80bcb 100644
--- a/src/gallium/drivers/iris/iris_resource.h
+++ b/src/gallium/drivers/iris/iris_resource.h
@@ -45,6 +45,7 @@ struct iris_format_info {
#define IRIS_RESOURCE_FLAG_SURFACE_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
#define IRIS_RESOURCE_FLAG_DYNAMIC_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
#define IRIS_RESOURCE_FLAG_BINDLESS_MEMZONE (PIPE_RESOURCE_FLAG_DRV_PRIV << 3)
+#define IRIS_RESOURCE_FLAG_DEVICE_MEM (PIPE_RESOURCE_FLAG_DRV_PRIV << 4)
/**
* Resources represent a GPU buffer object or image (mipmap tree).
More information about the mesa-commit
mailing list