Move i915tex driver into place as just i915.
[mesa.git] / src / mesa / drivers / dri / i915 / intel_pixel.c
1 /**************************************************************************
2 *
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
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 above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portionsalloc
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 #include "enums.h"
29 #include "state.h"
30 #include "swrast/swrast.h"
31
32 #include "intel_context.h"
33 #include "intel_pixel.h"
34 #include "intel_regions.h"
35
36
37 /**
38 * Check if any fragment operations are in effect which might effect
39 * glDraw/CopyPixels.
40 */
41 GLboolean
42 intel_check_blit_fragment_ops(GLcontext * ctx)
43 {
44 if (ctx->NewState)
45 _mesa_update_state(ctx);
46
47 /* XXX Note: Scissor could be done with the blitter:
48 */
49 return !(ctx->_ImageTransferState ||
50 ctx->Color.AlphaEnabled ||
51 ctx->Depth.Test ||
52 ctx->Fog.Enabled ||
53 ctx->Scissor.Enabled ||
54 ctx->Stencil.Enabled ||
55 !ctx->Color.ColorMask[0] ||
56 !ctx->Color.ColorMask[1] ||
57 !ctx->Color.ColorMask[2] ||
58 !ctx->Color.ColorMask[3] ||
59 ctx->Texture._EnabledUnits ||
60 ctx->FragmentProgram._Enabled ||
61 ctx->Color.BlendEnabled);
62 }
63
64
65 GLboolean
66 intel_check_meta_tex_fragment_ops(GLcontext * ctx)
67 {
68 if (ctx->NewState)
69 _mesa_update_state(ctx);
70
71 /* Some of _ImageTransferState (scale, bias) could be done with
72 * fragment programs on i915.
73 */
74 return !(ctx->_ImageTransferState || ctx->Fog.Enabled || /* not done yet */
75 ctx->Texture._EnabledUnits || ctx->FragmentProgram._Enabled);
76 }
77
78 /* The intel_region struct doesn't really do enough to capture the
79 * format of the pixels in the region. For now this code assumes that
80 * the region is a display surface and hence is either ARGB8888 or
81 * RGB565.
82 * XXX FBO: If we'd pass in the intel_renderbuffer instead of region, we'd
83 * know the buffer's pixel format.
84 *
85 * \param format as given to glDraw/ReadPixels
86 * \param type as given to glDraw/ReadPixels
87 */
88 GLboolean
89 intel_check_blit_format(struct intel_region * region,
90 GLenum format, GLenum type)
91 {
92 if (region->cpp == 4 &&
93 (type == GL_UNSIGNED_INT_8_8_8_8_REV ||
94 type == GL_UNSIGNED_BYTE) && format == GL_BGRA) {
95 return GL_TRUE;
96 }
97
98 if (region->cpp == 2 &&
99 type == GL_UNSIGNED_SHORT_5_6_5_REV && format == GL_BGR) {
100 return GL_TRUE;
101 }
102
103 if (INTEL_DEBUG & DEBUG_PIXEL)
104 fprintf(stderr, "%s: bad format for blit (cpp %d, type %s format %s)\n",
105 __FUNCTION__, region->cpp,
106 _mesa_lookup_enum_by_nr(type), _mesa_lookup_enum_by_nr(format));
107
108 return GL_FALSE;
109 }
110
111
112 void
113 intelInitPixelFuncs(struct dd_function_table *functions)
114 {
115 functions->Accum = _swrast_Accum;
116 functions->Bitmap = _swrast_Bitmap;
117 functions->CopyPixels = intelCopyPixels;
118 functions->ReadPixels = intelReadPixels;
119 functions->DrawPixels = intelDrawPixels;
120 }