Softpipe: import TGSI tree. Not hooked-up yet.

This commit is contained in:
michal 2007-07-05 19:55:38 +02:00
parent ac5523a9c3
commit ffe58739da
22 changed files with 7229 additions and 7 deletions

View file

@ -0,0 +1,3 @@
default:
cd ../.. ; make

View file

@ -0,0 +1,3 @@
default:
cd ../../.. ; make

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,309 @@
#if !defined TGSI_BUILD_H
#define TGSI_BUILD_H
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
/*
* version
*/
struct tgsi_version
tgsi_build_version( void );
/*
* header
*/
struct tgsi_header
tgsi_build_header( void );
struct tgsi_processor
tgsi_default_processor( void );
struct tgsi_processor
tgsi_build_processor(
GLuint processor,
struct tgsi_header *header );
/*
* declaration
*/
struct tgsi_declaration
tgsi_default_declaration( void );
struct tgsi_declaration
tgsi_build_declaration(
GLuint file,
GLuint declare,
GLuint interpolate,
struct tgsi_header *header );
struct tgsi_full_declaration
tgsi_default_full_declaration( void );
GLuint
tgsi_build_full_declaration(
const struct tgsi_full_declaration *full_decl,
struct tgsi_token *tokens,
struct tgsi_header *header,
GLuint maxsize );
struct tgsi_declaration_range
tgsi_build_declaration_range(
GLuint first,
GLuint last,
struct tgsi_declaration *declaration,
struct tgsi_header *header );
struct tgsi_declaration_mask
tgsi_build_declaration_mask(
GLuint mask,
struct tgsi_declaration *declaration,
struct tgsi_header *header );
struct tgsi_declaration_interpolation
tgsi_default_declaration_interpolation( void );
struct tgsi_declaration_interpolation
tgsi_build_declaration_interpolation(
GLuint interpolate,
struct tgsi_declaration *declaration,
struct tgsi_header *header );
/*
* immediate
*/
struct tgsi_immediate
tgsi_default_immediate( void );
struct tgsi_immediate
tgsi_build_immediate(
struct tgsi_header *header );
struct tgsi_full_immediate
tgsi_default_full_immediate( void );
struct tgsi_immediate_float32
tgsi_build_immediate_float32(
GLfloat value,
struct tgsi_immediate *immediate,
struct tgsi_header *header );
GLuint
tgsi_build_full_immediate(
const struct tgsi_full_immediate *full_imm,
struct tgsi_token *tokens,
struct tgsi_header *header,
GLuint maxsize );
/*
* instruction
*/
struct tgsi_instruction
tgsi_default_instruction( void );
struct tgsi_instruction
tgsi_build_instruction(
GLuint opcode,
GLuint saturate,
GLuint num_dst_regs,
GLuint num_src_regs,
struct tgsi_header *header );
struct tgsi_full_instruction
tgsi_default_full_instruction( void );
GLuint
tgsi_build_full_instruction(
const struct tgsi_full_instruction *full_inst,
struct tgsi_token *tokens,
struct tgsi_header *header,
GLuint maxsize );
struct tgsi_instruction_ext_nv
tgsi_default_instruction_ext_nv( void );
GLuint
tgsi_compare_instruction_ext_nv(
struct tgsi_instruction_ext_nv a,
struct tgsi_instruction_ext_nv b );
struct tgsi_instruction_ext_nv
tgsi_build_instruction_ext_nv(
GLuint precision,
GLuint cond_dst_index,
GLuint cond_flow_index,
GLuint cond_mask,
GLuint cond_swizzle_x,
GLuint cond_swizzle_y,
GLuint cond_swizzle_z,
GLuint cond_swizzle_w,
GLuint cond_dst_update,
GLuint cond_flow_update,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
struct tgsi_instruction_ext_label
tgsi_default_instruction_ext_label( void );
GLuint
tgsi_compare_instruction_ext_label(
struct tgsi_instruction_ext_label a,
struct tgsi_instruction_ext_label b );
struct tgsi_instruction_ext_label
tgsi_build_instruction_ext_label(
GLuint label,
GLuint target,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
struct tgsi_instruction_ext_texture
tgsi_default_instruction_ext_texture( void );
GLuint
tgsi_compare_instruction_ext_texture(
struct tgsi_instruction_ext_texture a,
struct tgsi_instruction_ext_texture b );
struct tgsi_instruction_ext_texture
tgsi_build_instruction_ext_texture(
GLuint texture,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
struct tgsi_src_register
tgsi_default_src_register( void );
struct tgsi_src_register
tgsi_build_src_register(
GLuint file,
GLuint swizzle_x,
GLuint swizzle_y,
GLuint swizzle_z,
GLuint swizzle_w,
GLuint negate,
GLuint indirect,
GLuint dimension,
GLint index,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
struct tgsi_full_src_register
tgsi_default_full_src_register( void );
struct tgsi_src_register_ext_swz
tgsi_default_src_register_ext_swz( void );
GLuint
tgsi_compare_src_register_ext_swz(
struct tgsi_src_register_ext_swz a,
struct tgsi_src_register_ext_swz b );
struct tgsi_src_register_ext_swz
tgsi_build_src_register_ext_swz(
GLuint ext_swizzle_x,
GLuint ext_swizzle_y,
GLuint ext_swizzle_z,
GLuint ext_swizzle_w,
GLuint negate_x,
GLuint negate_y,
GLuint negate_z,
GLuint negate_w,
GLuint ext_divide,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
struct tgsi_src_register_ext_mod
tgsi_default_src_register_ext_mod( void );
GLuint
tgsi_compare_src_register_ext_mod(
struct tgsi_src_register_ext_mod a,
struct tgsi_src_register_ext_mod b );
struct tgsi_src_register_ext_mod
tgsi_build_src_register_ext_mod(
GLuint complement,
GLuint bias,
GLuint scale_2x,
GLuint absolute,
GLuint negate,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
struct tgsi_dimension
tgsi_default_dimension( void );
struct tgsi_dimension
tgsi_build_dimension(
GLuint indirect,
GLuint index,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
struct tgsi_dst_register
tgsi_default_dst_register( void );
struct tgsi_dst_register
tgsi_build_dst_register(
GLuint file,
GLuint mask,
GLint index,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
struct tgsi_full_dst_register
tgsi_default_full_dst_register( void );
struct tgsi_dst_register_ext_concode
tgsi_default_dst_register_ext_concode( void );
GLuint
tgsi_compare_dst_register_ext_concode(
struct tgsi_dst_register_ext_concode a,
struct tgsi_dst_register_ext_concode b );
struct tgsi_dst_register_ext_concode
tgsi_build_dst_register_ext_concode(
GLuint cc,
GLuint swizzle_x,
GLuint swizzle_y,
GLuint swizzle_z,
GLuint swizzle_w,
GLint index,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
struct tgsi_dst_register_ext_modulate
tgsi_default_dst_register_ext_modulate( void );
GLuint
tgsi_compare_dst_register_ext_modulate(
struct tgsi_dst_register_ext_modulate a,
struct tgsi_dst_register_ext_modulate b );
struct tgsi_dst_register_ext_modulate
tgsi_build_dst_register_ext_modulate(
GLuint modulate,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
#endif // !defined TGSI_BUILD_H

View file

@ -0,0 +1,12 @@
#if !defined TGSI_CORE_H
#define TGSI_CORE_H
#include "tgsi_token.h"
#include "tgsi_parse.h"
#include "tgsi_build.h"
#include "tgsi_exec.h"
#include "tgsi_dump.h"
#include "tgsi_util.h"
#endif // !defined TGSI_CORE_H

View file

@ -0,0 +1,871 @@
#include "tgsi_platform.h"
#include "tgsi_core.h"
struct text_dump
{
FILE *file;
GLuint tabs;
};
static void
text_dump_write(
struct text_dump *dump,
const void *buffer,
GLuint size )
{
fwrite( buffer, size, 1, dump->file );
}
static void
text_dump_str(
struct text_dump *dump,
const char *str )
{
GLuint i;
GLuint len = strlen( str );
for( i = 0; i < len; i++ ) {
text_dump_write( dump, &str[i], 1 );
if( str[i] == '\n' ) {
GLuint i;
for( i = 0; i < dump->tabs; i++ ) {
text_dump_write( dump, " ", 4 );
}
}
}
}
static void
text_dump_chr(
struct text_dump *dump,
const char chr )
{
char str[2];
str[0] = chr;
str[1] = '\0';
text_dump_str( dump, str );
}
static void
text_dump_uix(
struct text_dump *dump,
const GLuint ui)
{
char str[36];
sprintf( str, "0x%x", ui );
text_dump_str( dump, str );
}
static void
text_dump_uid(
struct text_dump *dump,
const GLuint ui )
{
char str[16];
sprintf( str, "%u", ui );
text_dump_str( dump, str );
}
static void
text_dump_sid(
struct text_dump *dump,
const GLint si )
{
char str[16];
sprintf( str, "%d", si );
text_dump_str( dump, str );
}
static void
text_dump_flt(
struct text_dump *dump,
const GLfloat f )
{
char str[48];
sprintf( str, "%40.6f", f );
text_dump_str( dump, str );
}
static void
text_dump_enum(
struct text_dump *dump,
const GLuint e,
const char **enums,
const GLuint enums_count )
{
if( e >= enums_count ) {
text_dump_uid( dump, e );
}
else {
text_dump_str( dump, enums[e] );
}
}
static void
text_dump_tab(
struct text_dump *dump )
{
dump->tabs++;
}
static void
text_dump_untab(
struct text_dump *dump )
{
assert( dump->tabs > 0 );
--dump->tabs;
}
#define TXT(S) text_dump_str( &dump, S )
#define CHR(C) text_dump_chr( &dump, C )
#define UIX(I) text_dump_uix( &dump, I )
#define UID(I) text_dump_uid( &dump, I )
#define SID(I) text_dump_sid( &dump, I )
#define FLT(F) text_dump_flt( &dump, F )
#define TAB() text_dump_tab( &dump )
#define UNT() text_dump_untab( &dump )
#define ENM(E,ENUMS) text_dump_enum( &dump, E, ENUMS, sizeof( ENUMS ) / sizeof( *ENUMS ) )
static const char *TGSI_PROCESSOR_TYPES[] =
{
"PROCESSOR_FRAGMENT",
"PROCESSOR_VERTEX"
};
static const char *TGSI_TOKEN_TYPES[] =
{
"TOKEN_TYPE_DECLARATION",
"TOKEN_TYPE_IMMEDIATE",
"TOKEN_TYPE_INSTRUCTION"
};
static const char *TGSI_FILES[] =
{
"FILE_NULL",
"FILE_CONSTANT",
"FILE_INPUT",
"FILE_OUTPUT",
"FILE_TEMPORARY",
"FILE_SAMPLER",
"FILE_ADDRESS",
"FILE_IMMEDIATE"
};
static const char *TGSI_DECLARES[] =
{
"DECLARE_RANGE",
"DECLARE_MASK"
};
static const char *TGSI_INTERPOLATES[] =
{
"INTERPOLATE_CONSTANT",
"INTERPOLATE_LINEAR",
"INTERPOLATE_PERSPECTIVE"
};
static const char *TGSI_IMMS[] =
{
"IMM_FLOAT32"
};
static const char *TGSI_OPCODES[] =
{
"OPCODE_MOV",
"OPCODE_LIT",
"OPCODE_RCP",
"OPCODE_RSQ",
"OPCODE_EXP",
"OPCODE_LOG",
"OPCODE_MUL",
"OPCODE_ADD",
"OPCODE_DP3",
"OPCODE_DP4",
"OPCODE_DST",
"OPCODE_MIN",
"OPCODE_MAX",
"OPCODE_SLT",
"OPCODE_SGE",
"OPCODE_MAD",
"OPCODE_SUB",
"OPCODE_LERP",
"OPCODE_CND",
"OPCODE_CND0",
"OPCODE_DOT2ADD",
"OPCODE_INDEX",
"OPCODE_NEGATE",
"OPCODE_FRAC",
"OPCODE_CLAMP",
"OPCODE_FLOOR",
"OPCODE_ROUND",
"OPCODE_EXPBASE2",
"OPCODE_LOGBASE2",
"OPCODE_POWER",
"OPCODE_CROSSPRODUCT",
"OPCODE_MULTIPLYMATRIX",
"OPCODE_ABS",
"OPCODE_RCC",
"OPCODE_DPH",
"OPCODE_COS",
"OPCODE_DDX",
"OPCODE_DDY",
"OPCODE_KIL",
"OPCODE_PK2H",
"OPCODE_PK2US",
"OPCODE_PK4B",
"OPCODE_PK4UB",
"OPCODE_RFL",
"OPCODE_SEQ",
"OPCODE_SFL",
"OPCODE_SGT",
"OPCODE_SIN",
"OPCODE_SLE",
"OPCODE_SNE",
"OPCODE_STR",
"OPCODE_TEX",
"OPCODE_TXD",
"OPCODE_UP2H",
"OPCODE_UP2US",
"OPCODE_UP4B",
"OPCODE_UP4UB",
"OPCODE_X2D",
"OPCODE_ARA",
"OPCODE_ARR",
"OPCODE_BRA",
"OPCODE_CAL",
"OPCODE_RET",
"OPCODE_SSG",
"OPCODE_CMP",
"OPCODE_SCS",
"OPCODE_TXB",
"OPCODE_NRM",
"OPCODE_DIV",
"OPCODE_DP2",
"OPCODE_TXL",
"OPCODE_BRK",
"OPCODE_IF",
"OPCODE_LOOP",
"OPCODE_REP",
"OPCODE_ELSE",
"OPCODE_ENDIF",
"OPCODE_ENDLOOP",
"OPCODE_ENDREP",
"OPCODE_PUSHA",
"OPCODE_POPA",
"OPCODE_CEIL",
"OPCODE_I2F",
"OPCODE_NOT",
"OPCODE_TRUNC",
"OPCODE_SHL",
"OPCODE_SHR",
"OPCODE_AND",
"OPCODE_OR",
"OPCODE_MOD",
"OPCODE_XOR",
"OPCODE_SAD",
"OPCODE_TXF",
"OPCODE_TXQ",
"OPCODE_CONT",
"OPCODE_EMIT",
"OPCODE_ENDPRIM"
};
static const char *TGSI_SATS[] =
{
"SAT_NONE",
"SAT_ZERO_ONE",
"SAT_MINUS_PLUS_ONE"
};
static const char *TGSI_INSTRUCTION_EXTS[] =
{
"INSTRUCTION_EXT_TYPE_NV",
"INSTRUCTION_EXT_TYPE_LABEL",
"INSTRUCTION_EXT_TYPE_TEXTURE"
};
static const char *TGSI_PRECISIONS[] =
{
"PRECISION_DEFAULT",
"TGSI_PRECISION_FLOAT32",
"TGSI_PRECISION_FLOAT16",
"TGSI_PRECISION_FIXED12"
};
static const char *TGSI_CCS[] =
{
"CC_GT",
"CC_EQ",
"CC_LT",
"CC_UN",
"CC_GE",
"CC_LE",
"CC_NE",
"CC_TR",
"CC_FL"
};
static const char *TGSI_SWIZZLES[] =
{
"SWIZZLE_X",
"SWIZZLE_Y",
"SWIZZLE_Z",
"SWIZZLE_W"
};
static const char *TGSI_TEXTURES[] =
{
"TEXTURE_UNKNOWN",
"TEXTURE_1D",
"TEXTURE_2D",
"TEXTURE_3D",
"TEXTURE_CUBE",
"TEXTURE_RECT",
"TEXTURE_SHADOW1D",
"TEXTURE_SHADOW2D",
"TEXTURE_SHADOWRECT"
};
static const char *TGSI_SRC_REGISTER_EXTS[] =
{
"SRC_REGISTER_EXT_TYPE_SWZ",
"SRC_REGISTER_EXT_TYPE_MOD"
};
static const char *TGSI_EXTSWIZZLES[] =
{
"EXTSWIZZLE_X",
"EXTSWIZZLE_Y",
"EXTSWIZZLE_Z",
"EXTSWIZZLE_W",
"EXTSWIZZLE_ZERO",
"EXTSWIZZLE_ONE"
};
static const char *TGSI_WRITEMASKS[] =
{
"0",
"WRITEMASK_X",
"WRITEMASK_Y",
"WRITEMASK_XY",
"WRITEMASK_Z",
"WRITEMASK_XZ",
"WRITEMASK_YZ",
"WRITEMASK_XYZ",
"WRITEMASK_W",
"WRITEMASK_XW",
"WRITEMASK_YW",
"WRITEMASK_XYW",
"WRITEMASK_ZW",
"WRITEMASK_XZW",
"WRITEMASK_YZW",
"WRITEMASK_XYZW"
};
static const char *TGSI_DST_REGISTER_EXTS[] =
{
"DST_REGISTER_EXT_TYPE_CONDCODE",
"DST_REGISTER_EXT_TYPE_MODULATE"
};
static const char *TGSI_MODULATES[] =
{
"MODULATE_1X",
"MODULATE_2X",
"MODULATE_4X",
"MODULATE_8X",
"MODULATE_HALF",
"MODULATE_QUARTER",
"MODULATE_EIGHTH"
};
void
tgsi_dump(
const struct tgsi_token *tokens,
GLuint flags )
{
struct text_dump dump;
struct tgsi_parse_context parse;
struct tgsi_full_instruction fi;
struct tgsi_full_declaration fd;
GLuint ignored = !(flags & TGSI_DUMP_NO_IGNORED);
GLuint deflt = !(flags & TGSI_DUMP_NO_DEFAULT);
{
static GLuint counter = 0;
char buffer[64];
sprintf( buffer, "sbir-dump-%.4u.txt", counter++ );
dump.file = fopen( buffer, "wt" );
dump.tabs = 0;
}
tgsi_parse_init( &parse, tokens );
TXT( "sbir-dump" );
CHR( '\n' );
TXT( "\nMajorVersion: " );
UID( parse.FullVersion.Version.MajorVersion );
TXT( "\nMinorVersion: " );
UID( parse.FullVersion.Version.MinorVersion );
CHR( '\n' );
TXT( "\nHeaderSize: " );
UID( parse.FullHeader.Header.HeaderSize );
TXT( "\nBodySize : " );
UID( parse.FullHeader.Header.BodySize );
TXT( "\nProcessor : " );
ENM( parse.FullHeader.Processor.Processor, TGSI_PROCESSOR_TYPES );
fi = tgsi_default_full_instruction();
fd = tgsi_default_full_declaration();
while( !tgsi_parse_end_of_tokens( &parse ) ) {
GLuint i;
tgsi_parse_token( &parse );
CHR( '\n' );
TXT( "\nType : " );
ENM( parse.FullToken.Token.Type, TGSI_TOKEN_TYPES );
if( ignored ) {
TXT( "\nSize : " );
UID( parse.FullToken.Token.Size );
if( deflt || parse.FullToken.Token.Extended ) {
TXT( "\nExtended : " );
UID( parse.FullToken.Token.Extended );
}
}
switch( parse.FullToken.Token.Type ) {
case TGSI_TOKEN_TYPE_DECLARATION:
{
struct tgsi_full_declaration *decl = &parse.FullToken.FullDeclaration;
TXT( "\nFile : " );
ENM( decl->Declaration.File, TGSI_FILES );
TXT( "\nDeclare : " );
ENM( decl->Declaration.Declare, TGSI_DECLARES );
if( deflt || fd.Declaration.Interpolate != decl->Declaration.Interpolate ) {
TXT( "\nInterpolate: " );
UID( decl->Declaration.Interpolate );
}
if( ignored ) {
TXT( "\nPadding : " );
UIX( decl->Declaration.Padding );
}
CHR( '\n' );
switch( decl->Declaration.Declare ) {
case TGSI_DECLARE_RANGE:
TXT( "\nFirst: " );
UID( decl->u.DeclarationRange.First );
TXT( "\nLast : " );
UID( decl->u.DeclarationRange.Last );
break;
case TGSI_DECLARE_MASK:
TXT( "\nMask: " );
UIX( decl->u.DeclarationMask.Mask );
break;
default:
assert( 0 );
}
if( decl->Declaration.Interpolate ) {
CHR( '\n' );
TXT( "\nInterpolate: " );
ENM( decl->Interpolation.Interpolate, TGSI_INTERPOLATES );
if( ignored ) {
TXT( "\nPadding : " );
UIX( decl->Interpolation.Padding );
}
}
}
break;
case TGSI_TOKEN_TYPE_IMMEDIATE:
TXT( "\nDataType : " );
ENM( parse.FullToken.FullImmediate.Immediate.DataType, TGSI_IMMS );
if( ignored ) {
TXT( "\nPadding : " );
UIX( parse.FullToken.FullImmediate.Immediate.Padding );
}
for( i = 0; i < parse.FullToken.FullImmediate.Immediate.Size - 1; i++ ) {
CHR( '\n' );
switch( parse.FullToken.FullImmediate.Immediate.DataType ) {
case TGSI_IMM_FLOAT32:
TXT( "\nFloat: " );
FLT( parse.FullToken.FullImmediate.u.ImmediateFloat32[i].Float );
break;
default:
assert( 0 );
}
}
break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
{
struct tgsi_full_instruction *inst = &parse.FullToken.FullInstruction;
TXT( "\nOpcode : " );
ENM( inst->Instruction.Opcode, TGSI_OPCODES );
if( deflt || fi.Instruction.Saturate != inst->Instruction.Saturate ) {
TXT( "\nSaturate : " );
ENM( inst->Instruction.Saturate, TGSI_SATS );
}
if( deflt || fi.Instruction.NumDstRegs != inst->Instruction.NumDstRegs ) {
TXT( "\nNumDstRegs : " );
UID( inst->Instruction.NumDstRegs );
}
if( deflt || fi.Instruction.NumSrcRegs != inst->Instruction.NumSrcRegs ) {
TXT( "\nNumSrcRegs : " );
UID( inst->Instruction.NumSrcRegs );
}
if( ignored ) {
TXT( "\nPadding : " );
UIX( inst->Instruction.Padding );
}
if( deflt || tgsi_compare_instruction_ext_nv( inst->InstructionExtNv, fi.InstructionExtNv)) {
CHR( '\n' );
TXT( "\nType : " );
ENM( inst->InstructionExtNv.Type, TGSI_INSTRUCTION_EXTS );
if( deflt || fi.InstructionExtNv.Precision != inst->InstructionExtNv.Precision ) {
TXT( "\nPrecision : " );
ENM( inst->InstructionExtNv.Precision, TGSI_PRECISIONS );
}
if( deflt || fi.InstructionExtNv.CondDstIndex != inst->InstructionExtNv.CondDstIndex ) {
TXT( "\nCondDstIndex : " );
UID( inst->InstructionExtNv.CondDstIndex );
}
if( deflt || fi.InstructionExtNv.CondFlowIndex != inst->InstructionExtNv.CondFlowIndex ) {
TXT( "\nCondFlowIndex : " );
UID( inst->InstructionExtNv.CondFlowIndex );
}
if( deflt || fi.InstructionExtNv.CondMask != inst->InstructionExtNv.CondMask ) {
TXT( "\nCondMask : " );
ENM( inst->InstructionExtNv.CondMask, TGSI_CCS );
}
if( deflt || fi.InstructionExtNv.CondSwizzleX != inst->InstructionExtNv.CondSwizzleX ) {
TXT( "\nCondSwizzleX : " );
ENM( inst->InstructionExtNv.CondSwizzleX, TGSI_SWIZZLES );
}
if( deflt || fi.InstructionExtNv.CondSwizzleY != inst->InstructionExtNv.CondSwizzleY ) {
TXT( "\nCondSwizzleY : " );
ENM( inst->InstructionExtNv.CondSwizzleY, TGSI_SWIZZLES );
}
if( deflt || fi.InstructionExtNv.CondSwizzleZ != inst->InstructionExtNv.CondSwizzleZ ) {
TXT( "\nCondSwizzleZ : " );
ENM( inst->InstructionExtNv.CondSwizzleZ, TGSI_SWIZZLES );
}
if( deflt || fi.InstructionExtNv.CondSwizzleW != inst->InstructionExtNv.CondSwizzleW ) {
TXT( "\nCondSwizzleW : " );
ENM( inst->InstructionExtNv.CondSwizzleW, TGSI_SWIZZLES );
}
if( deflt || fi.InstructionExtNv.CondDstUpdate != inst->InstructionExtNv.CondDstUpdate ) {
TXT( "\nCondDstUpdate : " );
UID( inst->InstructionExtNv.CondDstUpdate );
}
if( deflt || fi.InstructionExtNv.CondFlowEnable != inst->InstructionExtNv.CondFlowEnable ) {
TXT( "\nCondFlowEnable: " );
UID( inst->InstructionExtNv.CondFlowEnable );
}
if( ignored ) {
TXT( "\nPadding : " );
UIX( inst->InstructionExtNv.Padding );
if( deflt || fi.InstructionExtNv.Extended != inst->InstructionExtNv.Extended ) {
TXT( "\nExtended : " );
UID( inst->InstructionExtNv.Extended );
}
}
}
if( deflt || tgsi_compare_instruction_ext_label( inst->InstructionExtLabel, fi.InstructionExtLabel ) ) {
CHR( '\n' );
TXT( "\nType : " );
ENM( inst->InstructionExtLabel.Type, TGSI_INSTRUCTION_EXTS );
if( deflt || fi.InstructionExtLabel.Label != inst->InstructionExtLabel.Label ) {
TXT( "\nLabel : " );
UID( inst->InstructionExtLabel.Label );
}
if( deflt || fi.InstructionExtLabel.Target != inst->InstructionExtLabel.Target ) {
TXT( "\nTarget : " );
UID( inst->InstructionExtLabel.Target );
}
if( ignored ) {
TXT( "\nPadding : " );
UIX( inst->InstructionExtLabel.Padding );
if( deflt || fi.InstructionExtLabel.Extended != inst->InstructionExtLabel.Extended ) {
TXT( "\nExtended: " );
UID( inst->InstructionExtLabel.Extended );
}
}
}
if( deflt || tgsi_compare_instruction_ext_texture( inst->InstructionExtTexture, fi.InstructionExtTexture ) ) {
CHR( '\n' );
TXT( "\nType : " );
ENM( inst->InstructionExtTexture.Type, TGSI_INSTRUCTION_EXTS );
if( deflt || fi.InstructionExtTexture.Texture != inst->InstructionExtTexture.Texture ) {
TXT( "\nTexture : " );
ENM( inst->InstructionExtTexture.Texture, TGSI_TEXTURES );
}
if( ignored ) {
TXT( "\nPadding : " );
UIX( inst->InstructionExtTexture.Padding );
if( deflt || fi.InstructionExtTexture.Extended != inst->InstructionExtTexture.Extended ) {
TXT( "\nExtended: " );
UID( inst->InstructionExtTexture.Extended );
}
}
}
for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
struct tgsi_full_dst_register *fd = &fi.FullDstRegisters[i];
CHR( '\n' );
TXT( "\nFile : " );
ENM( dst->DstRegister.File, TGSI_FILES );
if( deflt || fd->DstRegister.WriteMask != dst->DstRegister.WriteMask ) {
TXT( "\nWriteMask: " );
ENM( dst->DstRegister.WriteMask, TGSI_WRITEMASKS );
}
if( ignored ) {
if( deflt || fd->DstRegister.Indirect != dst->DstRegister.Indirect ) {
TXT( "\nIndirect : " );
UID( dst->DstRegister.Indirect );
}
if( deflt || fd->DstRegister.Dimension != dst->DstRegister.Dimension ) {
TXT( "\nDimension: " );
UID( dst->DstRegister.Dimension );
}
}
if( deflt || fd->DstRegister.Index != dst->DstRegister.Index ) {
TXT( "\nIndex : " );
SID( dst->DstRegister.Index );
}
if( ignored ) {
TXT( "\nPadding : " );
UIX( dst->DstRegister.Padding );
if( deflt || fd->DstRegister.Extended != dst->DstRegister.Extended ) {
TXT( "\nExtended : " );
UID( dst->DstRegister.Extended );
}
}
if( deflt || tgsi_compare_dst_register_ext_concode( dst->DstRegisterExtConcode, fd->DstRegisterExtConcode ) ) {
CHR( '\n' );
TXT( "\nType : " );
ENM( dst->DstRegisterExtConcode.Type, TGSI_DST_REGISTER_EXTS );
if( deflt || fd->DstRegisterExtConcode.CondMask != dst->DstRegisterExtConcode.CondMask ) {
TXT( "\nCondMask : " );
ENM( dst->DstRegisterExtConcode.CondMask, TGSI_CCS );
}
if( deflt || fd->DstRegisterExtConcode.CondSwizzleX != dst->DstRegisterExtConcode.CondSwizzleX ) {
TXT( "\nCondSwizzleX: " );
ENM( dst->DstRegisterExtConcode.CondSwizzleX, TGSI_SWIZZLES );
}
if( deflt || fd->DstRegisterExtConcode.CondSwizzleY != dst->DstRegisterExtConcode.CondSwizzleY ) {
TXT( "\nCondSwizzleY: " );
ENM( dst->DstRegisterExtConcode.CondSwizzleY, TGSI_SWIZZLES );
}
if( deflt || fd->DstRegisterExtConcode.CondSwizzleZ != dst->DstRegisterExtConcode.CondSwizzleZ ) {
TXT( "\nCondSwizzleZ: " );
ENM( dst->DstRegisterExtConcode.CondSwizzleZ, TGSI_SWIZZLES );
}
if( deflt || fd->DstRegisterExtConcode.CondSwizzleW != dst->DstRegisterExtConcode.CondSwizzleW ) {
TXT( "\nCondSwizzleW: " );
ENM( dst->DstRegisterExtConcode.CondSwizzleW, TGSI_SWIZZLES );
}
if( deflt || fd->DstRegisterExtConcode.CondSrcIndex != dst->DstRegisterExtConcode.CondSrcIndex ) {
TXT( "\nCondSrcIndex: " );
UID( dst->DstRegisterExtConcode.CondSrcIndex );
}
if( ignored ) {
TXT( "\nPadding : " );
UIX( dst->DstRegisterExtConcode.Padding );
if( deflt || fd->DstRegisterExtConcode.Extended != dst->DstRegisterExtConcode.Extended ) {
TXT( "\nExtended : " );
UID( dst->DstRegisterExtConcode.Extended );
}
}
}
if( deflt || tgsi_compare_dst_register_ext_modulate( dst->DstRegisterExtModulate, fd->DstRegisterExtModulate ) ) {
CHR( '\n' );
TXT( "\nType : " );
ENM( dst->DstRegisterExtModulate.Type, TGSI_DST_REGISTER_EXTS );
if( deflt || fd->DstRegisterExtModulate.Modulate != dst->DstRegisterExtModulate.Modulate ) {
TXT( "\nModulate: " );
ENM( dst->DstRegisterExtModulate.Modulate, TGSI_MODULATES );
}
if( ignored ) {
TXT( "\nPadding : " );
UIX( dst->DstRegisterExtModulate.Padding );
if( deflt || fd->DstRegisterExtModulate.Extended != dst->DstRegisterExtModulate.Extended ) {
TXT( "\nExtended: " );
UID( dst->DstRegisterExtModulate.Extended );
}
}
}
}
for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
struct tgsi_full_src_register *fs = &fi.FullSrcRegisters[i];
CHR( '\n' );
TXT( "\nFile : ");
ENM( src->SrcRegister.File, TGSI_FILES );
if( deflt || fs->SrcRegister.SwizzleX != src->SrcRegister.SwizzleX ) {
TXT( "\nSwizzleX : " );
ENM( src->SrcRegister.SwizzleX, TGSI_SWIZZLES );
}
if( deflt || fs->SrcRegister.SwizzleY != src->SrcRegister.SwizzleY ) {
TXT( "\nSwizzleY : " );
ENM( src->SrcRegister.SwizzleY, TGSI_SWIZZLES );
}
if( deflt || fs->SrcRegister.SwizzleZ != src->SrcRegister.SwizzleZ ) {
TXT( "\nSwizzleZ : " );
ENM( src->SrcRegister.SwizzleZ, TGSI_SWIZZLES );
}
if( deflt || fs->SrcRegister.SwizzleW != src->SrcRegister.SwizzleW ) {
TXT( "\nSwizzleW : " );
ENM( src->SrcRegister.SwizzleW, TGSI_SWIZZLES );
}
if( deflt || fs->SrcRegister.Negate != src->SrcRegister.Negate ) {
TXT( "\nNegate : " );
UID( src->SrcRegister.Negate );
}
if( ignored ) {
if( deflt || fs->SrcRegister.Indirect != src->SrcRegister.Indirect ) {
TXT( "\nIndirect : " );
UID( src->SrcRegister.Indirect );
}
if( deflt || fs->SrcRegister.Dimension != src->SrcRegister.Dimension ) {
TXT( "\nDimension: " );
UID( src->SrcRegister.Dimension );
}
}
if( deflt || fs->SrcRegister.Index != src->SrcRegister.Index ) {
TXT( "\nIndex : " );
SID( src->SrcRegister.Index );
}
if( ignored ) {
if( deflt || fs->SrcRegister.Extended != src->SrcRegister.Extended ) {
TXT( "\nExtended : " );
UID( src->SrcRegister.Extended );
}
}
if( deflt || tgsi_compare_src_register_ext_swz( src->SrcRegisterExtSwz, fs->SrcRegisterExtSwz ) ) {
CHR( '\n' );
TXT( "\nType : " );
ENM( src->SrcRegisterExtSwz.Type, TGSI_SRC_REGISTER_EXTS );
if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleX != src->SrcRegisterExtSwz.ExtSwizzleX ) {
TXT( "\nExtSwizzleX: " );
ENM( src->SrcRegisterExtSwz.ExtSwizzleX, TGSI_EXTSWIZZLES );
}
if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleY != src->SrcRegisterExtSwz.ExtSwizzleY ) {
TXT( "\nExtSwizzleY: " );
ENM( src->SrcRegisterExtSwz.ExtSwizzleY, TGSI_EXTSWIZZLES );
}
if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleZ != src->SrcRegisterExtSwz.ExtSwizzleZ ) {
TXT( "\nExtSwizzleZ: " );
ENM( src->SrcRegisterExtSwz.ExtSwizzleZ, TGSI_EXTSWIZZLES );
}
if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleW != src->SrcRegisterExtSwz.ExtSwizzleW ) {
TXT( "\nExtSwizzleW: " );
ENM( src->SrcRegisterExtSwz.ExtSwizzleW, TGSI_EXTSWIZZLES );
}
if( deflt || fs->SrcRegisterExtSwz.NegateX != src->SrcRegisterExtSwz.NegateX ) {
TXT( "\nNegateX : " );
UID( src->SrcRegisterExtSwz.NegateX );
}
if( deflt || fs->SrcRegisterExtSwz.NegateY != src->SrcRegisterExtSwz.NegateY ) {
TXT( "\nNegateY : " );
UID( src->SrcRegisterExtSwz.NegateY );
}
if( deflt || fs->SrcRegisterExtSwz.NegateZ != src->SrcRegisterExtSwz.NegateZ ) {
TXT( "\nNegateZ : " );
UID( src->SrcRegisterExtSwz.NegateZ );
}
if( deflt || fs->SrcRegisterExtSwz.NegateW != src->SrcRegisterExtSwz.NegateW ) {
TXT( "\nNegateW : " );
UID( src->SrcRegisterExtSwz.NegateW );
}
if( deflt || fs->SrcRegisterExtSwz.ExtDivide != src->SrcRegisterExtSwz.ExtDivide ) {
TXT( "\nExtDivide : " );
ENM( src->SrcRegisterExtSwz.ExtDivide, TGSI_EXTSWIZZLES );
}
if( ignored ) {
TXT( "\nPadding : " );
UIX( src->SrcRegisterExtSwz.Padding );
if( deflt || fs->SrcRegisterExtSwz.Extended != src->SrcRegisterExtSwz.Extended ) {
TXT( "\nExtended : " );
UID( src->SrcRegisterExtSwz.Extended );
}
}
}
if( deflt || tgsi_compare_src_register_ext_mod( src->SrcRegisterExtMod, fs->SrcRegisterExtMod ) ) {
CHR( '\n' );
TXT( "\nType : " );
ENM( src->SrcRegisterExtMod.Type, TGSI_SRC_REGISTER_EXTS );
if( deflt || fs->SrcRegisterExtMod.Complement != src->SrcRegisterExtMod.Complement ) {
TXT( "\nComplement: " );
UID( src->SrcRegisterExtMod.Complement );
}
if( deflt || fs->SrcRegisterExtMod.Bias != src->SrcRegisterExtMod.Bias ) {
TXT( "\nBias : " );
UID( src->SrcRegisterExtMod.Bias );
}
if( deflt || fs->SrcRegisterExtMod.Scale2X != src->SrcRegisterExtMod.Scale2X ) {
TXT( "\nScale2X : " );
UID( src->SrcRegisterExtMod.Scale2X );
}
if( deflt || fs->SrcRegisterExtMod.Absolute != src->SrcRegisterExtMod.Absolute ) {
TXT( "\nAbsolute : " );
UID( src->SrcRegisterExtMod.Absolute );
}
if( deflt || fs->SrcRegisterExtMod.Negate != src->SrcRegisterExtMod.Negate ) {
TXT( "\nNegate : " );
UID( src->SrcRegisterExtMod.Negate );
}
if( ignored ) {
TXT( "\nPadding : " );
UIX( src->SrcRegisterExtMod.Padding );
if( deflt || fs->SrcRegisterExtMod.Extended != src->SrcRegisterExtMod.Extended ) {
TXT( "\nExtended : " );
UID( src->SrcRegisterExtMod.Extended );
}
}
}
}
}
break;
default:
assert( 0 );
}
}
tgsi_parse_free( &parse );
fclose( dump.file );
}

View file

@ -0,0 +1,22 @@
#if !defined TGSI_DUMP_H
#define TGSI_DUMP_H
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
#define TGSI_DUMP_VERBOSE 0
#define TGSI_DUMP_NO_IGNORED 1
#define TGSI_DUMP_NO_DEFAULT 2
void
tgsi_dump(
const struct tgsi_token *tokens,
GLuint flags );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
#endif // !defined TGSI_DUMP_H

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,137 @@
#if !defined TGSI_EXEC_H
#define TGSI_EXEC_H
#if 0
#include "x86/rtasm/x86sse.h"
#endif
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
union tgsi_exec_channel
{
GLfloat f[4];
GLint i[4];
GLuint u[4];
};
struct tgsi_exec_vector
{
union tgsi_exec_channel xyzw[4];
};
struct tgsi_sampler_state
{
GLboolean NeedLambda;
GLboolean NeedLodBias; /* if NeedLambda */
GLboolean NeedLambdaClamp; /* if NeedLambda */
GLfloat LodBias; /* if NeedLodBias */
GLfloat MinLod; /* if NeedLambdaClamp */
GLfloat MaxLod; /* if NeedLambdaClamp */
GLfloat ImageWidth;
GLfloat ImageHeight;
GLfloat ImageDepth;
};
struct tgsi_exec_labels
{
GLuint labels[128][2];
GLuint count;
};
#define TGSI_EXEC_TEMP_00000000_I 32
#define TGSI_EXEC_TEMP_00000000_C 0
#define TGSI_EXEC_TEMP_7FFFFFFF_I 32
#define TGSI_EXEC_TEMP_7FFFFFFF_C 1
#define TGSI_EXEC_TEMP_80000000_I 32
#define TGSI_EXEC_TEMP_80000000_C 2
#define TGSI_EXEC_TEMP_FFFFFFFF_I 32
#define TGSI_EXEC_TEMP_FFFFFFFF_C 3
#define TGSI_EXEC_TEMP_ONE_I 33
#define TGSI_EXEC_TEMP_ONE_C 0
#define TGSI_EXEC_TEMP_TWO_I 33
#define TGSI_EXEC_TEMP_TWO_C 1
#define TGSI_EXEC_TEMP_128_I 33
#define TGSI_EXEC_TEMP_128_C 2
#define TGSI_EXEC_TEMP_MINUS_128_I 33
#define TGSI_EXEC_TEMP_MINUS_128_C 3
#define TGSI_EXEC_TEMP_KILMASK_I 34
#define TGSI_EXEC_TEMP_KILMASK_C 0
#define TGSI_EXEC_TEMP_OUTPUT_I 34
#define TGSI_EXEC_TEMP_OUTPUT_C 1
#define TGSI_EXEC_TEMP_PRIMITIVE_I 34
#define TGSI_EXEC_TEMP_PRIMITIVE_C 2
#define TGSI_EXEC_TEMP_R0 35
#define TGSI_EXEC_NUM_TEMPS (32 + 4)
#define TGSI_EXEC_NUM_ADDRS 1
struct tgsi_exec_machine
{
/*
* 32 program temporaries
* 4 internal temporaries
* 1 address
* 1 temporary of padding to align to 16 bytes
*/
struct tgsi_exec_vector _Temps[TGSI_EXEC_NUM_TEMPS + TGSI_EXEC_NUM_ADDRS + 1];
/*
* This will point to _Temps after aligning to 16B boundary.
*/
struct tgsi_exec_vector *Temps;
struct tgsi_exec_vector *Addrs;
struct tgsi_sampler_state Samplers[16];
GLfloat Imms[256][4];
GLuint ImmLimit;
GLfloat (*Consts)[4];
const struct tgsi_exec_vector *Inputs;
struct tgsi_exec_vector *Outputs;
struct tgsi_token *Tokens;
GLuint Processor;
GLuint *Primitives;
#if XXX_SSE
struct x86_function Function;
#endif
};
void
tgsi_exec_machine_init(
struct tgsi_exec_machine *mach,
struct tgsi_token *tokens );
void
tgsi_exec_prepare(
struct tgsi_exec_machine *mach,
struct tgsi_exec_labels *labels );
void
tgsi_exec_machine_run(
struct tgsi_exec_machine *mach );
void
tgsi_exec_machine_run2(
struct tgsi_exec_machine *mach,
struct tgsi_exec_labels *labels );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
#endif // !defined TGSI_EXEC_H

View file

@ -0,0 +1,284 @@
#include "tgsi_platform.h"
#include "tgsi_core.h"
void
tgsi_full_token_init(
union tgsi_full_token *full_token )
{
full_token->Token.Type = TGSI_TOKEN_TYPE_DECLARATION;
}
void
tgsi_full_token_free(
union tgsi_full_token *full_token )
{
if( full_token->Token.Type == TGSI_TOKEN_TYPE_IMMEDIATE )
free( full_token->FullImmediate.u.Pointer );
}
GLuint
tgsi_parse_init(
struct tgsi_parse_context *ctx,
const struct tgsi_token *tokens )
{
ctx->FullVersion.Version = *(struct tgsi_version *) &tokens[0];
if( ctx->FullVersion.Version.MajorVersion > 1 ) {
return TGSI_PARSE_ERROR;
}
ctx->FullHeader.Header = *(struct tgsi_header *) &tokens[1];
if( ctx->FullHeader.Header.HeaderSize >= 2 ) {
ctx->FullHeader.Processor = *(struct tgsi_processor *) &tokens[2];
}
else {
ctx->FullHeader.Processor = tgsi_default_processor();
}
ctx->Tokens = tokens;
ctx->Position = 1 + ctx->FullHeader.Header.HeaderSize;
tgsi_full_token_init( &ctx->FullToken );
return TGSI_PARSE_OK;
}
void
tgsi_parse_free(
struct tgsi_parse_context *ctx )
{
tgsi_full_token_free( &ctx->FullToken );
}
GLuint
tgsi_parse_end_of_tokens(
struct tgsi_parse_context *ctx )
{
return ctx->Position >=
1 + ctx->FullHeader.Header.HeaderSize + ctx->FullHeader.Header.BodySize;
}
static void
next_token(
struct tgsi_parse_context *ctx,
void *token )
{
assert( !tgsi_parse_end_of_tokens( ctx ) );
*(struct tgsi_token *) token = ctx->Tokens[ctx->Position++];
}
void
tgsi_parse_token(
struct tgsi_parse_context *ctx )
{
struct tgsi_token token;
GLuint i;
tgsi_full_token_free( &ctx->FullToken );
tgsi_full_token_init( &ctx->FullToken );
next_token( ctx, &token );
switch( token.Type ) {
case TGSI_TOKEN_TYPE_DECLARATION:
{
struct tgsi_full_declaration *decl = &ctx->FullToken.FullDeclaration;
*decl = tgsi_default_full_declaration();
decl->Declaration = *(struct tgsi_declaration *) &token;
switch( decl->Declaration.Type ) {
case TGSI_DECLARE_RANGE:
next_token( ctx, &decl->u.DeclarationRange );
break;
case TGSI_DECLARE_MASK:
next_token( ctx, &decl->u.DeclarationMask );
break;
default:
assert (0);
}
if( decl->Declaration.Interpolate ) {
next_token( ctx, &decl->Interpolation );
}
break;
}
case TGSI_TOKEN_TYPE_IMMEDIATE:
{
struct tgsi_full_immediate *imm = &ctx->FullToken.FullImmediate;
*imm = tgsi_default_full_immediate();
imm->Immediate = *(struct tgsi_immediate *) &token;
assert( !imm->Immediate.Extended );
switch (imm->Immediate.DataType) {
case TGSI_IMM_FLOAT32:
imm->u.Pointer = malloc(
sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.Size - 1) );
for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
next_token( ctx, &imm->u.ImmediateFloat32[i] );
}
break;
default:
assert( 0 );
}
break;
}
case TGSI_TOKEN_TYPE_INSTRUCTION:
{
struct tgsi_full_instruction *inst = &ctx->FullToken.FullInstruction;
GLuint extended;
*inst = tgsi_default_full_instruction();
inst->Instruction = *(struct tgsi_instruction *) &token;
extended = inst->Instruction.Extended;
while( extended ) {
struct tgsi_src_register_ext token;
next_token( ctx, &token );
switch( token.Type ) {
case TGSI_INSTRUCTION_EXT_TYPE_NV:
inst->InstructionExtNv =
*(struct tgsi_instruction_ext_nv *) &token;
break;
case TGSI_INSTRUCTION_EXT_TYPE_LABEL:
inst->InstructionExtLabel =
*(struct tgsi_instruction_ext_label *) &token;
break;
case TGSI_INSTRUCTION_EXT_TYPE_TEXTURE:
inst->InstructionExtTexture =
*(struct tgsi_instruction_ext_texture *) &token;
break;
default:
assert( 0 );
}
extended = token.Extended;
}
assert( inst->Instruction.NumDstRegs <= TGSI_FULL_MAX_DST_REGISTERS );
for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
GLuint extended;
next_token( ctx, &inst->FullDstRegisters[i].DstRegister );
/*
* No support for indirect or multi-dimensional addressing.
*/
assert( !inst->FullDstRegisters[i].DstRegister.Indirect );
assert( !inst->FullDstRegisters[i].DstRegister.Dimension );
extended = inst->FullDstRegisters[i].DstRegister.Extended;
while( extended ) {
struct tgsi_src_register_ext token;
next_token( ctx, &token );
switch( token.Type ) {
case TGSI_DST_REGISTER_EXT_TYPE_CONDCODE:
inst->FullDstRegisters[i].DstRegisterExtConcode =
*(struct tgsi_dst_register_ext_concode *) &token;
break;
case TGSI_DST_REGISTER_EXT_TYPE_MODULATE:
inst->FullDstRegisters[i].DstRegisterExtModulate =
*(struct tgsi_dst_register_ext_modulate *) &token;
break;
default:
assert( 0 );
}
extended = token.Extended;
}
}
assert( inst->Instruction.NumSrcRegs <= TGSI_FULL_MAX_SRC_REGISTERS );
for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
GLuint extended;
next_token( ctx, &inst->FullSrcRegisters[i].SrcRegister );
extended = inst->FullSrcRegisters[i].SrcRegister.Extended;
while( extended ) {
struct tgsi_src_register_ext token;
next_token( ctx, &token );
switch( token.Type ) {
case TGSI_SRC_REGISTER_EXT_TYPE_SWZ:
inst->FullSrcRegisters[i].SrcRegisterExtSwz =
*(struct tgsi_src_register_ext_swz *) &token;
break;
case TGSI_SRC_REGISTER_EXT_TYPE_MOD:
inst->FullSrcRegisters[i].SrcRegisterExtMod =
*(struct tgsi_src_register_ext_mod *) &token;
break;
default:
assert( 0 );
}
extended = token.Extended;
}
if( inst->FullSrcRegisters[i].SrcRegister.Indirect ) {
next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterInd );
/*
* No support for indirect or multi-dimensional addressing.
*/
assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Indirect );
assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Dimension );
assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Extended );
}
if( inst->FullSrcRegisters[i].SrcRegister.Dimension ) {
next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterDim );
/*
* No support for multi-dimensional addressing.
*/
assert( !inst->FullSrcRegisters[i].SrcRegisterDim.Dimension );
assert( !inst->FullSrcRegisters[i].SrcRegisterDim.Extended );
if( inst->FullSrcRegisters[i].SrcRegisterDim.Indirect ) {
next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterDimInd );
/*
* No support for indirect or multi-dimensional addressing.
*/
assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Indirect );
assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Dimension );
assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Extended );
}
}
}
break;
}
default:
assert( 0 );
}
}

