CLUTMapLength = Length of CLUT to test. Reasonable values would be
256, …, 2048. Values up to 8192 would work on modern GPU’s, values
up to 16384 might work on the latest gen hardware from 2017.
If omitted, the test will run itself with CLUTMapLength 256 and 2048.
This test is derived from CLUTMappingBug.m, written by Denis Pelli,
which demonstrated the following bug in the May 2017 PTB release, which
is now fixed, as this test should verify:
This program demonstrates a bug in the software CLUT mapping that
appeared in the May 2017 release of Psychtoolbox. It seems that the
rounding rule has changed for conversion of the floating point color
(argument to FillRect)) to selection of the index in the software CLUT. My
programs use the software CLUT. They were reliably displaying my stimuli.
Since the new release, my stimuli are distorted as though my floating
point colors are mapped through the wrong CLUT entries.
MacBook Pro (Retina, 15-inch, Mid 2015). MATLAB 220.127.116.117246 (R2015b),
Psychtoolbox 3.0.14 beta.
This program loads the CLUT with a gray ramp, and then sets two CLUT
entries (rectEntry and screenEntry) to green. It then uses FillRect to
fill the whole screen with the color of screenEntry, and then a small
rect with the color of rectEntry. If everything works, then both color
values should display the same green. This works fine when the clut
length is short (e.g. 256) and and the entry numbers are small (under
100). This fails when the clut length is large or the entry number is
large. When the CLUT size is 2048, this fails even for entry 1. Very
likely we’re missing the right CLUT entry by just one, but that is a very
obvious fail here because only two CLUT entries are green. Off by one is
terrible for my psychophysical programs as well.
If you set CLUTMapLength=256 and rectEntry=20, then everything works
fine, and you get the same green over the whole screen, as you should. If
you then set rectEntry=128, then the rect will be gray, not green. If you
increase CLUTMapLength to 2048 then you’ll get no green, as the rect
and the screen background are black.
This seems to be a problem in the rounding rule used to convert the
floating point color argument of FillRect to an index in the CLUT.
I am very surprised to find that the bug disappears if I turn on
EnableNative10BitFramebuffer while running on my MacBook Pro. In my
psychophysical software, I always have that on, yet I’m encountering the
rounding bug. I’m not sure what might be different between this demo and
my psychophysical software. I wrote this program to isolate the problem I
was having in that software.
May 30, 2017