From 3329dfbbeed9c736960f3f97bee48607c90a5a24 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 19 Nov 2018 09:08:34 -0500 Subject: [PATCH] gpu: don't compute scene if the scene buffer isn't filled yet --- .../client/plugins/gpu/GpuPlugin.java | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java index 83363750ea..ba21c8193a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java @@ -740,48 +740,48 @@ public class GpuPlugin extends Plugin implements DrawCallbacks gl.glBufferSubData(gl.GL_UNIFORM_BUFFER, 0, uniformBuffer.limit() * Integer.BYTES, uniformBuffer); gl.glBindBuffer(gl.GL_UNIFORM_BUFFER, 0); - gl.glUniformBlockBinding(glSmallComputeProgram, uniBlockSmall, 0); - gl.glUniformBlockBinding(glComputeProgram, uniBlockLarge, 0); - - gl.glBindBufferBase(gl.GL_UNIFORM_BUFFER, 0, uniformBufferId); - - /* - * Compute is split into two separate programs 'small' and 'large' to - * save on GPU resources. Small will sort <= 512 faces, large will do <= 4096. - */ - - // small - gl.glUseProgram(glSmallComputeProgram); - - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 0, modelBufferSmallId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 1, this.bufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 2, bufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 3, outBufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 4, outUvBufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 5, this.uvBufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 6, uvBufferId); - - gl.glDispatchCompute(smallModels, 1, 1); - - // large - gl.glUseProgram(glComputeProgram); - - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 0, modelBufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 1, this.bufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 2, bufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 3, outBufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 4, outUvBufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 5, this.uvBufferId); - gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 6, uvBufferId); - - gl.glDispatchCompute(largeModels, 1, 1); - - gl.glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); - // Draw 3d scene final TextureProvider textureProvider = client.getTextureProvider(); - if (textureProvider != null) + if (textureProvider != null && this.bufferId != -1) { + gl.glUniformBlockBinding(glSmallComputeProgram, uniBlockSmall, 0); + gl.glUniformBlockBinding(glComputeProgram, uniBlockLarge, 0); + + gl.glBindBufferBase(gl.GL_UNIFORM_BUFFER, 0, uniformBufferId); + + /* + * Compute is split into two separate programs 'small' and 'large' to + * save on GPU resources. Small will sort <= 512 faces, large will do <= 4096. + */ + + // small + gl.glUseProgram(glSmallComputeProgram); + + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 0, modelBufferSmallId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 1, this.bufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 2, bufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 3, outBufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 4, outUvBufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 5, this.uvBufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 6, uvBufferId); + + gl.glDispatchCompute(smallModels, 1, 1); + + // large + gl.glUseProgram(glComputeProgram); + + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 0, modelBufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 1, this.bufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 2, bufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 3, outBufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 4, outUvBufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 5, this.uvBufferId); + gl.glBindBufferBase(gl.GL_SHADER_STORAGE_BUFFER, 6, uvBufferId); + + gl.glDispatchCompute(largeModels, 1, 1); + + gl.glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); + if (textureArrayId == -1) { // lazy init textures as they may not be loaded at plugin start.