Merge remote-tracking branch 'mesa-public/master' into vulkan
[mesa.git] / src / mesa / drivers / dri / i965 / intel_screen.c
index 147fa1ea49e77ef8d4f28541bcaa4a884fbd5735..5911b44445492ed234649dc82208a19ba5257fc4 100644 (file)
@@ -122,7 +122,7 @@ aub_dump_bmp(struct gl_context *ctx)
 {
    struct gl_framebuffer *fb = ctx->DrawBuffer;
 
-   for (int i = 0; i < fb->_NumColorDrawBuffers; i++) {
+   for (unsigned i = 0; i < fb->_NumColorDrawBuffers; i++) {
       struct intel_renderbuffer *irb =
         intel_renderbuffer(fb->_ColorDrawBuffers[i]);
 
@@ -1219,7 +1219,7 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
    __DRIconfig **configs = NULL;
 
    /* Generate singlesample configs without accumulation buffer. */
-   for (int i = 0; i < ARRAY_SIZE(formats); i++) {
+   for (unsigned i = 0; i < ARRAY_SIZE(formats); i++) {
       __DRIconfig **new_configs;
       int num_depth_stencil_bits = 2;
 
@@ -1256,7 +1256,7 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
    /* Generate the minimum possible set of configs that include an
     * accumulation buffer.
     */
-   for (int i = 0; i < ARRAY_SIZE(formats); i++) {
+   for (unsigned i = 0; i < ARRAY_SIZE(formats); i++) {
       __DRIconfig **new_configs;
 
       if (formats[i] == MESA_FORMAT_B5G6R5_UNORM) {
@@ -1288,7 +1288,7 @@ intel_screen_make_configs(__DRIscreen *dri_screen)
     * supported.  Singlebuffer configs are not supported because no one wants
     * them.
     */
-   for (int i = 0; i < ARRAY_SIZE(formats); i++) {
+   for (unsigned i = 0; i < ARRAY_SIZE(formats); i++) {
       if (devinfo->gen < 6)
          break;
 
@@ -1486,6 +1486,78 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
    return (const __DRIconfig**) intel_screen_make_configs(psp);
 }
 
+struct intel_screen *
+intel_screen_create(int fd)
+{
+   __DRIscreen *psp;
+   __DRIconfig **configs;
+   int i;
+
+   psp = malloc(sizeof(*psp));
+   if (psp == NULL)
+      return NULL;
+
+   psp->image.loader = (void *) 1; /* Don't complain about this being NULL */
+   psp->fd = fd;
+   psp->dri2.useInvalidate = (void *) 1;
+
+   configs = (__DRIconfig **) intelInitScreen2(psp);
+   for (i = 0; configs[i]; i++)
+      free(configs[i]);
+   free(configs);
+
+   return psp->driverPrivate;
+}
+
+void
+intel_screen_destroy(struct intel_screen *screen)
+{
+   __DRIscreen *psp;
+
+   psp = screen->driScrnPriv;
+   intelDestroyScreen(screen->driScrnPriv);
+   free(psp);
+}
+
+
+struct brw_context *
+intel_context_create(struct intel_screen *screen)
+{
+   __DRIcontext *driContextPriv;
+   struct brw_context *brw;
+   unsigned error;
+
+   driContextPriv = malloc(sizeof(*driContextPriv));
+   if (driContextPriv == NULL)
+      return NULL;
+
+   driContextPriv->driScreenPriv = screen->driScrnPriv;
+
+   brwCreateContext(API_OPENGL_CORE,
+                    NULL, /* visual */
+                    driContextPriv,
+                    3, 0,
+                    0, /* flags */
+                    false, /* notify_reset */
+                    &error,
+                    NULL);
+
+   brw = driContextPriv->driverPrivate;
+   brw->ctx.FirstTimeCurrent = false;
+
+   return driContextPriv->driverPrivate;
+}
+
+void
+intel_context_destroy(struct brw_context *brw)
+{
+   __DRIcontext *driContextPriv;
+
+   driContextPriv = brw->driContext;
+   intelDestroyContext(driContextPriv);
+   free(driContextPriv);
+}
+
 struct intel_buffer {
    __DRIbuffer base;
    drm_intel_bo *bo;