intel_screen.h File Reference

Include dependency graph for intel_screen.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  intel_screen

Functions

static struct intel_screenintel_screen (__DRIscreenPrivate *sPriv)
 cast wrapper
void intelUpdateScreenRotation (__DRIscreenPrivate *sPriv, drmI830Sarea *sarea)
 Use the information in the sarea to update the screen parameters related to screen rotation.
void intelDestroyContext (__DRIcontextPrivate *driContextPriv)
boolean intelUnbindContext (__DRIcontextPrivate *driContextPriv)
boolean intelMakeCurrent (__DRIcontextPrivate *driContextPriv, __DRIdrawablePrivate *driDrawPriv, __DRIdrawablePrivate *driReadPriv)
boolean intelCreatePools (__DRIscreenPrivate *sPriv)
boolean intelCreateContext (const __GLcontextModes *visual, __DRIcontextPrivate *driContextPriv, void *sharedContextPrivate)


Function Documentation

static struct intel_screen* intel_screen ( __DRIscreenPrivate *  sPriv  )  [static, read]

cast wrapper

Definition at line 93 of file intel_screen.h.

00094 {
00095    return (struct intel_screen *) sPriv->private;
00096 }

boolean intelCreateContext ( const __GLcontextModes *  visual,
__DRIcontextPrivate *  driContextPriv,
void *  sharedContextPrivate 
)

Definition at line 159 of file intel_context.c.

References intel_be_context::base, intel_be_device::base, intel_screen::base, intel_context::base, CALLOC_STRUCT, card_extensions, st_context::ctx, intel_screen::deviceID, intel_context::driFd, intel_context::driHwLock, intel_context::driScreen, intel_context::first_swap_fence, intel_be_context::hardware_lock, intel_be_context::hardware_locked, intel_be_context::hardware_unlock, intel_screen::havePools, intel_context::hHWContext, i915_create_context(), intel_be_init_context(), intel_create_softpipe(), intel_lock_hardware(), intel_locked_hardware(), intel_screen(), intel_unlock_hardware(), intelCreatePools(), intel_context::intelScreen, intel_context::irqsEmitted, intel_context::iw, intel_context::last_swap_fence, intel_screen::optionCache, intel_context::optionCache, PCI_CHIP_G33_G, PCI_CHIP_I915_G, PCI_CHIP_I915_GM, PCI_CHIP_I945_G, PCI_CHIP_I945_GM, PCI_CHIP_I945_GME, PCI_CHIP_Q33_G, PCI_CHIP_Q35_G, pipe_context::priv, intel_context::sarea, intel_screen::sarea, intel_be_device::screen, intel_context::st, and st_create_context().

00162 {
00163    struct intel_context *intel = CALLOC_STRUCT(intel_context);
00164    __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
00165    struct intel_screen *intelScreen = intel_screen(sPriv);
00166    drmI830Sarea *saPriv = intelScreen->sarea;
00167    int fthrottle_mode;
00168    GLboolean havePools;
00169    struct pipe_context *pipe;
00170    struct st_context *st_share = NULL;
00171 
00172    if (sharedContextPrivate) {
00173       st_share = ((struct intel_context *) sharedContextPrivate)->st;
00174    }
00175 
00176    driContextPriv->driverPrivate = intel;
00177    intel->intelScreen = intelScreen;
00178    intel->driScreen = sPriv;
00179    intel->sarea = saPriv;
00180 
00181    driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
00182                        intel->driScreen->myNum, "i915");
00183 
00184 
00185    /*
00186     * memory pools
00187     */
00188    DRM_LIGHT_LOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
00189    // ZZZ JB should be per screen and not be done per context
00190    havePools = intelCreatePools(sPriv);
00191    DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
00192    if (!havePools)
00193       return GL_FALSE;
00194 
00195 
00196    /* Dri stuff */
00197    intel->hHWContext = driContextPriv->hHWContext;
00198    intel->driFd = sPriv->fd;
00199    intel->driHwLock = (drmLock *) & sPriv->pSAREA->lock;
00200 
00201    fthrottle_mode = driQueryOptioni(&intel->optionCache, "fthrottle_mode");
00202    intel->iw.irq_seq = -1;
00203    intel->irqsEmitted = 0;
00204 
00205    intel->last_swap_fence = NULL;
00206    intel->first_swap_fence = NULL;
00207 
00208 #ifdef DEBUG
00209    __intel_debug = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
00210 #endif
00211    intel->base.hardware_lock = intel_lock_hardware;
00212    intel->base.hardware_unlock = intel_unlock_hardware;
00213    intel->base.hardware_locked = intel_locked_hardware;
00214 
00215    intel_be_init_context(&intel->base, &intelScreen->base);
00216 
00217    /*
00218     * Pipe-related setup
00219     */
00220    if (getenv("INTEL_SP")) {
00221       /* use softpipe driver instead of hw */
00222       pipe = intel_create_softpipe( intel, &intelScreen->base.base );
00223    }
00224    else {
00225       switch (intel->intelScreen->deviceID) {
00226       case PCI_CHIP_I945_G:
00227       case PCI_CHIP_I945_GM:
00228       case PCI_CHIP_I945_GME:
00229       case PCI_CHIP_G33_G:
00230       case PCI_CHIP_Q33_G:
00231       case PCI_CHIP_Q35_G:
00232       case PCI_CHIP_I915_G:
00233       case PCI_CHIP_I915_GM:
00234          pipe = i915_create_context(intelScreen->base.screen,
00235                                     &intelScreen->base.base,
00236                                     &intel->base.base);
00237          break;
00238       default:
00239          fprintf(stderr, "Unknown PCIID %x in %s, using software driver\n",
00240                  intel->intelScreen->deviceID, __FUNCTION__);
00241 
00242          pipe = intel_create_softpipe( intel, &intelScreen->base.base );
00243          break;
00244       }
00245    }
00246 
00247    pipe->priv = intel;
00248 
00249    intel->st = st_create_context(pipe, visual, st_share);
00250 
00251    driInitExtensions( intel->st->ctx, card_extensions, GL_TRUE );
00252 
00253    return GL_TRUE;
00254 }

