From 17fe6d1252527ac1bb3eb367f6faef9d29552eb3 Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Sat, 22 Apr 2023 15:09:46 +0200 Subject: [PATCH] frontend/nine: Add debug driconf var force_features_emulation This is useful to debug drivers to be able to disable all specific d3d9 features and always trigger the emulated path. Acked-by: Mike Blumenkrantz Signed-off-by: Axel Davy Part-of: --- src/gallium/frontends/nine/adapter9.h | 1 + src/gallium/frontends/nine/device9.c | 9 +++++++++ src/gallium/frontends/nine/device9.h | 1 + src/gallium/frontends/nine/nine_shader.c | 10 +++++++++- src/gallium/frontends/nine/nine_shader.h | 1 + src/gallium/targets/d3dadapter9/drm.c | 2 ++ src/util/driconf.h | 4 ++++ 7 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/nine/adapter9.h b/src/gallium/frontends/nine/adapter9.h index c40bacd0775..54587d80a6c 100644 --- a/src/gallium/frontends/nine/adapter9.h +++ b/src/gallium/frontends/nine/adapter9.h @@ -46,6 +46,7 @@ struct d3dadapter9_context BOOL shader_inline_constants; int memfd_virtualsizelimit; int override_vram_size; + BOOL force_emulation; void (*destroy)( struct d3dadapter9_context *ctx ); }; diff --git a/src/gallium/frontends/nine/device9.c b/src/gallium/frontends/nine/device9.c index 06958dee6fa..5e913843025 100644 --- a/src/gallium/frontends/nine/device9.c +++ b/src/gallium/frontends/nine/device9.c @@ -564,6 +564,15 @@ NineDevice9_ctor( struct NineDevice9 *This, * TODO: Only generate pointsize for draw calls that need it */ This->driver_caps.always_output_pointsize = !GET_PCAP(POINT_SIZE_FIXED); This->driver_caps.emulate_ucp = !(GET_PCAP(CLIP_PLANES) == 1 || GET_PCAP(CLIP_PLANES) >= 8); + This->driver_caps.shader_emulate_features = pCTX->force_emulation; + + if (pCTX->force_emulation) { + This->driver_caps.user_sw_vbufs = false; + This->driver_caps.window_space_position_support = false; + This->driver_caps.alpha_test_emulation = true; + This->driver_caps.always_output_pointsize = true; + This->driver_caps.emulate_ucp = true; + } /* Disable SPE constants if there is no room for them */ if (This->max_vs_const_f != NINE_MAX_CONST_F) { diff --git a/src/gallium/frontends/nine/device9.h b/src/gallium/frontends/nine/device9.h index 66f452a0ae7..8d9ac60bace 100644 --- a/src/gallium/frontends/nine/device9.h +++ b/src/gallium/frontends/nine/device9.h @@ -136,6 +136,7 @@ struct NineDevice9 boolean alpha_test_emulation; boolean always_output_pointsize; boolean emulate_ucp; + boolean shader_emulate_features; } driver_caps; struct { diff --git a/src/gallium/frontends/nine/nine_shader.c b/src/gallium/frontends/nine/nine_shader.c index 7cb878a87ea..114fb003560 100644 --- a/src/gallium/frontends/nine/nine_shader.c +++ b/src/gallium/frontends/nine/nine_shader.c @@ -3687,6 +3687,13 @@ tx_ctor(struct shader_translator *tx, struct pipe_screen *screen, struct nine_sh tx->wpos_is_sysval = GET_CAP(FS_POSITION_IS_SYSVAL); tx->face_is_sysval_integer = GET_CAP(FS_FACE_IS_INTEGER_SYSVAL); tx->no_vs_window_space = !GET_CAP(VS_WINDOW_SPACE_POSITION); + tx->mul_zero_wins = GET_CAP(LEGACY_MATH_RULES); + + if (info->emulate_features) { + tx->shift_wpos = true; + tx->no_vs_window_space = true; + tx->mul_zero_wins = false; + } if (IS_VS) { tx->num_constf_allowed = NINE_MAX_CONST_F; @@ -3724,7 +3731,6 @@ tx_ctor(struct shader_translator *tx, struct pipe_screen *screen, struct nine_sh ureg_property(tx->ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER, TGSI_FS_COORD_PIXEL_CENTER_INTEGER); } - tx->mul_zero_wins = GET_CAP(LEGACY_MATH_RULES); if (tx->mul_zero_wins) ureg_property(tx->ureg, TGSI_PROPERTY_LEGACY_MATH_RULES, 1); @@ -4077,6 +4083,8 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info, if (!tx) return E_OUTOFMEMORY; + info->emulate_features = device->driver_caps.shader_emulate_features; + if (tx_ctor(tx, screen, info) == E_OUTOFMEMORY) { hr = E_OUTOFMEMORY; goto out; diff --git a/src/gallium/frontends/nine/nine_shader.h b/src/gallium/frontends/nine/nine_shader.h index 4d52396e6e8..80308465545 100644 --- a/src/gallium/frontends/nine/nine_shader.h +++ b/src/gallium/frontends/nine/nine_shader.h @@ -77,6 +77,7 @@ struct nine_shader_info uint16_t fetch4; uint8_t alpha_test_emulation; uint8_t clip_plane_emulation; + boolean emulate_features; unsigned const_i_base; /* in vec4 (16 byte) units */ unsigned const_b_base; /* in vec4 (16 byte) units */ diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c index ca7f9abb0c9..fe2371d5d1c 100644 --- a/src/gallium/targets/d3dadapter9/drm.c +++ b/src/gallium/targets/d3dadapter9/drm.c @@ -69,6 +69,7 @@ const driOptionDescription __driConfigOptionsNine[] = { DRI_CONF_NINE_SHADERINLINECONSTANTS(false) DRI_CONF_NINE_SHMEM_LIMIT() DRI_CONF_NINE_FORCESWRENDERINGONCPU(false) + DRI_CONF_NINE_FORCEFEATURESEMULATION(false) DRI_CONF_SECTION_END DRI_CONF_SECTION_DEBUG DRI_CONF_OVERRIDE_VRAM_SIZE() @@ -292,6 +293,7 @@ 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"); + ctx->base.force_emulation = driQueryOptionb(&userInitOptions, "force_features_emulation"); sw_rendering = driQueryOptionb(&userInitOptions, "force_sw_rendering_on_cpu"); driDestroyOptionCache(&userInitOptions); diff --git a/src/util/driconf.h b/src/util/driconf.h index ef04aba598b..d1a000e2d77 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -506,6 +506,10 @@ 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.") +#define DRI_CONF_NINE_FORCEFEATURESEMULATION(def) \ + DRI_CONF_OPT_B(force_features_emulation, def, \ + "If set to true, force emulation of d3d9 features when possible instead of using native hw support.") + #define DRI_CONF_V3D_NONMSAA_TEXTURE_SIZE_LIMIT(def) \ DRI_CONF_OPT_B(v3d_nonmsaa_texture_size_limit, def, \ "Report the non-MSAA-only texture size limit")