View file

@ -0,0 +1,120 @@
#if !defined TGSI_PARSE_H
#define TGSI_PARSE_H
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
struct tgsi_full_version
{
struct tgsi_version Version;
};
struct tgsi_full_header
{
struct tgsi_header Header;
struct tgsi_processor Processor;
};
struct tgsi_full_dst_register
{
struct tgsi_dst_register DstRegister;
struct tgsi_dst_register_ext_concode DstRegisterExtConcode;
struct tgsi_dst_register_ext_modulate DstRegisterExtModulate;
};
struct tgsi_full_src_register
{
struct tgsi_src_register SrcRegister;
struct tgsi_src_register_ext_swz SrcRegisterExtSwz;
struct tgsi_src_register_ext_mod SrcRegisterExtMod;
struct tgsi_src_register SrcRegisterInd;
struct tgsi_dimension SrcRegisterDim;
struct tgsi_src_register SrcRegisterDimInd;
};
struct tgsi_full_declaration
{
struct tgsi_declaration Declaration;
union
{
struct tgsi_declaration_range DeclarationRange;
struct tgsi_declaration_mask DeclarationMask;
} u;
struct tgsi_declaration_interpolation Interpolation;
};
struct tgsi_full_immediate
{
struct tgsi_immediate Immediate;
union
{
void *Pointer;
struct tgsi_immediate_float32 *ImmediateFloat32;
} u;
};
#define TGSI_FULL_MAX_DST_REGISTERS 2
#define TGSI_FULL_MAX_SRC_REGISTERS 3
struct tgsi_full_instruction
{
struct tgsi_instruction Instruction;
struct tgsi_instruction_ext_nv InstructionExtNv;
struct tgsi_instruction_ext_label InstructionExtLabel;
struct tgsi_instruction_ext_texture InstructionExtTexture;
struct tgsi_full_dst_register FullDstRegisters[TGSI_FULL_MAX_DST_REGISTERS];
struct tgsi_full_src_register FullSrcRegisters[TGSI_FULL_MAX_SRC_REGISTERS];
};
union tgsi_full_token
{
struct tgsi_token Token;
struct tgsi_full_declaration FullDeclaration;
struct tgsi_full_immediate FullImmediate;
struct tgsi_full_instruction FullInstruction;
};
void
tgsi_full_token_init(
union tgsi_full_token *full_token );
void
tgsi_full_token_free(
union tgsi_full_token *full_token );
struct tgsi_parse_context
{
const struct tgsi_token *Tokens;
GLuint Position;
struct tgsi_full_version FullVersion;
struct tgsi_full_header FullHeader;
union tgsi_full_token FullToken;
};
#define TGSI_PARSE_OK 0
#define TGSI_PARSE_ERROR 1
GLuint
tgsi_parse_init(
struct tgsi_parse_context *ctx,
const struct tgsi_token *tokens );
void
tgsi_parse_free(
struct tgsi_parse_context *ctx );
GLuint
tgsi_parse_end_of_tokens(
struct tgsi_parse_context *ctx );
void
tgsi_parse_token(
struct tgsi_parse_context *ctx );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
#endif // !defined TGSI_PARSE_H

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,263 @@
#include "tgsi_platform.h"
#include "tgsi_core.h"
void *
tgsi_align_128bit(
void *unaligned )
{
GLuint *ptr, addr;
ptr = (GLuint *) unaligned;
addr = (*(GLuint *) &ptr + 15) & ~15;
return *(void **) &addr;
}
GLuint
tgsi_util_get_src_register_swizzle(
const struct tgsi_src_register *reg,
GLuint component )
{
switch( component ) {
case 0:
return reg->SwizzleX;
case 1:
return reg->SwizzleY;
case 2:
return reg->SwizzleZ;
case 3:
return reg->SwizzleW;
default:
assert( 0 );
}
return 0;
}
GLuint
tgsi_util_get_src_register_extswizzle(
const struct tgsi_src_register_ext_swz *reg,
GLuint component )
{
switch( component ) {
case 0:
return reg->ExtSwizzleX;
case 1:
return reg->ExtSwizzleY;
case 2:
return reg->ExtSwizzleZ;
case 3:
return reg->ExtSwizzleW;
default:
assert( 0 );
}
return 0;
}
GLuint
tgsi_util_get_full_src_register_extswizzle(
const struct tgsi_full_src_register *reg,
GLuint component )
{
GLuint swizzle;
/*
* First, calculate the extended swizzle for a given channel. This will give
* us either a channel index into the simple swizzle or a constant 1 or 0.
*/
swizzle = tgsi_util_get_src_register_extswizzle(
&reg->SrcRegisterExtSwz,
component );
assert (TGSI_SWIZZLE_X == TGSI_EXTSWIZZLE_X);
assert (TGSI_SWIZZLE_Y == TGSI_EXTSWIZZLE_Y);
assert (TGSI_SWIZZLE_Z == TGSI_EXTSWIZZLE_Z);
assert (TGSI_SWIZZLE_W == TGSI_EXTSWIZZLE_W);
assert (TGSI_EXTSWIZZLE_ZERO > TGSI_SWIZZLE_W);
assert (TGSI_EXTSWIZZLE_ONE > TGSI_SWIZZLE_W);
/*
* Second, calculate the simple swizzle for the unswizzled channel index.
* Leave the constants intact, they are not affected by the simple swizzle.
*/
if( swizzle <= TGSI_SWIZZLE_W ) {
swizzle = tgsi_util_get_src_register_swizzle(
&reg->SrcRegister,
swizzle );
}
return swizzle;
}
void
tgsi_util_set_src_register_swizzle(
struct tgsi_src_register *reg,
GLuint swizzle,
GLuint component )
{
switch( component ) {
case 0:
reg->SwizzleX = swizzle;
break;
case 1:
reg->SwizzleY = swizzle;
break;
case 2:
reg->SwizzleZ = swizzle;
break;
case 3:
reg->SwizzleW = swizzle;
break;
default:
assert( 0 );
}
}
void
tgsi_util_set_src_register_extswizzle(
struct tgsi_src_register_ext_swz *reg,
GLuint swizzle,
GLuint component )
{
switch( component ) {
case 0:
reg->ExtSwizzleX = swizzle;
break;
case 1:
reg->ExtSwizzleY = swizzle;
break;
case 2:
reg->ExtSwizzleZ = swizzle;
break;
case 3:
reg->ExtSwizzleW = swizzle;
break;
default:
assert( 0 );
}
}
GLuint
tgsi_util_get_src_register_extnegate(
const struct tgsi_src_register_ext_swz *reg,
GLuint component )
{
switch( component ) {
case 0:
return reg->NegateX;
case 1:
return reg->NegateY;
case 2:
return reg->NegateZ;
case 3:
return reg->NegateW;
default:
assert( 0 );
}
return 0;
}
void
tgsi_util_set_src_register_extnegate(
struct tgsi_src_register_ext_swz *reg,
GLuint negate,
GLuint component )
{
switch( component ) {
case 0:
reg->NegateX = negate;
break;
case 1:
reg->NegateY = negate;
break;
case 2:
reg->NegateZ = negate;
break;
case 3:
reg->NegateW = negate;
break;
default:
assert( 0 );
}
}
GLuint
tgsi_util_get_full_src_register_sign_mode(
const struct tgsi_full_src_register *reg,
GLuint component )
{
GLuint sign_mode;
if( reg->SrcRegisterExtMod.Absolute ) {
/* Consider only the post-abs negation. */
if( reg->SrcRegisterExtMod.Negate ) {
sign_mode = TGSI_UTIL_SIGN_SET;
}
else {
sign_mode = TGSI_UTIL_SIGN_CLEAR;
}
}
else {
/* Accumulate the three negations. */
GLuint negate;
negate = reg->SrcRegister.Negate;
if( tgsi_util_get_src_register_extnegate( &reg->SrcRegisterExtSwz, component ) ) {
negate = !negate;
}
if( reg->SrcRegisterExtMod.Negate ) {
negate = !negate;
}
if( negate ) {
sign_mode = TGSI_UTIL_SIGN_TOGGLE;
}
else {
sign_mode = TGSI_UTIL_SIGN_KEEP;
}
}
return sign_mode;
}
void
tgsi_util_set_full_src_register_sign_mode(
struct tgsi_full_src_register *reg,
GLuint sign_mode )
{
reg->SrcRegisterExtSwz.NegateX = 0;
reg->SrcRegisterExtSwz.NegateY = 0;
reg->SrcRegisterExtSwz.NegateZ = 0;
reg->SrcRegisterExtSwz.NegateW = 0;
switch (sign_mode)
{
case TGSI_UTIL_SIGN_CLEAR:
reg->SrcRegister.Negate = 0;
reg->SrcRegisterExtMod.Absolute = 1;
reg->SrcRegisterExtMod.Negate = 0;
break;
case TGSI_UTIL_SIGN_SET:
reg->SrcRegister.Negate = 0;
reg->SrcRegisterExtMod.Absolute = 1;
reg->SrcRegisterExtMod.Negate = 1;
break;
case TGSI_UTIL_SIGN_TOGGLE:
reg->SrcRegister.Negate = 1;
reg->SrcRegisterExtMod.Absolute = 0;
reg->SrcRegisterExtMod.Negate = 0;
break;
case TGSI_UTIL_SIGN_KEEP:
reg->SrcRegister.Negate = 0;
reg->SrcRegisterExtMod.Absolute = 0;
reg->SrcRegisterExtMod.Negate = 0;
break;
default:
assert( 0 );
}
}

