Skip to content

Commit

Permalink
Fixed barycentrics not working on Nvidia hardware
Browse files Browse the repository at this point in the history
  • Loading branch information
jay3d committed Dec 6, 2023
1 parent deaf875 commit c83ddbb
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/renderer_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ namespace bgfx { namespace gl
{ "EXT_draw_instanced", false, true }, // GLES2 extension.
{ "EXT_instanced_arrays", false, true }, // GLES2 extension.
{ "EXT_frag_depth", false, true }, // GLES2 extension.
{ "EXT_fragment_shader_barycentric", false, true },
{ "EXT_fragment_shader_barycentric", BGFX_CONFIG_RENDERER_OPENGL >= 46, true },
{ "EXT_framebuffer_blit", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "EXT_framebuffer_object", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
{ "EXT_framebuffer_sRGB", BGFX_CONFIG_RENDERER_OPENGL >= 30, true },
Expand Down Expand Up @@ -897,7 +897,7 @@ namespace bgfx { namespace gl
{ "NV_copy_image", false, true },
{ "NV_draw_buffers", false, true }, // GLES2 extension.
{ "NV_draw_instanced", false, true }, // GLES2 extension.
{ "NV_fragment_shader_barycentric", false, true },
{ "NV_fragment_shader_barycentric", BGFX_CONFIG_RENDERER_OPENGL >= 46, true },
{ "NV_instanced_arrays", false, true }, // GLES2 extension.
{ "NV_occlusion_query", false, true },
{ "NV_texture_border_clamp", false, true }, // GLES2 extension.
Expand Down Expand Up @@ -6874,39 +6874,39 @@ namespace bgfx { namespace gl
}
else if (GL_FRAGMENT_SHADER == m_type)
{
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL >= 45))
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL >= 46))
{
int32_t codeLen = (int32_t)bx::strLen(code);
int32_t tempLen = codeLen + (4<<10);
char* temp = (char*)alloca(tempLen);
bx::StaticMemoryBlockWriter writer(temp, tempLen);

bx::write(&writer
, "#version 450\n"
, "#version 460\n"
, &err
);

if (!bx::findIdentifierMatch(code, s_EXT_fragment_shader_barycentric).isEmpty())
{
if (s_extension[Extension::EXT_fragment_shader_barycentric].m_supported)
if (s_extension[Extension::NV_fragment_shader_barycentric].m_supported)
{
bx::write(&writer,
"#extension GL_EXT_fragment_shader_barycentric : enable\n"
"#define gl_BaryCoord gl_BaryCoordEXT\n"
"#define gl_BaryCoordNoPersp gl_BaryCoordNoPerspEXT\n", &err
"#extension GL_NV_fragment_shader_barycentric : require\n"
"#define gl_BaryCoord gl_BaryCoordNV\n"
"#define gl_BaryCoordNoPersp gl_BaryCoordNoPerspNV\n", &err
);
}
else if (s_extension[Extension::NV_fragment_shader_barycentric].m_supported)
else if (s_extension[Extension::EXT_fragment_shader_barycentric].m_supported)
{
bx::write(&writer,
"#extension GL_NV_fragment_shader_barycentric : enable\n"
"#define gl_BaryCoord gl_BaryCoordNV\n"
"#define gl_BaryCoordNoPersp gl_BaryCoordNoPerspNV\n", &err
"#extension GL_EXT_fragment_shader_barycentric : require\n"
"#define gl_BaryCoord gl_BaryCoordEXT\n"
"#define gl_BaryCoordNoPersp gl_BaryCoordNoPerspEXT\n", &err
);
}
}

int32_t verLen = bx::strLen("#version 450\n");
int32_t verLen = bx::strLen("#version 460\n");
bx::write(&writer, code.getPtr()+verLen, codeLen-verLen, &err);
bx::write(&writer, '\0', &err);

Expand Down

0 comments on commit c83ddbb

Please sign in to comment.