From c097ff36174d77df9b641be392c5f15d4ab930fd Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Wed, 10 Apr 2019 23:09:08 +0200 Subject: st/nine: Add drirc option to use data_internal for dynamic textures dynamic textures seem to have predictable stride. This stride should be the same as for a ram buffer. It seems some game don't check the actual stride value, assuming it to be the expected one. Thus this workaround (protected by drirc option) is to use an intermediate ram buffer. Fixes Rayman Legends texture issues when enabled. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/adapter9.h | 1 + src/gallium/state_trackers/nine/device9.c | 2 ++ src/gallium/state_trackers/nine/device9.h | 4 ++++ src/gallium/state_trackers/nine/surface9.c | 6 +++++- src/gallium/state_trackers/nine/volume9.c | 6 +++++- 5 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src/gallium/state_trackers') diff --git a/src/gallium/state_trackers/nine/adapter9.h b/src/gallium/state_trackers/nine/adapter9.h index 60be056f892..ba20a3abe87 100644 --- a/src/gallium/state_trackers/nine/adapter9.h +++ b/src/gallium/state_trackers/nine/adapter9.h @@ -42,6 +42,7 @@ struct d3dadapter9_context BOOL discard_delayed_release; BOOL tearfree_discard; int csmt_force; + BOOL dynamic_texture_workaround; void (*destroy)( struct d3dadapter9_context *ctx ); }; diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index e7317238e6c..2cc3a9465fa 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -291,6 +291,8 @@ NineDevice9_ctor( struct NineDevice9 *This, if (This->csmt_active) DBG("\033[1;32mCSMT is active\033[0m\n"); + This->workarounds.dynamic_texture_workaround = pCTX->dynamic_texture_workaround; + This->buffer_upload = nine_upload_create(This->pipe_secondary, 4 * 1024 * 1024, 4); /* Initialize a dummy VBO to be used when a vertex declaration does not diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h index 4cce29a28e0..167a830d824 100644 --- a/src/gallium/state_trackers/nine/device9.h +++ b/src/gallium/state_trackers/nine/device9.h @@ -138,6 +138,10 @@ struct NineDevice9 boolean buggy_barycentrics; } driver_bugs; + struct { + boolean dynamic_texture_workaround; + } workarounds; + struct u_upload_mgr *vertex_uploader; struct nine_range_pool range_pool; diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index d57d13ef7c6..db74de2823a 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -146,7 +146,11 @@ NineSurface9_ctor( struct NineSurface9 *This, This->base.info.bind, FALSE, TRUE); - if (This->base.info.format != This->format_internal) { + if (This->base.info.format != This->format_internal || + /* DYNAMIC Textures requires same stride as ram buffers. + * Do not use workaround by default as it eats more virtual space */ + (pParams->device->workarounds.dynamic_texture_workaround && + pDesc->Pool == D3DPOOL_DEFAULT && pDesc->Usage & D3DUSAGE_DYNAMIC)) { This->data_internal = align_calloc( nine_format_get_level_alloc_size(This->format_internal, pDesc->Width, diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c index ab0a82e288d..7a844b28387 100644 --- a/src/gallium/state_trackers/nine/volume9.c +++ b/src/gallium/state_trackers/nine/volume9.c @@ -118,7 +118,11 @@ NineVolume9_ctor( struct NineVolume9 *This, This->info.nr_samples, This->info.bind, FALSE, TRUE); - if (This->info.format != This->format_internal) { + if (This->info.format != This->format_internal || + /* DYNAMIC Textures requires same stride as ram buffers. + * Do not use workaround by default as it eats more virtual space */ + (pParams->device->workarounds.dynamic_texture_workaround && + pDesc->Pool == D3DPOOL_DEFAULT && pDesc->Usage & D3DUSAGE_DYNAMIC)) { This->stride_internal = nine_format_get_stride(This->format_internal, pDesc->Width); This->layer_stride_internal = util_format_get_2d_size(This->format_internal, -- cgit v1.2.3