Files
2nd/10_Wiki/Topics/Frontend/WebGL 모바일 GPU 성능 관리.md
T
2026-05-10 22:08:15 +09:00

6.6 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-webgl-모바일-gpu-성능-관리 WebGL 모바일 GPU 성능 관리 10_Wiki/Topics verified self
WebGL Mobile Performance
Mobile GPU WebGL
none A 0.9 applied
webgl
mobile
gpu
performance
thermal
2026-05-10 pending
language framework
JavaScript/GLSL WebGL2 / Three.js

WebGL 모바일 GPU 성능 관리

매 한 줄

"매 thermal throttle 의 적 — fillrate 의 절약". Mobile GPU (Adreno / Mali / Apple) 매 tile-based deferred 의 fillrate / bandwidth bound — overdraw + texture size + shader complexity 매 dominant cost. 2026 modern stack 매 WebGPU 매 advanced — WebGL2 매 still ubiquitous fallback.

매 핵심

매 mobile GPU 차이

  • TBDR (Tile-Based Deferred Rendering): Mali / Apple / PowerVR — early-Z + tile cache.
  • IMR (Immediate Mode): desktop NVIDIA / AMD — overdraw 매 expensive.
  • Adreno: hybrid — flexrender (tile + immediate).
  • Bandwidth bound: mobile DRAM 매 desktop 의 1/5 — texture size 의 major impact.
  • Thermal: sustained GPU load → throttle → 30-50% perf drop in 30-60s.

매 bottleneck 식별

  • Fragment-bound: fragment shader complexity / overdraw — resolution down / shader simplify.
  • Vertex-bound: triangle count — LOD / cull.
  • Bandwidth-bound: texture size + framebuffer — compress / lower precision.
  • Draw call-bound: state changes — batch / instance.

매 응용

  1. Mobile web games: PlayCanvas / Three.js — 60fps target on mid-tier device.
  2. AR / VR web (WebXR): Quest browser / iOS Safari WebXR — 72-90fps strict.
  3. Map / data viz: Mapbox GL — millions of features on phone.
  4. Product 3D viewer: e-commerce — fast load + smooth orbit.

💻 패턴

Resolution scaling 매 dynamic

let scale = 1.0;
let lastFrameTime = performance.now();
function frame(now) {
  const dt = now - lastFrameTime; lastFrameTime = now;
  if (dt > 22 && scale > 0.5) scale -= 0.05; // <45fps → downscale
  else if (dt < 14 && scale < 1.0) scale += 0.02;
  const w = Math.floor(canvas.clientWidth * devicePixelRatio * scale);
  const h = Math.floor(canvas.clientHeight * devicePixelRatio * scale);
  if (canvas.width !== w) { canvas.width = w; canvas.height = h; gl.viewport(0,0,w,h); }
  render();
  requestAnimationFrame(frame);
}

Texture compression 매 KTX2 / Basis

import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
const loader = new KTX2Loader()
  .setTranscoderPath('/basis/')
  .detectSupport(renderer);
loader.load('texture.ktx2', (tex) => { /* ASTC / ETC2 / BC7 transcode 매 device */ });
// 매 mobile 의 ASTC — 매 4-8x smaller VRAM + bandwidth

Overdraw 매 줄임

// 매 sort opaque front-to-back (early-Z reject)
opaque.sort((a, b) => a.distanceToCamera - b.distanceToCamera);

// 매 transparent back-to-front (correct blending)
transparent.sort((a, b) => b.distanceToCamera - a.distanceToCamera);

// 매 alpha-test 의 alpha-blend 보다 prefer (TBDR-friendly)
material.alphaTest = 0.5; material.transparent = false;

Mipmap 매 always

gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
gl.generateMipmap(gl.TEXTURE_2D);
// 매 minified texture 의 cache hit + bandwidth 의 1/3

LOD 매 distance-based

const lod = new THREE.LOD();
lod.addLevel(highMesh, 0);    // 0-10m: 50k tris
lod.addLevel(midMesh, 10);    // 10-30m: 10k tris
lod.addLevel(lowMesh, 30);    // 30m+: 2k tris
scene.add(lod);

Shader precision 매 mediump

#version 300 es
precision mediump float; // 매 16-bit on mobile — 매 highp 보다 2x throughput
in vec2 vUv;
uniform sampler2D map;
out vec4 fragColor;
void main() { fragColor = texture(map, vUv); }

Thermal-aware quality scaling

// 매 thermal API (limited) + battery + perf observer
async function detectTier() {
  const battery = await navigator.getBattery?.();
  const memory = navigator.deviceMemory ?? 4;
  const cores = navigator.hardwareConcurrency ?? 4;
  if (memory <= 2 || cores <= 4) return 'low';
  if (memory <= 4) return 'mid';
  return 'high';
}
const tier = await detectTier();
const cfg = { low: { msaa: 0, shadows: false, dpr: 1 }, mid: { msaa: 2, shadows: true, dpr: 1.5 }, high: { msaa: 4, shadows: true, dpr: 2 } }[tier];

Disable expensive features on mobile

const isMobile = /Mobi|Android|iPhone/.test(navigator.userAgent);
renderer.shadowMap.enabled = !isMobile;
renderer.toneMapping = isMobile ? THREE.NoToneMapping : THREE.ACESFilmicToneMapping;
postProcessing.enabled = !isMobile; // bloom / SSAO 매 expensive

Instanced rendering 매 thousands

const mesh = new THREE.InstancedMesh(geometry, material, 5000);
for (let i = 0; i < 5000; i++) {
  mat.setPosition(randomPos());
  mesh.setMatrixAt(i, mat);
}
// 매 1 draw call 매 5k objects — mobile 의 huge win

매 결정 기준

증상 원인 처방
Frame time spike Overdraw Front-to-back sort + alphaTest
Sustained slowdown Thermal Resolution scale + reduce shader
Memory OOM Texture VRAM KTX2 ASTC + mipmap + atlas
Stutter GC / draw calls Instance + pool
Low FPS on Adreno Shader complexity mediump + simplify

기본값: WebGL2 + KTX2 textures + LOD + dynamic resolution + mediump shaders + InstancedMesh.

🔗 Graph

🤖 LLM 활용

언제: mobile-targeted WebGL app — 60fps 의 mid-tier device 의 hold / thermal throttle 의 prevent. 언제 X: desktop-only / WebGPU available 매 flagship — WebGPU compute path 매 better.

안티패턴

  • devicePixelRatio 의 fixed: 매 retina 의 4x fragments — clamp 1.5-2.
  • Uncompressed PNG: 매 mobile VRAM 의 폭주 — KTX2 / Basis 의 사용.
  • Real-time shadows on low-end: 매 30%+ frame budget — bake / disable.
  • Postprocessing on mobile: bloom / SSAO 매 fillrate killer — disable.
  • No LOD: distant 50k-tri mesh 매 vertex bound — LOD.
  • highp everywhere: precision 매 mediump 의 충분 (color / UV).

🧪 검증 / 중복

  • Verified (Khronos WebGL spec / Arm Mali best practices / Apple Metal docs).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — TBDR, KTX2, LOD, dynamic resolution, thermal awareness