diff --git a/src/com/sheepit/client/Job.java b/src/com/sheepit/client/Job.java index 3939c9c3..7a93cdb8 100644 --- a/src/com/sheepit/client/Job.java +++ b/src/com/sheepit/client/Job.java @@ -45,6 +45,7 @@ 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 @@ public Error.Type render(Observer renderStarted) { 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"); } diff --git a/src/com/sheepit/client/SettingsLoader.java b/src/com/sheepit/client/SettingsLoader.java index 4e6dc7be..11a4fddc 100644 --- a/src/com/sheepit/client/SettingsLoader.java +++ b/src/com/sheepit/client/SettingsLoader.java @@ -109,7 +109,7 @@ public SettingsLoader(String path_, String login_, String password_, String prox gpu = gpu_.getId(); } - if (renderbucketSize_ >= 32) { + if (renderbucketSize_ >= GPU.MIN_RENDERBUCKET_SIZE) { renderbucketSize = String.valueOf(renderbucketSize_); } } @@ -382,7 +382,7 @@ else if ((config.getComputeMethod() == null && computeMethod != null) || (comput 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 @@ else if ((config.getComputeMethod() == null && computeMethod != null) || (comput 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)); diff --git a/src/com/sheepit/client/hardware/cpu/CPU.java b/src/com/sheepit/client/hardware/cpu/CPU.java index 49f59721..371d7606 100644 --- a/src/com/sheepit/client/hardware/cpu/CPU.java +++ b/src/com/sheepit/client/hardware/cpu/CPU.java @@ -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; diff --git a/src/com/sheepit/client/hardware/gpu/GPU.java b/src/com/sheepit/client/hardware/gpu/GPU.java index 08dd2757..240ffcc1 100644 --- a/src/com/sheepit/client/hardware/gpu/GPU.java +++ b/src/com/sheepit/client/hardware/gpu/GPU.java @@ -29,6 +29,7 @@ import com.sheepit.client.os.Windows; public class GPU { + final public static int MIN_RENDERBUCKET_SIZE = 32; public static List devices = null; public static boolean generate() { diff --git a/src/com/sheepit/client/hardware/gpu/GPUDevice.java b/src/com/sheepit/client/hardware/gpu/GPUDevice.java index 58d1513a..fe1e2ec1 100644 --- a/src/com/sheepit/client/hardware/gpu/GPUDevice.java +++ b/src/com/sheepit/client/hardware/gpu/GPUDevice.java @@ -37,7 +37,7 @@ public GPUDevice(String type, String model, long ram, String id) { 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) { @@ -88,9 +88,13 @@ public void setOldId(String id) { public int getRenderbucketSize() { return this.renderBucketSize; } + + public int getRecommendedBucketSize() { + this.setRenderbucketSize(null); + return this.renderBucketSize; + } - public void setRenderbucketSize(int proposedRenderbucketSize) { - int renderBucketSize = 32; + public void setRenderbucketSize(Integer proposedRenderbucketSize) { GPULister gpu; if (type.equals("CUDA")) { @@ -104,11 +108,16 @@ else if (type.equals("OPENCL")) { // 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; } diff --git a/src/com/sheepit/client/standalone/Worker.java b/src/com/sheepit/client/standalone/Worker.java index 1ae0b952..fb343588 100644 --- a/src/com/sheepit/client/standalone/Worker.java +++ b/src/com/sheepit/client/standalone/Worker.java @@ -266,7 +266,7 @@ else if (compute_method == ComputeType.CPU) { 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); } diff --git a/src/com/sheepit/client/standalone/swing/activity/Settings.java b/src/com/sheepit/client/standalone/swing/activity/Settings.java index 80c236c0..661a1db3 100644 --- a/src/com/sheepit/client/standalone/swing/activity/Settings.java +++ b/src/com/sheepit/client/standalone/swing/activity/Settings.java @@ -314,7 +314,7 @@ else if (method == ComputeType.GPU) { // 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 @@ class GpuChangeAction implements ActionListener { 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();