-
Notifications
You must be signed in to change notification settings - Fork 81
Refactor RenderConfig interface #1561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
6c89994
471416f
ca82fd6
9833029
882ca11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -186,7 +186,9 @@ public DefaultRenderManager(RenderContext context, boolean headless) { | |
| this.bufferedScene = context.getChunky().getSceneFactory().newScene(); | ||
|
|
||
| // Create a new pool. Set the seed to the current time in milliseconds. | ||
| this.pool = context.renderPoolFactory.create(context.numRenderThreads(), System.currentTimeMillis()); | ||
| this.pool = context.renderPoolFactory.create( | ||
| context.getRenderOptions().getRenderThreadCount(), System.currentTimeMillis() | ||
| ); | ||
| this.setCPULoad(PersistentSettings.getCPULoad()); | ||
|
|
||
| // Initialize callbacks here since java will complain `bufferedScene` is not initialized yet. | ||
|
|
@@ -294,16 +296,16 @@ public void run() { | |
| getPreviewRenderer().sceneReset(this, reason, resetCount); | ||
|
|
||
| // Select the correct renderer | ||
| Renderer render = mode == RenderMode.PREVIEW ? getPreviewRenderer() : getRenderer(); | ||
| Renderer renderer = mode == RenderMode.PREVIEW ? getPreviewRenderer() : getRenderer(); | ||
|
|
||
| frameStart = System.currentTimeMillis(); | ||
| if (mode == RenderMode.PREVIEW) { | ||
| // Bail early if the preview is not visible | ||
| if (finalizeAllFrames) { | ||
| // Preview with no CPU limit | ||
| pool.setCpuLoad(100); | ||
| render.setPostRender(previewCallback); | ||
| render.render(this); | ||
| renderer.setPostRender(previewCallback); | ||
| startRender(renderer); | ||
| pool.setCpuLoad(cpuLoad); | ||
| } | ||
| } else { | ||
|
|
@@ -314,8 +316,8 @@ public void run() { | |
| updateRenderState(scene); | ||
| }); | ||
| } else if (mode != RenderMode.PAUSED) { | ||
| render.setPostRender(renderCallback); | ||
| render.render(this); | ||
| renderer.setPostRender(renderCallback); | ||
| startRender(renderer); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -328,6 +330,10 @@ public void run() { | |
| } | ||
| } | ||
|
|
||
| protected void startRender(Renderer renderer) throws InterruptedException { | ||
| renderer.render(this); | ||
| } | ||
|
Comment on lines
+333
to
+335
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this for plugins?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe I added this to be overridable by custom RenderManagers to add pre-start logic.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. e.g. setting data in the new worker state / ray factories |
||
|
|
||
| /** | ||
| * Redraw the GUI screen. This should be run after postprocessing. | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package se.llbit.chunky.renderer; | ||
|
|
||
| public class ModifiableRenderOptions implements RenderOptions { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. Can we improve this so that modifying the render options is safe and gets applied after the user confirms (or reset otherwise)?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty sure that this would be the job of the UI logic or something in the render code which copies its state from this object. At the moment, the user can only set the |
||
| protected int renderThreadCount = -1; | ||
| protected int tileWidth = TILE_WIDTH_DEFAULT; | ||
| protected int sppPerPass = SPP_PER_PASS_DEFAULT; | ||
|
|
||
| public void copyState(RenderOptions other) { | ||
| renderThreadCount = other.getRenderThreadCount(); | ||
| tileWidth = other.getTileWidth(); | ||
| sppPerPass = other.getSppPerPass(); | ||
| } | ||
|
|
||
| @Override | ||
| public int getRenderThreadCount() { | ||
| return renderThreadCount; | ||
| } | ||
|
|
||
| public void setRenderThreadCount(int renderThreadCount) { | ||
| this.renderThreadCount = renderThreadCount; | ||
| } | ||
|
|
||
| @Override | ||
| public int getTileWidth() { | ||
| return tileWidth; | ||
| } | ||
|
|
||
| public void setTileWidth(int tileWidth) { | ||
| this.tileWidth = tileWidth; | ||
| } | ||
|
|
||
| @Override | ||
| public int getSppPerPass() { | ||
| return sppPerPass; | ||
| } | ||
|
|
||
| public void setSppPerPass(int sppPerPass) { | ||
| this.sppPerPass = sppPerPass; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.