[Mesa-dev] [PATCH] softpipe: fix up NUM_ENTRIES confusion
Jose Fonseca
jfonseca at vmware.com
Thu Mar 14 07:46:49 PDT 2013
Looks good. Thanks.
I saw this warning transiently, but then couldn't see it again -- completely forgot that I needed to rebuild in order to force a recompile.
Jose
----- Original Message -----
> There were two different NUM_ENTRIES #defines for the framebuffer
> tile cache and the texture tile cache. Rename the later to fix
> the warnings:
>
> In file included from sp_flush.c:40:0:
> sp_tex_tile_cache.h:76:0: warning: "NUM_ENTRIES" redefined
> sp_tile_cache.h:78:0: note: this is the location of the previous definition
> In file included from sp_context.c:50:0:
> sp_tex_tile_cache.h:76:0: warning: "NUM_ENTRIES" redefined
> sp_tile_cache.h:78:0: note: this is the location of the previous definition
>
> Also, replace occurances of NUM_ENTRIES with Element() macro to
> be safer.
> ---
> src/gallium/drivers/softpipe/sp_tex_tile_cache.c | 12 ++++++------
> src/gallium/drivers/softpipe/sp_tex_tile_cache.h | 4 ++--
> src/gallium/drivers/softpipe/sp_tile_cache.c | 10 +++++-----
> 3 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
> b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
> index b6a848b..af1024d 100644
> --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
> +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
> @@ -55,7 +55,7 @@ sp_create_tex_tile_cache( struct pipe_context *pipe )
> tc = CALLOC_STRUCT( softpipe_tex_tile_cache );
> if (tc) {
> tc->pipe = pipe;
> - for (pos = 0; pos < NUM_ENTRIES; pos++) {
> + for (pos = 0; pos < Elements(tc->entries); pos++) {
> tc->entries[pos].addr.bits.invalid = 1;
> }
> tc->last_tile = &tc->entries[0]; /* any tile */
> @@ -70,7 +70,7 @@ sp_destroy_tex_tile_cache(struct softpipe_tex_tile_cache
> *tc)
> if (tc) {
> uint pos;
>
> - for (pos = 0; pos < NUM_ENTRIES; pos++) {
> + for (pos = 0; pos < Elements(tc->entries); pos++) {
> /*assert(tc->entries[pos].x < 0);*/
> }
> if (tc->transfer) {
> @@ -97,7 +97,7 @@ sp_tex_tile_cache_validate_texture(struct
> softpipe_tex_tile_cache *tc)
> assert(tc);
> assert(tc->texture);
>
> - for (i = 0; i < NUM_ENTRIES; i++) {
> + for (i = 0; i < Elements(tc->entries); i++) {
> tc->entries[i].addr.bits.invalid = 1;
> }
> }
> @@ -147,7 +147,7 @@ sp_tex_tile_cache_set_sampler_view(struct
> softpipe_tex_tile_cache *tc,
>
> /* mark as entries as invalid/empty */
> /* XXX we should try to avoid this when the teximage hasn't changed */
> - for (i = 0; i < NUM_ENTRIES; i++) {
> + for (i = 0; i < Elements(tc->entries); i++) {
> tc->entries[i].addr.bits.invalid = 1;
> }
>
> @@ -169,7 +169,7 @@ sp_flush_tex_tile_cache(struct softpipe_tex_tile_cache
> *tc)
>
> if (tc->texture) {
> /* caching a texture, mark all entries as empty */
> - for (pos = 0; pos < NUM_ENTRIES; pos++) {
> + for (pos = 0; pos < Elements(tc->entries); pos++) {
> tc->entries[pos].addr.bits.invalid = 1;
> }
> tc->tex_face = -1;
> @@ -194,7 +194,7 @@ tex_cache_pos( union tex_tile_address addr )
> addr.bits.face +
> addr.bits.level * 7);
>
> - return entry % NUM_ENTRIES;
> + return entry % NUM_TEX_TILE_ENTRIES;
> }
>
> /**
> diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
> b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
> index 31f21bf..b55c493 100644
> --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
> +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
> @@ -73,7 +73,7 @@ struct softpipe_tex_cached_tile
> } data;
> };
>
> -#define NUM_ENTRIES 4
> +#define NUM_TEX_TILE_ENTRIES 4
>
> struct softpipe_tex_tile_cache
> {
> @@ -84,7 +84,7 @@ struct softpipe_tex_tile_cache
> struct pipe_resource *texture; /**< if caching a texture */
> unsigned timestamp;
>
> - struct softpipe_tex_cached_tile entries[NUM_ENTRIES];
> + struct softpipe_tex_cached_tile entries[NUM_TEX_TILE_ENTRIES];
>
> struct pipe_transfer *tex_trans;
> void *tex_trans_map;
> diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c
> b/src/gallium/drivers/softpipe/sp_tile_cache.c
> index b6dd6af..1f9c3dd 100644
> --- a/src/gallium/drivers/softpipe/sp_tile_cache.c
> +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
> @@ -99,7 +99,7 @@ sp_create_tile_cache( struct pipe_context *pipe )
> tc = CALLOC_STRUCT( softpipe_tile_cache );
> if (tc) {
> tc->pipe = pipe;
> - for (pos = 0; pos < NUM_ENTRIES; pos++) {
> + for (pos = 0; pos < Elements(tc->tile_addrs); pos++) {
> tc->tile_addrs[pos].bits.invalid = 1;
> }
> tc->last_tile_addr.bits.invalid = 1;
> @@ -134,7 +134,7 @@ sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
> if (tc) {
> uint pos;
>
> - for (pos = 0; pos < NUM_ENTRIES; pos++) {
> + for (pos = 0; pos < Elements(tc->entries); pos++) {
> /*assert(tc->entries[pos].x < 0);*/
> FREE( tc->entries[pos] );
> }
> @@ -419,7 +419,7 @@ sp_flush_tile_cache(struct softpipe_tile_cache *tc)
>
> if (pt) {
> /* caching a drawing transfer */
> - for (pos = 0; pos < NUM_ENTRIES; pos++) {
> + for (pos = 0; pos < Elements(tc->entries); pos++) {
> struct softpipe_cached_tile *tile = tc->entries[pos];
> if (!tile)
> {
> @@ -452,7 +452,7 @@ sp_alloc_tile(struct softpipe_tile_cache *tc)
> if (!tc->tile)
> {
> unsigned pos;
> - for (pos = 0; pos < NUM_ENTRIES; ++pos) {
> + for (pos = 0; pos < Elements(tc->entries); ++pos) {
> if (!tc->entries[pos])
> continue;
>
> @@ -608,7 +608,7 @@ sp_tile_cache_clear(struct softpipe_tile_cache *tc,
> /* set flags to indicate all the tiles are cleared */
> memset(tc->clear_flags, 255, sizeof(tc->clear_flags));
>
> - for (pos = 0; pos < NUM_ENTRIES; pos++) {
> + for (pos = 0; pos < Elements(tc->tile_addrs); pos++) {
> tc->tile_addrs[pos].bits.invalid = 1;
> }
> tc->last_tile_addr.bits.invalid = 1;
> --
> 1.7.3.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list