Low priority: OpenGL error every frame in missions with a volumetric nebula

Abierto Apto para principiantes
#7,901 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp

Línea de trabajo

Comienza en code/graphics/opengl/gropengldeferred.cpp en la restauración de la textura emisiva después de la pasada de nebulosa volumétrica y examina las llamadas circundantes de OpenGL al estado de la textura. Reproduce el problema con una misión que contenga una nebulosa volumétrica en una compilación de depuración y luego verifica que fs2_open.log ya no informe el error GL_INVALID_OPERATION por fotograma y que el filtro de la textura emisiva esté restaurado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Low priority: nothing looks wrong on screen, it only shows up as an OpenGL error in debug logs. Found while testing another PR.

Problem

On OpenGL, a mission with a volumetric nebula logs GL_INVALID_OPERATION in glBindTexture(target mismatch) about once per frame in a debug build. Missions without a volumetric nebula don't log it, and it goes away with -no_deferred.

After the volumetric nebula draws, the code switches back to the emissive texture with the one-argument GL_state.Texture.Enable(Scene_emissive_texture) (code/graphics/opengl/gropengldeferred.cpp, line 656 on master). That binds to whichever texture unit was active last, which is the unit the nebula's 3D volume texture was just bound to. So OpenGL is asked to bind a 2D texture as a 3D one and refuses. The glTexParameteri on the next line, which is meant to put the emissive texture's filter back to GL_LINEAR, then doesn't reach the emissive texture either.

Steps to reproduce

  1. Build current master (I used 12a36dc1a, Debug, Linux).
  2. Use MediaVPs 5.0.2 and a mission with a volumetric nebula. I copied MediaVPs' SM1-01 and added a +Volumetric Nebula: block using volume_noise_sphere.pof from Beyond the Aftermath 2.2.0 (any volumetric nebula should do).
  3. Run it on OpenGL and fly for a few seconds.
  4. Open fs2_open.log.

Expected vs. actual behavior

Expected: no OpenGL errors.

Actual: OpenGL Debug: ... Type:Error ... GL_INVALID_OPERATION in glBindTexture(target mismatch) every frame (19 in the first 5 seconds). A debugger breakpoint on the error puts it in opengl_texture_state::Enable(GLuint) called from gr_opengl_deferred_lighting_finish. Seen on Mesa's software OpenGL; I haven't checked a hardware OpenGL driver.

Proposed fixes

  1. Name the unit and target on that line: GL_state.Texture.Enable(1, GL_TEXTURE_2D, Scene_emissive_texture). Unit 1 is where the emissive texture was bound for the nebula pass, so the filter reset after it lands on the right texture.
  2. Set the emissive texture's filter back without depending on which unit is active, for example by binding it explicitly first in its own small helper, so later edits to the nebula pass can't break it again.
  3. Make the one-argument Enable check that the active unit's target matches the texture it's asked to bind (and complain in debug builds), which would catch this pattern anywhere else in the OpenGL code.
Lenguaje dominante
C++
Estrellas
488
Forks
184
Merge medio
6 d 30 min
PR fusionados (30 d)
40

Preparar el entorno

Aún no hemos revisado los archivos de configuración de este proyecto. Empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de scp-fs2open/fs2open.github.com

Todos los issues de scp-fs2open/fs2open.github.com

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.