Continue refactoring for non-NV12 support in EGLRenderer

This commit is contained in:
Cameron Gutman 2021-03-21 21:43:57 -05:00
parent 402b6d1f0c
commit a0b9684504
2 changed files with 15 additions and 15 deletions

View file

@ -250,7 +250,7 @@ void EGLRenderer::renderOverlay(Overlay::OverlayType type)
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_OverlayTextures[type]); glBindTexture(GL_TEXTURE_2D, m_OverlayTextures[type]);
glUniform1i(m_OverlayShaderProgramParams[PARAM_TEXTURE], 0); glUniform1i(m_OverlayShaderProgramParams[OVERLAY_PARAM_TEXTURE], 0);
glDrawArrays(GL_TRIANGLES, 0, 6); glDrawArrays(GL_TRIANGLES, 0, 6);
} }
@ -379,10 +379,10 @@ bool EGLRenderer::compileShaders() {
return false; return false;
} }
m_ShaderProgramParams[PARAM_YUVMAT] = glGetUniformLocation(m_ShaderProgram, "yuvmat"); m_ShaderProgramParams[NV12_PARAM_YUVMAT] = glGetUniformLocation(m_ShaderProgram, "yuvmat");
m_ShaderProgramParams[PARAM_OFFSET] = glGetUniformLocation(m_ShaderProgram, "offset"); m_ShaderProgramParams[NV12_PARAM_OFFSET] = glGetUniformLocation(m_ShaderProgram, "offset");
m_ShaderProgramParams[PARAM_PLANE1] = glGetUniformLocation(m_ShaderProgram, "plane1"); m_ShaderProgramParams[NV12_PARAM_PLANE1] = glGetUniformLocation(m_ShaderProgram, "plane1");
m_ShaderProgramParams[PARAM_PLANE2] = glGetUniformLocation(m_ShaderProgram, "plane2"); m_ShaderProgramParams[NV12_PARAM_PLANE2] = glGetUniformLocation(m_ShaderProgram, "plane2");
} }
else { else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
@ -397,7 +397,7 @@ bool EGLRenderer::compileShaders() {
return false; return false;
} }
m_OverlayShaderProgramParams[PARAM_TEXTURE] = glGetUniformLocation(m_OverlayShaderProgram, "uTexture"); m_OverlayShaderProgramParams[OVERLAY_PARAM_TEXTURE] = glGetUniformLocation(m_OverlayShaderProgram, "uTexture");
return true; return true;
} }
@ -787,10 +787,10 @@ void EGLRenderer::renderFrame(AVFrame* frame)
// Bind parameters for the NV12 shaders // Bind parameters for the NV12 shaders
if (m_EGLImagePixelFormat == AV_PIX_FMT_NV12) { if (m_EGLImagePixelFormat == AV_PIX_FMT_NV12) {
glUniformMatrix3fv(m_ShaderProgramParams[PARAM_YUVMAT], 1, GL_FALSE, getColorMatrix()); glUniformMatrix3fv(m_ShaderProgramParams[NV12_PARAM_YUVMAT], 1, GL_FALSE, getColorMatrix());
glUniform3fv(m_ShaderProgramParams[PARAM_OFFSET], 1, getColorOffsets()); glUniform3fv(m_ShaderProgramParams[NV12_PARAM_OFFSET], 1, getColorOffsets());
glUniform1i(m_ShaderProgramParams[PARAM_PLANE1], 0); glUniform1i(m_ShaderProgramParams[NV12_PARAM_PLANE1], 0);
glUniform1i(m_ShaderProgramParams[PARAM_PLANE2], 1); glUniform1i(m_ShaderProgramParams[NV12_PARAM_PLANE2], 1);
} }
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);

View file

@ -51,13 +51,13 @@ private:
PFNGLBINDVERTEXARRAYOESPROC m_glBindVertexArrayOES; PFNGLBINDVERTEXARRAYOESPROC m_glBindVertexArrayOES;
PFNGLDELETEVERTEXARRAYSOESPROC m_glDeleteVertexArraysOES; PFNGLDELETEVERTEXARRAYSOESPROC m_glDeleteVertexArraysOES;
#define PARAM_YUVMAT 0 #define NV12_PARAM_YUVMAT 0
#define PARAM_OFFSET 1 #define NV12_PARAM_OFFSET 1
#define PARAM_PLANE1 2 #define NV12_PARAM_PLANE1 2
#define PARAM_PLANE2 3 #define NV12_PARAM_PLANE2 3
int m_ShaderProgramParams[4]; int m_ShaderProgramParams[4];
#define PARAM_TEXTURE 0 #define OVERLAY_PARAM_TEXTURE 0
int m_OverlayShaderProgramParams[1]; int m_OverlayShaderProgramParams[1];
int m_OldContextProfileMask; int m_OldContextProfileMask;