fix(gui): Guard against invalid display_size in blur pipeline init
- Remove _init_blur_pipeline call from _post_init (display_size not valid yet) - Add dimension validation in _init_blur_pipeline (ws.x > 0 and ws.y > 0) - Add fb_scale validation (default to 1.0 if <= 0) - Lazy init only happens when frosted glass is enabled and dimensions are valid - Fixes GLError 1281 'invalid value' crash on startup
This commit is contained in:
15
src/gui_2.py
15
src/gui_2.py
@@ -4039,24 +4039,33 @@ def hello():
|
|||||||
|
|
||||||
def _post_init(self) -> None:
|
def _post_init(self) -> None:
|
||||||
theme.apply_current()
|
theme.apply_current()
|
||||||
self._init_blur_pipeline()
|
|
||||||
|
|
||||||
def _init_blur_pipeline(self):
|
def _init_blur_pipeline(self):
|
||||||
if self._blur_pipeline is None:
|
if self._blur_pipeline is None:
|
||||||
self._blur_pipeline = BlurPipeline()
|
self._blur_pipeline = BlurPipeline()
|
||||||
ws = imgui.get_io().display_size
|
ws = imgui.get_io().display_size
|
||||||
fb_scale = imgui.get_io().display_framebuffer_scale.x
|
fb_scale = imgui.get_io().display_framebuffer_scale.x
|
||||||
|
if ws.x <= 0 or ws.y <= 0:
|
||||||
|
return False
|
||||||
|
if fb_scale <= 0:
|
||||||
|
fb_scale = 1.0
|
||||||
self._blur_pipeline.setup_fbos(int(ws.x), int(ws.y), fb_scale)
|
self._blur_pipeline.setup_fbos(int(ws.x), int(ws.y), fb_scale)
|
||||||
self._blur_pipeline.compile_deepsea_shader()
|
self._blur_pipeline.compile_deepsea_shader()
|
||||||
self._blur_pipeline.compile_blur_shaders()
|
self._blur_pipeline.compile_blur_shaders()
|
||||||
|
return True
|
||||||
|
|
||||||
def _pre_new_frame(self) -> None:
|
def _pre_new_frame(self) -> None:
|
||||||
if not self.ui_frosted_glass_enabled:
|
if not self.ui_frosted_glass_enabled:
|
||||||
return
|
return
|
||||||
if self._blur_pipeline is None:
|
|
||||||
self._init_blur_pipeline()
|
|
||||||
ws = imgui.get_io().display_size
|
ws = imgui.get_io().display_size
|
||||||
fb_scale = imgui.get_io().display_framebuffer_scale.x
|
fb_scale = imgui.get_io().display_framebuffer_scale.x
|
||||||
|
if ws.x <= 0 or ws.y <= 0:
|
||||||
|
return
|
||||||
|
if fb_scale <= 0:
|
||||||
|
fb_scale = 1.0
|
||||||
|
if self._blur_pipeline is None:
|
||||||
|
if not self._init_blur_pipeline():
|
||||||
|
return
|
||||||
import time
|
import time
|
||||||
t = time.time()
|
t = time.time()
|
||||||
self._blur_pipeline.prepare_global_blur(int(ws.x), int(ws.y), t, fb_scale)
|
self._blur_pipeline.prepare_global_blur(int(ws.x), int(ws.y), t, fb_scale)
|
||||||
|
|||||||
Reference in New Issue
Block a user