1/* 2 * Copyright 2006 VMware, Inc. 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sublicense, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the 14 * next paragraph) shall be included in all copies or substantial portionsalloc 15 * of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 26#include "main/accum.h" 27#include "main/enums.h" 28#include "main/state.h" 29#include "main/bufferobj.h" 30#include "main/context.h" 31#include "swrast/swrast.h" 32 33#include "brw_context.h" 34#include "intel_pixel.h" 35 36#define FILE_DEBUG_FLAG DEBUG_PIXEL 37 38static GLenum 39effective_func(GLenum func, bool src_alpha_is_one) 40{ 41 if (src_alpha_is_one) { 42 if (func == GL_SRC_ALPHA) 43 return GL_ONE; 44 if (func == GL_ONE_MINUS_SRC_ALPHA) 45 return GL_ZERO; 46 } 47 48 return func; 49} 50 51/** 52 * Check if any fragment operations are in effect which might effect 53 * glDraw/CopyPixels. 54 */ 55bool 56intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one) 57{ 58 if (ctx->NewState) 59 _mesa_update_state(ctx); 60 61 if (ctx->FragmentProgram._Enabled) { 62 DBG("fallback due to fragment program\n"); 63 return false; 64 } 65 66 if (ctx->Color.BlendEnabled && 67 (effective_func(ctx->Color.Blend[0].SrcRGB, src_alpha_is_one) != GL_ONE || 68 effective_func(ctx->Color.Blend[0].DstRGB, src_alpha_is_one) != GL_ZERO || 69 ctx->Color.Blend[0].EquationRGB != GL_FUNC_ADD || 70 effective_func(ctx->Color.Blend[0].SrcA, src_alpha_is_one) != GL_ONE || 71 effective_func(ctx->Color.Blend[0].DstA, src_alpha_is_one) != GL_ZERO || 72 ctx->Color.Blend[0].EquationA != GL_FUNC_ADD)) { 73 DBG("fallback due to blend\n"); 74 return false; 75 } 76 77 if (ctx->Texture._MaxEnabledTexImageUnit != -1) { 78 DBG("fallback due to texturing\n"); 79 return false; 80 } 81 82 if (!(ctx->Color.ColorMask[0][0] && 83 ctx->Color.ColorMask[0][1] && 84 ctx->Color.ColorMask[0][2] && 85 ctx->Color.ColorMask[0][3])) { 86 DBG("fallback due to color masking\n"); 87 return false; 88 } 89 90 if (ctx->Color.AlphaEnabled) { 91 DBG("fallback due to alpha\n"); 92 return false; 93 } 94 95 if (ctx->Depth.Test) { 96 DBG("fallback due to depth test\n"); 97 return false; 98 } 99 100 if (ctx->Fog.Enabled) { 101 DBG("fallback due to fog\n"); 102 return false; 103 } 104 105 if (ctx->_ImageTransferState) { 106 DBG("fallback due to image transfer\n"); 107 return false; 108 } 109 110 if (ctx->Stencil._Enabled) { 111 DBG("fallback due to image stencil\n"); 112 return false; 113 } 114 115 if (ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F) { 116 DBG("fallback due to pixel zoom\n"); 117 return false; 118 } 119 120 if (ctx->RenderMode != GL_RENDER) { 121 DBG("fallback due to render mode\n"); 122 return false; 123 } 124 125 return true; 126} 127 128void 129intelInitPixelFuncs(struct dd_function_table *functions) 130{ 131 functions->Bitmap = intelBitmap; 132 functions->CopyPixels = intelCopyPixels; 133 functions->DrawPixels = intelDrawPixels; 134 functions->ReadPixels = intelReadPixels; 135} 136 137