summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAxel Davy <davyaxel0@gmail.com>2021-04-10 22:52:47 +0200
committerMarge Bot <eric+marge@anholt.net>2021-04-14 08:33:14 +0000
commitb41f1e32e96c973dba8981e8e66e68730aaa35a8 (patch)
treea147c3d947cc4a0ec02d05924f01caa3819569ac
parentc5f75bc2001126c688b384ce18221a8db02c2cfd (diff)
st/nine: Make it optional to use a sw renderer
Until the problem described in https://gitlab.freedesktop.org/mesa/mesa/-/issues/4489 is fixed, the advantages of using a sw renderer for the sw rendering in nine are too small compared to the disadvantages. Add an option to control whether we use a sw renderer, and make it so by default we don't. Signed-off-by: Axel Davy <davyaxel0@gmail.com> Acked-by: Timur Kristóf <timur.kristof@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10160>
-rw-r--r--src/gallium/targets/d3dadapter9/drm.c17
-rw-r--r--src/util/driconf.h4
2 files changed, 14 insertions, 7 deletions
diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c
index cb05d5ca579..7a889a0d623 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -61,6 +61,7 @@ const driOptionDescription __driConfigOptionsNine[] = {
DRI_CONF_NINE_DYNAMICTEXTUREWORKAROUND(true)
DRI_CONF_NINE_SHADERINLINECONSTANTS(false)
DRI_CONF_NINE_SHMEM_LIMIT()
+ DRI_CONF_NINE_FORCESWRENDERINGONCPU(false)
DRI_CONF_SECTION_END
DRI_CONF_SECTION_DEBUG
DRI_CONF_OVERRIDE_VRAM_SIZE()
@@ -101,13 +102,13 @@ drm_destroy( struct d3dadapter9_context *ctx )
{
struct d3dadapter9drm_context *drm = (struct d3dadapter9drm_context *)ctx;
- if (ctx->ref)
+ if (ctx->ref && ctx->hal != ctx->ref)
ctx->ref->destroy(ctx->ref);
/* because ref is a wrapper around hal, freeing ref frees hal too. */
else if (ctx->hal)
ctx->hal->destroy(ctx->hal);
- if (drm->swdev)
+ if (drm->swdev && drm->swdev != drm->dev)
pipe_loader_release(&drm->swdev, 1);
if (drm->dev)
pipe_loader_release(&drm->dev, 1);
@@ -214,6 +215,7 @@ drm_create_adapter( int fd,
driOptionCache userInitOptions;
int throttling_value_user = -2;
int override_vendorid = -1;
+ bool sw_rendering;
if (!ctx) { return E_OUTOFMEMORY; }
@@ -283,17 +285,18 @@ drm_create_adapter( int fd,
ctx->base.shader_inline_constants = driQueryOptionb(&userInitOptions, "shader_inline_constants");
ctx->base.memfd_virtualsizelimit = driQueryOptioni(&userInitOptions, "texture_memory_limit");
ctx->base.override_vram_size = driQueryOptioni(&userInitOptions, "override_vram_size");
+ sw_rendering = driQueryOptionb(&userInitOptions, "force_sw_rendering_on_cpu");
driDestroyOptionCache(&userInitOptions);
driDestroyOptionInfo(&defaultInitOptions);
/* wrap it to create a software screen that can share resources */
- if (pipe_loader_sw_probe_wrapped(&ctx->swdev, ctx->base.hal))
+ if (sw_rendering && pipe_loader_sw_probe_wrapped(&ctx->swdev, ctx->base.hal))
ctx->base.ref = pipe_loader_create_screen(ctx->swdev);
-
- if (!ctx->base.ref) {
- ERR("Couldn't wrap drm screen to swrast screen. Software devices "
- "will be unavailable.\n");
+ else {
+ /* Use the hardware for sw rendering */
+ ctx->swdev = ctx->dev;
+ ctx->base.ref = ctx->base.hal;
}
/* read out PCI info */
diff --git a/src/util/driconf.h b/src/util/driconf.h
index 5467c150d31..dc31d5b0129 100644
--- a/src/util/driconf.h
+++ b/src/util/driconf.h
@@ -418,6 +418,10 @@
DRI_CONF_OPT_I(texture_memory_limit, 512, 0, 0, \
"In MB the limit of virtual memory used for textures until shmem files are unmapped (default 512MB, 32bits only). If negative disables shmem. Set to a low amount to reduce virtual memory usage, but can inccur a small perf hit if too low.")
+#define DRI_CONF_NINE_FORCESWRENDERINGONCPU(def) \
+ DRI_CONF_OPT_B(force_sw_rendering_on_cpu, def, \
+ "If set to false, emulates software rendering on the requested device, else uses a software renderer.")
+
/**
* \brief radeonsi specific configuration options
*/