View file

@ -0,0 +1,70 @@
#if !defined TGSI_UTIL_H
#define TGSI_UTIL_H
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
void *
tgsi_align_128bit(
void *unaligned );
GLuint
tgsi_util_get_src_register_swizzle(
const struct tgsi_src_register *reg,
GLuint component );
GLuint
tgsi_util_get_src_register_extswizzle(
const struct tgsi_src_register_ext_swz *reg,
GLuint component);
GLuint
tgsi_util_get_full_src_register_extswizzle(
const struct tgsi_full_src_register *reg,
GLuint component );
void
tgsi_util_set_src_register_swizzle(
struct tgsi_src_register *reg,
GLuint swizzle,
GLuint component );
void
tgsi_util_set_src_register_extswizzle(
struct tgsi_src_register_ext_swz *reg,
GLuint swizzle,
GLuint component );
GLuint
tgsi_util_get_src_register_extnegate(
const struct tgsi_src_register_ext_swz *reg,
GLuint component );
void
tgsi_util_set_src_register_extnegate(
struct tgsi_src_register_ext_swz *reg,
GLuint negate,
GLuint component );
#define TGSI_UTIL_SIGN_CLEAR 0 /* Force positive */
#define TGSI_UTIL_SIGN_SET 1 /* Force negative */
#define TGSI_UTIL_SIGN_TOGGLE 2 /* Negate */
#define TGSI_UTIL_SIGN_KEEP 3 /* No change */
GLuint
tgsi_util_get_full_src_register_sign_mode(
const struct tgsi_full_src_register *reg,
GLuint component );
void
tgsi_util_set_full_src_register_sign_mode(
struct tgsi_full_src_register *reg,
GLuint sign_mode );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
#endif // !defined TGSI_UTIL_H