boolean intelCreatePools ( __DRIscreenPrivate *  sPriv  ) 

Definition at line 225 of file intel_screen.c.

References intel_screen::havePools, intel_screen(), intelUpdateScreenRotation(), and intel_screen::sarea.

00226 {
00227    //unsigned batchPoolSize = 1024*1024;
00228    struct intel_screen *intelScreen = intel_screen(sPriv);
00229 
00230    if (intelScreen->havePools)
00231       return GL_TRUE;
00232 
00233    intelScreen->havePools = GL_TRUE;
00234 
00235    intelUpdateScreenRotation(sPriv, intelScreen->sarea);
00236 
00237    return GL_TRUE;
00238 }

void intelDestroyContext ( __DRIcontextPrivate *  driContextPriv  ) 

Definition at line 258 of file intel_context.c.

References assert, intel_context::base, driFenceFinish(), driFenceUnReference(), intel_screen::dummyContext, intel_context::first_swap_fence, intel_be_destroy_context(), intel_context(), intel_context::intelScreen, intel_context::last_swap_fence, intel_context::st, st_destroy_context(), and st_finish().

00259 {
00260    struct intel_context *intel = intel_context(driContextPriv);
00261 
00262    assert(intel);               /* should never be null */
00263    if (intel) {
00264       st_finish(intel->st);
00265 
00266       if (intel->last_swap_fence) {
00267          driFenceFinish(intel->last_swap_fence, DRM_FENCE_TYPE_EXE, GL_TRUE);
00268          driFenceUnReference(&intel->last_swap_fence);
00269          intel->last_swap_fence = NULL;
00270       }
00271       if (intel->first_swap_fence) {
00272          driFenceFinish(intel->first_swap_fence, DRM_FENCE_TYPE_EXE, GL_TRUE);
00273          driFenceUnReference(&intel->first_swap_fence);
00274          intel->first_swap_fence = NULL;
00275       }
00276 
00277       if (intel->intelScreen->dummyContext == intel)
00278          intel->intelScreen->dummyContext = NULL;
00279 
00280       st_destroy_context(intel->st);
00281       intel_be_destroy_context(&intel->base);
00282       free(intel);
00283    }
00284 }

boolean intelMakeCurrent ( __DRIcontextPrivate *  driContextPriv,
__DRIdrawablePrivate *  driDrawPriv,
__DRIdrawablePrivate *  driReadPriv 
)

Definition at line 298 of file intel_context.c.

References assert, intel_context::driDrawable, intel_screen::dummyContext, intel_context(), intel_framebuffer(), intel_context::intelScreen, intelUpdateWindowSize(), intel_context::lastStamp, intel_context::st, st_make_current(), and intel_framebuffer::stfb.

