Search
lxdream.org :: lxdream/test/testta.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/testta.c
changeset 190:f7653df5e832
prev185:6755a04c447f
next193:31151fcc3cb7
author nkeynes
date Wed Aug 02 04:13:15 2006 +0000 (13 years ago)
permissions -rw-r--r--
last change Add many more TA test cases (a couple of corner cases aren't 100% correct
yet, TBA)
Add new test "testregs" to check register masks (currently just PVR registers)
file annotate diff log raw
1.1 --- a/test/testta.c Tue Jul 11 01:35:27 2006 +0000
1.2 +++ b/test/testta.c Wed Aug 02 04:13:15 2006 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: testta.c,v 1.1 2006-07-11 01:35:23 nkeynes Exp $
1.6 + * $Id: testta.c,v 1.2 2006-08-02 04:13:15 nkeynes Exp $
1.7 *
1.8 * Tile Accelerator test cases
1.9 *
1.10 @@ -25,51 +25,197 @@
1.11 #define DMA_ALIGN(x) ((void *)((((unsigned int)(x))+0x1F)&0xFFFFFFE0))
1.12
1.13 #define OBJ_START 0x00010000
1.14 +#define OBJ_LENGTH 0x00010000
1.15 #define TILE_START 0x00060000
1.16 +#define TILE_LENGTH 0x00010000
1.17 +
1.18 +#define MEM_FILL 0xFE
1.19 +
1.20 +int ta_tile_sizes[4] = { 0, 32, 64, 128 };
1.21 +
1.22 +#define TILE_SIZE(cfg, tile) ta_tile_sizes[((((cfg->ta_cfg) >> (4*tile))&0x03))]
1.23 +
1.24 +struct ta_config default_ta_config = { 0x00111111, GRID_SIZE(640,480), OBJ_START,
1.25 + OBJ_START+OBJ_LENGTH, TILE_START+TILE_LENGTH,
1.26 + TILE_START, TILE_START+TILE_LENGTH };
1.27 +
1.28 +
1.29 +int tile_sizes[5];
1.30 +int tile_events[5] = { EVENT_PVR_OPAQUE_DONE, EVENT_PVR_OPAQUEMOD_DONE,
1.31 + EVENT_PVR_TRANS_DONE, EVENT_PVR_TRANSMOD_DONE,
1.32 + EVENT_PVR_PUNCHOUT_DONE };
1.33 +char *tile_names[5] = { "Opaque", "Opaque Mod", "Trans", "Trans Mod", "Punch Out" };
1.34
1.35 #define FLOAT(p) *((float *)(p))
1.36
1.37 +void make_expected_buffer( test_data_block_t expected_block, char *expect, int length )
1.38 +{
1.39 + memset( expect, MEM_FILL,length );
1.40 +
1.41 + if( expected_block != NULL ) {
1.42 + if( expected_block->length > length ) {
1.43 + fprintf( stderr, "Test data error: expected tile length is %d, but tile size is only %d\n", expected_block->length, length );
1.44 + return;
1.45 + }
1.46 + memcpy( expect, expected_block->data, expected_block->length );
1.47 +
1.48 + if( expected_block->length <= length-4 ) {
1.49 + *((unsigned int *)&expect[expected_block->length]) = 0xF0000000;
1.50 + }
1.51 + }
1.52 +}
1.53 +
1.54 +int tilematrix_block_compare( test_data_block_t expected_block, char *tile_ptrs[], int tile_type, int offset )
1.55 +{
1.56 + int tile_size = tile_sizes[tile_type];
1.57 + char expect[tile_size];
1.58 +
1.59 + make_expected_buffer(expected_block, expect, tile_size);
1.60 + return memcmp( expect, tile_ptrs[tile_type]+(offset*tile_sizes[tile_type]), tile_size );
1.61 +}
1.62 +
1.63 int test_ta( test_data_t test_case )
1.64 {
1.65 char buf[1024];
1.66 unsigned int *p = DMA_ALIGN(buf);
1.67 unsigned int *data = p;
1.68 + int haveFailure = 0;
1.69 + int checkedTile[5] = {0,0,0,0,0};
1.70 + int i;
1.71 + int hsegs,vsegs;
1.72 + char *result = (char *)(PVR_VRAM_BASE+OBJ_START);
1.73 + char *tilematrix = (char *)(PVR_VRAM_BASE+TILE_START+TILE_LENGTH);
1.74 + char *tile_ptrs[5];
1.75
1.76 asic_clear();
1.77
1.78 - memset( PVR_VRAM_BASE, 0, 0x00080000 );
1.79 - ta_init(640,480, OBJ_START, 0x10000, TILE_START, 0x10000 );
1.80 + memset( PVR_VRAM_BASE, MEM_FILL, 0x00090000 );
1.81 + test_data_block_t config_data = get_test_data( test_case, "config" );
1.82 + struct ta_config *config = &default_ta_config;
1.83 + if( config_data != NULL ) {
1.84 + if( config_data->length != sizeof(struct ta_config) ) {
1.85 + fprintf( stderr, "Invalid config data length %d - aborting test %s\n",
1.86 + config_data->length, test_case->test_name );
1.87 + return -1;
1.88 + }
1.89 + config = (struct ta_config *)config_data->data;
1.90 + }
1.91 + ta_init(config);
1.92 + for( i=0; i<5; i++ ) {
1.93 + tile_sizes[i] = TILE_SIZE(config,i);
1.94 + }
1.95 + hsegs = (config->grid_size & 0xFFFF)+1;
1.96 + vsegs = (config->grid_size >> 16) + 1;
1.97 + tile_ptrs[0] = tilematrix;
1.98 + tile_ptrs[1] = tile_ptrs[0] + (hsegs*vsegs*tile_sizes[0]);
1.99 + tile_ptrs[2] = tile_ptrs[1] + (hsegs*vsegs*tile_sizes[1]);
1.100 + tile_ptrs[3] = tile_ptrs[2] + (hsegs*vsegs*tile_sizes[2]);
1.101 + tile_ptrs[4] = tile_ptrs[3] + (hsegs*vsegs*tile_sizes[3]);
1.102 +
1.103
1.104 test_data_block_t input = get_test_data(test_case, "input");
1.105 test_data_block_t output = get_test_data(test_case, "output");
1.106 + test_data_block_t error = get_test_data(test_case, "error");
1.107 if( input == NULL || output == NULL ) {
1.108 fprintf( stderr, "Skipping test case '%s': data incomplete\n", test_case->test_name );
1.109 return -1;
1.110 }
1.111
1.112 - fprintf( stderr, "Before test start: %s\n", test_case->test_name );
1.113 if( pvr_dma_write( 0x10000000, input->data, input->length, 0 ) == -1 ) {
1.114 return -1;
1.115 }
1.116 - if( asic_wait( EVENT_PVR_OPAQUE_DONE ) == -1 ) {
1.117 - fprintf( stderr, "Timeout waiting for Opaque Done event\n" );
1.118 - ta_dump_regs();
1.119 - asic_dump( stderr );
1.120 +
1.121 + if( error != NULL ) {
1.122 + for( i=0; i<error->length; i++ ) {
1.123 + if( asic_wait( error->data[i] ) == -1 ) {
1.124 + fprintf( stderr, "Test %s: failed (Timeout waiting for error event %d)\n",
1.125 + test_case->test_name, error->data[i] );
1.126 + asic_dump( stderr );
1.127 + return -1;
1.128 + }
1.129 + }
1.130 }
1.131
1.132 - char *result = (char *)(PVR_VRAM_BASE+OBJ_START);
1.133 + for( i=0; i<MAX_DATA_BLOCKS; i++ ) {
1.134 + test_data_block_t data = &test_case->item[i];
1.135 + int tile, x, y, offset;
1.136 + if( data->name != NULL ) {
1.137 + int result = sscanf( data->name, "tile %d %dx%d", &tile, &x, &y );
1.138 + if( result == 1 ) {
1.139 + x = y = 0;
1.140 + } else if( result != 3 ) {
1.141 + continue;
1.142 + }
1.143 + tile--;
1.144 + offset = x + (y * hsegs);
1.145 +
1.146 + if( checkedTile[tile] == 0 ) {
1.147 + if( asic_wait( tile_events[tile] ) == -1 ) {
1.148 + fprintf( stderr, "Test %s: failed (Timeout waiting for %s done event)\n",
1.149 + test_case->test_name, tile_names[tile] );
1.150 + ta_dump_regs();
1.151 + asic_dump( stderr );
1.152 + haveFailure = 1;
1.153 + }
1.154 + }
1.155 +
1.156 + if( tilematrix_block_compare( data, tile_ptrs, tile, offset ) != 0 ) {
1.157 + fprintf( stderr, "Test %s: Failed (%s matrix %dx%d). ",
1.158 + test_case->test_name, tile_names[tile], x, y );
1.159 + fwrite_diff32( stderr, data->data, data->length,
1.160 + tile_ptrs[tile] + (tile_sizes[tile]*offset), tile_sizes[tile] );
1.161 + haveFailure = 1;
1.162 + }
1.163 + checkedTile[tile] = 1;
1.164 + }
1.165 + }
1.166 +
1.167 + /* Overflow */
1.168 + test_data_block_t plist = get_test_data(test_case, "plist" );
1.169 + if( plist != NULL ) {
1.170 + unsigned int plist_posn, plist_end;
1.171 + if( config->ta_cfg & 0x00100000 ) { /* Descending */
1.172 + plist_posn = pvr_get_plist_posn() + tile_sizes[0];
1.173 + plist_end = config->plist_start;
1.174 + } else {
1.175 + plist_posn = config->plist_start;
1.176 + plist_end = pvr_get_plist_posn();
1.177 + }
1.178 + char *plist_data = (char *)(PVR_VRAM_BASE + plist_posn);
1.179 + if( test_block_compare( plist, plist_data, plist_end-plist_posn ) != 0 ) {
1.180 + fprintf( stderr, "Test %s: Failed (Plist buffer)", test_case->test_name );
1.181 + fwrite_diff32( stderr, plist->data, plist->length, (char *)plist_data,
1.182 + plist_end - plist_posn );
1.183 + haveFailure = 1;
1.184 + }
1.185 + }
1.186 +
1.187 + /* Vertex buffer */
1.188 int result_length = pvr_get_objbuf_size();
1.189 if( test_block_compare( output, result, result_length ) != 0 ) {
1.190 - fprintf( stderr, "Test %s: Failed. Expected %d bytes:\n", test_case->test_name, output->length );
1.191 - fwrite_dump( stderr, output->data, output->length );
1.192 - fprintf( stderr, "but was %d bytes =>\n", result_length );
1.193 - fwrite_dump( stderr, result, result_length );
1.194 - return -1;
1.195 - } else {
1.196 - fprintf( stdout, "Test %s: OK\n", test_case->test_name );
1.197 - return 0;
1.198 + fprintf( stderr, "Test %s: Failed (Vertex buffer). ", test_case->test_name );
1.199 + fwrite_diff32( stderr, output->data, output->length, result, result_length );
1.200 + haveFailure = 1;
1.201 }
1.202
1.203 +
1.204 + for( i=0; i<5; i++ ) {
1.205 + if( checkedTile[i] == 0 ) {
1.206 + if( tilematrix_block_compare( NULL, tile_ptrs, i, 0 ) != 0 ) {
1.207 + fprintf( stderr, "Test %s: Failed (%s matrix). ", test_case->test_name, tile_names[i] );
1.208 + fprintf( stderr, "Expected empty buffer at %08X, but was =>\n",
1.209 + (unsigned int)(tile_ptrs[i]) );
1.210 + fwrite_dump( stderr, tile_ptrs[i], tile_sizes[i] );
1.211 + // fwrite_dump( stderr, tile_ptrs[i] - 128, 256 );
1.212 +
1.213 + }
1.214 + }
1.215 + }
1.216 + if( haveFailure )
1.217 + return -1;
1.218 +
1.219 + fprintf( stdout, "Test %s: OK\n", test_case->test_name );
1.220 + return 0;
1.221 }
1.222
1.223 int main( int argc, char *argv[] )
.