1 /**************************************************************************
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portionsalloc
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "main/enums.h"
29 #include "main/state.h"
30 #include "main/bufferobj.h"
31 #include "main/context.h"
32 #include "main/enable.h"
33 #include "main/matrix.h"
34 #include "main/texstate.h"
35 #include "main/varray.h"
36 #include "main/viewport.h"
37 #include "swrast/swrast.h"
38 #include "shader/arbprogram.h"
39 #include "shader/program.h"
41 #include "intel_context.h"
42 #include "intel_pixel.h"
43 #include "intel_regions.h"
45 #define FILE_DEBUG_FLAG DEBUG_PIXEL
48 effective_func(GLenum func
, GLboolean src_alpha_is_one
)
50 if (src_alpha_is_one
) {
51 if (func
== GL_SRC_ALPHA
)
53 if (func
== GL_ONE_MINUS_SRC_ALPHA
)
61 * Check if any fragment operations are in effect which might effect
65 intel_check_blit_fragment_ops(GLcontext
* ctx
, GLboolean src_alpha_is_one
)
68 _mesa_update_state(ctx
);
70 if (ctx
->FragmentProgram
._Enabled
) {
71 DBG("fallback due to fragment program\n");
75 if (ctx
->Color
.BlendEnabled
&&
76 (effective_func(ctx
->Color
.BlendSrcRGB
, src_alpha_is_one
) != GL_ONE
||
77 effective_func(ctx
->Color
.BlendDstRGB
, src_alpha_is_one
) != GL_ZERO
||
78 ctx
->Color
.BlendEquationRGB
!= GL_FUNC_ADD
||
79 effective_func(ctx
->Color
.BlendSrcA
, src_alpha_is_one
) != GL_ONE
||
80 effective_func(ctx
->Color
.BlendDstA
, src_alpha_is_one
) != GL_ZERO
||
81 ctx
->Color
.BlendEquationA
!= GL_FUNC_ADD
)) {
82 DBG("fallback due to blend\n");
86 if (ctx
->Texture
._EnabledUnits
) {
87 DBG("fallback due to texturing\n");
91 if (!(ctx
->Color
.ColorMask
[0] &&
92 ctx
->Color
.ColorMask
[1] &&
93 ctx
->Color
.ColorMask
[2] &&
94 ctx
->Color
.ColorMask
[3])) {
95 DBG("fallback due to color masking\n");
99 if (ctx
->Color
.AlphaEnabled
) {
100 DBG("fallback due to alpha\n");
104 if (ctx
->Depth
.Test
) {
105 DBG("fallback due to depth test\n");
109 if (ctx
->Fog
.Enabled
) {
110 DBG("fallback due to fog\n");
114 if (ctx
->_ImageTransferState
) {
115 DBG("fallback due to image transfer\n");
119 if (ctx
->Stencil
._Enabled
) {
120 DBG("fallback due to image stencil\n");
124 if (ctx
->RenderMode
!= GL_RENDER
) {
125 DBG("fallback due to render mode\n");
132 /* The intel_region struct doesn't really do enough to capture the
133 * format of the pixels in the region. For now this code assumes that
134 * the region is a display surface and hence is either ARGB8888 or
136 * XXX FBO: If we'd pass in the intel_renderbuffer instead of region, we'd
137 * know the buffer's pixel format.
139 * \param format as given to glDraw/ReadPixels
140 * \param type as given to glDraw/ReadPixels
143 intel_check_blit_format(struct intel_region
* region
,
144 GLenum format
, GLenum type
)
146 if (region
->cpp
== 4 &&
147 (type
== GL_UNSIGNED_INT_8_8_8_8_REV
||
148 type
== GL_UNSIGNED_BYTE
) && format
== GL_BGRA
) {
152 if (region
->cpp
== 2 &&
153 type
== GL_UNSIGNED_SHORT_5_6_5_REV
&& format
== GL_BGR
) {
157 if (INTEL_DEBUG
& DEBUG_PIXEL
)
158 fprintf(stderr
, "%s: bad format for blit (cpp %d, type %s format %s)\n",
159 __FUNCTION__
, region
->cpp
,
160 _mesa_lookup_enum_by_nr(type
), _mesa_lookup_enum_by_nr(format
));
166 intelInitPixelFuncs(struct dd_function_table
*functions
)
168 functions
->Accum
= _swrast_Accum
;
169 if (!getenv("INTEL_NO_BLIT")) {
170 functions
->Bitmap
= intelBitmap
;
171 functions
->CopyPixels
= intelCopyPixels
;
172 functions
->DrawPixels
= intelDrawPixels
;
174 functions
->ReadPixels
= intelReadPixels
;