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:
@@ -45,6 +45,7 @@ import java.util.regex.Matcher;
|
|||||||
|
|
||||||
import com.sheepit.client.Configuration.ComputeType;
|
import com.sheepit.client.Configuration.ComputeType;
|
||||||
import com.sheepit.client.Error.Type;
|
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.GPUDevice;
|
||||||
import com.sheepit.client.hardware.gpu.opencl.OpenCL;
|
import com.sheepit.client.hardware.gpu.opencl.OpenCL;
|
||||||
import com.sheepit.client.os.OS;
|
import com.sheepit.client.os.OS;
|
||||||
@@ -184,7 +185,7 @@ import lombok.Getter;
|
|||||||
else {
|
else {
|
||||||
// Otherwise (CPU), fix the tile size to 32x32px
|
// Otherwise (CPU), fix the tile size to 32x32px
|
||||||
core_script = "sheepit_set_compute_device(\"NONE\", \"CPU\", \"CPU\")\n";
|
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");
|
gui.setComputeMethod("CPU");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class SettingsLoader {
|
|||||||
gpu = gpu_.getId();
|
gpu = gpu_.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderbucketSize_ >= 32) {
|
if (renderbucketSize_ >= GPU.MIN_RENDERBUCKET_SIZE) {
|
||||||
renderbucketSize = String.valueOf(renderbucketSize_);
|
renderbucketSize = String.valueOf(renderbucketSize_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,7 +382,7 @@ public class SettingsLoader {
|
|||||||
config.setGPUDevice(device);
|
config.setGPUDevice(device);
|
||||||
|
|
||||||
// If the user has indicated a render bucket size at least 32x32 px, overwrite the config file value
|
// 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
|
config.getGPUDevice().setRenderbucketSize(config.getRenderbucketSize()); // Update size
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -400,6 +400,19 @@ public class SettingsLoader {
|
|||||||
config.setRenderbucketSize(config.getGPUDevice().getRenderbucketSize());
|
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) {
|
if (config.getNbCores() == -1 && cores != null) {
|
||||||
config.setNbCores(Integer.valueOf(cores));
|
config.setNbCores(Integer.valueOf(cores));
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
package com.sheepit.client.hardware.cpu;
|
package com.sheepit.client.hardware.cpu;
|
||||||
|
|
||||||
public class CPU {
|
public class CPU {
|
||||||
|
final public static int MIN_RENDERBUCKET_SIZE = 32;
|
||||||
private String name;
|
private String name;
|
||||||
private String model;
|
private String model;
|
||||||
private String family;
|
private String family;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.sheepit.client.os.OS;
|
|||||||
import com.sheepit.client.os.Windows;
|
import com.sheepit.client.os.Windows;
|
||||||
|
|
||||||
public class GPU {
|
public class GPU {
|
||||||
|
final public static int MIN_RENDERBUCKET_SIZE = 32;
|
||||||
public static List<GPUDevice> devices = null;
|
public static List<GPUDevice> devices = null;
|
||||||
|
|
||||||
public static boolean generate() {
|
public static boolean generate() {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class GPUDevice {
|
|||||||
this.model = model;
|
this.model = model;
|
||||||
this.memory = ram;
|
this.memory = ram;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.renderBucketSize = 32;
|
this.renderBucketSize = GPU.MIN_RENDERBUCKET_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GPUDevice(String type, String model, long ram, String id, String oldId) {
|
public GPUDevice(String type, String model, long ram, String id, String oldId) {
|
||||||
@@ -89,8 +89,12 @@ public class GPUDevice {
|
|||||||
return this.renderBucketSize;
|
return this.renderBucketSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRenderbucketSize(int proposedRenderbucketSize) {
|
public int getRecommendedBucketSize() {
|
||||||
int renderBucketSize = 32;
|
this.setRenderbucketSize(null);
|
||||||
|
return this.renderBucketSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRenderbucketSize(Integer proposedRenderbucketSize) {
|
||||||
GPULister gpu;
|
GPULister gpu;
|
||||||
|
|
||||||
if (type.equals("CUDA")) {
|
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
|
// because is a new one (different from CUDA and OPENCL). In that case, move into the safest position
|
||||||
// of 32x32 pixel tile sizes
|
// of 32x32 pixel tile sizes
|
||||||
System.out.println("GPUDevice::setRenderbucketSize Unable to detect GPU technology. Render bucket size set to 32x32 pixels");
|
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;
|
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())) {
|
if (proposedRenderbucketSize <= gpu.getMaximumRenderBucketSize(getMemory())) {
|
||||||
renderBucketSize = proposedRenderbucketSize;
|
renderBucketSize = proposedRenderbucketSize;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ public class Worker {
|
|||||||
config.setComputeMethod(compute_method);
|
config.setComputeMethod(compute_method);
|
||||||
|
|
||||||
// Change the default configuration if the user has specified a minimum renderbucket size of 32
|
// 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
|
// Send the proposed renderbucket size and check if viable
|
||||||
config.setRenderbucketSize(renderbucketSize);
|
config.setRenderbucketSize(renderbucketSize);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
// 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"
|
// of 32x32 pixel render bucket and a maximum of 128x128 pixel for the "unknown GPU"
|
||||||
int maxRenderbucketSize = 128;
|
int maxRenderbucketSize = 128;
|
||||||
int recommendedBucketSize = 32;
|
int recommendedBucketSize = GPU.MIN_RENDERBUCKET_SIZE;
|
||||||
|
|
||||||
if (config.getComputeMethod() == ComputeType.GPU || config.getComputeMethod() == ComputeType.CPU_GPU) {
|
if (config.getComputeMethod() == ComputeType.GPU || config.getComputeMethod() == ComputeType.CPU_GPU) {
|
||||||
GPULister gpu;
|
GPULister gpu;
|
||||||
@@ -633,7 +633,7 @@ public class Settings implements Activity {
|
|||||||
else {
|
else {
|
||||||
GPULister gpu;
|
GPULister gpu;
|
||||||
int maxRenderbucketSize = 128; // Max default render bucket size
|
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")) {
|
if (useGPUs.get(counter).getGPUDevice().getType().equals("CUDA")) {
|
||||||
gpu = new Nvidia();
|
gpu = new Nvidia();
|
||||||
|
|||||||
Reference in New Issue
Block a user