Fix: -renderbucket-size value not applied to GPU render (#256)

* Fix: -renderbucket-size option not applied if configuration file doesn't exist
This commit is contained in:
Luis Uguina
2020-06-21 19:21:23 +10:00
committed by GitHub
parent f3538eafde
commit 36c14b6ee1
7 changed files with 36 additions and 11 deletions

View File

@@ -45,6 +45,7 @@ import java.util.regex.Matcher;
import com.sheepit.client.Configuration.ComputeType;
import com.sheepit.client.Error.Type;
import com.sheepit.client.hardware.cpu.CPU;
import com.sheepit.client.hardware.gpu.GPUDevice;
import com.sheepit.client.hardware.gpu.opencl.OpenCL;
import com.sheepit.client.os.OS;
@@ -184,7 +185,7 @@ import lombok.Getter;
else {
// Otherwise (CPU), fix the tile size to 32x32px
core_script = "sheepit_set_compute_device(\"NONE\", \"CPU\", \"CPU\")\n";
core_script += String.format("bpy.context.scene.render.tile_x = %1$d\nbpy.context.scene.render.tile_y = %1$d\n", 32);
core_script += String.format("bpy.context.scene.render.tile_x = %1$d\nbpy.context.scene.render.tile_y = %1$d\n", CPU.MIN_RENDERBUCKET_SIZE);
gui.setComputeMethod("CPU");
}

View File

@@ -109,7 +109,7 @@ public class SettingsLoader {
gpu = gpu_.getId();
}
if (renderbucketSize_ >= 32) {
if (renderbucketSize_ >= GPU.MIN_RENDERBUCKET_SIZE) {
renderbucketSize = String.valueOf(renderbucketSize_);
}
}
@@ -382,7 +382,7 @@ public class SettingsLoader {
config.setGPUDevice(device);
// If the user has indicated a render bucket size at least 32x32 px, overwrite the config file value
if (config.getRenderbucketSize() >= 32) {
if (config.getRenderbucketSize() >= GPU.MIN_RENDERBUCKET_SIZE) {
config.getGPUDevice().setRenderbucketSize(config.getRenderbucketSize()); // Update size
}
else {
@@ -400,6 +400,19 @@ public class SettingsLoader {
config.setRenderbucketSize(config.getGPUDevice().getRenderbucketSize());
}
}
else if (config.getGPUDevice() != null) {
// The order of conditions is important to ensure the priority or app arguments, then the config file and finally the recommended size (if none
// specified or already in config file).
if (config.getRenderbucketSize() >= GPU.MIN_RENDERBUCKET_SIZE) {
config.getGPUDevice().setRenderbucketSize(config.getRenderbucketSize());
}
else if (renderbucketSize != null) {
config.getGPUDevice().setRenderbucketSize(Integer.parseInt(renderbucketSize));
}
else {
config.getGPUDevice().setRenderbucketSize(config.getGPUDevice().getRecommendedBucketSize());
}
}
if (config.getNbCores() == -1 && cores != null) {
config.setNbCores(Integer.valueOf(cores));

View File

@@ -20,6 +20,7 @@
package com.sheepit.client.hardware.cpu;
public class CPU {
final public static int MIN_RENDERBUCKET_SIZE = 32;
private String name;
private String model;
private String family;

View File

@@ -29,6 +29,7 @@ import com.sheepit.client.os.OS;
import com.sheepit.client.os.Windows;
public class GPU {
final public static int MIN_RENDERBUCKET_SIZE = 32;
public static List<GPUDevice> devices = null;
public static boolean generate() {

View File

@@ -37,7 +37,7 @@ public class GPUDevice {
this.model = model;
this.memory = ram;
this.id = id;
this.renderBucketSize = 32;
this.renderBucketSize = GPU.MIN_RENDERBUCKET_SIZE;
}
public GPUDevice(String type, String model, long ram, String id, String oldId) {
@@ -89,8 +89,12 @@ public class GPUDevice {
return this.renderBucketSize;
}
public void setRenderbucketSize(int proposedRenderbucketSize) {
int renderBucketSize = 32;
public int getRecommendedBucketSize() {
this.setRenderbucketSize(null);
return this.renderBucketSize;
}
public void setRenderbucketSize(Integer proposedRenderbucketSize) {
GPULister gpu;
if (type.equals("CUDA")) {
@@ -104,11 +108,16 @@ public class GPUDevice {
// because is a new one (different from CUDA and OPENCL). In that case, move into the safest position
// of 32x32 pixel tile sizes
System.out.println("GPUDevice::setRenderbucketSize Unable to detect GPU technology. Render bucket size set to 32x32 pixels");
this.renderBucketSize = 32;
this.renderBucketSize = GPU.MIN_RENDERBUCKET_SIZE;
return;
}
if (proposedRenderbucketSize >= 32) {
int renderBucketSize = GPU.MIN_RENDERBUCKET_SIZE;
if (proposedRenderbucketSize == null) {
renderBucketSize = gpu.getRecommendedRenderBucketSize(getMemory());
}
else if (proposedRenderbucketSize >= GPU.MIN_RENDERBUCKET_SIZE) {
if (proposedRenderbucketSize <= gpu.getMaximumRenderBucketSize(getMemory())) {
renderBucketSize = proposedRenderbucketSize;
}

View File

@@ -266,7 +266,7 @@ public class Worker {
config.setComputeMethod(compute_method);
// Change the default configuration if the user has specified a minimum renderbucket size of 32
if (renderbucketSize >= 32) {
if (renderbucketSize >= GPU.MIN_RENDERBUCKET_SIZE) {
// Send the proposed renderbucket size and check if viable
config.setRenderbucketSize(renderbucketSize);
}

View File

@@ -314,7 +314,7 @@ public class Settings implements Activity {
// because is a new one (different from CUDA and OPENCL). In that case, move into a safe position
// of 32x32 pixel render bucket and a maximum of 128x128 pixel for the "unknown GPU"
int maxRenderbucketSize = 128;
int recommendedBucketSize = 32;
int recommendedBucketSize = GPU.MIN_RENDERBUCKET_SIZE;
if (config.getComputeMethod() == ComputeType.GPU || config.getComputeMethod() == ComputeType.CPU_GPU) {
GPULister gpu;
@@ -633,7 +633,7 @@ public class Settings implements Activity {
else {
GPULister gpu;
int maxRenderbucketSize = 128; // Max default render bucket size
int recommendedBucketSize = 32; // Default recommended render bucket size
int recommendedBucketSize = GPU.MIN_RENDERBUCKET_SIZE; // Default recommended render bucket size
if (useGPUs.get(counter).getGPUDevice().getType().equals("CUDA")) {
gpu = new Nvidia();