Reverted @CachedReference tracking removal.

This commit is contained in:
Ioannis Tsakpinis 2010-11-29 18:25:28 +00:00
parent 4f332612f4
commit 1b6a2e866c
22 changed files with 51 additions and 48 deletions

View File

@ -31,15 +31,20 @@
*/
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;
final Buffer[] glVertexAttribPointer_buffer;
final Buffer[] glTexCoordPointer_buffer;
int glClientActiveTexture;
int vertexArrayObject;
@ -49,31 +54,29 @@ class BaseReferences {
int indirectBuffer;
BaseReferences(ContextCapabilities caps) {
/*
int max_vertex_attribs;
if (caps.OpenGL20 || caps.GL_ARB_vertex_shader)
if ( caps.OpenGL20 || caps.GL_ARB_vertex_shader )
max_vertex_attribs = glGetInteger(GL_MAX_VERTEX_ATTRIBS);
else
max_vertex_attribs = 0;
glVertexAttribPointer_buffer = new Buffer[max_vertex_attribs];
glVertexAttribPointer_buffer = new Buffer[max_vertex_attribs];
int max_texture_units;
if (caps.OpenGL20)
if ( caps.OpenGL20 )
max_texture_units = glGetInteger(GL_MAX_TEXTURE_IMAGE_UNITS);
else if (caps.OpenGL13 || caps.GL_ARB_multitexture)
else if ( caps.OpenGL13 || caps.GL_ARB_multitexture )
max_texture_units = glGetInteger(GL_MAX_TEXTURE_UNITS);
else
max_texture_units = 1;
glTexCoordPointer_buffer = new Buffer[max_texture_units];
*/
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);
this.glClientActiveTexture = 0;
Arrays.fill(glVertexAttribPointer_buffer, null);
Arrays.fill(glTexCoordPointer_buffer, null);
this.vertexArrayObject = 0;
@ -87,9 +90,9 @@ class BaseReferences {
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.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.vertexArrayObject = references.vertexArrayObject;

View File

@ -34,10 +34,10 @@ package org.lwjgl.opengl;
import static org.lwjgl.opengl.GL11.*;
class ReferencesStack {
private BaseReferences[] references_stack;
private References[] references_stack;
private int stack_pos;
public BaseReferences getReferences() {
public References 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 BaseReferences popState(int mask) {
BaseReferences result = references_stack[stack_pos--];
public References popState(int mask) {
References result = references_stack[stack_pos--];
references_stack[stack_pos].copy(result, ~mask);
result.clear();
@ -59,17 +59,17 @@ class ReferencesStack {
}
private void growStack() {
BaseReferences[] new_references_stack = new BaseReferences[references_stack.length + 1];
References[] new_references_stack = new References[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 BaseReferences(GLContext.getCapabilities());
references_stack[references_stack.length - 1] = new References(GLContext.getCapabilities());
}
ReferencesStack() {
ContextCapabilities caps = GLContext.getCapabilities();
references_stack = new BaseReferences[1];
references_stack = new References[1];
stack_pos = 0;
for (int i = 0; i < references_stack.length; i++)
references_stack[i] = new BaseReferences(caps);
references_stack[i] = new References(caps);
}
}

View File

@ -81,7 +81,7 @@ final class StateTracker {
references_stack.pushState();
}
static BaseReferences getReferences(ContextCapabilities caps) {
static References getReferences(ContextCapabilities caps) {
return caps.tracker.references_stack.getReferences();
}

View File

@ -596,7 +596,7 @@ public class JavaMethodsGenerator {
cachedReference != null &&
(mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
param.getAnnotation(Result.class) == null) {
writer.print("\t\tif ( LWJGLUtil.CHECKS ) " + Utils.CHECKS_CLASS_NAME + ".getReferences(caps).");
writer.print("\t\tif ( LWJGLUtil.CHECKS ) " + "StateTracker.getReferences(caps).");
if(cachedReference.name().length() > 0) {
writer.print(cachedReference.name());
} else {

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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 = "StateTracker.getReferences(caps).glClientActiveTexture", name = "glTexCoordPointer_buffer")
@BufferObject(BufferKind.ArrayVBO)
@Check
@Const

View File

@ -150,7 +150,7 @@ public interface GL13 {
void glActiveTexture(@GLenum int texture);
//@Code("\t\tGLChecks.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;")
@Code("\t\tStateTracker.getReferences(caps).glClientActiveTexture = texture - GL_TEXTURE0;")
@DeprecatedGL
void glClientActiveTexture(@GLenum int texture);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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