mesa: Upload boolean uniforms using UniformBooleanTrue.
[mesa.git] / src / mesa / main / pixelstore.c
index 86625e411e57673e6c05168c0edad380fe26bc25..fc815337b8dfd6bcfd1e11b1a51413a13e174ba0 100644 (file)
@@ -97,6 +97,34 @@ _mesa_PixelStorei( GLenum pname, GLint param )
             goto invalid_enum_error;
          ctx->Pack.Invert = param;
          break;
+      case GL_PACK_COMPRESSED_BLOCK_WIDTH:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         if (param<0)
+            goto invalid_value_error;
+         ctx->Pack.CompressedBlockWidth = param;
+         break;
+      case GL_PACK_COMPRESSED_BLOCK_HEIGHT:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         if (param<0)
+            goto invalid_value_error;
+         ctx->Pack.CompressedBlockHeight = param;
+         break;
+      case GL_PACK_COMPRESSED_BLOCK_DEPTH:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         if (param<0)
+            goto invalid_value_error;
+         ctx->Pack.CompressedBlockDepth = param;
+         break;
+      case GL_PACK_COMPRESSED_BLOCK_SIZE:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         if (param<0)
+            goto invalid_value_error;
+         ctx->Pack.CompressedBlockSize = param;
+         break;
 
       case GL_UNPACK_SWAP_BYTES:
          if (!_mesa_is_desktop_gl(ctx))
@@ -148,6 +176,34 @@ _mesa_PixelStorei( GLenum pname, GLint param )
             goto invalid_value_error;
          ctx->Unpack.Alignment = param;
          break;
+      case GL_UNPACK_COMPRESSED_BLOCK_WIDTH:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         if (param<0)
+            goto invalid_value_error;
+         ctx->Unpack.CompressedBlockWidth = param;
+         break;
+      case GL_UNPACK_COMPRESSED_BLOCK_HEIGHT:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         if (param<0)
+            goto invalid_value_error;
+         ctx->Unpack.CompressedBlockHeight = param;
+         break;
+      case GL_UNPACK_COMPRESSED_BLOCK_DEPTH:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         if (param<0)
+            goto invalid_value_error;
+         ctx->Unpack.CompressedBlockDepth = param;
+         break;
+      case GL_UNPACK_COMPRESSED_BLOCK_SIZE:
+         if (!_mesa_is_desktop_gl(ctx))
+            goto invalid_enum_error;
+         if (param<0)
+            goto invalid_value_error;
+         ctx->Unpack.CompressedBlockSize = param;
+         break;
       default:
          goto invalid_enum_error;
    }
@@ -188,6 +244,10 @@ _mesa_init_pixelstore( struct gl_context *ctx )
    ctx->Pack.SwapBytes = GL_FALSE;
    ctx->Pack.LsbFirst = GL_FALSE;
    ctx->Pack.Invert = GL_FALSE;
+   ctx->Pack.CompressedBlockWidth = 0;
+   ctx->Pack.CompressedBlockHeight = 0;
+   ctx->Pack.CompressedBlockDepth = 0;
+   ctx->Pack.CompressedBlockSize = 0;
    _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj,
                                  ctx->Shared->NullBufferObj);
    ctx->Unpack.Alignment = 4;
@@ -199,6 +259,10 @@ _mesa_init_pixelstore( struct gl_context *ctx )
    ctx->Unpack.SwapBytes = GL_FALSE;
    ctx->Unpack.LsbFirst = GL_FALSE;
    ctx->Unpack.Invert = GL_FALSE;
+   ctx->Unpack.CompressedBlockWidth = 0;
+   ctx->Unpack.CompressedBlockHeight = 0;
+   ctx->Unpack.CompressedBlockDepth = 0;
+   ctx->Unpack.CompressedBlockSize = 0;
    _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj,
                                  ctx->Shared->NullBufferObj);
 
@@ -220,3 +284,45 @@ _mesa_init_pixelstore( struct gl_context *ctx )
    _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj,
                                  ctx->Shared->NullBufferObj);
 }
+
+
+/**
+ * Check if the given compressed pixel storage parameters are legal.
+ * Record a GL error if illegal.
+ * \return  true if legal, false if illegal
+ */
+bool
+_mesa_compressed_pixel_storage_error_check(
+   struct gl_context *ctx,
+   GLint dimensions,
+   const struct gl_pixelstore_attrib *packing,
+   const char *caller)
+{
+   if (!_mesa_is_desktop_gl(ctx) || !packing->CompressedBlockSize)
+      return true;
+
+   if (packing->CompressedBlockWidth &&
+       packing->SkipPixels % packing->CompressedBlockWidth) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "%s(skip-pixels %% block-width)", caller);
+      return false;
+   }
+
+   if (dimensions > 1 &&
+       packing->CompressedBlockHeight &&
+       packing->SkipRows % packing->CompressedBlockHeight) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "%s(skip-rows %% block-height)", caller);
+      return false;
+   }
+
+   if (dimensions > 2 &&
+       packing->CompressedBlockDepth &&
+       packing->SkipImages % packing->CompressedBlockDepth) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "%s(skip-images %% block-depth)", caller);
+      return false;
+   }
+
+   return true;
+}