From 6b07087c3103c6aa57ec3758255144d65873bf1c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Sat, 12 May 2007 00:57:35 +0000 Subject: [PATCH] 32 matrices is just a feeeeew two many for ATI cards, but of course their drivers can't do anything useful like report an error; they just silently screw up. Limiting it to 31 makes it work, but there's still a strange slowdown issue (and it's not that the shaders are being run in software, but it's worth checking for that anyway). git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@243 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../com/threerings/jme/model/SkinMesh.java | 2 +- .../com/threerings/jme/util/ShaderCache.java | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/java/com/threerings/jme/model/SkinMesh.java b/src/java/com/threerings/jme/model/SkinMesh.java index 141a5abb..161d7de9 100644 --- a/src/java/com/threerings/jme/model/SkinMesh.java +++ b/src/java/com/threerings/jme/model/SkinMesh.java @@ -71,7 +71,7 @@ import com.threerings.jme.util.ShaderConfig; public class SkinMesh extends ModelMesh { /** The maximum number of bone matrices that we can use for hardware skinning. */ - public static final int MAX_SHADER_BONE_COUNT = 32; + public static final int MAX_SHADER_BONE_COUNT = 31; /** The maximum number of bones influencing a single vertex for hardware skinning. */ public static final int MAX_SHADER_BONES_PER_VERTEX = 4; diff --git a/src/java/com/threerings/jme/util/ShaderCache.java b/src/java/com/threerings/jme/util/ShaderCache.java index 1e1c8641..67b2d2e2 100644 --- a/src/java/com/threerings/jme/util/ShaderCache.java +++ b/src/java/com/threerings/jme/util/ShaderCache.java @@ -26,7 +26,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.ByteBuffer; import java.nio.IntBuffer; +import java.nio.charset.Charset; import java.util.Collections; import java.util.HashMap; @@ -152,10 +154,22 @@ public class ShaderCache (frag == null) ? null : getSource(frag, defs)); // check its link status - IntBuffer linked = BufferUtils.createIntBuffer(1); + IntBuffer ibuf = BufferUtils.createIntBuffer(1); ARBShaderObjects.glGetObjectParameterARB(sstate.getProgramID(), - ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB, linked); - return (linked.get() == 0) ? null : sstate; + ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB, ibuf); + if (ibuf.get(0) == 0) { + return null; // failed to link + } + + // check the info log + ARBShaderObjects.glGetObjectParameterARB(sstate.getProgramID(), + ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB, ibuf); + ByteBuffer bbuf = BufferUtils.createByteBuffer(ibuf.get(0)); + ARBShaderObjects.glGetInfoLogARB(sstate.getProgramID(), ibuf, bbuf); + String log = Charset.forName("US-ASCII").decode(bbuf).toString(); + + // if it runs in software mode, that counts as a failure + return (log.indexOf("software") == -1) ? sstate : null; } /**