[Mesa-dev] [PATCH] gallium: implement WGL_ARB_create_context
morgan devel
morgan.devel at gmail.com
Wed Oct 19 14:04:21 PDT 2011
---
src/gallium/state_trackers/wgl/SConscript | 1 +
src/gallium/state_trackers/wgl/stw_context.c | 39 ++++++++++++++++++--
.../state_trackers/wgl/stw_getprocaddress.c | 3 ++
src/gallium/state_trackers/wgl/stw_icd.h | 8 ++++
4 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/src/gallium/state_trackers/wgl/SConscript
b/src/gallium/state_trackers/wgl/SConscript
index 7cb953b..1014b45 100644
--- a/src/gallium/state_trackers/wgl/SConscript
+++ b/src/gallium/state_trackers/wgl/SConscript
@@ -22,6 +22,7 @@ if not env['gles']:
sources = [
'stw_context.c',
'stw_device.c',
+ 'stw_ext_context.c',
'stw_ext_extensionsstring.c',
'stw_ext_gallium.c',
'stw_ext_pbuffer.c',
diff --git a/src/gallium/state_trackers/wgl/stw_context.c
b/src/gallium/state_trackers/wgl/stw_context.c
index c2839fe..875d713 100644
--- a/src/gallium/state_trackers/wgl/stw_context.c
+++ b/src/gallium/state_trackers/wgl/stw_context.c
@@ -27,6 +27,11 @@
#include <windows.h>
+#define WGL_WGLEXT_PROTOTYPES
+
+#include <GL/gl.h>
+#include <GL/wglext.h>
+
#include "pipe/p_compiler.h"
#include "pipe/p_context.h"
#include "pipe/p_state.h"
@@ -121,11 +126,23 @@ DrvCreateLayerContext(
HDC hdc,
INT iLayerPlane )
{
+ return DrvCreateContextAttribs(hdc, iLayerPlane, 0, 1, 0, 0,
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB);
+}
+
+DHGLRC APIENTRY
+DrvCreateContextAttribs(
+ HDC hdc,
+ INT iLayerPlane,
+ DHGLRC hShareContext,
+ int majorVersion, int minorVersion,
+ int contextFlags, int profileMask)
+{
int iPixelFormat;
const struct stw_pixelformat_info *pfi;
struct st_context_attribs attribs;
struct stw_context *ctx = NULL;
-
+ struct stw_context *shareCtx = NULL;
+
if(!stw_dev)
return 0;
@@ -137,7 +154,13 @@ DrvCreateLayerContext(
return 0;
pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
-
+
+ if (hShareContext != 0) {
+ pipe_mutex_lock( stw_dev->ctx_mutex );
+ shareCtx = stw_lookup_context_locked( hShareContext );
+ pipe_mutex_unlock( stw_dev->ctx_mutex );
+ }
+
ctx = CALLOC_STRUCT( stw_context );
if (ctx == NULL)
goto no_ctx;
@@ -148,9 +171,19 @@ DrvCreateLayerContext(
memset(&attribs, 0, sizeof(attribs));
attribs.profile = ST_PROFILE_DEFAULT;
attribs.visual = pfi->stvis;
+ attribs.major = majorVersion;
+ attribs.minor = minorVersion;
+ if (contextFlags & WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
+ if (contextFlags & WGL_CONTEXT_DEBUG_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
+ if (profileMask & WGL_CONTEXT_CORE_PROFILE_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_CORE_PROFILE;
+ if (profileMask & WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB)
+ attribs.flags |= ST_CONTEXT_FLAG_COMPATIBLE_PROFILE;
ctx->st = stw_dev->stapi->create_context(stw_dev->stapi,
- stw_dev->smapi, &attribs, NULL);
+ stw_dev->smapi, &attribs, shareCtx ? shareCtx->st : NULL);
if (ctx->st == NULL)
goto no_st_ctx;
diff --git a/src/gallium/state_trackers/wgl/stw_getprocaddress.c
b/src/gallium/state_trackers/wgl/stw_getprocaddress.c
index b0aef94..a1df44c 100644
--- a/src/gallium/state_trackers/wgl/stw_getprocaddress.c
+++ b/src/gallium/state_trackers/wgl/stw_getprocaddress.c
@@ -73,6 +73,9 @@ static const struct stw_extension_entry
stw_extension_entries[] = {
STW_EXTENSION_ENTRY( wglGetGalliumScreenMESA ),
STW_EXTENSION_ENTRY( wglCreateGalliumContextMESA ),
+ /* WGL_ARB_create_context */
+ STW_EXTENSION_ENTRY( wglCreateContextAttribsARB ),
+
{ NULL, NULL }
};
diff --git a/src/gallium/state_trackers/wgl/stw_icd.h
b/src/gallium/state_trackers/wgl/stw_icd.h
index 02eb543..9ff8d7a 100644
--- a/src/gallium/state_trackers/wgl/stw_icd.h
+++ b/src/gallium/state_trackers/wgl/stw_icd.h
@@ -502,6 +502,14 @@ DrvCopyContext(
UINT fuMask );
DHGLRC APIENTRY
+DrvCreateContextAttribs(
+ HDC hdc,
+ INT iLayerPlane,
+ DHGLRC hShareContext,
+ int majorVersion, int minorVersion,
+ int contextFlags, int profileMask);
+
+DHGLRC APIENTRY
DrvCreateLayerContext(
HDC hdc,
INT iLayerPlane );
--
1.7.7.msysgit.1
More information about the mesa-dev
mailing list