Просмотр исходного кода

* VertexBuffer.invariant() - check that buffer position is zero and limit is non zero
* Remove unneeded null check when binding uniforms to uniform bindings
* Added Uniform.deleteNativeBuffers() to delete any buffers the uniform might be using (currently independent of Shader disposal)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10770 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

sha..RD 12 лет назад
Родитель
Сommit
228a8e2ebd

+ 1 - 3
engine/src/core/com/jme3/material/Technique.java

@@ -222,9 +222,7 @@ public class Technique /* implements Savable */ {
            for (UniformBinding binding : def.getWorldBindings()) {
                Uniform uniform = shader.getUniform("g_" + binding.name());
                uniform.setBinding(binding);
-               if (uniform != null) {
-                   worldBindUniforms.add(uniform);
-               }
+               worldBindUniforms.add(uniform);
            }
         }        
         needReload = false;

+ 8 - 0
engine/src/core/com/jme3/scene/VertexBuffer.java

@@ -351,6 +351,14 @@ public class VertexBuffer extends NativeObject implements Savable, Cloneable {
         if (data == null) {
             throw new AssertionError();
         }
+        // Position must be 0.
+        if (data.position() != 0) {
+            throw new AssertionError();
+        }
+        // Is the size of the VB == 0?
+        if (data.limit() == 0) {
+            throw new AssertionError();
+        }
         // Does offset exceed buffer limit or negative?
         if (offset > data.limit() || offset < 0) {
             throw new AssertionError();

+ 7 - 0
engine/src/core/com/jme3/shader/Uniform.java

@@ -33,6 +33,7 @@ package com.jme3.shader;
 
 import com.jme3.math.*;
 import com.jme3.util.BufferUtils;
+import java.nio.Buffer;
 import java.nio.FloatBuffer;
 import java.nio.IntBuffer;
 
@@ -347,4 +348,10 @@ public class Uniform extends ShaderVariable {
         updateNeeded = true;
     }
 
+    public void deleteNativeBuffers() {
+        if (value instanceof Buffer) {
+            BufferUtils.destroyDirectBuffer((Buffer)value);
+            value = null; // ????
+        }
+    }
 }