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 <michael.blumenkrantz@gmail.com>
Signed-off-by: Axel Davy <davyaxel0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22644>
This commit is contained in:
Axel Davy 2023-04-22 15:09:46 +02:00 committed by Marge Bot
parent 824fad18b3
commit 17fe6d1252
7 changed files with 27 additions and 1 deletions

View file

@ -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 );
};

View file

@ -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) {

View file

@ -136,6 +136,7 @@ struct NineDevice9
boolean alpha_test_emulation;
boolean always_output_pointsize;
boolean emulate_ucp;
boolean shader_emulate_features;
} driver_caps;
struct {

View file

@ -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;

View file

@ -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 */

View file

@ -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);

View file

@ -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")