Search
lxdream.org :: lxdream/test/testrend.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename test/testrend.c
changeset 213:da6b1904f67b
next216:657ce4d3edd9
author nkeynes
date Fri Aug 18 09:33:19 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Initial rendering tests (no support for result comparison yet)
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/testrend.c Fri Aug 18 09:33:19 2006 +0000
1.3 @@ -0,0 +1,134 @@
1.4 +/**
1.5 + * $Id: testrend.c,v 1.1 2006-08-18 09:33:19 nkeynes Exp $
1.6 + *
1.7 + * Renderer test cases
1.8 + *
1.9 + * Copyright (c) 2006 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +#include <stdio.h>
1.22 +#include "testdata.h"
1.23 +#include "pvr.h"
1.24 +#include "lib.h"
1.25 +#include "asic.h"
1.26 +
1.27 +#define OBJ_START 0x00010000
1.28 +#define OBJ_LENGTH 0x00010000
1.29 +#define TILE_START 0x00060000
1.30 +#define TILE_LENGTH 0x00010000
1.31 +#define TILEMAP_ADDR 0x050B2C8
1.32 +#define RENDER_ADDR 0x00600000
1.33 +
1.34 +struct ta_config default_ta_config = { 0x00111111, GRID_SIZE(640,480), OBJ_START,
1.35 + OBJ_START+OBJ_LENGTH, TILE_START+TILE_LENGTH,
1.36 + TILE_START, TILE_START+TILE_LENGTH };
1.37 +
1.38 +struct render_config default_render_config = { TILEMAP_ADDR, RENDER_ADDR, 640, 480,
1.39 + 0x00000009, 0.2, 1.0 };
1.40 +
1.41 +int test_render( test_data_t test_case )
1.42 +{
1.43 + int i;
1.44 +
1.45 + /* Check input */
1.46 + test_data_block_t input = get_test_data(test_case, "input");
1.47 + test_data_block_t event = get_test_data(test_case, "event");
1.48 + test_data_block_t backplane = get_test_data(test_case, "backplane");
1.49 + if( input == NULL ) {
1.50 + fprintf( stderr, "Skipping test '%s' - no input\n", test_case->test_name );
1.51 + return -1;
1.52 + }
1.53 + if( event == NULL ) {
1.54 + fprintf( stderr, "Skipping test '%s' - no event list\n", test_case->test_name );
1.55 + }
1.56 +
1.57 + test_data_block_t config_data = get_test_data( test_case, "config" );
1.58 + struct ta_config *config = &default_ta_config;
1.59 + if( config_data != NULL ) {
1.60 + if( config_data->length != sizeof(struct ta_config) ) {
1.61 + fprintf( stderr, "Invalid config data length %d - aborting test %s\n",
1.62 + config_data->length, test_case->test_name );
1.63 + return -1;
1.64 + }
1.65 + config = (struct ta_config *)config_data->data;
1.66 + }
1.67 +
1.68 + /* Send TA data */
1.69 + asic_clear();
1.70 + pvr_init();
1.71 + ta_init(config);
1.72 + default_render_config.polybuf = config->obj_start & 0x00F00000;
1.73 + if( pvr_dma_write( 0x10000000, input->data, input->length, 0 ) == -1 ) {
1.74 + return -1;
1.75 + }
1.76 +
1.77 + /* Wait for events */
1.78 + for( i=0; i<event->length; i++ ) {
1.79 + if( asic_wait( event->data[i] ) == -1 ) {
1.80 + fprintf( stderr, "Test %s: failed (Timeout waiting for event %d)\n",
1.81 + test_case->test_name, event->data[i] );
1.82 + asic_dump( stderr );
1.83 + return -1;
1.84 + }
1.85 + }
1.86 +
1.87 + /* Write backplane (if any) */
1.88 + if( backplane != NULL ) {
1.89 + uint32_t bgplane = pvr_get_objbuf_posn();
1.90 + memcpy( (char *)(PVR_VRAM_BASE + bgplane), backplane->data, backplane->length );
1.91 + bgplane -= default_render_config.polybuf;
1.92 + render_set_backplane( (bgplane << 1) | 0x01000000 );
1.93 + } else {
1.94 + render_set_backplane( 0 );
1.95 + }
1.96 + /* Setup the tilemap */
1.97 + pvr_build_tilemap1( TILEMAP_ADDR, config, 0x20000000 );
1.98 + render_start( &default_render_config );
1.99 + if( asic_wait( EVENT_PVR_RENDER_DONE ) == -1 ) {
1.100 + fprintf( stderr, "Test %s: failed (timeout waiting for render)\n",
1.101 + test_case->test_name );
1.102 + asic_dump( stderr );
1.103 + return -1;
1.104 + }
1.105 + asic_wait( EVENT_RETRACE );
1.106 + display_render( &default_render_config );
1.107 + return 0;
1.108 +
1.109 +}
1.110 +
1.111 +int main( int argc, char *argv[] )
1.112 +{
1.113 + int test_cases = 0;
1.114 + int test_failures = 0;
1.115 + test_data_t test_data = load_test_dataset(stdin);
1.116 + test_data_t test_case = test_data;
1.117 +
1.118 + asic_mask_all();
1.119 + pvr_init();
1.120 +
1.121 + while( test_case != NULL ) {
1.122 + test_cases++;
1.123 + int result = test_render(test_case);
1.124 + if( result != 0 ) {
1.125 + test_failures++;
1.126 + }
1.127 + test_case = test_case->next;
1.128 + }
1.129 + free_test_dataset(test_data);
1.130 + if( test_failures != 0 ) {
1.131 + fprintf( stderr, "%d/%d test failures!\n", test_failures, test_cases );
1.132 + return 1;
1.133 + } else {
1.134 + fprintf( stderr, "%d tests OK\n", test_cases );
1.135 + return 0;
1.136 + }
1.137 +}
.