~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychOneliners/LoadIdentityClut.m

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
% Get current clut for use as backup copy later on:
79
79
oldClut = Screen('ReadNormalizedGammaTable', windowPtr);
80
80
 
 
81
% Try to use PsychGPUControl() method to disable display dithering
 
82
% globally on all connected GPUs and displays. As of March 2013, this
 
83
% function is only supported on Linux and Windows with AMD/ATI GPU's,
 
84
% and only when running the proprietary Catalyst display driver.
 
85
% It will no-op silently on other system configurations.
 
86
%
 
87
% We don't use the success status return code of the function, because
 
88
% we don't know how trustworthy it is. Also this only affects dithering,
 
89
% not gamma table identity setup, so the code-pathes below must run anyway
 
90
% for proper setup, even if their dithering disable effect may be redundant.
 
91
PsychGPUControl('SetDitheringEnabled', 0);
 
92
 
81
93
% Ask Screen to use low-level setup code to configure the GPU for
82
94
% untampered framebuffer pixel paththrough. This is only supported on a
83
95
% subset of GPU's under certain conditions if the PsychtoolboxKernelDriver
139
151
        else
140
152
            % Full blown LUT given:
141
153
            lut = lutconfig;
142
 
            if ~isnumeric(lut) | size(lut,1) < 1 | size(lut,2) ~= 3 %#ok<OR2>
 
154
            if ~isnumeric(lut) || size(lut,1) < 1 || size(lut,2) ~= 3
143
155
                sca;
144
156
                error('LoadIdentityClut: Loaded data from config file is not a valid LUT! Not a numeric matrix or less than 1 row, or not 3 columns!');
145
157
            end
161
173
        % We derive type of hardware and thereby our strategy from the vendor name:
162
174
        gfxhwtype = winfo.GLVendor;
163
175
 
164
 
        if ~isempty(strfind(gfxhwtype, 'NVIDIA')) | ~isempty(strfind(gfxhwtype, 'nouveau'))
 
176
        if ~isempty(strfind(gfxhwtype, 'NVIDIA')) || ~isempty(strfind(gfxhwtype, 'nouveau'))
165
177
            % NVidia card:
166
178
 
167
179
            % We start with assumption that it is a "normal" one:
174
186
            end
175
187
            
176
188
            % Is it a Geforce-8000 or later (G80 core or later) and is this OS/X?
177
 
            if ~isempty(strfind(winfo.GPUCoreId, 'G80')) & IsOSX %#ok<AND2>
 
189
            if ~isempty(strfind(winfo.GPUCoreId, 'G80')) && IsOSX
178
190
                % 10.5.x Leopard?
179
 
                if (osxversion(1) == 10) & (osxversion(2) == 5) & (osxversion(3) >=0) %#ok<AND2>
 
191
                if (osxversion(1) == 10) && (osxversion(2) == 5) && (osxversion(3) >=0)
180
192
                    % Yes. One of the releases with an embarassing amount of bugs,
181
193
                    % brought to you by Apple. Need to apply an especially ugly
182
194
                    % clut to force these cards into an identity mapping:
185
197
                end
186
198
 
187
199
                % 10.6.x Snow Leopard or later?
188
 
                if (osxversion(1) == 10) & (osxversion(2) >= 6) & (osxversion(3) >=0) %#ok<AND2>
 
200
                if (osxversion(1) == 10) && (osxversion(2) >= 6) && (osxversion(3) >=0)
189
201
                    % Yes. One of the releases with an embarassing amount of bugs,
190
202
                    % brought to you by Apple. Need to apply an especially ugly
191
203
                    % clut to force these cards into an identity mapping:
211
223
                fprintf('LoadIdentityClut: NVidia Quadro or later on Linux with binary Blob detected. Enabling special type-III LUT.\n');
212
224
            end
213
225
        else
214
 
            if ~isempty(strfind(gfxhwtype, 'ATI')) | ~isempty(strfind(gfxhwtype, 'AMD')) | ~isempty(strfind(gfxhwtype, 'Advanced Micro Devices')) | ...
215
 
                    ~isempty(strfind(winfo.GLRenderer, 'DRI R')) | ~isempty(strfind(winfo.GLRenderer, 'on ATI R')) %#ok<OR2>
 
