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.
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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:")
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user