intel_be_context.c

Go to the documentation of this file.
00001 
00002 /*
00003  * Authors: Jakob Bornecrantz <jakob-at-tungstengraphics.com>
00004  */
00005 
00006 #include "ws_dri_fencemgr.h"
00007 #include "intel_be_device.h"
00008 #include "intel_be_context.h"
00009 #include "intel_be_batchbuffer.h"
00010 
00011 static INLINE struct intel_be_context *
00012 intel_be_context(struct i915_winsys *sws)
00013 {
00014         return (struct intel_be_context *)sws;
00015 }
00016 
00017 /* Simple batchbuffer interface:
00018  */
00019 
00020 static struct i915_batchbuffer*
00021 intel_i915_batch_get(struct i915_winsys *sws)
00022 {
00023         struct intel_be_context *intel = intel_be_context(sws);
00024         return &intel->batch->base;
00025 }
00026 
00027 static void intel_i915_batch_reloc(struct i915_winsys *sws,
00028                                    struct pipe_buffer *buf,
00029                                    unsigned access_flags,
00030                                    unsigned delta)
00031 {
00032         struct intel_be_context *intel = intel_be_context(sws);
00033 
00034         unsigned flags = DRM_BO_FLAG_MEM_TT;
00035         unsigned mask = DRM_BO_MASK_MEM;
00036 
00037         if (access_flags & I915_BUFFER_ACCESS_WRITE) {
00038                 flags |= DRM_BO_FLAG_WRITE;
00039                 mask |= DRM_BO_FLAG_WRITE;
00040         }
00041 
00042         if (access_flags & I915_BUFFER_ACCESS_READ) {
00043                 flags |= DRM_BO_FLAG_READ;
00044                 mask |= DRM_BO_FLAG_READ;
00045         }
00046 
00047         intel_be_offset_relocation(intel->batch,
00048                                 delta,
00049                                 dri_bo(buf),
00050                                 flags,
00051                                 mask);
00052 }
00053 
00054 static void intel_i915_batch_flush(struct i915_winsys *sws,
00055                                    struct pipe_fence_handle **fence)
00056 {
00057         struct intel_be_context *intel = intel_be_context(sws);
00058 
00059         union {
00060                 struct _DriFenceObject *dri;
00061                 struct pipe_fence_handle *pipe;
00062         } fu;
00063 
00064         if (fence)
00065                 assert(!*fence);
00066 
00067         fu.dri = intel_be_batchbuffer_flush(intel->batch);
00068 
00069         if (!fu.dri) {
00070                 assert(0);
00071                 *fence = NULL;
00072                 return;
00073         }
00074 
00075         if (fu.dri) {
00076                 if (fence)
00077                         *fence = fu.pipe;
00078                 else
00079                         driFenceUnReference(&fu.dri);
00080         }
00081 
00082 }
00083 
00084 boolean
00085 intel_be_init_context(struct intel_be_context *intel, struct intel_be_device *device)
00086 {
00087         assert(intel);
00088         assert(device);
00089 
00090         intel->device = device;
00091 
00092         /* TODO move framebuffer createion to the driver */
00093 
00094         intel->base.batch_get = intel_i915_batch_get;
00095         intel->base.batch_reloc = intel_i915_batch_reloc;
00096         intel->base.batch_flush = intel_i915_batch_flush;
00097 
00098         intel->batch = intel_be_batchbuffer_alloc(intel);
00099 
00100         return true;
00101 }
00102 
00103 void
00104 intel_be_destroy_context(struct intel_be_context *intel)
00105 {
00106         intel_be_batchbuffer_free(intel->batch);
00107 }

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