static void mgaDDTexParameter( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj, GLenum pname, const GLfloat *params ) { mgaContextPtr mmesa = MGA_CONTEXT( ctx ); mgaTextureObjectPtr t; t = (mgaTextureObjectPtr) tObj->DriverData; /* If we don't have a hardware texture, it will be automatically * created with current state before it is used, so we don't have * to do anything now */ if ( (t == NULL) || (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_NV) ) { return; } switch (pname) { case GL_TEXTURE_MIN_FILTER: driSwapOutTextureObject( (driTextureObject *) t ); /* FALLTHROUGH */ case GL_TEXTURE_MAG_FILTER: FLUSH_BATCH(mmesa); mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter ); break; case GL_TEXTURE_WRAP_S: case GL_TEXTURE_WRAP_T: FLUSH_BATCH(mmesa); mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT); break; case GL_TEXTURE_BORDER_COLOR: FLUSH_BATCH(mmesa); mgaSetTexBorderColor(t, tObj->_BorderChan); break; case GL_TEXTURE_BASE_LEVEL: case GL_TEXTURE_MAX_LEVEL: case GL_TEXTURE_MIN_LOD: case GL_TEXTURE_MAX_LOD: /* This isn't the most efficient solution but there doesn't appear to * be a nice alternative. Since there's no LOD clamping, * we just have to rely on loading the right subset of mipmap levels * to simulate a clamped LOD. */ driSwapOutTextureObject( (driTextureObject *) t ); break; default: return; } }
static void mach64DDTexEnv( struct gl_context *ctx, GLenum target, GLenum pname, const GLfloat *param ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); #if 0 struct gl_texture_unit *texUnit; GLubyte c[4]; #endif if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { fprintf( stderr, "%s( %s )\n", __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) ); } switch ( pname ) { case GL_TEXTURE_ENV_MODE: FLUSH_BATCH( mmesa ); mmesa->new_state |= MACH64_NEW_TEXTURE | MACH64_NEW_ALPHA; break; #if 0 case GL_TEXTURE_ENV_COLOR: texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; CLAMPED_FLOAT_TO_UBYTE( c[0], texUnit->EnvColor[0] ); CLAMPED_FLOAT_TO_UBYTE( c[1], texUnit->EnvColor[1] ); CLAMPED_FLOAT_TO_UBYTE( c[2], texUnit->EnvColor[2] ); CLAMPED_FLOAT_TO_UBYTE( c[3], texUnit->EnvColor[3] ); mmesa->env_color = mach64PackColor( 32, c[0], c[1], c[2], c[3] ); if ( mmesa->setup.constant_color_c != mmesa->env_color ) { FLUSH_BATCH( mmesa ); mmesa->setup.constant_color_c = mmesa->env_color; mmesa->new_state |= MACH64_NEW_TEXTURE; /* More complex multitexture/multipass fallbacks for GL_BLEND * can be done later, but this allows a single pass GL_BLEND * in some cases (ie. Performer town demo). */ mmesa->blend_flags &= ~MACH64_BLEND_ENV_COLOR; if ( mmesa->env_color != 0x00000000 && mmesa->env_color != 0xff000000 && mmesa->env_color != 0x00ffffff && mmesa->env_color != 0xffffffff )) { mmesa->blend_flags |= MACH64_BLEND_ENV_COLOR; } } break; #endif default: return; }
void i915_fill_blit(struct i915_context *i915, unsigned cpp, unsigned rgba_mask, unsigned short dst_pitch, struct i915_winsys_buffer *dst_buffer, unsigned dst_offset, short x, short y, short w, short h, unsigned color) { unsigned BR13, CMD; I915_DBG(DBG_BLIT, "%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", __FUNCTION__, dst_buffer, dst_pitch, dst_offset, x, y, w, h); if(!i915_winsys_validate_buffers(i915->batch, &dst_buffer, 1)) { FLUSH_BATCH(NULL); assert(i915_winsys_validate_buffers(i915->batch, &dst_buffer, 1)); } switch (cpp) { case 1: case 2: case 3: BR13 = (((int) dst_pitch) & 0xffff) | (0xF0 << 16) | (1 << 24); CMD = XY_COLOR_BLT_CMD; break; case 4: BR13 = (((int) dst_pitch) & 0xffff) | (0xF0 << 16) | (1 << 24) | (1 << 25); CMD = (XY_COLOR_BLT_CMD | rgba_mask); break; default: return; } if (!BEGIN_BATCH(6)) { FLUSH_BATCH(NULL); assert(BEGIN_BATCH(6)); } OUT_BATCH(CMD); OUT_BATCH(BR13); OUT_BATCH((y << 16) | x); OUT_BATCH(((y + h) << 16) | (x + w)); OUT_RELOC_FENCED(dst_buffer, I915_USAGE_2D_TARGET, dst_offset); OUT_BATCH(color); i915_set_flush_dirty(i915, I915_FLUSH_CACHE); }
static void r128TexParameter( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj, GLenum pname, const GLfloat *params ) { r128ContextPtr rmesa = R128_CONTEXT(ctx); r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData; if ( R128_DEBUG & DEBUG_VERBOSE_API ) { fprintf( stderr, "%s( %s )\n", __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) ); } if ( ( target != GL_TEXTURE_2D ) && ( target != GL_TEXTURE_1D ) ) return; switch ( pname ) { case GL_TEXTURE_MIN_FILTER: case GL_TEXTURE_MAG_FILTER: if ( t->base.bound ) FLUSH_BATCH( rmesa ); r128SetTexFilter( t, tObj->MinFilter, tObj->MagFilter ); break; case GL_TEXTURE_WRAP_S: case GL_TEXTURE_WRAP_T: if ( t->base.bound ) FLUSH_BATCH( rmesa ); r128SetTexWrap( t, tObj->WrapS, tObj->WrapT ); break; case GL_TEXTURE_BORDER_COLOR: if ( t->base.bound ) FLUSH_BATCH( rmesa ); r128SetTexBorderColor( t, tObj->BorderColor.f ); break; case GL_TEXTURE_BASE_LEVEL: case GL_TEXTURE_MAX_LEVEL: case GL_TEXTURE_MIN_LOD: case GL_TEXTURE_MAX_LOD: /* This isn't the most efficient solution but there doesn't appear to * be a nice alternative for R128. Since there's no LOD clamping, * we just have to rely on loading the right subset of mipmap levels * to simulate a clamped LOD. */ if ( t->base.bound ) FLUSH_BATCH( rmesa ); driSwapOutTextureObject( (driTextureObject *) t ); break; default: return; } }
void i915_fill_blit(struct i915_context *i915, unsigned cpp, unsigned short dst_pitch, struct intel_buffer *dst_buffer, unsigned dst_offset, short x, short y, short w, short h, unsigned color) { unsigned BR13, CMD; I915_DBG(i915, "%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", __FUNCTION__, dst_buffer, dst_pitch, dst_offset, x, y, w, h); switch (cpp) { case 1: case 2: case 3: BR13 = (((int) dst_pitch) & 0xffff) | (0xF0 << 16) | (1 << 24); CMD = XY_COLOR_BLT_CMD; break; case 4: BR13 = (((int) dst_pitch) & 0xffff) | (0xF0 << 16) | (1 << 24) | (1 << 25); CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB); break; default: return; } if (!BEGIN_BATCH(6, 1)) { FLUSH_BATCH(NULL); assert(BEGIN_BATCH(6, 1)); } OUT_BATCH(CMD); OUT_BATCH(BR13); OUT_BATCH((y << 16) | x); OUT_BATCH(((y + h) << 16) | (x + w)); OUT_RELOC(dst_buffer, INTEL_USAGE_2D_TARGET, dst_offset); OUT_BATCH(color); FLUSH_BATCH(NULL); }
static void tdfxDDStencilMask( GLcontext *ctx, GLuint mask ) { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_STENCIL; }
static void mgaDDDrawBuffer(GLcontext *ctx, GLenum mode ) { mgaContextPtr mmesa = MGA_CONTEXT(ctx); FLUSH_BATCH( mmesa ); /* * _DrawDestMask is easier to cope with than <mode>. */ switch ( ctx->Color._DrawDestMask[0] ) { case DD_FRONT_LEFT_BIT: mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset; mmesa->dirty |= MGA_UPLOAD_CONTEXT; mmesa->draw_buffer = MGA_FRONT; mgaXMesaSetFrontClipRects( mmesa ); FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; case DD_BACK_LEFT_BIT: mmesa->setup.dstorg = mmesa->mgaScreen->backOffset; mmesa->draw_buffer = MGA_BACK; mmesa->dirty |= MGA_UPLOAD_CONTEXT; mgaXMesaSetBackClipRects( mmesa ); FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; default: /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } /* We want to update the s/w rast state too so that r200SetBuffer() * gets called. */ _swrast_DrawBuffer(ctx, mode); }
void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) { TNLcontext *tnl = TNL_CONTEXT(ctx); mgaContextPtr mmesa = MGA_CONTEXT(ctx); GLuint oldfallback = mmesa->Fallback; if (mode) { mmesa->Fallback |= bit; if (oldfallback == 0) { FLUSH_BATCH(mmesa); _swsetup_Wakeup( ctx ); mmesa->RenderIndex = ~0; if (MGA_DEBUG & DEBUG_VERBOSE_FALLBACK) { fprintf(stderr, "MGA begin rasterization fallback: 0x%x %s\n", bit, getFallbackString(bit)); } } } else { mmesa->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); tnl->Driver.Render.Start = mgaCheckTexSizes; tnl->Driver.Render.PrimitiveNotify = mgaRenderPrimitive; tnl->Driver.Render.Finish = mgaRenderFinish; tnl->Driver.Render.BuildVertices = mgaBuildVertices; mmesa->NewGLState |= (_MGA_NEW_RENDERSTATE | _MGA_NEW_RASTERSETUP); if (MGA_DEBUG & DEBUG_VERBOSE_FALLBACK) { fprintf(stderr, "MGA end rasterization fallback: 0x%x %s\n", bit, getFallbackString(bit)); } } } }
static void gammaDDFrontFace( GLcontext *ctx, GLenum mode ) { gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); FLUSH_BATCH( gmesa ); gmesa->new_state |= GAMMA_NEW_CULL; }
static void gammaDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) { gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); FLUSH_BATCH( gmesa ); gmesa->new_state |= GAMMA_NEW_FOG; }
static void gammaDDDepthMask( GLcontext *ctx, GLboolean flag ) { gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); FLUSH_BATCH( gmesa ); gmesa->new_state |= GAMMA_NEW_DEPTH; }
static void gammaDDDepthFunc( GLcontext *ctx, GLenum func ) { gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); FLUSH_BATCH( gmesa ); gmesa->new_state |= GAMMA_NEW_DEPTH; }
void r128SpanRenderStart( GLcontext *ctx ) { r128ContextPtr rmesa = R128_CONTEXT(ctx); FLUSH_BATCH(rmesa); LOCK_HARDWARE(rmesa); r128WaitForIdleLocked( rmesa ); }
static void tdfxDDFrontFace( GLcontext *ctx, GLenum mode ) { tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_CULL; }
static void tdfxDDScissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h) { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_CLIP; }
static void tdfxDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g, GLboolean b, GLboolean a ) { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); FLUSH_BATCH( fxMesa ); if ( fxMesa->Color.ColorMask[RCOMP] != r || fxMesa->Color.ColorMask[GCOMP] != g || fxMesa->Color.ColorMask[BCOMP] != b || fxMesa->Color.ColorMask[ACOMP] != a ) { fxMesa->Color.ColorMask[RCOMP] = r; fxMesa->Color.ColorMask[GCOMP] = g; fxMesa->Color.ColorMask[BCOMP] = b; fxMesa->Color.ColorMask[ACOMP] = a; fxMesa->dirty |= TDFX_UPLOAD_COLOR_MASK; if (ctx->Visual.redBits < 8) { /* Can't do RGB colormasking in 16bpp mode. */ /* We can completely ignore the alpha mask. */ FALLBACK( fxMesa, TDFX_FALLBACK_COLORMASK, (r != g || g != b) ); } } }
static void tdfxDDClearDepth( GLcontext *ctx, GLclampd d ) { tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_DEPTH; }
static void tdfxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_FOG; switch (pname) { case GL_FOG_COORDINATE_SOURCE_EXT: { GLenum p = (GLenum)*param; if (p == GL_FOG_COORDINATE_EXT) { _swrast_allow_vertex_fog(ctx, GL_TRUE); _swrast_allow_pixel_fog(ctx, GL_FALSE); _tnl_allow_vertex_fog( ctx, GL_TRUE); _tnl_allow_pixel_fog( ctx, GL_FALSE); } else { _swrast_allow_vertex_fog(ctx, GL_FALSE); _swrast_allow_pixel_fog(ctx, GL_TRUE); _tnl_allow_vertex_fog( ctx, GL_FALSE); _tnl_allow_pixel_fog( ctx, GL_TRUE); } break; } default: ; } }
static void tdfxDDDepthFunc( GLcontext *ctx, GLenum func ) { tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_DEPTH; }
/* XXX support for separate read/draw buffers hasn't been tested */ static void tdfxDDDrawBuffer( GLcontext *ctx, GLenum mode ) { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) { fprintf( stderr, "%s()\n", __FUNCTION__ ); } FLUSH_BATCH( fxMesa ); if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) { FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) { case BUFFER_FRONT_LEFT: fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER; fxMesa->new_state |= TDFX_NEW_RENDER; FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; case BUFFER_BACK_LEFT: fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER; fxMesa->new_state |= TDFX_NEW_RENDER; FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; case -1: FX_grColorMaskv( ctx, false4 ); FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; default: FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE ); break; } }
static void tdfxDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref ) { tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_ALPHA; }
void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode ) { TNLcontext *tnl = TNL_CONTEXT(ctx); mgaContextPtr mmesa = MGA_CONTEXT(ctx); GLuint oldfallback = mmesa->Fallback; if (mode) { mmesa->Fallback |= bit; if (oldfallback == 0) { FLUSH_BATCH(mmesa); _swsetup_Wakeup( ctx ); mmesa->RenderIndex = ~0; } } else { mmesa->Fallback &= ~bit; if (oldfallback == bit) { _swrast_flush( ctx ); tnl->Driver.Render.Start = mgaCheckTexSizes; tnl->Driver.Render.PrimitiveNotify = mgaRenderPrimitive; tnl->Driver.Render.Finish = mgaRenderFinish; tnl->Driver.Render.BuildVertices = mgaBuildVertices; mmesa->new_gl_state |= (_MGA_NEW_RENDERSTATE | _MGA_NEW_RASTERSETUP); } } }
static void mgaDDDrawBuffer(GLcontext *ctx, GLenum mode ) { mgaContextPtr mmesa = MGA_CONTEXT(ctx); FLUSH_BATCH( mmesa ); /* * _DrawDestMask is easier to cope with than <mode>. */ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) { case BUFFER_BIT_FRONT_LEFT: mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset; mmesa->dirty |= MGA_UPLOAD_CONTEXT; mmesa->draw_buffer = MGA_FRONT; mgaXMesaSetFrontClipRects( mmesa ); FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; case BUFFER_BIT_BACK_LEFT: mmesa->setup.dstorg = mmesa->mgaScreen->backOffset; mmesa->draw_buffer = MGA_BACK; mmesa->dirty |= MGA_UPLOAD_CONTEXT; mgaXMesaSetBackClipRects( mmesa ); FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE ); break; default: /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE ); return; } }
void tdfxCheckTexSizes( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); if (!setup_tab[fxMesa->SetupIndex].check_tex_sizes(ctx)) { GLuint ind = fxMesa->SetupIndex |= (TDFX_PTEX_BIT|TDFX_RGBA_BIT); /* Tdfx handles projective textures nicely; just have to change * up to the new vertex format. */ if (setup_tab[ind].vertex_format != fxMesa->vertexFormat) { FLUSH_BATCH(fxMesa); fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT; fxMesa->vertexFormat = setup_tab[ind].vertex_format; /* This is required as we have just changed the vertex * format, so the interp and copy routines must also change. * In the unfilled and twosided cases we are using the * swrast_setup ones anyway, so leave them in place. */ if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { tnl->Driver.Render.Interp = setup_tab[fxMesa->SetupIndex].interp; tnl->Driver.Render.CopyPV = setup_tab[fxMesa->SetupIndex].copy_pv; } } } }
static void tdfxDDViewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_VIEWPORT; }
static void tdfxDDDepthMask( GLcontext *ctx, GLboolean flag ) { tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_DEPTH; }
static void tdfxDDShadeModel( GLcontext *ctx, GLenum mode ) { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); /* FIXME: Can we implement native flat shading? */ FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_TEXTURE; }
static void mgaDDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) { if ( ctx->Scissor.Enabled ) { FLUSH_BATCH( MGA_CONTEXT(ctx) ); /* don't pipeline cliprect changes */ mgaUpdateClipping( ctx ); } }
static void mgaDDLightModelfv(GLcontext *ctx, GLenum pname, const GLfloat *param) { if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) { FLUSH_BATCH( MGA_CONTEXT(ctx) ); updateSpecularLighting( ctx ); } }
static void tdfxDDStencilOp( GLcontext *ctx, GLenum sfail, GLenum zfail, GLenum zpass ) { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); FLUSH_BATCH( fxMesa ); fxMesa->new_state |= TDFX_NEW_STENCIL; }