mesa: Skip update_gl_clamp() if samplers need clamp

update_gl_clamp() was ~12% of drawoverhead -test 40.. this turns it into
a no-op when no clamp lowering is needed.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23149>
This commit is contained in:
Rob Clark
2023-05-20 06:37:32 -07:00
committed by Marge Bot
parent 3e44b14af8
commit 15c66adc8a
3 changed files with 11 additions and 0 deletions
+2
View File
@@ -1323,6 +1323,8 @@ struct gl_texture_attrib
/** GL_ARB_seamless_cubemap */
GLboolean CubeMapSeamless;
GLshort NumSamplersWithClamp;
struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
struct gl_fixedfunc_texture_unit FixedFuncUnit[MAX_TEXTURE_COORD_UNITS];
};
+6
View File
@@ -195,10 +195,16 @@ update_sampler_gl_clamp(struct gl_context *ctx, struct gl_sampler_object *samp,
if (cur_state == new_state)
return;
ctx->NewDriverState |= ctx->DriverFlags.NewSamplersWithClamp;
uint8_t old_mask = samp->glclamp_mask;
if (new_state)
samp->glclamp_mask |= wrap;
else
samp->glclamp_mask &= ~wrap;
if (old_mask && !samp->glclamp_mask)
ctx->Texture.NumSamplersWithClamp--;
else if (samp->glclamp_mask && !old_mask)
ctx->Texture.NumSamplersWithClamp++;
}
#ifdef __cplusplus
}
+3
View File
@@ -79,6 +79,9 @@ update_gl_clamp(struct st_context *st, struct gl_program *prog, uint32_t *gl_cla
if (!st->emulate_gl_clamp)
return;
if (!st->ctx->Texture.NumSamplersWithClamp)
return;
gl_clamp[0] = gl_clamp[1] = gl_clamp[2] = 0;
GLbitfield samplers_used = prog->SamplersUsed;
unsigned unit;