View file

@ -0,0 +1,3 @@
default:
cd ../../.. ; make

View file

@ -0,0 +1,499 @@
#include "tgsi_platform.h"
#include "tgsi_mesa.h"
/*
* Map mesa register file to SBIR register file.
*/
static GLuint
map_register_file( enum register_file file )
{
switch (file) {
case PROGRAM_UNDEFINED:
return TGSI_FILE_NULL;
case PROGRAM_TEMPORARY:
return TGSI_FILE_TEMPORARY;
//case PROGRAM_LOCAL_PARAM:
//case PROGRAM_ENV_PARAM:
case PROGRAM_STATE_VAR:
//case PROGRAM_NAMED_PARAM:
case PROGRAM_CONSTANT:
return TGSI_FILE_CONSTANT;
case PROGRAM_INPUT:
return TGSI_FILE_INPUT;
case PROGRAM_OUTPUT:
return TGSI_FILE_OUTPUT;
case PROGRAM_ADDRESS:
return TGSI_FILE_ADDRESS;
default:
assert (0);
return TGSI_FILE_NULL;
}
}
/*
* Map mesa register file index to SBIR index.
* Take special care when processing input and output indices.
*/
static GLuint
map_register_file_index( GLuint processor,
GLuint file,
GLuint index,
GLuint usage_bitmask )
{
GLuint mapped_index;
GLuint i;
switch (file)
{
case TGSI_FILE_INPUT:
assert (index < 32);
assert (usage_bitmask & (1 << index));
mapped_index = 0;
for (i = 0; i < index; i++) {
if (usage_bitmask & (1 << i))
mapped_index++;
}
break;
case TGSI_FILE_OUTPUT:
assert (usage_bitmask == 0);
if (processor == TGSI_PROCESSOR_FRAGMENT) {
if (index == FRAG_RESULT_DEPR) {
mapped_index = 0;
} else {
assert (index == FRAG_RESULT_COLR);
mapped_index = index + 1;
}
} else {
mapped_index = index;
}
break;
default:
mapped_index = index;
}
return mapped_index;
}
/*
* Map mesa texture target to SBIR texture target.
*/
static GLuint
map_texture_target( GLuint textarget )
{
switch (textarget) {
case TEXTURE_1D_INDEX:
return TGSI_TEXTURE_1D;
case TEXTURE_2D_INDEX:
return TGSI_TEXTURE_2D;
case TEXTURE_3D_INDEX:
return TGSI_TEXTURE_3D;
case TEXTURE_CUBE_INDEX:
return TGSI_TEXTURE_CUBE;
case TEXTURE_RECT_INDEX:
return TGSI_TEXTURE_RECT;
default:
assert (0);
}
return TGSI_TEXTURE_1D;
}
static GLuint
convert_sat( GLuint sat )
{
switch (sat) {
case SATURATE_OFF:
return TGSI_SAT_NONE;
case SATURATE_ZERO_ONE:
return TGSI_SAT_ZERO_ONE;
case SATURATE_PLUS_MINUS_ONE:
return TGSI_SAT_MINUS_PLUS_ONE;
default:
assert (0);
return TGSI_SAT_NONE;
}
}
static GLuint
convert_writemask( GLuint writemask )
{
assert (WRITEMASK_X == TGSI_WRITEMASK_X);
assert (WRITEMASK_Y == TGSI_WRITEMASK_Y);
assert (WRITEMASK_Z == TGSI_WRITEMASK_Z);
assert (WRITEMASK_W == TGSI_WRITEMASK_W);
assert ((writemask & ~TGSI_WRITEMASK_XYZW) == 0);
return writemask;
}
static GLboolean
compile_instruction( struct prog_instruction *inst,
struct tgsi_full_instruction *fullinst,
GLuint inputs_read,
GLuint processor )
{
GLuint i;
struct tgsi_full_dst_register *fulldst;
struct tgsi_full_src_register *fullsrc;
*fullinst = tgsi_default_full_instruction ();
fullinst->Instruction.Saturate = convert_sat (inst->SaturateMode);
fullinst->Instruction.NumDstRegs = 1;
fullinst->Instruction.NumSrcRegs = _mesa_num_inst_src_regs (inst->Opcode);
fulldst = &fullinst->FullDstRegisters[0];
fulldst->DstRegister.File =
map_register_file (inst->DstReg.File);
fulldst->DstRegister.Index =
map_register_file_index (processor,
fulldst->DstRegister.File,
inst->DstReg.Index,
0);
fulldst->DstRegister.WriteMask =
convert_writemask (inst->DstReg.WriteMask);
for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) {
GLuint j;
fullsrc = &fullinst->FullSrcRegisters[i];
fullsrc->SrcRegister.File =
map_register_file (inst->SrcReg[i].File);
fullsrc->SrcRegister.Index =
map_register_file_index (processor,
fullsrc->SrcRegister.File,
inst->SrcReg[i].Index,
inputs_read);
for (j = 0; j < 4; j++) {
GLuint swz;
swz = GET_SWZ(inst->SrcReg[i].Swizzle, j);
if (swz > SWIZZLE_W) {
tgsi_util_set_src_register_extswizzle (
&fullsrc->SrcRegisterExtSwz,
swz,
j);
} else {
tgsi_util_set_src_register_swizzle (
&fullsrc->SrcRegister,
swz,
j);
}
}
if (inst->SrcReg[i].NegateBase == NEGATE_XYZW) {
fullsrc->SrcRegister.Negate = 1;
} else if (inst->SrcReg[i].NegateBase != NEGATE_NONE) {
if (inst->SrcReg[i].NegateBase & NEGATE_X)
fullsrc->SrcRegisterExtSwz.NegateX = 1;
if (inst->SrcReg[i].NegateBase & NEGATE_Y)
fullsrc->SrcRegisterExtSwz.NegateY = 1;
if (inst->SrcReg[i].NegateBase & NEGATE_Z)
fullsrc->SrcRegisterExtSwz.NegateZ = 1;
if (inst->SrcReg[i].NegateBase & NEGATE_W)
fullsrc->SrcRegisterExtSwz.NegateW = 1;
}
if (inst->SrcReg[i].Abs)
fullsrc->SrcRegisterExtMod.Absolute = 1;
if (inst->SrcReg[i].NegateAbs)
fullsrc->SrcRegisterExtMod.Negate = 1;
if (inst->SrcReg[i].RelAddr) {
fullsrc->SrcRegister.Indirect = 1;
fullsrc->SrcRegisterInd.File = TGSI_FILE_ADDRESS;
fullsrc->SrcRegisterInd.Index = 0;
}
}
switch (inst->Opcode) {
case OPCODE_ARL:
fullinst->Instruction.Opcode = TGSI_OPCODE_ARL;
break;
case OPCODE_ABS:
fullinst->Instruction.Opcode = TGSI_OPCODE_ABS;
break;
case OPCODE_ADD:
fullinst->Instruction.Opcode = TGSI_OPCODE_ADD;
break;
case OPCODE_CMP:
fullinst->Instruction.Opcode = TGSI_OPCODE_CMP;
break;
case OPCODE_COS:
fullinst->Instruction.Opcode = TGSI_OPCODE_COS;
break;
case OPCODE_DP3:
fullinst->Instruction.Opcode = TGSI_OPCODE_DP3;
break;
case OPCODE_DP4:
fullinst->Instruction.Opcode = TGSI_OPCODE_DP4;
break;
case OPCODE_DPH:
fullinst->Instruction.Opcode = TGSI_OPCODE_DPH;
break;
case OPCODE_DST:
fullinst->Instruction.Opcode = TGSI_OPCODE_DST;
break;
case OPCODE_EX2:
fullinst->Instruction.Opcode = TGSI_OPCODE_EX2;
break;
case OPCODE_FLR:
fullinst->Instruction.Opcode = TGSI_OPCODE_FLR;
break;
case OPCODE_FRC:
fullinst->Instruction.Opcode = TGSI_OPCODE_FRC;
break;
case OPCODE_KIL:
fullinst->Instruction.Opcode = TGSI_OPCODE_KIL;
break;
case OPCODE_LG2:
fullinst->Instruction.Opcode = TGSI_OPCODE_LG2;
break;
case OPCODE_LIT:
fullinst->Instruction.Opcode = TGSI_OPCODE_LIT;
break;
case OPCODE_LRP:
fullinst->Instruction.Opcode = TGSI_OPCODE_LRP;
break;
case OPCODE_MAD:
fullinst->Instruction.Opcode = TGSI_OPCODE_MAD;
break;
case OPCODE_MAX:
fullinst->Instruction.Opcode = TGSI_OPCODE_MAX;
break;
case OPCODE_MIN:
fullinst->Instruction.Opcode = TGSI_OPCODE_MIN;
break;
case OPCODE_MOV:
fullinst->Instruction.Opcode = TGSI_OPCODE_MOV;
break;
case OPCODE_MUL:
fullinst->Instruction.Opcode = TGSI_OPCODE_MUL;
break;
case OPCODE_POW:
fullinst->Instruction.Opcode = TGSI_OPCODE_POW;
break;
case OPCODE_RCP:
fullinst->Instruction.Opcode = TGSI_OPCODE_RCP;
break;
case OPCODE_RSQ:
fullinst->Instruction.Opcode = TGSI_OPCODE_RSQ;
tgsi_util_set_full_src_register_sign_mode (&fullinst->FullSrcRegisters[0],
TGSI_UTIL_SIGN_CLEAR);
break;
case OPCODE_SCS:
fullinst->Instruction.Opcode = TGSI_OPCODE_SCS;
fulldst->DstRegister.WriteMask &= TGSI_WRITEMASK_XY;
break;
case OPCODE_SGE:
fullinst->Instruction.Opcode = TGSI_OPCODE_SGE;
break;
case OPCODE_SIN:
fullinst->Instruction.Opcode = TGSI_OPCODE_SIN;
break;
case OPCODE_SLT:
fullinst->Instruction.Opcode = TGSI_OPCODE_SLT;
break;
case OPCODE_SUB:
fullinst->Instruction.Opcode = TGSI_OPCODE_SUB;
break;
case OPCODE_SWZ:
fullinst->Instruction.Opcode = TGSI_OPCODE_SWZ;
break;
case OPCODE_TEX:
fullinst->Instruction.Opcode = TGSI_OPCODE_TEX;
fullinst->Instruction.NumSrcRegs = 2;
fullinst->InstructionExtTexture.Texture = map_texture_target (inst->TexSrcTarget);
fullinst->FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
fullinst->FullSrcRegisters[1].SrcRegister.Index = inst->TexSrcUnit;
break;
case OPCODE_TXB:
fullinst->Instruction.Opcode = TGSI_OPCODE_TXB;
fullinst->Instruction.NumSrcRegs = 2;
fullinst->InstructionExtTexture.Texture = map_texture_target (inst->TexSrcTarget);
fullinst->FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
fullinst->FullSrcRegisters[1].SrcRegister.Index = inst->TexSrcUnit;
break;
case OPCODE_TXP:
fullinst->Instruction.Opcode = TGSI_OPCODE_TEX;
fullinst->Instruction.NumSrcRegs = 2;
fullinst->InstructionExtTexture.Texture = map_texture_target (inst->TexSrcTarget);
fullinst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtDivide = TGSI_EXTSWIZZLE_W;
fullinst->FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
fullinst->FullSrcRegisters[1].SrcRegister.Index = inst->TexSrcUnit;
break;
case OPCODE_XPD:
fullinst->Instruction.Opcode = TGSI_OPCODE_XPD;
fulldst->DstRegister.WriteMask &= TGSI_WRITEMASK_XYZ;
break;
case OPCODE_END:
return GL_TRUE;
default:
assert (0);
}
return GL_FALSE;
}
GLboolean
tgsi_compile_fp_program( const struct gl_fragment_program *program,
struct tgsi_token *tokens,
GLuint max_token_count,
GLuint *token_count )
{
GLuint i, ti;
struct tgsi_header *header;
struct tgsi_full_declaration fulldecl;
struct tgsi_full_instruction fullinst;
struct tgsi_full_dst_register *fulldst;
struct tgsi_full_src_register *fullsrc;
GLuint inputs_read;
*(struct tgsi_version *) &tokens[0] = tgsi_build_version ();
header = (struct tgsi_header *) &tokens[1];
*header = tgsi_build_header ();
ti = 2;
/*
* Input 0 is always read, at least implicitly by the instruction generated
* above, so mark it as used.
*/
inputs_read = program->Base.InputsRead | 1;
/*
* Declare input attributes.
*/
fulldecl = tgsi_default_full_declaration();
fulldecl.Declaration.File = TGSI_FILE_INPUT;
fulldecl.Declaration.Declare = TGSI_DECLARE_RANGE;
fulldecl.Declaration.Interpolate = 1;
/*
* Do not interpolate fragment position.
*/
fulldecl.u.DeclarationRange.First = 0;
fulldecl.u.DeclarationRange.Last = 0;
fulldecl.Interpolation.Interpolate = TGSI_INTERPOLATE_CONSTANT;
ti += tgsi_build_full_declaration(
&fulldecl,
&tokens[ti],
header,
max_token_count - ti );
/*
* Interpolate generic attributes.
*/
fulldecl.u.DeclarationRange.First = 1;
fulldecl.u.DeclarationRange.Last = 1;
for( i = 1; i < 32; i++ ) {
if( inputs_read & (1 << i) ) {
fulldecl.u.DeclarationRange.Last++;
}
}
fulldecl.Interpolation.Interpolate = TGSI_INTERPOLATE_LINEAR;
ti += tgsi_build_full_declaration(
&fulldecl,
&tokens[ti],
header,
max_token_count - ti );
/*
* Copy input fragment xyz to output xyz.
* If the shader writes depth, do not copy the z component.
*/
fullinst = tgsi_default_full_instruction ();
fullinst.Instruction.Opcode = TGSI_OPCODE_MOV;
fullinst.Instruction.NumDstRegs = 1;
fullinst.Instruction.NumSrcRegs = 1;
fulldst = &fullinst.FullDstRegisters[0];
fulldst->DstRegister.File = TGSI_FILE_OUTPUT;
fulldst->DstRegister.Index = 0;
if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR)) {
fulldst->DstRegister.WriteMask = TGSI_WRITEMASK_XY;
} else {
fulldst->DstRegister.WriteMask = TGSI_WRITEMASK_XYZ;
}
fullsrc = &fullinst.FullSrcRegisters[0];
fullsrc->SrcRegister.File = TGSI_FILE_INPUT;
fullsrc->SrcRegister.Index = 0;
ti += tgsi_build_full_instruction (&fullinst,
&tokens[ti],
header,
max_token_count - ti);
for( i = 0; i < program->Base.NumInstructions; i++ ) {
if (compile_instruction (&program->Base.Instructions[i],
&fullinst,
inputs_read,
TGSI_PROCESSOR_FRAGMENT)) {
assert (i == program->Base.NumInstructions - 1);
tgsi_dump (tokens, TGSI_DUMP_NO_IGNORED | TGSI_DUMP_NO_DEFAULT);
break;
}
ti += tgsi_build_full_instruction (&fullinst,
&tokens[ti],
header,
max_token_count - ti);
}
return GL_TRUE;
}
GLboolean
tgsi_compile_vp_program( const struct gl_vertex_program *program,
struct tgsi_token *tokens,
GLuint max_token_count,
GLuint *token_count )
{
GLuint ii, ti;
struct tgsi_header *header;
struct tgsi_processor *processor;
struct tgsi_full_instruction fullinst;
GLuint inputs_read = ~0;
*(struct tgsi_version *) &tokens[0] = tgsi_build_version ();
header = (struct tgsi_header *) &tokens[1];
*header = tgsi_build_header ();
processor = (struct tgsi_processor *) &tokens[2];
*processor = tgsi_build_processor (TGSI_PROCESSOR_VERTEX, header);
ti = 3;
for (ii = 0; ii < program->Base.NumInstructions; ii++) {
if (compile_instruction (&program->Base.Instructions[ii],
&fullinst,
inputs_read,
TGSI_PROCESSOR_VERTEX)) {
assert (ii == program->Base.NumInstructions - 1);
tgsi_dump (tokens, TGSI_DUMP_NO_IGNORED | TGSI_DUMP_NO_DEFAULT);
break;
}
ti += tgsi_build_full_instruction (&fullinst,
&tokens[ti],
header,
max_token_count - ti);
}
return GL_TRUE;
}

