odd clut indexing in LoadNormalizedGammaTable?

I'm experiencing the following when using LoadNormalizedGammaTable in the latest beta
on OS X. I found the same behavior on a Dual 1.8 G5 GeForce FX5200 and on an iMac
Core 2 Duo Radeon X1600.

After loading a 256-line clut:
Anything I draw with color values 1-6 is drawn with the color on line 1 of the lookup table.
Anything I draw with color values 249-256 is drawn with the color on line 256
Accordingly, approximately every 20th line of the clut is never used.

If I understand how things are supposed work, the following code should make 10
columns of squares with colors vertically aligned. But I get the first six squares the same
and the last eight squares same, and a color gets skipped a little less than every two rows.

Am I doing something wrong?

Daw-An Wu
Caltech

%make table of 10 repeating colors, cut it at 256 rows
testClut= repmat([.4 .2 .2; 1 0 0; 1 .4 0; 1 1 0; 0 1 0;...
0 0 1; .8 .4 1; .6 .6 .6; 1 1 1; 0 0 0], [26 1]);
testClut= testClut(1:256,:);
%open window, load clut
win = screen('OpenWindow',0,1,[],8);
oldTable=screen('ReadNormalizedGammaTable',win);
screen('LoadNormalizedGammaTable',win,testClut);
%draw one square of each index color, in rows of 10.
for i = 1:256
screen('FillRect',win,i,[0 0 20 20] + [22 0 22 0]*rem(i-1,10) + [0 22 0 22]*fix((i-1)/10))
end
screen('Flip',win);
%show until mouse click
FlushEvents('mouseDown', 'mouseUp')
GetClicks;
%clean up
screen('LoadNormalizedGammaTable',win,oldTable);
screen CloseAll
Hmm. I ran your code on the MacBookPro (Radeon X1600 mobile) and on a PowerMac G5
1.6Ghz uniprocessor with GeforceFX5200 and can't reproduce this behaviour.

Your understanding is correct and i get exactly the results that you'd expect. Ten columns,
each of uniform color. Your for-loop should run from 0 to 255 instead of 1 to 256, but
other than that it behaves as expected.

Don't know? I'd say if it isn't a weird bug in your Matlab (did you print out your testClut?
Does it look as expected? If you do a 'ReadNormalizedGammaTable' after setting the clut,
does it match your testClut?) then it must be a driver bug. Strange thing is i'd expect your
drivers to be identical to mine.

Can anybody else reproduce this bug?
-mario


--- In psychtoolbox@yahoogroups.com, "Daw-An Wu" <daw-an@...> wrote:
>
> I'm experiencing the following when using LoadNormalizedGammaTable in the latest
beta
> on OS X. I found the same behavior on a Dual 1.8 G5 GeForce FX5200 and on an iMac
> Core 2 Duo Radeon X1600.
>
> After loading a 256-line clut:
> Anything I draw with color values 1-6 is drawn with the color on line 1 of the lookup
table.
> Anything I draw with color values 249-256 is drawn with the color on line 256
> Accordingly, approximately every 20th line of the clut is never used.
>
> If I understand how things are supposed work, the following code should make 10
> columns of squares with colors vertically aligned. But I get the first six squares the
same
> and the last eight squares same, and a color gets skipped a little less than every two
rows.
>
> Am I doing something wrong?
>
> Daw-An Wu
> Caltech
>
> %make table of 10 repeating colors, cut it at 256 rows
> testClut= repmat([.4 .2 .2; 1 0 0; 1 .4 0; 1 1 0; 0 1 0;...
> 0 0 1; .8 .4 1; .6 .6 .6; 1 1 1; 0 0 0], [26 1]);
> testClut= testClut(1:256,:);
> %open window, load clut
> win = screen('OpenWindow',0,1,[],8);
> oldTable=screen('ReadNormalizedGammaTable',win);
> screen('LoadNormalizedGammaTable',win,testClut);
> %draw one square of each index color, in rows of 10.
> for i = 1:256
> screen('FillRect',win,i,[0 0 20 20] + [22 0 22 0]*rem(i-1,10) + [0 22 0 22]*fix((i-1)/
10))
> end
> screen('Flip',win);
> %show until mouse click
> FlushEvents('mouseDown', 'mouseUp')
> GetClicks;
> %clean up
> screen('LoadNormalizedGammaTable',win,oldTable);
> screen CloseAll
>