void tridentFallback( tridentContextPtr tmesa, GLuint bit, GLboolean mode ) { GLcontext *ctx = tmesa->glCtx; TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint oldfallback = tmesa->Fallback; _tnl_need_projected_coords( ctx, GL_FALSE ); if (mode) { tmesa->Fallback |= bit; if (oldfallback == 0) { _swsetup_Wakeup( ctx ); tmesa->RenderIndex = ~0; } } else { tmesa->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); tnl->Driver.Render.Start = tridentRenderStart; tnl->Driver.Render.PrimitiveNotify = tridentRenderPrimitive; tnl->Driver.Render.Finish = tridentRenderFinish; tnl->Driver.Render.BuildVertices = tridentBuildVertices; tnl->Driver.Render.ResetLineStipple = tridentResetLineStipple; tmesa->new_gl_state |= (_TRIDENT_NEW_RENDER_STATE| _TRIDENT_NEW_VERTEX); } } }
void sisFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) { TNLcontext *tnl = TNL_CONTEXT(ctx); sisContextPtr smesa = SIS_CONTEXT(ctx); GLuint oldfallback = smesa->Fallback; if (mode) { smesa->Fallback |= bit; if (oldfallback == 0) { _swsetup_Wakeup( ctx ); smesa->RenderIndex = ~0; } } else { smesa->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); tnl->Driver.Render.Start = sisRenderStart; tnl->Driver.Render.PrimitiveNotify = sisRenderPrimitive; tnl->Driver.Render.Finish = sisRenderFinish; tnl->Driver.Render.BuildVertices = sisBuildVertices; smesa->NewGLState |= (_SIS_NEW_RENDER_STATE| _SIS_NEW_VERTEX_STATE); } } }
void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) { TNLcontext *tnl = TNL_CONTEXT(ctx); mgaContextPtr mmesa = MGA_CONTEXT(ctx); GLuint oldfallback = mmesa->Fallback; if (mode) { mmesa->Fallback |= bit; if (oldfallback == 0) { FLUSH_BATCH(mmesa); _swsetup_Wakeup( ctx ); mmesa->RenderIndex = ~0; } } else { mmesa->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); tnl->Driver.Render.Start = mgaCheckTexSizes; tnl->Driver.Render.PrimitiveNotify = mgaRenderPrimitive; tnl->Driver.Render.Finish = mgaRenderFinish; tnl->Driver.Render.BuildVertices = mgaBuildVertices; mmesa->new_gl_state |= (_MGA_NEW_RENDERSTATE | _MGA_NEW_RASTERSETUP); } } }
static void gl_ggiSetupPointers(GLcontext *ctx) { TNLcontext *tnl; GGIMESADPRINT_CORE("gl_ggiSetupPointers() called\n"); /* Plug in default driver functions */ _mesa_init_driver_functions(&ctx->Driver); /* Plug in ggi-specific functions */ ctx->Driver.GetString = gl_ggiGetString; ctx->Driver.GetBufferSize = gl_ggiGetSize; ctx->Driver.Viewport = gl_ggiViewport; ctx->Driver.Finish = gl_ggiFlush; ctx->Driver.Flush = gl_ggiFlush; ctx->Driver.Clear = gl_ggiClear; ctx->Driver.ClearIndex = gl_ggiSetClearIndex; ctx->Driver.ClearColor = gl_ggiSetClearColor; ctx->Driver.IndexMask = gl_ggiIndexMask; ctx->Driver.ColorMask = gl_ggiColorMask; ctx->Driver.Enable = gl_ggiEnable; ctx->Driver.UpdateState = gl_ggiUpdateState; /* Initialize TNL driver interface */ tnl = TNL_CONTEXT(ctx); tnl->Driver.RunPipeline = _tnl_run_pipeline; /* Install setup for tnl */ _swsetup_Wakeup(ctx); }
void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) { TNLcontext *tnl = TNL_CONTEXT(ctx); mgaContextPtr mmesa = MGA_CONTEXT(ctx); GLuint oldfallback = mmesa->Fallback; if (mode) { mmesa->Fallback |= bit; if (oldfallback == 0) { FLUSH_BATCH(mmesa); _swsetup_Wakeup( ctx ); mmesa->RenderIndex = ~0; if (MGA_DEBUG & DEBUG_VERBOSE_FALLBACK) { fprintf(stderr, "MGA begin rasterization fallback: 0x%x %s\n", bit, getFallbackString(bit)); } } } else { mmesa->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); tnl->Driver.Render.Start = mgaCheckTexSizes; tnl->Driver.Render.PrimitiveNotify = mgaRenderPrimitive; tnl->Driver.Render.Finish = mgaRenderFinish; tnl->Driver.Render.BuildVertices = mgaBuildVertices; mmesa->NewGLState |= (_MGA_NEW_RENDERSTATE | _MGA_NEW_RASTERSETUP); if (MGA_DEBUG & DEBUG_VERBOSE_FALLBACK) { fprintf(stderr, "MGA end rasterization fallback: 0x%x %s\n", bit, getFallbackString(bit)); } } } }
void i830Fallback( i830ContextPtr imesa, GLuint bit, GLboolean mode ) { GLcontext *ctx = imesa->glCtx; TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint oldfallback = imesa->Fallback; if (mode) { imesa->Fallback |= bit; if (oldfallback == 0) { I830_FIREVERTICES(imesa); if (I830_DEBUG & DEBUG_FALLBACKS) fprintf(stderr, "ENTER FALLBACK %s\n", getFallbackString( bit )); _swsetup_Wakeup( ctx ); imesa->RenderIndex = ~0; } } else { imesa->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); if (I830_DEBUG & DEBUG_FALLBACKS) fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString( bit )); tnl->Driver.Render.Start = i830RenderStart; tnl->Driver.Render.PrimitiveNotify = i830RenderPrimitive; tnl->Driver.Render.Finish = i830RenderFinish; tnl->Driver.Render.BuildVertices = i830BuildVertices; imesa->NewGLState |= (_I830_NEW_RENDERSTATE|_I830_NEW_VERTEX); } } }
DHGLRC sw_CreateContext(struct wgl_dc_data* dc_data) { struct sw_context* sw_ctx; struct sw_framebuffer* fb = dc_data->sw_data; struct dd_function_table mesa_drv_functions; TNLcontext *tnl; /* We use the mesa memory routines for this function */ sw_ctx = CALLOC_STRUCT(sw_context); if(!sw_ctx) return NULL; /* Set mesa default functions */ _mesa_init_driver_functions(&mesa_drv_functions); /* Override */ mesa_drv_functions.GetString = sw_get_string; mesa_drv_functions.UpdateState = sw_update_state; mesa_drv_functions.GetBufferSize = NULL; /* Initialize the context */ if(!_mesa_initialize_context(&sw_ctx->mesa, fb->gl_visual, NULL, &mesa_drv_functions, (void *) sw_ctx)) { ERR("Failed to initialize the mesa context.\n"); free(sw_ctx); return NULL; } /* Initialize the "meta driver" */ _mesa_meta_init(&sw_ctx->mesa); /* Initialize helpers */ if(!_swrast_CreateContext(&sw_ctx->mesa) || !_vbo_CreateContext(&sw_ctx->mesa) || !_tnl_CreateContext(&sw_ctx->mesa) || !_swsetup_CreateContext(&sw_ctx->mesa)) { ERR("Failed initializing helpers.\n"); _mesa_free_context_data(&sw_ctx->mesa); free(sw_ctx); return NULL; } /* Wake up! */ _swsetup_Wakeup(&sw_ctx->mesa); /* Use TnL defaults */ tnl = TNL_CONTEXT(&sw_ctx->mesa); tnl->Driver.RunPipeline = _tnl_run_pipeline; /* To map the display into user memory */ sw_ctx->mesa.Driver.MapRenderbuffer = sw_MapRenderbuffer; sw_ctx->mesa.Driver.UnmapRenderbuffer = sw_UnmapRenderbuffer; return (DHGLRC)sw_ctx; }
void brw_draw_prims( struct gl_context *ctx, const struct _mesa_prim *prims, GLuint nr_prims, const struct _mesa_index_buffer *ib, GLboolean index_bounds_valid, GLuint min_index, GLuint max_index, struct gl_transform_feedback_object *unused_tfb_object, struct gl_buffer_object *indirect ) { struct brw_context *brw = brw_context(ctx); const struct gl_client_array **arrays = ctx->Array._DrawArrays; assert(unused_tfb_object == NULL); if (ctx->Query.CondRenderQuery) { perf_debug("Conditional rendering is implemented in software and may " "stall. This should be fixed in the driver.\n"); } if (!_mesa_check_conditional_render(ctx)) return; /* Handle primitive restart if needed */ if (brw_handle_primitive_restart(ctx, prims, nr_prims, ib, indirect)) { /* The draw was handled, so we can exit now */ return; } /* Do GL_SELECT and GL_FEEDBACK rendering using swrast, even though it * won't support all the extensions we support. */ if (ctx->RenderMode != GL_RENDER) { perf_debug("%s render mode not supported in hardware\n", _mesa_lookup_enum_by_nr(ctx->RenderMode)); _swsetup_Wakeup(ctx); _tnl_wakeup(ctx); _tnl_draw_prims(ctx, prims, nr_prims, ib, index_bounds_valid, min_index, max_index, NULL, NULL); return; } /* If we're going to have to upload any of the user's vertex arrays, then * get the minimum and maximum of their index buffer so we know what range * to upload. */ if (!index_bounds_valid && !vbo_all_varyings_in_vbos(arrays)) { perf_debug("Scanning index buffer to compute index buffer bounds. " "Use glDrawRangeElements() to avoid this.\n"); vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims); } /* Try drawing with the hardware, but don't do anything else if we can't * manage it. swrast doesn't support our featureset, so we can't fall back * to it. */ brw_try_draw_prims(ctx, arrays, prims, nr_prims, ib, min_index, max_index, indirect); }
void brw_draw_prims( GLcontext *ctx, const struct gl_client_array *arrays[], const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, GLuint min_index, GLuint max_index ) { struct intel_context *intel = intel_context(ctx); GLboolean retval; /* Decide if we want to rebase. If so we end up recursing once * only into this function. */ if (brw_need_rebase( ctx, arrays, ib, min_index )) { vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, min_index, max_index, brw_draw_prims ); return; } /* Make a first attempt at drawing: */ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); /* This looks like out-of-memory but potentially we have * situation where there is enough memory but it has become * fragmented. Clear out all heaps and start from scratch by * faking a contended lock event: (done elsewhere) */ if (!retval && !intel->Fallback && bmError(intel)) { DBG("retrying\n"); /* Then try a second time only to upload textures and draw the * primitives: */ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); } /* Otherwise, we really are out of memory. Pass the drawing * command to the software tnl module and which will in turn call * swrast to do the drawing. */ if (!retval) { _swsetup_Wakeup(ctx); _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); } if (intel->aub_file && (INTEL_DEBUG & DEBUG_SYNC)) { intelFinish( &intel->ctx ); intel->aub_wrap = 1; } }
/* Create the device specific context. */ static GLboolean fbCreateContext( const __GLcontextModes *glVisual, __DRIcontextPrivate *driContextPriv, void *sharedContextPrivate) { fbContextPtr fbmesa; GLcontext *ctx, *shareCtx; struct dd_function_table functions; assert(glVisual); assert(driContextPriv); /* Allocate the Fb context */ fbmesa = (fbContextPtr) _mesa_calloc( sizeof(*fbmesa) ); if ( !fbmesa ) return GL_FALSE; /* Init default driver functions then plug in our FBdev-specific functions */ _mesa_init_driver_functions(&functions); init_core_functions(&functions); /* Allocate the Mesa context */ if (sharedContextPrivate) shareCtx = ((fbContextPtr) sharedContextPrivate)->glCtx; else shareCtx = NULL; ctx = fbmesa->glCtx = _mesa_create_context(glVisual, shareCtx, &functions, (void *) fbmesa); if (!fbmesa->glCtx) { _mesa_free(fbmesa); return GL_FALSE; } driContextPriv->driverPrivate = fbmesa; /* Create module contexts */ _swrast_CreateContext( ctx ); _vbo_CreateContext( ctx ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); _swsetup_Wakeup( ctx ); /* use default TCL pipeline */ { TNLcontext *tnl = TNL_CONTEXT(ctx); tnl->Driver.RunPipeline = _tnl_run_pipeline; } _mesa_enable_sw_extensions(ctx); return GL_TRUE; }
static GLboolean CreateContext(void) { struct dd_function_table ddFuncs; GLvisual *vis; GLframebuffer *buf; GLcontext *ctx; CompilerContext *cc; vis = _mesa_create_visual(GL_FALSE, GL_FALSE, /* RGB */ 8, 8, 8, 8, /* color */ 0, 0, /* z, stencil */ 0, 0, 0, 0, 1); /* accum */ buf = _mesa_create_framebuffer(vis); cc = calloc(1, sizeof(*cc)); if (!vis || !buf || !cc) { if (vis) _mesa_destroy_visual(vis); if (buf) _mesa_destroy_framebuffer(buf); return GL_FALSE; } _mesa_init_driver_functions(&ddFuncs); ddFuncs.GetString = NULL;/*get_string;*/ ddFuncs.UpdateState = UpdateState; ddFuncs.GetBufferSize = NULL; ctx = &cc->MesaContext; _mesa_initialize_context(ctx, vis, NULL, &ddFuncs, cc); _mesa_enable_sw_extensions(ctx); if (!_swrast_CreateContext( ctx ) || !_vbo_CreateContext( ctx ) || !_tnl_CreateContext( ctx ) || !_swsetup_CreateContext( ctx )) { _mesa_destroy_visual(vis); _mesa_free_context_data(ctx); free(cc); return GL_FALSE; } TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline; _swsetup_Wakeup( ctx ); /* Override the context's default pragma settings */ ctx->Shader.DefaultPragmas = Options.Pragmas; _mesa_make_current(ctx, buf, buf); return GL_TRUE; }
GLFBDevContextPtr glFBDevCreateContext( const GLFBDevVisualPtr visual, GLFBDevContextPtr share ) { GLFBDevContextPtr ctx; GLcontext *glctx; struct dd_function_table functions; ASSERT(visual); ctx = CALLOC_STRUCT(GLFBDevContextRec); if (!ctx) return NULL; /* build table of device driver functions */ _mesa_init_driver_functions(&functions); functions.GetString = get_string; functions.UpdateState = update_state; functions.GetBufferSize = get_buffer_size; functions.Viewport = viewport; if (!_mesa_initialize_context(&ctx->glcontext, &visual->glvisual, share ? &share->glcontext : NULL, &functions, (void *) ctx)) { free(ctx); return NULL; } ctx->visual = visual; /* Create module contexts */ glctx = (GLcontext *) &ctx->glcontext; _swrast_CreateContext( glctx ); _vbo_CreateContext( glctx ); _tnl_CreateContext( glctx ); _swsetup_CreateContext( glctx ); _swsetup_Wakeup( glctx ); /* use default TCL pipeline */ { TNLcontext *tnl = TNL_CONTEXT(glctx); tnl->Driver.RunPipeline = _tnl_run_pipeline; } _mesa_enable_sw_extensions(glctx); _mesa_enable_1_3_extensions(glctx); _mesa_enable_1_4_extensions(glctx); _mesa_enable_1_5_extensions(glctx); _mesa_enable_2_0_extensions(glctx); _mesa_enable_2_1_extensions(glctx); return ctx; }
void brw_draw_prims( struct gl_context *ctx, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, GLboolean index_bounds_valid, GLuint min_index, GLuint max_index, struct gl_transform_feedback_object *tfb_vertcount ) { const struct gl_client_array **arrays = ctx->Array._DrawArrays; bool retval; if (!_mesa_check_conditional_render(ctx)) return; /* Handle primitive restart if needed */ if (brw_handle_primitive_restart(ctx, prim, nr_prims, ib)) { /* The draw was handled, so we can exit now */ return; } if (!vbo_all_varyings_in_vbos(arrays)) { if (!index_bounds_valid) vbo_get_minmax_indices(ctx, prim, ib, &min_index, &max_index, nr_prims); /* Decide if we want to rebase. If so we end up recursing once * only into this function. */ if (min_index != 0 && !vbo_any_varyings_in_vbos(arrays)) { vbo_rebase_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index, brw_draw_prims ); return; } } /* Make a first attempt at drawing: */ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); /* Otherwise, we really are out of memory. Pass the drawing * command to the software tnl module and which will in turn call * swrast to do the drawing. */ if (!retval) { _swsetup_Wakeup(ctx); _tnl_wakeup(ctx); _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); } }
void radeonFallback( struct gl_context *ctx, GLuint bit, GLboolean mode ) { r100ContextPtr rmesa = R100_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint oldfallback = rmesa->radeon.Fallback; if (mode) { rmesa->radeon.Fallback |= bit; if (oldfallback == 0) { radeon_firevertices(&rmesa->radeon); TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_RASTER, GL_TRUE ); _swsetup_Wakeup( ctx ); rmesa->radeon.swtcl.RenderIndex = ~0; if (RADEON_DEBUG & RADEON_FALLBACKS) { fprintf(stderr, "Radeon begin rasterization fallback: 0x%x %s\n", bit, getFallbackString(bit)); } } } else { rmesa->radeon.Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); tnl->Driver.Render.Start = radeonRenderStart; tnl->Driver.Render.PrimitiveNotify = radeonRenderPrimitive; tnl->Driver.Render.Finish = radeonRenderFinish; tnl->Driver.Render.BuildVertices = _tnl_build_vertices; tnl->Driver.Render.CopyPV = _tnl_copy_pv; tnl->Driver.Render.Interp = _tnl_interp; tnl->Driver.Render.ResetLineStipple = radeonResetLineStipple; TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_RASTER, GL_FALSE ); if (rmesa->radeon.TclFallback) { /* These are already done if rmesa->radeon.TclFallback goes to * zero above. But not if it doesn't (RADEON_NO_TCL for * example?) */ _tnl_invalidate_vertex_state( ctx, ~0 ); _tnl_invalidate_vertices( ctx, ~0 ); rmesa->radeon.tnl_index_bitset = 0; radeonChooseVertexState( ctx ); radeonChooseRenderState( ctx ); } if (RADEON_DEBUG & RADEON_FALLBACKS) { fprintf(stderr, "Radeon end rasterization fallback: 0x%x %s\n", bit, getFallbackString(bit)); } } } }
void brw_draw_prims( struct gl_context *ctx, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, GLboolean index_bounds_valid, GLuint min_index, GLuint max_index, struct gl_transform_feedback_object *tfb_vertcount ) { struct intel_context *intel = intel_context(ctx); const struct gl_client_array **arrays = ctx->Array._DrawArrays; if (!_mesa_check_conditional_render(ctx)) return; /* Handle primitive restart if needed */ if (brw_handle_primitive_restart(ctx, prim, nr_prims, ib)) { /* The draw was handled, so we can exit now */ return; } /* If we're going to have to upload any of the user's vertex arrays, then * get the minimum and maximum of their index buffer so we know what range * to upload. */ if (!vbo_all_varyings_in_vbos(arrays) && !index_bounds_valid) vbo_get_minmax_indices(ctx, prim, ib, &min_index, &max_index, nr_prims); /* Do GL_SELECT and GL_FEEDBACK rendering using swrast, even though it * won't support all the extensions we support. */ if (ctx->RenderMode != GL_RENDER) { perf_debug("%s render mode not supported in hardware\n", _mesa_lookup_enum_by_nr(ctx->RenderMode)); _swsetup_Wakeup(ctx); _tnl_wakeup(ctx); _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); return; } /* Try drawing with the hardware, but don't do anything else if we can't * manage it. swrast doesn't support our featureset, so we can't fall back * to it. */ brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); }
void brw_draw_prims( struct gl_context *ctx, const struct gl_client_array *arrays[], const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, GLboolean index_bounds_valid, GLuint min_index, GLuint max_index ) { GLboolean retval; if (!_mesa_check_conditional_render(ctx)) return; if (!vbo_all_varyings_in_vbos(arrays)) { if (!index_bounds_valid) vbo_get_minmax_index(ctx, prim, ib, &min_index, &max_index); /* Decide if we want to rebase. If so we end up recursing once * only into this function. */ if (min_index != 0 && !vbo_any_varyings_in_vbos(arrays)) { vbo_rebase_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index, brw_draw_prims ); return; } } /* Make a first attempt at drawing: */ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); /* Otherwise, we really are out of memory. Pass the drawing * command to the software tnl module and which will in turn call * swrast to do the drawing. */ if (!retval) { _swsetup_Wakeup(ctx); _tnl_wakeup(ctx); _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); } }
void intelFallback( intelContextPtr intel, GLuint bit, GLboolean mode ) { GLcontext *ctx = &intel->ctx; TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint oldfallback = intel->Fallback; if (mode) { intel->Fallback |= bit; if (oldfallback == 0) { intelFlush(ctx); if (INTEL_DEBUG & DEBUG_FALLBACKS) fprintf(stderr, "ENTER FALLBACK 0x%x: %s\n", bit, getFallbackString(bit)); _swsetup_Wakeup( ctx ); intel->RenderIndex = ~0; } } else { intel->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); if (INTEL_DEBUG & DEBUG_FALLBACKS) fprintf(stderr, "LEAVE FALLBACK 0x%x: %s\n", bit, getFallbackString(bit)); tnl->Driver.Render.Start = intelRenderStart; tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive; tnl->Driver.Render.Finish = intelRenderFinish; tnl->Driver.Render.BuildVertices = _tnl_build_vertices; tnl->Driver.Render.CopyPV = _tnl_copy_pv; tnl->Driver.Render.Interp = _tnl_interp; _tnl_invalidate_vertex_state( ctx, ~0 ); _tnl_invalidate_vertices( ctx, ~0 ); _tnl_install_attrs( ctx, intel->vertex_attrs, intel->vertex_attr_count, intel->ViewportMatrix.m, 0 ); intel->NewGLState |= _INTEL_NEW_RENDERSTATE; } } }
void ffbFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) { ffbContextPtr fmesa = FFB_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint oldfallback = fmesa->bad_fragment_attrs; if (mode) { fmesa->bad_fragment_attrs |= bit; if (oldfallback == 0) { /* FFB_FIREVERTICES(fmesa); */ _swsetup_Wakeup( ctx ); if (fmesa->debugFallbacks) fprintf(stderr, "FFB begin software fallback: 0x%x %s\n", bit, getFallbackString(bit)); } } else { fmesa->bad_fragment_attrs &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); tnl->Driver.Render.Start = ffbRenderStart; tnl->Driver.Render.PrimitiveNotify = ffbRenderPrimitive; tnl->Driver.Render.Finish = ffbRenderFinish; fmesa->new_gl_state = ~0; /* Just re-choose everything: */ ffbChooseVertexState(ctx); ffbChooseRenderState(ctx); ffbChooseTriangleState(ctx); ffbChooseLineState(ctx); ffbChoosePointState(ctx); if (fmesa->debugFallbacks) fprintf(stderr, "FFB end software fallback: 0x%x %s\n", bit, getFallbackString(bit)); } } }
void nouveauFallback(struct nouveau_context *nmesa, GLuint bit, GLboolean mode) { GLcontext *ctx = nmesa->glCtx; GLuint oldfallback = nmesa->Fallback; if (mode) { nmesa->Fallback |= bit; if (oldfallback == 0) { if (nmesa->screen->card->type<NV_10) { //nv04FinishPrimitive(nmesa); } else { //nv10FinishPrimitive(nmesa); } _swsetup_Wakeup(ctx); nmesa->render_index = ~0; } } else { nmesa->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); if (nmesa->screen->card->type<NV_10) { nv04TriInitFunctions(ctx); } else { nv10TriInitFunctions(ctx); } _tnl_invalidate_vertex_state( ctx, ~0 ); _tnl_invalidate_vertices( ctx, ~0 ); _tnl_install_attrs( ctx, nmesa->vertex_attrs, nmesa->vertex_attr_count, nmesa->viewport.m, 0 ); } } }
static void evergreenDrawPrims(GLcontext *ctx, const struct gl_client_array *arrays[], const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, GLboolean index_bounds_valid, GLuint min_index, GLuint max_index) { GLboolean retval = GL_FALSE; context_t *context = EVERGREEN_CONTEXT(ctx); radeonContextPtr radeon = &context->radeon; radeon_prepare_render(radeon); /* This check should get folded into just the places that * min/max index are really needed. */ if (!vbo_all_varyings_in_vbos(arrays)) { if (!index_bounds_valid) vbo_get_minmax_index(ctx, prim, ib, &min_index, &max_index); /* do we want to rebase, minimizes the * amount of data to upload? */ if (min_index) { vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, min_index, max_index, evergreenDrawPrims ); return; } } /* Make an attempt at drawing */ retval = evergreenTryDrawPrims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); /* If failed run tnl pipeline - it should take care of fallbacks */ if (!retval) { _swsetup_Wakeup(ctx); _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); } }
AMesaContext GLAPIENTRY AMesaCreateContext(AMesaVisual visual, AMesaContext share) { AMesaContext context; GLboolean direct = GL_FALSE; GLcontext *ctx; context = (AMesaContext) malloc(sizeof(struct amesa_context)); if (!context) return NULL; context->GLContext = _mesa_create_context(visual->GLVisual, share ? share->GLContext : NULL, (void*)context, direct); if (!context->GLContext) { free(context); return NULL; } context->Visual = visual; ctx = context->GLContext; _mesa_enable_sw_extensions(ctx); _mesa_enable_1_3_extensions(ctx); /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); _ac_CreateContext( ctx ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); _swsetup_Wakeup( ctx ); /*AMesaRegisterSwrastFunctions(ctx);*/ return context; }
void brw_draw_prims( GLcontext *ctx, const struct gl_client_array *arrays[], const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, GLuint min_index, GLuint max_index ) { GLboolean retval; /* Decide if we want to rebase. If so we end up recursing once * only into this function. */ if (brw_need_rebase( ctx, arrays, ib, min_index )) { vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, min_index, max_index, brw_draw_prims ); return; } /* Make a first attempt at drawing: */ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); /* Otherwise, we really are out of memory. Pass the drawing * command to the software tnl module and which will in turn call * swrast to do the drawing. */ if (!retval) { _swsetup_Wakeup(ctx); _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); } }
static GLboolean dri_create_context(gl_api api, const struct gl_config * visual, __DRIcontext * cPriv, void *sharedContextPrivate) { struct dri_context *ctx = NULL; struct dri_context *share = (struct dri_context *)sharedContextPrivate; struct gl_context *mesaCtx = NULL; struct gl_context *sharedCtx = NULL; struct dd_function_table functions; TRACE; ctx = CALLOC_STRUCT(dri_context); if (ctx == NULL) goto context_fail; cPriv->driverPrivate = ctx; ctx->cPriv = cPriv; /* build table of device driver functions */ _mesa_init_driver_functions(&functions); swrast_init_driver_functions(&functions); if (share) { sharedCtx = &share->Base; } mesaCtx = &ctx->Base; /* basic context setup */ if (!_mesa_initialize_context(mesaCtx, api, visual, sharedCtx, &functions, (void *) cPriv)) { goto context_fail; } /* do bounds checking to prevent segfaults and server crashes! */ mesaCtx->Const.CheckArrayBounds = GL_TRUE; /* create module contexts */ _swrast_CreateContext( mesaCtx ); _vbo_CreateContext( mesaCtx ); _tnl_CreateContext( mesaCtx ); _swsetup_CreateContext( mesaCtx ); _swsetup_Wakeup( mesaCtx ); /* use default TCL pipeline */ { TNLcontext *tnl = TNL_CONTEXT(mesaCtx); tnl->Driver.RunPipeline = _tnl_run_pipeline; } _mesa_meta_init(mesaCtx); _mesa_enable_sw_extensions(mesaCtx); switch (api) { case API_OPENGL: _mesa_enable_1_3_extensions(mesaCtx); _mesa_enable_1_4_extensions(mesaCtx); _mesa_enable_1_5_extensions(mesaCtx); _mesa_enable_2_0_extensions(mesaCtx); _mesa_enable_2_1_extensions(mesaCtx); driInitExtensions( mesaCtx, NULL, GL_FALSE ); break; case API_OPENGLES: _mesa_enable_1_3_extensions(mesaCtx); _mesa_enable_1_4_extensions(mesaCtx); _mesa_enable_1_5_extensions(mesaCtx); break; case API_OPENGLES2: InitExtensionsES2( mesaCtx); break; } return GL_TRUE; context_fail: FREE(ctx); return GL_FALSE; }
static EGLContext fbCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list) { GLcontext *ctx; _EGLConfig *conf; fbContext *c; _EGLDisplay *disp = _eglLookupDisplay(dpy); struct dd_function_table functions; GLvisual vis; int i; conf = _eglLookupConfig(drv, dpy, config); if (!conf) { _eglError(EGL_BAD_CONFIG, "eglCreateContext"); return EGL_NO_CONTEXT; } for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { switch (attrib_list[i]) { /* no attribs defined for now */ default: _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext"); return EGL_NO_CONTEXT; } } c = (fbContext *) calloc(1, sizeof(fbContext)); if (!c) return EGL_NO_CONTEXT; _eglInitContext(&c->Base); c->Base.Display = disp; c->Base.Config = conf; c->Base.DrawSurface = EGL_NO_SURFACE; c->Base.ReadSurface = EGL_NO_SURFACE; /* generate handle and insert into hash table */ _eglSaveContext(&c->Base); assert(c->Base.Handle); /* Init default driver functions then plug in our FBdev-specific functions */ _mesa_init_driver_functions(&functions); init_core_functions(&functions); _eglConfigToContextModesRec(conf, &vis); ctx = c->glCtx = _mesa_create_context(&vis, NULL, &functions, (void *)c); if (!c->glCtx) { _mesa_free(c); return GL_FALSE; } /* Create module contexts */ _swrast_CreateContext( ctx ); _vbo_CreateContext( ctx ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); _swsetup_Wakeup( ctx ); /* use default TCL pipeline */ { TNLcontext *tnl = TNL_CONTEXT(ctx); tnl->Driver.RunPipeline = _tnl_run_pipeline; } _mesa_enable_sw_extensions(ctx); return c->Base.Handle; }
/** * New in Mesa 11.2 * * Create context with attribute list. */ GLAPI OSMesaContext GLAPIENTRY OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist) { OSMesaContext osmesa; struct dd_function_table functions; GLint rind, gind, bind, aind; GLint redBits = 0, greenBits = 0, blueBits = 0, alphaBits =0; GLenum format = OSMESA_RGBA; GLint depthBits = 0, stencilBits = 0, accumBits = 0; int profile = OSMESA_COMPAT_PROFILE, version_major = 1, version_minor = 0; gl_api api_profile = API_OPENGL_COMPAT; int i; for (i = 0; attribList[i]; i += 2) { switch (attribList[i]) { case OSMESA_FORMAT: format = attribList[i+1]; switch (format) { case OSMESA_COLOR_INDEX: case OSMESA_RGBA: case OSMESA_BGRA: case OSMESA_ARGB: case OSMESA_RGB: case OSMESA_BGR: case OSMESA_RGB_565: /* legal */ break; default: return NULL; } break; case OSMESA_DEPTH_BITS: depthBits = attribList[i+1]; if (depthBits < 0) return NULL; break; case OSMESA_STENCIL_BITS: stencilBits = attribList[i+1]; if (stencilBits < 0) return NULL; break; case OSMESA_ACCUM_BITS: accumBits = attribList[i+1]; if (accumBits < 0) return NULL; break; case OSMESA_PROFILE: profile = attribList[i+1]; if (profile == OSMESA_COMPAT_PROFILE) api_profile = API_OPENGL_COMPAT; else if (profile == OSMESA_CORE_PROFILE) api_profile = API_OPENGL_CORE; else return NULL; break; case OSMESA_CONTEXT_MAJOR_VERSION: version_major = attribList[i+1]; if (version_major < 1) return NULL; break; case OSMESA_CONTEXT_MINOR_VERSION: version_minor = attribList[i+1]; if (version_minor < 0) return NULL; break; case 0: /* end of list */ break; default: fprintf(stderr, "Bad attribute in OSMesaCreateContextAttribs()\n"); return NULL; } } rind = gind = bind = aind = 0; if (format==OSMESA_RGBA) { redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; rind = 0; gind = 1; bind = 2; aind = 3; } else if (format==OSMESA_BGRA) { redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; bind = 0; gind = 1; rind = 2; aind = 3; } else if (format==OSMESA_ARGB) { redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; aind = 0; rind = 1; gind = 2; bind = 3; } else if (format==OSMESA_RGB) { redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = 0; rind = 0; gind = 1; bind = 2; } else if (format==OSMESA_BGR) { redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = 0; rind = 2; gind = 1; bind = 0; } #if CHAN_TYPE == GL_UNSIGNED_BYTE else if (format==OSMESA_RGB_565) { redBits = 5; greenBits = 6; blueBits = 5; alphaBits = 0; rind = 0; /* not used */ gind = 0; bind = 0; } #endif else { return NULL; } osmesa = (OSMesaContext) CALLOC_STRUCT(osmesa_context); if (osmesa) { osmesa->gl_visual = _mesa_create_visual( GL_FALSE, /* double buffer */ GL_FALSE, /* stereo */ redBits, greenBits, blueBits, alphaBits, depthBits, stencilBits, accumBits, accumBits, accumBits, alphaBits ? accumBits : 0, 1 /* num samples */ ); if (!osmesa->gl_visual) { free(osmesa); return NULL; } /* Initialize device driver function table */ _mesa_init_driver_functions(&functions); /* override with our functions */ functions.GetString = get_string; functions.UpdateState = osmesa_update_state_wrapper; if (!_mesa_initialize_context(&osmesa->mesa, api_profile, osmesa->gl_visual, sharelist ? &sharelist->mesa : (struct gl_context *) NULL, &functions)) { _mesa_destroy_visual( osmesa->gl_visual ); free(osmesa); return NULL; } _mesa_enable_sw_extensions(&(osmesa->mesa)); osmesa->gl_buffer = _mesa_create_framebuffer(osmesa->gl_visual); if (!osmesa->gl_buffer) { _mesa_destroy_visual( osmesa->gl_visual ); _mesa_free_context_data( &osmesa->mesa ); free(osmesa); return NULL; } /* Create depth/stencil/accum buffers. We'll create the color * buffer later in OSMesaMakeCurrent(). */ _swrast_add_soft_renderbuffers(osmesa->gl_buffer, GL_FALSE, /* color */ osmesa->gl_visual->haveDepthBuffer, osmesa->gl_visual->haveStencilBuffer, osmesa->gl_visual->haveAccumBuffer, GL_FALSE, /* alpha */ GL_FALSE /* aux */ ); osmesa->format = format; osmesa->userRowLength = 0; osmesa->yup = GL_TRUE; osmesa->rInd = rind; osmesa->gInd = gind; osmesa->bInd = bind; osmesa->aInd = aind; _mesa_meta_init(&osmesa->mesa); /* Initialize the software rasterizer and helper modules. */ { struct gl_context *ctx = &osmesa->mesa; SWcontext *swrast; TNLcontext *tnl; if (!_swrast_CreateContext( ctx ) || !_vbo_CreateContext( ctx ) || !_tnl_CreateContext( ctx ) || !_swsetup_CreateContext( ctx )) { _mesa_destroy_visual(osmesa->gl_visual); _mesa_free_context_data(ctx); free(osmesa); return NULL; } _swsetup_Wakeup( ctx ); /* use default TCL pipeline */ tnl = TNL_CONTEXT(ctx); tnl->Driver.RunPipeline = _tnl_run_pipeline; ctx->Driver.MapRenderbuffer = osmesa_MapRenderbuffer; ctx->Driver.UnmapRenderbuffer = osmesa_UnmapRenderbuffer; ctx->Driver.GenerateMipmap = _mesa_generate_mipmap; /* Extend the software rasterizer with our optimized line and triangle * drawing functions. */ swrast = SWRAST_CONTEXT( ctx ); swrast->choose_line = osmesa_choose_line; swrast->choose_triangle = osmesa_choose_triangle; _mesa_compute_version(ctx); if (ctx->Version < version_major * 10 + version_minor) { _mesa_destroy_visual(osmesa->gl_visual); _mesa_free_context_data(ctx); free(osmesa); return NULL; } /* Exec table initialization requires the version to be computed */ _mesa_initialize_dispatch_tables(ctx); _mesa_initialize_vbo_vtxfmt(ctx); } } return osmesa; }
/** * New in Mesa 3.5 * * Create context and specify size of ancillary buffers. */ GLAPI OSMesaContext GLAPIENTRY OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, OSMesaContext sharelist ) { OSMesaContext osmesa; struct dd_function_table functions; GLint rind, gind, bind, aind; GLint redBits = 0, greenBits = 0, blueBits = 0, alphaBits =0; rind = gind = bind = aind = 0; if (format==OSMESA_RGBA) { redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; rind = 0; gind = 1; bind = 2; aind = 3; } else if (format==OSMESA_BGRA) { redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; bind = 0; gind = 1; rind = 2; aind = 3; } else if (format==OSMESA_ARGB) { redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; aind = 0; rind = 1; gind = 2; bind = 3; } else if (format==OSMESA_RGB) { redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = 0; rind = 0; gind = 1; bind = 2; } else if (format==OSMESA_BGR) { redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = 0; rind = 2; gind = 1; bind = 0; } #if CHAN_TYPE == GL_UNSIGNED_BYTE else if (format==OSMESA_RGB_565) { redBits = 5; greenBits = 6; blueBits = 5; alphaBits = 0; rind = 0; /* not used */ gind = 0; bind = 0; } #endif else { return NULL; } osmesa = (OSMesaContext) CALLOC_STRUCT(osmesa_context); if (osmesa) { osmesa->gl_visual = _mesa_create_visual( GL_FALSE, /* double buffer */ GL_FALSE, /* stereo */ redBits, greenBits, blueBits, alphaBits, depthBits, stencilBits, accumBits, accumBits, accumBits, alphaBits ? accumBits : 0, 1 /* num samples */ ); if (!osmesa->gl_visual) { free(osmesa); return NULL; } /* Initialize device driver function table */ _mesa_init_driver_functions(&functions); /* override with our functions */ functions.GetString = get_string; functions.UpdateState = osmesa_update_state; functions.GetBufferSize = NULL; if (!_mesa_initialize_context(&osmesa->mesa, API_OPENGL_COMPAT, osmesa->gl_visual, sharelist ? &sharelist->mesa : (struct gl_context *) NULL, &functions)) { _mesa_destroy_visual( osmesa->gl_visual ); free(osmesa); return NULL; } _mesa_enable_sw_extensions(&(osmesa->mesa)); _mesa_enable_1_3_extensions(&(osmesa->mesa)); _mesa_enable_1_4_extensions(&(osmesa->mesa)); _mesa_enable_1_5_extensions(&(osmesa->mesa)); _mesa_enable_2_0_extensions(&(osmesa->mesa)); _mesa_enable_2_1_extensions(&(osmesa->mesa)); osmesa->gl_buffer = _mesa_create_framebuffer(osmesa->gl_visual); if (!osmesa->gl_buffer) { _mesa_destroy_visual( osmesa->gl_visual ); _mesa_free_context_data( &osmesa->mesa ); free(osmesa); return NULL; } /* Create depth/stencil/accum buffers. We'll create the color * buffer later in OSMesaMakeCurrent(). */ _swrast_add_soft_renderbuffers(osmesa->gl_buffer, GL_FALSE, /* color */ osmesa->gl_visual->haveDepthBuffer, osmesa->gl_visual->haveStencilBuffer, osmesa->gl_visual->haveAccumBuffer, GL_FALSE, /* alpha */ GL_FALSE /* aux */ ); osmesa->format = format; osmesa->userRowLength = 0; osmesa->yup = GL_TRUE; osmesa->rInd = rind; osmesa->gInd = gind; osmesa->bInd = bind; osmesa->aInd = aind; _mesa_meta_init(&osmesa->mesa); /* Initialize the software rasterizer and helper modules. */ { struct gl_context *ctx = &osmesa->mesa; SWcontext *swrast; TNLcontext *tnl; if (!_swrast_CreateContext( ctx ) || !_vbo_CreateContext( ctx ) || !_tnl_CreateContext( ctx ) || !_swsetup_CreateContext( ctx )) { _mesa_destroy_visual(osmesa->gl_visual); _mesa_free_context_data(ctx); free(osmesa); return NULL; } _swsetup_Wakeup( ctx ); /* use default TCL pipeline */ tnl = TNL_CONTEXT(ctx); tnl->Driver.RunPipeline = _tnl_run_pipeline; ctx->Driver.MapRenderbuffer = osmesa_MapRenderbuffer; ctx->Driver.UnmapRenderbuffer = osmesa_UnmapRenderbuffer; /* Extend the software rasterizer with our optimized line and triangle * drawing functions. */ swrast = SWRAST_CONTEXT( ctx ); swrast->choose_line = osmesa_choose_line; swrast->choose_triangle = osmesa_choose_triangle; } } return osmesa; }
/* * New in Mesa 3.5 * * Create context and specify size of ancillary buffers. */ GLAPI OSMesaContext GLAPIENTRY OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, OSMesaContext sharelist ) { OSMesaContext osmesa; struct dd_function_table functions; GLint rind, gind, bind, aind; GLint indexBits = 0, redBits = 0, greenBits = 0, blueBits = 0, alphaBits =0; GLboolean rgbmode; rind = gind = bind = aind = 0; if (format==OSMESA_COLOR_INDEX) { indexBits = 8; rgbmode = GL_FALSE; } else if (format==OSMESA_RGBA) { indexBits = 0; redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; rind = 0; gind = 1; bind = 2; aind = 3; rgbmode = GL_TRUE; } else if (format==OSMESA_BGRA) { indexBits = 0; redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; bind = 0; gind = 1; rind = 2; aind = 3; rgbmode = GL_TRUE; } else if (format==OSMESA_ARGB) { indexBits = 0; redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = CHAN_BITS; aind = 0; rind = 1; gind = 2; bind = 3; rgbmode = GL_TRUE; } else if (format==OSMESA_RGB) { indexBits = 0; redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = 0; rind = 0; gind = 1; bind = 2; rgbmode = GL_TRUE; } else if (format==OSMESA_BGR) { indexBits = 0; redBits = CHAN_BITS; greenBits = CHAN_BITS; blueBits = CHAN_BITS; alphaBits = 0; rind = 2; gind = 1; bind = 0; rgbmode = GL_TRUE; } #if CHAN_TYPE == GL_UNSIGNED_BYTE else if (format==OSMESA_RGB_565) { indexBits = 0; redBits = 5; greenBits = 6; blueBits = 5; alphaBits = 0; rind = 0; /* not used */ gind = 0; bind = 0; rgbmode = GL_TRUE; } #endif else { return NULL; } osmesa = (OSMesaContext) CALLOC_STRUCT(osmesa_context); if (osmesa) { osmesa->gl_visual = _mesa_create_visual( rgbmode, GL_FALSE, /* double buffer */ GL_FALSE, /* stereo */ redBits, greenBits, blueBits, alphaBits, indexBits, depthBits, stencilBits, accumBits, accumBits, accumBits, alphaBits ? accumBits : 0, 1 /* num samples */ ); if (!osmesa->gl_visual) { FREE(osmesa); return NULL; } /* Initialize device driver function table */ _mesa_init_driver_functions(&functions); /* override with our functions */ functions.GetString = get_string; functions.UpdateState = osmesa_update_state; functions.GetBufferSize = get_buffer_size; if (!_mesa_initialize_context(&osmesa->mesa, osmesa->gl_visual, sharelist ? &sharelist->mesa : (GLcontext *) NULL, &functions, (void *) osmesa)) { _mesa_destroy_visual( osmesa->gl_visual ); FREE(osmesa); return NULL; } _mesa_enable_sw_extensions(&(osmesa->mesa)); _mesa_enable_1_3_extensions(&(osmesa->mesa)); _mesa_enable_1_4_extensions(&(osmesa->mesa)); _mesa_enable_1_5_extensions(&(osmesa->mesa)); osmesa->gl_buffer = _mesa_create_framebuffer(osmesa->gl_visual); if (!osmesa->gl_buffer) { _mesa_destroy_visual( osmesa->gl_visual ); _mesa_free_context_data( &osmesa->mesa ); FREE(osmesa); return NULL; } /* create front color buffer in user-provided memory (no back buffer) */ _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, new_osmesa_renderbuffer(format)); _mesa_add_soft_renderbuffers(osmesa->gl_buffer, GL_FALSE, /* color */ osmesa->gl_visual->haveDepthBuffer, osmesa->gl_visual->haveStencilBuffer, osmesa->gl_visual->haveAccumBuffer, GL_FALSE, /* alpha */ GL_FALSE /* aux */ ); osmesa->format = format; osmesa->buffer = NULL; osmesa->width = 0; osmesa->height = 0; osmesa->userRowLength = 0; osmesa->rowlength = 0; osmesa->yup = GL_TRUE; osmesa->rInd = rind; osmesa->gInd = gind; osmesa->bInd = bind; osmesa->aInd = aind; /* Initialize the software rasterizer and helper modules. */ { GLcontext *ctx = &osmesa->mesa; SWcontext *swrast; TNLcontext *tnl; if (!_swrast_CreateContext( ctx ) || !_ac_CreateContext( ctx ) || !_tnl_CreateContext( ctx ) || !_swsetup_CreateContext( ctx )) { _mesa_destroy_visual(osmesa->gl_visual); _mesa_free_context_data(ctx); _mesa_free(osmesa); return NULL; } _swsetup_Wakeup( ctx ); /* use default TCL pipeline */ tnl = TNL_CONTEXT(ctx); tnl->Driver.RunPipeline = _tnl_run_pipeline; /* Extend the software rasterizer with our optimized line and triangle * drawing functions. */ swrast = SWRAST_CONTEXT( ctx ); swrast->choose_line = osmesa_choose_line; swrast->choose_triangle = osmesa_choose_triangle; } } return osmesa; }
void gldSetupDriverPointers_DX7( struct gl_context *ctx) { GLD_context *gldCtx = GLD_GET_CONTEXT(ctx); GLD_driver_dx7 *gld = GLD_GET_DX7_DRIVER(gldCtx); TNLcontext *tnl = TNL_CONTEXT(ctx); // Mandatory functions ctx->Driver.GetString = _gldGetStringGeneric; ctx->Driver.UpdateState = gld_update_state_DX7; ctx->Driver.Clear = gld_Clear_DX7; ctx->Driver.DrawBuffer = gld_set_draw_buffer_DX7; ctx->Driver.GetBufferSize = gld_buffer_size_DX7; ctx->Driver.Finish = gld_Finish_DX7; ctx->Driver.Flush = gld_Flush_DX7; ctx->Driver.Error = gld_Error_DX7; // Hardware accumulation buffer ctx->Driver.Accum = NULL; // TODO: gld_Accum; // Bitmap functions ctx->Driver.CopyPixels = gld_CopyPixels_DX7; ctx->Driver.DrawPixels = gld_DrawPixels_DX7; ctx->Driver.ReadPixels = gld_ReadPixels_DX7; ctx->Driver.Bitmap = gld_Bitmap_DX7; // Buffer resize ctx->Driver.ResizeBuffers = gldResizeBuffers_DX7; // Texture image functions ctx->Driver.ChooseTextureFormat = gld_ChooseTextureFormat_DX7; ctx->Driver.TexImage1D = gld_TexImage1D_DX7; ctx->Driver.TexImage2D = gld_TexImage2D_DX7; ctx->Driver.TexImage3D = _mesa_store_teximage3d; ctx->Driver.TexSubImage1D = gld_TexSubImage1D_DX7; ctx->Driver.TexSubImage2D = gld_TexSubImage2D_DX7; ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d; ctx->Driver.CopyTexImage1D = gldCopyTexImage1D_DX7; //NULL; ctx->Driver.CopyTexImage2D = gldCopyTexImage2D_DX7; //NULL; ctx->Driver.CopyTexSubImage1D = gldCopyTexSubImage1D_DX7; //NULL; ctx->Driver.CopyTexSubImage2D = gldCopyTexSubImage2D_DX7; //NULL; ctx->Driver.CopyTexSubImage3D = gldCopyTexSubImage3D_DX7; ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage; // Texture object functions ctx->Driver.BindTexture = NULL; ctx->Driver.NewTextureObject = NULL; // Not yet implemented by Mesa!; ctx->Driver.DeleteTexture = gld_DeleteTexture_DX7; ctx->Driver.PrioritizeTexture = NULL; // Imaging functionality ctx->Driver.CopyColorTable = NULL; ctx->Driver.CopyColorSubTable = NULL; ctx->Driver.CopyConvolutionFilter1D = NULL; ctx->Driver.CopyConvolutionFilter2D = NULL; // State changing functions ctx->Driver.AlphaFunc = NULL; //gld_AlphaFunc; ctx->Driver.BlendFuncSeparate = NULL; //gld_BlendFunc; ctx->Driver.ClearColor = NULL; //gld_ClearColor; ctx->Driver.ClearDepth = NULL; //gld_ClearDepth; ctx->Driver.ClearStencil = NULL; //gld_ClearStencil; ctx->Driver.ColorMask = NULL; //gld_ColorMask; ctx->Driver.CullFace = NULL; //gld_CullFace; ctx->Driver.ClipPlane = NULL; //gld_ClipPlane; ctx->Driver.FrontFace = NULL; //gld_FrontFace; ctx->Driver.DepthFunc = NULL; //gld_DepthFunc; ctx->Driver.DepthMask = NULL; //gld_DepthMask; ctx->Driver.DepthRange = NULL; ctx->Driver.Enable = NULL; //gld_Enable; ctx->Driver.Fogfv = NULL; //gld_Fogfv; ctx->Driver.Hint = NULL; //gld_Hint; ctx->Driver.Lightfv = NULL; //gld_Lightfv; ctx->Driver.LightModelfv = NULL; //gld_LightModelfv; ctx->Driver.LineStipple = NULL; //gld_LineStipple; ctx->Driver.LineWidth = NULL; //gld_LineWidth; ctx->Driver.LogicOpcode = NULL; //gld_LogicOpcode; ctx->Driver.PointParameterfv = NULL; //gld_PointParameterfv; ctx->Driver.PointSize = NULL; //gld_PointSize; ctx->Driver.PolygonMode = NULL; //gld_PolygonMode; ctx->Driver.PolygonOffset = NULL; //gld_PolygonOffset; ctx->Driver.PolygonStipple = NULL; //gld_PolygonStipple; ctx->Driver.RenderMode = NULL; //gld_RenderMode; ctx->Driver.Scissor = NULL; //gld_Scissor; ctx->Driver.ShadeModel = NULL; //gld_ShadeModel; ctx->Driver.StencilFunc = NULL; //gld_StencilFunc; ctx->Driver.StencilMask = NULL; //gld_StencilMask; ctx->Driver.StencilOp = NULL; //gld_StencilOp; ctx->Driver.TexGen = NULL; //gld_TexGen; ctx->Driver.TexEnv = NULL; ctx->Driver.TexParameter = NULL; ctx->Driver.TextureMatrix = NULL; //gld_TextureMatrix; ctx->Driver.Viewport = gld_Viewport_DX7; _swsetup_Wakeup(ctx); tnl->Driver.RunPipeline = _tnl_run_pipeline; tnl->Driver.Render.ResetLineStipple = gld_ResetLineStipple_DX7; tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine; // Hook into glFrustum() and glOrtho() // ctx->Exec->Frustum = gldFrustumHook_DX7; // ctx->Exec->Ortho = gldOrthoHook_DX7; }
static GLboolean dri_create_context(gl_api api, const struct gl_config * visual, __DRIcontext * cPriv, unsigned major_version, unsigned minor_version, uint32_t flags, unsigned *error, void *sharedContextPrivate) { struct dri_context *ctx = NULL; struct dri_context *share = (struct dri_context *)sharedContextPrivate; struct gl_context *mesaCtx = NULL; struct gl_context *sharedCtx = NULL; struct dd_function_table functions; TRACE; /* Flag filtering is handled in dri2CreateContextAttribs. */ (void) flags; switch (api) { case API_OPENGL_COMPAT: if (major_version > 2 || (major_version == 2 && minor_version > 1)) { *error = __DRI_CTX_ERROR_BAD_VERSION; return GL_FALSE; } break; case API_OPENGLES: case API_OPENGLES2: break; case API_OPENGL_CORE: *error = __DRI_CTX_ERROR_BAD_API; return GL_FALSE; } ctx = CALLOC_STRUCT(dri_context); if (ctx == NULL) { *error = __DRI_CTX_ERROR_NO_MEMORY; goto context_fail; } cPriv->driverPrivate = ctx; ctx->cPriv = cPriv; /* build table of device driver functions */ _mesa_init_driver_functions(&functions); swrast_init_driver_functions(&functions); if (share) { sharedCtx = &share->Base; } mesaCtx = &ctx->Base; /* basic context setup */ if (!_mesa_initialize_context(mesaCtx, api, visual, sharedCtx, &functions)) { *error = __DRI_CTX_ERROR_NO_MEMORY; goto context_fail; } /* do bounds checking to prevent segfaults and server crashes! */ mesaCtx->Const.CheckArrayBounds = GL_TRUE; /* create module contexts */ _swrast_CreateContext( mesaCtx ); _vbo_CreateContext( mesaCtx ); _tnl_CreateContext( mesaCtx ); _swsetup_CreateContext( mesaCtx ); _swsetup_Wakeup( mesaCtx ); /* use default TCL pipeline */ { TNLcontext *tnl = TNL_CONTEXT(mesaCtx); tnl->Driver.RunPipeline = _tnl_run_pipeline; } _mesa_meta_init(mesaCtx); _mesa_enable_sw_extensions(mesaCtx); _mesa_compute_version(mesaCtx); _mesa_initialize_dispatch_tables(mesaCtx); _mesa_initialize_vbo_vtxfmt(mesaCtx); *error = __DRI_CTX_ERROR_SUCCESS; return GL_TRUE; context_fail: free(ctx); return GL_FALSE; }
static GLboolean dri_create_context(gl_api api, const struct gl_config * visual, __DRIcontext * cPriv, unsigned major_version, unsigned minor_version, uint32_t flags, bool notify_reset, unsigned *error, void *sharedContextPrivate) { struct dri_context *ctx = NULL; struct dri_context *share = (struct dri_context *)sharedContextPrivate; struct gl_context *mesaCtx = NULL; struct gl_context *sharedCtx = NULL; struct dd_function_table functions; TRACE; /* Flag filtering is handled in dri2CreateContextAttribs. */ (void) flags; ctx = CALLOC_STRUCT(dri_context); if (ctx == NULL) { *error = __DRI_CTX_ERROR_NO_MEMORY; goto context_fail; } cPriv->driverPrivate = ctx; ctx->cPriv = cPriv; /* build table of device driver functions */ _mesa_init_driver_functions(&functions); swrast_init_driver_functions(&functions); if (share) { sharedCtx = &share->Base; } mesaCtx = &ctx->Base; /* basic context setup */ if (!_mesa_initialize_context(mesaCtx, api, visual, sharedCtx, &functions)) { *error = __DRI_CTX_ERROR_NO_MEMORY; goto context_fail; } driContextSetFlags(mesaCtx, flags); /* create module contexts */ _swrast_CreateContext( mesaCtx ); _vbo_CreateContext( mesaCtx ); _tnl_CreateContext( mesaCtx ); _swsetup_CreateContext( mesaCtx ); _swsetup_Wakeup( mesaCtx ); /* use default TCL pipeline */ { TNLcontext *tnl = TNL_CONTEXT(mesaCtx); tnl->Driver.RunPipeline = _tnl_run_pipeline; } _mesa_meta_init(mesaCtx); _mesa_enable_sw_extensions(mesaCtx); _mesa_compute_version(mesaCtx); _mesa_initialize_dispatch_tables(mesaCtx); _mesa_initialize_vbo_vtxfmt(mesaCtx); *error = __DRI_CTX_ERROR_SUCCESS; return GL_TRUE; context_fail: free(ctx); return GL_FALSE; }