Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / mesa / drivers / dri / nouveau_winsys / nouveau_context.c
index 67df43647aad798b6730413f786a4d67cf209bcc..01fada5b89b282851e79c247d90343171e479a58 100644 (file)
@@ -1,18 +1,9 @@
-#include "glheader.h"
-#include "context.h"
-#include "extensions.h"
-
-#include "tnl/tnl.h"
-#include "tnl/t_pipeline.h"
-#include "tnl/t_vertex.h"
-
-#include "drivers/common/driverfuncs.h"
-
-#include "drirenderbuffer.h"
+#include "main/glheader.h"
+#include "glapi/glthread.h"
+#include <GL/internal/glcore.h>
+#include "utils.h"
 
 #include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-
 #include "pipe/p_defines.h"
 #include "pipe/p_context.h"
 
 #include "nouveau_screen.h"
 #include "nouveau_winsys_pipe.h"
 
-#define need_GL_ARB_fragment_program
-#define need_GL_ARB_multisample
-#define need_GL_ARB_occlusion_query
-#define need_GL_ARB_point_parameters
-#define need_GL_ARB_texture_compression
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_vertex_buffer_object
-#define need_GL_EXT_compiled_vertex_array
-#define need_GL_EXT_fog_coord
-#define need_GL_EXT_secondary_color
-#define need_GL_EXT_framebuffer_object
-#include "extension_helper.h"
-
-const struct dri_extension common_extensions[] =
-{
-       { NULL, 0 }
-};
-
-const struct dri_extension nv40_extensions[] =
-{
-       { "GL_ARB_fragment_program", NULL },
-       { "GL_ARB_multisample", GL_ARB_multisample_functions },
-       { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions },
-       { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
-       { "GL_ARB_texture_border_clamp", NULL },
-       { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
-       { "GL_ARB_texture_cube_map", NULL },
-       { "GL_ARB_texture_env_add", NULL },
-       { "GL_ARB_texture_env_combine", NULL },
-       { "GL_ARB_texture_env_crossbar", NULL },
-       { "GL_ARB_texture_env_dot3", NULL },
-       { "GL_ARB_texture_mirrored_repeat", NULL },
-       { "GL_ARB_texture_non_power_of_two", NULL },
-       { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions },
-       { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions },
-       { "GL_ATI_texture_env_combine3", NULL },
-       { "GL_EXT_compiled_vertex_array", GL_EXT_compiled_vertex_array_functions },
-       { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
-       { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
-       { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
-       { "GL_EXT_texture_edge_clamp", NULL },
-       { "GL_EXT_texture_env_add", NULL },
-       { "GL_EXT_texture_env_combine", NULL },
-       { "GL_EXT_texture_env_dot3", NULL },
-       { "GL_EXT_texture_mirror_clamp", NULL },
-       { "GL_NV_texture_rectangle", NULL },
-       { NULL, 0 }
-};
-
 #ifdef DEBUG
 static const struct dri_debug_control debug_control[] = {
        { "bo", DEBUG_BO },
@@ -125,6 +67,40 @@ nouveau_context_create(const __GLcontextModes *glVis,
                                              debug_control);
 #endif
 
+       /*XXX: Hack up a fake region and buffer object for front buffer.
+        *     This will go away with TTM, replaced with a simple reference
+        *     of the front buffer handle passed to us by the DDX.
+        */
+       {
+               struct pipe_surface *fb_surf;
+               struct nouveau_pipe_buffer *fb_buf;
+               struct nouveau_bo_priv *fb_bo;
+
+               fb_bo = calloc(1, sizeof(struct nouveau_bo_priv));
+               fb_bo->drm.offset = nv_screen->front_offset;
+               fb_bo->drm.flags = NOUVEAU_MEM_FB;
+               fb_bo->drm.size = nv_screen->front_pitch * 
+                                 nv_screen->front_height;
+               fb_bo->refcount = 1;
+               fb_bo->base.flags = NOUVEAU_BO_PIN | NOUVEAU_BO_VRAM;
+               fb_bo->base.offset = fb_bo->drm.offset;
+               fb_bo->base.handle = (unsigned long)fb_bo;
+               fb_bo->base.size = fb_bo->drm.size;
+               fb_bo->base.device = nv_screen->device;
+
+               fb_buf = calloc(1, sizeof(struct nouveau_pipe_buffer));
+               fb_buf->bo = &fb_bo->base;
+
+               fb_surf = calloc(1, sizeof(struct pipe_surface));
+               fb_surf->cpp = nv_screen->front_cpp;
+               fb_surf->pitch = nv_screen->front_pitch / fb_surf->cpp;
+               fb_surf->height = nv_screen->front_height;
+               fb_surf->refcount = 1;
+               fb_surf->buffer = &fb_buf->base;
+
+               nv->frontbuffer = fb_surf;
+       }
+
        if ((ret = nouveau_grobj_alloc(nv->channel, 0x00000000, 0x30,
                                       &nv->NvNull))) {
                NOUVEAU_ERR("Error creating NULL object: %d\n", ret);
@@ -139,9 +115,9 @@ nouveau_context_create(const __GLcontextModes *glVis,
        }
 
        if (nv->chipset < 0x50)
-               ret = nouveau_region_init_nv04(nv);
+               ret = nouveau_surface_init_nv04(nv);
        else
-               ret = nouveau_region_init_nv50(nv);
+               ret = nouveau_surface_init_nv50(nv);
        if (ret) {
                return GL_FALSE;
        }