00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "utils.h"
00030
00031 #include "state_tracker/st_public.h"
00032 #include "i915simple/i915_screen.h"
00033
00034 #include "intel_context.h"
00035 #include "intel_device.h"
00036 #include "intel_batchbuffer.h"
00037 #include "intel_egl.h"
00038
00039
00040 extern const struct dri_extension card_extensions[];
00041
00042
00043 int
00044 intel_create_device(struct egl_drm_device *device)
00045 {
00046 struct intel_device *intel_device;
00047
00048
00049 intel_device = CALLOC_STRUCT(intel_device);
00050 if (!intel_device)
00051 return FALSE;
00052
00053 device->priv = (void *)intel_device;
00054 intel_device->device = device;
00055
00056 intel_device->deviceID = device->deviceID;
00057
00058 intel_be_init_device(&intel_device->base, device->drmFD, intel_device->deviceID);
00059
00060 intel_device->pipe = i915_create_screen(&intel_device->base.base, intel_device->deviceID);
00061
00062
00063 driInitExtensions(NULL, card_extensions, GL_FALSE);
00064
00065 return TRUE;
00066 }
00067
00068 int
00069 intel_destroy_device(struct egl_drm_device *device)
00070 {
00071 struct intel_device *intel_device = (struct intel_device *)device->priv;
00072
00073 intel_be_destroy_device(&intel_device->base);
00074
00075 free(intel_device);
00076 device->priv = NULL;
00077
00078 return TRUE;
00079 }
00080
00081 int
00082 intel_create_drawable(struct egl_drm_drawable *drawable,
00083 const __GLcontextModes * visual)
00084 {
00085 enum pipe_format colorFormat, depthFormat, stencilFormat;
00086 struct intel_framebuffer *intelfb = CALLOC_STRUCT(intel_framebuffer);
00087
00088 if (!intelfb)
00089 return GL_FALSE;
00090
00091 intelfb->device = drawable->device->priv;
00092
00093 if (visual->redBits == 5)
00094 colorFormat = PIPE_FORMAT_R5G6B5_UNORM;
00095 else
00096 colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
00097
00098 if (visual->depthBits == 16)
00099 depthFormat = PIPE_FORMAT_Z16_UNORM;
00100 else if (visual->depthBits == 24)
00101 depthFormat = PIPE_FORMAT_S8Z24_UNORM;
00102 else
00103 depthFormat = PIPE_FORMAT_NONE;
00104
00105 if (visual->stencilBits == 8)
00106 stencilFormat = PIPE_FORMAT_S8Z24_UNORM;
00107 else
00108 stencilFormat = PIPE_FORMAT_NONE;
00109
00110 intelfb->stfb = st_create_framebuffer(visual,
00111 colorFormat,
00112 depthFormat,
00113 stencilFormat,
00114 drawable->w,
00115 drawable->h,
00116 (void*) intelfb);
00117
00118 if (!intelfb->stfb) {
00119 free(intelfb);
00120 return GL_FALSE;
00121 }
00122
00123 drawable->priv = (void *) intelfb;
00124 return GL_TRUE;
00125 }
00126
00127 int
00128 intel_destroy_drawable(struct egl_drm_drawable *drawable)
00129 {
00130 struct intel_framebuffer *intelfb = (struct intel_framebuffer *)drawable->priv;
00131 drawable->priv = NULL;
00132
00133 assert(intelfb->stfb);
00134 st_unreference_framebuffer(&intelfb->stfb);
00135 free(intelfb);
00136 return TRUE;
00137 }