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 "swrast/swrast.h"
32 #include "intel_context.h"
33 #include "intel_pixel.h"
34 #include "intel_regions.h"
36 #define FILE_DEBUG_FLAG DEBUG_PIXEL
39 effective_func(GLenum func
, GLboolean src_alpha_is_one
)
41 if (src_alpha_is_one
) {
42 if (func
== GL_SRC_ALPHA
)
44 if (func
== GL_ONE_MINUS_SRC_ALPHA
)
52 * Check if any fragment operations are in effect which might effect
56 intel_check_blit_fragment_ops(GLcontext
* ctx
, GLboolean src_alpha_is_one
)
59 _mesa_update_state(ctx
);
61 if (ctx
->FragmentProgram
._Enabled
) {
62 DBG("fallback due to fragment program\n");
66 if (ctx
->Color
.BlendEnabled
&&
67 (effective_func(ctx
->Color
.BlendSrcRGB
, src_alpha_is_one
) != GL_ONE
||
68 effective_func(ctx
->Color
.BlendDstRGB
, src_alpha_is_one
) != GL_ZERO
||
69 ctx
->Color
.BlendEquationRGB
!= GL_FUNC_ADD
||
70 effective_func(ctx
->Color
.BlendSrcA
, src_alpha_is_one
) != GL_ONE
||
71 effective_func(ctx
->Color
.BlendDstA
, src_alpha_is_one
) != GL_ZERO
||
72 ctx
->Color
.BlendEquationA
!= GL_FUNC_ADD
)) {
73 DBG("fallback due to blend\n");
77 if (ctx
->Texture
._EnabledUnits
) {
78 DBG("fallback due to texturing\n");
82 if (!(ctx
->Color
.ColorMask
[0] &&
83 ctx
->Color
.ColorMask
[1] &&
84 ctx
->Color
.ColorMask
[2] &&
85 ctx
->Color
.ColorMask
[3])) {
86 DBG("fallback due to color masking\n");
90 if (ctx
->Color
.AlphaEnabled
) {
91 DBG("fallback due to alpha\n");
95 if (ctx
->Depth
.Test
) {
96 DBG("fallback due to depth test\n");
100 if (ctx
->Fog
.Enabled
) {
101 DBG("fallback due to fog\n");
105 if (ctx
->_ImageTransferState
) {
106 DBG("fallback due to image transfer\n");
110 if (ctx
->Stencil
.Enabled
) {
111 DBG("fallback due to image stencil\n");
115 if (ctx
->RenderMode
!= GL_RENDER
) {
116 DBG("fallback due to render mode\n");
125 intel_check_meta_tex_fragment_ops(GLcontext
* ctx
)
128 _mesa_update_state(ctx
);
130 /* Some of _ImageTransferState (scale, bias) could be done with
131 * fragment programs on i915.
133 return !(ctx
->_ImageTransferState
|| ctx
->Fog
.Enabled
|| /* not done yet */
134 ctx
->Texture
._EnabledUnits
|| ctx
->FragmentProgram
._Enabled
);
137 /* The intel_region struct doesn't really do enough to capture the
138 * format of the pixels in the region. For now this code assumes that
139 * the region is a display surface and hence is either ARGB8888 or
141 * XXX FBO: If we'd pass in the intel_renderbuffer instead of region, we'd
142 * know the buffer's pixel format.
144 * \param format as given to glDraw/ReadPixels
145 * \param type as given to glDraw/ReadPixels
148 intel_check_blit_format(struct intel_region
* region
,
149 GLenum format
, GLenum type
)
151 if (region
->cpp
== 4 &&
152 (type
== GL_UNSIGNED_INT_8_8_8_8_REV
||
153 type
== GL_UNSIGNED_BYTE
) && format
== GL_BGRA
) {
157 if (region
->cpp
== 2 &&
158 type
== GL_UNSIGNED_SHORT_5_6_5_REV
&& format
== GL_BGR
) {
162 if (INTEL_DEBUG
& DEBUG_PIXEL
)
163 fprintf(stderr
, "%s: bad format for blit (cpp %d, type %s format %s)\n",
164 __FUNCTION__
, region
->cpp
,
165 _mesa_lookup_enum_by_nr(type
), _mesa_lookup_enum_by_nr(format
));
172 intelInitPixelFuncs(struct dd_function_table
*functions
)
174 functions
->Accum
= _swrast_Accum
;
175 if (!getenv("INTEL_NO_BLIT")) {
176 functions
->Bitmap
= intelBitmap
;
177 functions
->CopyPixels
= intelCopyPixels
;
178 functions
->DrawPixels
= intelDrawPixels
;
180 functions
->ReadPixels
= intelReadPixels
;