summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/teximage.c
diff options
context:
space:
mode:
authorLaura Ekstrand <[email protected]>2014-12-02 17:51:30 -0800
committerLaura Ekstrand <[email protected]>2015-01-08 11:37:30 -0800
commit98e64e538afeaa800e1cdcbc7ce5d5093b274fe7 (patch)
tree3f9e6e85c4f30ae34a8e34542be34788cc1a2df7 /src/mesa/main/teximage.c
parent499004e56a51bdabff489913680aa972e7fab369 (diff)
main: Added entry point for glTextureBuffer.
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r--src/mesa/main/teximage.c90
1 files changed, 74 insertions, 16 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index a283bbe5e85..2f2f072c8e1 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -4919,30 +4919,26 @@ _mesa_validate_texbuffer_format(const struct gl_context *ctx,
}
-static void
-texbufferrange(struct gl_context *ctx, GLenum target, GLenum internalFormat,
- struct gl_buffer_object *bufObj,
- GLintptr offset, GLsizeiptr size)
+void
+_mesa_texture_buffer_range(struct gl_context *ctx,
+ struct gl_texture_object *texObj, GLenum target,
+ GLenum internalFormat,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size, bool range,
+ bool dsa)
{
- struct gl_texture_object *texObj;
mesa_format format;
FLUSH_VERTICES(ctx, 0);
- if (target != GL_TEXTURE_BUFFER_ARB) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(target)");
- return;
- }
-
format = _mesa_validate_texbuffer_format(ctx, internalFormat);
if (format == MESA_FORMAT_NONE) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(internalFormat 0x%x)",
- internalFormat);
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTex%sBuffer%s(internalFormat 0x%x)", dsa ? "ture" : "",
+ range ? "Range" : "", internalFormat);
return;
}
- texObj = _mesa_get_current_tex_object(ctx, target);
-
_mesa_lock_texture(ctx, texObj);
{
_mesa_reference_buffer_object(ctx, &texObj->BufferObject, bufObj);
@@ -4965,10 +4961,17 @@ texbufferrange(struct gl_context *ctx, GLenum target, GLenum internalFormat,
void GLAPIENTRY
_mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
{
+ struct gl_texture_object *texObj;
struct gl_buffer_object *bufObj;
GET_CURRENT_CONTEXT(ctx);
+ /* Need to catch this before it gets to _mesa_get_current_tex_object */
+ if (target != GL_TEXTURE_BUFFER_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexBuffer(target)");
+ return;
+ }
+
/* NOTE: ARB_texture_buffer_object has interactions with
* the compatibility profile that are not implemented.
*/
@@ -4984,7 +4987,12 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
return;
}
- texbufferrange(ctx, target, internalFormat, bufObj, 0, buffer ? -1 : 0);
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ if (!texObj)
+ return;
+
+ _mesa_texture_buffer_range(ctx, texObj, target, internalFormat, bufObj, 0,
+ buffer ? -1 : 0, false, false);
}
@@ -4993,10 +5001,17 @@ void GLAPIENTRY
_mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
GLintptr offset, GLsizeiptr size)
{
+ struct gl_texture_object *texObj;
struct gl_buffer_object *bufObj;
GET_CURRENT_CONTEXT(ctx);
+ /* Need to catch this before it gets to _mesa_get_current_tex_object */
+ if (target != GL_TEXTURE_BUFFER_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexBufferRange(target)");
+ return;
+ }
+
if (!(ctx->API == API_OPENGL_CORE &&
ctx->Extensions.ARB_texture_buffer_range)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glTexBufferRange");
@@ -5025,9 +5040,52 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
size = 0;
}
- texbufferrange(ctx, target, internalFormat, bufObj, offset, size);
+ texObj = _mesa_get_current_tex_object(ctx, target);
+ if (!texObj)
+ return;
+
+ _mesa_texture_buffer_range(ctx, texObj, target, internalFormat, bufObj,
+ offset, size, true, false);
}
+void GLAPIENTRY
+_mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer)
+{
+ struct gl_texture_object *texObj;
+ 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, "glTextureBuffer");
+ return;
+ }
+
+ bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+ if (!bufObj && buffer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glTextureBuffer(buffer %u)",
+ buffer);
+ return;
+ }
+
+ /* Get the texture object by Name. */
+ texObj = _mesa_lookup_texture_err(ctx, texture,
+ "glTextureBuffer(texture)");
+ if (!texObj)
+ return;
+
+ if (texObj->Target != GL_TEXTURE_BUFFER_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTextureBuffer(target)");
+ return;
+ }
+
+ _mesa_texture_buffer_range(ctx, texObj, texObj->Target, internalFormat,
+ bufObj, 0, buffer ? -1 : 0, false, true);
+}
static GLboolean
is_renderable_texture_format(struct gl_context *ctx, GLenum internalformat)