Fixed ELEMENT_ARRAY_BUFFER_BINDING tracking when VAOs are used.
Removed CachedReference tracking, we never check those.
This commit is contained in:
parent
75b5331c28
commit
4f332612f4
|
@ -31,20 +31,17 @@
|
|||
*/
|
||||
package org.lwjgl.opengl;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL13.*;
|
||||
import static org.lwjgl.opengl.GL20.*;
|
||||
|
||||
class BaseReferences {
|
||||
|
||||
int elementArrayBuffer;
|
||||
int arrayBuffer;
|
||||
final Buffer[] glVertexAttribPointer_buffer;
|
||||
final Buffer[] glTexCoordPointer_buffer;
|
||||
int glClientActiveTexture;
|
||||
int elementArrayBuffer;
|
||||
int arrayBuffer;
|
||||
//final Buffer[] glVertexAttribPointer_buffer;
|
||||
//final Buffer[] glTexCoordPointer_buffer;
|
||||
//int glClientActiveTexture;
|
||||
|
||||
int vertexArrayObject;
|
||||
|
||||
int pixelPackBuffer;
|
||||
int pixelUnpackBuffer;
|
||||
|
@ -52,6 +49,7 @@ class BaseReferences {
|
|||
int indirectBuffer;
|
||||
|
||||
BaseReferences(ContextCapabilities caps) {
|
||||
/*
|
||||
int max_vertex_attribs;
|
||||
if (caps.OpenGL20 || caps.GL_ARB_vertex_shader)
|
||||
max_vertex_attribs = glGetInteger(GL_MAX_VERTEX_ATTRIBS);
|
||||
|
@ -67,35 +65,40 @@ class BaseReferences {
|
|||
else
|
||||
max_texture_units = 1;
|
||||
glTexCoordPointer_buffer = new Buffer[max_texture_units];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void clear() {
|
||||
this.elementArrayBuffer = 0;
|
||||
this.arrayBuffer = 0;
|
||||
this.glClientActiveTexture = 0;
|
||||
Arrays.fill(glVertexAttribPointer_buffer, null);
|
||||
Arrays.fill(glTexCoordPointer_buffer, null);
|
||||
void clear() {
|
||||
this.elementArrayBuffer = 0;
|
||||
this.arrayBuffer = 0;
|
||||
//this.glClientActiveTexture = 0;
|
||||
//Arrays.fill(glVertexAttribPointer_buffer, null);
|
||||
//Arrays.fill(glTexCoordPointer_buffer, null);
|
||||
|
||||
this.pixelPackBuffer = 0;
|
||||
this.pixelUnpackBuffer = 0;
|
||||
this.vertexArrayObject = 0;
|
||||
|
||||
this.indirectBuffer = 0;
|
||||
}
|
||||
this.pixelPackBuffer = 0;
|
||||
this.pixelUnpackBuffer = 0;
|
||||
|
||||
void copy(BaseReferences references, int mask) {
|
||||
if ( (mask & GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {
|
||||
this.elementArrayBuffer = references.elementArrayBuffer;
|
||||
this.arrayBuffer = references.arrayBuffer;
|
||||
this.glClientActiveTexture = references.glClientActiveTexture;
|
||||
System.arraycopy(references.glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer.length);
|
||||
System.arraycopy(references.glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer.length);
|
||||
this.indirectBuffer = 0;
|
||||
}
|
||||
|
||||
this.indirectBuffer = references.indirectBuffer;
|
||||
}
|
||||
void copy(BaseReferences references, int mask) {
|
||||
if ( (mask & GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {
|
||||
this.elementArrayBuffer = references.elementArrayBuffer;
|
||||
this.arrayBuffer = references.arrayBuffer;
|
||||
//this.glClientActiveTexture = references.glClientActiveTexture;
|
||||
//System.arraycopy(references.glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer, 0, glVertexAttribPointer_buffer.length);
|
||||
//System.arraycopy(references.glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer, 0, glTexCoordPointer_buffer.length);
|
||||
|
||||
if ( (mask & GL_CLIENT_PIXEL_STORE_BIT) != 0 ) {
|
||||
this.vertexArrayObject = references.vertexArrayObject;
|
||||
|
||||
this.indirectBuffer = references.indirectBuffer;
|
||||
}
|
||||
|
||||
if ( (mask & GL_CLIENT_PIXEL_STORE_BIT) != 0 ) {
|
||||
this.pixelPackBuffer = references.pixelPackBuffer;
|
||||
this.pixelUnpackBuffer = references.pixelUnpackBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
* Copyright 2002-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
|
||||
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.lwjgl.opengl;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* A hash map using primitive ints as keys rather than objects.
|
||||
*
|
||||
* @author Justin Couch
|
||||
* @author Alex Chaffee (alex@apache.org)
|
||||
* @author Stephen Colebourne
|
||||
* @author Nathan Sweet
|
||||
*/
|
||||
final class FastIntMap<V> implements Iterable<FastIntMap.Entry<V>> {
|
||||
|
||||
private Entry[] table;
|
||||
private int size, mask, capacity, threshold;
|
||||
|
||||
/** Same as: FastIntMap(16, 0.75f); */
|
||||
FastIntMap() {
|
||||
this(16, 0.75f);
|
||||
}
|
||||
|
||||
/** Same as: FastIntMap(initialCapacity, 0.75f); */
|
||||
FastIntMap(int initialCapacity) {
|
||||
this(initialCapacity, 0.75f);
|
||||
}
|
||||
|
||||
FastIntMap(int initialCapacity, float loadFactor) {
|
||||
if ( initialCapacity > 1 << 30 ) throw new IllegalArgumentException("initialCapacity is too large.");
|
||||
if ( initialCapacity < 0 ) throw new IllegalArgumentException("initialCapacity must be greater than zero.");
|
||||
if ( loadFactor <= 0 ) throw new IllegalArgumentException("initialCapacity must be greater than zero.");
|
||||
capacity = 1;
|
||||
while ( capacity < initialCapacity )
|
||||
capacity <<= 1;
|
||||
this.threshold = (int)(capacity * loadFactor);
|
||||
this.table = new Entry[capacity];
|
||||
this.mask = capacity - 1;
|
||||
}
|
||||
|
||||
private int index(final int key) {
|
||||
return index(key, mask);
|
||||
}
|
||||
|
||||
private static int index(final int key, final int mask) {
|
||||
return key & mask;
|
||||
}
|
||||
|
||||
public V put(int key, V value) {
|
||||
final Entry<V>[] table = this.table;
|
||||
int index = index(key);
|
||||
|
||||
// Check if key already exists.
|
||||
for ( Entry<V> e = table[index]; e != null; e = e.next ) {
|
||||
if ( e.key != key ) continue;
|
||||
V oldValue = e.value;
|
||||
e.value = value;
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
table[index] = new Entry<V>(key, value, table[index]);
|
||||
|
||||
if ( size++ >= threshold )
|
||||
rehash(table);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void rehash(final Entry<V>[] table) {
|
||||
final int newCapacity = 2 * capacity;
|
||||
final int newMask = newCapacity - 1;
|
||||
|
||||
final Entry<V>[] newTable = new Entry[newCapacity];
|
||||
|
||||
for ( int i = 0, index; i < table.length; i++ ) {
|
||||
Entry<V> e = table[i];
|
||||
if ( e == null ) continue;
|
||||
do {
|
||||
final Entry<V> next = e.next;
|
||||
index = index(e.key, newMask);
|
||||
e.next = newTable[index];
|
||||
newTable[index] = e;
|
||||
e = next;
|
||||
} while ( e != null );
|
||||
}
|
||||
|
||||
this.table = newTable;
|
||||
capacity = newCapacity;
|
||||
mask = newMask;
|
||||
threshold *= 2;
|
||||
}
|
||||
|
||||
public V get(int key) {
|
||||
final int index = index(key);
|
||||
for ( Entry<V> e = table[index]; e != null; e = e.next )
|
||||
if ( e.key == key ) return e.value;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean containsValue(Object value) {
|
||||
final Entry<V>[] table = this.table;
|
||||
for ( int i = table.length - 1; i >= 0; i-- )
|
||||
for ( Entry<V> e = table[i]; e != null; e = e.next )
|
||||
if ( e.value.equals(value) ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsKey(int key) {
|
||||
final int index = index(key);
|
||||
for ( Entry<V> e = table[index]; e != null; e = e.next )
|
||||
if ( e.key == key ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public V remove(int key) {
|
||||
final int index = index(key);
|
||||
|
||||
Entry<V> prev = table[index];
|
||||
Entry<V> e = prev;
|
||||
while ( e != null ) {
|
||||
Entry<V> next = e.next;
|
||||
if ( e.key == key ) {
|
||||
size--;
|
||||
if ( prev == e )
|
||||
table[index] = next;
|
||||
else
|
||||
prev.next = next;
|
||||
return e.value;
|
||||
}
|
||||
prev = e;
|
||||
e = next;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return size == 0;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
final Entry<V>[] table = this.table;
|
||||
for ( int index = table.length - 1; index >= 0; index-- )
|
||||
table[index] = null;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
public EntryIterator iterator() {
|
||||
return new EntryIterator();
|
||||
}
|
||||
|
||||
public class EntryIterator implements Iterator<Entry<V>> {
|
||||
|
||||
private int nextIndex;
|
||||
private Entry<V> current;
|
||||
|
||||
EntryIterator() {
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
current = null;
|
||||
// Find first bucket.
|
||||
final Entry<V>[] table = FastIntMap.this.table;
|
||||
int i;
|
||||
for ( i = table.length - 1; i >= 0; i-- )
|
||||
if ( table[i] != null ) break;
|
||||
nextIndex = i;
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
if ( nextIndex >= 0 ) return true;
|
||||
Entry e = current;
|
||||
return e != null && e.next != null;
|
||||
}
|
||||
|
||||
public Entry<V> next() {
|
||||
// Next entry in current bucket.
|
||||
Entry<V> e = current;
|
||||
if ( e != null ) {
|
||||
e = e.next;
|
||||
if ( e != null ) {
|
||||
current = e;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
// Use the bucket at nextIndex and find the next nextIndex.
|
||||
final Entry<V>[] table = FastIntMap.this.table;
|
||||
int i = nextIndex;
|
||||
e = current = table[i];
|
||||
while ( --i >= 0 )
|
||||
if ( table[i] != null ) break;
|
||||
nextIndex = i;
|
||||
return e;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
FastIntMap.this.remove(current.key);
|
||||
}
|
||||
}
|
||||
|
||||
static final class Entry<T> {
|
||||
|
||||
final int key;
|
||||
T value;
|
||||
Entry<T> next;
|
||||
|
||||
Entry(int key, T value, Entry<T> next) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
public int getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -63,10 +63,6 @@ class GLChecks {
|
|||
private GLChecks() {
|
||||
}
|
||||
|
||||
static References getReferences(ContextCapabilities caps) {
|
||||
return StateTracker.getReferencesStack(caps).getReferences();
|
||||
}
|
||||
|
||||
static int getBufferObjectSize(ContextCapabilities caps, int buffer_enum) {
|
||||
return glGetBufferParameter(buffer_enum, GL_BUFFER_SIZE);
|
||||
}
|
||||
|
@ -85,61 +81,61 @@ class GLChecks {
|
|||
|
||||
/** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureArrayVBOdisabled(ContextCapabilities caps) {
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().arrayBuffer != 0 )
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 )
|
||||
throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensureArrayVBOenabled(ContextCapabilities caps) {
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().arrayBuffer == 0 )
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer == 0 )
|
||||
throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureElementVBOdisabled(ContextCapabilities caps) {
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer != 0 )
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) != 0 )
|
||||
throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensureElementVBOenabled(ContextCapabilities caps) {
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().elementArrayBuffer == 0 )
|
||||
if( LWJGLUtil.CHECKS && StateTracker.getElementArrayBufferBound(caps) == 0 )
|
||||
throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureIndirectBOdisabled(ContextCapabilities caps) {
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().indirectBuffer != 0 )
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).indirectBuffer != 0 )
|
||||
throw new OpenGLException("Cannot use Buffers when Draw Indirect Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensureIndirectBOenabled(ContextCapabilities caps) {
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().indirectBuffer == 0 )
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).indirectBuffer == 0 )
|
||||
throw new OpenGLException("Cannot use offsets when Draw Indirect Object is disabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that pixel pack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensurePackPBOdisabled(ContextCapabilities caps) {
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer != 0 )
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).pixelPackBuffer != 0 )
|
||||
throw new OpenGLException("Cannot use Buffers when Pixel Pack Buffer Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that pixel pack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensurePackPBOenabled(ContextCapabilities caps) {
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelPackBuffer == 0 )
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).pixelPackBuffer == 0 )
|
||||
throw new OpenGLException("Cannot use offsets when Pixel Pack Buffer Object is disabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that pixel unpack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureUnpackPBOdisabled(ContextCapabilities caps) {
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer != 0 )
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).pixelUnpackBuffer != 0 )
|
||||
throw new OpenGLException("Cannot use Buffers when Pixel Unpack Buffer Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that pixel unpack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensureUnpackPBOenabled(ContextCapabilities caps) {
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferencesStack(caps).getReferences().pixelUnpackBuffer == 0 )
|
||||
if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).pixelUnpackBuffer == 0 )
|
||||
throw new OpenGLException("Cannot use offsets when Pixel Unpack Buffer Object is disabled");
|
||||
}
|
||||
|
||||
|
|
|
@ -34,10 +34,10 @@ package org.lwjgl.opengl;
|
|||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
class ReferencesStack {
|
||||
private References[] references_stack;
|
||||
private BaseReferences[] references_stack;
|
||||
private int stack_pos;
|
||||
|
||||
public References getReferences() {
|
||||
public BaseReferences getReferences() {
|
||||
return references_stack[stack_pos];
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ class ReferencesStack {
|
|||
references_stack[pos].copy(references_stack[pos - 1], GL_ALL_CLIENT_ATTRIB_BITS);
|
||||
}
|
||||
|
||||
public References popState(int mask) {
|
||||
References result = references_stack[stack_pos--];
|
||||
public BaseReferences popState(int mask) {
|
||||
BaseReferences result = references_stack[stack_pos--];
|
||||
|
||||
references_stack[stack_pos].copy(result, ~mask);
|
||||
result.clear();
|
||||
|
@ -59,17 +59,17 @@ class ReferencesStack {
|
|||
}
|
||||
|
||||
private void growStack() {
|
||||
References[] new_references_stack = new References[references_stack.length + 1];
|
||||
BaseReferences[] new_references_stack = new BaseReferences[references_stack.length + 1];
|
||||
System.arraycopy(references_stack, 0, new_references_stack, 0, references_stack.length);
|
||||
references_stack = new_references_stack;
|
||||
references_stack[references_stack.length - 1] = new References(GLContext.getCapabilities());
|
||||
references_stack[references_stack.length - 1] = new BaseReferences(GLContext.getCapabilities());
|
||||
}
|
||||
|
||||
ReferencesStack() {
|
||||
ContextCapabilities caps = GLContext.getCapabilities();
|
||||
references_stack = new References[1];
|
||||
references_stack = new BaseReferences[1];
|
||||
stack_pos = 0;
|
||||
for (int i = 0; i < references_stack.length; i++)
|
||||
references_stack[i] = new References(caps);
|
||||
references_stack[i] = new BaseReferences(caps);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,16 +31,22 @@
|
|||
*/
|
||||
package org.lwjgl.opengl;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import static org.lwjgl.opengl.GL15.*;
|
||||
import static org.lwjgl.opengl.GL21.*;
|
||||
import static org.lwjgl.opengl.GL40.*;
|
||||
|
||||
final class StateTracker {
|
||||
|
||||
private ReferencesStack references_stack;
|
||||
private final StateStack attrib_stack;
|
||||
|
||||
private boolean insideBeginEnd;
|
||||
|
||||
// VAOs are not shareable between contexts, no need to sync or make this static.
|
||||
private final FastIntMap<VAOState> vaoMap = new FastIntMap<VAOState>();
|
||||
|
||||
StateTracker() {
|
||||
attrib_stack = new StateStack(0);
|
||||
}
|
||||
|
@ -75,29 +81,82 @@ final class StateTracker {
|
|||
references_stack.pushState();
|
||||
}
|
||||
|
||||
static ReferencesStack getReferencesStack(ContextCapabilities caps) {
|
||||
return caps.tracker.references_stack;
|
||||
static BaseReferences getReferences(ContextCapabilities caps) {
|
||||
return caps.tracker.references_stack.getReferences();
|
||||
}
|
||||
|
||||
static void bindBuffer(ContextCapabilities caps, int target, int buffer) {
|
||||
ReferencesStack references_stack = getReferencesStack(caps);
|
||||
switch(target) {
|
||||
case GL_ELEMENT_ARRAY_BUFFER:
|
||||
references_stack.getReferences().elementArrayBuffer = buffer;
|
||||
break;
|
||||
case GL_ARRAY_BUFFER:
|
||||
references_stack.getReferences().arrayBuffer = buffer;
|
||||
break;
|
||||
case GL_PIXEL_PACK_BUFFER:
|
||||
references_stack.getReferences().pixelPackBuffer = buffer;
|
||||
break;
|
||||
case GL_PIXEL_UNPACK_BUFFER:
|
||||
references_stack.getReferences().pixelUnpackBuffer = buffer;
|
||||
break;
|
||||
case GL_DRAW_INDIRECT_BUFFER:
|
||||
references_stack.getReferences().indirectBuffer = buffer;
|
||||
break;
|
||||
static void bindBuffer(ContextCapabilities caps, int target, int buffer) {
|
||||
final BaseReferences references = getReferences(caps);
|
||||
switch ( target ) {
|
||||
case GL_ARRAY_BUFFER:
|
||||
references.arrayBuffer = buffer;
|
||||
break;
|
||||
case GL_ELEMENT_ARRAY_BUFFER:
|
||||
// When a vertex array object is currently bound, update
|
||||
// the VAO state instead of client state.
|
||||
if ( references.vertexArrayObject != 0 )
|
||||
caps.tracker.vaoMap.get(references.vertexArrayObject).elementArrayBuffer = buffer;
|
||||
else
|
||||
references.elementArrayBuffer = buffer;
|
||||
break;
|
||||
case GL_PIXEL_PACK_BUFFER:
|
||||
references.pixelPackBuffer = buffer;
|
||||
break;
|
||||
case GL_PIXEL_UNPACK_BUFFER:
|
||||
references.pixelUnpackBuffer = buffer;
|
||||
break;
|
||||
case GL_DRAW_INDIRECT_BUFFER:
|
||||
references.indirectBuffer = buffer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
static void bindVAO(final ContextCapabilities caps, final int array) {
|
||||
final FastIntMap<VAOState> vaoMap = caps.tracker.vaoMap;
|
||||
if ( !vaoMap.containsKey(array) )
|
||||
vaoMap.put(array, new VAOState());
|
||||
|
||||
getReferences(caps).vertexArrayObject = array;
|
||||
}
|
||||
|
||||
static void deleteVAO(final ContextCapabilities caps, final IntBuffer arrays) {
|
||||
for ( int i = arrays.position(); i < arrays.limit(); i++ )
|
||||
deleteVAO(caps, arrays.get(i));
|
||||
}
|
||||
|
||||
static void deleteVAO(final ContextCapabilities caps, final int array) {
|
||||
caps.tracker.vaoMap.remove(array);
|
||||
|
||||
final BaseReferences references = getReferences(caps);
|
||||
if ( references.vertexArrayObject == array )
|
||||
references.vertexArrayObject = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently bound ELEMENT_ARRAY_BUFFER. If a vertex array
|
||||
* object is currently bound, then the VAO state is returned instead
|
||||
* of the client state.
|
||||
*
|
||||
* @return the currently bound ELEMENT_ARRAY_BUFFER.
|
||||
*/
|
||||
static int getElementArrayBufferBound(final ContextCapabilities caps) {
|
||||
final BaseReferences references = getReferences(caps);
|
||||
|
||||
if ( references.vertexArrayObject == 0 )
|
||||
return references.elementArrayBuffer;
|
||||
else
|
||||
return caps.tracker.vaoMap.get(references.vertexArrayObject).elementArrayBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple class to help us track VAO state. Currently
|
||||
* only ELEMENT_ARRAY_BUFFER_BINDING is tracked, since
|
||||
* that's the only state we check from tables 6.6-6.9.
|
||||
*/
|
||||
private static class VAOState {
|
||||
|
||||
int elementArrayBuffer;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -52,7 +52,7 @@ public interface ARB_matrix_palette {
|
|||
void glCurrentPaletteMatrixARB(int index);
|
||||
|
||||
void glMatrixIndexPointerARB(int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -85,7 +85,7 @@ public interface ARB_vertex_attrib_64bit {
|
|||
|
||||
@Reuse("GL41")
|
||||
void glVertexAttribLPointer(@GLuint int index, int size, @Constant("GL11.GL_DOUBLE") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
//@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check @Const @GLdouble Buffer pointer);
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ public interface ARB_vertex_blend {
|
|||
void glWeightuivARB(@AutoSize("pWeights") int size, @GLuint IntBuffer pWeights);
|
||||
|
||||
void glWeightPointerARB(int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -134,7 +134,7 @@ public interface ARB_vertex_program extends ARB_program {
|
|||
|
||||
@Reuse("ARBVertexShader")
|
||||
void glVertexAttribPointerARB(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride,
|
||||
@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
//@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -129,7 +129,7 @@ public interface ARB_vertex_shader {
|
|||
void glVertexAttrib4NubARB(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w);
|
||||
|
||||
void glVertexAttribPointerARB(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride,
|
||||
@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
//@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -54,7 +54,7 @@ public interface EXT_fog_coord {
|
|||
void glFogCoorddEXT(double coord);
|
||||
|
||||
void glFogCoordPointerEXT(@AutoType("data") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -158,7 +158,7 @@ public interface EXT_gpu_shader4 {
|
|||
void glVertexAttribI4usvEXT(@GLuint int index, @Check("4") @Const @GLushort ShortBuffer v);
|
||||
|
||||
void glVertexAttribIPointerEXT(@GLuint int index, int size, @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -55,7 +55,7 @@ public interface EXT_secondary_color {
|
|||
void glSecondaryColor3ubEXT(@GLubyte byte red, @GLubyte byte green, @GLubyte byte blue);
|
||||
|
||||
void glSecondaryColorPointerEXT(int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -75,7 +75,7 @@ public interface EXT_vertex_attrib_64bit {
|
|||
void glVertexAttribL4dvEXT(@GLuint int index, @Const @Check("4") DoubleBuffer v);
|
||||
|
||||
void glVertexAttribLPointerEXT(@GLuint int index, int size, @Constant("GL11.GL_DOUBLE") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
//@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check @Const @GLdouble Buffer pointer);
|
||||
|
||||
|
|
|
@ -225,7 +225,7 @@ public interface EXT_vertex_shader {
|
|||
void glVariantuivEXT(@GLuint int id, @Check("4") @Const @GLuint IntBuffer pAddr);
|
||||
|
||||
void glVariantPointerEXT(@GLuint int id, @AutoType("pAddr") @GLenum int type, @GLuint int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -57,7 +57,7 @@ public interface EXT_vertex_weighting {
|
|||
void glVertexWeightfEXT(float weight);
|
||||
|
||||
void glVertexWeightPointerEXT(@GLsizei int size, @AutoType("pPointer") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -800,7 +800,7 @@ public interface GL11 {
|
|||
|
||||
@DeprecatedGL
|
||||
void glColorPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@Check
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Const
|
||||
|
@ -889,7 +889,7 @@ public interface GL11 {
|
|||
|
||||
@DeprecatedGL
|
||||
void glEdgeFlagPointer(int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
@ -1295,7 +1295,7 @@ public interface GL11 {
|
|||
|
||||
@DeprecatedGL
|
||||
void glNormalPointer(@AutoType("pointer") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
@ -1431,7 +1431,7 @@ public interface GL11 {
|
|||
|
||||
@DeprecatedGL
|
||||
void glVertexPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
@ -1565,7 +1565,7 @@ public interface GL11 {
|
|||
|
||||
@DeprecatedGL
|
||||
void glTexCoordPointer(int size, @AutoType("pointer") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference(index = "GLChecks.getReferences(caps).glClientActiveTexture", name = "glTexCoordPointer_buffer")
|
||||
//@CachedReference(index = "GLChecks.getReferences(caps).glClientActiveTexture", name = "glTexCoordPointer_buffer")
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -150,7 +150,7 @@ public interface GL13 {
|
|||
|
||||
void glActiveTexture(@GLenum int texture);
|
||||
|
||||
@Code("\t\tGLChecks.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;")
|
||||
//@Code("\t\tGLChecks.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;")
|
||||
@DeprecatedGL
|
||||
void glClientActiveTexture(@GLenum int texture);
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ public interface GL14 {
|
|||
|
||||
@DeprecatedGL
|
||||
void glFogCoordPointer(@AutoType("data") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -338,7 +338,7 @@ public interface GL20 {
|
|||
void glVertexAttrib4Nub(@GLuint int index, @GLubyte byte x, @GLubyte byte y, @GLubyte byte z, @GLubyte byte w);
|
||||
|
||||
void glVertexAttribPointer(@GLuint int index, int size, @AutoType("buffer") @GLenum int type, boolean normalized, @GLsizei int stride,
|
||||
@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
//@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
|
@ -204,7 +204,7 @@ public interface GL30 {
|
|||
void glVertexAttribI4usv(@GLuint int index, @Check("4") @Const @GLushort ShortBuffer v);
|
||||
|
||||
void glVertexAttribIPointer(@GLuint int index, int size, @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference
|
||||
//@CachedReference
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
@ -1011,11 +1011,14 @@ public interface GL30 {
|
|||
*/
|
||||
int GL_VERTEX_ARRAY_BINDING = 0x85B5;
|
||||
|
||||
@Code(" StateTracker.bindVAO(caps, array);")
|
||||
void glBindVertexArray(@GLuint int array);
|
||||
|
||||
@Code(" StateTracker.deleteVAO(caps, arrays);")
|
||||
void glDeleteVertexArrays(@AutoSize("arrays") @GLsizei int n, @Const @GLuint IntBuffer arrays);
|
||||
|
||||
@Alternate("glDeleteVertexArrays")
|
||||
@Code(" StateTracker.deleteVAO(caps, array);")
|
||||
void glDeleteVertexArrays(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getBufferInt().put(0, array), 0", keepParam = true) int array);
|
||||
|
||||
void glGenVertexArrays(@AutoSize("arrays") @GLsizei int n, @OutParameter @GLuint IntBuffer arrays);
|
||||
|
|
|
@ -390,7 +390,7 @@ public interface GL41 {
|
|||
|
||||
@Optional(reason = "Not exposed in ATI Catalyst 10.10c")
|
||||
void glVertexAttribLPointer(@GLuint int index, int size, @Constant("GL11.GL_DOUBLE") @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
//@CachedReference(index = "index", name = "glVertexAttribPointer_buffer")
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check @Const @GLdouble Buffer pointer);
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ public interface NV_vertex_program extends NV_program {
|
|||
void glTrackMatrixNV(@GLenum int target, @GLuint int address, @GLenum int matrix, @GLenum int transform);
|
||||
|
||||
void glVertexAttribPointerNV(@GLuint int index, int size, @GLenum int type, @GLsizei int stride,
|
||||
@CachedReference(index="index",name="glVertexAttribPointer_buffer")
|
||||
//@CachedReference(index="index",name="glVertexAttribPointer_buffer")
|
||||
@BufferObject(BufferKind.ArrayVBO)
|
||||
@Check
|
||||
@Const
|
||||
|
|
Loading…
Reference in New Issue