From: Roland Scheidegger <srol...@vmware.com> Some apps are known to require more than 16. Albeit they probably still won't run with 18 (since all new hw/drivers support 32) it shouldn't hurt to at least support 18 (seemingly the hw limit on all r600-ni chips - the blob also supports 18, at least for eg+ by the looks of it).
Unfortunately border colors do not work for the last 2 units. The reg guide says there is a 5 bit index for setting border colors, but this is a lie. piglit max-samplers shows that indeed setting border color for units 16/17 (per stage) will simply overwrite the border color for units 0/1, and sampling will consequently also use those border color values for sampling on units 16/17. (For eg - no idea about ni.) This will cause piglit max-samplers border to fail, but meh... border colors are more or less totally busted (sampler swizzling...) on that hw anyway. Border colors should still work if not both units 0 and 16 (or units 1 and 17) use a border color simultaneously. Setting border color values on r600/r700 is different, and I have no idea if the hw would also wrap-around when trying to use border colors or do something crazy (like locking up...) so don't increase the limit there (since the blob doesn't do it I'm not sure if it would be safe). --- src/gallium/drivers/r600/evergreen_state.c | 7 +++++++ src/gallium/drivers/r600/r600_pipe.c | 6 +++++- src/gallium/drivers/r600/r600_pipe.h | 8 ++++---- src/gallium/drivers/r600/r600_state_common.c | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index fb1de9cbf4..55a460053c 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -2372,6 +2372,13 @@ static void evergreen_emit_sampler_states(struct r600_context *rctx, radeon_emit(cs, (resource_id_base + i) * 3); radeon_emit_array(cs, rstate->tex_sampler_words, 3); + /* + * Note for sampler 16/17 this will overwrite border color + * on sampler 0/1. As long as border color isn't used on + * both units 0 and 16 (or 1 and 17) it should actually work + * since the sampler also appears to remap those border color + * values the same way. + */ if (rstate->border_color_use) { radeon_set_config_reg_seq(cs, border_index_reg, 5); radeon_emit(cs, i); diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 95aa2e5383..7f9500ad4b 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -595,7 +595,11 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, return 1; case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: - return 16; + /* + * There is potentially even more trouble with border colors + * for units 16/17 on r600/r700, so only enable 18 on eg+ + */ + return rscreen->b.family >= CHIP_CEDAR ? R600_NUM_TEX_UNITS : 16; case PIPE_SHADER_CAP_PREFERRED_IR: if (shader == PIPE_SHADER_COMPUTE) { return PIPE_SHADER_IR_NATIVE; diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 112b5cbb83..e2bd7b0a99 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -366,7 +366,7 @@ struct r600_pipe_sampler_state { }; /* needed for blitter save */ -#define NUM_TEX_UNITS 16 +#define R600_NUM_TEX_UNITS 18 struct r600_seamless_cube_map { struct r600_atom atom; @@ -375,7 +375,7 @@ struct r600_seamless_cube_map { struct r600_samplerview_state { struct r600_atom atom; - struct r600_pipe_sampler_view *views[NUM_TEX_UNITS]; + struct r600_pipe_sampler_view *views[R600_NUM_TEX_UNITS]; uint32_t enabled_mask; uint32_t dirty_mask; uint32_t compressed_depthtex_mask; /* which textures are depth */ @@ -385,7 +385,7 @@ struct r600_samplerview_state { struct r600_sampler_states { struct r600_atom atom; - struct r600_pipe_sampler_state *states[NUM_TEX_UNITS]; + struct r600_pipe_sampler_state *states[R600_NUM_TEX_UNITS]; uint32_t enabled_mask; uint32_t dirty_mask; uint32_t has_bordercolor_mask; /* which states contain the border color */ @@ -394,7 +394,7 @@ struct r600_sampler_states { struct r600_textures_info { struct r600_samplerview_state views; struct r600_sampler_states states; - bool is_array_sampler[NUM_TEX_UNITS]; + bool is_array_sampler[R600_NUM_TEX_UNITS]; }; struct r600_shader_driver_constants_info { diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index b49b05608d..0096282ec5 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -479,7 +479,7 @@ static void r600_bind_sampler_states(struct pipe_context *pipe, } memcpy(dst->states.states, rstates, sizeof(void*) * count); - memset(dst->states.states + count, 0, sizeof(void*) * (NUM_TEX_UNITS - count)); + memset(dst->states.states + count, 0, sizeof(void*) * (R600_NUM_TEX_UNITS - count)); dst->states.enabled_mask &= ~disable_mask; dst->states.dirty_mask &= dst->states.enabled_mask; -- 2.12.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev