diff options
author | Kenneth Graunke <[email protected]> | 2014-07-26 01:16:27 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2014-10-09 15:43:18 +0200 |
commit | 4ce11de4ae356375833cb403711f5af1ed681965 (patch) | |
tree | 30947c344a5f4f0a0f6a755645a2cc7dca8b3fda /src/mesa/drivers/dri/i965 | |
parent | b7844d12487dbac702ecd734faeffa6fe1a61a83 (diff) |
i965: Skip uploading border color when unnecessary.
The border color is only needed when using the GL_CLAMP_TO_BORDER or
(deprecated) GL_CLAMP wrap modes; all others ignore it, including the
common GL_CLAMP_TO_EDGE and GL_REPEAT wrap modes.
In those cases, we can skip uploading it entirely, saving a bit of space
in the batchbuffer. Instead, we just point it at the start of the
batch (offset 0); we have to program something, and that address is safe
to read.
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Chris Forbes <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_sampler_state.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c b/src/mesa/drivers/dri/i965/brw_sampler_state.c index 5855af6d2bf..8363a48ef71 100644 --- a/src/mesa/drivers/dri/i965/brw_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c @@ -186,6 +186,16 @@ translate_wrap_mode(struct brw_context *brw, GLenum wrap, bool using_nearest) } /** + * Return true if the given wrap mode requires the border color to exist. + */ +static bool +wrap_mode_needs_border_color(unsigned wrap_mode) +{ + return wrap_mode == BRW_TEXCOORDMODE_CLAMP_BORDER || + wrap_mode == GEN8_TEXCOORDMODE_HALF_BORDER; +} + +/** * Upload SAMPLER_BORDER_COLOR_STATE. */ static void @@ -431,8 +441,16 @@ brw_update_sampler_state(struct brw_context *brw, S_FIXED(CLAMP(texUnit->LodBias + sampler->LodBias, -16, 15), lod_bits); const unsigned base_level = U_FIXED(0, 1); - uint32_t border_color_offset; - upload_default_color(brw, sampler, unit, &border_color_offset); + /* Upload the border color if necessary. If not, just point it at + * offset 0 (the start of the batch) - the color should be ignored, + * but that address won't fault in case something reads it anyway. + */ + uint32_t border_color_offset = 0; + if (wrap_mode_needs_border_color(wrap_s) || + wrap_mode_needs_border_color(wrap_t) || + wrap_mode_needs_border_color(wrap_r)) { + upload_default_color(brw, sampler, unit, &border_color_offset); + } const bool non_normalized_coords = texObj->Target == GL_TEXTURE_RECTANGLE; |