summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mapi/glapi/gen/ARB_texture_buffer_range.xml22
-rw-r--r--src/mapi/glapi/gen/Makefile.am1
-rw-r--r--src/mapi/glapi/gen/gl_API.xml4
-rw-r--r--src/mesa/main/context.c1
-rw-r--r--src/mesa/main/extensions.c1
-rw-r--r--src/mesa/main/get.c1
-rw-r--r--src/mesa/main/get_hash_params.py6
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/main/teximage.c89
-rw-r--r--src/mesa/main/teximage.h4
-rw-r--r--src/mesa/main/texparam.c12
11 files changed, 130 insertions, 17 deletions
diff --git a/src/mapi/glapi/gen/ARB_texture_buffer_range.xml b/src/mapi/glapi/gen/ARB_texture_buffer_range.xml
new file mode 100644
index 00000000000..2176c08efcb
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_texture_buffer_range.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+
+<category name="GL_ARB_texture_buffer_range" number="139">
+
+ <enum name="TEXTURE_BUFFER_OFFSET" value="0x919D"/>
+ <enum name="TEXTURE_BUFFER_SIZE" value="0x919E"/>
+ <enum name="TEXTURE_BUFFER_OFFSET_ALIGNMENT" value="0x919F"/>
+
+ <function name="TexBufferRange" offset="assign">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="buffer" type="GLuint"/>
+ <param name="offset" type="GLintptr"/>
+ <param name="size" type="GLsizeiptr"/>
+ </function>
+
+</category>
+
+</OpenGLAPI>
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index f869d28e578..4d51bbca63c 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -108,6 +108,7 @@ API_XML = \
ARB_seamless_cube_map.xml \
ARB_sync.xml \
ARB_texture_buffer_object.xml \
+ ARB_texture_buffer_range.xml \
ARB_texture_compression_rgtc.xml \
ARB_texture_float.xml \
ARB_texture_rg.xml \
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 404ccea8e2a..4cbd72462b4 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8316,6 +8316,10 @@
<xi:include href="ARB_invalidate_subdata.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+<!-- ARB extensions #133...#138 -->
+
+<xi:include href="ARB_texture_buffer_range.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
<!-- Non-ARB extensions sorted by extension number. -->
<category name="GL_EXT_blend_color" number="2">
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 531b811fecd..e5ed97f00aa 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -564,6 +564,7 @@ _mesa_init_constants(struct gl_context *ctx)
ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY;
ctx->Const.MaxTextureLodBias = MAX_TEXTURE_LOD_BIAS;
ctx->Const.MaxTextureBufferSize = 65536;
+ ctx->Const.TextureBufferOffsetAlignment = 1;
ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE;
ctx->Const.SubPixelBits = SUB_PIXEL_BITS;
ctx->Const.MinPointSize = MIN_POINT_SIZE;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 7a8195a2bde..c9638a1af33 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -131,6 +131,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), GLL, 2000 },
{ "GL_ARB_texture_buffer_object", o(ARB_texture_buffer_object), GLC, 2008 },
{ "GL_ARB_texture_buffer_object_rgb32", o(ARB_texture_buffer_object_rgb32), GLC, 2009 },
+ { "GL_ARB_texture_buffer_range", o(ARB_texture_buffer_range), GLC, 2012 },
{ "GL_ARB_texture_compression", o(dummy_true), GLL, 2000 },
{ "GL_ARB_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL, 2004 },
{ "GL_ARB_texture_cube_map", o(ARB_texture_cube_map), GLL, 1999 },
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 5f4e2fa512f..da1e01cb55c 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -353,6 +353,7 @@ EXTRA_EXT(ARB_uniform_buffer_object);
EXTRA_EXT(ARB_timer_query);
EXTRA_EXT(ARB_map_buffer_alignment);
EXTRA_EXT(ARB_texture_cube_map_array);
+EXTRA_EXT(ARB_texture_buffer_range);
static const int
extra_NV_primitive_restart[] = {
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 26a722a87a7..b6bed809cf7 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -701,6 +701,12 @@ descriptor=[
# GL_ARB_texture_cube_map_array
[ "TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB", "LOC_CUSTOM, TYPE_INT, TEXTURE_CUBE_ARRAY_INDEX, extra_ARB_texture_cube_map_array" ],
+]},
+
+# Enums restricted to OpenGL Core profile
+{ "apis": ["GL_CORE"], "params": [
+# GL_ARB_texture_buffer_range
+ [ "TEXTURE_BUFFER_OFFSET_ALIGNMENT", "CONTEXT_INT(Const.TextureBufferOffsetAlignment), extra_ARB_texture_buffer_range" ],
]}
]
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 3369623f707..b92f98e7d32 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1295,6 +1295,9 @@ struct gl_texture_object
GLenum BufferObjectFormat;
/** Equivalent Mesa format for BufferObjectFormat. */
gl_format _BufferObjectFormat;
+ /** GL_ARB_texture_buffer_range */
+ GLintptr BufferOffset;
+ GLsizeiptr BufferSize; /**< if this is -1, use BufferObject->Size instead */
/** GL_OES_EGL_image_external */
GLint RequiredTextureImageUnits;
@@ -2851,6 +2854,8 @@ struct gl_constants
GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */
GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */
+ GLuint TextureBufferOffsetAlignment; /**< GL_ARB_texture_buffer_range */
+
GLuint MaxArrayLockSize;
GLint SubPixelBits;
@@ -3075,6 +3080,7 @@ struct gl_extensions
GLboolean ARB_texture_border_clamp;
GLboolean ARB_texture_buffer_object;
GLboolean ARB_texture_buffer_object_rgb32;
+ GLboolean ARB_texture_buffer_range;
GLboolean ARB_texture_compression_rgtc;
GLboolean ARB_texture_cube_map;
GLboolean ARB_texture_cube_map_array;
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 31a559e9dc0..f03e84ad840 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3994,23 +3994,16 @@ validate_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat)
}
-/** GL_ARB_texture_buffer_object */
-void GLAPIENTRY
-_mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
+static void
+texbufferrange(struct gl_context *ctx, GLenum target, GLenum internalFormat,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size)
{
struct gl_texture_object *texObj;
- struct gl_buffer_object *bufObj;
gl_format format;
- GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
- if (!(ctx->API == API_OPENGL_CORE &&
- ctx->Extensions.ARB_texture_buffer_object)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer");
- return;
- }
-
if (target != GL_TEXTURE_BUFFER_ARB) {
_mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(target)");
return;
@@ -4023,12 +4016,6 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
return;
}
- bufObj = _mesa_lookup_bufferobj(ctx, buffer);
- if (buffer && !bufObj) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer(buffer %u)", buffer);
- return;
- }
-
texObj = _mesa_get_current_tex_object(ctx, target);
_mesa_lock_texture(ctx, texObj);
@@ -4036,6 +4023,74 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
_mesa_reference_buffer_object(ctx, &texObj->BufferObject, bufObj);
texObj->BufferObjectFormat = internalFormat;
texObj->_BufferObjectFormat = format;
+ texObj->BufferOffset = offset;
+ texObj->BufferSize = size;
}
_mesa_unlock_texture(ctx, texObj);
}
+
+/** GL_ARB_texture_buffer_object */
+void GLAPIENTRY
+_mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
+{
+ struct gl_buffer_object *bufObj;
+
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* NOTE: ARB_texture_buffer_object has interactions with
+ * the compatibility profile that are not implemented.
+ */
+ if (!(ctx->API == API_OPENGL_CORE &&
+ ctx->Extensions.ARB_texture_buffer_object)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer");
+ return;
+ }
+
+ bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+ if (!bufObj && buffer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer(buffer %u)", buffer);
+ return;
+ }
+
+ texbufferrange(ctx, target, internalFormat, bufObj, 0, buffer ? -1 : 0);
+}
+
+/** GL_ARB_texture_buffer_range */
+void GLAPIENTRY
+_mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
+ GLintptr offset, GLsizeiptr size)
+{
+ struct gl_buffer_object *bufObj;
+
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!(ctx->API == API_OPENGL_CORE &&
+ ctx->Extensions.ARB_texture_buffer_range)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBufferRange");
+ return;
+ }
+
+ bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+ if (bufObj) {
+ if (offset < 0 ||
+ size <= 0 ||
+ (offset + size) > bufObj->Size) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexBufferRange");
+ return;
+ }
+ if (offset % ctx->Const.TextureBufferOffsetAlignment) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexBufferRange(invalid offset alignment)");
+ return;
+ }
+ } else if (buffer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glTexBufferRange(buffer %u)",
+ buffer);
+ return;
+ } else {
+ offset = 0;
+ size = 0;
+ }
+
+ texbufferrange(ctx, target, internalFormat, bufObj, offset, size);
+}
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index 65e93337126..7124cac5214 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -289,6 +289,10 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
extern void GLAPIENTRY
_mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
+extern void GLAPIENTRY
+_mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
+ GLintptr offset, GLsizeiptr size);
+
/*@}*/
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 52ede13c0c3..b6afd35ba23 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -1181,6 +1181,18 @@ get_tex_level_parameter_buffer(struct gl_context *ctx,
*params = _mesa_get_format_bits(texFormat, pname);
break;
+ /* GL_ARB_texture_buffer_range */
+ case GL_TEXTURE_BUFFER_OFFSET:
+ if (!ctx->Extensions.ARB_texture_buffer_range)
+ goto invalid_pname;
+ *params = texObj->BufferOffset;
+ break;
+ case GL_TEXTURE_BUFFER_SIZE:
+ if (!ctx->Extensions.ARB_texture_buffer_range)
+ goto invalid_pname;
+ *params = (texObj->BufferSize == -1) ? bo->Size : texObj->BufferSize;
+ break;
+
/* GL_ARB_texture_compression */
case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
/* Always illegal for GL_TEXTURE_BUFFER */