mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-05 09:17:37 +08:00
fix: move _initialized flag to end of GLContext.__init__
Prevents '_vao' attribute error when init fails partway through and subsequent calls skip initialization due to early _initialized flag.
This commit is contained in:
parent
9f4ef1a094
commit
78d1798655
@ -327,7 +327,6 @@ class GLContext:
|
|||||||
if GLContext._initialized:
|
if GLContext._initialized:
|
||||||
logger.debug("GLContext.__init__: already initialized, skipping")
|
logger.debug("GLContext.__init__: already initialized, skipping")
|
||||||
return
|
return
|
||||||
GLContext._initialized = True
|
|
||||||
|
|
||||||
logger.debug("GLContext.__init__: starting initialization")
|
logger.debug("GLContext.__init__: starting initialization")
|
||||||
|
|
||||||
@ -343,6 +342,7 @@ class GLContext:
|
|||||||
self._egl_surface = None
|
self._egl_surface = None
|
||||||
self._osmesa_ctx = None
|
self._osmesa_ctx = None
|
||||||
self._osmesa_buffer = None
|
self._osmesa_buffer = None
|
||||||
|
self._vao = None
|
||||||
|
|
||||||
# Try backends in order: GLFW → EGL → OSMesa
|
# Try backends in order: GLFW → EGL → OSMesa
|
||||||
errors = []
|
errors = []
|
||||||
@ -409,7 +409,6 @@ class GLContext:
|
|||||||
|
|
||||||
# Create VAO (required for core profile, but OSMesa may use compat profile)
|
# Create VAO (required for core profile, but OSMesa may use compat profile)
|
||||||
logger.debug("GLContext.__init__: creating VAO")
|
logger.debug("GLContext.__init__: creating VAO")
|
||||||
self._vao = None
|
|
||||||
try:
|
try:
|
||||||
vao = gl.glGenVertexArrays(1)
|
vao = gl.glGenVertexArrays(1)
|
||||||
gl.glBindVertexArray(vao)
|
gl.glBindVertexArray(vao)
|
||||||
@ -435,6 +434,7 @@ class GLContext:
|
|||||||
vendor = vendor.decode() if vendor else "Unknown"
|
vendor = vendor.decode() if vendor else "Unknown"
|
||||||
version = version.decode() if version else "Unknown"
|
version = version.decode() if version else "Unknown"
|
||||||
|
|
||||||
|
GLContext._initialized = True
|
||||||
logger.info(f"GLSL context initialized in {elapsed:.1f}ms ({self._backend}) - {renderer} ({vendor}), GL {version}")
|
logger.info(f"GLSL context initialized in {elapsed:.1f}ms ({self._backend}) - {renderer} ({vendor}), GL {version}")
|
||||||
|
|
||||||
def make_current(self):
|
def make_current(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user