diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-11-05 12:05:14 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-11-05 12:05:14 +0400 |
commit | 759ea4078782ace683a3e835166b7f324c8e3224 (patch) | |
tree | 80b50138b42f89a247612c9461d467391014683d | |
parent | 6eec49ed20fb3a8032718d5f4b9a3e774098df3f (diff) |
Render engines: replace number of x/y tiles with tile size
Now tile size is setting up explicitly instead of using number of tiles.
This allows better control over GPU performance, where having tiles aligned
to specific size makes lots of sense.
Still to come: need to update startup.blend to make tiles size 64x64.
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 6 | ||||
-rw-r--r-- | intern/cycles/render/tile.cpp | 20 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/properties_render.py | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 4 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 16 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 10 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 16 | ||||
-rw-r--r-- | source/blender/render/intern/include/render_types.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/envmap.c | 3 | ||||
-rw-r--r-- | source/blender/render/intern/source/initrender.c | 26 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 3 | ||||
-rw-r--r-- | source/blender/render/intern/source/renderdatabase.c | 3 |
14 files changed, 70 insertions, 67 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 52d2c6a2d89..9cc58e65bef 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -193,10 +193,10 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel): sub.prop(rd, "threads") sub = col.column(align=True) - sub.label(text="Tiles:") + sub.label(text="Tile Size:") - sub.prop(rd, "parts_x", text="X") - sub.prop(rd, "parts_y", text="Y") + sub.prop(rd, "tile_x", text="X") + sub.prop(rd, "tile_y", text="Y") sub.prop(cscene, "use_progressive_refine") diff --git a/intern/cycles/render/tile.cpp b/intern/cycles/render/tile.cpp index c294239bac0..74585dd5058 100644 --- a/intern/cycles/render/tile.cpp +++ b/intern/cycles/render/tile.cpp @@ -84,8 +84,6 @@ void TileManager::gen_tiles_global() int tile_w = (tile_size.x >= image_w)? 1: (image_w + tile_size.x - 1)/tile_size.x; int tile_h = (tile_size.y >= image_h)? 1: (image_h + tile_size.y - 1)/tile_size.y; - int sub_w = (image_w + tile_w - 1)/tile_w; - int sub_h = (image_h + tile_h - 1)/tile_h; int num_logical_devices = preserve_tile_device? num_devices: 1; int num = min(image_h, num_logical_devices); @@ -96,10 +94,10 @@ void TileManager::gen_tiles_global() for(int tile_y = 0; tile_y < tile_h; tile_y++) { for(int tile_x = 0; tile_x < tile_w; tile_x++, tile_index++) { - int x = tile_x * sub_w; - int y = tile_y * sub_h; - int w = (tile_x == tile_w-1)? image_w - x: sub_w; - int h = (tile_y == tile_h-1)? image_h - y: sub_h; + int x = tile_x * tile_size.x; + int y = tile_y * tile_size.y; + int w = (tile_x == tile_w-1)? image_w - x: tile_size.x; + int h = (tile_y == tile_h-1)? image_h - y: tile_size.y; state.tiles.push_back(Tile(tile_index, x, y, w, h, cur_device)); cur_tiles++; @@ -131,15 +129,13 @@ void TileManager::gen_tiles_sliced() int tile_w = (tile_size.x >= image_w)? 1: (image_w + tile_size.x - 1)/tile_size.x; int tile_h = (tile_size.y >= device_h)? 1: (device_h + tile_size.y - 1)/tile_size.y; - int sub_w = (image_w + tile_w - 1)/tile_w; - int sub_h = (device_h + tile_h - 1)/tile_h; for(int tile_y = 0; tile_y < tile_h; tile_y++) { for(int tile_x = 0; tile_x < tile_w; tile_x++, tile_index++) { - int x = tile_x * sub_w; - int y = tile_y * sub_h; - int w = (tile_x == tile_w-1)? image_w - x: sub_w; - int h = (tile_y == tile_h-1)? device_h - y: sub_h; + int x = tile_x * tile_size.x; + int y = tile_y * tile_size.y; + int w = (tile_x == tile_w-1)? image_w - x: tile_size.x; + int h = (tile_y == tile_h-1)? device_h - y: tile_size.x; state.tiles.push_back(Tile(tile_index, x, y + device_y, w, h, device)); } diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index abc2626ee13..9814dd7e902 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -340,9 +340,9 @@ class RENDER_PT_performance(RenderButtonsPanel, Panel): subsub.prop(rd, "threads") sub = col.column(align=True) - sub.label(text="Tiles:") - sub.prop(rd, "parts_x", text="X") - sub.prop(rd, "parts_y", text="Y") + sub.label(text="Tile Size:") + sub.prop(rd, "tile_x", text="X") + sub.prop(rd, "tile_y", text="Y") col = split.column() col.label(text="Memory:") diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index fbe327aa525..a1918b77a1e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -368,8 +368,8 @@ Scene *BKE_scene_add(const char *name) sce->r.ysch = 1080; sce->r.xasp = 1; sce->r.yasp = 1; - sce->r.xparts = 8; - sce->r.yparts = 8; + sce->r.tilex = 256; + sce->r.tiley = 256; sce->r.mblur_samples = 1; sce->r.filtertype = R_FILTER_MITCH; sce->r.size = 50; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 38213878ba1..38e92961075 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8297,7 +8297,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + } + + { + /* convert tiles size from resolution and number of tiles */ + { + Scene *scene; + for (scene = main->scene.first; scene; scene = scene->id.next) { + if (scene->r.tilex == 0 || scene->r.tiley == 1) { + /* scene could be set for panoramic rendering, so clamp with the + * lowest possible tile size value + */ + scene->r.tilex = max_ii(scene->r.xsch * scene->r.size / scene->r.xparts / 100, 8); + scene->r.tiley = max_ii(scene->r.ysch * scene->r.size / scene->r.yparts / 100, 8); + } + } + } } { diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index a2f31b35246..53cb5340940 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -266,10 +266,13 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre BKE_color_managed_view_settings_copy(&sce->view_settings, &scene->view_settings); /* prevent overhead for small renders and icons (32) */ - if (id && sp->sizex < 40) - sce->r.xparts = sce->r.yparts = 1; - else - sce->r.xparts = sce->r.yparts = 4; + if (id && sp->sizex < 40) { + sce->r.tilex = sce->r.tiley = 64; + } + else { + sce->r.tilex = sce->r.xsch / 4; + sce->r.tiley = sce->r.ysch / 4; + } /* exception: don't apply render part of display transform for texture previews or icons */ if ((id && sp->pr_method == PR_ICON_RENDER) || id_type == ID_TE) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 0a282a17f74..4d4fad47698 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2857,14 +2857,8 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw engine = RE_engine_create(type); - engine->tile_x = ceil(ar->winx / (float)scene->r.xparts); - engine->tile_y = ceil(ar->winy / (float)scene->r.yparts); - - /* clamp small tile sizes to prevent inefficient threading utilization - * the same happens for final renders as well - */ - engine->tile_x = max_ii(engine->tile_x, 64); - engine->tile_y = max_ii(engine->tile_x, 64); + engine->tile_x = scene->r.tilex; + engine->tile_y = scene->r.tiley; type->view_update(engine, C); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 9d59817632a..1479d5268ed 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -396,11 +396,16 @@ typedef struct RenderData { /** * The number of part to use in the x direction */ - short xparts; + short xparts DNA_DEPRECATED; /** * The number of part to use in the y direction */ - short yparts; + short yparts DNA_DEPRECATED; + + /** + * render tile dimensions + */ + short tilex, tiley; short planes DNA_DEPRECATED, imtype DNA_DEPRECATED, subimtype DNA_DEPRECATED, quality DNA_DEPRECATED; /*deprecated!*/ @@ -448,6 +453,8 @@ typedef struct RenderData { short frs_sec, edgeint; + int pad; + /* safety, border and display rect */ rctf safety, border; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index df50f84add7..69bb1cc98ff 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3395,16 +3395,16 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Resolution %", "Percentage scale for render resolution"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "parts_x", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "xparts"); - RNA_def_property_range(prop, 1, 512); - RNA_def_property_ui_text(prop, "Parts X", "Number of horizontal tiles to use while rendering"); + prop = RNA_def_property(srna, "tile_x", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "tilex"); + RNA_def_property_range(prop, 8, 10000); + RNA_def_property_ui_text(prop, "Tile X", "Horizontal tile size to use while rendering"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "parts_y", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "yparts"); - RNA_def_property_range(prop, 1, 512); - RNA_def_property_ui_text(prop, "Parts Y", "Number of vertical tiles to use while rendering"); + prop = RNA_def_property(srna, "tile_y", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "tiley"); + RNA_def_property_range(prop, 8, 10000); + RNA_def_property_ui_text(prop, "Tile Y", "Vertical tile size to use while rendering"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "pixel_aspect_x", PROP_FLOAT, PROP_NONE); diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 1e62ab6d14d..825fe2ff4d0 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -145,8 +145,6 @@ struct Render /* final picture width and height (within disprect) */ int rectx, recty; - /* real maximum amount of xparts/yparts after correction for minimum */ - int xparts, yparts; /* real maximum size of parts after correction for minimum * partx*xparts can be larger than rectx, in that case last part is smaller */ int partx, party; diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 558ba8fe062..28f70211a9c 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -148,7 +148,8 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) envre->r.mode &= ~(R_BORDER | R_PANORAMA | R_ORTHO | R_MBLUR); envre->r.layers.first = envre->r.layers.last = NULL; envre->r.filtertype = 0; - envre->r.xparts = envre->r.yparts = 2; + envre->r.tilex = envre->r.xsch / 2; + envre->r.tiley = envre->r.ysch / 2; envre->r.size = 100; envre->r.yasp = envre->r.xasp = 1; diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 2b564a09024..b2cf8db7995 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -555,31 +555,17 @@ void initparts(Render *re, int do_crop) xmaxb = re->disprect.xmax; ymaxb = re->disprect.ymax; - xparts = re->r.xparts; - yparts = re->r.yparts; - - /* minimum part size */ - if (re->r.mode & R_PANORAMA) { - if (ceil(re->rectx / (float)xparts) < 8) - xparts = 1 + re->rectx / 8; - } - else { - if (ceil(re->rectx / (float)xparts) < 64) - xparts = 1 + re->rectx / 64; - } - - if (ceil(re->recty / (float)yparts) < 64) - yparts = 1 + re->recty / 64; - /* part size */ - partx = ceil(re->rectx / (float)xparts); - party = ceil(re->recty / (float)yparts); + partx = min_ii(re->r.tilex, re->rectx); + party = min_ii(re->r.tiley, re->recty); - re->xparts = xparts; - re->yparts = yparts; re->partx = partx; re->party = party; + /* part count */ + xparts = (re->rectx + partx - 1) / partx; + yparts = (re->recty + party - 1) / party; + /* calculate rotation factor of 1 pixel */ if (re->r.mode & R_PANORAMA) re->panophi = panorama_pixel_rot(re); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index a3fb953e7b2..7ef3aecad08 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -677,6 +677,7 @@ float panorama_pixel_rot(Render *re) { float psize, phi, xfac; float borderfac = (float)BLI_rcti_size_x(&re->disprect) / (float)re->winx; + int xparts = (re->rectx + re->partx - 1) / re->partx; /* size of 1 pixel mapped to viewplane coords */ psize = BLI_rctf_size_x(&re->viewplane) / (float)re->winx; @@ -684,7 +685,7 @@ float panorama_pixel_rot(Render *re) phi = atan(psize / re->clipsta); /* correction factor for viewplane shifting, first calculate how much the viewplane angle is */ - xfac = borderfac * BLI_rctf_size_x(&re->viewplane) / (float)re->xparts; + xfac = borderfac * BLI_rctf_size_x(&re->viewplane) / (float)xparts; xfac = atan(0.5f * xfac / re->clipsta); /* and how much the same viewplane angle is wrapped */ psize = 0.5f * phi * ((float)re->partx); diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 886f266b22f..7a7602dcce2 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -1184,6 +1184,7 @@ static int panotestclip(Render *re, int do_pano, float *v) /* to be used for halos en infos */ float abs4; short c=0; + int xparts = (re->rectx + re->partx - 1) / re->partx; if (do_pano == FALSE) { return testclip(v); @@ -1197,7 +1198,7 @@ static int panotestclip(Render *re, int do_pano, float *v) if ( v[1]>abs4) c+=4; else if ( v[1]< -abs4) c+=8; - abs4*= re->xparts; + abs4*= xparts; if ( v[0]>abs4) c+=2; else if ( v[0]< -abs4) c+=1; |