/** * Copy from a source image into a destination image of the specified * format and check the result. * * If \a strict_layout_qualifiers is false, uniform layout qualifiers * will be omitted where allowed by the spec. If \a * strict_access_qualifiers is false, the "readonly" and "writeonly" * qualifiers will be omitted. If \a strict_binding is false, the * image will be bound as READ_WRITE, otherwise only the required * access type will be used. */ static bool run_test(const struct image_format_info *format, bool strict_layout_qualifiers, bool strict_access_qualifiers, bool strict_binding) { const struct grid_info grid = grid_info(GL_FRAGMENT_SHADER, image_base_internal_format(format), W, H); const struct image_info img = image_info(GL_TEXTURE_2D, format->format, W, H); GLuint prog = generate_program( grid, GL_FRAGMENT_SHADER, concat(image_hunk(img, ""), test_hunk(strict_layout_qualifiers, strict_access_qualifiers), hunk("SRC_IMAGE_Q uniform IMAGE_BARE_T src_img;\n" "DST_IMAGE_Q uniform IMAGE_BARE_T dst_img;\n" "\n" "GRID_T op(ivec2 idx, GRID_T x) {\n" " imageStore(dst_img, IMAGE_ADDR(idx)," " imageLoad(src_img, IMAGE_ADDR(idx)));\n" " return x;\n" "}\n"), NULL)); bool ret = prog && init_fb(grid) && init_image(img, 0, strict_binding) && init_image(img, 1, strict_binding) && set_uniform_int(prog, "src_img", 0) && set_uniform_int(prog, "dst_img", 1) && draw_grid(grid, prog) && check(grid, img); glDeleteProgram(prog); return ret; }
int do_iminfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int arg; ulong addr; int rcode=0; if (argc < 2) { return image_info (load_addr); } for (arg=1; arg <argc; ++arg) { addr = simple_strtoul(argv[arg], NULL, 16); if (image_info (addr) != 0) rcode = 1; } return rcode; }
void menu_image_info::populate() { item_append(machine().system().description, "", FLAG_DISABLE, nullptr); item_append("", "", FLAG_DISABLE, nullptr); for (device_image_interface &image : image_interface_iterator(machine().root_device())) image_info(&image); }
/** * If \a layered is false, bind an individual layer of a texture to an * image unit, read its contents and write back a different value to * the same location. If \a layered is true or the texture has a * single layer, the whole texture will be read and written back. * * For textures with a single layer, the arguments \a layered and \a * layer which are passed to the same arguments of * glBindImageTexture() should have no effect as required by the spec. */ static bool run_test(const struct image_target_info *target, bool layered, unsigned layer) { const struct image_info real_img = image_info( target->target, GL_RGBA32F, W, H); const unsigned slices = (layered ? 1 : image_num_layers(real_img)); /* * "Slice" of the image that will be bound to the pipeline. */ const struct image_info slice_img = image_info( (layered ? target->target : image_layer_target(target)), GL_RGBA32F, W, H / slices); /* * Grid with as many elements as the slice. */ const struct grid_info grid = grid_info( GL_FRAGMENT_SHADER, GL_RGBA32F, W, H / slices); GLuint prog = generate_program( grid, GL_FRAGMENT_SHADER, concat(image_hunk(slice_img, ""), hunk("IMAGE_UNIFORM_T img;\n" "\n" "GRID_T op(ivec2 idx, GRID_T x) {\n" " GRID_T v = imageLoad(img, IMAGE_ADDR(idx));\n" " imageStore(img, IMAGE_ADDR(idx), DATA_T(33));\n" " return v;\n" "}\n"), NULL)); bool ret = prog && init_fb(grid) && init_image(real_img, layered, layer) && set_uniform_int(prog, "img", 0) && draw_grid(grid, prog) && check(grid, real_img, (slices == 1 ? 0 : layer)); glDeleteProgram(prog); return ret; }
static bool run_test(const struct image_qualifier_info *qual) { const struct grid_info grid = grid_info(GL_FRAGMENT_SHADER, GL_R32UI, W, H); const struct image_info img = image_info(GL_TEXTURE_1D, GL_R32UI, W, H); GLuint prog = generate_program( grid, /** * Write to consecutive locations of an image using a * the value read from a fixed location of a different * image uniform which aliases the first image. If * the implementation incorrectly coalesces repeated * loads from the fixed location the results of the * test will be altered. */ GL_FRAGMENT_SHADER, concat(qualifier_hunk(qual), image_hunk(img, ""), hunk("IMAGE_Q IMAGE_UNIFORM_T src_img;\n" "IMAGE_Q IMAGE_UNIFORM_T dst_img;\n" "\n" "GRID_T op(ivec2 idx, GRID_T x) {\n" " int i;\n" "\n" " for (i = 0; i < N / 2; ++i) {\n" " imageStore(dst_img, 2 * i," " imageLoad(src_img, W) + 1u);\n" " imageStore(dst_img, 2 * i + 1," " imageLoad(src_img, W) - 1u);\n" " }\n" "\n" " return x;\n" "}\n"), NULL)); bool ret = prog && init_fb(grid) && init_image(img) && set_uniform_int(prog, "src_img", 0) && set_uniform_int(prog, "dst_img", 0) && draw_grid(set_grid_size(grid, 1, 1), prog) && (check(img) || qual->control_test); glDeleteProgram(prog); return ret; }
/** * Execute the given action. */ static bool exec_action(const struct image_unit_action a) { if (a.action == BIND_NEW) { const GLenum format = (get_image_format(a.format) ? a.format : GL_RGBA32F); const struct image_info img = image_info(a.obj, format, W, H); const unsigned num_levels = image_num_levels(img); uint32_t pixels[4 * N * M] = { 0 }; if (!upload_image_levels(img, num_levels, 0, a.idx, pixels)) return false; glBindImageTexture(a.idx, get_texture(a.idx), a.level, a.layered, a.layer, a.access, a.format); } else if (a.action == BIND_IDX) { const unsigned idx = MIN2(a.idx, max_image_units()); glBindImageTexture(idx, get_texture(a.obj), a.level, a.layered, a.layer, a.access, a.format); } else if (a.action == BIND_OBJ) { glBindImageTexture(a.idx, a.obj, a.level, a.layered, a.layer, a.access, a.format); } else if (a.action == DELETE_IDX) { GLuint tex = get_texture(a.idx); glDeleteTextures(1, &tex); } else { abort(); } return piglit_check_gl_error(a.expect_status); }
int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]){ ulong addr; int rcode = 0; if (argc == 2){ addr = simple_strtoul(argv[1], NULL, 16); return image_info(addr); } else { #ifdef CFG_LONGHELP if(cmdtp->help != NULL){ printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->help); } else { printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->usage); } #else printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->usage); #endif return(1); } return(rcode); }
/** * Test skeleton: Init image to \a init_value, run the provided shader * \a op, check that the first \a check_sz pixels of the image equal * \a check_value and optionally check that the resulting fragment * values on the framebuffer are unique. */ static bool run_test(uint32_t init_value, unsigned check_sz, uint32_t check_value, bool check_unique, const char *op) { const struct grid_info grid = grid_info(GL_FRAGMENT_SHADER, GL_R32UI, W, H); const struct image_info img = image_info(GL_TEXTURE_1D, GL_R32UI, W, H); GLuint prog = generate_program( grid, GL_FRAGMENT_SHADER, concat(image_hunk(img, ""), hunk("volatile uniform IMAGE_T img;\n"), hunk(op), NULL)); bool ret = prog && init_fb(grid) && init_image(img, init_value) && set_uniform_int(prog, "img", 0) && draw_grid(grid, prog) && check_image_const(img, check_sz, check_value) && (!check_unique || check_fb_unique(grid)); glDeleteProgram(prog); return ret; }
void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact) { #define MAX_INFO_LEN 128 PropertyRNA *prop; PointerRNA imaptr; RNAUpdateCb *cb; Image *ima; ImageUser *iuser; Scene *scene = CTX_data_scene(C); uiLayout *row, *split, *col; uiBlock *block; char str[MAX_INFO_LEN]; void *lock; if (!ptr->data) return; prop = RNA_struct_find_property(ptr, propname); if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } block = uiLayoutGetBlock(layout); imaptr = RNA_property_pointer_get(ptr, prop); ima = imaptr.data; iuser = userptr->data; BKE_image_user_check_frame_calc(iuser, (int)scene->r.cfra, 0); cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); cb->ptr = *ptr; cb->prop = prop; cb->iuser = iuser; uiLayoutSetContextPointer(layout, "edit_image", &imaptr); uiLayoutSetContextPointer(layout, "edit_image_user", userptr); if (!compact) uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL); if (ima) { uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL); if (ima->source == IMA_SRC_VIEWER) { ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN); BKE_image_release_ibuf(ima, ibuf, lock); uiItemL(layout, ima->id.name + 2, ICON_NONE); uiItemL(layout, str, ICON_NONE); if (ima->type == IMA_TYPE_COMPOSITE) { // XXX not working yet #if 0 iuser = ntree_get_active_iuser(scene->nodetree); if (iuser) { uiBlockBeginAlign(block); uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10, 120, 100, 20, 0, 0, 0, 0, 0, ""); uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110, 120, 100, 20, 0, 0, 0, 0, 0, ""); but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, ""); uiButSetFunc(but, image_freecache_cb, ima, NULL); if (iuser->frames) BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr); else strcpy(str, "Frames:"); uiBlockBeginAlign(block); uiDefButI(block, NUM, imagechanged, str, 10, 90, 150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use"); uiDefButI(block, NUM, imagechanged, "StartFr:", 160, 90, 150, 20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie"); } #endif } else if (ima->type == IMA_TYPE_R_RESULT) { /* browse layer/passes */ RenderResult *rr; /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ rr = BKE_image_acquire_renderresult(scene, ima); uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); BKE_image_release_renderresult(scene, ima); } } else { uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); if (ima->source != IMA_SRC_GENERATED) { row = uiLayoutRow(layout, TRUE); if (ima->packedfile) uiItemO(row, "", ICON_PACKAGE, "image.unpack"); else uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); row = uiLayoutRow(row, TRUE); uiLayoutSetEnabled(row, ima->packedfile == NULL); uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); } // XXX what was this for? #if 0 /* check for re-render, only buttons */ if (imagechanged == B_IMAGECHANGED) { if (iuser->flag & IMA_ANIM_REFRESHED) { iuser->flag &= ~IMA_ANIM_REFRESHED; WM_event_add_notifier(C, NC_IMAGE, ima); } } #endif /* multilayer? */ if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) { uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL); } else if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN); BKE_image_release_ibuf(ima, ibuf, lock); uiItemL(layout, str, ICON_NONE); } } col = uiLayoutColumn(layout, FALSE); uiTemplateColorspaceSettings(col, &imaptr, "colorspace_settings"); uiItemR(col, &imaptr, "use_view_as_render", 0, NULL, ICON_NONE); if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { /* background image view doesnt need these */ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); int has_alpha = TRUE; if (ibuf) { int imtype = BKE_ftype_to_imtype(ibuf->ftype); char valid_channels = BKE_imtype_valid_channels(imtype); has_alpha = valid_channels & IMA_CHAN_FLAG_ALPHA; BKE_image_release_ibuf(ima, ibuf, NULL); } if (has_alpha) { col = uiLayoutColumn(layout, FALSE); uiItemR(col, &imaptr, "use_alpha", 0, NULL, ICON_NONE); uiItemR(col, &imaptr, "alpha_mode", 0, "Alpha", ICON_NONE); } uiItemS(layout); split = uiLayoutSplit(layout, 0.0f, FALSE); col = uiLayoutColumn(split, FALSE); /* XXX Why only display fields_per_frame only for video image types? * And why allow fields for non-video image types at all??? */ if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiLayout *subsplit = uiLayoutSplit(col, 0.0f, FALSE); uiLayout *subcol = uiLayoutColumn(subsplit, FALSE); uiItemR(subcol, &imaptr, "use_fields", 0, NULL, ICON_NONE); subcol = uiLayoutColumn(subsplit, FALSE); uiLayoutSetActive(subcol, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(subcol, userptr, "fields_per_frame", 0, IFACE_("Fields"), ICON_NONE); } else uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE); row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiItemS(layout); split = uiLayoutSplit(layout, 0.0f, FALSE); col = uiLayoutColumn(split, FALSE); BLI_snprintf(str, sizeof(str), IFACE_("(%d) Frames"), iuser->framenr); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); uiItemR(col, userptr, "frame_start", 0, IFACE_("Start"), ICON_NONE); uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE); col = uiLayoutColumn(split, FALSE); uiItemO(col, NULL, ICON_NONE, "IMAGE_OT_match_movie_length"); uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE); uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE); } else if (ima->source == IMA_SRC_GENERATED) { split = uiLayoutSplit(layout, 0.0f, FALSE); col = uiLayoutColumn(split, TRUE); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE); uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } uiBlockSetNFunc(block, NULL, NULL, NULL); } MEM_freeN(cb); #undef MAX_INFO_LEN }
void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact) { PropertyRNA *prop; PointerRNA imaptr; RNAUpdateCb *cb; Image *ima; ImageUser *iuser; ImBuf *ibuf; Scene *scene = CTX_data_scene(C); uiLayout *row, *split, *col; uiBlock *block; uiBut *but; char str[128]; void *lock; if (!ptr->data) return; prop = RNA_struct_find_property(ptr, propname); if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } block = uiLayoutGetBlock(layout); imaptr = RNA_property_pointer_get(ptr, prop); ima = imaptr.data; iuser = userptr->data; cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); cb->ptr = *ptr; cb->prop = prop; cb->iuser = iuser; uiLayoutSetContextPointer(layout, "edit_image", &imaptr); if (!compact) uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL); if (ima) { uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL); if (ima->source == IMA_SRC_VIEWER) { ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str); BKE_image_release_ibuf(ima, lock); uiItemL(layout, ima->id.name + 2, ICON_NONE); uiItemL(layout, str, ICON_NONE); if (ima->type == IMA_TYPE_COMPOSITE) { // XXX not working yet #if 0 iuser = ntree_get_active_iuser(scene->nodetree); if (iuser) { uiBlockBeginAlign(block); uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10, 120, 100, 20, 0, 0, 0, 0, 0, ""); uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110, 120, 100, 20, 0, 0, 0, 0, 0, ""); but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, ""); uiButSetFunc(but, image_freecache_cb, ima, NULL); if (iuser->frames) BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr); else strcpy(str, "Frames:"); uiBlockBeginAlign(block); uiDefButI(block, NUM, imagechanged, str, 10, 90, 150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use"); uiDefButI(block, NUM, imagechanged, "StartFr:", 160, 90, 150, 20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie"); } #endif } else if (ima->type == IMA_TYPE_R_RESULT) { /* browse layer/passes */ Render *re = RE_GetRender(scene->id.name); RenderResult *rr = RE_AcquireResultRead(re); uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); RE_ReleaseResult(re); } } else { uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); if (ima->source != IMA_SRC_GENERATED) { row = uiLayoutRow(layout, 1); if (ima->packedfile) uiItemO(row, "", ICON_PACKAGE, "image.unpack"); else uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); row = uiLayoutRow(row, 0); uiLayoutSetEnabled(row, ima->packedfile == NULL); uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); } // XXX what was this for? #if 0 /* check for re-render, only buttons */ if (imagechanged == B_IMAGECHANGED) { if (iuser->flag & IMA_ANIM_REFRESHED) { iuser->flag &= ~IMA_ANIM_REFRESHED; WM_event_add_notifier(C, NC_IMAGE, ima); } } #endif /* multilayer? */ if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) { uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL); } else if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str); BKE_image_release_ibuf(ima, lock); uiItemL(layout, str, ICON_NONE); } } if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { /* background image view doesnt need these */ uiItemS(layout); split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 0); uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE); row = uiLayoutRow(col, 0); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); row = uiLayoutRow(layout, 0); uiItemR(row, &imaptr, "use_premultiply", 0, NULL, ICON_NONE); uiItemR(row, &imaptr, "use_color_unpremultiply", 0, NULL, ICON_NONE); } } if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiItemS(layout); split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 0); BLI_snprintf(str, sizeof(str), "(%d) Frames", iuser->framenr); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); if (ima->anim) { block = uiLayoutGetBlock(col); but = uiDefBut(block, BUT, 0, "Match Movie Length", 0, 0, UI_UNIT_X * 2, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Set the number of frames to match the movie or sequence"); uiButSetFunc(but, set_frames_cb, ima, iuser); } uiItemR(col, userptr, "frame_start", 0, "Start", ICON_NONE); uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE); col = uiLayoutColumn(split, 0); row = uiLayoutRow(col, 0); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(row, userptr, "fields_per_frame", 0, "Fields", ICON_NONE); uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE); uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE); } else if (ima->source == IMA_SRC_GENERATED) { split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 1); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE); uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } uiBlockSetNFunc(block, NULL, NULL, NULL); } MEM_freeN(cb); }