/* Test texenv-combine with a single texture unit. */ static bool run_single_texture_test(const struct test_param test_params[], const char *test_name) { assert(num_tex_units == 1); setup_colors(); const int num_tests = count_test_combinations(test_params); for (int test = 0; test < num_tests; test += test_stride) { /* 0. Setup state */ reset_machine(); setup_test_env(test, test_params); /* 1. Render with OpenGL */ glTexCoord2f(0, 0); /* use texcoord (0,0) for all vertices */ piglit_draw_rect(-1, -1, 2, 2); /* 2. Compute expected result */ float expected[4]; expected[3] = -1.0f; compute_tex_combine(0, machine.frag_color, expected); /* 3. Compare rendered result to expected result */ if (!piglit_probe_pixel_rgba(0, 0, expected)) { printf("Single Texture Test %s %d\n", test_name, test); print_test_env(test, test_params); return false; } } return true; }
TOKEN skip_nontokens_file(FILE* file, STATE_MACHINE* sm) { long int penultimate_position = 0; long int last_position = ftell(file); // Do transitions until execute_transition returns an error (no valid transition) while (1) { int c = tolower(fgetc(file)); if (c == EOF) { if (sm->current_state->return_token == T_INVALID) { TOKEN t = {T_INVALID, NULL}; fprintf(stderr, "Syntax error on file position %ld.\n", last_position); return t; } else { TOKEN t = {T_EOF, NULL}; return t; } } if (execute_transition(sm, c)) { // If execute_transition fails, we went through more characters than needed. // Go back one position in the file, and return the code of the current state. fseek(file, last_position, SEEK_SET); break; } if (c == '\n') { f_line++; f_column = 0; } else { f_column++; } penultimate_position = last_position; last_position = ftell(file); } // Set sm back to its initial state so it can skip more whitespace later. int ret = sm->current_state->return_token; if (ret == T_INVALID) { fprintf(stderr, "Syntax error on file position %ld.\n", last_position); } if (ret == T_REWIND_ONE) { f_column--; fseek(file, penultimate_position, SEEK_SET); } reset_machine(sm); TOKEN t = {ret, NULL}; return t; }
/* * There are global variables that must be zeroed before any execution. * In case of errors, there will be a LONGJMP(), and the variables will * have to be cleared explicitely. They are normally maintained by the * code that use them. * * This routine must only be called from top level, not from inside * stack machine execution (as stack will be cleared). */ void clear_state() { current_object = 0; set_command_giver(0); current_interactive = 0; previous_ob = 0; current_prog = 0; caller_type = 0; reset_machine(0); /* Pop down the stack. */ } /* clear_state() */
/* * There are global variables that must be zeroed before any execution. * In case of errors, there will be a longjmp(), and the variables will * have to be cleared explicitely. They are normally maintained by the * code that use them. * * This routine must only be called from top level, not from inside * stack machine execution (as stack will be cleared). */ void clear_state(void) { extern struct object *previous_ob; current_object = 0; command_giver = 0; current_interactive = 0; previous_ob = 0; current_prog = 0; reset_machine(); /* Pop down the stack. */ }
void piglit_init(int argc, char **argv) { piglit_require_extension("GL_EXT_texture_env_combine"); /* Test the availability of the DOT3 extenstion */ have_dot3 = piglit_is_extension_supported("GL_EXT_texture_env_dot3"); have_crossbar = piglit_is_extension_supported("GL_ARB_texture_env_crossbar"); have_combine3 = piglit_is_extension_supported("GL_ATI_texture_env_combine3"); /* Allocate our textures */ glGenTextures(MAX_TEX_UNITS, textures); reset_machine(); num_tex_units = 1; for (int i = 1; i < argc; i++) if (!strcmp(argv[i], "--quick")) test_stride = 67; /* a prime number */ }
int main P2(int, argc, char **, argv) { time_t tm; int i, new_mudlib = 0, got_defaults = 0; int no_ip_demon = 0; char *p; char version_buf[80]; #if 0 int dtablesize; #endif error_context_t econ; #if !defined(LATTICE) && !defined(OLD_ULTRIX) && !defined(sequent) && \ !defined(sgi) void tzset(); #endif struct lpc_predef_s predefs; #if !defined(__SASC) && (defined(AMITCP) || defined(AS225)) amiga_sockinit(); atexit(amiga_sockexit); #endif #ifdef WRAPPEDMALLOC wrappedmalloc_init(); #endif /* WRAPPEDMALLOC */ #ifdef DEBUGMALLOC MDinit(); #endif #if (defined(PROFILING) && !defined(PROFILE_ON) && defined(HAS_MONCONTROL)) moncontrol(0); #endif #if !defined(OLD_ULTRIX) && !defined(LATTICE) && !defined(sequent) tzset(); #endif boot_time = get_current_time(); const0.type = T_NUMBER; const0.u.number = 0; const1.type = T_NUMBER; const1.u.number = 1; /* const0u used by undefinedp() */ const0u.type = T_NUMBER; const0u.subtype = T_UNDEFINED; const0u.u.number = 0; /* const0n used by nullp() */ const0n.type = T_NUMBER; const0n.subtype = T_NULLVALUE; const0n.u.number = 0; fake_prog.program_size = 0; /* * Check that the definition of EXTRACT_UCHAR() is correct. */ p = (char *) &i; *p = -10; if (EXTRACT_UCHAR(p) != 0x100 - 10) { fprintf(stderr, "Bad definition of EXTRACT_UCHAR() in interpret.h.\n"); exit(-1); } /* * An added test: can we do EXTRACT_UCHAR(x++)? * (read_number, etc uses it) */ p = (char *) &i; (void) EXTRACT_UCHAR(p++); if ((p - (char *) &i) != 1) { fprintf(stderr, "EXTRACT_UCHAR() in interpret.h evaluates its argument more than once.\n"); exit(-1); } /* * Check the living hash table size */ if (CFG_LIVING_HASH_SIZE != 4 && CFG_LIVING_HASH_SIZE != 16 && CFG_LIVING_HASH_SIZE != 64 && CFG_LIVING_HASH_SIZE != 256 && CFG_LIVING_HASH_SIZE != 1024 && CFG_LIVING_HASH_SIZE != 4096) { fprintf(stderr, "CFG_LIVING_HASH_SIZE in options.h must be one of 4, 16, 64, 256, 1024, 4096, ...\n"); exit(-1); } #ifdef RAND srand(get_current_time()); #else # ifdef DRAND48 srand48(get_current_time()); # else # ifdef RANDOM srandom(get_current_time()); # else fprintf(stderr, "Warning: no random number generator specified!\n"); # endif # endif #endif current_time = get_current_time(); /* * Initialize the microsecond clock. */ init_usec_clock(); /* read in the configuration file */ got_defaults = 0; for (i = 1; (i < argc) && !got_defaults; i++) { if (argv[i][0] != '-') { set_defaults(argv[i]); got_defaults = 1; } } if (!got_defaults) { fprintf(stderr, "You must specify the configuration filename as an argument.\n"); exit(-1); } printf("Initializing internal tables....\n"); init_strings(); /* in stralloc.c */ init_otable(); /* in otable.c */ init_identifiers(); /* in lex.c */ init_locals(); /* in compiler.c */ /* disable this for now */ #if 0 /* * We estimate that we will need MAX_USERS + MAX_EFUN_SOCKS + 10 file * descriptors if the maximum number of users were to log in and all LPC * sockets were in use. This is a pretty close estimate. */ #ifndef LATTICE dtablesize = MAX_USERS + MAX_EFUN_SOCKS + 10; #else /* * Amiga sockets separate from file descriptors */ dtablesize = MAX_USERS + MAX_EFUN_SOCKS; #endif /* * If our estimate is larger than FD_SETSIZE, then we need more file * descriptors than the operating system can handle. This is a problem * that can be resolved by decreasing MAX_USERS, MAX_EFUN_SOCKS, or both. */ if (dtablesize > FD_SETSIZE) { fprintf(stderr, "Warning: File descriptor requirements exceed system capacity!\n"); fprintf(stderr, " Configuration exceeds system capacity by %d descriptor(s).\n", dtablesize - FD_SETSIZE); } #ifdef HAS_SETDTABLESIZE /* * If the operating system supports setdtablesize() then we can request * the number of file descriptors we really need. First check to see if * wee already have enough. If so dont bother the OS. If not, attempt to * allocate the number we estimated above. There are system imposed * limits on file descriptors, so we may not get as many as we asked for. * Check to make sure we get enough. */ if (getdtablesize() < dtablesize) if (setdtablesize(dtablesize) < dtablesize) { fprintf(stderr, "Warning: Could not allocate enough file descriptors!\n"); fprintf(stderr, " setdtablesize() could not allocate %d descriptor(s).\n", getdtablesize() - dtablesize); } /* * Just be polite and tell the administrator how many he has. */ fprintf(stderr, "%d file descriptors were allocated, (%d were requested).\n", getdtablesize(), dtablesize); #endif #endif time_to_clean_up = TIME_TO_CLEAN_UP; time_to_swap = TIME_TO_SWAP; max_cost = MAX_COST; reserved_size = RESERVED_SIZE; max_array_size = MAX_ARRAY_SIZE; max_buffer_size = MAX_BUFFER_SIZE; max_string_length = MAX_STRING_LENGTH; master_file_name = (char *) MASTER_FILE; /* fix the filename */ while (*master_file_name == '/') master_file_name++; p = master_file_name; while (*p++); if (p[-2]=='c' && p[-3]=='.') p[-3]=0; mud_lib = (char *) MUD_LIB; set_inc_list(INCLUDE_DIRS); if (reserved_size > 0) reserved_area = (char *) DMALLOC(reserved_size, TAG_RESERVED, "main.c: reserved_area"); for (i = 0; i < sizeof consts / sizeof consts[0]; i++) consts[i] = exp(-i / 900.0); init_num_args(); reset_machine(1); /* * The flags are parsed twice ! The first time, we only search for the -m * flag, which specifies another mudlib, and the D-flags, so that they * will be available when compiling master.c. */ for (i = 1; i < argc; i++) { if (argv[i][0] != '-') continue; switch (argv[i][1]) { case 'D': if (argv[i][2]) { /* Amylaar : allow flags to be passed down to * the LPC preprocessor */ struct lpc_predef_s *tmp; tmp = &predefs; tmp->flag = argv[i] + 2; tmp->next = lpc_predefs; lpc_predefs = tmp; continue; } fprintf(stderr, "Illegal flag syntax: %s\n", argv[i]); exit(-1); case 'N': no_ip_demon++; continue; #ifdef YYDEBUG case 'y': yydebug = 1; continue; #endif /* YYDEBUG */ case 'm': mud_lib = alloc_cstring(argv[i] + 2, "mudlib dir"); if (chdir(mud_lib) == -1) { fprintf(stderr, "Bad mudlib directory: %s\n", mud_lib); exit(-1); } new_mudlib = 1; break; } } if (!new_mudlib && chdir(mud_lib) == -1) { fprintf(stderr, "Bad mudlib directory: %s\n", mud_lib); exit(-1); } get_version(version_buf); time(&tm); debug_message("----------------------------------------------------------------------------\n%s (%s) starting up on %s - %s\n\n", MUD_NAME, version_buf, ARCH, ctime(&tm)); #ifdef BINARIES init_binaries(argc, argv); #endif #ifdef LPC_TO_C init_lpc_to_c(); #endif add_predefines(); #ifndef NO_IP_DEMON if (!no_ip_demon && ADDR_SERVER_IP) init_addr_server(ADDR_SERVER_IP, ADDR_SERVER_PORT); #endif /* NO_IP_DEMON */ eval_cost = max_cost; /* needed for create() functions */ save_context(&econ); if (SETJMP(econ.context)) { debug_message("The simul_efun (%s) and master (%s) objects must be loadable.\n", SIMUL_EFUN, MASTER_FILE); exit(-1); } else { init_simul_efun(SIMUL_EFUN); init_master(MASTER_FILE); } pop_context(&econ); for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { continue; } else { /* * Look at flags. -m and -o has already been tested. */ switch (argv[i][1]) { case 'D': case 'N': case 'm': case 'y': continue; case 'f': save_context(&econ); if (SETJMP(econ.context)) { debug_message("Error while calling master::flag(\"%s\"), aborting ...", argv[i] + 2); exit(-1); } push_constant_string(argv[i] + 2); (void) apply_master_ob(APPLY_FLAG, 1); if (MudOS_is_being_shut_down) { debug_message("Shutdown by master object.\n"); exit(0); } pop_context(&econ); continue; case 'e': e_flag++; continue; case 'p': external_port[0].port = atoi(argv[i] + 2); continue; case 'd': #ifdef DEBUG d_flag++; #else debug_message("Driver must be compiled with DEBUG on to use -d.\n"); #endif case 'c': comp_flag++; continue; case 't': t_flag++; continue; default: debug_message("Unknown flag: %s\n", argv[i]); exit(-1); } } } if (MudOS_is_being_shut_down) exit(1); if (strlen(DEFAULT_FAIL_MESSAGE)) default_fail_message = DEFAULT_FAIL_MESSAGE; else default_fail_message = "What?"; #ifdef PACKAGE_MUDLIB_STATS restore_stat_files(); #endif #ifdef PACKAGE_SOCKETS init_sockets(); /* initialize efun sockets */ #endif preload_objects(e_flag); #ifdef SIGFPE signal(SIGFPE, sig_fpe); #endif #ifdef TRAP_CRASHES #ifdef SIGUSR1 signal(SIGUSR1, sig_usr1); #endif signal(SIGTERM, sig_term); signal(SIGINT, sig_int); #ifndef DEBUG #if defined(SIGABRT) && !defined(LATTICE) signal(SIGABRT, sig_abrt); #endif #ifdef SIGIOT signal(SIGIOT, sig_iot); #endif #ifdef SIGHUP signal(SIGHUP, sig_hup); #endif #ifdef SIGBUS signal(SIGBUS, sig_bus); #endif #ifndef LATTICE signal(SIGSEGV, sig_segv); signal(SIGILL, sig_ill); #endif #endif /* DEBUG */ #endif backend(); return 0; }
TOKEN next_token_file(FILE* file, STATE_MACHINE* sm, STATE_MACHINE* wsssm) { TOKEN return_skip = skip_nontokens_file(file, wsssm); if (return_skip.type == T_INVALID) { return return_skip; } char* buffer = (char*) malloc(sizeof(char)); size_t allocated = 1; size_t i = 0; int c = tolower(fgetc(file)); if (c == EOF) { TOKEN t = {T_EOF, NULL}; return t; } long int last_position = ftell(file); // Do transitions until execute_transition returns an error (no valid transition) // This assumes that your file ends on a newline. while (1) { if (execute_transition(sm, c)) { // If execute_transition fails, we went through more characters than needed // Go back in the file, and return the code of the current state. --i; fseek(file, last_position, SEEK_SET); break; } if (c == '\n') { f_line++; f_column = 0; } else { f_column++; } if (i + 1 >= allocated) { allocated = allocated << 1; buffer = (char*) realloc(buffer, allocated * sizeof(char)); } buffer[i] = sm->current_state->state; last_position = ftell(file); c = tolower(fgetc(file)); ++i; } // Null-terminate string. buffer[++i] = 0; // Set sm back to its initial state so it can tokenize another string. int ret = sm->current_state->return_token; if (ret == T_INVALID) { fprintf(stderr, "Syntax error on file position %ld.\n", last_position); } reset_machine(sm); TOKEN t = {ret, buffer}; return t; }
int main (int argc, char ** argv) { time_t tm; int i, new_mudlib = 0, got_defaults = 0; char *p; char version_buf[80]; #if 0 int dtablesize; #endif error_context_t econ; #ifdef PROTO_TZSET void tzset(); #endif #ifdef INCL_LOCALE_H setlocale(LC_ALL, "C"); #endif #if !defined(__SASC) && (defined(AMITCP) || defined(AS225)) amiga_sockinit(); atexit(amiga_sockexit); #endif #ifdef WRAPPEDMALLOC wrappedmalloc_init(); #endif /* WRAPPEDMALLOC */ #ifdef DEBUGMALLOC MDinit(); #endif #if (defined(PROFILING) && !defined(PROFILE_ON) && defined(HAS_MONCONTROL)) moncontrol(0); #endif #ifdef USE_TZSET tzset(); #endif boot_time = get_current_time(); const0.type = T_NUMBER; const0.u.number = 0; const1.type = T_NUMBER; const1.u.number = 1; /* const0u used by undefinedp() */ const0u.type = T_NUMBER; const0u.subtype = T_UNDEFINED; const0u.u.number = 0; //fake_prog.program_size = 0; //0 anyway /* * Check that the definition of EXTRACT_UCHAR() is correct. */ p = (char *) &i; *p = -10; if (EXTRACT_UCHAR(p) != 0x100 - 10) { fprintf(stderr, "Bad definition of EXTRACT_UCHAR() in interpret.h.\n"); exit(-1); } /* * An added test: can we do EXTRACT_UCHAR(x++)? * (read_number, etc uses it) */ p = (char *) &i; (void) EXTRACT_UCHAR(p++); if ((p - (char *) &i) != 1) { fprintf(stderr, "EXTRACT_UCHAR() in interpret.h evaluates its argument more than once.\n"); exit(-1); } /* * Check the living hash table size */ if (CFG_LIVING_HASH_SIZE != 4 && CFG_LIVING_HASH_SIZE != 16 && CFG_LIVING_HASH_SIZE != 64 && CFG_LIVING_HASH_SIZE != 256 && CFG_LIVING_HASH_SIZE != 1024 && CFG_LIVING_HASH_SIZE != 4096) { fprintf(stderr, "CFG_LIVING_HASH_SIZE in options.h must be one of 4, 16, 64, 256, 1024, 4096, ...\n"); exit(-1); } #ifdef RAND srand(get_current_time()); #else # ifdef DRAND48 srand48(get_current_time()); # else # ifdef RANDOM srandom(get_current_time()); # else fprintf(stderr, "Warning: no random number generator specified!\n"); # endif # endif #endif current_time = get_current_time(); /* * Initialize the microsecond clock. */ init_usec_clock(); /* read in the configuration file */ got_defaults = 0; for (i = 1; (i < argc) && !got_defaults; i++) { if (argv[i][0] != '-') { set_defaults(argv[i]); got_defaults = 1; } } get_version(version_buf); if (!got_defaults) { fprintf(stderr, "%s for %s.\n", version_buf, ARCH); fprintf(stderr, "You must specify the configuration filename as an argument.\n"); exit(-1); } printf("Initializing internal tables....\n"); init_strings(); /* in stralloc.c */ init_otable(); /* in otable.c */ init_identifiers(); /* in lex.c */ init_locals(); /* in compiler.c */ /* * If our estimate is larger than FD_SETSIZE, then we need more file * descriptors than the operating system can handle. This is a problem * that can be resolved by decreasing MAX_USERS, MAX_EFUN_SOCKS, or both. * * Unfortunately, since neither MAX_USERS or MAX_EFUN_SOCKS exist any more, * we have no clue how many we will need. This code really should be * moved to places where ENFILE/EMFILE is returned. */ #if 0 if (dtablesize > FD_SETSIZE) { fprintf(stderr, "Warning: File descriptor requirements exceed system capacity!\n"); fprintf(stderr, " Configuration exceeds system capacity by %d descriptor(s).\n", dtablesize - FD_SETSIZE); } #ifdef HAS_SETDTABLESIZE /* * If the operating system supports setdtablesize() then we can request * the number of file descriptors we really need. First check to see if * wee already have enough. If so dont bother the OS. If not, attempt to * allocate the number we estimated above. There are system imposed * limits on file descriptors, so we may not get as many as we asked for. * Check to make sure we get enough. */ if (getdtablesize() < dtablesize) if (setdtablesize(dtablesize) < dtablesize) { fprintf(stderr, "Warning: Could not allocate enough file descriptors!\n"); fprintf(stderr, " setdtablesize() could not allocate %d descriptor(s).\n", getdtablesize() - dtablesize); } /* * Just be polite and tell the administrator how many he has. */ fprintf(stderr, "%d file descriptors were allocated, (%d were requested).\n", getdtablesize(), dtablesize); #endif #endif time_to_clean_up = TIME_TO_CLEAN_UP; max_cost = MAX_COST; reserved_size = RESERVED_SIZE; max_array_size = MAX_ARRAY_SIZE; if(max_array_size > 65535){ fprintf(stderr, "Maximum array size can not exceed 65535"); max_array_size = 65535; } max_buffer_size = MAX_BUFFER_SIZE; max_string_length = MAX_STRING_LENGTH; mud_lib = (char *) MUD_LIB; set_inc_list(INCLUDE_DIRS); if (reserved_size > 0) reserved_area = (char *) DMALLOC(reserved_size, TAG_RESERVED, "main.c: reserved_area"); for (i = 0; i < sizeof consts / sizeof consts[0]; i++) consts[i] = exp(-i / 900.0); reset_machine(1); /* * The flags are parsed twice ! The first time, we only search for the -m * flag, which specifies another mudlib, and the D-flags, so that they * will be available when compiling master.c. */ for (i = 1; i < argc; i++) { if (argv[i][0] != '-') continue; switch (argv[i][1]) { case 'D': if (argv[i][2]) { lpc_predef_t *tmp = ALLOCATE(lpc_predef_t, TAG_PREDEFINES, "predef"); tmp->flag = argv[i] + 2; tmp->next = lpc_predefs; lpc_predefs = tmp; continue; } fprintf(stderr, "Illegal flag syntax: %s\n", argv[i]); exit(-1); case 'N': no_ip_demon++; continue; #ifdef HAS_CONSOLE case 'C': has_console = 1; continue; #endif #ifdef YYDEBUG case 'y': yydebug = 1; continue; #endif /* YYDEBUG */ case 'm': mud_lib = alloc_cstring(argv[i] + 2, "mudlib dir"); if (chdir(mud_lib) == -1) { fprintf(stderr, "Bad mudlib directory: %s\n", mud_lib); exit(-1); } new_mudlib = 1; break; } } if (!new_mudlib && chdir(mud_lib) == -1) { fprintf(stderr, "Bad mudlib directory: %s\n", mud_lib); exit(-1); } time(&tm); debug_message("----------------------------------------------------------------------------\n%s (%s) starting up on %s - %s\n\n", MUD_NAME, version_buf, ARCH, ctime(&tm)); add_predefines(); #ifdef WIN32 _tzset(); #endif #ifndef NO_IP_DEMON if (!no_ip_demon && ADDR_SERVER_IP) init_addr_server(ADDR_SERVER_IP, ADDR_SERVER_PORT); #endif /* NO_IP_DEMON */ set_eval(max_cost); save_context(&econ); if (SETJMP(econ.context)) { debug_message("The simul_efun (%s) and master (%s) objects must be loadable.\n", SIMUL_EFUN, MASTER_FILE); exit(-1); } else { init_simul_efun(SIMUL_EFUN); init_master(); } pop_context(&econ); for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { continue; } else { /* * Look at flags. -m and -o has already been tested. */ switch (argv[i][1]) { case 'D': case 'N': case 'm': case 'y': case 'C': continue; case 'f': save_context(&econ); if (SETJMP(econ.context)) { debug_message("Error while calling master::flag(\"%s\"), aborting ...\n", argv[i] + 2); exit(-1); } push_constant_string(argv[i] + 2); apply_master_ob(APPLY_FLAG, 1); if (MudOS_is_being_shut_down) { debug_message("Shutdown by master object.\n"); exit(0); } pop_context(&econ); continue; case 'e': e_flag++; continue; case 'p': external_port[0].port = atoi(argv[i] + 2); continue; case 'd': #ifdef DEBUG_MACRO if (argv[i][2]) debug_level_set(&argv[i][2]); else debug_level |= DBG_d_flag; #else debug_message("Driver must be compiled with DEBUG_MACRO on to use -d.\n"); #endif break; case 'c': comp_flag++; continue; case 't': t_flag++; continue; default: debug_message("Unknown flag: %s\n", argv[i]); exit(-1); } } } if (MudOS_is_being_shut_down) exit(1); if (*(DEFAULT_FAIL_MESSAGE)) { char buf[8192]; strcpy(buf, DEFAULT_FAIL_MESSAGE); strcat(buf, "\n"); default_fail_message = make_shared_string(buf); } else default_fail_message = "What?\n"; #ifdef PACKAGE_MUDLIB_STATS restore_stat_files(); #endif preload_objects(e_flag); #ifdef SIGFPE signal(SIGFPE, sig_fpe); #endif #ifdef TRAP_CRASHES #ifdef SIGUSR1 signal(SIGUSR1, sig_usr1); #endif #ifdef SIGUSR2 signal(SIGUSR2, sig_usr2); #endif signal(SIGTERM, sig_term); signal(SIGINT, sig_int); #ifndef DEBUG #if defined(SIGABRT) signal(SIGABRT, sig_abrt); #endif #ifdef SIGIOT signal(SIGIOT, sig_iot); #endif #ifdef SIGHUP signal(SIGHUP, sig_hup); #endif #ifdef SIGBUS signal(SIGBUS, sig_bus); #endif signal(SIGSEGV, sig_segv); signal(SIGILL, sig_ill); #endif /* DEBUG */ #endif #ifndef WIN32 #ifdef USE_BSD_SIGNALS signal(SIGCHLD, sig_cld); #else signal(SIGCLD, sig_cld); #endif #endif #ifdef HAS_CONSOLE if(has_console >= 0) signal(SIGTTIN, sig_ttin); signal(SIGTTOU, SIG_IGN); #endif backend(); return 0; }
/* We do a really short, simple test for GL_ARB_texture_env_crossbar since the * preceeding tests are pretty comprehensive and the crossbar feature is just * an incremental addition. Basically, if we have N texture units we run N * tests. For test [i] we set texture unit [i] to fetch the texture color * from unit [num_units - i - 1]. For units != i we use the constant color * (0,0,0,0). We use GL_ADD mode to compute the sum over all units. So * effectively, the result of texture combine is simply the incoming fragment * color plus unit [num_units - test - 1]'s texture color. */ static bool run_crossbar_test() { glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num_tex_units); /* Set up constant texture state for all tests */ setup_colors(); reset_machine(); for (int unit = 0; unit < num_tex_units; unit++) { tex_env(unit, GL_COMBINE_RGB_EXT, GL_ADD); tex_env(unit, GL_COMBINE_ALPHA_EXT, GL_ADD); tex_env(unit, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); tex_env(unit, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT); /* SOURCE1_RGB/ALPHA is set below, per test */ tex_env(unit, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); tex_env(unit, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); tex_env(unit, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA); tex_env(unit, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA); tex_env(unit, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA); tex_env(unit, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA); tex_env(unit, GL_RGB_SCALE_EXT, 1); tex_env(unit, GL_ALPHA_SCALE, 1); machine.env_color[unit][0] = 0.0; machine.env_color[unit][1] = 0.0; machine.env_color[unit][2] = 0.0; machine.env_color[unit][3] = 0.0; glActiveTexture(GL_TEXTURE0 + unit); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, machine.env_color[unit]); } for (int test = 0; test < num_tex_units; test++) { /* 1. Set up texture state */ for (int unit = 0; unit < num_tex_units; unit++) { if (unit == test) { const int revUnit = num_tex_units - unit - 1; tex_env(unit, GL_SOURCE1_RGB_EXT, GL_TEXTURE0 + revUnit); tex_env(unit, GL_SOURCE1_ALPHA_EXT, GL_TEXTURE0 + revUnit); } else { tex_env(unit, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT); tex_env(unit, GL_SOURCE1_ALPHA_EXT, GL_CONSTANT_EXT); } } /* 2. Render with OpenGL */ /* texcoord (0,) for all vertices is OK */ for (int unit = 0; unit < num_tex_units; unit++) glMultiTexCoord2f(GL_TEXTURE0 + unit, 0, 0); piglit_draw_rect(-1, -1, 2, 2); /* 3. Compute expected result */ float prev_color[4]; float expected[4]; COPY4(prev_color, machine.frag_color); for (int unit = 0; unit < num_tex_units; unit++) { compute_tex_combine(unit, prev_color, expected); COPY4(prev_color, expected); } /* 4. Compare rendered result to expected result */ if (!piglit_probe_pixel_rgba(0, 0, expected)) { printf("Texture crossbar test %d\n", test); return false; } } return true; }
/* Test texenv-combine with multiple texture units. */ static bool run_multi_texture_test(void) { static const GLenum combine_modes[10] = { GL_REPLACE, GL_ADD, GL_ADD_SIGNED_EXT, GL_MODULATE, GL_INTERPOLATE_EXT, GL_DOT3_RGB_EXT, GL_DOT3_RGBA_EXT, GL_MODULATE_ADD_ATI, GL_MODULATE_SIGNED_ADD_ATI, GL_MODULATE_SUBTRACT_ATI }; const int num_modes = have_dot3 ? (have_combine3 ? 10 : 7) : 5; /* four texture units is enough to test */ if (num_tex_units > 4) num_tex_units = 4; const int num_tests = count_multi_texture_test_combinations(); setup_colors(); for (int test_num = 0; test_num < num_tests; test_num += test_stride) { /* 0. Set up texture units */ reset_machine(); int divisor = 1; for (int u = 0; u < num_tex_units; u++) { const int m = (test_num / divisor) % num_modes; const GLenum mode = combine_modes[m]; /* Set GL_COMBINE_RGB_EXT and GL_COMBINE_ALPHA_EXT */ tex_env(u, GL_COMBINE_RGB_EXT, mode); tex_env(u, GL_COMBINE_ALPHA_EXT, (mode == GL_DOT3_RGB_EXT || mode == GL_DOT3_RGBA_EXT) ? GL_REPLACE : mode); tex_env(u, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT); tex_env(u, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); tex_env(u, GL_SOURCE2_RGB_EXT, GL_TEXTURE); tex_env(u, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT); tex_env(u, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT); tex_env(u, GL_SOURCE2_ALPHA_EXT, GL_TEXTURE); tex_env(u, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); tex_env(u, GL_OPERAND1_RGB_EXT, GL_ONE_MINUS_SRC_COLOR); tex_env(u, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA); tex_env(u, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA); tex_env(u, GL_OPERAND1_ALPHA_EXT, GL_ONE_MINUS_SRC_ALPHA); tex_env(u, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA); tex_env(u, GL_RGB_SCALE_EXT, 1); tex_env(u, GL_ALPHA_SCALE, 1); divisor *= num_modes; } /* 1. Render with OpenGL */ /* use texcoord (0,0) for all vertices */ for (int u = 0; u < num_tex_units; u++) glMultiTexCoord2f(GL_TEXTURE0 + u, 0, 0); piglit_draw_rect(-1, -1, 2, 2); /* 2. Compute expected result */ float prev_color[4]; float expected[4] = {0}; COPY4(prev_color, machine.frag_color); for (int u = 0; u < num_tex_units; u++) { compute_tex_combine(u, prev_color, expected); COPY4(prev_color, expected); } /* 3. Compare rendered result to expected result */ if (!piglit_probe_pixel_rgba(0, 0, expected)) { printf("Multi-texture test %d\n", test_num); return false; } } return true; }