static void mach64TexImage2D( struct gl_context *ctx, GLenum target, GLint level, GLint internalFormat, GLint width, GLint height, GLint border, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); driTextureObject * t = (driTextureObject *) texObj->DriverData; if ( t ) { driSwapOutTextureObject( t ); } else { t = (driTextureObject *) mach64AllocTexObj(texObj); if (!t) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); return; } } /* Note, this will call mach64ChooseTextureFormat */ _mesa_store_teximage2d( ctx, target, level, internalFormat, width, height, border, format, type, pixels, &ctx->Unpack, texObj, texImage ); mmesa->new_state |= MACH64_NEW_TEXTURE; }
static void mach64TexSubImage2D( struct gl_context *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, const struct gl_pixelstore_attrib *packing, struct gl_texture_object *texObj, struct gl_texture_image *texImage ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); driTextureObject * t = (driTextureObject *) texObj->DriverData; assert( t ); /* this _should_ be true */ if ( t ) { driSwapOutTextureObject( t ); } else { t = (driTextureObject *) mach64AllocTexObj(texObj); if (!t) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D"); return; } } _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, height, format, type, pixels, packing, texObj, texImage); mmesa->new_state |= MACH64_NEW_TEXTURE; }
void mach64FreeVB( GLcontext *ctx ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); if (mmesa->verts) { ALIGN_FREE(mmesa->verts); mmesa->verts = 0; } }
void mach64_emit_contiguous_verts( GLcontext *ctx, GLuint start, GLuint count ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); GLuint vertex_size = mmesa->vertex_size * 4; GLuint *dest = mach64AllocDmaLow( mmesa, (count-start) * vertex_size); setup_tab[mmesa->SetupIndex].emit( ctx, start, count, dest, vertex_size ); }
/* Update the hardware texture state */ void mach64UpdateTextureState( GLcontext *ctx ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { fprintf( stderr, "%s( %p ) en=0x%x 0x%x\n", __FUNCTION__, ctx, ctx->Texture.Unit[0]._ReallyEnabled, ctx->Texture.Unit[1]._ReallyEnabled); } /* Clear any texturing fallbacks */ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_FALSE ); /* Unbind any currently bound textures */ if ( mmesa->CurrentTexObj[0] ) mmesa->CurrentTexObj[0]->base.bound = 0; if ( mmesa->CurrentTexObj[1] ) mmesa->CurrentTexObj[1]->base.bound = 0; mmesa->CurrentTexObj[0] = NULL; mmesa->CurrentTexObj[1] = NULL; /* Disable all texturing until it is known to be good */ mmesa->setup.scale_3d_cntl |= MACH64_TEXTURE_DISABLE; mmesa->setup.scale_3d_cntl &= ~MACH64_TEX_MAP_AEN; mmesa->setup.tex_cntl &= ~MACH64_TEXTURE_COMPOSITE; mmesa->setup.tex_size_pitch = 0x00000000; mmesa->tmu_source[0] = 0; mmesa->tmu_source[1] = 1; mmesa->multitex = 0; if (ctx->Texture._EnabledUnits & 0x2) { /* unit 1 enabled */ if (ctx->Texture._EnabledUnits & 0x1) { /* units 0 and 1 enabled */ mmesa->multitex = 1; mach64UpdateTextureUnit( ctx, 0 ); mach64UpdateTextureEnv( ctx, 0 ); mach64UpdateTextureUnit( ctx, 1 ); mach64UpdateTextureEnv( ctx, 1 ); } else { mmesa->tmu_source[0] = 1; mmesa->tmu_source[1] = 0; mach64UpdateTextureUnit( ctx, 0 ); mach64UpdateTextureEnv( ctx, 0 ); } } else if (ctx->Texture._EnabledUnits & 0x1) { /* only unit 0 enabled */ mach64UpdateTextureUnit( ctx, 0 ); mach64UpdateTextureEnv( ctx, 0 ); } mmesa->dirty |= (MACH64_UPLOAD_SCALE_3D_CNTL | MACH64_UPLOAD_TEXTURE); }
/* Return the current color buffer size. */ static void mach64DDGetBufferSize( GLframebuffer *buffer, GLuint *width, GLuint *height ) { GET_CURRENT_CONTEXT(ctx); mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); LOCK_HARDWARE( mmesa ); *width = mmesa->driDrawable->w; *height = mmesa->driDrawable->h; UNLOCK_HARDWARE( mmesa ); }
/* Make sure all commands have been sent to the hardware and have * completed processing. */ static void mach64DDFinish( GLcontext *ctx ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); #if ENABLE_PERF_BOXES /* Bump the performance counter */ mmesa->c_drawWaits++; #endif mach64DDFlush( ctx ); mach64WaitForIdle( mmesa ); }
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 mach64InitVB( GLcontext *ctx ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); GLuint size = TNL_CONTEXT(ctx)->vb.Size; mmesa->verts = (GLubyte *)ALIGN_MALLOC(size * 4 * 16, 32); { static int firsttime = 1; if (firsttime) { init_setup_tab(); firsttime = 0; } } }
void mach64BuildVertices( GLcontext *ctx, GLuint start, GLuint count, GLuint newinputs ) { mach64ContextPtr mmesa = MACH64_CONTEXT( ctx ); GLuint stride = mmesa->vertex_size * sizeof(int); GLubyte *v = ((GLubyte *)mmesa->verts + (start * stride)); newinputs |= mmesa->SetupNewInputs; mmesa->SetupNewInputs = 0; if (!newinputs) return; if (newinputs & VERT_BIT_POS) { setup_tab[mmesa->SetupIndex].emit( ctx, start, count, v, stride ); } else { GLuint ind = 0; if (newinputs & VERT_BIT_COLOR0) ind |= MACH64_RGBA_BIT; if (newinputs & VERT_BIT_COLOR1) ind |= MACH64_SPEC_BIT; if (newinputs & VERT_BIT_TEX0) ind |= MACH64_TEX0_BIT; if (newinputs & VERT_BIT_TEX1) ind |= MACH64_TEX1_BIT; if (newinputs & VERT_BIT_FOG) ind |= MACH64_FOG_BIT; if (mmesa->SetupIndex & MACH64_PTEX_BIT) ind = ~0; ind &= mmesa->SetupIndex; if (ind) { setup_tab[ind].emit( ctx, start, count, v, stride ); } } }
void mach64CheckTexSizes( GLcontext *ctx ) { mach64ContextPtr mmesa = MACH64_CONTEXT( ctx ); if (!setup_tab[mmesa->SetupIndex].check_tex_sizes(ctx)) { TNLcontext *tnl = TNL_CONTEXT(ctx); /* Invalidate stored verts */ mmesa->SetupNewInputs = ~0; mmesa->SetupIndex |= MACH64_PTEX_BIT; if (!mmesa->Fallback && !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { tnl->Driver.Render.Interp = setup_tab[mmesa->SetupIndex].interp; tnl->Driver.Render.CopyPV = setup_tab[mmesa->SetupIndex].copy_pv; } } }
/* Send all commands to the hardware. If vertex buffers or indirect * buffers are in use, then we need to make sure they are sent to the * hardware. All commands that are normally sent to the ring are * already considered `flushed'. */ static void mach64DDFlush( GLcontext *ctx ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); LOCK_HARDWARE( mmesa ); FLUSH_DMA_LOCKED( mmesa ); UNLOCK_HARDWARE( mmesa ); #if ENABLE_PERF_BOXES if ( mmesa->boxes ) { LOCK_HARDWARE( mmesa ); mach64PerformanceBoxesLocked( mmesa ); UNLOCK_HARDWARE( mmesa ); } /* Log the performance counters if necessary */ mach64PerformanceCounters( mmesa ); #endif }
void mach64ChooseVertexState( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); mach64ContextPtr mmesa = MACH64_CONTEXT( ctx ); GLuint ind = MACH64_XYZW_BIT|MACH64_RGBA_BIT; if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) ind |= MACH64_SPEC_BIT; if (ctx->Fog.Enabled) ind |= MACH64_FOG_BIT; if (ctx->Texture._EnabledUnits) { ind |= MACH64_TEX0_BIT; if (ctx->Texture.Unit[0]._ReallyEnabled && ctx->Texture.Unit[1]._ReallyEnabled) { ind |= MACH64_TEX1_BIT; } } mmesa->SetupIndex = ind; if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) { tnl->Driver.Render.Interp = mach64_interp_extras; tnl->Driver.Render.CopyPV = mach64_copy_pv_extras; } else { tnl->Driver.Render.Interp = setup_tab[ind].interp; tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv; } #if 0 if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) { mach64PrintSetupFlags( __FUNCTION__, ind ); } #endif if (setup_tab[ind].vertex_format != mmesa->vertex_format) { FLUSH_BATCH(mmesa); mmesa->vertex_format = setup_tab[ind].vertex_format; mmesa->vertex_size = setup_tab[ind].vertex_size; } }
/* Force the context `c' to be the current context and associate with it * buffer `b'. */ GLboolean mach64MakeCurrent( __DRIcontext *driContextPriv, __DRIdrawable *driDrawPriv, __DRIdrawable *driReadPriv ) { if ( driContextPriv ) { GET_CURRENT_CONTEXT(ctx); mach64ContextPtr oldMach64Ctx = ctx ? MACH64_CONTEXT(ctx) : NULL; mach64ContextPtr newMach64Ctx = (mach64ContextPtr) driContextPriv->driverPrivate; if ( newMach64Ctx != oldMach64Ctx ) { newMach64Ctx->new_state |= MACH64_NEW_CONTEXT; newMach64Ctx->dirty = MACH64_UPLOAD_ALL; } if ( newMach64Ctx->driDrawable != driDrawPriv ) { if (driDrawPriv->swap_interval == (unsigned)-1) { driDrawPriv->vblFlags = (newMach64Ctx->do_irqs) ? driGetDefaultVBlankFlags(&newMach64Ctx->optionCache) : VBLANK_FLAG_NO_IRQ; driDrawableInitVBlank( driDrawPriv ); } newMach64Ctx->driDrawable = driDrawPriv; mach64CalcViewport( newMach64Ctx->glCtx ); } _mesa_make_current( newMach64Ctx->glCtx, (GLframebuffer *) driDrawPriv->driverPrivate, (GLframebuffer *) driReadPriv->driverPrivate ); newMach64Ctx->new_state |= MACH64_NEW_CLIP; } else { _mesa_make_current( NULL, NULL, NULL ); } return GL_TRUE; }
/* Return various strings for glGetString(). */ static const GLubyte *mach64DDGetString( GLcontext *ctx, GLenum name ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); static char buffer[128]; unsigned offset; const char * card_name = "Mach64 [Rage Pro]"; GLuint agp_mode = mmesa->mach64Screen->IsPCI ? 0 : mmesa->mach64Screen->AGPMode; switch ( name ) { case GL_VENDOR: return (GLubyte*)"Gareth Hughes, Leif Delgass, José Fonseca"; case GL_RENDERER: offset = driGetRendererString( buffer, card_name, DRIVER_DATE, agp_mode ); return (GLubyte *)buffer; default: return NULL; } }
/* Force the context `c' to be the current context and associate with it * buffer `b'. */ GLboolean mach64MakeCurrent( __DRIcontextPrivate *driContextPriv, __DRIdrawablePrivate *driDrawPriv, __DRIdrawablePrivate *driReadPriv ) { if ( driContextPriv ) { GET_CURRENT_CONTEXT(ctx); mach64ContextPtr oldMach64Ctx = ctx ? MACH64_CONTEXT(ctx) : NULL; mach64ContextPtr newMach64Ctx = (mach64ContextPtr) driContextPriv->driverPrivate; if ( newMach64Ctx != oldMach64Ctx ) { newMach64Ctx->new_state |= MACH64_NEW_CONTEXT; newMach64Ctx->dirty = MACH64_UPLOAD_ALL; } driDrawableInitVBlank( driDrawPriv, newMach64Ctx->vblank_flags, &newMach64Ctx->vbl_seq ); if ( newMach64Ctx->driDrawable != driDrawPriv ) { newMach64Ctx->driDrawable = driDrawPriv; mach64CalcViewport( newMach64Ctx->glCtx ); } _mesa_make_current( newMach64Ctx->glCtx, (GLframebuffer *) driDrawPriv->driverPrivate, (GLframebuffer *) driReadPriv->driverPrivate ); newMach64Ctx->new_state |= MACH64_NEW_CLIP; } else { _mesa_make_current( NULL, NULL, NULL ); } return GL_TRUE; }
/* Called by the _mesa_store_teximage[123]d() functions. */ static gl_format mach64ChooseTextureFormat( struct gl_context *ctx, GLint internalFormat, GLenum format, GLenum type ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); (void) format; (void) type; switch ( internalFormat ) { case GL_ALPHA: case GL_ALPHA4: case GL_ALPHA8: case GL_ALPHA12: case GL_ALPHA16: case GL_COMPRESSED_ALPHA: case 2: case GL_LUMINANCE_ALPHA: case GL_LUMINANCE4_ALPHA4: case GL_LUMINANCE6_ALPHA2: case GL_LUMINANCE8_ALPHA8: case GL_LUMINANCE12_ALPHA4: case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: case GL_COMPRESSED_LUMINANCE_ALPHA: case 4: case GL_RGBA: case GL_RGBA2: case GL_COMPRESSED_RGBA: if (mmesa->mach64Screen->cpp == 4) return MESA_FORMAT_ARGB8888; else return MESA_FORMAT_ARGB4444; case GL_RGB5_A1: if (mmesa->mach64Screen->cpp == 4) return MESA_FORMAT_ARGB8888; else return MESA_FORMAT_ARGB1555; case GL_RGBA8: case GL_RGB10_A2: case GL_RGBA12: case GL_RGBA16: case GL_RGBA4: if (mmesa->mach64Screen->cpp == 4) return MESA_FORMAT_ARGB8888; else return MESA_FORMAT_ARGB4444; case 3: case GL_RGB: case GL_R3_G3_B2: case GL_RGB4: case GL_RGB5: case GL_RGB8: case GL_RGB10: case GL_RGB12: case GL_RGB16: case GL_COMPRESSED_RGB: if (mmesa->mach64Screen->cpp == 4) return MESA_FORMAT_ARGB8888; else return MESA_FORMAT_RGB565; case 1: case GL_LUMINANCE: case GL_LUMINANCE4: case GL_LUMINANCE8: case GL_LUMINANCE12: case GL_LUMINANCE16: case GL_COMPRESSED_LUMINANCE: if (mmesa->mach64Screen->cpp == 4) return MESA_FORMAT_ARGB8888; /* inefficient but accurate */ else return MESA_FORMAT_ARGB1555; case GL_INTENSITY4: case GL_INTENSITY: case GL_INTENSITY8: case GL_INTENSITY12: case GL_INTENSITY16: case GL_COMPRESSED_INTENSITY: if (mmesa->mach64Screen->cpp == 4) return MESA_FORMAT_ARGB8888; /* inefficient but accurate */ else return MESA_FORMAT_ARGB4444; case GL_COLOR_INDEX: case GL_COLOR_INDEX1_EXT: case GL_COLOR_INDEX2_EXT: case GL_COLOR_INDEX4_EXT: case GL_COLOR_INDEX8_EXT: case GL_COLOR_INDEX12_EXT: case GL_COLOR_INDEX16_EXT: return MESA_FORMAT_CI8; case GL_YCBCR_MESA: if (type == GL_UNSIGNED_SHORT_8_8_APPLE || type == GL_UNSIGNED_BYTE) return MESA_FORMAT_YCBCR; else return MESA_FORMAT_YCBCR_REV; default: _mesa_problem( ctx, "unexpected format in %s", __FUNCTION__ ); return MESA_FORMAT_NONE; } }
static void mach64UpdateTextureUnit( GLcontext *ctx, int unit ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); int source = mmesa->tmu_source[unit]; const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; const struct gl_texture_object *tObj = ctx->Texture.Unit[source]._Current; mach64TexObjPtr t = tObj->DriverData; GLuint d = mmesa->setup.dp_pix_width; GLuint s = mmesa->setup.scale_3d_cntl; assert(unit == 0 || unit == 1); /* only two tex units */ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { fprintf( stderr, "%s( %p, %d ) enabled=0x%x 0x%x\n", __FUNCTION__, ctx, unit, ctx->Texture.Unit[0]._ReallyEnabled, ctx->Texture.Unit[1]._ReallyEnabled); } if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) { assert(t); /* should have driver tex data by now */ /* Fallback if there's a texture border */ if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) { FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); return; } /* Upload teximages */ if (t->base.dirty_images[0]) { mach64SetTexImages( mmesa, tObj ); mmesa->dirty |= (MACH64_UPLOAD_TEX0IMAGE << unit); } /* Bind to the given texture unit */ mmesa->CurrentTexObj[unit] = t; t->base.bound |= (1 << unit); if ( t->base.memBlock ) driUpdateTextureLRU( (driTextureObject *) t ); /* XXX: should be locked! */ /* register setup */ if ( unit == 0 ) { d &= ~MACH64_SCALE_PIX_WIDTH_MASK; d |= (t->textureFormat << 28); s &= ~(MACH64_TEXTURE_DISABLE | MACH64_TEX_CACHE_SPLIT | MACH64_TEX_BLEND_FCN_MASK | MACH64_TEX_MAP_AEN); if ( mmesa->multitex ) { s |= MACH64_TEX_BLEND_FCN_TRILINEAR | MACH64_TEX_CACHE_SPLIT; } else if ( t->BilinearMin ) { s |= MACH64_TEX_BLEND_FCN_LINEAR; } else { s |= MACH64_TEX_BLEND_FCN_NEAREST; } if ( t->BilinearMag ) { s |= MACH64_BILINEAR_TEX_EN; } else { s &= ~MACH64_BILINEAR_TEX_EN; } if ( t->hasAlpha ) { s |= MACH64_TEX_MAP_AEN; } mmesa->setup.tex_cntl &= ~(MACH64_TEXTURE_CLAMP_S | MACH64_TEXTURE_CLAMP_T | MACH64_SECONDARY_STW); if ( t->ClampS ) { mmesa->setup.tex_cntl |= MACH64_TEXTURE_CLAMP_S; } if ( t->ClampT ) { mmesa->setup.tex_cntl |= MACH64_TEXTURE_CLAMP_T; } mmesa->setup.tex_size_pitch |= ((t->widthLog2 << 0) | (t->maxLog2 << 4) | (t->heightLog2 << 8)); } else { /* Enable texture mapping mode */ s &= ~MACH64_TEXTURE_DISABLE; d &= ~MACH64_COMPOSITE_PIX_WIDTH_MASK; d |= (t->textureFormat << 4); mmesa->setup.tex_cntl &= ~(MACH64_COMP_ALPHA | MACH64_SEC_TEX_CLAMP_S | MACH64_SEC_TEX_CLAMP_T); mmesa->setup.tex_cntl |= (MACH64_TEXTURE_COMPOSITE | MACH64_SECONDARY_STW); if ( t->BilinearMin ) { mmesa->setup.tex_cntl |= MACH64_COMP_BLEND_BILINEAR; } else { mmesa->setup.tex_cntl &= ~MACH64_COMP_BLEND_BILINEAR; } if ( t->BilinearMag ) { mmesa->setup.tex_cntl |= MACH64_COMP_FILTER_BILINEAR; } else { mmesa->setup.tex_cntl &= ~MACH64_COMP_FILTER_BILINEAR; } if ( t->hasAlpha ) { mmesa->setup.tex_cntl |= MACH64_COMP_ALPHA; } if ( t->ClampS ) { mmesa->setup.tex_cntl |= MACH64_SEC_TEX_CLAMP_S; } if ( t->ClampT ) { mmesa->setup.tex_cntl |= MACH64_SEC_TEX_CLAMP_T; } mmesa->setup.tex_size_pitch |= ((t->widthLog2 << 16) | (t->maxLog2 << 20) | (t->heightLog2 << 24)); } if ( mmesa->setup.scale_3d_cntl != s ) { mmesa->setup.scale_3d_cntl = s; mmesa->dirty |= MACH64_UPLOAD_SCALE_3D_CNTL; } if ( mmesa->setup.dp_pix_width != d ) { mmesa->setup.dp_pix_width = d; mmesa->dirty |= MACH64_UPLOAD_DP_PIX_WIDTH; } } else if (texUnit->_ReallyEnabled) { /* 3D or cube map texture enabled - fallback */ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); } else { /* texture unit disabled */ } }
static void mach64SpanRenderStart( GLcontext *ctx ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); LOCK_HARDWARE( mmesa ); FINISH_DMA_LOCKED( mmesa ); }
static void mach64UpdateTextureEnv( GLcontext *ctx, int unit ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); GLint source = mmesa->tmu_source[unit]; const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source]; const struct gl_texture_object *tObj = texUnit->_Current; const GLenum format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; GLuint s = mmesa->setup.scale_3d_cntl; if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) { fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, ctx, unit ); } /* REPLACE MODULATE DECAL GL_BLEND * * ALPHA C = Cf C = Cf undef C = Cf * A = At A = AfAt A = AfAt * * LUMINANCE C = Ct C = CfCt undef C = Cf(1-Ct)+CcCt * A = Af A = Af A = Af * * LUMINANCE_ALPHA C = Ct C = CfCt undef C = Cf(1-Ct)+CcCt * A = At A = AfAt A = AfAt * * INTENSITY C = Ct C = CfCt undef C = Cf(1-Ct)+CcCt * A = At A = AfAt A = Af(1-At)+AcAt * * RGB C = Ct C = CfCt C = Ct C = Cf(1-Ct)+CcCt * A = Af A = Af A = Af A = Af * * RGBA C = Ct C = CfCt C = Cf(1-At)+CtAt C = Cf(1-Ct)+CcCt * A = At A = AfAt A = Af A = AfAt */ if ( unit == 0 ) { s &= ~MACH64_TEX_LIGHT_FCN_MASK; /* Set the texture environment state * Need to verify these are working correctly, but the * texenv Mesa demo seems to work. */ switch ( texUnit->EnvMode ) { case GL_REPLACE: switch ( format ) { case GL_ALPHA: case GL_LUMINANCE_ALPHA: case GL_INTENSITY: /* Not compliant - can't get At */ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); s |= MACH64_TEX_LIGHT_FCN_MODULATE; break; default: s |= MACH64_TEX_LIGHT_FCN_REPLACE; } break; case GL_MODULATE: switch ( format ) { case GL_ALPHA: FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); s |= MACH64_TEX_LIGHT_FCN_MODULATE; break; case GL_RGB: case GL_LUMINANCE: /* These should be compliant */ s |= MACH64_TEX_LIGHT_FCN_MODULATE; break; case GL_LUMINANCE_ALPHA: case GL_INTENSITY: FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); s |= MACH64_TEX_LIGHT_FCN_MODULATE; break; case GL_RGBA: /* Should fallback when blending enabled for complete compliance */ s |= MACH64_TEX_LIGHT_FCN_MODULATE; break; default: s |= MACH64_TEX_LIGHT_FCN_MODULATE; } break; case GL_DECAL: switch ( format ) { case GL_RGBA: s |= MACH64_TEX_LIGHT_FCN_ALPHA_DECAL; break; case GL_RGB: s |= MACH64_TEX_LIGHT_FCN_REPLACE; break; case GL_ALPHA: case GL_LUMINANCE_ALPHA: /* undefined - disable texturing, pass fragment unmodified */ /* Also, pass fragment alpha instead of texture alpha */ s &= ~MACH64_TEX_MAP_AEN; s |= MACH64_TEXTURE_DISABLE; s |= MACH64_TEX_LIGHT_FCN_MODULATE; break; case GL_LUMINANCE: case GL_INTENSITY: /* undefined - disable texturing, pass fragment unmodified */ s |= MACH64_TEXTURE_DISABLE; s |= MACH64_TEX_LIGHT_FCN_MODULATE; break; default: s |= MACH64_TEX_LIGHT_FCN_MODULATE; } break; case GL_BLEND: /* GL_BLEND not supported by RagePRO, use software */ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); s |= MACH64_TEX_LIGHT_FCN_MODULATE; break; case GL_ADD: case GL_COMBINE: FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); s |= MACH64_TEX_LIGHT_FCN_MODULATE; break; default: s |= MACH64_TEX_LIGHT_FCN_MODULATE; } if ( mmesa->setup.scale_3d_cntl != s ) { mmesa->setup.scale_3d_cntl = s; mmesa->dirty |= MACH64_UPLOAD_SCALE_3D_CNTL; } } else { /* blend = 0, modulate = 1 - initialize to blend */ mmesa->setup.tex_cntl &= ~MACH64_COMP_COMBINE_MODULATE; /* Set the texture composite function for multitexturing*/ switch ( texUnit->EnvMode ) { case GL_BLEND: /* GL_BLEND not supported by RagePRO, use software */ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; break; case GL_MODULATE: /* Should fallback when blending enabled for complete compliance */ mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; break; case GL_REPLACE: switch ( format ) { case GL_ALPHA: mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; break; default: /* not supported by RagePRO */ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; } break; case GL_DECAL: switch ( format ) { case GL_ALPHA: case GL_LUMINANCE: case GL_LUMINANCE_ALPHA: case GL_INTENSITY: /* undefined, disable compositing and pass fragment unmodified */ mmesa->setup.tex_cntl &= ~MACH64_TEXTURE_COMPOSITE; break; default: /* not supported by RagePRO */ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; } break; case GL_ADD: case GL_COMBINE: FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE ); mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; break; default: mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE; } } }
static void mach64SpanRenderFinish( GLcontext *ctx ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); _swrast_flush( ctx ); UNLOCK_HARDWARE( mmesa ); }
/* Called by the _mesa_store_teximage[123]d() functions. */ static const struct gl_texture_format * mach64ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, GLenum format, GLenum type ) { mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); (void) format; (void) type; switch ( internalFormat ) { case GL_ALPHA: case GL_ALPHA4: case GL_ALPHA8: case GL_ALPHA12: case GL_ALPHA16: case 2: case GL_LUMINANCE_ALPHA: case GL_LUMINANCE4_ALPHA4: case GL_LUMINANCE6_ALPHA2: case GL_LUMINANCE8_ALPHA8: case GL_LUMINANCE12_ALPHA4: case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: case 4: case GL_RGBA: case GL_RGBA2: if (mmesa->mach64Screen->cpp == 4) return &_mesa_texformat_argb8888; else return &_mesa_texformat_argb4444; case GL_RGB5_A1: if (mmesa->mach64Screen->cpp == 4) return &_mesa_texformat_argb8888; else return &_mesa_texformat_argb1555; case GL_RGBA8: case GL_RGB10_A2: case GL_RGBA12: case GL_RGBA16: case GL_RGBA4: if (mmesa->mach64Screen->cpp == 4) return &_mesa_texformat_argb8888; else return &_mesa_texformat_argb4444; case 3: case GL_RGB: case GL_R3_G3_B2: case GL_RGB4: case GL_RGB5: case GL_RGB8: case GL_RGB10: case GL_RGB12: case GL_RGB16: if (mmesa->mach64Screen->cpp == 4) return &_mesa_texformat_argb8888; else return &_mesa_texformat_rgb565; case 1: case GL_LUMINANCE: case GL_LUMINANCE4: case GL_LUMINANCE8: case GL_LUMINANCE12: case GL_LUMINANCE16: if (mmesa->mach64Screen->cpp == 4) return &_mesa_texformat_argb8888; /* inefficient but accurate */ else return &_mesa_texformat_argb1555; case GL_INTENSITY4: case GL_INTENSITY: case GL_INTENSITY8: case GL_INTENSITY12: case GL_INTENSITY16: if (mmesa->mach64Screen->cpp == 4) return &_mesa_texformat_argb8888; /* inefficient but accurate */ else return &_mesa_texformat_argb4444; case GL_COLOR_INDEX: case GL_COLOR_INDEX1_EXT: case GL_COLOR_INDEX2_EXT: case GL_COLOR_INDEX4_EXT: case GL_COLOR_INDEX8_EXT: case GL_COLOR_INDEX12_EXT: case GL_COLOR_INDEX16_EXT: return &_mesa_texformat_ci8; case GL_YCBCR_MESA: if (type == GL_UNSIGNED_SHORT_8_8_APPLE || type == GL_UNSIGNED_BYTE) return &_mesa_texformat_ycbcr; else return &_mesa_texformat_ycbcr_rev; default: _mesa_problem( ctx, "unexpected format in %s", __FUNCTION__ ); return NULL; } }