00301 {
00302    if (driContextPriv) {
00303       struct intel_context *intel = intel_context(driContextPriv);
00304       struct intel_framebuffer *draw_fb = intel_framebuffer(driDrawPriv);
00305       struct intel_framebuffer *read_fb = intel_framebuffer(driReadPriv);
00306 
00307       assert(draw_fb->stfb);
00308       assert(read_fb->stfb);
00309 
00310       /* This is for situations in which we need a rendering context but
00311        * there may not be any currently bound.
00312        */
00313       intel->intelScreen->dummyContext = intel;
00314 
00315       st_make_current(intel->st, draw_fb->stfb, read_fb->stfb);
00316 
00317       if ((intel->driDrawable != driDrawPriv) ||
00318           (intel->lastStamp != driDrawPriv->lastStamp)) {
00319          intel->driDrawable = driDrawPriv;
00320          intelUpdateWindowSize(driDrawPriv);
00321          intel->lastStamp = driDrawPriv->lastStamp;
00322       }
00323 
00324       /* The size of the draw buffer will have been updated above.
00325        * If the readbuffer is a different window, check/update its size now.
00326        */
00327       if (driReadPriv != driDrawPriv) {
00328          intelUpdateWindowSize(driReadPriv);
00329       }
00330 
00331    }
00332    else {
00333       st_make_current(NULL, NULL, NULL);
00334    }
00335 
00336    return GL_TRUE;
00337 }

boolean intelUnbindContext ( __DRIcontextPrivate *  driContextPriv  ) 

Definition at line 288 of file intel_context.c.

References intel_context(), PIPE_FLUSH_RENDER_CACHE, intel_context::st, and st_flush().

00289 {
00290    struct intel_context *intel = intel_context(driContextPriv);
00291    st_flush(intel->st, PIPE_FLUSH_RENDER_CACHE, NULL);
00292    /* XXX make_current(NULL)? */
00293    return GL_TRUE;
00294 }

void intelUpdateScreenRotation ( __DRIscreenPrivate *  sPriv,
drmI830Sarea sarea 
)

Use the information in the sarea to update the screen parameters related to screen rotation.

Needs to be called locked.

Definition at line 164 of file intel_screen.c.

References assert, intel_be_device::base, intel_screen::base, intel_screen::buffer, intel_screen::cpp, driBOUnReference(), driDeleteBuffers(), driGenBuffers(), intel_screen::front, drmI830Sarea::front_bo_handle, drmI830Sarea::front_handle, drmI830Sarea::front_offset, drmI830Sarea::front_size, intel_screen::handle, drmI830Sarea::height, intel_screen::height, intel_screen(), intelCreateSurface(), intel_screen::map, intel_screen::offset, pipe_surface_reference(), pipe_texture_reference(), drmI830Sarea::pitch, intel_screen::pitch, intel_screen::size, intel_be_device::staticPool, intel_screen::surface, intel_screen::texture, drmI830Sarea::width, and intel_screen::width.

00165 {
00166    struct intel_screen *intelScreen = intel_screen(sPriv);
00167 
00168    if (intelScreen->front.map) {
00169       drmUnmap(intelScreen->front.map, intelScreen->front.size);
00170       intelScreen->front.map = NULL;
00171    }
00172 
00173    if (intelScreen->front.buffer)
00174       driDeleteBuffers(1, &intelScreen->front.buffer);
00175 
00176    intelScreen->front.width = sarea->width;
00177    intelScreen->front.height = sarea->height;
00178    intelScreen->front.offset = sarea->front_offset;
00179    intelScreen->front.pitch = sarea->pitch * intelScreen->front.cpp;
00180    intelScreen->front.size = sarea->front_size;
00181    intelScreen->front.handle = sarea->front_handle;
00182 
00183    assert( sarea->front_size >=
00184            intelScreen->front.pitch * intelScreen->front.height );
00185 
00186 #if 0 /* JB not important */
00187    if (!sarea->front_handle)
00188       return;
00189 
00190    if (drmMap(sPriv->fd,
00191               sarea->front_handle,
00192               intelScreen->front.size,
00193               (drmAddress *) & intelScreen->front.map) != 0) {
00194       fprintf(stderr, "drmMap(frontbuffer) failed!\n");
00195       return;
00196    }
00197 #endif
00198 
00199 #if 0 /* JB */
00200    if (intelScreen->staticPool) {
00201       driGenBuffers(intelScreen->staticPool, "static region", 1,
00202                     &intelScreen->front.buffer, 64,
00203                     DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_NO_MOVE |
00204                     DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0);
00205 
00206       driBOSetStatic(intelScreen->front.buffer,
00207                      intelScreen->front.offset,
00208                      intelScreen->front.pitch * intelScreen->front.height,
00209                      intelScreen->front.map, 0);
00210    }
00211 #else
00212    if (intelScreen->base.staticPool) {
00213       if (intelScreen->front.buffer) {
00214          driBOUnReference(intelScreen->front.buffer);
00215          pipe_surface_reference(&intelScreen->front.surface, NULL);
00216          pipe_texture_reference(&intelScreen->front.texture, NULL);
00217       }
00218       intelCreateSurface(intelScreen, &intelScreen->base.base, sarea->front_bo_handle);
00219    }
00220 #endif
00221 }


Generated on Tue Sep 29 06:25:46 2009 for Gallium3D by  doxygen 1.5.4