void mpi_sendrecv_(void* sendbuf, int* sendcount, int* sendtype, int* dst, int* sendtag, void *recvbuf, int* recvcount, int* recvtype, int* src, int* recvtag, int* comm, MPI_Status* status, int* ierr) { *ierr = MPI_Sendrecv(sendbuf, *sendcount, get_datatype(*sendtype), *dst, *sendtag, recvbuf, *recvcount,get_datatype(*recvtype), *src, *recvtag, get_comm(*comm), status); }
void mpi_type_create_hvector_(int* count, int* blocklen, MPI_Aint* stride, int* old_type, int* newtype, int* ierr){ MPI_Datatype tmp; *ierr= MPI_Type_hvector(*count, *blocklen, *stride, get_datatype(*old_type), &tmp); if(*ierr == MPI_SUCCESS) { *newtype = new_datatype(tmp); } }
void mpi_type_free_(int* datatype, int* ierr){ MPI_Datatype tmp= get_datatype(*datatype); *ierr= MPI_Type_free (&tmp); if(*ierr == MPI_SUCCESS) { free_datatype(*datatype); } }
void mpi_irecv_(void *buf, int* count, int* datatype, int* src, int* tag, int* comm, int* request, int* ierr) { MPI_Request req; *ierr = MPI_Irecv(buf, *count, get_datatype(*datatype), *src, *tag, get_comm(*comm), &req); if(*ierr == MPI_SUCCESS) { *request = new_request(req); } }
void mpi_send_init_(void *buf, int* count, int* datatype, int* dst, int* tag, int* comm, int* request, int* ierr) { MPI_Request req; *ierr = MPI_Send_init(buf, *count, get_datatype(*datatype), *dst, *tag, get_comm(*comm), &req); if(*ierr == MPI_SUCCESS) { *request = new_request(req); } }
void mpi_scan_(void* sendbuf, void* recvbuf, int* count, int* datatype, int* op, int* comm, int* ierr) { *ierr = MPI_Scan(sendbuf, recvbuf, *count, get_datatype(*datatype), get_op(*op), get_comm(*comm)); }
/** \return GL_TRUE for pass, GL_FALSE for fail */ static bool test_fbo(const struct format_info *info) { const int comps = num_components(info->BaseFormat); const GLenum type = get_datatype(info); GLint f; GLuint fbo, texObj; GLenum status; GLboolean intMode; GLint buf; bool pass = true; if (0) fprintf(stderr, "============ Testing format = %s ========\n", info->Name); /* Create texture */ glGenTextures(1, &texObj); glBindTexture(GL_TEXTURE_2D, texObj); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, info->IntFormat, TexWidth, TexHeight, 0, info->BaseFormat, type, NULL); if (check_error(__FILE__, __LINE__)) return GL_FALSE; glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &f); assert(f == info->IntFormat); /* Create FBO to render to texture */ glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texObj, 0); if (check_error(__FILE__, __LINE__)) return GL_FALSE; status = glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { fprintf(stderr, "%s: failure: framebuffer incomplete.\n", TestName); return GL_FALSE; } glGetBooleanv(GL_RGBA_INTEGER_MODE_EXT, &intMode); if (check_error(__FILE__, __LINE__)) return GL_FALSE; if (!intMode) { fprintf(stderr, "%s: GL_RGBA_INTEGER_MODE_EXT return GL_FALSE\n", TestName); return GL_FALSE; } glGetIntegerv(GL_READ_BUFFER, &buf); assert(buf == GL_COLOR_ATTACHMENT0_EXT); glGetIntegerv(GL_DRAW_BUFFER, &buf); assert(buf == GL_COLOR_ATTACHMENT0_EXT); /* test clearing */ if (1) { /* clear with an integer - exp unsigned int */ static const GLint clr_i[4] = { 300000005, -7, 6, 5 }; static const GLuint exp_ui[4] = { 300000005, 0, 6, 5 }; /* clear with an unsigned integer - exp int */ static const GLuint clr_ui[4] = { 300000005, 0x80000007, 6, 5 }; static const GLint exp_i[4] = { 300000005, 0x7fffffff, 6, 5 }; GLint pix[4], i; GLuint pix_ui[4]; if (info->Signed) glClearColorIiEXT(clr_i[0], clr_i[1], clr_i[2], clr_i[3]); else glClearColorIuiEXT(clr_ui[0], clr_ui[1], clr_ui[2], clr_ui[3]); glClear(GL_COLOR_BUFFER_BIT); if (info->Signed) glReadPixels(5, 5, 1, 1, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, pix_ui); else glReadPixels(5, 5, 1, 1, GL_RGBA_INTEGER_EXT, GL_INT, pix); if (info->Signed) { for (i = 0; i < comps; i++) { if (pix_ui[i] != exp_ui[i]) { fprintf(stderr, "%s: glClear failed\n", TestName); fprintf(stderr, " Texture format = %s\n", info->Name); fprintf(stderr, " Expected %u, %u, %u, %u\n", exp_ui[0], exp_ui[1], exp_ui[2], exp_ui[3]); fprintf(stderr, " Found %u, %u, %u, %u\n", pix_ui[0], pix_ui[1], pix_ui[2], pix_ui[3]); pass = false; break; } } } else { for (i = 0; i < comps; i++) { if (pix[i] != exp_i[i]) { fprintf(stderr, "%s: glClear failed\n", TestName); fprintf(stderr, " Texture format = %s\n", info->Name); fprintf(stderr, " Expected %d, %d, %d, %d\n", exp_i[0], exp_i[1], exp_i[2], exp_i[3]); fprintf(stderr, " Found %d, %d, %d, %d\n", pix[0], pix[1], pix[2], pix[3]); pass = false; break; } } } } glutSwapBuffers(); glDeleteTextures(1, &texObj); glDeleteFramebuffers(1, &fbo); return pass; }
static enum piglit_result test_format(const struct format_info *info) { const GLenum type = get_datatype(info); GLenum status; uint32_t expected_color[4]; printf("%s:\n", info->name); /* Create texture */ glTexImage2D(GL_TEXTURE_2D, 0, info->internal_format, 1, 1, 0, info->base_format, type, NULL); glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0); status = glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { printf(" framebuffer incomplete.\n"); return PIGLIT_SKIP; } piglit_draw_rect(-1, -1, 2, 2); memcpy(expected_color, color, sizeof(color)); switch (info->base_format) { case GL_RGBA_INTEGER: case GL_BGRA_INTEGER: break; case GL_RGB_INTEGER: expected_color[3] = 1; break; case GL_LUMINANCE_INTEGER_EXT: expected_color[1] = expected_color[0]; expected_color[2] = expected_color[0]; expected_color[3] = 1; break; case GL_LUMINANCE_ALPHA_INTEGER_EXT: expected_color[1] = expected_color[0]; expected_color[2] = expected_color[0]; break; case GL_RED_INTEGER: if (strstr(info->name, "INTENSITY")) { expected_color[1] = expected_color[0]; expected_color[2] = expected_color[0]; expected_color[3] = expected_color[0]; } else { expected_color[1] = 0; expected_color[2] = 0; expected_color[3] = 1; } break; case GL_RG_INTEGER: expected_color[2] = 0; expected_color[3] = 1; break; case GL_ALPHA_INTEGER_EXT: expected_color[0] = 0; expected_color[1] = 0; expected_color[2] = 0; break; default: abort(); } if (piglit_probe_rect_rgba_uint(0, 0, 1, 1, expected_color)) return PIGLIT_PASS; else { printf(" Input color: %d %d %d %d\n", color[0], color[1], color[2], color[3]); return PIGLIT_FAIL; } }
void mpi_type_size_(int* datatype, int *size, int* ierr) { *ierr = MPI_Type_size(get_datatype(*datatype), size); }
void mpi_type_ub_(int* datatype, MPI_Aint * disp, int* ierr){ *ierr= MPI_Type_ub(get_datatype(*datatype), disp); }
void mpi_get_count_(MPI_Status * status, int* datatype, int *count, int* ierr){ *ierr = MPI_Get_count(status, get_datatype(*datatype), count); }
void mpi_recv_(void* buf, int* count, int* datatype, int* src, int* tag, int* comm, MPI_Status* status, int* ierr) { *ierr = MPI_Recv(buf, *count, get_datatype(*datatype), *src, *tag, get_comm(*comm), status); }
void mpi_rsend_(void* buf, int* count, int* datatype, int* dst, int* tag, int* comm, int* ierr) { *ierr = MPI_Rsend(buf, *count, get_datatype(*datatype), *dst, *tag, get_comm(*comm)); }
static enum piglit_result test_fbo(const struct format_info *info) { const int comps = num_components(info->BaseFormat); const GLenum type = get_datatype(info); GLint f; GLuint fbo, texObj; GLenum status; GLboolean intMode; GLint buf; static const GLint clr[4] = { 300000005, 7, 6, 5 }; GLint pix[4], i; bool pass = true; if (0) fprintf(stderr, "============ Testing format = %s ========\n", info->Name); /* Create texture */ glGenTextures(1, &texObj); glBindTexture(GL_TEXTURE_2D, texObj); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, info->IntFormat, TexWidth, TexHeight, 0, info->BaseFormat, type, NULL); if (check_error(__FILE__, __LINE__)) return PIGLIT_FAIL; glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &f); assert(f == info->IntFormat); /* Create FBO to render to texture */ glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texObj, 0); if (check_error(__FILE__, __LINE__)) return PIGLIT_FAIL; status = glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { printf("%s: framebuffer incomplete.\n", info->Name); return PIGLIT_SKIP; } glGetBooleanv(GL_RGBA_INTEGER_MODE_EXT, &intMode); if (check_error(__FILE__, __LINE__)) return PIGLIT_FAIL; if (!intMode) { fprintf(stderr, "%s: GL_RGBA_INTEGER_MODE_EXT return GL_FALSE\n", TestName); return PIGLIT_FAIL; } glGetIntegerv(GL_READ_BUFFER, &buf); assert(buf == GL_COLOR_ATTACHMENT0_EXT); glGetIntegerv(GL_DRAW_BUFFER, &buf); assert(buf == GL_COLOR_ATTACHMENT0_EXT); glClearColorIiEXT(clr[0], clr[1], clr[2], clr[3]); glClear(GL_COLOR_BUFFER_BIT); glReadPixels(5, 5, 1, 1, GL_RGBA_INTEGER_EXT, GL_INT, pix); for (i = 0; i < comps; i++) { if (pix[i] != clr[i]) { fprintf(stderr, "%s: glClear failed\n", TestName); fprintf(stderr, " Texture format = %s\n", info->Name); fprintf(stderr, " Expected %d, %d, %d, %d\n", clr[0], clr[1], clr[2], clr[3]); fprintf(stderr, " Found %d, %d, %d, %d\n", pix[0], pix[1], pix[2], pix[3]); pass = false; break; } } piglit_present_results(); glDeleteTextures(1, &texObj); glDeleteFramebuffers(1, &fbo); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
/** \return GL_TRUE for pass, GL_FALSE for fail */ static GLboolean test_fbo(const struct format_info *info) { const int max = get_max_val(info); const int comps = num_components(info->BaseFormat); const GLenum type = get_datatype(info); GLint f; GLuint fbo, texObj; GLenum status; GLboolean intMode; GLint buf; if (0) fprintf(stderr, "============ Testing format = %s ========\n", info->Name); /* Create texture */ glGenTextures(1, &texObj); glBindTexture(GL_TEXTURE_2D, texObj); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, info->IntFormat, TexWidth, TexHeight, 0, info->BaseFormat, type, NULL); if (check_error(__FILE__, __LINE__)) return GL_FALSE; glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &f); assert(f == info->IntFormat); /* Create FBO to render to texture */ glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texObj, 0); if (check_error(__FILE__, __LINE__)) return GL_FALSE; status = glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { fprintf(stderr, "%s: failure: framebuffer incomplete.\n", TestName); return GL_FALSE; } glGetBooleanv(GL_RGBA_INTEGER_MODE_EXT, &intMode); if (check_error(__FILE__, __LINE__)) return GL_FALSE; if (!intMode) { fprintf(stderr, "%s: GL_RGBA_INTEGER_MODE_EXT return GL_FALSE\n", TestName); return GL_FALSE; } glGetIntegerv(GL_READ_BUFFER, &buf); assert(buf == GL_COLOR_ATTACHMENT0_EXT); glGetIntegerv(GL_DRAW_BUFFER, &buf); assert(buf == GL_COLOR_ATTACHMENT0_EXT); /* test clearing */ if (1) { static const GLint clr[4] = { 8, 7, 6, 5 }; GLint pix[4], i; glClearColorIiEXT(clr[0], clr[1], clr[2], clr[3]); glClear(GL_COLOR_BUFFER_BIT); glReadPixels(5, 5, 1, 1, GL_RGBA_INTEGER_EXT, GL_INT, pix); for (i = 0; i < comps; i++) { if (pix[i] != clr[i]) { fprintf(stderr, "%s: glClear failed\n", TestName); fprintf(stderr, " Texture format = %s\n", info->Name); fprintf(stderr, " Expected %d, %d, %d, %d\n", clr[0], clr[1], clr[2], clr[3]); fprintf(stderr, " Found %d, %d, %d, %d\n", pix[0], pix[1], pix[2], pix[3]); return GL_FALSE; } } } /* Do glDraw/ReadPixels test */ if (1) { #define W 15 #define H 10 GLint image[H * W * 4], readback[H * W * 4]; GLint i; if (info->Signed) { for (i = 0; i < W * H * 4; i++) { image[i] = (i - 10) % max; assert(image[i] < max); } } else { for (i = 0; i < W * H * 4; i++) { image[i] = (i + 3) % max; assert(image[i] < max); } } glUseProgram(PassthroughProgram); if(0)glUseProgram(SimpleProgram); glWindowPos2i(1, 1); glDrawPixels(W, H, GL_RGBA_INTEGER_EXT, GL_INT, image); if (check_error(__FILE__, __LINE__)) return GL_FALSE; glReadPixels(1, 1, W, H, GL_RGBA_INTEGER_EXT, GL_INT, readback); if (check_error(__FILE__, __LINE__)) return GL_FALSE; for (i = 0; i < W * H * 4; i++) { if (readback[i] != image[i]) { if (comps == 3 && i % 4 == 3 && readback[i] == 1) continue; /* alpha = 1 if base format == RGB */ fprintf(stderr, "%s: glDraw/ReadPixels failed at %d. Expected %d, found %d\n", TestName, i, image[i], readback[i]); fprintf(stderr, "Texture format = %s\n", info->Name); assert(0); return GL_FALSE; } } #undef W #undef H } /* Do rendering test */ if (1) { GLint value[4], result[4], loc, w = piglit_width, h = piglit_height; GLint error = 1; /* XXX fix */ /* choose random value/color for polygon */ value[0] = rand() % 100; value[1] = rand() % 100; value[2] = rand() % 100; value[3] = rand() % 100; glUseProgram(SimpleProgram); check_error(__FILE__, __LINE__); loc = glGetUniformLocation(SimpleProgram, "value"); assert(loc >= 0); glUniform4iv(loc, 1, value); check_error(__FILE__, __LINE__); #if 0 /* allow testing on mesa until this is implemented */ loc = glGetFragDataLocationEXT(SimpleProgram, "out_color"); assert(loc >= 0); #endif glBegin(GL_POLYGON); glVertex2f(0, 0); glVertex2f(w, 0); glVertex2f(w, h); glVertex2f(0, h); glEnd(); check_error(__FILE__, __LINE__); glReadPixels(w/2, h/2, 1, 1, GL_RGBA_INTEGER, GL_INT, result); check_error(__FILE__, __LINE__); if (info->BaseFormat == GL_RGB_INTEGER_EXT) { value[3] = 1; } if (abs(result[0] - value[0]) > error || abs(result[1] - value[1]) > error || abs(result[2] - value[2]) > error || abs(result[3] - value[3]) > error) { fprintf(stderr, "%s: failure with format %s:\n", TestName, info->Name); fprintf(stderr, " input value = %d, %d, %d, %d\n", value[0], value[1], value[2], value[3]); fprintf(stderr, " result color = %d, %d, %d, %d\n", result[0], result[1], result[2], result[3]); return GL_FALSE; } } piglit_present_results(); glDeleteTextures(1, &texObj); glDeleteFramebuffers(1, &fbo); return GL_TRUE; }
void mpi_alltoall_(void* sendbuf, int* sendcount, int* sendtype, void* recvbuf, int* recvcount, int* recvtype, int* comm, int* ierr) { *ierr = MPI_Alltoall(sendbuf, *sendcount, get_datatype(*sendtype), recvbuf, *recvcount, get_datatype(*recvtype), get_comm(*comm)); }
void mpi_alltoallv_(void* sendbuf, int* sendcounts, int* senddisps, int* sendtype, void* recvbuf, int* recvcounts, int* recvdisps, int* recvtype, int* comm, int* ierr) { *ierr = MPI_Alltoallv(sendbuf, sendcounts, senddisps, get_datatype(*sendtype), recvbuf, recvcounts, recvdisps, get_datatype(*recvtype), get_comm(*comm)); }
void mpi_bcast_(void *buf, int* count, int* datatype, int* root, int* comm, int* ierr) { *ierr = MPI_Bcast(buf, *count, get_datatype(*datatype), *root, get_comm(*comm)); }
void mpi_type_commit_(int* datatype, int* ierr){ MPI_Datatype tmp= get_datatype(*datatype); *ierr= MPI_Type_commit(&tmp); }
void mpi_allreduce_(void* sendbuf, void* recvbuf, int* count, int* datatype, int* op, int* comm, int* ierr) { *ierr = MPI_Allreduce(sendbuf, recvbuf, *count, get_datatype(*datatype), get_op(*op), get_comm(*comm)); }
void mpi_reduce_scatter_(void* sendbuf, void* recvbuf, int* recvcounts, int* datatype, int* op, int* comm, int* ierr) { *ierr = MPI_Reduce_scatter(sendbuf, recvbuf, recvcounts, get_datatype(*datatype), get_op(*op), get_comm(*comm)); }
void mpi_scatterv_(void* sendbuf, int* sendcounts, int* displs, int* sendtype, void* recvbuf, int* recvcount, int* recvtype, int* root, int* comm, int* ierr) { *ierr = MPI_Scatterv(sendbuf, sendcounts, displs, get_datatype(*sendtype), recvbuf, *recvcount, get_datatype(*recvtype), *root, get_comm(*comm)); }
void mpi_type_lb_(int* datatype, MPI_Aint * extent, int* ierr){ *ierr= MPI_Type_extent(get_datatype(*datatype), extent); }
void mpi_gather_(void* sendbuf, int* sendcount, int* sendtype, void* recvbuf, int* recvcount, int* recvtype, int* root, int* comm, int* ierr) { *ierr = MPI_Gather(sendbuf, *sendcount, get_datatype(*sendtype), recvbuf, *recvcount, get_datatype(*recvtype), *root, get_comm(*comm)); }
void mpi_get_( int *origin_addr, int* origin_count, int* origin_datatype, int *target_rank, MPI_Aint* target_disp, int *target_count, int* target_datatype, int* win, int* ierr){ *ierr = MPI_Get( (void*)origin_addr,*origin_count, get_datatype(*origin_datatype),*target_rank, *target_disp, *target_count,get_datatype(*target_datatype), *(MPI_Win *)win); }
void mpi_allgatherv_(void* sendbuf, int* sendcount, int* sendtype, void* recvbuf, int* recvcounts,int* displs, int* recvtype, int* comm, int* ierr) { *ierr = MPI_Allgatherv(sendbuf, *sendcount, get_datatype(*sendtype), recvbuf, recvcounts, displs, get_datatype(*recvtype), get_comm(*comm)); }
int main(int argc, char *argv[]){ char buffer[64]; char *c; #if DEBUG printf("[DEBUG MODE]\n"); printf("Compile: %s %s\n", __DATE__, __TIME__); #endif printf("Version: %d.%d.%d\n", VER_REL, VER_MAJOR, VER_MINOR); printf("Database> "); dbfile_t *mdb = open_dbfile(get_input(buffer, 32, TRUE)); commit_db(mdb); for(;;){ printf("valca> "); c = get_input(buffer, 64, TRUE); if(!strcmp("quit", c)||!strcmp("exit", c)||!strcmp("\\q", c)){ break; } if(!strcmp("help", c)){ printf("COMMANDS:\n"); printf("COMMIT Commit file to disk\n"); printf("COUNT Show row count\n"); printf("TRUNCATE Delete all keys\n"); printf("UPDATE Update key value\n"); printf("INSERT Insert key\n"); printf("DELETE \\\n"); printf(" COLUMN Delete column\n"); printf(" ROW Delete row\n"); printf("ALTER \\\n"); printf(" NAME Change column name\n"); printf(" LEFT Shift column left\n"); printf(" RIGHT Shift column right\n"); printf("SELECT Select value from\n"); printf("ADD \\\n"); printf(" COLUMN Add column\n"); printf("SHOW \\\n"); printf(" COLUMNS Show all columns\n"); printf(" TREE Show storage tree\n"); printf(" STATUS Show database info\n"); printf(" TABLE Show dataset as table\n"); printf("FREE \\\n"); printf(" COLUMNS Columns freelist\n"); printf(" NODE Node freelist\n"); printf(" DATAFIELDS Payload freelist\n"); printf("EXIT Quit the shell\n"); } if(!strcmp("commit", c)){ commit_db(mdb); } if(!strcmp("count", c)){ printf("Total rows: %d\n", mdb->k_cnt); } if(!strcmp("truncate", c)){ truncate_root(mdb); } if(!strcmp("update", c)){ char tmp[32]; printf(">psid: "); c = get_input(tmp, 32, FALSE); int key = atoi(tmp); char tmpcolname[32]; printf(">column: "); c = get_input(tmpcolname, 32, FALSE); int idx = get_column_idx(mdb, tmpcolname); printf(">value: "); c = get_input(tmp, 32, FALSE); change(mdb, key, (void*)tmp, idx); } if(!strcmp("insert", c)){ if(!mdb->c_cnt){ printf("Cannot insert without column\n"); }else{ char tmp[32]; printf(">psid[%d]: ", mdb->seq_cnt); c = get_input(tmp, 32, FALSE); int key; if(!strlen(tmp)){ key = mdb->seq_cnt++; }else{ key = atoi(tmp); } column_t col; read_column(mdb, mdb->data.c_root, &col); printf(">%s<%s(%d)>: ", col.name, get_datatype_name(col.d_type), col.maxsize); c = get_input(tmp, 32, FALSE); if(get_datatype(col.d_type).size == -1) tmp[col.maxsize] = '\0'; if(col.usign) printf("<> %d\n", atoi(tmp)); //if(atoi()) if(insert_key(mdb, key, (void*)tmp) == SUCCESS){ result_t rs = search_key(mdb, key); if(rs.rstat == SUCCESS){ char tmp[32]; int i = 1; while(col.c_next != EMPTY){ read_column(mdb, col.c_next, &col); printf(">%s<%s(%d)>: ", col.name, get_datatype_name(col.d_type), col.maxsize); c = get_input(tmp, 32, FALSE); add_field(mdb, rs.fpos, rs.idx, (void*)tmp, i); i++; } } } } } if(!strcmp("delete", c)){ printf(">"); c = get_input(buffer, 64, TRUE); if(!strcmp("column", c)){ char tmpcolname[32]; printf(">column: "); c = get_input(tmpcolname, 32, FALSE); int idx = get_column_idx(mdb, tmpcolname); delete_column(mdb, idx); } if(!strcmp("row", c)){ char tmp[32]; printf(">psid: "); c = get_input(tmp, 32, FALSE); int key = atoi(tmp); result_t rs = search_key(mdb, key); if(rs.rstat == SUCCESS){ int i; for(i=mdb->c_cnt; i>1; i--){ delete_field(mdb, rs.fpos, rs.idx, (i-1)); } delete_key(mdb, key); } } } if(!strcmp("alter", c)){ printf(">"); c = get_input(buffer, 64, TRUE); if(!strcmp("name", c)){ printf(">column: "); char tmpcolname[32]; c = get_input(tmpcolname, 32, FALSE); int idx = get_column_idx(mdb, tmpcolname); printf(">new name: "); c = get_input(tmpcolname, 32, FALSE); rename_column(mdb, tmpcolname, idx); } if(!strcmp("left", c)){ char tmpcolname[32]; printf(">column: "); c = get_input(tmpcolname, 32, FALSE); int idx = get_column_idx(mdb, tmpcolname); shift_column_left(mdb, idx); } if(!strcmp("right", c)){ char tmpcolname[32]; printf(">column: "); c = get_input(tmpcolname, 32, FALSE); int idx = get_column_idx(mdb, tmpcolname); shift_column_right(mdb, idx); } } if(!strcmp("select", c)){ printf(">"); char tmp[16]; printf(">psid: "); c = get_input(tmp, 32, FALSE); int key = atoi(tmp); result_t rs = search_key(mdb, key); if(rs.rstat == SUCCESS){ found(mdb, rs.fpos, rs.idx); } } if(!strcmp("add", c)){ printf(">"); c = get_input(buffer, 64, TRUE); if(!strcmp("column", c)){ char colname[32]; DTYPE type; int size; bool usign = FALSE; int idx; printf(">name: "); c = get_input(colname, 32, FALSE); printf(">type: "); char tmptype[32]; c = get_input(tmptype, 32, FALSE); type = get_datatype_idx(tmptype); if(type == EMPTY){ printf("Unkown datatype\n"); continue; } size = get_datatype(type).size; if(size == EMPTY){ printf(">size: "); char tmpsize[16]; c = get_input(tmpsize, 16, FALSE); size = atoi(tmpsize); } if(get_datatype(type).signness){ printf(">unsigned: "); char tmpsign[4]; c = get_input(tmpsign, 4, FALSE); if(!strcmp("y", tmpsign)){ usign = TRUE; } } printf(">before: "); char tmpcolname[32]; c = get_input(tmpcolname, 32, FALSE); idx = get_column_idx(mdb, tmpcolname); add_column(mdb, colname, size, type, usign, idx); } } if(!strcmp("show", c)){ printf(">"); c = get_input(buffer, 64, TRUE); if(!strcmp("columns", c)){ printf("Idx Offset Psid Columnname Size Type Unsigned Next\n"); printf("--------------------------------------------------------------------------\n"); print_column(mdb, mdb->data.c_root, 0); } if(!strcmp("tree", c)){ print_tree(mdb, mdb->data.n_root, 0); } if(!strcmp("status", c)){ print_status(mdb); } if(!strcmp("table", c)){ print_table(mdb); } } if(!strcmp("free", c)){ printf(">"); c = get_input(buffer, 64, TRUE); if(!strcmp("columns", c)){ printf("Idx Offset Psid Columnname Size Type Unsigned Next\n"); printf("--------------------------------------------------------------------------\n"); print_column(mdb, mdb->data.c_free, 0); } if(!strcmp("node", c)){ print_tree(mdb, mdb->data.n_free, 0); } if(!strcmp("datafields", c)){ print_datafield(mdb, mdb->data.d_free); } } } commit_db(mdb); close_dbfile(mdb->vfp); close_db(mdb); return 0; }
/** \return GL_TRUE for pass, GL_FALSE for fail */ static bool test_format(const struct format_info *info) { const int max = get_max_val(info); const int comps = num_components(info->BaseFormat); const int texels = TexWidth * TexHeight; const GLenum type = get_datatype(info); const int w = piglit_width / 10; const int h = piglit_height / 10; const float error = 2.0 / 255.0; /* XXX fix */ GLfloat expected[4]; void *buf; int value[4]; GLfloat result[4], bias[4]; GLint f; /* pick random texture color */ value[0] = rand() % max; value[1] = rand() % max; value[2] = rand() % max; value[3] = rand() % max; /* alloc, fill texture image */ buf = malloc(comps * texels * info->BitsPerChannel / 8); fill_array(comps, texels, buf, info->BitsPerChannel, value); glTexImage2D(GL_TEXTURE_2D, 0, info->IntFormat, TexWidth, TexHeight, 0, info->BaseFormat, type, buf); /* make sure the teximage call worked */ if (!piglit_check_gl_error(GL_NO_ERROR)) return false; glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &f); /* setup expected polygon color */ expected[0] = 0.25; expected[1] = 0.50; expected[2] = 0.75; expected[3] = 1.00; /* need to swizzle things depending on texture format */ switch (info->BaseFormat) { case GL_RGBA_INTEGER_EXT: /* nothing */ break; case GL_RGB_INTEGER_EXT: value[3] = 0.0; break; case GL_ALPHA_INTEGER_EXT: expected[0] = expected[1] = expected[2] = 0.0; expected[3] = 0.25; value[3] = value[0]; value[0] = value[1] = value[2] = 0.0; break; case GL_LUMINANCE_INTEGER_EXT: expected[0] = expected[1] = expected[2] = 0.25; expected[3] = 1.0; value[1] = value[2] = value[0]; value[3] = 1.0; break; case GL_LUMINANCE_ALPHA_INTEGER_EXT: expected[0] = expected[1] = expected[2] = 0.25; value[3] = value[1]; value[1] = value[2] = value[0]; break; case GL_RED_INTEGER_EXT: expected[0] = expected[1] = expected[2] = expected[3] = 0.25; value[1] = value[2] = value[3] = value[0]; break; default: ; } /* compute, set test bias */ bias[0] = expected[0] - value[0]; bias[1] = expected[1] - value[1]; bias[2] = expected[2] - value[2]; bias[3] = expected[3] - value[3]; glUniform4fv(BiasUniform, 1, bias); /* draw */ glClearColor(0, 1, 1, 0); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glTexCoord2f(0, 0); glVertex2f(0, 0); glTexCoord2f(1, 0); glVertex2f(w, 0); glTexCoord2f(1, 1); glVertex2f(w, h); glTexCoord2f(0, 1); glVertex2f(0, h); glEnd(); /* test */ glReadPixels(w/2, h/2, 1, 1, GL_RGBA, GL_FLOAT, result); if (fabsf(result[0] - expected[0]) > error || fabsf(result[1] - expected[1]) > error || fabsf(result[2] - expected[2]) > error || fabsf(result[3] - expected[3]) > error) { fprintf(stderr, "%s: failure with format %s:\n", TestName, piglit_get_gl_enum_name(info->IntFormat)); fprintf(stderr, " texture color = %d, %d, %d, %d\n", value[0], value[1], value[2], value[3]); fprintf(stderr, " expected color = %g, %g, %g, %g\n", expected[0], expected[1], expected[2], expected[3]); fprintf(stderr, " result color = %g, %g, %g, %g\n", result[0], result[1], result[2], result[3]); return false; } piglit_present_results(); free(buf); return GL_TRUE; }