226
            if ~isempty(strfind(gfxhwtype, 'ATI')) || ~isempty(strfind(gfxhwtype, 'AMD')) || ~isempty(strfind(gfxhwtype, 'Advanced Micro Devices')) || ...
 
227
                    ~isempty(strfind(winfo.GLRenderer, 'DRI R')) || ~isempty(strfind(winfo.GLRenderer, 'on ATI R'))
216
228
                % ATI card:
217
229
 
218
230
                % A good default at least on OS/X is type 1:
219
231
                gfxhwtype = 1;
220
232
 
221
 
                if (IsWin | IsLinux) & ~isempty(strfind(winfo.GPUCoreId, 'R600')) %#ok<OR2,AND2>
 
233
                if (IsWin || IsLinux) && ~isempty(strfind(winfo.GPUCoreId, 'R600'))
222
234
                    % At least the Radeon HD 3470 under Windows Vista and Linux needs type 0
223
235
                    % LUT's. Let's assume for the moment this is true for all R600
224
236
                    % cores, ie., all Radeon HD series cards.
225
237
                    fprintf('LoadIdentityClut: ATI Radeon HD-2000 or later detected. Enabling special type-0 LUT hacks for totally broken drivers.\n');
226
238
                    gfxhwtype = 0;
227
 
                elseif (IsLinux) & (~isempty(strfind(winfo.GLRenderer, 'DRI R')) | ~isempty(strfind(winfo.GLRenderer, 'on ATI R'))) %#ok<OR2,AND2>
 
239
                elseif (IsLinux) && (~isempty(strfind(winfo.GLRenderer, 'DRI R')) || ~isempty(strfind(winfo.GLRenderer, 'on ATI R')))
228
240
                    % At least the Radeon R3xx/4xx/5xx under Linux with DRI2 Mesa needs type 0
229
241
                    % LUT's. Let's assume for the moment this is true for all R600
230
242
                    % cores, ie., all Radeon HD series cards.
271
283
        oldClut = Screen('LoadNormalizedGammaTable', windowPtr, ((1/256:1/256:1)' * ones(1, 3)), loadOnNextFlip);
272
284
    end
273
285
 
274
 
    if gfxhwtype == 2 & IsOSX %#ok<AND2>
 
286
    if gfxhwtype == 2 && IsOSX
275
287
        % This works on OS/X 10.5 with NVidia GeForce 8800. It is an ugly hack
276
288
        % to compensate for the absolutely horrible, embarassing bugs in Apple's NVidia
277
289
        % graphics drivers and their clut handling. Does this company still
285
297
        oldClut = Screen('LoadNormalizedGammaTable', windowPtr, loadlut, loadOnNextFlip);
286
298
    end
287
299
 
288
 
    if gfxhwtype == 3 & IsOSX %#ok<AND2>
 
300
    if gfxhwtype == 3 && IsOSX
289
301
        % This works on OS/X 10.6.0 with NVidia Geforce-9200M according to CRS
290
302
        % and with 10.6.0 with Geforce-8800  in the MacPro according to
291
303
        % me. We assume this works on all G80 et al. GPU's:
300
312
        oldClut = Screen('LoadNormalizedGammaTable', windowPtr, loadlut, loadOnNextFlip);
301
313
    end
302
314
 
303
 
    if gfxhwtype == 3 & IsWin %#ok<AND2>
 
315
    if gfxhwtype == 3 && IsWin
304
316
        % This is an experimental variant of the OS/X type 3 lut, but with 256
305
317
        % slots. It is supposed for WindowsXP, assuming some NVidia GPU's,
306
318
        % e.g., some QuadroFX 3700 GPU's have similar problems:
315
327
        oldClut = Screen('LoadNormalizedGammaTable', windowPtr, loadlut, loadOnNextFlip);
316
328
    end
317
329
 
318
 
    if gfxhwtype == 3 & IsLinux %#ok<AND2>
 
330
    if gfxhwtype == 3 && IsLinux
319
331
        % NVidia QuadroFX cards with binary blob and lut's with more than
320
332
        % 256 slots. Upload a standard linear lut with matching number of
321
333
        % slots: