Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Commit

Permalink
Fix: -renderbucket-size value not applied to GPU render (#256)
Browse files Browse the repository at this point in the history
* Fix: -renderbucket-size option not applied if configuration file doesn't exist
  • Loading branch information
luguina authored Jun 21, 2020
1 parent a4b5493 commit 2b2e5cc
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/com/sheepit/client/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}

Expand Down
17 changes: 15 additions & 2 deletions src/com/sheepit/client/SettingsLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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));
Expand Down
1 change: 1 addition & 0 deletions src/com/sheepit/client/hardware/cpu/CPU.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/com/sheepit/client/hardware/gpu/GPU.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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() {
Expand Down
19 changes: 14 additions & 5 deletions src/com/sheepit/client/hardware/gpu/GPUDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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")) {
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/sheepit/client/standalone/Worker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 2b2e5cc

Please sign in to comment.