Opened 12 years ago

Closed 11 years ago

#1197 closed defect (wontfix)

[PATCH] Incorrect aliasing of core/extension GLhandleARB shader functions

Reported by: Philip Taylor Owned by:
Priority: If Time Permits Milestone: Alpha 15
Component: Core engine Keywords: patch
Cc: Patch:

Description

In glext_funcs.h we declare function pointers like

GLhandleARB (*pglCreateShaderObjectARB)(GLenum);

That is initialised in ogl.cpp with GetProcAddress to point to functions that GL defines with the signatures

GLhandleARB glCreateShaderObjectARB(GLenum);

(if the GL version is old but the relevant extension is supported) or

GLuint glCreateShader(GLenum);

(if the GL version is >=2.0 so we should use the core version instead of the extension).

That's fine on Windows/Linux because GLhandleARB is equivalent to GLuint, so the type of pglCreateShaderObjectARB is compatible with glCreateShader. But OS X defines GLhandleARB as void*, and on 64-bit builds that's a larger type than GLuint.

I don't think that'll cause problems in practice (the calling conventions mean glCreateShader will return a 32-bit uint in a register, which we store in a 64-bit void* and then we pass it in a register to some other shader function that expects a 32-bit uint, so there's no data loss). But it's pretty ugly and fragile.

It should be possible to implement wrapper functions that know whether they're calling glCreateShader or glCreateShaderObjectARB, and explicitly cast the return value to intptr_t (which will be safe), and same for other shader functions. But I think we should just drop extension support for GLSL in GL versions <2.0, and only support GLSL via core functions - it's not worth the effort of adding wrappers when it'll help about zero users. So we should change glext_funcs.h to remove the ARB versions of the GL 2.0 shader functions, and change the code that detects shader support to test the GL version instead of testing the extensions string.

Attachments (1)

ogl_drop_shader_extensions.patch (24.1 KB ) - added by Emils Solmanis 12 years ago.

Download all attachments as: .zip

Change History (10)

by Emils Solmanis, 12 years ago

comment:1 by Emils Solmanis, 12 years ago

Keywords: review added
Summary: Incorrect aliasing of core/extension GLhandleARB shader functions[PATCH] Incorrect aliasing of core/extension GLhandleARB shader functions

Don't have anything pre-2.0 to test on, the lowest thing I have is a HD3k on my laptop and it's 2.1. Anyway, does this look like what you asked for?

comment:2 by Kieran P, 12 years ago

Keywords: patch added
Milestone: BacklogAlpha 11
Priority: Should HaveNice to Have

comment:3 by historic_bruno, 12 years ago

Milestone: Alpha 11Alpha 12

comment:4 by historic_bruno, 12 years ago

Priority: Nice to HaveIf Time Permits

comment:5 by Kieran P, 11 years ago

Keywords: simple removed
Milestone: Alpha 12Alpha 13
Owner: set to myconid

Assigning this to myconid to take a look at for the next release, seeing as he'll be deep in this stuff already :-)

comment:6 by historic_bruno, 11 years ago

Milestone: Alpha 13Alpha 14

Bumping to A14 since it's not a release blocker.

comment:7 by historic_bruno, 11 years ago

Owner: myconid removed

comment:8 by historic_bruno, 11 years ago

Milestone: Alpha 14Alpha 15

comment:9 by Jorma Rebane, 11 years ago

Keywords: review removed
Resolution: wontfix
Status: newclosed

There is no need for this patch due to massive changes in megapatch. Since this ticket is older than a year, there simply isn't a need for it anymore.

Note: See TracTickets for help on using tickets.