diff options
Diffstat (limited to 'src/mesa/drivers/windows')
| -rw-r--r-- | src/mesa/drivers/windows/gdi/mesa.def | 31 | ||||
| -rw-r--r-- | src/mesa/drivers/windows/gdi/wgl.c | 30 | ||||
| -rw-r--r-- | src/mesa/drivers/windows/gdi/wmesa.c | 338 | 
3 files changed, 330 insertions, 69 deletions
diff --git a/src/mesa/drivers/windows/gdi/mesa.def b/src/mesa/drivers/windows/gdi/mesa.def index c525945426..3f2d644e86 100644 --- a/src/mesa/drivers/windows/gdi/mesa.def +++ b/src/mesa/drivers/windows/gdi/mesa.def @@ -867,8 +867,6 @@ EXPORTS  	_glapi_get_proc_address  	_mesa_add_soft_renderbuffers  	_mesa_add_renderbuffer -	_mesa_attach_shader -	_mesa_bind_attrib_location  	_mesa_buffer_data  	_mesa_buffer_get_subdata  	_mesa_buffer_map @@ -877,24 +875,20 @@ EXPORTS  	_mesa_bzero  	_mesa_calloc  	_mesa_choose_tex_format -	_mesa_compile_shader  	_mesa_compressed_texture_size  	_mesa_create_framebuffer -	_mesa_create_program -	_mesa_create_shader  	_mesa_create_visual  	_mesa_delete_array_object  	_mesa_delete_buffer_object  	_mesa_delete_program -	_mesa_delete_program2 -	_mesa_delete_shader  	_mesa_delete_texture_object  	_mesa_destroy_framebuffer  	_mesa_destroy_visual -	_mesa_detach_shader  	_mesa_enable_1_3_extensions  	_mesa_enable_1_4_extensions  	_mesa_enable_1_5_extensions +	_mesa_enable_2_0_extensions +	_mesa_enable_2_1_extensions  	_mesa_enable_sw_extensions  	_mesa_error  	_mesa_finish_render_texture @@ -902,28 +896,15 @@ EXPORTS  	_mesa_free  	_mesa_free_context_data  	_mesa_free_texture_image_data -	_mesa_get_active_attrib -	_mesa_get_active_uniform  -	_mesa_get_attached_shaders -	_mesa_get_attrib_location +	_mesa_generate_mipmap  	_mesa_get_compressed_teximage  	_mesa_get_current_context -	_mesa_get_handle -	_mesa_get_programiv -	_mesa_get_program_info_log  	_mesa_get_program_register -	_mesa_get_shaderiv -	_mesa_get_shader_info_log -	_mesa_get_shader_source  	_mesa_get_teximage -	_mesa_get_uniformfv -	_mesa_get_uniform_location  	_mesa_init_driver_functions +	_mesa_init_glsl_driver_functions  	_mesa_init_renderbuffer  	_mesa_initialize_context -	_mesa_is_program -	_mesa_is_shader -	_mesa_link_program  	_mesa_make_current  	_mesa_memcpy  	_mesa_memset @@ -942,7 +923,6 @@ EXPORTS  	_mesa_render_texture  	_mesa_ResizeBuffersMESA  	_mesa_resize_framebuffer -	_mesa_shader_source  	_mesa_store_compressed_teximage1d  	_mesa_store_compressed_teximage2d  	_mesa_store_compressed_teximage3d @@ -957,12 +937,9 @@ EXPORTS  	_mesa_store_texsubimage3d  	_mesa_strcmp  	_mesa_test_proxy_teximage -	_mesa_uniform -	_mesa_uniform_matrix  	_mesa_unreference_framebuffer  	_mesa_update_framebuffer_visual  	_mesa_use_program -	_mesa_validate_program  	_mesa_Viewport  	_swrast_Accum  	_swrast_Bitmap diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c index 6e00d08aba..9f0bb9122a 100644 --- a/src/mesa/drivers/windows/gdi/wgl.c +++ b/src/mesa/drivers/windows/gdi/wgl.c @@ -54,7 +54,7 @@  #include <windows.h>  #endif - +#include "config.h"  #include "glapi.h"  #include "GL/wmesa.h"   /* protos for wmesa* functions */ @@ -69,10 +69,12 @@ struct __pixelformat__      GLboolean doubleBuffered;  }; + +  /* These are the PFD's supported by this driver. */  struct __pixelformat__	pfd[] =  { -#if 0 +#if 0       /* Double Buffer, alpha */      {	  	{	 @@ -86,7 +88,7 @@ struct __pixelformat__	pfd[] =  	    8, 16,	  	    8, 24,  	    0, 0, 0, 0, 0,	 -	    16,	8,	 +	    DEFAULT_SOFTWARE_DEPTH_BITS,	8,	  	    0, 0, 0,	  	    0, 0, 0   	}, @@ -105,13 +107,13 @@ struct __pixelformat__	pfd[] =  	    8, 16,	  	    8, 24,  	    0, 0, 0, 0,	0,	 -	    16,	8, +	    DEFAULT_SOFTWARE_DEPTH_BITS,	8,	  	    0, 0, 0,	  	    0, 0, 0  	},          GL_FALSE      }, -#endif +#endif       /* Double Buffer, no alpha */      {	  	{	 @@ -125,7 +127,7 @@ struct __pixelformat__	pfd[] =  	    8, 16,  	    0, 0,  	    0, 0, 0, 0,	0, -	    16,	8, +	    DEFAULT_SOFTWARE_DEPTH_BITS,	8,	  	    0, 0, 0,   	    0, 0, 0   	}, @@ -144,7 +146,7 @@ struct __pixelformat__	pfd[] =  	    8, 16,  	    0, 0,  	    0, 0, 0, 0,	0, -	    16,	8, +	    DEFAULT_SOFTWARE_DEPTH_BITS,	8,	  	    0, 0, 0,  	    0, 0, 0   	}, @@ -578,6 +580,13 @@ WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsA(HDC hdc, DWORD first,      return success;  } +WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1, +					HGLRC hglrc2) +{ +    WMesaShareLists((WMesaContext)hglrc1, (WMesaContext)hglrc2); +    return(TRUE); +} +  /* NOT IMPLEMENTED YET */ @@ -597,13 +606,6 @@ WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc,      return(NULL);  } -WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1, -					HGLRC hglrc2) -{ -    (void) hglrc1; (void) hglrc2; -    return(TRUE); -} -  WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc,  					     DWORD first, diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 5b67439f0f..80746950c7 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -56,11 +56,13 @@ wmesa_free_framebuffer(HDC hdc)  	prev = pwfb;      }      if (pwfb) { +        struct gl_framebuffer *fb;  	if (pwfb == FirstFramebuffer)  	    FirstFramebuffer = pwfb->next;  	else  	    prev->next = pwfb->next; -	free(pwfb); +        fb = &pwfb->Base; +        _mesa_unreference_framebuffer(&fb);       }  } @@ -118,6 +120,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC)      /* Only 16 and 32 bit targets are supported now */      assert(pwfb->cColorBits == 0 ||  	   pwfb->cColorBits == 16 ||  +	   pwfb->cColorBits == 24 ||   	   pwfb->cColorBits == 32);      switch(pwfb->cColorBits){ @@ -127,6 +130,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC)      case 16:  	pwfb->pixelformat = PF_5R6G5B;  	break; +    case 24:      case 32:  	pwfb->pixelformat = PF_8R8G8B;  	break; @@ -458,23 +462,84 @@ static void write_rgba_span_front(const GLcontext *ctx,  				   const GLubyte rgba[][4],   				   const GLubyte mask[] )  { -    WMesaContext pwc = wmesa_context(ctx); -    GLuint i; -     -    (void) ctx; -    y=FLIP(y); -    if (mask) { -	for (i=0; i<n; i++) -	    if (mask[i]) -		SetPixel(pwc->hDC, x+i, y, RGB(rgba[i][RCOMP], rgba[i][GCOMP],  -					       rgba[i][BCOMP])); -    } -    else { -	for (i=0; i<n; i++) -	    SetPixel(pwc->hDC, x+i, y, RGB(rgba[i][RCOMP], rgba[i][GCOMP],  -					   rgba[i][BCOMP])); -    } -     +   WMesaContext pwc = wmesa_context(ctx); +   WMesaFramebuffer pwfb = wmesa_lookup_framebuffer(pwc->hDC); +   CONST BITMAPINFO bmi= +   { +      { +         sizeof(BITMAPINFOHEADER), +         n, 1, 1, 32, BI_RGB, 0, 1, 1, 0, 0 +      } +   }; +   HBITMAP bmp=0; +   HDC mdc=0; +   typedef union +   { +      unsigned i; +      struct { +         unsigned b:8, g:8, r:8, a:8; +      }; +   } BGRA; +   BGRA *bgra, c; +   int i; + +   if (n < 16) {   // the value 16 is just guessed +      y=FLIP(y); +      if (mask) { +         for (i=0; i<n; i++) +            if (mask[i]) +               SetPixel(pwc->hDC, x+i, y, +                        RGB(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP])); +      } +      else { +         for (i=0; i<n; i++) +            SetPixel(pwc->hDC, x+i, y, +                     RGB(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP])); +      } +   } +   else { +      if (!pwfb) { +         _mesa_problem(NULL, "wmesa: write_rgba_span_front on unknown hdc"); +         return; +      } +      bgra=malloc(n*sizeof(BGRA)); +      if (!bgra) { +         _mesa_problem(NULL, "wmesa: write_rgba_span_front: out of memory"); +         return; +      } +      c.a=0; +      if (mask) { +         for (i=0; i<n; i++) { +            if (mask[i]) { +               c.r=rgba[i][RCOMP]; +               c.g=rgba[i][GCOMP]; +               c.b=rgba[i][BCOMP]; +               c.a=rgba[i][ACOMP]; +               bgra[i]=c; +            } +            else +               bgra[i].i=0; +         } +      } +      else { +         for (i=0; i<n; i++) { +            c.r=rgba[i][RCOMP]; +            c.g=rgba[i][GCOMP]; +            c.b=rgba[i][BCOMP]; +            c.a=rgba[i][ACOMP]; +            bgra[i]=c; +         } +      } +      bmp=CreateBitmap(n, 1,  1, 32, bgra); +      mdc=CreateCompatibleDC(pwfb->hDC); +      SelectObject(mdc, bmp); +      y=FLIP(y); +      BitBlt(pwfb->hDC, x, y, n, 1, mdc, 0, 0, SRCCOPY); +      SelectObject(mdc, 0); +      DeleteObject(bmp); +      DeleteDC(mdc); +      free(bgra); +   }  }  /* Write a horizontal span of RGB color pixels with a boolean mask. */ @@ -795,6 +860,195 @@ static void read_rgba_pixels_32(const GLcontext *ctx,  /*********************************************************************/ +/* DOUBLE BUFFER 24-bit */ + +#define WMSETPIXEL24(pwc, y, x, r, g, b) { \ +LPBYTE lpb = ((LPBYTE)((pwc)->pbPixels + (pwc)->ScanWidth * (y)) + (3 * x)); \ +lpb[0] = (b); \ +lpb[1] = (g); \ +lpb[2] = (r); } + +/* Write a horizontal span of RGBA color pixels with a boolean mask. */ +static void write_rgba_span_24(const GLcontext *ctx,  +			       struct gl_renderbuffer *rb,  +			       GLuint n, GLint x, GLint y, +			       const GLubyte rgba[][4],  +			       const GLubyte mask[] ) +{ +    WMesaContext pwc = wmesa_context(ctx); +    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); +    GLuint i; +    LPBYTE lpb; + +    (void) ctx; +     +    y=FLIP(y); +    lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); +    if (mask) { +	for (i=0; i<n; i++) +	    if (mask[i]) { +                lpb[3*i] = rgba[i][BCOMP]; +                lpb[3*i+1] = rgba[i][GCOMP]; +                lpb[3*i+2] = rgba[i][RCOMP]; +	    } +    } +    else { +	    for (i=0; i<n; i++) { +            *lpb++ = rgba[i][BCOMP]; +            *lpb++ = rgba[i][GCOMP]; +            *lpb++ = rgba[i][RCOMP]; +	    } +    } +} + + +/* Write a horizontal span of RGB color pixels with a boolean mask. */ +static void write_rgb_span_24(const GLcontext *ctx,  +			      struct gl_renderbuffer *rb,  +			      GLuint n, GLint x, GLint y, +			      const GLubyte rgb[][3],  +			      const GLubyte mask[] ) +{ +    WMesaContext pwc = wmesa_context(ctx); +    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); +    GLuint i; +    LPBYTE lpb; + +    (void) ctx; +     +    y=FLIP(y); +    lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); +    if (mask) { +	for (i=0; i<n; i++) +	    if (mask[i]) { +            lpb[3*i] = rgb[i][BCOMP]; +            lpb[3*i+1] = rgb[i][GCOMP]; +            lpb[3*i+2] = rgb[i][RCOMP]; +	    } +    } +    else { +    	for (i=0; i<n; i++) { +    		*lpb++ = rgb[i][BCOMP]; +    		*lpb++ = rgb[i][GCOMP]; +    		*lpb++ = rgb[i][RCOMP]; +    	} +    } +} + +/* + * Write a horizontal span of pixels with a boolean mask.  The current color + * is used for all pixels. + */ +static void write_mono_rgba_span_24(const GLcontext *ctx,  +				    struct gl_renderbuffer *rb, +				    GLuint n, GLint x, GLint y, +				    const GLchan color[4],  +				    const GLubyte mask[]) +{ +    LPBYTE lpb; +    GLuint i; +    WMesaContext pwc = wmesa_context(ctx); +    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); +    lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); +    y=FLIP(y); +    if (mask) { +	for (i=0; i<n; i++) +	    if (mask[i]) { +	    	lpb[3*i] = color[BCOMP]; +	    	lpb[3*i+1] = color[GCOMP]; +	    	lpb[3*i+2] = color[RCOMP]; +	    } +    } +    else +	for (i=0; i<n; i++) { +		*lpb++ = color[BCOMP]; +		*lpb++ = color[GCOMP]; +		*lpb++ = color[RCOMP];		 +	} +} + +/* Write an array of RGBA pixels with a boolean mask. */ +static void write_rgba_pixels_24(const GLcontext *ctx,  +				 struct gl_renderbuffer *rb, +				 GLuint n, const GLint x[], const GLint y[], +				 const GLubyte rgba[][4],  +				 const GLubyte mask[]) +{ +    GLuint i; +    WMesaContext pwc = wmesa_context(ctx); +    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); +    for (i=0; i<n; i++) +	if (mask[i]) +	    WMSETPIXEL24(pwfb, FLIP(y[i]), x[i], +			 rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]); +} + +/* + * Write an array of pixels with a boolean mask.  The current color + * is used for all pixels. + */ +static void write_mono_rgba_pixels_24(const GLcontext *ctx,  +				      struct gl_renderbuffer *rb, +				      GLuint n, +				      const GLint x[], const GLint y[], +				      const GLchan color[4], +				      const GLubyte mask[]) +{ +    GLuint i; +    WMesaContext pwc = wmesa_context(ctx); +    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); +    for (i=0; i<n; i++) +	if (mask[i]) +	    WMSETPIXEL24(pwfb, FLIP(y[i]),x[i],color[RCOMP], +			 color[GCOMP], color[BCOMP]); +} + +/* Read a horizontal span of color pixels. */ +static void read_rgba_span_24(const GLcontext *ctx,  +			      struct gl_renderbuffer *rb, +			      GLuint n, GLint x, GLint y, +			      GLubyte rgba[][4] ) +{ +    GLuint i; +    LPBYTE lpb; +    WMesaContext pwc = wmesa_context(ctx); +    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); +     +    y = FLIP(y); +    lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x); +    for (i=0; i<n; i++) { +	rgba[i][RCOMP] = lpb[3*i+2]; +	rgba[i][GCOMP] = lpb[3*i+1]; +	rgba[i][BCOMP] = lpb[3*i]; +	rgba[i][ACOMP] = 255; +    } +} + + +/* Read an array of color pixels. */ +static void read_rgba_pixels_24(const GLcontext *ctx,  +				struct gl_renderbuffer *rb, +				GLuint n, const GLint x[], const GLint y[], +				GLubyte rgba[][4]) +{ +    GLuint i; +    LPBYTE lpb; +    WMesaContext pwc = wmesa_context(ctx); +    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); + +    for (i=0; i<n; i++) { +	GLint y2 = FLIP(y[i]); +	lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y2)) + (3 * x[i]); +	rgba[i][RCOMP] = lpb[3*i+2]; +	rgba[i][GCOMP] = lpb[3*i+1]; +	rgba[i][BCOMP] = lpb[3*i]; +	rgba[i][ACOMP] = 255; +  } +} + + +/*********************************************************************/ +  /* DOUBLE BUFFER 16-bit */  #define WMSETPIXEL16(pwc, y, x, r, g, b) { \ @@ -1016,7 +1270,7 @@ wmesa_renderbuffer_storage(GLcontext *ctx,   * on if we're drawing to the front or back color buffer.   */  void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, -                                  int double_buffer) +                                  BYTE cColorBits, int double_buffer)  {      if (double_buffer) {          /* back buffer */ @@ -1036,16 +1290,32 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat,              rb->BlueBits = 5;  	    break;  	case PF_8R8G8B: -	    rb->PutRow = write_rgba_span_32; -	    rb->PutRowRGB = write_rgb_span_32; -	    rb->PutMonoRow = write_mono_rgba_span_32; -	    rb->PutValues = write_rgba_pixels_32; -	    rb->PutMonoValues = write_mono_rgba_pixels_32; -	    rb->GetRow = read_rgba_span_32; -	    rb->GetValues = read_rgba_pixels_32; +		if (cColorBits == 24) +		{ +		    rb->PutRow = write_rgba_span_24; +		    rb->PutRowRGB = write_rgb_span_24; +		    rb->PutMonoRow = write_mono_rgba_span_24; +		    rb->PutValues = write_rgba_pixels_24; +		    rb->PutMonoValues = write_mono_rgba_pixels_24; +		    rb->GetRow = read_rgba_span_24; +		    rb->GetValues = read_rgba_pixels_24; +	        rb->RedBits = 8; +	        rb->GreenBits = 8; +	        rb->BlueBits = 8;		 +		} +		else +		{ +	        rb->PutRow = write_rgba_span_32; +	        rb->PutRowRGB = write_rgb_span_32; +	        rb->PutMonoRow = write_mono_rgba_span_32; +	        rb->PutValues = write_rgba_pixels_32; +	        rb->PutMonoValues = write_mono_rgba_pixels_32; +	        rb->GetRow = read_rgba_span_32; +	        rb->GetValues = read_rgba_pixels_32;              rb->RedBits = 8;              rb->GreenBits = 8;              rb->BlueBits = 8; +		}  	    break;  	default:  	    break; @@ -1235,6 +1505,9 @@ WMesaContext WMesaCreateContext(HDC hDC,      ctx = &c->gl_ctx;      _mesa_initialize_context(ctx, visual, NULL, &functions, (void *)c); +    /* visual no longer needed - it was copied by _mesa_initialize_context() */ +    _mesa_destroy_visual(visual); +      _mesa_enable_sw_extensions(ctx);      _mesa_enable_1_3_extensions(ctx);      _mesa_enable_1_4_extensions(ctx); @@ -1352,11 +1625,11 @@ void WMesaMakeCurrent(WMesaContext c, HDC hdc)          if (visual->doubleBufferMode == 1) {              rb = wmesa_new_renderbuffer();              _mesa_add_renderbuffer(&pwfb->Base, BUFFER_BACK_LEFT, rb); -            wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, 1); +            wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 1);  	}          rb = wmesa_new_renderbuffer();          _mesa_add_renderbuffer(&pwfb->Base, BUFFER_FRONT_LEFT, rb); -        wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, 0); +        wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 0);  	/* Let Mesa own the Depth, Stencil, and Accum buffers */          _mesa_add_soft_renderbuffers(&pwfb->Base, @@ -1401,6 +1674,11 @@ void WMesaSwapBuffers( HDC hdc )      }  } +void WMesaShareLists(WMesaContext ctx_to_share, WMesaContext ctx) +{ +	_mesa_share_state(&ctx->gl_ctx, &ctx_to_share->gl_ctx);	 +} +  /* This is hopefully a temporary hack to define some needed dispatch   * table entries.  Hopefully, I'll find a better solution.  The   * dispatch table generation scripts ought to be making these dummy @@ -1439,15 +1717,19 @@ void gl_dispatch_stub_650(void){}  void gl_dispatch_stub_651(void){}  void gl_dispatch_stub_652(void){}  void gl_dispatch_stub_653(void){} +void gl_dispatch_stub_733(void){}  void gl_dispatch_stub_734(void){}  void gl_dispatch_stub_735(void){}  void gl_dispatch_stub_736(void){}  void gl_dispatch_stub_737(void){}  void gl_dispatch_stub_738(void){} +void gl_dispatch_stub_744(void){}  void gl_dispatch_stub_745(void){}  void gl_dispatch_stub_746(void){}  void gl_dispatch_stub_760(void){}  void gl_dispatch_stub_761(void){} +void gl_dispatch_stub_763(void){} +void gl_dispatch_stub_765(void){}  void gl_dispatch_stub_766(void){}  void gl_dispatch_stub_767(void){}  void gl_dispatch_stub_768(void){}  | 
