1 /**************************************************************************
3 Copyright 2006 Stephane Marchesin
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 on the rights to use, copy, modify, merge, publish, distribute, sub
10 license, and/or sell copies of the Software, and to permit persons to whom
11 the Software is furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice (including the next
14 paragraph) shall be included in all copies or substantial portions of the
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,
21 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
28 #include "nouveau_context.h"
29 #include "nouveau_span.h"
30 #include "nouveau_fifo.h"
31 #include "nouveau_lock.h"
33 #include "swrast/swrast.h"
35 #define HAVE_HW_DEPTH_SPANS 0
36 #define HAVE_HW_DEPTH_PIXELS 0
37 #define HAVE_HW_STENCIL_SPANS 0
38 #define HAVE_HW_STENCIL_PIXELS 0
40 static char *fake_span
[1280*1024*4];
42 #define HW_CLIPLOOP() \
44 int _nc = nmesa->numClipRects; \
46 int minx = nmesa->pClipRects[_nc].x1 - nmesa->drawX; \
47 int miny = nmesa->pClipRects[_nc].y1 - nmesa->drawY; \
48 int maxx = nmesa->pClipRects[_nc].x2 - nmesa->drawX; \
49 int maxy = nmesa->pClipRects[_nc].y2 - nmesa->drawY;
52 nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \
53 nouveau_renderbuffer *nrb = (nouveau_renderbuffer *)rb; \
54 GLuint height = nrb->mesa.Height; \
55 GLubyte *map = (GLubyte *)(nrb->map ? nrb->map : nrb->mem->map) + \
56 (nmesa->drawY * nrb->pitch) + (nmesa->drawX * nrb->cpp); \
61 #define Y_FLIP( _y ) (height - _y - 1)
69 /* ================================================================
74 #define SPANTMP_PIXEL_FMT GL_RGB
75 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
77 #define TAG(x) nouveau##x##_RGB565
78 #define TAG2(x,y) nouveau##x##_RGB565##y
79 #define GET_PTR(X,Y) (map + (Y)*nrb->pitch + (X)*nrb->cpp)
84 #define SPANTMP_PIXEL_FMT GL_BGRA
85 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
87 #define TAG(x) nouveau##x##_ARGB8888
88 #define TAG2(x,y) nouveau##x##_ARGB8888##y
89 #define GET_PTR(X,Y) (map + (Y)*nrb->pitch + (X)*nrb->cpp)
93 nouveauSpanRenderStart( GLcontext
*ctx
)
95 nouveauContextPtr nmesa
= NOUVEAU_CONTEXT(ctx
);
98 nouveauWaitForIdleLocked( nmesa
);
102 nouveauSpanRenderFinish( GLcontext
*ctx
)
104 nouveauContextPtr nmesa
= NOUVEAU_CONTEXT(ctx
);
105 _swrast_flush( ctx
);
106 nouveauWaitForIdleLocked( nmesa
);
107 UNLOCK_HARDWARE( nmesa
);
110 void nouveauSpanInitFunctions( GLcontext
*ctx
)
112 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference(ctx
);
113 swdd
->SpanRenderStart
= nouveauSpanRenderStart
;
114 swdd
->SpanRenderFinish
= nouveauSpanRenderFinish
;
119 * Plug in the Get/Put routines for the given driRenderbuffer.
122 nouveauSpanSetFunctions(nouveau_renderbuffer
*nrb
, const GLvisual
*vis
)
124 if (nrb
->mesa
._ActualFormat
== GL_RGBA8
)
125 nouveauInitPointers_ARGB8888(&nrb
->mesa
);
126 else // if (nrb->mesa._ActualFormat == GL_RGB5)
127 nouveauInitPointers_RGB565(&nrb
->mesa
);