Skip to content

Commit

Permalink
Gfxbench Manhattan3.0 optimization
Browse files Browse the repository at this point in the history
Eliminate draw call for Manhattan robot shadow when conditions
apply. Mark the shadow shader. If the draw call uses the shadow
shader and the last operation of its depth texture resource is
clear, the draw call can be skiped.
The performance of Gfxbench 1080pManhattan3.0 offscreen can
be improved 1.5%.

Test Done:
1. Boot up and adb reboot
2. Gfxbench

Tracked-On: OAM-122053
Signed-off-by: Huang Rui <[email protected]>
  • Loading branch information
huangrui666 committed Jul 17, 2024
1 parent ccc6905 commit 11b32d6
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/gallium/drivers/iris/driinfo_iris.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DRI_CONF_SECTION_DEBUG
DRI_CONF_ALWAYS_FLUSH_CACHE(false)
DRI_CONF_OPT_B(sync_compile, false, "Always compile synchronously (will cause stalls)")
DRI_CONF_LIMIT_TRIG_INPUT_RANGE(false)
DRI_CONF_MHT_ROBOT_SHADOW_SHADER_ELIMINATION(false)
DRI_CONF_SECTION_END

DRI_CONF_SECTION_PERFORMANCE
Expand Down
2 changes: 2 additions & 0 deletions src/gallium/drivers/iris/iris_clear.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ fast_clear_depth(struct iris_context *ice,
ISL_AUX_STATE_CLEAR);
ice->state.dirty |= IRIS_DIRTY_DEPTH_BUFFER;
ice->state.stage_dirty |= IRIS_ALL_STAGE_DIRTY_BINDINGS;
struct pipe_resource *p_res = (void *) res;
p_res->last_operation_is_clear = true;
}

static void
Expand Down
2 changes: 2 additions & 0 deletions src/gallium/drivers/iris/iris_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,8 @@ struct iris_context {

/** Resource holding the pixel pipe hashing tables. */
struct pipe_resource *pixel_hashing_tables;

bool skipManhattanRobotShadowShader;
} state;
};

Expand Down
4 changes: 4 additions & 0 deletions src/gallium/drivers/iris/iris_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info,
stage, true);
}
iris_predraw_resolve_framebuffer(ice, batch, draw_aux_buffer_disabled);
if (screen->driconf.mht_robot_shadow_shader_elimination && ice->state.skipManhattanRobotShadowShader) {
ice->state.skipManhattanRobotShadowShader = false;
return;
};
}

if (ice->state.dirty & IRIS_DIRTY_RENDER_MISC_BUFFER_FLUSHES) {
Expand Down
13 changes: 12 additions & 1 deletion src/gallium/drivers/iris/iris_resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ resolve_sampler_views(struct iris_context *ice,
continue;

struct iris_sampler_view *isv = shs->textures[i];

if (isv->res->base.b.last_operation_is_clear) {
isv->res->base.b.last_operation_is_clear = false;
struct iris_screen *screen = (struct iris_screen*)ice->ctx.screen;
if (screen->driconf.mht_robot_shadow_shader_elimination &&
(*(uint32_t*)ice->shaders.uncompiled[MESA_SHADER_FRAGMENT]->nir->info.source_sha1 == 880113298 ||
*(uint32_t*)ice->shaders.uncompiled[MESA_SHADER_FRAGMENT]->nir->info.source_sha1 == 2932317437)) {
ice->state.skipManhattanRobotShadowShader = true;
}
}
if (isv->res->base.b.target != PIPE_BUFFER) {
if (consider_framebuffer) {
disable_rb_aux_buffer(ice, draw_aux_buffer_disabled, isv->res,
Expand Down Expand Up @@ -215,6 +223,9 @@ iris_predraw_resolve_framebuffer(struct iris_context *ice,
if (zs_surf) {
struct iris_resource *z_res, *s_res;
iris_get_depth_stencil_resources(zs_surf->texture, &z_res, &s_res);
if (z_res->base.b.last_operation_is_clear) {
z_res->base.b.last_operation_is_clear = false;
}
unsigned num_layers =
zs_surf->u.tex.last_layer - zs_surf->u.tex.first_layer + 1;

Expand Down
2 changes: 2 additions & 0 deletions src/gallium/drivers/iris/iris_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,8 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
driQueryOptionb(config->options, "limit_trig_input_range");
screen->driconf.lower_depth_range_rate =
driQueryOptionf(config->options, "lower_depth_range_rate");
screen->driconf.mht_robot_shadow_shader_elimination =
driQueryOptionf(config->options, "mht_robot_shadow_shader_elimination");

screen->precompile = debug_get_bool_option("shader_precompile", true);

Expand Down
1 change: 1 addition & 0 deletions src/gallium/drivers/iris/iris_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ struct iris_screen {
bool sync_compile;
bool limit_trig_input_range;
float lower_depth_range_rate;
bool mht_robot_shadow_shader_elimination;
} driconf;

/** Does the kernel support various features (KERNEL_HAS_* bitfield)? */
Expand Down
1 change: 1 addition & 0 deletions src/gallium/include/pipe/p_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ struct pipe_resource
uint16_t height0; /* Textures: The maximum height/depth/array_size is 16k. */
uint16_t depth0;
uint16_t array_size;
bool last_operation_is_clear;

enum pipe_format format:16; /**< PIPE_FORMAT_x */
enum pipe_texture_target target:8; /**< PIPE_TEXTURE_x */
Expand Down
9 changes: 9 additions & 0 deletions src/util/00-mesa-defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,15 @@ TODO: document the other workarounds.
<application name="Insurgency" executable="insurgency_linux">
<option name="force_gl_vendor" value="X.Org" />
</application>
<application name="Manhattan3.0" executable="testfw_app">
<option name="mht_robot_shadow_shader_elimination" value="true" />
</application>
<application name="Manhattan3.0" executable="net.kishonti.gfxbench.gl.v50000.corporate">
<option name="mht_robot_shadow_shader_elimination" value="true" />
</application>
<application name="Manhattan3.0" executable="net.kishonti.gfxbench.vulkan.v50000.corporate">
<option name="mht_robot_shadow_shader_elimination" value="true" />
</application>
</device>
<device driver="crocus">
<application name="glmark2" executable="glmark2">
Expand Down
4 changes: 4 additions & 0 deletions src/util/driconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@
DRI_CONF_OPT_B(limit_trig_input_range, def, \
"Limit trig input range to [-2p : 2p] to improve sin/cos calculation precision on Intel")

#define DRI_CONF_MHT_ROBOT_SHADOW_SHADER_ELIMINATION(def) \
DRI_CONF_OPT_B(mht_robot_shadow_shader_elimination, def, \
"Eliminate draw call for Gfxbench Manhattan3.0 robot shadow when conditions apply.")

/**
* \brief Image quality-related options
*/
Expand Down

0 comments on commit 11b32d6

Please sign in to comment.