/shark/trunk/ports/mesa/src/texformat_tmp.h |
---|
File deleted |
/shark/trunk/ports/mesa/src/tnl/t_vb_texgen.c |
---|
File deleted |
/shark/trunk/ports/mesa/src/tnl/t_array_import.c |
---|
File deleted |
/shark/trunk/ports/mesa/src/tnl/t_array_import.h |
---|
File deleted |
/shark/trunk/ports/mesa/src/tnl/t_vb_gentex.c |
---|
0,0 → 1,692 |
/* $Id: t_vb_gentex.c,v 1.1 2003-04-24 14:24:01 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
* Version: 3.5 |
* |
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the "Software"), |
* to deal in the Software without restriction, including without limitation |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
* and/or sell copies of the Software, and to permit persons to whom the |
* Software is furnished to do so, subject to the following conditions: |
* |
* The above copyright notice and this permission notice shall be included |
* in all copies or substantial portions of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
* |
* Authors: |
* Brian Paul |
* Keith Whitwell <keith@tungstengraphics.com> |
*/ |
#include "glheader.h" |
#include "colormac.h" |
#include "context.h" |
#include "macros.h" |
#include "mmath.h" |
#include "imports.h" |
#include "mtypes.h" |
#include "math/m_xform.h" |
#include "t_context.h" |
#include "t_pipeline.h" |
/*********************************************************************** |
* Automatic texture coordinate generation (texgen) code. |
*/ |
struct texgen_stage_data; |
typedef void (*texgen_func)( GLcontext *ctx, |
struct texgen_stage_data *store, |
GLuint unit); |
struct texgen_stage_data { |
/* Per-texunit derived state. |
*/ |
GLuint TexgenSize[MAX_TEXTURE_UNITS]; |
GLuint TexgenHoles[MAX_TEXTURE_UNITS]; |
texgen_func TexgenFunc[MAX_TEXTURE_UNITS]; |
/* Temporary values used in texgen. |
*/ |
GLfloat (*tmp_f)[3]; |
GLfloat *tmp_m; |
/* Buffered outputs of the stage. |
*/ |
GLvector4f texcoord[MAX_TEXTURE_UNITS]; |
}; |
#define TEXGEN_STAGE_DATA(stage) ((struct texgen_stage_data *)stage->privatePtr) |
static GLuint all_bits[5] = { |
0, |
VEC_SIZE_1, |
VEC_SIZE_2, |
VEC_SIZE_3, |
VEC_SIZE_4, |
}; |
#define VEC_SIZE_FLAGS (VEC_SIZE_1|VEC_SIZE_2|VEC_SIZE_3|VEC_SIZE_4) |
#define TEXGEN_NEED_M (TEXGEN_SPHERE_MAP) |
#define TEXGEN_NEED_F (TEXGEN_SPHERE_MAP | \ |
TEXGEN_REFLECTION_MAP_NV) |
static void build_m3( GLfloat f[][3], GLfloat m[], |
const GLvector4f *normal, |
const GLvector4f *eye ) |
{ |
GLuint stride = eye->stride; |
GLfloat *coord = (GLfloat *)eye->start; |
GLuint count = eye->count; |
const GLfloat *norm = normal->start; |
GLuint i; |
for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(norm,normal->stride)) { |
GLfloat u[3], two_nu, fx, fy, fz; |
COPY_3V( u, coord ); |
NORMALIZE_3FV( u ); |
two_nu = 2.0F * DOT3(norm,u); |
fx = f[i][0] = u[0] - norm[0] * two_nu; |
fy = f[i][1] = u[1] - norm[1] * two_nu; |
fz = f[i][2] = u[2] - norm[2] * two_nu; |
m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); |
if (m[i] != 0.0F) { |
m[i] = 0.5F / (GLfloat) GL_SQRT(m[i]); |
} |
} |
} |
static void build_m2( GLfloat f[][3], GLfloat m[], |
const GLvector4f *normal, |
const GLvector4f *eye ) |
{ |
GLuint stride = eye->stride; |
GLfloat *coord = eye->start; |
GLuint count = eye->count; |
GLfloat *norm = normal->start; |
GLuint i; |
for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(norm,normal->stride)) { |
GLfloat u[3], two_nu, fx, fy, fz; |
COPY_2V( u, coord ); |
u[2] = 0; |
NORMALIZE_3FV( u ); |
two_nu = 2.0F * DOT3(norm,u); |
fx = f[i][0] = u[0] - norm[0] * two_nu; |
fy = f[i][1] = u[1] - norm[1] * two_nu; |
fz = f[i][2] = u[2] - norm[2] * two_nu; |
m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); |
if (m[i] != 0.0F) { |
m[i] = 0.5F / (GLfloat) GL_SQRT(m[i]); |
} |
} |
} |
typedef void (*build_m_func)( GLfloat f[][3], |
GLfloat m[], |
const GLvector4f *normal, |
const GLvector4f *eye ); |
static build_m_func build_m_tab[5] = { |
0, |
0, |
build_m2, |
build_m3, |
build_m3 |
}; |
/* This is unusual in that we respect the stride of the output vector |
* (f). This allows us to pass in either a texcoord vector4f, or a |
* temporary vector3f. |
*/ |
static void build_f3( GLfloat *f, |
GLuint fstride, |
const GLvector4f *normal, |
const GLvector4f *eye ) |
{ |
GLuint stride = eye->stride; |
GLfloat *coord = eye->start; |
GLuint count = eye->count; |
GLfloat *norm = normal->start; |
GLuint i; |
for (i=0;i<count;i++) { |
GLfloat u[3], two_nu; |
COPY_3V( u, coord ); |
NORMALIZE_3FV( u ); |
two_nu = 2.0F * DOT3(norm,u); |
f[0] = u[0] - norm[0] * two_nu; |
f[1] = u[1] - norm[1] * two_nu; |
f[2] = u[2] - norm[2] * two_nu; |
STRIDE_F(coord,stride); |
STRIDE_F(f,fstride); |
STRIDE_F(norm, normal->stride); |
} |
} |
static void build_f2( GLfloat *f, |
GLuint fstride, |
const GLvector4f *normal, |
const GLvector4f *eye ) |
{ |
GLuint stride = eye->stride; |
GLfloat *coord = eye->start; |
GLuint count = eye->count; |
GLfloat *norm = normal->start; |
GLuint i; |
for (i=0;i<count;i++) { |
GLfloat u[3], two_nu; |
COPY_2V( u, coord ); |
u[2] = 0; |
NORMALIZE_3FV( u ); |
two_nu = 2.0F * DOT3(norm,u); |
f[0] = u[0] - norm[0] * two_nu; |
f[1] = u[1] - norm[1] * two_nu; |
f[2] = u[2] - norm[2] * two_nu; |
STRIDE_F(coord,stride); |
STRIDE_F(f,fstride); |
STRIDE_F(norm, normal->stride); |
} |
} |
typedef void (*build_f_func)( GLfloat *f, |
GLuint fstride, |
const GLvector4f *normal_vec, |
const GLvector4f *eye ); |
/* Just treat 4-vectors as 3-vectors. |
*/ |
static build_f_func build_f_tab[5] = { |
0, |
0, |
build_f2, |
build_f3, |
build_f3 |
}; |
/* Special case texgen functions. |
*/ |
static void texgen_reflection_map_nv( GLcontext *ctx, |
struct texgen_stage_data *store, |
GLuint unit ) |
{ |
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
GLvector4f *in = VB->TexCoordPtr[unit]; |
GLvector4f *out = &store->texcoord[unit]; |
build_f_tab[VB->EyePtr->size]( out->start, |
out->stride, |
VB->NormalPtr, |
VB->EyePtr ); |
if (in) { |
out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3; |
out->count = in->count; |
out->size = MAX2(in->size, 3); |
if (in->size == 4) |
_mesa_copy_tab[0x8]( out, in ); |
} |
else { |
out->flags |= VEC_SIZE_3; |
out->size = 3; |
out->count = in->count; |
} |
} |
static void texgen_normal_map_nv( GLcontext *ctx, |
struct texgen_stage_data *store, |
GLuint unit ) |
{ |
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
GLvector4f *in = VB->TexCoordPtr[unit]; |
GLvector4f *out = &store->texcoord[unit]; |
GLvector4f *normal = VB->NormalPtr; |
GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->start; |
GLuint count = VB->Count; |
GLuint i; |
const GLfloat *norm = normal->start; |
for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) { |
texcoord[i][0] = norm[0]; |
texcoord[i][1] = norm[1]; |
texcoord[i][2] = norm[2]; |
} |
if (in) { |
out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3; |
out->count = in->count; |
out->size = MAX2(in->size, 3); |
if (in->size == 4) |
_mesa_copy_tab[0x8]( out, in ); |
} |
else { |
out->flags |= VEC_SIZE_3; |
out->size = 3; |
out->count = in->count; |
} |
} |
static void texgen_sphere_map( GLcontext *ctx, |
struct texgen_stage_data *store, |
GLuint unit ) |
{ |
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
GLvector4f *in = VB->TexCoordPtr[unit]; |
GLvector4f *out = &store->texcoord[unit]; |
GLfloat (*texcoord)[4] = (GLfloat (*)[4]) out->start; |
GLuint count = VB->Count; |
GLuint i; |
GLfloat (*f)[3] = store->tmp_f; |
GLfloat *m = store->tmp_m; |
/* _mesa_debug(NULL, "%s normstride %d eyestride %d\n", */ |
/* __FUNCTION__, VB->NormalPtr->stride, */ |
/* VB->EyePtr->stride); */ |
(build_m_tab[VB->EyePtr->size])( store->tmp_f, |
store->tmp_m, |
VB->NormalPtr, |
VB->EyePtr ); |
for (i=0;i<count;i++) { |
texcoord[i][0] = f[i][0] * m[i] + 0.5F; |
texcoord[i][1] = f[i][1] * m[i] + 0.5F; |
} |
if (in) { |
out->size = MAX2(in->size,2); |
out->count = in->count; |
out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_2; |
if (in->size > 2) |
_mesa_copy_tab[all_bits[in->size] & ~0x3]( out, in ); |
} else { |
out->size = 2; |
out->flags |= VEC_SIZE_2; |
out->count = in->count; |
} |
} |
static void texgen( GLcontext *ctx, |
struct texgen_stage_data *store, |
GLuint unit ) |
{ |
TNLcontext *tnl = TNL_CONTEXT(ctx); |
struct vertex_buffer *VB = &tnl->vb; |
GLvector4f *in = VB->TexCoordPtr[unit]; |
GLvector4f *out = &store->texcoord[unit]; |
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; |
const GLvector4f *obj = VB->ObjPtr; |
const GLvector4f *eye = VB->EyePtr; |
const GLvector4f *normal = VB->NormalPtr; |
GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->data; |
GLfloat *indata; |
GLuint count = VB->Count; |
GLfloat (*f)[3] = store->tmp_f; |
GLfloat *m = store->tmp_m; |
GLuint holes = 0; |
if (texUnit->_GenFlags & TEXGEN_NEED_M) { |
build_m_tab[in->size]( store->tmp_f, store->tmp_m, normal, eye ); |
} else if (texUnit->_GenFlags & TEXGEN_NEED_F) { |
build_f_tab[in->size]( (GLfloat *)store->tmp_f, 3, normal, eye ); |
} |
if (!in) { |
ASSERT(0); |
in = out; |
in->count = VB->Count; |
out->size = store->TexgenSize[unit]; |
out->flags |= texUnit->TexGenEnabled; |
out->count = VB->Count; |
holes = store->TexgenHoles[unit]; |
} |
else { |
GLuint copy = (all_bits[in->size] & ~texUnit->TexGenEnabled); |
if (copy) |
_mesa_copy_tab[copy]( out, in ); |
out->size = MAX2(in->size, store->TexgenSize[unit]); |
out->flags |= (in->flags & VEC_SIZE_FLAGS) | texUnit->TexGenEnabled; |
out->count = in->count; |
holes = ~all_bits[in->size] & store->TexgenHoles[unit]; |
} |
if (holes) { |
if (holes & VEC_DIRTY_2) _mesa_vector4f_clean_elem(out, count, 2); |
if (holes & VEC_DIRTY_1) _mesa_vector4f_clean_elem(out, count, 1); |
if (holes & VEC_DIRTY_0) _mesa_vector4f_clean_elem(out, count, 0); |
} |
if (texUnit->TexGenEnabled & S_BIT) { |
GLuint i; |
switch (texUnit->GenModeS) { |
case GL_OBJECT_LINEAR: |
_mesa_dotprod_tab[obj->size]( (GLfloat *)out->data, |
sizeof(out->data[0]), obj, |
texUnit->ObjectPlaneS ); |
break; |
case GL_EYE_LINEAR: |
_mesa_dotprod_tab[eye->size]( (GLfloat *)out->data, |
sizeof(out->data[0]), eye, |
texUnit->EyePlaneS ); |
break; |
case GL_SPHERE_MAP: |
for (indata=in->start,i=0 ; i<count ;i++, STRIDE_F(indata,in->stride)) |
texcoord[i][0] = indata[0] * m[i] + 0.5F; |
break; |
case GL_REFLECTION_MAP_NV: |
for (i=0;i<count;i++) |
texcoord[i][0] = f[i][0]; |
break; |
case GL_NORMAL_MAP_NV: { |
const GLfloat *norm = normal->start; |
for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) { |
texcoord[i][0] = norm[0]; |
} |
break; |
} |
default: |
_mesa_problem(ctx, "Bad S texgen"); |
} |
} |
if (texUnit->TexGenEnabled & T_BIT) { |
GLuint i; |
switch (texUnit->GenModeT) { |
case GL_OBJECT_LINEAR: |
_mesa_dotprod_tab[obj->size]( &(out->data[0][1]), |
sizeof(out->data[0]), obj, |
texUnit->ObjectPlaneT ); |
break; |
case GL_EYE_LINEAR: |
_mesa_dotprod_tab[eye->size]( &(out->data[0][1]), |
sizeof(out->data[0]), eye, |
texUnit->EyePlaneT ); |
break; |
case GL_SPHERE_MAP: |
for (indata=in->start,i=0; i<count ;i++,STRIDE_F(indata,in->stride)) |
texcoord[i][1] = indata[1] * m[i] + 0.5F; |
break; |
case GL_REFLECTION_MAP_NV: |
for (i=0;i<count;i++) |
texcoord[i][0] = f[i][0]; |
break; |
case GL_NORMAL_MAP_NV: { |
const GLfloat *norm = normal->start; |
for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) { |
texcoord[i][1] = norm[1]; |
} |
break; |
} |
default: |
_mesa_problem(ctx, "Bad T texgen"); |
} |
} |
if (texUnit->TexGenEnabled & R_BIT) { |
GLuint i; |
switch (texUnit->GenModeR) { |
case GL_OBJECT_LINEAR: |
_mesa_dotprod_tab[obj->size]( &(out->data[0][2]), |
sizeof(out->data[0]), obj, |
texUnit->ObjectPlaneR ); |
break; |
case GL_EYE_LINEAR: |
_mesa_dotprod_tab[eye->size]( &(out->data[0][2]), |
sizeof(out->data[0]), eye, |
texUnit->EyePlaneR ); |
break; |
case GL_REFLECTION_MAP_NV: |
for (i=0;i<count;i++) |
texcoord[i][2] = f[i][2]; |
break; |
case GL_NORMAL_MAP_NV: { |
const GLfloat *norm = normal->start; |
for (i=0;i<count;i++,STRIDE_F(norm, normal->stride)) { |
texcoord[i][2] = norm[2]; |
} |
break; |
} |
default: |
_mesa_problem(ctx, "Bad R texgen"); |
} |
} |
if (texUnit->TexGenEnabled & Q_BIT) { |
switch (texUnit->GenModeQ) { |
case GL_OBJECT_LINEAR: |
_mesa_dotprod_tab[obj->size]( &(out->data[0][3]), |
sizeof(out->data[0]), obj, |
texUnit->ObjectPlaneQ ); |
break; |
case GL_EYE_LINEAR: |
_mesa_dotprod_tab[eye->size]( &(out->data[0][3]), |
sizeof(out->data[0]), eye, |
texUnit->EyePlaneQ ); |
break; |
default: |
_mesa_problem(ctx, "Bad Q texgen"); |
} |
} |
} |
static GLboolean run_texgen_stage( GLcontext *ctx, |
struct gl_pipeline_stage *stage ) |
{ |
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
struct texgen_stage_data *store = TEXGEN_STAGE_DATA( stage ); |
GLuint i; |
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) |
if (ctx->Texture._TexGenEnabled & ENABLE_TEXGEN(i)) { |
if (stage->changed_inputs & (VERT_BIT_EYE | VERT_BIT_NORMAL | VERT_BIT_TEX(i))) |
store->TexgenFunc[i]( ctx, store, i ); |
VB->TexCoordPtr[i] = &store->texcoord[i]; |
} |
return GL_TRUE; |
} |
static GLboolean run_validate_texgen_stage( GLcontext *ctx, |
struct gl_pipeline_stage *stage ) |
{ |
struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); |
GLuint i; |
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { |
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; |
if (texUnit->TexGenEnabled) { |
GLuint sz; |
if (texUnit->TexGenEnabled & R_BIT) |
sz = 4; |
else if (texUnit->TexGenEnabled & Q_BIT) |
sz = 3; |
else if (texUnit->TexGenEnabled & T_BIT) |
sz = 2; |
else |
sz = 1; |
store->TexgenSize[i] = sz; |
store->TexgenHoles[i] = (all_bits[sz] & ~texUnit->TexGenEnabled); |
store->TexgenFunc[i] = texgen; |
if (texUnit->TexGenEnabled == (S_BIT|T_BIT|R_BIT)) { |
if (texUnit->_GenFlags == TEXGEN_REFLECTION_MAP_NV) { |
store->TexgenFunc[i] = texgen_reflection_map_nv; |
} |
else if (texUnit->_GenFlags == TEXGEN_NORMAL_MAP_NV) { |
store->TexgenFunc[i] = texgen_normal_map_nv; |
} |
} |
else if (texUnit->TexGenEnabled == (S_BIT|T_BIT) && |
texUnit->_GenFlags == TEXGEN_SPHERE_MAP) { |
store->TexgenFunc[i] = texgen_sphere_map; |
} |
} |
} |
stage->run = run_texgen_stage; |
return stage->run( ctx, stage ); |
} |
static void check_texgen( GLcontext *ctx, struct gl_pipeline_stage *stage ) |
{ |
GLuint i; |
stage->active = 0; |
if (ctx->Texture._TexGenEnabled && !ctx->VertexProgram.Enabled) { |
GLuint inputs = 0; |
GLuint outputs = 0; |
if (ctx->Texture._GenFlags & TEXGEN_OBJ_LINEAR) |
inputs |= VERT_BIT_POS; |
if (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) |
inputs |= VERT_BIT_EYE; |
if (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS) |
inputs |= VERT_BIT_NORMAL; |
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) |
if (ctx->Texture._TexGenEnabled & ENABLE_TEXGEN(i)) |
{ |
outputs |= VERT_BIT_TEX(i); |
/* Need the original input in case it contains a Q coord: |
* (sigh) |
*/ |
inputs |= VERT_BIT_TEX(i); |
/* Something for Feedback? */ |
} |
if (stage->privatePtr) |
stage->run = run_validate_texgen_stage; |
stage->active = 1; |
stage->inputs = inputs; |
stage->outputs = outputs; |
} |
} |
/* Called the first time stage->run() is invoked. |
*/ |
static GLboolean alloc_texgen_data( GLcontext *ctx, |
struct gl_pipeline_stage *stage ) |
{ |
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
struct texgen_stage_data *store; |
GLuint i; |
stage->privatePtr = CALLOC(sizeof(*store)); |
store = TEXGEN_STAGE_DATA(stage); |
if (!store) |
return GL_FALSE; |
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) |
_mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 ); |
store->tmp_f = (GLfloat (*)[3]) MALLOC(VB->Size * sizeof(GLfloat) * 3); |
store->tmp_m = (GLfloat *) MALLOC(VB->Size * sizeof(GLfloat)); |
/* Now validate and run the stage. |
*/ |
stage->run = run_validate_texgen_stage; |
return stage->run( ctx, stage ); |
} |
static void free_texgen_data( struct gl_pipeline_stage *stage ) |
{ |
struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage); |
GLuint i; |
if (store) { |
for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) |
if (store->texcoord[i].data) |
_mesa_vector4f_free( &store->texcoord[i] ); |
if (store->tmp_f) FREE( store->tmp_f ); |
if (store->tmp_m) FREE( store->tmp_m ); |
FREE( store ); |
stage->privatePtr = NULL; |
} |
} |
const struct gl_pipeline_stage _tnl_texgen_stage = |
{ |
"texgen", /* name */ |
_NEW_TEXTURE, /* when to call check() */ |
_NEW_TEXTURE, /* when to invalidate stored data */ |
GL_FALSE, /* active? */ |
0, /* inputs */ |
0, /* outputs */ |
0, /* changed_inputs */ |
NULL, /* private data */ |
free_texgen_data, /* destructor */ |
check_texgen, /* check */ |
alloc_texgen_data /* run -- initially set to alloc data */ |
}; |
/shark/trunk/ports/mesa/src/tnl/t_import_array.c |
---|
0,0 → 1,432 |
/* $Id: t_import_array.c,v 1.1 2003-04-24 14:24:01 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
* Version: 4.1 |
* |
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the "Software"), |
* to deal in the Software without restriction, including without limitation |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
* and/or sell copies of the Software, and to permit persons to whom the |
* Software is furnished to do so, subject to the following conditions: |
* |
* The above copyright notice and this permission notice shall be included |
* in all copies or substantial portions of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
* |
* Authors: |
* Keith Whitwell <keith@tungstengraphics.com> |
*/ |
#include "glheader.h" |
#include "context.h" |
#include "macros.h" |
#include "imports.h" |
#include "mmath.h" |
#include "state.h" |
#include "mtypes.h" |
#include "array_cache/acache.h" |
#include "math/m_translate.h" |
#include "t_import_array.h" |
#include "t_context.h" |
#include "t_imm_debug.h" |
static void _tnl_import_vertex( GLcontext *ctx, |
GLboolean writeable, |
GLboolean stride ) |
{ |
struct gl_client_array *tmp; |
GLboolean is_writeable = 0; |
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; |
tmp = _ac_import_vertex(ctx, |
GL_FLOAT, |
stride ? 4*sizeof(GLfloat) : 0, |
0, |
writeable, |
&is_writeable); |
inputs->Obj.data = (GLfloat (*)[4]) tmp->Ptr; |
inputs->Obj.start = (GLfloat *) tmp->Ptr; |
inputs->Obj.stride = tmp->StrideB; |
inputs->Obj.size = tmp->Size; |
inputs->Obj.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); |
if (inputs->Obj.stride != 4*sizeof(GLfloat)) |
inputs->Obj.flags |= VEC_BAD_STRIDE; |
if (!is_writeable) |
inputs->Obj.flags |= VEC_NOT_WRITEABLE; |
} |
static void _tnl_import_normal( GLcontext *ctx, |
GLboolean writeable, |
GLboolean stride ) |
{ |
struct gl_client_array *tmp; |
GLboolean is_writeable = 0; |
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; |
tmp = _ac_import_normal(ctx, GL_FLOAT, |
stride ? 3*sizeof(GLfloat) : 0, writeable, |
&is_writeable); |
inputs->Normal.data = (GLfloat (*)[4]) tmp->Ptr; |
inputs->Normal.start = (GLfloat *) tmp->Ptr; |
inputs->Normal.stride = tmp->StrideB; |
inputs->Normal.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); |
if (inputs->Normal.stride != 3*sizeof(GLfloat)) |
inputs->Normal.flags |= VEC_BAD_STRIDE; |
if (!is_writeable) |
inputs->Normal.flags |= VEC_NOT_WRITEABLE; |
} |
static void _tnl_import_color( GLcontext *ctx, |
GLenum type, |
GLboolean writeable, |
GLboolean stride ) |
{ |
struct gl_client_array *tmp; |
GLboolean is_writeable = 0; |
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; |
tmp = _ac_import_color(ctx, |
type, |
stride ? 4*sizeof(GLfloat) : 0, |
4, |
writeable, |
&is_writeable); |
inputs->Color = *tmp; |
} |
static void _tnl_import_secondarycolor( GLcontext *ctx, |
GLenum type, |
GLboolean writeable, |
GLboolean stride ) |
{ |
struct gl_client_array *tmp; |
GLboolean is_writeable = 0; |
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; |
tmp = _ac_import_secondarycolor(ctx, |
type, |
stride ? 4*sizeof(GLfloat) : 0, |
4, |
writeable, |
&is_writeable); |
inputs->SecondaryColor = *tmp; |
} |
static void _tnl_import_fogcoord( GLcontext *ctx, |
GLboolean writeable, |
GLboolean stride ) |
{ |
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; |
struct gl_client_array *tmp; |
GLboolean is_writeable = 0; |
tmp = _ac_import_fogcoord(ctx, GL_FLOAT, |
stride ? sizeof(GLfloat) : 0, writeable, |
&is_writeable); |
inputs->FogCoord.data = (GLfloat (*)[4]) tmp->Ptr; |
inputs->FogCoord.start = (GLfloat *) tmp->Ptr; |
inputs->FogCoord.stride = tmp->StrideB; |
inputs->FogCoord.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); |
if (inputs->FogCoord.stride != sizeof(GLfloat)) |
inputs->FogCoord.flags |= VEC_BAD_STRIDE; |
if (!is_writeable) |
inputs->FogCoord.flags |= VEC_NOT_WRITEABLE; |
} |
static void _tnl_import_index( GLcontext *ctx, |
GLboolean writeable, |
GLboolean stride ) |
{ |
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; |
struct gl_client_array *tmp; |
GLboolean is_writeable = 0; |
tmp = _ac_import_index(ctx, GL_UNSIGNED_INT, |
stride ? sizeof(GLuint) : 0, writeable, |
&is_writeable); |
inputs->Index.data = (GLuint *) tmp->Ptr; |
inputs->Index.start = (GLuint *) tmp->Ptr; |
inputs->Index.stride = tmp->StrideB; |
inputs->Index.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); |
if (inputs->Index.stride != sizeof(GLuint)) |
inputs->Index.flags |= VEC_BAD_STRIDE; |
if (!is_writeable) |
inputs->Index.flags |= VEC_NOT_WRITEABLE; |
} |
static void _tnl_import_texcoord( GLcontext *ctx, |
GLuint unit, |
GLboolean writeable, |
GLboolean stride ) |
{ |
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; |
struct gl_client_array *tmp; |
GLboolean is_writeable = 0; |
tmp = _ac_import_texcoord(ctx, unit, GL_FLOAT, |
stride ? 4 * sizeof(GLfloat) : 0, |
0, |
writeable, |
&is_writeable); |
inputs->TexCoord[unit].data = (GLfloat (*)[4]) tmp->Ptr; |
inputs->TexCoord[unit].start = (GLfloat *) tmp->Ptr; |
inputs->TexCoord[unit].stride = tmp->StrideB; |
inputs->TexCoord[unit].size = tmp->Size; |
inputs->TexCoord[unit].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); |
if (inputs->TexCoord[unit].stride != 4*sizeof(GLfloat)) |
inputs->TexCoord[unit].flags |= VEC_BAD_STRIDE; |
if (!is_writeable) |
inputs->TexCoord[unit].flags |= VEC_NOT_WRITEABLE; |
} |
static void _tnl_import_edgeflag( GLcontext *ctx, |
GLboolean writeable, |
GLboolean stride ) |
{ |
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; |
struct gl_client_array *tmp; |
GLboolean is_writeable = 0; |
tmp = _ac_import_edgeflag(ctx, GL_UNSIGNED_BYTE, |
stride ? sizeof(GLubyte) : 0, |
0, |
&is_writeable); |
inputs->EdgeFlag.data = (GLubyte *) tmp->Ptr; |
inputs->EdgeFlag.start = (GLubyte *) tmp->Ptr; |
inputs->EdgeFlag.stride = tmp->StrideB; |
inputs->EdgeFlag.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); |
if (inputs->EdgeFlag.stride != sizeof(GLubyte)) |
inputs->EdgeFlag.flags |= VEC_BAD_STRIDE; |
if (!is_writeable) |
inputs->EdgeFlag.flags |= VEC_NOT_WRITEABLE; |
} |
static void _tnl_import_attrib( GLcontext *ctx, |
GLuint index, |
GLboolean writeable, |
GLboolean stride ) |
{ |
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; |
struct gl_client_array *tmp; |
GLboolean is_writeable = 0; |
tmp = _ac_import_attrib(ctx, index, GL_FLOAT, |
stride ? 4 * sizeof(GLfloat) : 0, |
4, /* want GLfloat[4] */ |
writeable, |
&is_writeable); |
inputs->Attribs[index].data = (GLfloat (*)[4]) tmp->Ptr; |
inputs->Attribs[index].start = (GLfloat *) tmp->Ptr; |
inputs->Attribs[index].stride = tmp->StrideB; |
inputs->Attribs[index].size = tmp->Size; |
inputs->Attribs[index].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); |
if (inputs->Attribs[index].stride != 4 * sizeof(GLfloat)) |
inputs->Attribs[index].flags |= VEC_BAD_STRIDE; |
if (!is_writeable) |
inputs->Attribs[index].flags |= VEC_NOT_WRITEABLE; |
} |
/** |
* Callback for VB stages that need to improve the quality of arrays |
* bound to the VB. This is only necessary for client arrays which |
* have not been transformed at any point in the pipeline. |
* \param required - bitmask of VERT_*_BIT flags |
* \param flags - bitmask of VEC_* flags (ex: VEC_NOT_WRITABLE) |
*/ |
static void _tnl_upgrade_client_data( GLcontext *ctx, |
GLuint required, |
GLuint flags ) |
{ |
GLuint i; |
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; |
GLboolean writeable = (flags & VEC_NOT_WRITEABLE) != 0; |
GLboolean stride = (flags & VEC_BAD_STRIDE) != 0; |
struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; |
GLuint ca_flags = 0; |
(void) inputs; |
if (writeable || stride) ca_flags |= CA_CLIENT_DATA; |
if ((required & VERT_BIT_CLIP) && VB->ClipPtr == VB->ObjPtr) |
required |= VERT_BIT_POS; |
/* _tnl_print_vert_flags("_tnl_upgrade_client_data", required); */ |
if ((required & VERT_BIT_POS) && (VB->ObjPtr->flags & flags)) { |
ASSERT(VB->ObjPtr == &inputs->Obj); |
_tnl_import_vertex( ctx, writeable, stride ); |
VB->importable_data &= ~(VERT_BIT_POS|VERT_BIT_CLIP); |
} |
if ((required & VERT_BIT_NORMAL) && (VB->NormalPtr->flags & flags)) { |
ASSERT(VB->NormalPtr == &inputs->Normal); |
_tnl_import_normal( ctx, writeable, stride ); |
VB->importable_data &= ~VERT_BIT_NORMAL; |
} |
if ((required & VERT_BIT_COLOR0) && (VB->ColorPtr[0]->Flags & ca_flags)) { |
ASSERT(VB->ColorPtr[0] == &inputs->Color); |
_tnl_import_color( ctx, GL_FLOAT, writeable, stride ); |
VB->importable_data &= ~VERT_BIT_COLOR0; |
} |
if ((required & VERT_BIT_COLOR1) && |
(VB->SecondaryColorPtr[0]->Flags & ca_flags)) { |
ASSERT(VB->SecondaryColorPtr[0] == &inputs->SecondaryColor); |
_tnl_import_secondarycolor( ctx, GL_FLOAT, writeable, stride ); |
VB->importable_data &= ~VERT_BIT_COLOR1; |
} |
if ((required & VERT_BIT_FOG) |
&& (VB->FogCoordPtr->flags & flags)) { |
ASSERT(VB->FogCoordPtr == &inputs->FogCoord); |
_tnl_import_fogcoord( ctx, writeable, stride ); |
VB->importable_data &= ~VERT_BIT_FOG; |
} |
if ((required & VERT_BIT_INDEX) && (VB->IndexPtr[0]->flags & flags)) { |
ASSERT(VB->IndexPtr[0] == &inputs->Index); |
_tnl_import_index( ctx, writeable, stride ); |
VB->importable_data &= ~VERT_BIT_INDEX; |
} |
if (required & VERT_BITS_TEX_ANY) |
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) |
if ((required & VERT_BIT_TEX(i)) && (VB->TexCoordPtr[i]->flags & flags)) { |
ASSERT(VB->TexCoordPtr[i] == &inputs->TexCoord[i]); |
_tnl_import_texcoord( ctx, i, writeable, stride ); |
VB->importable_data &= ~VERT_BIT_TEX(i); |
} |
/* XXX not sure what to do here for vertex program arrays */ |
} |
void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) |
{ |
TNLcontext *tnl = TNL_CONTEXT(ctx); |
struct vertex_buffer *VB = &tnl->vb; |
GLuint inputs = tnl->pipeline.inputs; |
struct vertex_arrays *tmp = &tnl->array_inputs; |
/* _mesa_debug(ctx, "%s %d..%d // %d..%d\n", __FUNCTION__, */ |
/* start, count, ctx->Array.LockFirst, ctx->Array.LockCount); */ |
/* _tnl_print_vert_flags(" inputs", inputs); */ |
/* _tnl_print_vert_flags(" _Enabled", ctx->Array._Enabled); */ |
/* _tnl_print_vert_flags(" importable", inputs & VERT_BITS_FIXUP); */ |
VB->Count = count - start; |
VB->FirstClipped = VB->Count; |
VB->Elts = NULL; |
VB->MaterialMask = NULL; |
VB->Material = NULL; |
VB->Flag = NULL; |
VB->Primitive = tnl->tmp_primitive; |
VB->PrimitiveLength = tnl->tmp_primitive_length; |
VB->import_data = _tnl_upgrade_client_data; |
VB->importable_data = inputs & VERT_BITS_FIXUP; |
if (ctx->Array.LockCount) { |
ASSERT(start == (GLint) ctx->Array.LockFirst); |
ASSERT(count == (GLint) ctx->Array.LockCount); |
} |
_ac_import_range( ctx, start, count ); |
if (inputs & VERT_BIT_POS) { |
_tnl_import_vertex( ctx, 0, 0 ); |
tmp->Obj.count = VB->Count; |
VB->ObjPtr = &tmp->Obj; |
} |
if (inputs & VERT_BIT_NORMAL) { |
_tnl_import_normal( ctx, 0, 0 ); |
tmp->Normal.count = VB->Count; |
VB->NormalPtr = &tmp->Normal; |
} |
if (inputs & VERT_BIT_COLOR0) { |
_tnl_import_color( ctx, 0, 0, 0 ); |
VB->ColorPtr[0] = &tmp->Color; |
VB->ColorPtr[1] = 0; |
} |
if (inputs & VERT_BITS_TEX_ANY) { |
GLuint unit; |
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { |
if (inputs & VERT_BIT_TEX(unit)) { |
_tnl_import_texcoord( ctx, unit, GL_FALSE, GL_FALSE ); |
tmp->TexCoord[unit].count = VB->Count; |
VB->TexCoordPtr[unit] = &tmp->TexCoord[unit]; |
} |
} |
} |
if (inputs & (VERT_BIT_INDEX | VERT_BIT_FOG | |
VERT_BIT_EDGEFLAG | VERT_BIT_COLOR1)) { |
if (inputs & VERT_BIT_INDEX) { |
_tnl_import_index( ctx, 0, 0 ); |
tmp->Index.count = VB->Count; |
VB->IndexPtr[0] = &tmp->Index; |
VB->IndexPtr[1] = 0; |
} |
if (inputs & VERT_BIT_FOG) { |
_tnl_import_fogcoord( ctx, 0, 0 ); |
tmp->FogCoord.count = VB->Count; |
VB->FogCoordPtr = &tmp->FogCoord; |
} |
if (inputs & VERT_BIT_EDGEFLAG) { |
_tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) ); |
VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data; |
} |
if (inputs & VERT_BIT_COLOR1) { |
_tnl_import_secondarycolor( ctx, 0, 0, 0 ); |
VB->SecondaryColorPtr[0] = &tmp->SecondaryColor; |
VB->SecondaryColorPtr[1] = 0; |
} |
} |
/* XXX not 100% sure this is finished. Keith should probably inspect. */ |
if (ctx->VertexProgram.Enabled) { |
GLuint index; |
for (index = 0; index < VERT_ATTRIB_MAX; index++) { |
/* XXX check program->InputsRead to reduce work here */ |
_tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE ); |
VB->AttribPtr[index] = &tmp->Attribs[index]; |
} |
} |
} |
/shark/trunk/ports/mesa/src/tnl/t_import_array.h |
---|
0,0 → 1,37 |
/* $Id: t_import_array.h,v 1.1 2003-04-24 14:24:01 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
* Version: 3.5 |
* |
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the "Software"), |
* to deal in the Software without restriction, including without limitation |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
* and/or sell copies of the Software, and to permit persons to whom the |
* Software is furnished to do so, subject to the following conditions: |
* |
* The above copyright notice and this permission notice shall be included |
* in all copies or substantial portions of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
*/ |
#ifndef _T_ARRAY_IMPORT_H |
#define _T_ARRAY_IMPORT_H |
#include "mtypes.h" |
#include "t_context.h" |
extern void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ); |
extern void _tnl_array_import_init( GLcontext *ctx ); |
#endif |
/shark/trunk/ports/mesa/src/tnl/t_imm_exec.c |
---|
1,4 → 1,4 |
/* $Id: t_imm_exec.c,v 1.1 2003-02-28 11:48:07 pj Exp $ */ |
/* $Id: t_imm_exec.c,v 1.2 2003-04-24 14:22:20 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
46,7 → 46,7 |
#include "math/m_xform.h" |
#include "t_context.h" |
#include "t_array_import.h" |
#include "t_import_array.h" |
#include "t_imm_alloc.h" |
#include "t_imm_api.h" |
#include "t_imm_debug.h" |
/shark/trunk/ports/mesa/src/tnl/t_array_api.c |
---|
1,4 → 1,4 |
/* $Id: t_array_api.c,v 1.1 2003-02-28 11:48:06 pj Exp $ */ |
/* $Id: t_array_api.c,v 1.2 2003-04-24 14:22:20 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
42,7 → 42,7 |
#include "array_cache/acache.h" |
#include "t_array_api.h" |
#include "t_array_import.h" |
#include "t_import_array.h" |
#include "t_imm_api.h" |
#include "t_imm_exec.h" |
#include "t_context.h" |
/shark/trunk/ports/mesa/src/swrast/s_aalinetemp.h |
---|
File deleted |
/shark/trunk/ports/mesa/src/swrast/s_aaline.c |
---|
1,4 → 1,4 |
/* $Id: s_aaline.c,v 1.1 2003-02-28 11:49:40 pj Exp $ */ |
/* $Id: s_aaline.c,v 1.2 2003-04-24 14:22:20 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
468,7 → 468,7 |
#define DO_Z |
#define DO_FOG |
#define DO_INDEX |
#include "s_aalinetemp.h" |
#include "s_aatempline.h" |
#define NAME(x) aa_rgba_##x |
475,7 → 475,7 |
#define DO_Z |
#define DO_FOG |
#define DO_RGBA |
#include "s_aalinetemp.h" |
#include "s_aatempline.h" |
#define NAME(x) aa_tex_rgba_##x |
483,7 → 483,7 |
#define DO_FOG |
#define DO_RGBA |
#define DO_TEX |
#include "s_aalinetemp.h" |
#include "s_aatempline.h" |
#define NAME(x) aa_multitex_rgba_##x |
491,7 → 491,7 |
#define DO_FOG |
#define DO_RGBA |
#define DO_MULTITEX |
#include "s_aalinetemp.h" |
#include "s_aatempline.h" |
#define NAME(x) aa_multitex_spec_##x |
500,7 → 500,7 |
#define DO_RGBA |
#define DO_MULTITEX |
#define DO_SPEC |
#include "s_aalinetemp.h" |
#include "s_aatempline.h" |
/shark/trunk/ports/mesa/src/swrast/s_aatempline.h |
---|
0,0 → 1,315 |
/* $Id: s_aatempline.h,v 1.1 2003-04-24 14:24:01 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
* Version: 4.1 |
* |
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the "Software"), |
* to deal in the Software without restriction, including without limitation |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
* and/or sell copies of the Software, and to permit persons to whom the |
* Software is furnished to do so, subject to the following conditions: |
* |
* The above copyright notice and this permission notice shall be included |
* in all copies or substantial portions of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
*/ |
/* |
* Antialiased line template. |
*/ |
/* |
* Function to render each fragment in the AA line. |
*/ |
static void |
NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) |
{ |
const GLfloat fx = (GLfloat) ix; |
const GLfloat fy = (GLfloat) iy; |
const GLfloat coverage = compute_coveragef(line, ix, iy); |
const GLuint i = line->span.end; |
if (coverage == 0.0) |
return; |
line->span.end++; |
line->span.array->coverage[i] = coverage; |
line->span.array->x[i] = ix; |
line->span.array->y[i] = iy; |
/* |
* Compute Z, color, texture coords, fog for the fragment by |
* solving the plane equations at (ix,iy). |
*/ |
#ifdef DO_Z |
line->span.array->z[i] = (GLdepth) solve_plane(fx, fy, line->zPlane); |
#endif |
#ifdef DO_FOG |
line->span.array->fog[i] = solve_plane(fx, fy, line->fPlane); |
#endif |
#ifdef DO_RGBA |
line->span.array->rgba[i][RCOMP] = solve_plane_chan(fx, fy, line->rPlane); |
line->span.array->rgba[i][GCOMP] = solve_plane_chan(fx, fy, line->gPlane); |
line->span.array->rgba[i][BCOMP] = solve_plane_chan(fx, fy, line->bPlane); |
line->span.array->rgba[i][ACOMP] = solve_plane_chan(fx, fy, line->aPlane); |
#endif |
#ifdef DO_INDEX |
line->span.array->index[i] = (GLint) solve_plane(fx, fy, line->iPlane); |
#endif |
#ifdef DO_SPEC |
line->span.array->spec[i][RCOMP] = solve_plane_chan(fx, fy, line->srPlane); |
line->span.array->spec[i][GCOMP] = solve_plane_chan(fx, fy, line->sgPlane); |
line->span.array->spec[i][BCOMP] = solve_plane_chan(fx, fy, line->sbPlane); |
#endif |
#ifdef DO_TEX |
{ |
const GLfloat invQ = solve_plane_recip(fx, fy, line->vPlane[0]); |
line->span.array->texcoords[0][i][0] = solve_plane(fx, fy, line->sPlane[0]) * invQ; |
line->span.array->texcoords[0][i][1] = solve_plane(fx, fy, line->tPlane[0]) * invQ; |
line->span.array->texcoords[0][i][2] = solve_plane(fx, fy, line->uPlane[0]) * invQ; |
line->span.array->lambda[0][i] = compute_lambda(line->sPlane[0], line->tPlane[0], invQ, |
line->texWidth[0], line->texHeight[0]); |
} |
#elif defined(DO_MULTITEX) |
{ |
GLuint unit; |
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { |
if (ctx->Texture.Unit[unit]._ReallyEnabled) { |
const GLfloat invQ = solve_plane_recip(fx, fy, line->vPlane[unit]); |
line->span.array->texcoords[unit][i][0] = solve_plane(fx, fy, line->sPlane[unit]) * invQ; |
line->span.array->texcoords[unit][i][1] = solve_plane(fx, fy, line->tPlane[unit]) * invQ; |
line->span.array->texcoords[unit][i][2] = solve_plane(fx, fy, line->uPlane[unit]) * invQ; |
line->span.array->lambda[unit][i] = compute_lambda(line->sPlane[unit], |
line->tPlane[unit], invQ, |
line->texWidth[unit], line->texHeight[unit]); |
} |
} |
} |
#endif |
if (line->span.end == MAX_WIDTH) { |
#if defined(DO_TEX) || defined(DO_MULTITEX) |
_mesa_write_texture_span(ctx, &(line->span)); |
#elif defined(DO_RGBA) |
_mesa_write_rgba_span(ctx, &(line->span)); |
#else |
_mesa_write_index_span(ctx, &(line->span)); |
#endif |
line->span.end = 0; /* reset counter */ |
} |
} |
/* |
* Line setup |
*/ |
static void |
NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) |
{ |
SWcontext *swrast = SWRAST_CONTEXT(ctx); |
GLfloat tStart, tEnd; /* segment start, end along line length */ |
GLboolean inSegment; |
GLint iLen, i; |
/* Init the LineInfo struct */ |
struct LineInfo line; |
line.x0 = v0->win[0]; |
line.y0 = v0->win[1]; |
line.x1 = v1->win[0]; |
line.y1 = v1->win[1]; |
line.dx = line.x1 - line.x0; |
line.dy = line.y1 - line.y0; |
line.len = (GLfloat) sqrt(line.dx * line.dx + line.dy * line.dy); |
line.halfWidth = 0.5F * ctx->Line.Width; |
if (line.len == 0.0 || IS_INF_OR_NAN(line.len)) |
return; |
INIT_SPAN(line.span, GL_LINE, 0, 0, SPAN_XY | SPAN_COVERAGE); |
line.xAdj = line.dx / line.len * line.halfWidth; |
line.yAdj = line.dy / line.len * line.halfWidth; |
#ifdef DO_Z |
line.span.arrayMask |= SPAN_Z; |
compute_plane(line.x0, line.y0, line.x1, line.y1, |
v0->win[2], v1->win[2], line.zPlane); |
#endif |
#ifdef DO_FOG |
line.span.arrayMask |= SPAN_FOG; |
compute_plane(line.x0, line.y0, line.x1, line.y1, |
v0->fog, v1->fog, line.fPlane); |
#endif |
#ifdef DO_RGBA |
line.span.arrayMask |= SPAN_RGBA; |
if (ctx->Light.ShadeModel == GL_SMOOTH) { |
compute_plane(line.x0, line.y0, line.x1, line.y1, |
v0->color[RCOMP], v1->color[RCOMP], line.rPlane); |
compute_plane(line.x0, line.y0, line.x1, line.y1, |
v0->color[GCOMP], v1->color[GCOMP], line.gPlane); |
compute_plane(line.x0, line.y0, line.x1, line.y1, |
v0->color[BCOMP], v1->color[BCOMP], line.bPlane); |
compute_plane(line.x0, line.y0, line.x1, line.y1, |
v0->color[ACOMP], v1->color[ACOMP], line.aPlane); |
} |
else { |
constant_plane(v1->color[RCOMP], line.rPlane); |
constant_plane(v1->color[GCOMP], line.gPlane); |
constant_plane(v1->color[BCOMP], line.bPlane); |
constant_plane(v1->color[ACOMP], line.aPlane); |
} |
#endif |
#ifdef DO_SPEC |
line.span.arrayMask |= SPAN_SPEC; |
if (ctx->Light.ShadeModel == GL_SMOOTH) { |
compute_plane(line.x0, line.y0, line.x1, line.y1, |
v0->specular[RCOMP], v1->specular[RCOMP], line.srPlane); |
compute_plane(line.x0, line.y0, line.x1, line.y1, |
v0->specular[GCOMP], v1->specular[GCOMP], line.sgPlane); |
compute_plane(line.x0, line.y0, line.x1, line.y1, |
v0->specular[BCOMP], v1->specular[BCOMP], line.sbPlane); |
} |
else { |
constant_plane(v1->specular[RCOMP], line.srPlane); |
constant_plane(v1->specular[GCOMP], line.sgPlane); |
constant_plane(v1->specular[BCOMP], line.sbPlane); |
} |
#endif |
#ifdef DO_INDEX |
line.span.arrayMask |= SPAN_INDEX; |
if (ctx->Light.ShadeModel == GL_SMOOTH) { |
compute_plane(line.x0, line.y0, line.x1, line.y1, |
(GLfloat) v0->index, (GLfloat) v1->index, line.iPlane); |
} |
else { |
constant_plane((GLfloat) v1->index, line.iPlane); |
} |
#endif |
#ifdef DO_TEX |
{ |
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; |
const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel]; |
const GLfloat invW0 = v0->win[3]; |
const GLfloat invW1 = v1->win[3]; |
const GLfloat s0 = v0->texcoord[0][0] * invW0; |
const GLfloat s1 = v1->texcoord[0][0] * invW1; |
const GLfloat t0 = v0->texcoord[0][1] * invW0; |
const GLfloat t1 = v1->texcoord[0][1] * invW0; |
const GLfloat r0 = v0->texcoord[0][2] * invW0; |
const GLfloat r1 = v1->texcoord[0][2] * invW0; |
const GLfloat q0 = v0->texcoord[0][3] * invW0; |
const GLfloat q1 = v1->texcoord[0][3] * invW0; |
line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); |
compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[0]); |
compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[0]); |
compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[0]); |
compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[0]); |
line.texWidth[0] = (GLfloat) texImage->Width; |
line.texHeight[0] = (GLfloat) texImage->Height; |
} |
#elif defined(DO_MULTITEX) |
{ |
GLuint u; |
line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); |
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { |
if (ctx->Texture.Unit[u]._ReallyEnabled) { |
const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; |
const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel]; |
const GLfloat invW0 = v0->win[3]; |
const GLfloat invW1 = v1->win[3]; |
const GLfloat s0 = v0->texcoord[u][0] * invW0; |
const GLfloat s1 = v1->texcoord[u][0] * invW1; |
const GLfloat t0 = v0->texcoord[u][1] * invW0; |
const GLfloat t1 = v1->texcoord[u][1] * invW0; |
const GLfloat r0 = v0->texcoord[u][2] * invW0; |
const GLfloat r1 = v1->texcoord[u][2] * invW0; |
const GLfloat q0 = v0->texcoord[u][3] * invW0; |
const GLfloat q1 = v1->texcoord[u][3] * invW0; |
compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[u]); |
compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[u]); |
compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[u]); |
compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[u]); |
line.texWidth[u] = (GLfloat) texImage->Width; |
line.texHeight[u] = (GLfloat) texImage->Height; |
} |
} |
} |
#endif |
tStart = tEnd = 0.0; |
inSegment = GL_FALSE; |
iLen = (GLint) line.len; |
if (ctx->Line.StippleFlag) { |
for (i = 0; i < iLen; i++) { |
const GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf; |
if ((1 << bit) & ctx->Line.StipplePattern) { |
/* stipple bit is on */ |
const GLfloat t = (GLfloat) i / (GLfloat) line.len; |
if (!inSegment) { |
/* start new segment */ |
inSegment = GL_TRUE; |
tStart = t; |
} |
else { |
/* still in the segment, extend it */ |
tEnd = t; |
} |
} |
else { |
/* stipple bit is off */ |
if (inSegment && (tEnd > tStart)) { |
/* draw the segment */ |
segment(ctx, &line, NAME(plot), tStart, tEnd); |
inSegment = GL_FALSE; |
} |
else { |
/* still between segments, do nothing */ |
} |
} |
swrast->StippleCounter++; |
} |
if (inSegment) { |
/* draw the final segment of the line */ |
segment(ctx, &line, NAME(plot), tStart, 1.0F); |
} |
} |
else { |
/* non-stippled */ |
segment(ctx, &line, NAME(plot), 0.0, 1.0); |
} |
#if defined(DO_TEX) || defined(DO_MULTITEX) |
_mesa_write_texture_span(ctx, &(line.span)); |
#elif defined(DO_RGBA) |
_mesa_write_rgba_span(ctx, &(line.span)); |
#else |
_mesa_write_index_span(ctx, &(line.span)); |
#endif |
} |
#undef DO_Z |
#undef DO_FOG |
#undef DO_RGBA |
#undef DO_INDEX |
#undef DO_SPEC |
#undef DO_TEX |
#undef DO_MULTITEX |
#undef NAME |
/shark/trunk/ports/mesa/src/texformat.c |
---|
1,4 → 1,4 |
/* $Id: texformat.c,v 1.1 2003-02-28 11:42:04 pj Exp $ */ |
/* $Id: texformat.c,v 1.2 2003-04-24 14:22:20 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
42,13 → 42,13 |
/* Texel fetch routines for all supported formats: |
*/ |
#define DIM 1 |
#include "texformat_tmp.h" |
#include "tmp_texformat.h" |
#define DIM 2 |
#include "texformat_tmp.h" |
#include "tmp_texformat.h" |
#define DIM 3 |
#include "texformat_tmp.h" |
#include "tmp_texformat.h" |
/* Have to have this so the FetchTexel function pointer is never NULL. |
*/ |
/shark/trunk/ports/mesa/src/makefile |
---|
27,12 → 27,12 |
./swrast/s_span.o ./swrast/s_stencil.o ./swrast/s_texstore.o ./swrast/s_texture.o\ |
./swrast/s_triangle.o ./swrast/s_zoom.o ./swrast_setup/ss_context.o\ |
./swrast_setup/ss_triangle.o ./swrast_setup/ss_vb.o ./tnl/t_array_api.o\ |
./tnl/t_array_import.o ./tnl/t_context.o ./tnl/t_eval_api.o ./tnl/t_imm_alloc.o\ |
./tnl/t_import_array.o ./tnl/t_context.o ./tnl/t_eval_api.o ./tnl/t_imm_alloc.o\ |
./tnl/t_imm_api.o ./tnl/t_imm_debug.o ./tnl/t_imm_dlist.o ./tnl/t_imm_elt.o\ |
./tnl/t_imm_eval.o ./tnl/t_imm_exec.o ./tnl/t_imm_fixup.o ./tnl/t_pipeline.o\ |
./tnl/t_vb_fog.o ./tnl/t_vb_light.o\ |
./tnl/t_vb_normals.o ./tnl/t_vb_points.o ./tnl/t_vb_program.o ./tnl/t_vb_render.o\ |
./tnl/t_vb_texgen.o ./tnl/t_vb_texmat.o ./tnl/t_vb_vertex.o\ |
./tnl/t_vb_gentex.o ./tnl/t_vb_texmat.o ./tnl/t_vb_vertex.o\ |
./math/m_clip_debug.o ./math/m_norm_debug.o\ |
./math/m_xform_debug.o ./math/m_eval.o ./math/m_matrix.o ./math/m_translate.o\ |
./math/m_vector.o ./math/m_xform.o\ |
/shark/trunk/ports/mesa/src/tmp_texformat.h |
---|
0,0 → 1,461 |
/* $Id: tmp_texformat.h,v 1.1 2003-04-24 14:24:01 giacomo Exp $ */ |
/* |
* Mesa 3-D graphics library |
* Version: 4.1 |
* |
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved. |
* |
* Permission is hereby granted, free of charge, to any person obtaining a |
* copy of this software and associated documentation files (the "Software"), |
* to deal in the Software without restriction, including without limitation |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
* and/or sell copies of the Software, and to permit persons to whom the |
* Software is furnished to do so, subject to the following conditions: |
* |
* The above copyright notice and this permission notice shall be included |
* in all copies or substantial portions of the Software. |
* |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
* |
* Authors: |
* Gareth Hughes |
* Brian Paul |
*/ |
/* |
* This template file generates texel fetch functions for 1-D, 2-D and 3-D |
* texture images. |
*/ |
#if DIM == 1 |
#define CHAN_SRC( t, i, j, k, sz ) \ |
((GLchan *)(t)->Data + (i) * (sz)) |
#define UBYTE_SRC( t, i, j, k, sz ) \ |
((GLubyte *)(t)->Data + (i) * (sz)) |
#define USHORT_SRC( t, i, j, k ) \ |
((GLushort *)(t)->Data + (i)) |
#define FLOAT_SRC( t, i, j, k ) \ |
((GLfloat *)(t)->Data + (i)) |
#define FETCH(x) fetch_1d_texel_##x |
#elif DIM == 2 |
#define CHAN_SRC( t, i, j, k, sz ) \ |
((GLchan *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)) |
#define UBYTE_SRC( t, i, j, k, sz ) \ |
((GLubyte *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)) |
#define USHORT_SRC( t, i, j, k ) \ |
((GLushort *)(t)->Data + ((t)->RowStride * (j) + (i))) |
#define FLOAT_SRC( t, i, j, k ) \ |
((GLfloat *)(t)->Data + ((t)->RowStride * (j) + (i))) |
#define FETCH(x) fetch_2d_texel_##x |
#elif DIM == 3 |
#define CHAN_SRC( t, i, j, k, sz ) \ |
(GLchan *)(t)->Data + (((t)->Height * (k) + (j)) * \ |
(t)->RowStride + (i)) * (sz) |
#define UBYTE_SRC( t, i, j, k, sz ) \ |
((GLubyte *)(t)->Data + (((t)->Height * (k) + (j)) * \ |
(t)->RowStride + (i)) * (sz)) |
#define USHORT_SRC( t, i, j, k ) \ |
((GLushort *)(t)->Data + (((t)->Height * (k) + (j)) * \ |
(t)->RowStride + (i))) |
#define FLOAT_SRC( t, i, j, k ) \ |
((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \ |
(t)->RowStride + (i))) |
#define FETCH(x) fetch_3d_texel_##x |
#else |
#error illegal number of texture dimensions |
#endif |
static void FETCH(rgba)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 ); |
GLchan *rgba = (GLchan *) texel; |
COPY_CHAN4( rgba, src ); |
} |
static void FETCH(rgb)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = src[0]; |
rgba[GCOMP] = src[1]; |
rgba[BCOMP] = src[2]; |
rgba[ACOMP] = CHAN_MAX; |
} |
static void FETCH(alpha)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = 0; |
rgba[GCOMP] = 0; |
rgba[BCOMP] = 0; |
rgba[ACOMP] = src[0]; |
} |
static void FETCH(luminance)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = src[0]; |
rgba[GCOMP] = src[0]; |
rgba[BCOMP] = src[0]; |
rgba[ACOMP] = CHAN_MAX; |
} |
static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLchan *src = CHAN_SRC( texImage, i, j, k, 2 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = src[0]; |
rgba[GCOMP] = src[0]; |
rgba[BCOMP] = src[0]; |
rgba[ACOMP] = src[1]; |
} |
static void FETCH(intensity)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = src[0]; |
rgba[GCOMP] = src[0]; |
rgba[BCOMP] = src[0]; |
rgba[ACOMP] = src[0]; |
} |
static void FETCH(color_index)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 ); |
GLchan *index = (GLchan *) texel; |
*index = *src; |
} |
static void FETCH(depth_component)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLfloat *src = FLOAT_SRC( texImage, i, j, k ); |
GLfloat *depth = (GLfloat *) texel; |
*depth = *src; |
} |
static void FETCH(rgba8888)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( src[3] ); |
rgba[GCOMP] = UBYTE_TO_CHAN( src[2] ); |
rgba[BCOMP] = UBYTE_TO_CHAN( src[1] ); |
rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); |
} |
static void FETCH(argb8888)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); |
rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); |
rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[ACOMP] = UBYTE_TO_CHAN( src[3] ); |
} |
static void FETCH(rgb888)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); |
rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); |
rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[ACOMP] = CHAN_MAX; |
} |
static void FETCH(rgb565)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
const GLushort s = *src; |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); |
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); |
rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); |
rgba[ACOMP] = CHAN_MAX; |
} |
static void FETCH(argb4444)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
const GLushort s = *src; |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); |
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); |
rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); |
rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); |
} |
static void FETCH(argb1555)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
const GLushort s = *src; |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); |
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); |
rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); |
rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); |
} |
static void FETCH(al88)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[ACOMP] = UBYTE_TO_CHAN( src[1] ); |
} |
static void FETCH(rgb332)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
const GLubyte s = *src; |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); |
rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); |
rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); |
rgba[ACOMP] = CHAN_MAX; |
} |
static void FETCH(a8)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = 0; |
rgba[GCOMP] = 0; |
rgba[BCOMP] = 0; |
rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); |
} |
static void FETCH(l8)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[ACOMP] = CHAN_MAX; |
} |
static void FETCH(i8)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); |
} |
static void FETCH(ci8)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
GLchan *index = (GLchan *) texel; |
*index = UBYTE_TO_CHAN( *src ); |
} |
/* XXX this may break if GLchan != GLubyte */ |
static void FETCH(ycbcr)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */ |
const GLushort *src1 = src0 + 1; /* odd */ |
const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */ |
const GLubyte cb = *src0 & 0xff; /* chroma U */ |
const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ |
const GLubyte cr = *src1 & 0xff; /* chroma V */ |
GLchan *rgba = (GLchan *) texel; |
GLint r, g, b; |
if (i & 1) { |
/* odd pixel: use y1,cr,cb */ |
r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128)); |
g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); |
b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128)); |
} |
else { |
/* even pixel: use y0,cr,cb */ |
r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128)); |
g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); |
b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128)); |
} |
rgba[RCOMP] = CLAMP(r, 0, CHAN_MAX); |
rgba[GCOMP] = CLAMP(g, 0, CHAN_MAX); |
rgba[BCOMP] = CLAMP(b, 0, CHAN_MAX); |
rgba[ACOMP] = CHAN_MAX; |
} |
/* XXX this may break if GLchan != GLubyte */ |
static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */ |
const GLushort *src1 = src0 + 1; /* odd */ |
const GLubyte y0 = *src0 & 0xff; /* luminance */ |
const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma U */ |
const GLubyte y1 = *src1 & 0xff; /* luminance */ |
const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma V */ |
GLchan *rgba = (GLchan *) texel; |
GLint r, g, b; |
if (i & 1) { |
/* odd pixel: use y1,cr,cb */ |
r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128)); |
g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); |
b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128)); |
} |
else { |
/* even pixel: use y0,cr,cb */ |
r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128)); |
g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128)); |
b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128)); |
} |
rgba[RCOMP] = CLAMP(r, 0, CHAN_MAX); |
rgba[GCOMP] = CLAMP(g, 0, CHAN_MAX); |
rgba[BCOMP] = CLAMP(b, 0, CHAN_MAX); |
rgba[ACOMP] = CHAN_MAX; |
} |
/* big-endian */ |
#if 0 |
static void FETCH(abgr8888)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( src[3] ); |
rgba[GCOMP] = UBYTE_TO_CHAN( src[2] ); |
rgba[BCOMP] = UBYTE_TO_CHAN( src[1] ); |
rgba[ACOMP] = UBYTE_TO_CHAN( src[0] ); |
} |
static void FETCH(bgra8888)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); |
rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); |
rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[ACOMP] = UBYTE_TO_CHAN( src[3] ); |
} |
static void FETCH(bgr888)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( src[2] ); |
rgba[GCOMP] = UBYTE_TO_CHAN( src[1] ); |
rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[ACOMP] = CHAN_MAX; |
} |
static void FETCH(bgr565)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
const GLushort s = *src; |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); |
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); |
rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); |
rgba[ACOMP] = CHAN_MAX; |
} |
static void FETCH(bgra4444)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
const GLushort s = *src; |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); |
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); |
rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); |
rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); |
} |
static void FETCH(bgra5551)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLushort *src = USHORT_SRC( texImage, i, j, k ); |
const GLushort s = *src; |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); |
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); |
rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); |
rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); |
} |
static void FETCH(la88)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[GCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[BCOMP] = UBYTE_TO_CHAN( src[0] ); |
rgba[ACOMP] = UBYTE_TO_CHAN( src[1] ); |
} |
static void FETCH(bgr233)( const struct gl_texture_image *texImage, |
GLint i, GLint j, GLint k, GLvoid *texel ) |
{ |
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); |
const GLubyte s = *src; |
GLchan *rgba = (GLchan *) texel; |
rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); |
rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); |
rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); |
rgba[ACOMP] = CHAN_MAX; |
} |
#endif |
#undef CHAN_SRC |
#undef UBYTE_SRC |
#undef USHORT_SRC |
#undef FLOAT_SRC |
#undef FETCH |
#undef DIM |
/shark/trunk/ports/mesa/src/x86/sse_normal.s |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/sse_xform4.s |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/sse_xform3.s |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/sse_xform2.s |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/sse_xform1.s |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/3dnow_normal.s |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/3dnow_xform1.s |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/3dnow_xform2.s |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/3dnow_xform3.s |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/3dnow_xform4.s |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/sse.c |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/sse.h |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/3dnow.c |
---|
File deleted |
/shark/trunk/ports/mesa/src/x86/3dnow.h |
---|
File deleted |