mesa/gles3: add support for GL_EXT_shader_group_vote
[mesa.git] / src / mesa / main / pixel.c
index 218e9fdd6bc0e1ce13e3e8292b06f0d95c42eee1..a5cb6d85ef57bf412c2ce0b3e8bac8b8feac348c 100644 (file)
@@ -28,6 +28,7 @@
  * Pixel transfer functions (glPixelZoom, glPixelMap, glPixelTransfer)
  */
 
+#include "c99_math.h"
 #include "glheader.h"
 #include "bufferobj.h"
 #include "context.h"
@@ -35,7 +36,6 @@
 #include "pixel.h"
 #include "pbo.h"
 #include "mtypes.h"
-#include "main/dispatch.h"
 
 
 /**********************************************************************/
@@ -114,7 +114,7 @@ store_pixelmap(struct gl_context *ctx, GLenum map, GLsizei mapsize,
       /* special case */
       ctx->PixelMaps.StoS.Size = mapsize;
       for (i = 0; i < mapsize; i++) {
-         ctx->PixelMaps.StoS.Map[i] = (GLfloat)IROUND(values[i]);
+         ctx->PixelMaps.StoS.Map[i] = roundf(values[i]);
       }
       break;
    case GL_PIXEL_MAP_I_TO_I:
@@ -156,11 +156,10 @@ validate_pbo_access(struct gl_context *ctx,
 
    /* restore */
    _mesa_reference_buffer_object(ctx,
-                                 &ctx->DefaultPacking.BufferObj,
-                                 ctx->Shared->NullBufferObj);
+                                 &ctx->DefaultPacking.BufferObj, NULL);
 
    if (!ok) {
-      if (_mesa_is_bufferobj(pack->BufferObj)) {
+      if (pack->BufferObj) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "gl[Get]PixelMap*v(out of bounds PBO access)");
       } else {
@@ -186,7 +185,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
 
    if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
       /* test that mapsize is a power of two */
-      if (!_mesa_is_pow_two(mapsize)) {
+      if (!util_is_power_of_two_or_zero(mapsize)) {
         _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" );
          return;
       }
@@ -201,7 +200,7 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
 
    values = (const GLfloat *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values);
    if (!values) {
-      if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) {
+      if (ctx->Unpack.BufferObj) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glPixelMapfv(PBO is mapped)");
       }
@@ -227,7 +226,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
 
    if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
       /* test that mapsize is a power of two */
-      if (!_mesa_is_pow_two(mapsize)) {
+      if (!util_is_power_of_two_or_zero(mapsize)) {
         _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
          return;
       }
@@ -242,7 +241,7 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
 
    values = (const GLuint *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values);
    if (!values) {
-      if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) {
+      if (ctx->Unpack.BufferObj) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glPixelMapuiv(PBO is mapped)");
       }
@@ -282,8 +281,8 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
 
    if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
       /* test that mapsize is a power of two */
-      if (!_mesa_is_pow_two(mapsize)) {
-        _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
+      if (!util_is_power_of_two_or_zero(mapsize)) {
+        _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapusv(mapsize)" );
          return;
       }
    }
@@ -297,7 +296,7 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
 
    values = (const GLushort *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values);
    if (!values) {
-      if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) {
+      if (ctx->Unpack.BufferObj) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glPixelMapusv(PBO is mapped)");
       }
@@ -346,7 +345,7 @@ _mesa_GetnPixelMapfvARB( GLenum map, GLsizei bufSize, GLfloat *values )
 
    values = (GLfloat *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
    if (!values) {
-      if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+      if (ctx->Pack.BufferObj) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glGetPixelMapfv(PBO is mapped)");
       }
@@ -395,7 +394,7 @@ _mesa_GetnPixelMapuivARB( GLenum map, GLsizei bufSize, GLuint *values )
 
    values = (GLuint *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
    if (!values) {
-      if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+      if (ctx->Pack.BufferObj) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glGetPixelMapuiv(PBO is mapped)");
       }
@@ -444,7 +443,7 @@ _mesa_GetnPixelMapusvARB( GLenum map, GLsizei bufSize, GLushort *values )
 
    values = (GLushort *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
    if (!values) {
-      if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+      if (ctx->Pack.BufferObj) {
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glGetPixelMapusv(PBO is mapped)");
       }
@@ -598,12 +597,13 @@ _mesa_PixelTransferi( GLenum pname, GLint param )
 /*****                    State Management                        *****/
 /**********************************************************************/
 
-/*
- * Return a bitmask of IMAGE_*_BIT flags which to indicate which
- * pixel transfer operations are enabled.
+
+/**
+ * Update mesa pixel transfer derived state to indicate which operations are
+ * enabled.
  */
-static void
-update_image_transfer_state(struct gl_context *ctx)
+void
+_mesa_update_pixel( struct gl_context *ctx )
 {
    GLuint mask = 0;
 
@@ -623,15 +623,6 @@ update_image_transfer_state(struct gl_context *ctx)
 }
 
 
-/**
- * Update mesa pixel transfer derived state.
- */
-void _mesa_update_pixel( struct gl_context *ctx )
-{
-   update_image_transfer_state(ctx);
-}
-
-
 /**********************************************************************/
 /*****                      Initialization                        *****/
 /**********************************************************************/