View file

@ -0,0 +1,25 @@
#if !defined MESA_TO_TGSI_H
#define MESA_TO_TGSI_H
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
GLboolean
tgsi_mesa_compile_fp_program(
const struct gl_fragment_program *program,
struct tgsi_token *tokens,
GLuint maxTokens );
GLboolean
tgsi_mesa_compile_vp_program(
const struct gl_vertex_program *program,
struct tgsi_token *tokens,
GLuint maxTokens );
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
#endif // !defined MESA_TO_TGSI_H

View file

@ -0,0 +1,8 @@
#if !defined TGSI_MESA_H
#define TGSI_MESA_H
#include "../core/tgsi_core.h"
#include "mesa_to_tgsi.h"
#endif // !defined TGSI_MESA_H

View file

@ -0,0 +1,18 @@
#if !defined TGSI_PLATFORM_H
#define TGSI_PLATFORM_H
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
#include "imports.h"
#include "mtypes.h"
#include "prog_instruction.h"
#include "program.h"
#if defined __cplusplus
} // extern "C"
#endif // defined __cplusplus
#endif // !defined TGSI_PLATFORM_H

View file

@ -179,6 +179,16 @@ SOFTPIPE_SOURCES = \
pipe/softpipe/sp_state_setup.c \
pipe/softpipe/sp_state_surface.c
TGSICORE_SOURCES = \
pipe/tgsi/core/tgsi_build.c \
pipe/tgsi/core/tgsi_dump.c \
pipe/tgsi/core/tgsi_exec.c \
pipe/tgsi/core/tgsi_parse.c \
pipe/tgsi/core/tgsi_util.c
TGSIMESA_SOURCES = \
pipe/tgsi/mesa/mesa_to_tgsi.c
STATETRACKER_SOURCES = \
state_tracker/st_atom.c \
state_tracker/st_atom_alphatest.c \
@ -344,8 +354,10 @@ SOLO_SOURCES = \
$(MATH_SOURCES) \
$(VBO_SOURCES) \
$(VF_SOURCES) \
$(SOFTPIPE_SOURCES) \
$(STATETRACKER_SOURCES) \
$(SOFTPIPE_SOURCES) \
$(TGSICORE_SOURCES) \
$(TGSIMESA_SOURCES) \
$(STATETRACKER_SOURCES) \
$(TNL_SOURCES) \
$(SHADER_SOURCES) \
$(SWRAST_SOURCES) \
@ -391,4 +403,5 @@ INCLUDE_DIRS = \
-I$(TOP)/src/mesa/shader/grammar \
-I$(TOP)/src/mesa/shader/slang \
-I$(TOP)/src/mesa/swrast \
-I$(TOP)/src/mesa/swrast_setup
-I$(TOP)/src/mesa/swrast_setup \
-I$(TOP)/src/mesa/pipe/tgsi

