# How can I use Variable Refresh Rate(VRR)?

**URL:** <https://psychtoolbox.discourse.group/t/how-can-i-use-variable-refresh-rate-vrr/4746>\
**Category:** Hardware\
**Tags:** linux, gpu\
**Created:** [December 14, 2022, 2:11pm UTC](https://psychtoolbox.discourse.group/t/how-can-i-use-variable-refresh-rate-vrr/4746 "2022-12-14T14:11:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AzerilA](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@AzerilA](https://psychtoolbox.discourse.group/u/AzerilA)\
**Post date:** [December 14, 2022, 2:11pm UTC](https://psychtoolbox.discourse.group/t/how-can-i-use-variable-refresh-rate-vrr/4746/1 "2022-12-14T14:11:16Z")

</div>

Hello. I am trying to use the VRR feature in my test. I have almost all the requirements that be recommendations. I want to display a simple image stimulus in the scale of milliseconds and even under ten milliseconds. But after calculating the duration time of the image stimulus, I don’t see any sign of applying the settings. That is, it displays with the same constant refresh rate. Or it does not show a reasonable time:

Linux 22.04  
AMD RX 580  
monitor 240hz (280 overclock)  
and PTB\_info:

```
PTB-INFO: This is Psychtoolbox-3 for GNU/Linux X11, under Matlab 64-Bit (Version 3.0.18 - 
  Build date: Jun 27 2022).
PTB-INFO: OS support status: Linux 5.15.0-56-lowlatency Supported.
PTB-INFO: Type 'PsychtoolboxVersion' for more detailed version information.
PTB-INFO: Most parts of the Psychtoolbox distribution are licensed to you under terms of the 
  MIT License, with
PTB-INFO: some restrictions. See file 'License.txt' in the Psychtoolbox root folder for the 
  exact licensing conditions.

PTB-INFO: For information about paid support, support memberships and other commercial 
  services, please type
PTB-INFO: 'PsychPaidSupportAndServices'.

PTB-INFO: Connected to Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 
  470/480/570/570X/580/580X/590] GPU with DCE-11.0 display engine [6 heads].

PTB-INFO: OpenGL-Renderer is AMD :: AMD Radeon RX 580 Series (polaris10, LLVM 13.0.1, DRM 
   3.42, 5.15.0-56-lowlatency) :: 4.6 (Compatibility Profile) Mesa 22.0.5
PTB-INFO: VBL startline = 1080 , VBL Endline = 1201
PTB-INFO: Measured monitor refresh interval from beamposition = 6.959837 ms [143.681519 Hz].
PTB-INFO: Measured monitor refresh interval from VBLsync = 6.944456 ms [143.999758 Hz]. (50 
   valid samples taken, stddev=0.000654 ms.)
PTB-INFO: Reported monitor refresh interval from operating system = 6.944444 ms [144.000000 
   Hz].
PTB-INFO: Small deviations between reported values are normal and no reason to worry.
PTB-INFO: Enabling Variable Refresh Rate VRR mode, using method 3 and timing style 0.
PTB-INFO: Assuming minimum VRR refresh duration 6.944444 msecs, maximum duration 
   33.333333 msecs.
PTB-INFO: Using initial VRR latency compensation of 0.720317 msecs.
PTB-INFO: Psychtoolbox imaging pipeline starting up for window with requested imagingmode 1061 
 ...
PTB-INFO: Will use 32 bits per color component floating point framebuffer for stimulus drawing. 
   Alpha blending should work correctly.
PTB-INFO: Will use 32 bits per color component floating point framebuffer for stimulus post- 
   processing (if any).
Building a fragment shader:Reading shader from file /usr/share/psychtoolbox- 
3/PsychOpenGL/PsychGLSLShaders/ICMSimpleGammaCorrectionShader.frag.txt ...
CreatePseudoGrayLUT: The LUT has 1792 unique potential luminance encodings, for up to 
10.807355 bpc simulated luminance precision.
Compiling all shaders matching GenericLuminanceToRGBA8_FormattingShader * into a GLSL 
     program.
 Building a fragment shader:Reading shader from file /usr/share/psychtoolbox- 
   3/PsychOpenGL/PsychGLSLShaders/GenericLuminanceToRGBA8_FormattingShader.frag.txt ...
 PsychImaging-EnablePseudoGrayOutput: Creating 4096 slot LUT suitable for precision boosting of 
     a 8 bpc native framebuffer and display or DAC.
 PsychHelperCreateGenericLuminanceToRGBA16MaxLUT: Using RGBA8 LUT with bit depths 
     [16,16,16] for targetBpc 8
 PTB-INFO: Switching stimulus onset scheduling to use of our own VRR scheduler.

```

I used PsychImaging for the screen configuration, and in the following code, I use ‘when’ for the flip command:

```
        if exist('onCleanup', 'class'), oC_Obj = onCleanup(@()sca); end 
        %Prepare setup of imaging pipeline for onscreen window.
        PsychImaging('PrepareConfiguration'); 
        PsychImaging('AddTask', 'General', 'UseVirtualFramebuffer');
        PsychImaging('AddTask', 'General', 'UseFineGrainedTiming', 'Simple');
        PsychImaging('AddTask', 'General', 'NormalizedHighresColorRange'); 
        PsychImaging('AddTask', 'FinalFormatting', 'DisplayColorCorrection', 'SimpleGamma');
        PsychImaging('AddTask', 'General', 'EnablePseudoGrayOutput');
        
        ...

        [windowPtr, screenRect] = PsychImaging('OpenWindow',obj.whichScreen, ... 
                   obj.screenBackground, [], [], [], [], [],[],[],[],[],1);

        PsychColorCorrection('SetEncodingGamma', windowPtr, 1 / obj.screenGamma);

        ...

        [StimOutputFeedback.t_start_stim(iterator)] = Screen('Flip', DisplaySetup.windowPtr,0);

        [StimOutputFeedback.t_end_stim(iterator)] = Screen('Flip', DisplaySetup.windowPtr,0.008);

        Screen('DrawTexture', DisplaySetup.windowPtr, StimProperties.tex_mask);

```

It doesn’t work at all and waits until the basic refresh rate, which is about 4 milliseconds.

I would be very grateful if you could help me.

Sorry, I forgot to mention that I didn’t install the pro driver either. I also implemented the requirements recommended for Ubuntu, such as:  
XOrgConfCreator  
PsychLinuxconfiguration

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [December 14, 2022, 5:29pm UTC](https://psychtoolbox.discourse.group/t/how-can-i-use-variable-refresh-rate-vrr/4746/2 "2022-12-14T17:29:13Z")

</div>

Should work unless there is some user error / misconfiguration / misunderstanding etc.

For up to 30 minutes of advice please post your paid support authentication token, cfe. `help PsychPaidSupportAndServices` for the process. Also see our special discounted christmas offer: [Get support memberships for 99 Euros + tax only! Limited offer!](https://psychtoolbox.discourse.group/t/get-support-memberships-for-99-euros-tax-only-limited-offer/4712/1)

Best,  
-mario

---

<div class="post-metadata">

**Author:** ![pgerhardstein](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@pgerhardstein](https://psychtoolbox.discourse.group/u/pgerhardstein)\
**Post date:** [December 15, 2022, 8:04pm UTC](https://psychtoolbox.discourse.group/t/how-can-i-use-variable-refresh-rate-vrr/4746/3 "2022-12-15T20:04:32Z")

</div>

Lots of ways to miss something important in this type of set up - well worth the fee to engage Mario for a consultation
