Preloading Sinbad (Unknown Usage error) w/ Testcase and w/ Possible patch

When preloading sinbad, it fails when it tries to preload a vertexbuffer of Usage.CpuOnly here:



[java]

private int convertUsage(Usage usage) {

switch (usage) {

case Static:

return GL_STATIC_DRAW;

case Dynamic:

return GL_DYNAMIC_DRAW;

case Stream:

return GL_STREAM_DRAW;

default:

throw new UnsupportedOperationException("Unknown usage type.");

}

}

[/java]


java.lang.UnsupportedOperationException: Unknown usage type.


Here is the testcase:

[java]package com.mmm.util.test;

import com.jme3.app.SimpleApplication;
import com.jme3.scene.Spatial;

public class TestPreloadSinbad extends SimpleApplication {

public static void main(String[] args) {
new TestPreloadSinbad().start();
}

@Override
public void simpleInitApp() {
Spatial model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
renderManager.preloadScene(model);
}
} [/java]

and possible patch in LwjglRenderer.java:
[java]
# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and n newlines.
--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -2011,6 +2011,10 @@
}

public void updateBufferData(VertexBuffer vb) {
+ if (vb.getUsage() == Usage.CpuOnly) {
+ return;
+ }
+
int bufId = vb.getId();
boolean created = false;
if (bufId == -1) {
[/java]

What buffer is CPU only?

That’s strange because if it’s CPU only it shouldn’t be sent to the GPU.

only CPU only buffer i can think of are vertex weight buffers and bone indice buffer for skeletal animations.

If it’s another buffer then the issue is elsewhere.

Could you try to debug and see what buffer causes this issue?

1 Like

Its the BindPosePosition that fails



but theres also BindPoseNormal, BoneWeight and BoneIndex which are CpuOnly inside the buffer list it iterates over (mesh.getBufferList()). There are 8 buffers in total there, with the others being the standard: index, texcoord, position and normal.



[java] Mesh mesh = gm.getMesh();

if (mesh != null) {

for (VertexBuffer vb : mesh.getBufferList().getArray()) {

if (vb.getData() != null) {

renderer.updateBufferData(vb);

}

}

}[/java]

@nehon: The issue seems to be that preloadScene() calls updateBufferData() directly whereas normally the renderer ignores CpuOnly buffers.

1 Like

yep, could explain why it fails on android too …

1 Like

Should be fixed now.

2 Likes