使用在瀏覽器中運行的 webgl 創建 GPU 密集型 Web 應用程序是否現實? (Is it realistic to create gpu-intensive web apps using webgl running in the browser?)


問題描述

使用在瀏覽器中運行的 webgl 創建 GPU 密集型 Web 應用程序是否現實? (Is it realistic to create gpu‑intensive web apps using webgl running in the browser?)

我一直在考慮使用在瀏覽器中運行的 webgl 創建一款時髦的遊戲,但我注意到儘管擁有 3gb 的 vram 的 NVIDIA GeForce GTX 1060,但我最多只能使用 512mb 的 vram一次。我相信這是因為瀏覽器使用的是我的集成 gpu 而不是我的專用 gpu。我讀過幾個人有同樣的問題並通過重新配置來糾正它,但我不希望我的 web 應用程序的用戶也有類似的問題並且需要更多的 vram 來擔心這個問題運行應用程序。

有沒有簡單的“修復”?允許瀏覽器使用專用 GPU 而無需進行任何技術重新配置?這只是在瀏覽器中使用 gpu 的不幸問題嗎?還是我不了解有關使用 gpu 的基本知識?


參考解法

方法 1:

In WebGL you can ask the browser to use the discrete gpu by passing in powerPreference: 'high‑performance' to getContext as in

const gl = someCanvas.getContext('webgl', {powerPreference: 'high‑performance'});

You can check if it worked by using the WEBGL_debug_renderer_info extension if it exists

const canvas = document.createElement('canvas');
const gl = canvas.getContext('webgl', {powerPreference: 'high‑performance'});
const ext = gl.getExtension('WEBGL_debug_renderer_info');
if (ext) {
  console.log(gl.getParameter(ext.UNMASKED_VENDOR_WEBGL));
  console.log(gl.getParameter(ext.UNMASKED_RENDERER_WEBGL));
} else {
  console.log('this browser does not support WEBGL_debug_renderer_info');
}

If you don't pass in a powerPerformance setting it defaults to whatever the browser chooses. Most browsers choose the integrated GPU by default to save power.

As for GPU intensive, I'd say Google Earth is fairly intense?


update

So as of 2020‑07 the powerPreference option really only works on Dual GPU Macs. The good news is apparently Microsoft is adding support to Chromium for Dual GPU Windows.

(by therealguygman)

參考文件

  1. Is it realistic to create gpu‑intensive web apps using webgl running in the browser? (CC BY‑SA 2.5/3.0/4.0)

#Browser #webgl #gpu






相關問題

讓 jQuery 與 Netscape 7 和 8 一起工作 (Getting jQuery to work with Netscape 7 and 8)

功能性 javascript 和網絡瀏覽器 javascript 版本 (Functional javascript and web browser javascript versions)

VB.NET - WebBrowser 附加標題 - 用戶代理覆蓋/取消其他標題? (VB.NET - WebBrowser Additional Headers - User Agent Overrides / Cancels Other Headers?)

無法在所有移動瀏覽器上居中 - 普通瀏覽器效果極佳 (Centering Not Possible On All Mobile Browsers - Normal Browser Works Superb)

在 SWT 瀏覽器小部件中獲取選定文本 (Getting a Selected Text In SWT Browser Widgets)

瀏覽器如何知道網頁發生了變化? (How does the browser know a web page has changed?)

iPhone/Android/BlackBerry 上的 jQuery (jQuery on iPhone/Android/BlackBerry)

對 DOM 和 HTML (API) 之間的關係感到困惑 (Confused by relation between DOM and HTML (APIs))

Firefox 5 - 無限循環處理 (Firefox 5 - infinite loop handling)

字符串或二進制數據將被截斷 (string or binary data would be truncated)

拖放圖片轉Base64 (Drag and drop image convert to Base64)

使用在瀏覽器中運行的 webgl 創建 GPU 密集型 Web 應用程序是否現實? (Is it realistic to create gpu-intensive web apps using webgl running in the browser?)







留言討論