[Mesa-dev] [PATCH] i965: Validate (and resolve) all the bound textures.

Kenneth Graunke kenneth at whitecape.org
Sat Feb 22 12:25:22 PST 2014


On 02/21/2014 09:09 PM, Chris Forbes wrote:
> BRW_MAX_TEX_UNIT is the static limit on the number of textures we
> support per-stage, not in total.
> 
> Core's `Unit` array is sized by MAX_COMBINED_TEXTURE_IMAGE_UNITS, which
> is significantly larger, and across the various shader stages, up to
> ctx->Const.MaxCombinedTextureImageUnits elements of it may be actually
> used.
> 
> Fixes invisible bad behavior in piglit's max-samplers test (although
> this escalated to an assertion failure on HSW with texture_view, since
> non-immutable textures only have _Format set by validation.)
> 
> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> Cc: "9.2 10.0 10.1" <mesa-stable at lists.freedesktop.org>
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_draw.c | 2 +-
>  src/mesa/drivers/dri/i965/brw_tex.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
> index 540834c..bc887fe 100644
> --- a/src/mesa/drivers/dri/i965/brw_draw.c
> +++ b/src/mesa/drivers/dri/i965/brw_draw.c
> @@ -317,7 +317,7 @@ brw_predraw_resolve_buffers(struct brw_context *brw)
>     /* Resolve depth buffer of each enabled depth texture, and color buffer of
>      * each fast-clear-enabled color texture.
>      */
> -   for (int i = 0; i < BRW_MAX_TEX_UNIT; i++) {
> +   for (int i = 0; i < ctx->Const.MaxCombinedTextureImageUnits; i++) {
>        if (!ctx->Texture.Unit[i]._ReallyEnabled)
>  	 continue;
>        tex_obj = intel_texture_object(ctx->Texture.Unit[i]._Current);
> diff --git a/src/mesa/drivers/dri/i965/brw_tex.c b/src/mesa/drivers/dri/i965/brw_tex.c
> index 9234e3a..b1f4de0 100644
> --- a/src/mesa/drivers/dri/i965/brw_tex.c
> +++ b/src/mesa/drivers/dri/i965/brw_tex.c
> @@ -47,7 +47,7 @@ void brw_validate_textures( struct brw_context *brw )
>     struct gl_context *ctx = &brw->ctx;
>     int i;
>  
> -   for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
> +   for (i = 0; i < ctx->Const.MaxCombinedTextureImageUnits; i++) {
>        struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
>  
>        if (texUnit->_ReallyEnabled) {
> 

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

I am concerned, though, that looping through all 96 texture units on
every draw call may be bad for performance on CPU-bound workloads.

I wonder if we couldn't use an approach similar to
update_stage_texture_surfaces, i.e.:

struct gl_program *progs = {
   &brw->vertex_program, &brw->geometry_program, &brw->fragment_program
};

for (int p = 0; p < 3; p++) {
   const gl_program *prog = progs[p];
   unsigned num_samplers = _mesa_fls(prog->SamplersUsed);
   for (int i = 0; i < num_samplers; i++) {
      if (prog->SamplersUsed & (1 << i)) {
         if (prog->SamplerUnits[i])
            intel_finalize_mipmap_tree(brw, i);
   }
}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140222/cad6f89b/attachment.pgp>


More information about the mesa-dev mailing list