Merge branch 'mesa_7_5_branch'
This commit is contained in:
@@ -80,25 +80,26 @@ clean:
|
||||
-rm -f *.o *~
|
||||
-rm -f extfuncs.h
|
||||
-rm -f shaderutil.*
|
||||
-rm -f readtex.*
|
||||
|
||||
|
||||
|
||||
##### Extra dependencies
|
||||
|
||||
extfuncs.h:
|
||||
cp $(TOP)/progs/util/extfuncs.h .
|
||||
extfuncs.h: $(TOP)/progs/util/extfuncs.h
|
||||
cp $< .
|
||||
|
||||
readtex.c:
|
||||
cp $(TOP)/progs/util/readtex.c .
|
||||
readtex.c: $(TOP)/progs/util/readtex.c
|
||||
cp $< .
|
||||
|
||||
readtex.h:
|
||||
cp $(TOP)/progs/util/readtex.h .
|
||||
readtex.h: $(TOP)/progs/util/readtex.h
|
||||
cp $< .
|
||||
|
||||
shaderutil.c:
|
||||
cp $(TOP)/progs/util/shaderutil.c .
|
||||
shaderutil.c: $(TOP)/progs/util/shaderutil.c
|
||||
cp $< .
|
||||
|
||||
shaderutil.h:
|
||||
cp $(TOP)/progs/util/shaderutil.h .
|
||||
shaderutil.h: $(TOP)/progs/util/shaderutil.h
|
||||
cp $< .
|
||||
|
||||
|
||||
|
||||
|
@@ -253,6 +253,7 @@ static void widepoint_flush( struct draw_stage *stage, unsigned flags )
|
||||
{
|
||||
stage->point = widepoint_first_point;
|
||||
stage->next->flush( stage->next, flags );
|
||||
stage->draw->extra_vp_outputs.slot = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -54,7 +54,15 @@ DrvCreateLayerContext(
|
||||
HDC hdc,
|
||||
INT iLayerPlane )
|
||||
{
|
||||
return stw_create_layer_context( hdc, iLayerPlane );
|
||||
DHGLRC r;
|
||||
|
||||
r = stw_create_layer_context( hdc, iLayerPlane );
|
||||
|
||||
if (DBG)
|
||||
debug_printf( "%s( %p, %i ) = %u\n",
|
||||
__FUNCTION__, hdc, iLayerPlane, r );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
DHGLRC APIENTRY
|
||||
@@ -68,7 +76,15 @@ BOOL APIENTRY
|
||||
DrvDeleteContext(
|
||||
DHGLRC dhglrc )
|
||||
{
|
||||
return stw_delete_context( dhglrc );
|
||||
BOOL r;
|
||||
|
||||
r = stw_delete_context( dhglrc );
|
||||
|
||||
if (DBG)
|
||||
debug_printf( "%s( %u ) = %u\n",
|
||||
__FUNCTION__, dhglrc, r );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
BOOL APIENTRY
|
||||
@@ -126,7 +142,7 @@ DrvGetProcAddress(
|
||||
r = stw_get_proc_address( lpszProc );
|
||||
|
||||
if (DBG)
|
||||
debug_printf( "%s( \", __FUNCTION__%s\" ) = %p\n", lpszProc, r );
|
||||
debug_printf( "%s( \"%s\" ) = %p\n", __FUNCTION__, lpszProc, r );
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -515,14 +531,16 @@ DrvSetContext(
|
||||
DHGLRC dhglrc,
|
||||
PFN_SETPROCTABLE pfnSetProcTable )
|
||||
{
|
||||
if (DBG)
|
||||
debug_printf( "%s( 0x%p, %u, 0x%p )\n",
|
||||
__FUNCTION__, hdc, dhglrc, pfnSetProcTable );
|
||||
PGLCLTPROCTABLE r = (PGLCLTPROCTABLE)&cpt;
|
||||
|
||||
if (!stw_make_current( hdc, dhglrc ))
|
||||
return NULL;
|
||||
r = NULL;
|
||||
|
||||
return (GLCLTPROCTABLE *)&cpt;
|
||||
if (DBG)
|
||||
debug_printf( "%s( 0x%p, %u, 0x%p ) = %p\n",
|
||||
__FUNCTION__, hdc, dhglrc, pfnSetProcTable, r );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int APIENTRY
|
||||
|
@@ -90,7 +90,7 @@ stw_share_lists(
|
||||
ctx2 = stw_lookup_context_locked( hglrc2 );
|
||||
|
||||
if (ctx1 && ctx2 &&
|
||||
ctx1->pfi == ctx2->pfi) {
|
||||
ctx1->iPixelFormat == ctx2->iPixelFormat) {
|
||||
ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx);
|
||||
}
|
||||
|
||||
@@ -104,10 +104,10 @@ stw_create_layer_context(
|
||||
HDC hdc,
|
||||
int iLayerPlane )
|
||||
{
|
||||
uint pfi;
|
||||
const struct stw_pixelformat_info *pf = NULL;
|
||||
int iPixelFormat;
|
||||
const struct stw_pixelformat_info *pfi;
|
||||
GLvisual visual;
|
||||
struct stw_context *ctx = NULL;
|
||||
GLvisual *visual = NULL;
|
||||
struct pipe_screen *screen = NULL;
|
||||
struct pipe_context *pipe = NULL;
|
||||
|
||||
@@ -117,39 +117,19 @@ stw_create_layer_context(
|
||||
if (iLayerPlane != 0)
|
||||
return 0;
|
||||
|
||||
pfi = stw_pixelformat_get( hdc );
|
||||
if (pfi == 0)
|
||||
iPixelFormat = GetPixelFormat(hdc);
|
||||
if(!iPixelFormat)
|
||||
return 0;
|
||||
|
||||
pf = stw_pixelformat_get_info( pfi - 1 );
|
||||
pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
|
||||
stw_pixelformat_visual(&visual, pfi);
|
||||
|
||||
ctx = CALLOC_STRUCT( stw_context );
|
||||
if (ctx == NULL)
|
||||
goto no_ctx;
|
||||
|
||||
ctx->hdc = hdc;
|
||||
ctx->color_bits = GetDeviceCaps( ctx->hdc, BITSPIXEL );
|
||||
|
||||
/* Create visual based on flags
|
||||
*/
|
||||
visual = _mesa_create_visual(
|
||||
(pf->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE,
|
||||
(pf->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,
|
||||
(pf->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE,
|
||||
pf->pfd.cRedBits,
|
||||
pf->pfd.cGreenBits,
|
||||
pf->pfd.cBlueBits,
|
||||
pf->pfd.cAlphaBits,
|
||||
(pf->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pf->pfd.cColorBits : 0,
|
||||
pf->pfd.cDepthBits,
|
||||
pf->pfd.cStencilBits,
|
||||
pf->pfd.cAccumRedBits,
|
||||
pf->pfd.cAccumGreenBits,
|
||||
pf->pfd.cAccumBlueBits,
|
||||
pf->pfd.cAccumAlphaBits,
|
||||
pf->numSamples );
|
||||
if (visual == NULL)
|
||||
goto no_visual;
|
||||
ctx->iPixelFormat = iPixelFormat;
|
||||
|
||||
screen = stw_dev->screen;
|
||||
|
||||
@@ -169,15 +149,15 @@ stw_create_layer_context(
|
||||
pipe = trace_context_create(stw_dev->screen, pipe);
|
||||
#endif
|
||||
|
||||
/* pass to stw_flush_frontbuffer as context_private */
|
||||
assert(!pipe->priv);
|
||||
pipe->priv = hdc;
|
||||
|
||||
ctx->st = st_create_context( pipe, visual, NULL );
|
||||
ctx->st = st_create_context( pipe, &visual, NULL );
|
||||
if (ctx->st == NULL)
|
||||
goto no_st_ctx;
|
||||
|
||||
ctx->st->ctx->DriverCtx = ctx;
|
||||
ctx->pfi = pf;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx);
|
||||
@@ -193,8 +173,6 @@ no_hglrc:
|
||||
no_st_ctx:
|
||||
pipe->destroy( pipe );
|
||||
no_pipe:
|
||||
_mesa_destroy_visual( visual );
|
||||
no_visual:
|
||||
FREE(ctx);
|
||||
no_ctx:
|
||||
return 0;
|
||||
@@ -218,20 +196,11 @@ stw_delete_context(
|
||||
if (ctx) {
|
||||
GLcontext *glctx = ctx->st->ctx;
|
||||
GET_CURRENT_CONTEXT( glcurctx );
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
/* Unbind current if deleting current context.
|
||||
*/
|
||||
/* Unbind current if deleting current context. */
|
||||
if (glcurctx == glctx)
|
||||
st_make_current( NULL, NULL, NULL );
|
||||
|
||||
fb = stw_framebuffer_from_hdc( ctx->hdc );
|
||||
if (fb)
|
||||
stw_framebuffer_destroy( fb );
|
||||
|
||||
if (WindowFromDC( ctx->hdc ) != NULL)
|
||||
ReleaseDC( WindowFromDC( ctx->hdc ), ctx->hdc );
|
||||
|
||||
st_destroy_context(ctx->st);
|
||||
FREE(ctx);
|
||||
|
||||
@@ -275,34 +244,6 @@ stw_release_context(
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Find the width and height of the window named by hdc.
|
||||
*/
|
||||
static void
|
||||
stw_get_window_size( HDC hdc, GLuint *pwidth, GLuint *pheight )
|
||||
{
|
||||
GLuint width, height;
|
||||
HWND hwnd;
|
||||
|
||||
hwnd = WindowFromDC( hdc );
|
||||
if (hwnd) {
|
||||
RECT rect;
|
||||
GetClientRect( hwnd, &rect );
|
||||
width = rect.right - rect.left;
|
||||
height = rect.bottom - rect.top;
|
||||
}
|
||||
else {
|
||||
width = GetDeviceCaps( hdc, HORZRES );
|
||||
height = GetDeviceCaps( hdc, VERTRES );
|
||||
}
|
||||
|
||||
if(width < 1)
|
||||
width = 1;
|
||||
if(height < 1)
|
||||
height = 1;
|
||||
|
||||
*pwidth = width;
|
||||
*pheight = height;
|
||||
}
|
||||
|
||||
UINT_PTR
|
||||
stw_get_current_context( void )
|
||||
@@ -346,64 +287,68 @@ stw_make_current(
|
||||
struct stw_context *ctx;
|
||||
GET_CURRENT_CONTEXT( glcurctx );
|
||||
struct stw_framebuffer *fb;
|
||||
GLuint width = 0;
|
||||
GLuint height = 0;
|
||||
struct stw_context *curctx = NULL;
|
||||
|
||||
if (!stw_dev)
|
||||
return FALSE;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
ctx = stw_lookup_context_locked( hglrc );
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
goto fail;
|
||||
|
||||
if (glcurctx != NULL) {
|
||||
struct stw_context *curctx;
|
||||
curctx = (struct stw_context *) glcurctx->DriverCtx;
|
||||
|
||||
if (curctx != ctx)
|
||||
if (curctx->hglrc != hglrc)
|
||||
st_flush(glcurctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
|
||||
|
||||
/* Return if already current. */
|
||||
if (curctx->hglrc == hglrc && curctx->hdc == hdc)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (hdc == NULL || hglrc == 0) {
|
||||
return st_make_current( NULL, NULL, NULL );
|
||||
}
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
|
||||
ctx = stw_lookup_context_locked( hglrc );
|
||||
if(!ctx)
|
||||
goto fail;
|
||||
|
||||
fb = stw_framebuffer_from_hdc_locked( hdc );
|
||||
if(!fb) {
|
||||
/* Applications should call SetPixelFormat before creating a context,
|
||||
* but not all do, and the opengl32 runtime seems to use a default pixel
|
||||
* format in some cases, so we must create a framebuffer for those here
|
||||
*/
|
||||
int iPixelFormat = GetPixelFormat(hdc);
|
||||
if(iPixelFormat)
|
||||
fb = stw_framebuffer_create_locked( hdc, iPixelFormat );
|
||||
if(!fb)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
|
||||
if(fb->iPixelFormat != ctx->iPixelFormat)
|
||||
goto fail;
|
||||
|
||||
/* Lazy allocation of the frame buffer */
|
||||
if(!stw_framebuffer_allocate(fb))
|
||||
goto fail;
|
||||
|
||||
/* Bind the new framebuffer */
|
||||
ctx->hdc = hdc;
|
||||
|
||||
/* pass to stw_flush_frontbuffer as context_private */
|
||||
ctx->st->pipe->priv = hdc;
|
||||
|
||||
if(!st_make_current( ctx->st, fb->stfb, fb->stfb ))
|
||||
goto fail;
|
||||
|
||||
stw_framebuffer_resize(fb);
|
||||
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
st_make_current( NULL, NULL, NULL );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Return if already current.
|
||||
*/
|
||||
if (glcurctx != NULL) {
|
||||
if (curctx != NULL && curctx == ctx && ctx->hdc == hdc)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
fb = stw_framebuffer_from_hdc( hdc );
|
||||
|
||||
if (hdc != NULL)
|
||||
stw_get_window_size( hdc, &width, &height );
|
||||
|
||||
/* Lazy creation of stw_framebuffers.
|
||||
*/
|
||||
if (fb == NULL && ctx != NULL && hdc != NULL) {
|
||||
GLvisual *visual = &ctx->st->ctx->Visual;
|
||||
|
||||
fb = stw_framebuffer_create( hdc, visual, ctx->pfi, width, height );
|
||||
if (fb == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ctx && fb) {
|
||||
pipe_mutex_lock( fb->mutex );
|
||||
st_make_current( ctx->st, fb->stfb, fb->stfb );
|
||||
st_resize_framebuffer( fb->stfb, width, height );
|
||||
pipe_mutex_unlock( fb->mutex );
|
||||
|
||||
ctx->hdc = hdc;
|
||||
ctx->st->pipe->priv = hdc;
|
||||
}
|
||||
else {
|
||||
/* Detach */
|
||||
st_make_current( NULL, NULL, NULL );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -31,15 +31,13 @@
|
||||
#include <windows.h>
|
||||
|
||||
struct st_context;
|
||||
struct stw_pixelformat_info;
|
||||
|
||||
struct stw_context
|
||||
{
|
||||
struct st_context *st;
|
||||
UINT_PTR hglrc;
|
||||
int iPixelFormat;
|
||||
HDC hdc;
|
||||
DWORD color_bits;
|
||||
const struct stw_pixelformat_info *pfi;
|
||||
};
|
||||
|
||||
#endif /* STW_CONTEXT_H */
|
||||
|
@@ -57,7 +57,7 @@ struct stw_device *stw_dev = NULL;
|
||||
* stw_winsys::flush_front_buffer.
|
||||
*/
|
||||
static void
|
||||
st_flush_frontbuffer(struct pipe_screen *screen,
|
||||
stw_flush_frontbuffer(struct pipe_screen *screen,
|
||||
struct pipe_surface *surface,
|
||||
void *context_private )
|
||||
{
|
||||
@@ -111,7 +111,7 @@ stw_init(const struct stw_winsys *stw_winsys)
|
||||
stw_dev->screen = screen;
|
||||
#endif
|
||||
|
||||
stw_dev->screen->flush_frontbuffer = st_flush_frontbuffer;
|
||||
stw_dev->screen->flush_frontbuffer = &stw_flush_frontbuffer;
|
||||
|
||||
pipe_mutex_init( stw_dev->mutex );
|
||||
|
||||
@@ -173,6 +173,8 @@ stw_cleanup(void)
|
||||
}
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
|
||||
stw_framebuffer_cleanup();
|
||||
|
||||
pipe_mutex_destroy( stw_dev->mutex );
|
||||
|
||||
stw_dev->screen->destroy(stw_dev->screen);
|
||||
|
@@ -94,18 +94,80 @@ stw_call_window_proc(
|
||||
}
|
||||
|
||||
|
||||
/* Create a new framebuffer object which will correspond to the given HDC.
|
||||
/**
|
||||
* Create a new framebuffer object which will correspond to the given HDC.
|
||||
*/
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_create(
|
||||
stw_framebuffer_create_locked(
|
||||
HDC hdc,
|
||||
GLvisual *visual,
|
||||
const struct stw_pixelformat_info *pfi,
|
||||
GLuint width,
|
||||
GLuint height )
|
||||
int iPixelFormat )
|
||||
{
|
||||
enum pipe_format colorFormat, depthFormat, stencilFormat;
|
||||
HWND hWnd;
|
||||
struct stw_framebuffer *fb;
|
||||
const struct stw_pixelformat_info *pfi;
|
||||
|
||||
/* We only support drawing to a window. */
|
||||
hWnd = WindowFromDC( hdc );
|
||||
if(!hWnd)
|
||||
return NULL;
|
||||
|
||||
fb = CALLOC_STRUCT( stw_framebuffer );
|
||||
if (fb == NULL)
|
||||
return NULL;
|
||||
|
||||
fb->hDC = hdc;
|
||||
fb->hWnd = hWnd;
|
||||
fb->iPixelFormat = iPixelFormat;
|
||||
|
||||
fb->pfi = pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
|
||||
|
||||
stw_pixelformat_visual(&fb->visual, pfi);
|
||||
|
||||
pipe_mutex_init( fb->mutex );
|
||||
|
||||
fb->next = stw_dev->fb_head;
|
||||
stw_dev->fb_head = fb;
|
||||
|
||||
return fb;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
stw_framebuffer_get_size( struct stw_framebuffer *fb, GLuint *pwidth, GLuint *pheight )
|
||||
{
|
||||
GLuint width, height;
|
||||
|
||||
if (fb->hWnd) {
|
||||
RECT rect;
|
||||
GetClientRect( fb->hWnd, &rect );
|
||||
width = rect.right - rect.left;
|
||||
height = rect.bottom - rect.top;
|
||||
}
|
||||
else {
|
||||
width = GetDeviceCaps( fb->hDC, HORZRES );
|
||||
height = GetDeviceCaps( fb->hDC, VERTRES );
|
||||
}
|
||||
|
||||
if(width < 1)
|
||||
width = 1;
|
||||
if(height < 1)
|
||||
height = 1;
|
||||
|
||||
*pwidth = width;
|
||||
*pheight = height;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
stw_framebuffer_allocate(
|
||||
struct stw_framebuffer *fb)
|
||||
{
|
||||
pipe_mutex_lock( fb->mutex );
|
||||
|
||||
if(!fb->stfb) {
|
||||
const struct stw_pixelformat_info *pfi = fb->pfi;
|
||||
enum pipe_format colorFormat, depthFormat, stencilFormat;
|
||||
GLuint width, height;
|
||||
|
||||
colorFormat = pfi->color_format;
|
||||
|
||||
@@ -121,54 +183,48 @@ stw_framebuffer_create(
|
||||
else
|
||||
stencilFormat = PIPE_FORMAT_NONE;
|
||||
|
||||
fb = CALLOC_STRUCT( stw_framebuffer );
|
||||
if (fb == NULL)
|
||||
return NULL;
|
||||
|
||||
fb->hDC = hdc;
|
||||
fb->hWnd = WindowFromDC( hdc );
|
||||
|
||||
pipe_mutex_init( fb->mutex );
|
||||
stw_framebuffer_get_size(fb, &width, &height);
|
||||
|
||||
fb->stfb = st_create_framebuffer(
|
||||
visual,
|
||||
&fb->visual,
|
||||
colorFormat,
|
||||
depthFormat,
|
||||
stencilFormat,
|
||||
width,
|
||||
height,
|
||||
(void *) fb );
|
||||
if(!fb->stfb) {
|
||||
FREE(fb);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
fb->next = stw_dev->fb_head;
|
||||
stw_dev->fb_head = fb;
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
pipe_mutex_unlock( fb->mutex );
|
||||
|
||||
return fb;
|
||||
return fb->stfb ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
stw_framebuffer_destroy(
|
||||
stw_framebuffer_resize(
|
||||
struct stw_framebuffer *fb)
|
||||
{
|
||||
GLuint width, height;
|
||||
assert(fb->stfb);
|
||||
stw_framebuffer_get_size(fb, &width, &height);
|
||||
st_resize_framebuffer(fb->stfb, width, height);
|
||||
}
|
||||
|
||||
|
||||
static INLINE void
|
||||
stw_framebuffer_destroy_locked(
|
||||
struct stw_framebuffer *fb )
|
||||
{
|
||||
struct stw_framebuffer **link;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
|
||||
link = &stw_dev->fb_head;
|
||||
while (link && *link != fb)
|
||||
while (*link != fb)
|
||||
link = &(*link)->next;
|
||||
assert(*link);
|
||||
if (link)
|
||||
*link = fb->next;
|
||||
fb->next = NULL;
|
||||
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
|
||||
st_unreference_framebuffer(fb->stfb);
|
||||
|
||||
pipe_mutex_destroy( fb->mutex );
|
||||
@@ -176,6 +232,44 @@ stw_framebuffer_destroy(
|
||||
FREE( fb );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
stw_framebuffer_cleanup( void )
|
||||
{
|
||||
struct stw_framebuffer *fb;
|
||||
struct stw_framebuffer *next;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
|
||||
fb = stw_dev->fb_head;
|
||||
while (fb) {
|
||||
next = fb->next;
|
||||
stw_framebuffer_destroy_locked(fb);
|
||||
fb = next;
|
||||
}
|
||||
stw_dev->fb_head = NULL;
|
||||
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Given an hdc, return the corresponding stw_framebuffer.
|
||||
*/
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_from_hdc_locked(
|
||||
HDC hdc )
|
||||
{
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
|
||||
if (fb->hDC == hdc)
|
||||
break;
|
||||
|
||||
return fb;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Given an hdc, return the corresponding stw_framebuffer.
|
||||
*/
|
||||
@@ -186,15 +280,69 @@ stw_framebuffer_from_hdc(
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
|
||||
if (fb->hDC == hdc)
|
||||
break;
|
||||
fb = stw_framebuffer_from_hdc_locked(hdc);
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
|
||||
return fb;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
stw_pixelformat_set(
|
||||
HDC hdc,
|
||||
int iPixelFormat )
|
||||
{
|
||||
uint count;
|
||||
uint index;
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
index = (uint) iPixelFormat - 1;
|
||||
count = stw_pixelformat_get_extended_count();
|
||||
if (index >= count)
|
||||
return FALSE;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
|
||||
fb = stw_framebuffer_from_hdc_locked(hdc);
|
||||
if(fb) {
|
||||
/* SetPixelFormat must be called only once */
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fb = stw_framebuffer_create_locked(hdc, iPixelFormat);
|
||||
if(!fb) {
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
|
||||
/* Some applications mistakenly use the undocumented wglSetPixelFormat
|
||||
* function instead of SetPixelFormat, so we call SetPixelFormat here to
|
||||
* avoid opengl32.dll's wglCreateContext to fail */
|
||||
if (GetPixelFormat(hdc) == 0) {
|
||||
SetPixelFormat(hdc, iPixelFormat, NULL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
stw_pixelformat_get(
|
||||
HDC hdc )
|
||||
{
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
fb = stw_framebuffer_from_hdc(hdc);
|
||||
if(!fb)
|
||||
return 0;
|
||||
|
||||
return fb->iPixelFormat;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
stw_swap_buffers(
|
||||
HDC hdc )
|
||||
|
@@ -44,6 +44,10 @@ struct stw_framebuffer
|
||||
HDC hDC;
|
||||
HWND hWnd;
|
||||
|
||||
int iPixelFormat;
|
||||
const struct stw_pixelformat_info *pfi;
|
||||
GLvisual visual;
|
||||
|
||||
pipe_mutex mutex;
|
||||
struct st_framebuffer *stfb;
|
||||
|
||||
@@ -52,17 +56,25 @@ struct stw_framebuffer
|
||||
};
|
||||
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_create(
|
||||
stw_framebuffer_create_locked(
|
||||
HDC hdc,
|
||||
GLvisual *visual,
|
||||
const struct stw_pixelformat_info *pfi,
|
||||
GLuint width,
|
||||
GLuint height );
|
||||
int iPixelFormat );
|
||||
|
||||
BOOL
|
||||
stw_framebuffer_allocate(
|
||||
struct stw_framebuffer *fb );
|
||||
|
||||
void
|
||||
stw_framebuffer_destroy(
|
||||
stw_framebuffer_resize(
|
||||
struct stw_framebuffer *fb);
|
||||
|
||||
void
|
||||
stw_framebuffer_cleanup(void);
|
||||
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_from_hdc_locked(
|
||||
HDC hdc );
|
||||
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_from_hdc(
|
||||
HDC hdc );
|
||||
|
@@ -25,12 +25,14 @@
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "main/mtypes.h"
|
||||
#include "main/context.h"
|
||||
|
||||
#include "pipe/p_format.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_screen.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
#include "stw_device.h"
|
||||
#include "stw_pixelformat.h"
|
||||
@@ -261,6 +263,31 @@ stw_pixelformat_get_info( uint index )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
stw_pixelformat_visual(GLvisual *visual,
|
||||
const struct stw_pixelformat_info *pfi )
|
||||
{
|
||||
memset(visual, 0, sizeof *visual);
|
||||
_mesa_initialize_visual(
|
||||
visual,
|
||||
(pfi->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE,
|
||||
(pfi->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE,
|
||||
(pfi->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE,
|
||||
pfi->pfd.cRedBits,
|
||||
pfi->pfd.cGreenBits,
|
||||
pfi->pfd.cBlueBits,
|
||||
pfi->pfd.cAlphaBits,
|
||||
(pfi->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pfi->pfd.cColorBits : 0,
|
||||
pfi->pfd.cDepthBits,
|
||||
pfi->pfd.cStencilBits,
|
||||
pfi->pfd.cAccumRedBits,
|
||||
pfi->pfd.cAccumGreenBits,
|
||||
pfi->pfd.cAccumBlueBits,
|
||||
pfi->pfd.cAccumAlphaBits,
|
||||
pfi->numSamples );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
stw_pixelformat_describe(
|
||||
HDC hdc,
|
||||
@@ -341,39 +368,3 @@ int stw_pixelformat_choose( HDC hdc,
|
||||
|
||||
return bestindex + 1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
stw_pixelformat_get(
|
||||
HDC hdc )
|
||||
{
|
||||
return stw_tls_get_data()->currentPixelFormat;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
stw_pixelformat_set(
|
||||
HDC hdc,
|
||||
int iPixelFormat )
|
||||
{
|
||||
uint count;
|
||||
uint index;
|
||||
|
||||
(void) hdc;
|
||||
|
||||
index = (uint) iPixelFormat - 1;
|
||||
count = stw_pixelformat_get_extended_count();
|
||||
if (index >= count)
|
||||
return FALSE;
|
||||
|
||||
stw_tls_get_data()->currentPixelFormat = iPixelFormat;
|
||||
|
||||
/* Some applications mistakenly use the undocumented wglSetPixelFormat
|
||||
* function instead of SetPixelFormat, so we call SetPixelFormat here to
|
||||
* avoid opengl32.dll's wglCreateContext to fail */
|
||||
if (GetPixelFormat(hdc) == 0) {
|
||||
SetPixelFormat(hdc, iPixelFormat, NULL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -30,6 +30,8 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "main/mtypes.h"
|
||||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_format.h"
|
||||
|
||||
@@ -56,5 +58,8 @@ stw_pixelformat_get_extended_count( void );
|
||||
const struct stw_pixelformat_info *
|
||||
stw_pixelformat_get_info( uint index );
|
||||
|
||||
void
|
||||
stw_pixelformat_visual(GLvisual *visual,
|
||||
const struct stw_pixelformat_info *pfi );
|
||||
|
||||
#endif /* STW_PIXELFORMAT_H */
|
||||
|
@@ -53,8 +53,6 @@ stw_tls_data_create()
|
||||
if (!data)
|
||||
return NULL;
|
||||
|
||||
data->currentPixelFormat = 0;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,6 @@
|
||||
|
||||
struct stw_tls_data
|
||||
{
|
||||
uint currentPixelFormat;
|
||||
HHOOK hCallWndProcHook;
|
||||
};
|
||||
|
||||
|
@@ -1259,7 +1259,7 @@ initialize_framebuffer_size(GLcontext *ctx, GLframebuffer *fb)
|
||||
* \param drawBuffer the drawing framebuffer
|
||||
* \param readBuffer the reading framebuffer
|
||||
*/
|
||||
void
|
||||
GLboolean
|
||||
_mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
|
||||
GLframebuffer *readBuffer )
|
||||
{
|
||||
@@ -1272,14 +1272,14 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
|
||||
if (!check_compatible(newCtx, drawBuffer)) {
|
||||
_mesa_warning(newCtx,
|
||||
"MakeCurrent: incompatible visuals for context and drawbuffer");
|
||||
return;
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
if (newCtx && readBuffer && newCtx->WinSysReadBuffer != readBuffer) {
|
||||
if (!check_compatible(newCtx, readBuffer)) {
|
||||
_mesa_warning(newCtx,
|
||||
"MakeCurrent: incompatible visuals for context and readbuffer");
|
||||
return;
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1384,6 +1384,8 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
|
||||
newCtx->FirstTimeCurrent = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -130,7 +130,7 @@ extern void
|
||||
_mesa_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
|
||||
|
||||
|
||||
extern void
|
||||
extern GLboolean
|
||||
_mesa_make_current( GLcontext *ctx, GLframebuffer *drawBuffer,
|
||||
GLframebuffer *readBuffer );
|
||||
|
||||
|
@@ -1008,6 +1008,16 @@ output_if_debug(const char *prefixString, const char *outputString,
|
||||
fprintf(stderr, "%s: %s", prefixString, outputString);
|
||||
if (newline)
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE)
|
||||
/* stderr from windows applications without console is not usually
|
||||
* visible, so communicate with the debugger instead */
|
||||
{
|
||||
char buf[4096];
|
||||
_mesa_snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : "");
|
||||
OutputDebugStringA(buf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -192,7 +192,8 @@ static void update_raster_state( struct st_context *st )
|
||||
raster->point_sprite = ctx->Point.PointSprite;
|
||||
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
|
||||
if (ctx->Point.CoordReplace[i]) {
|
||||
if (ctx->Point.SpriteOrigin == GL_UPPER_LEFT)
|
||||
if ((ctx->Point.SpriteOrigin == GL_UPPER_LEFT) ^
|
||||
(st_fb_orientation(ctx->DrawBuffer) == Y_0_BOTTOM))
|
||||
raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_UPPER_LEFT;
|
||||
else
|
||||
raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_LOWER_LEFT;
|
||||
|
@@ -263,7 +263,8 @@ void st_destroy_context( struct st_context *st )
|
||||
}
|
||||
|
||||
|
||||
void st_make_current(struct st_context *st,
|
||||
GLboolean
|
||||
st_make_current(struct st_context *st,
|
||||
struct st_framebuffer *draw,
|
||||
struct st_framebuffer *read)
|
||||
{
|
||||
@@ -274,7 +275,8 @@ void st_make_current(struct st_context *st,
|
||||
|
||||
if (st) {
|
||||
GLboolean firstTime = st->ctx->FirstTimeCurrent;
|
||||
_mesa_make_current(st->ctx, &draw->Base, &read->Base);
|
||||
if(!_mesa_make_current(st->ctx, &draw->Base, &read->Base))
|
||||
return GL_FALSE;
|
||||
/* Need to initialize viewport here since draw->Base->Width/Height
|
||||
* will still be zero at this point.
|
||||
* This could be improved, but would require rather extensive work
|
||||
@@ -286,9 +288,10 @@ void st_make_current(struct st_context *st,
|
||||
_mesa_set_scissor(st->ctx, 0, 0, w, h);
|
||||
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
else {
|
||||
_mesa_make_current(NULL, NULL, NULL);
|
||||
return _mesa_make_current(NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -91,7 +91,7 @@ void *st_framebuffer_private( struct st_framebuffer *stfb );
|
||||
|
||||
void st_unreference_framebuffer( struct st_framebuffer *stfb );
|
||||
|
||||
void st_make_current(struct st_context *st,
|
||||
GLboolean st_make_current(struct st_context *st,
|
||||
struct st_framebuffer *draw,
|
||||
struct st_framebuffer *read);
|
||||
|
||||
|
Reference in New Issue
Block a user