Merge commit 'origin/gallium-master-merge'
[mesa.git] / src / gallium / winsys / drm / intel / dri / intel_winsys_softpipe.c
1 /**************************************************************************
2 *
3 * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
24 * of the Software.
25 *
26 *
27 **************************************************************************/
28 /*
29 * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
30 */
31
32 #include "intel_context.h"
33 #include "intel_winsys_softpipe.h"
34 #include "pipe/p_defines.h"
35 #include "pipe/p_format.h"
36 #include "util/u_memory.h"
37 #include "softpipe/sp_winsys.h"
38
39
40 struct intel_softpipe_winsys {
41 struct softpipe_winsys sws;
42 struct intel_context *intel;
43 };
44
45 /**
46 * Return list of surface formats supported by this driver.
47 */
48 static boolean
49 intel_is_format_supported(struct softpipe_winsys *sws,
50 enum pipe_format format)
51 {
52 switch(format) {
53 case PIPE_FORMAT_A8R8G8B8_UNORM:
54 case PIPE_FORMAT_R5G6B5_UNORM:
55 case PIPE_FORMAT_S8Z24_UNORM:
56 return TRUE;
57 default:
58 return FALSE;
59 }
60 }
61
62
63 /**
64 * Create rendering context which uses software rendering.
65 */
66 struct pipe_context *
67 intel_create_softpipe( struct intel_context *intel,
68 struct pipe_winsys *winsys )
69 {
70 struct intel_softpipe_winsys *isws = CALLOC_STRUCT( intel_softpipe_winsys );
71 struct pipe_screen *screen = softpipe_create_screen(winsys);
72
73 /* Fill in this struct with callbacks that softpipe will need to
74 * communicate with the window system, buffer manager, etc.
75 */
76 isws->sws.is_format_supported = intel_is_format_supported;
77 isws->intel = intel;
78
79 /* Create the softpipe context:
80 */
81 return softpipe_create( screen, winsys, &isws->sws );
82 }