File tree Expand file tree Collapse file tree
src/platform/graphics/webgl Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -192,12 +192,17 @@ class WebglShader {
192192 * @param {string } src - The shader source code.
193193 * @param {boolean } isVertexShader - True if the shader is a vertex shader, false if it is a
194194 * fragment shader.
195- * @returns {WebGLShader } The compiled shader.
195+ * @returns {WebGLShader|null } The compiled shader, or null if the device is lost .
196196 * @private
197197 */
198198 _compileShaderSource ( device , src , isVertexShader ) {
199199 const gl = device . gl ;
200200
201+ // if the device is lost, silently ignore
202+ if ( gl . isContextLost ( ) ) {
203+ return null ;
204+ }
205+
201206 // device cache for current device, containing cache of compiled shaders
202207 const shaderDeviceCache = isVertexShader ? _vertexShaderCache : _fragmentShaderCache ;
203208 const shaderCache = shaderDeviceCache . get ( device , ( ) => {
@@ -218,11 +223,6 @@ class WebglShader {
218223
219224 glShader = gl . createShader ( isVertexShader ? gl . VERTEX_SHADER : gl . FRAGMENT_SHADER ) ;
220225
221- // if the device is lost, silently ignore
222- if ( ! glShader && gl . isContextLost ( ) ) {
223- return glShader ;
224- }
225-
226226 gl . shaderSource ( glShader , src ) ;
227227 gl . compileShader ( glShader ) ;
228228
You can’t perform that action at this time.
0 commit comments