# Engine.setHardwareScalingLevel() doesn't work if adaptToDeviceRatio = true

**URL:** <https://forum.babylonjs.com/t/engine-sethardwarescalinglevel-doesnt-work-if-adapttodeviceratio-true/29905>\
**Category:** Bugs\
**Created:** [May 1, 2022, 12:14pm UTC](https://forum.babylonjs.com/t/engine-sethardwarescalinglevel-doesnt-work-if-adapttodeviceratio-true/29905 "2022-05-01T12:14:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MiikaH](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/miikah/32/23054_2.png) [@MiikaH](https://forum.babylonjs.com/u/MiikaH)\
**Post date:** [May 1, 2022, 12:14pm UTC](https://forum.babylonjs.com/t/engine-sethardwarescalinglevel-doesnt-work-if-adapttodeviceratio-true/29905/1 "2022-05-01T12:14:57Z")

</div>

Engine `setHardwareScalingLevel()` option doesn’t do anything if engine has been initialized with `adaptToDeviceRatio` = true option.

I can’t create a Playground test case because I’m not sure how to alter the engine initialization options there.

The issue happens because the engine `resize()` function replaces `_hardwareScalingLevel` with devicePixelRatio on this line: [Babylon.js/thinEngine.ts at 5406aca3f55afdda974600032c21af71aae4190a · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/blob/5406aca3f55afdda974600032c21af71aae4190a/packages/dev/core/src/Engines/thinEngine.ts#L1718)

It should rather add a multiplier that is applied on top of the user defined hardwareScalingLevel.

Also, it would be good if it was possible to change adaptToDeviceRatio value afterwards. This would allow for example measuring performance with adaptToDeviceRatio = true and then disable it if frame times are unnecessarily long and ratio is high enough to make a difference.

Although I know that as a workaround I can just manipulate the hardwareScalingLevel manually with `devicePixelRatio` factor in mind and keep `adaptToDeviceRatio` disabled. 🙂

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 2, 2022, 3:08pm UTC](https://forum.babylonjs.com/t/engine-sethardwarescalinglevel-doesnt-work-if-adapttodeviceratio-true/29905/2 "2022-05-02T15:08:06Z")

</div>

This is actually by design, you are either in a manual mode or an automated one. we could disable automatic mode when setting manually a value but I wonder how much of a breaking change it could be @Deltakosh ?

---

<div class="post-metadata">

**Author:** ![MiikaH](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/miikah/32/23054_2.png) [@MiikaH](https://forum.babylonjs.com/u/MiikaH)\
**Post date:** [May 2, 2022, 4:00pm UTC](https://forum.babylonjs.com/t/engine-sethardwarescalinglevel-doesnt-work-if-adapttodeviceratio-true/29905/3 "2022-05-02T16:00:06Z")

</div>

Alternative would be to just make it clearer in `setHardwareScalingLevel` documentation that it only works if engine was initialized without `adaptToDeviceRatio`. That could save the next person some debug time trying to figure out why it doesn’t work. 🙂

Personally I just assumed that `adaptToDeviceRatio` defines if rendering happens at native resolution or at possibly lower “DPI base resolution” (which is pretty much what the setting does). But I incorrectly thought that hardware scaling level would be a separate factor on top of that to adjust the resolution.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [May 2, 2022, 6:01pm UTC](https://forum.babylonjs.com/t/engine-sethardwarescalinglevel-doesnt-work-if-adapttodeviceratio-true/29905/4 "2022-05-02T18:01:01Z")

</div>

Yeah I would recommend a better documentation than a code change

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 2, 2022, 6:38pm UTC](https://forum.babylonjs.com/t/engine-sethardwarescalinglevel-doesnt-work-if-adapttodeviceratio-true/29905/5 "2022-05-02T18:38:27Z")

</div>

I ll do it in my open PR

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 2, 2022, 6:50pm UTC](https://forum.babylonjs.com/t/engine-sethardwarescalinglevel-doesnt-work-if-adapttodeviceratio-true/29905/6 "2022-05-02T18:50:46Z")

</div>

Actually it is a regression from [Updated ThinEngine resize to optionally take device pixel ratio into … · BabylonJS/Babylon.js@04383a2 · GitHub](https://github.com/BabylonJS/Babylon.js/commit/04383a23bcee00dda17c54dd92723cab93164b12) cause we should be able to change it for the perf optimizer for instance… I ll handle it in another PR

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [June 1, 2022, 10:45am UTC](https://forum.babylonjs.com/t/engine-sethardwarescalinglevel-doesnt-work-if-adapttodeviceratio-true/29905/7 "2022-06-01T10:45:28Z")

</div>

Hi @sebavan just checking in if this was merged
