mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[OPENGL32]
- Implement storing thread data into the TEB CORE-14024
This commit is contained in:
parent
1bfbdb6123
commit
6aaf217b10
7 changed files with 437 additions and 357 deletions
|
@ -48,6 +48,7 @@
|
|||
# endif /* _STATIC_MESA support */
|
||||
#endif /* WIN32 / CYGWIN bracket */
|
||||
|
||||
#define WIN32_NO_STATUS
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/gl.h>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -48,9 +48,8 @@ DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
|
|||
#ifdef OPENGL32_USE_TLS
|
||||
if (!init_tls_data())
|
||||
return FALSE;
|
||||
#else
|
||||
NtCurrentTeb()->glTable = &StubTable.glDispatchTable;
|
||||
#endif // defined(OPENGL32_USE_TLS)
|
||||
IntSetCurrentDispatchTable(&StubTable.glDispatchTable);
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
|
||||
/* X86 opengl API entry points, fast forward to the current thread's dispatch table */
|
||||
#include <asm.inc>
|
||||
#include <ks386.inc>
|
||||
|
||||
.code
|
||||
|
||||
#ifdef OPENG32_USE_TLS
|
||||
EXTERN _OglTlsIndex:DWORD
|
||||
EXTERN _TlsGetValue@4:PROC
|
||||
|
||||
|
@ -22,6 +24,23 @@ PUBLIC _gl&name&@&stack
|
|||
jmp dword ptr [eax+4*VAL(offset)]
|
||||
.ENDP
|
||||
ENDM
|
||||
#else
|
||||
MACRO(USE_GL_FUNC, name, offset, stack)
|
||||
EXTERN _nop_&name@&stack:PROC
|
||||
PUBLIC _gl&name&@&stack
|
||||
.PROC _gl&name&@&stack
|
||||
/* Get the TEB */
|
||||
mov eax, fs:[TEB_SELF]
|
||||
/* Get the GL table */
|
||||
mov eax, [eax + TEB_GL_TABLE]
|
||||
/* If we don't have a dispatch table, call the nop */
|
||||
test eax, eax
|
||||
jz _nop_&name&@&stack
|
||||
/* Jump into the ICD */
|
||||
jmp dword ptr [eax+4*VAL(offset)]
|
||||
.ENDP
|
||||
ENDM
|
||||
#endif
|
||||
|
||||
USE_GL_FUNC Accum, 213, 8
|
||||
USE_GL_FUNC AlphaFunc, 240, 8
|
||||
|
@ -360,4 +379,4 @@ USE_GL_FUNC Vertex4sv, 149, 4
|
|||
USE_GL_FUNC VertexPointer, 321, 16
|
||||
USE_GL_FUNC Viewport, 305, 16
|
||||
|
||||
END
|
||||
END
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
#include <winddi.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
#ifndef OPENGL32_USE_TLS
|
||||
#include <pstypes.h>
|
||||
#endif
|
||||
|
||||
#include <wine/debug.h>
|
||||
|
||||
#include "icd.h"
|
||||
|
@ -124,7 +128,7 @@ C_ASSERT(FIELD_OFFSET(struct Opengl32_ThreadData, glDispatchTable) == 0);
|
|||
/* dllmain.c */
|
||||
BOOL init_tls_data(void);
|
||||
|
||||
static inline
|
||||
FORCEINLINE
|
||||
void
|
||||
IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
||||
{
|
||||
|
@ -143,7 +147,7 @@ IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
|||
thread_data->dc_data = dc_data;
|
||||
}
|
||||
|
||||
static inline
|
||||
FORCEINLINE
|
||||
HGLRC
|
||||
IntGetCurrentRC(void)
|
||||
{
|
||||
|
@ -151,16 +155,7 @@ IntGetCurrentRC(void)
|
|||
return data ? data->hglrc : NULL;
|
||||
}
|
||||
|
||||
static inline
|
||||
DHGLRC
|
||||
IntGetCurrentDHGLRC(void)
|
||||
{
|
||||
struct wgl_context* ctx = (struct wgl_context*)IntGetCurrentRC();
|
||||
if(!ctx) return NULL;
|
||||
return ctx->dhglrc;
|
||||
}
|
||||
|
||||
static inline
|
||||
FORCEINLINE
|
||||
HDC
|
||||
IntGetCurrentDC(void)
|
||||
{
|
||||
|
@ -168,7 +163,7 @@ IntGetCurrentDC(void)
|
|||
return data ? data->hdc : NULL;
|
||||
}
|
||||
|
||||
static inline
|
||||
FORCEINLINE
|
||||
struct wgl_dc_data*
|
||||
IntGetCurrentDcData(void)
|
||||
{
|
||||
|
@ -176,7 +171,7 @@ IntGetCurrentDcData(void)
|
|||
return data->dc_data;
|
||||
}
|
||||
|
||||
static inline
|
||||
FORCEINLINE
|
||||
const GLDISPATCHTABLE *
|
||||
IntGetCurrentDispatchTable(void)
|
||||
{
|
||||
|
@ -184,7 +179,7 @@ IntGetCurrentDispatchTable(void)
|
|||
return data->glDispatchTable;
|
||||
}
|
||||
|
||||
static inline
|
||||
FORCEINLINE
|
||||
void
|
||||
IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
|
||||
{
|
||||
|
@ -192,7 +187,7 @@ IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
|
|||
data->glDispatchTable = table;
|
||||
}
|
||||
|
||||
static inline
|
||||
FORCEINLINE
|
||||
void
|
||||
IntSetCurrentICDPrivate(void* value)
|
||||
{
|
||||
|
@ -200,7 +195,7 @@ IntSetCurrentICDPrivate(void* value)
|
|||
data->icdData = value;
|
||||
}
|
||||
|
||||
static inline
|
||||
FORCEINLINE
|
||||
void*
|
||||
IntGetCurrentICDPrivate(void)
|
||||
{
|
||||
|
@ -210,14 +205,77 @@ IntGetCurrentICDPrivate(void)
|
|||
|
||||
|
||||
#else
|
||||
static inline
|
||||
FORCEINLINE
|
||||
const GLDISPATCHTABLE*
|
||||
IntGetCurrentDispatchTable(void)
|
||||
{
|
||||
return (GLDISPATCHTABLE*)NtCurrentTeb()->glTable;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
void
|
||||
IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
|
||||
{
|
||||
NtCurrentTeb()->glTable = (void*)table;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
void
|
||||
IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
||||
{
|
||||
TEB* CurrentTeb = NtCurrentTeb();
|
||||
|
||||
CurrentTeb->glCurrentRC = hglrc;
|
||||
CurrentTeb->glReserved2 = hdc;
|
||||
CurrentTeb->glContext = dc_data;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
HGLRC
|
||||
IntGetCurrentRC(void)
|
||||
{
|
||||
return NtCurrentTeb()->glCurrentRC;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
HDC
|
||||
IntGetCurrentDC(void)
|
||||
{
|
||||
return NtCurrentTeb()->glReserved2;
|
||||
}
|
||||
|
||||
static inline
|
||||
struct wgl_dc_data*
|
||||
IntGetCurrentDcData(void)
|
||||
{
|
||||
return NtCurrentTeb()->glContext;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
void
|
||||
IntSetCurrentICDPrivate(void* value)
|
||||
{
|
||||
NtCurrentTeb()->glReserved1[0] = (ULONG_PTR)value;
|
||||
}
|
||||
|
||||
FORCEINLINE
|
||||
void*
|
||||
IntGetCurrentICDPrivate(void)
|
||||
{
|
||||
return (void*)NtCurrentTeb()->glReserved1[0];
|
||||
}
|
||||
|
||||
#endif // defined(OPENGL32_USE_TLS)
|
||||
|
||||
FORCEINLINE
|
||||
DHGLRC
|
||||
IntGetCurrentDHGLRC(void)
|
||||
{
|
||||
struct wgl_context* ctx = (struct wgl_context*)IntGetCurrentRC();
|
||||
if(!ctx) return NULL;
|
||||
return ctx->dhglrc;
|
||||
}
|
||||
|
||||
/* Software implementation functions */
|
||||
INT sw_DescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR* descr);
|
||||
BOOL sw_SetPixelFormat(HDC hdc, struct wgl_dc_data*, INT format);
|
||||
|
|
|
@ -736,6 +736,7 @@ OFFSET(TEB_SELF, TEB, NtTib.Self),
|
|||
OFFSET(TEB_PEB, TEB, ProcessEnvironmentBlock),
|
||||
OFFSET(TEB_EXCEPTION_CODE, TEB, ExceptionCode),
|
||||
OFFSET(TEB_ACTIVATION_CONTEXT_STACK_POINTER, TEB, ActivationContextStackPointer),
|
||||
OFFSET(TEB_GL_TABLE, TEB, glTable),
|
||||
OFFSET(TEB_DEALLOCATION_STACK, TEB, DeallocationStack),
|
||||
OFFSET(TEB_GDI_BATCH_COUNT, TEB, GdiBatchCount),
|
||||
OFFSET(TEB_GUARANTEED_STACK_BYTES, TEB, GuaranteedStackBytes),
|
||||
|
|
|
@ -414,6 +414,7 @@ Author:
|
|||
#define TEB_PEB 0x30
|
||||
#define TEB_EXCEPTION_CODE 0x1A4
|
||||
#define TEB_ACTIVATION_CONTEXT_STACK_POINTER 0x1A8
|
||||
#define TEB_GL_TABLE 0xBE8
|
||||
#define TEB_DEALLOCATION_STACK 0xE0C
|
||||
#define TEB_GDI_BATCH_COUNT 0xF70
|
||||
#define TEB_GUARANTEED_STACK_BYTES 0xF78
|
||||
|
|
Loading…
Reference in a new issue