View file

@ -41,6 +41,7 @@
#include "program.h"
#include "programopt.h"
#include "tnl/tnl.h"
#include "pipe/tgsi/mesa/tgsi_mesa.h"
static void st_bind_program( GLcontext *ctx,
@ -89,7 +90,7 @@ static struct gl_program *st_new_program( GLcontext *ctx,
static void st_delete_program( GLcontext *ctx,
struct gl_program *prog )
{
{
_mesa_delete_program( ctx, prog );
}
@ -115,7 +116,7 @@ static void st_program_string_notify( GLcontext *ctx,
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
p->id = st->program_id++;
p->id = st->program_id++;
#if 0
p->param_state = p->Base.Base.Parameters->StateFlags;
p->translated = 0;
@ -128,6 +129,14 @@ static void st_program_string_notify( GLcontext *ctx,
_mesa_append_fog_code(ctx, &p->Base);
p->Base.FogOption = GL_NONE;
}
/* XXX: Not hooked-up yet. */
{
struct tgsi_token tokens[1024];
tgsi_mesa_compile_fp_program( prog, tokens, 1024 );
tgsi_dump( tokens, TGSI_DUMP_VERBOSE );
}
}
}
else if (target == GL_VERTEX_PROGRAM_ARB) {
@ -148,7 +157,6 @@ void st_init_cb_program( struct st_context *st )
*/
st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
st->ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
assert(functions->ProgramStringNotify == _tnl_program_string);
functions->BindProgram = st_bind_program;

View file

@ -52,7 +52,8 @@ create_texture_object(struct gl_texture_object *texObj)
if (!pto)
return NULL;
assert(texObj->Complete);
/* XXX: Member not defined. Comment-out to get it compile. */
/*assert(texObj->Complete);*/
switch (texObj->Target) {
case GL_TEXTURE_1D: