Π
Lub hom phiaj tseem ceeb ntawm WebGPU yog los muab kev ruaj ntseg, siv tau yooj yim, txav tau yooj yim, thiab ua haujlwm siab ua haujlwm sib txuas rau lub vev xaib platform kom txhawb nqa 3D cov duab thev naus laus zis thiab muaj peev xwm muab los ntawm cov txheej txheem niaj hnub graphics APIs, xws li Direct3D 12 ntawm Windows, Hlau. ntawm macOS, thiab Vulkan ntawm Linux. Conceptually, WebGPU txawv ntawm WebGL nyob rau hauv ntau tib txoj kev uas Vulkan txawv ntawm OpenGL, thiab nyob rau tib lub sij hawm nws tsis yog raws li ib tug tshwj xeeb graphics API, tab sis yog ib tug universal txheej uas feem ntau siv tib theem qis primitives pom nyob rau hauv Vulkan, Hlau thiab Direct3D.
WebGPU muab cov ntawv thov JavaScript nrog kev tswj hwm qib qis hauv lub koom haum, ua, thiab xa cov lus txib mus rau GPU, tswj hwm cov peev txheej cuam tshuam, nco, buffers, cov khoom zoo nkauj, thiab suav nrog cov duab ntxoov ntxoo. Txoj hauv kev no tso cai rau koj kom ua tiav qhov kev ua tau zoo dua rau cov ntawv thov duab los ntawm kev txo cov nqi nyiaj siv ua haujlwm thiab nce kev ua haujlwm ntawm GPU.
WebGPU ua rau nws muaj peev xwm los tsim cov kev ua haujlwm 3D tag nrho rau lub vev xaib uas ua haujlwm tsis zoo dua li cov kev pabcuam ib leeg uas ncaj qha nkag mus rau Vulkan, Hlau lossis Direct3D, tab sis tsis khi rau cov platform tshwj xeeb. WebGPU kuj tseem muaj peev xwm ntxiv thaum xa cov kev pab cuam duab hauv ib lub web-enabled form los ntawm kev siv WebAssembly technology. Ntxiv nrog rau 3D cov duab, WebGPU kuj tseem suav nrog kev muaj peev xwm cuam tshuam txog kev suav cov lej rau GPU thiab txhawb kev txhim kho shader. Shaders
WebGPU siv cais tswj cov peev txheej, kev npaj ua haujlwm, thiab xa cov lus txib mus rau GPU (hauv WebGL, ib qho khoom yog lub luag haujlwm rau txhua yam ib zaug). Peb lub ntsiab lus sib cais yog muab:
GPUDevice tsim cov peev txheej xws li textures thiab buffers; GPUCommandEncoder rau encoding tus kheej cov lus txib, suav nrog theem ua thiab suav; GPUCommandBuffer yuav tsum tau queued rau kev ua tiav ntawm GPU. Cov txiaj ntsig tuaj yeem muab tso rau hauv thaj chaw cuam tshuam nrog ib lossis ntau lub ntsiab lus canvas, lossis ua tiav yam tsis muaj qhov tso zis (piv txwv li, thaum khiav cov haujlwm hauv computer). Sib cais cov theem ua rau nws yooj yim dua los cais cov peev txheej tsim thiab kev npaj ua haujlwm rau hauv cov neeg ua haujlwm sib txawv uas tuaj yeem khiav ntawm cov xov sib txawv.
Qhov sib txawv thib ob ntawm WebGPU thiab WebGL yog qhov sib txawv rau kev tuav cov xeev. WebGPU muaj ob yam khoom - GPURenderPipeline thiab GPUComputePipeline, uas tso cai rau koj los ua ke ntau lub xeev pre-txhais los ntawm tus tsim tawm, uas tso cai rau lub browser kom tsis txhob nkim cov peev txheej ntawm kev ua haujlwm ntxiv, xws li rov ua cov duab ntxoov ntxoo. Cov kev txhawb nqa muaj xws li: shaders, vertex buffer thiab attribute layouts, nplaum pab pawg layouts, blending, tob thiab qauv, thiab post-render tso zis tawm tswv yim.
Qhov thib peb feature ntawm WebGPU yog hu ua cov qauv kev khi, feem ntau
reminiscent ntawm cov peev txheej pab pawg cov cuab yeej tam sim no hauv Vulkan.
Txhawm rau pab pawg cov peev txheej ua ke, WebGPU muab cov khoom siv GPUBindGroup, uas tuaj yeem cuam tshuam nrog lwm yam khoom zoo sib xws rau siv hauv shaders thaum sau cov lus txib. Tsim cov pab pawg no tso cai rau tus neeg tsav tsheb ua qhov tsim nyog npaj ua ntej, thiab tso cai rau lub browser hloov pauv cov peev txheej ntawm kev kos npe sai dua. Cov txheej txheem ntawm kev sib txuas cov peev txheej tuaj yeem raug txhais ua ntej siv GPUBindGroupLayout khoom.
Hauv Firefox, txhawm rau pab kom WebGPU nyob rau hauv hais txog: config, muaj qhov chaw "dom.webgpu.enabled". CanvasContext rendering kuj yuav tsum tau muab tso ua ke kom qhib tau
Tau qhov twg los: opennet.ru