1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Mesa 3-D graphics library
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
12bf215546Sopenharmony_ci *
13bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included
14bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
15bf215546Sopenharmony_ci *
16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci/**
26bf215546Sopenharmony_ci * \file pixelstore.c
27bf215546Sopenharmony_ci * glPixelStore functions.
28bf215546Sopenharmony_ci */
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci#include "glheader.h"
32bf215546Sopenharmony_ci#include "bufferobj.h"
33bf215546Sopenharmony_ci#include "context.h"
34bf215546Sopenharmony_ci#include "pixelstore.h"
35bf215546Sopenharmony_ci#include "mtypes.h"
36bf215546Sopenharmony_ci#include "util/rounding.h"
37bf215546Sopenharmony_ci#include "api_exec_decl.h"
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_cistatic ALWAYS_INLINE void
41bf215546Sopenharmony_cipixel_storei(GLenum pname, GLint param, bool no_error)
42bf215546Sopenharmony_ci{
43bf215546Sopenharmony_ci   /* NOTE: this call can't be compiled into the display list */
44bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ci   switch (pname) {
47bf215546Sopenharmony_ci      case GL_PACK_SWAP_BYTES:
48bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
49bf215546Sopenharmony_ci            goto invalid_enum_error;
50bf215546Sopenharmony_ci         ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE;
51bf215546Sopenharmony_ci         break;
52bf215546Sopenharmony_ci      case GL_PACK_LSB_FIRST:
53bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
54bf215546Sopenharmony_ci            goto invalid_enum_error;
55bf215546Sopenharmony_ci         ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE;
56bf215546Sopenharmony_ci         break;
57bf215546Sopenharmony_ci      case GL_PACK_ROW_LENGTH:
58bf215546Sopenharmony_ci         if (!no_error && ctx->API == API_OPENGLES)
59bf215546Sopenharmony_ci            goto invalid_enum_error;
60bf215546Sopenharmony_ci         if (!no_error && param<0)
61bf215546Sopenharmony_ci            goto invalid_value_error;
62bf215546Sopenharmony_ci         ctx->Pack.RowLength = param;
63bf215546Sopenharmony_ci         break;
64bf215546Sopenharmony_ci      case GL_PACK_IMAGE_HEIGHT:
65bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
66bf215546Sopenharmony_ci            goto invalid_enum_error;
67bf215546Sopenharmony_ci         if (!no_error && param<0)
68bf215546Sopenharmony_ci            goto invalid_value_error;
69bf215546Sopenharmony_ci         ctx->Pack.ImageHeight = param;
70bf215546Sopenharmony_ci         break;
71bf215546Sopenharmony_ci      case GL_PACK_SKIP_PIXELS:
72bf215546Sopenharmony_ci         if (!no_error && ctx->API == API_OPENGLES)
73bf215546Sopenharmony_ci            goto invalid_enum_error;
74bf215546Sopenharmony_ci         if (!no_error && param<0)
75bf215546Sopenharmony_ci            goto invalid_value_error;
76bf215546Sopenharmony_ci         ctx->Pack.SkipPixels = param;
77bf215546Sopenharmony_ci         break;
78bf215546Sopenharmony_ci      case GL_PACK_SKIP_ROWS:
79bf215546Sopenharmony_ci         if (!no_error && ctx->API == API_OPENGLES)
80bf215546Sopenharmony_ci            goto invalid_enum_error;
81bf215546Sopenharmony_ci         if (!no_error && param<0)
82bf215546Sopenharmony_ci            goto invalid_value_error;
83bf215546Sopenharmony_ci         ctx->Pack.SkipRows = param;
84bf215546Sopenharmony_ci         break;
85bf215546Sopenharmony_ci      case GL_PACK_SKIP_IMAGES:
86bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
87bf215546Sopenharmony_ci            goto invalid_enum_error;
88bf215546Sopenharmony_ci         if (!no_error && param<0)
89bf215546Sopenharmony_ci            goto invalid_value_error;
90bf215546Sopenharmony_ci         ctx->Pack.SkipImages = param;
91bf215546Sopenharmony_ci         break;
92bf215546Sopenharmony_ci      case GL_PACK_ALIGNMENT:
93bf215546Sopenharmony_ci         if (!no_error && param!=1 && param!=2 && param!=4 && param!=8)
94bf215546Sopenharmony_ci            goto invalid_value_error;
95bf215546Sopenharmony_ci         ctx->Pack.Alignment = param;
96bf215546Sopenharmony_ci         break;
97bf215546Sopenharmony_ci      case GL_PACK_INVERT_MESA:
98bf215546Sopenharmony_ci         if (!no_error && !_mesa_has_MESA_pack_invert(ctx))
99bf215546Sopenharmony_ci            goto invalid_enum_error;
100bf215546Sopenharmony_ci         ctx->Pack.Invert = param;
101bf215546Sopenharmony_ci         break;
102bf215546Sopenharmony_ci      case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
103bf215546Sopenharmony_ci         if (!no_error && !_mesa_has_ANGLE_pack_reverse_row_order(ctx))
104bf215546Sopenharmony_ci            goto invalid_enum_error;
105bf215546Sopenharmony_ci         ctx->Pack.Invert = param;
106bf215546Sopenharmony_ci         break;
107bf215546Sopenharmony_ci      case GL_PACK_COMPRESSED_BLOCK_WIDTH:
108bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
109bf215546Sopenharmony_ci            goto invalid_enum_error;
110bf215546Sopenharmony_ci         if (!no_error && param<0)
111bf215546Sopenharmony_ci            goto invalid_value_error;
112bf215546Sopenharmony_ci         ctx->Pack.CompressedBlockWidth = param;
113bf215546Sopenharmony_ci         break;
114bf215546Sopenharmony_ci      case GL_PACK_COMPRESSED_BLOCK_HEIGHT:
115bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
116bf215546Sopenharmony_ci            goto invalid_enum_error;
117bf215546Sopenharmony_ci         if (!no_error && param<0)
118bf215546Sopenharmony_ci            goto invalid_value_error;
119bf215546Sopenharmony_ci         ctx->Pack.CompressedBlockHeight = param;
120bf215546Sopenharmony_ci         break;
121bf215546Sopenharmony_ci      case GL_PACK_COMPRESSED_BLOCK_DEPTH:
122bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
123bf215546Sopenharmony_ci            goto invalid_enum_error;
124bf215546Sopenharmony_ci         if (!no_error && param<0)
125bf215546Sopenharmony_ci            goto invalid_value_error;
126bf215546Sopenharmony_ci         ctx->Pack.CompressedBlockDepth = param;
127bf215546Sopenharmony_ci         break;
128bf215546Sopenharmony_ci      case GL_PACK_COMPRESSED_BLOCK_SIZE:
129bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
130bf215546Sopenharmony_ci            goto invalid_enum_error;
131bf215546Sopenharmony_ci         if (!no_error && param<0)
132bf215546Sopenharmony_ci            goto invalid_value_error;
133bf215546Sopenharmony_ci         ctx->Pack.CompressedBlockSize = param;
134bf215546Sopenharmony_ci         break;
135bf215546Sopenharmony_ci
136bf215546Sopenharmony_ci      case GL_UNPACK_SWAP_BYTES:
137bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
138bf215546Sopenharmony_ci            goto invalid_enum_error;
139bf215546Sopenharmony_ci         ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE;
140bf215546Sopenharmony_ci         break;
141bf215546Sopenharmony_ci      case GL_UNPACK_LSB_FIRST:
142bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
143bf215546Sopenharmony_ci            goto invalid_enum_error;
144bf215546Sopenharmony_ci         ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE;
145bf215546Sopenharmony_ci         break;
146bf215546Sopenharmony_ci      case GL_UNPACK_ROW_LENGTH:
147bf215546Sopenharmony_ci         if (!no_error && ctx->API == API_OPENGLES)
148bf215546Sopenharmony_ci            goto invalid_enum_error;
149bf215546Sopenharmony_ci         if (!no_error && param<0)
150bf215546Sopenharmony_ci            goto invalid_value_error;
151bf215546Sopenharmony_ci         ctx->Unpack.RowLength = param;
152bf215546Sopenharmony_ci         break;
153bf215546Sopenharmony_ci      case GL_UNPACK_IMAGE_HEIGHT:
154bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
155bf215546Sopenharmony_ci            goto invalid_enum_error;
156bf215546Sopenharmony_ci         if (!no_error && param<0)
157bf215546Sopenharmony_ci            goto invalid_value_error;
158bf215546Sopenharmony_ci         ctx->Unpack.ImageHeight = param;
159bf215546Sopenharmony_ci         break;
160bf215546Sopenharmony_ci      case GL_UNPACK_SKIP_PIXELS:
161bf215546Sopenharmony_ci         if (!no_error && ctx->API == API_OPENGLES)
162bf215546Sopenharmony_ci            goto invalid_enum_error;
163bf215546Sopenharmony_ci         if (!no_error && param<0)
164bf215546Sopenharmony_ci            goto invalid_value_error;
165bf215546Sopenharmony_ci         ctx->Unpack.SkipPixels = param;
166bf215546Sopenharmony_ci         break;
167bf215546Sopenharmony_ci      case GL_UNPACK_SKIP_ROWS:
168bf215546Sopenharmony_ci         if (!no_error && ctx->API == API_OPENGLES)
169bf215546Sopenharmony_ci            goto invalid_enum_error;
170bf215546Sopenharmony_ci         if (!no_error && param<0)
171bf215546Sopenharmony_ci            goto invalid_value_error;
172bf215546Sopenharmony_ci         ctx->Unpack.SkipRows = param;
173bf215546Sopenharmony_ci         break;
174bf215546Sopenharmony_ci      case GL_UNPACK_SKIP_IMAGES:
175bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
176bf215546Sopenharmony_ci            goto invalid_enum_error;
177bf215546Sopenharmony_ci         if (!no_error && param < 0)
178bf215546Sopenharmony_ci            goto invalid_value_error;
179bf215546Sopenharmony_ci         ctx->Unpack.SkipImages = param;
180bf215546Sopenharmony_ci         break;
181bf215546Sopenharmony_ci      case GL_UNPACK_ALIGNMENT:
182bf215546Sopenharmony_ci         if (!no_error && param!=1 && param!=2 && param!=4 && param!=8)
183bf215546Sopenharmony_ci            goto invalid_value_error;
184bf215546Sopenharmony_ci         ctx->Unpack.Alignment = param;
185bf215546Sopenharmony_ci         break;
186bf215546Sopenharmony_ci      case GL_UNPACK_COMPRESSED_BLOCK_WIDTH:
187bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
188bf215546Sopenharmony_ci            goto invalid_enum_error;
189bf215546Sopenharmony_ci         if (!no_error && param<0)
190bf215546Sopenharmony_ci            goto invalid_value_error;
191bf215546Sopenharmony_ci         ctx->Unpack.CompressedBlockWidth = param;
192bf215546Sopenharmony_ci         break;
193bf215546Sopenharmony_ci      case GL_UNPACK_COMPRESSED_BLOCK_HEIGHT:
194bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
195bf215546Sopenharmony_ci            goto invalid_enum_error;
196bf215546Sopenharmony_ci         if (!no_error && param<0)
197bf215546Sopenharmony_ci            goto invalid_value_error;
198bf215546Sopenharmony_ci         ctx->Unpack.CompressedBlockHeight = param;
199bf215546Sopenharmony_ci         break;
200bf215546Sopenharmony_ci      case GL_UNPACK_COMPRESSED_BLOCK_DEPTH:
201bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
202bf215546Sopenharmony_ci            goto invalid_enum_error;
203bf215546Sopenharmony_ci         if (!no_error && param<0)
204bf215546Sopenharmony_ci            goto invalid_value_error;
205bf215546Sopenharmony_ci         ctx->Unpack.CompressedBlockDepth = param;
206bf215546Sopenharmony_ci         break;
207bf215546Sopenharmony_ci      case GL_UNPACK_COMPRESSED_BLOCK_SIZE:
208bf215546Sopenharmony_ci         if (!no_error && !_mesa_is_desktop_gl(ctx))
209bf215546Sopenharmony_ci            goto invalid_enum_error;
210bf215546Sopenharmony_ci         if (!no_error && param<0)
211bf215546Sopenharmony_ci            goto invalid_value_error;
212bf215546Sopenharmony_ci         ctx->Unpack.CompressedBlockSize = param;
213bf215546Sopenharmony_ci         break;
214bf215546Sopenharmony_ci      default:
215bf215546Sopenharmony_ci         if (!no_error)
216bf215546Sopenharmony_ci            goto invalid_enum_error;
217bf215546Sopenharmony_ci         else
218bf215546Sopenharmony_ci            unreachable("invalid pixel store enum");
219bf215546Sopenharmony_ci   }
220bf215546Sopenharmony_ci
221bf215546Sopenharmony_ci   return;
222bf215546Sopenharmony_ci
223bf215546Sopenharmony_ciinvalid_enum_error:
224bf215546Sopenharmony_ci   _mesa_error(ctx, GL_INVALID_ENUM, "glPixelStore");
225bf215546Sopenharmony_ci   return;
226bf215546Sopenharmony_ci
227bf215546Sopenharmony_ciinvalid_value_error:
228bf215546Sopenharmony_ci   _mesa_error(ctx, GL_INVALID_VALUE, "glPixelStore(param)");
229bf215546Sopenharmony_ci   return;
230bf215546Sopenharmony_ci}
231bf215546Sopenharmony_ci
232bf215546Sopenharmony_ci
233bf215546Sopenharmony_civoid GLAPIENTRY
234bf215546Sopenharmony_ci_mesa_PixelStorei(GLenum pname, GLint param)
235bf215546Sopenharmony_ci{
236bf215546Sopenharmony_ci   pixel_storei(pname, param, false);
237bf215546Sopenharmony_ci}
238bf215546Sopenharmony_ci
239bf215546Sopenharmony_ci
240bf215546Sopenharmony_civoid GLAPIENTRY
241bf215546Sopenharmony_ci_mesa_PixelStoref(GLenum pname, GLfloat param)
242bf215546Sopenharmony_ci{
243bf215546Sopenharmony_ci   _mesa_PixelStorei(pname, lroundf(param));
244bf215546Sopenharmony_ci}
245bf215546Sopenharmony_ci
246bf215546Sopenharmony_ci
247bf215546Sopenharmony_civoid GLAPIENTRY
248bf215546Sopenharmony_ci_mesa_PixelStorei_no_error(GLenum pname, GLint param)
249bf215546Sopenharmony_ci{
250bf215546Sopenharmony_ci   pixel_storei(pname, param, true);
251bf215546Sopenharmony_ci}
252bf215546Sopenharmony_ci
253bf215546Sopenharmony_ci
254bf215546Sopenharmony_civoid GLAPIENTRY
255bf215546Sopenharmony_ci_mesa_PixelStoref_no_error(GLenum pname, GLfloat param)
256bf215546Sopenharmony_ci{
257bf215546Sopenharmony_ci   _mesa_PixelStorei_no_error(pname, lroundf(param));
258bf215546Sopenharmony_ci}
259bf215546Sopenharmony_ci
260bf215546Sopenharmony_ci
261bf215546Sopenharmony_ci/**
262bf215546Sopenharmony_ci * Initialize the context's pixel store state.
263bf215546Sopenharmony_ci */
264bf215546Sopenharmony_civoid
265bf215546Sopenharmony_ci_mesa_init_pixelstore(struct gl_context *ctx)
266bf215546Sopenharmony_ci{
267bf215546Sopenharmony_ci   /* Pixel transfer */
268bf215546Sopenharmony_ci   ctx->Pack.Alignment = 4;
269bf215546Sopenharmony_ci   ctx->Pack.RowLength = 0;
270bf215546Sopenharmony_ci   ctx->Pack.ImageHeight = 0;
271bf215546Sopenharmony_ci   ctx->Pack.SkipPixels = 0;
272bf215546Sopenharmony_ci   ctx->Pack.SkipRows = 0;
273bf215546Sopenharmony_ci   ctx->Pack.SkipImages = 0;
274bf215546Sopenharmony_ci   ctx->Pack.SwapBytes = GL_FALSE;
275bf215546Sopenharmony_ci   ctx->Pack.LsbFirst = GL_FALSE;
276bf215546Sopenharmony_ci   ctx->Pack.Invert = GL_FALSE;
277bf215546Sopenharmony_ci   ctx->Pack.CompressedBlockWidth = 0;
278bf215546Sopenharmony_ci   ctx->Pack.CompressedBlockHeight = 0;
279bf215546Sopenharmony_ci   ctx->Pack.CompressedBlockDepth = 0;
280bf215546Sopenharmony_ci   ctx->Pack.CompressedBlockSize = 0;
281bf215546Sopenharmony_ci   _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL);
282bf215546Sopenharmony_ci   ctx->Unpack.Alignment = 4;
283bf215546Sopenharmony_ci   ctx->Unpack.RowLength = 0;
284bf215546Sopenharmony_ci   ctx->Unpack.ImageHeight = 0;
285bf215546Sopenharmony_ci   ctx->Unpack.SkipPixels = 0;
286bf215546Sopenharmony_ci   ctx->Unpack.SkipRows = 0;
287bf215546Sopenharmony_ci   ctx->Unpack.SkipImages = 0;
288bf215546Sopenharmony_ci   ctx->Unpack.SwapBytes = GL_FALSE;
289bf215546Sopenharmony_ci   ctx->Unpack.LsbFirst = GL_FALSE;
290bf215546Sopenharmony_ci   ctx->Unpack.Invert = GL_FALSE;
291bf215546Sopenharmony_ci   ctx->Unpack.CompressedBlockWidth = 0;
292bf215546Sopenharmony_ci   ctx->Unpack.CompressedBlockHeight = 0;
293bf215546Sopenharmony_ci   ctx->Unpack.CompressedBlockDepth = 0;
294bf215546Sopenharmony_ci   ctx->Unpack.CompressedBlockSize = 0;
295bf215546Sopenharmony_ci   _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL);
296bf215546Sopenharmony_ci
297bf215546Sopenharmony_ci   /*
298bf215546Sopenharmony_ci    * _mesa_unpack_image() returns image data in this format.  When we
299bf215546Sopenharmony_ci    * execute image commands (glDrawPixels(), glTexImage(), etc) from
300bf215546Sopenharmony_ci    * within display lists we have to be sure to set the current
301bf215546Sopenharmony_ci    * unpacking parameters to these values!
302bf215546Sopenharmony_ci    */
303bf215546Sopenharmony_ci   ctx->DefaultPacking.Alignment = 1;
304bf215546Sopenharmony_ci   ctx->DefaultPacking.RowLength = 0;
305bf215546Sopenharmony_ci   ctx->DefaultPacking.SkipPixels = 0;
306bf215546Sopenharmony_ci   ctx->DefaultPacking.SkipRows = 0;
307bf215546Sopenharmony_ci   ctx->DefaultPacking.ImageHeight = 0;
308bf215546Sopenharmony_ci   ctx->DefaultPacking.SkipImages = 0;
309bf215546Sopenharmony_ci   ctx->DefaultPacking.SwapBytes = GL_FALSE;
310bf215546Sopenharmony_ci   ctx->DefaultPacking.LsbFirst = GL_FALSE;
311bf215546Sopenharmony_ci   ctx->DefaultPacking.Invert = GL_FALSE;
312bf215546Sopenharmony_ci   _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, NULL);
313bf215546Sopenharmony_ci}
314bf215546Sopenharmony_ci
315bf215546Sopenharmony_ci
316bf215546Sopenharmony_ci/**
317bf215546Sopenharmony_ci * Check if the given compressed pixel storage parameters are legal.
318bf215546Sopenharmony_ci * Record a GL error if illegal.
319bf215546Sopenharmony_ci * \return  true if legal, false if illegal
320bf215546Sopenharmony_ci */
321bf215546Sopenharmony_cibool
322bf215546Sopenharmony_ci_mesa_compressed_pixel_storage_error_check(
323bf215546Sopenharmony_ci   struct gl_context *ctx,
324bf215546Sopenharmony_ci   GLint dimensions,
325bf215546Sopenharmony_ci   const struct gl_pixelstore_attrib *packing,
326bf215546Sopenharmony_ci   const char *caller)
327bf215546Sopenharmony_ci{
328bf215546Sopenharmony_ci   if (!_mesa_is_desktop_gl(ctx) || !packing->CompressedBlockSize)
329bf215546Sopenharmony_ci      return true;
330bf215546Sopenharmony_ci
331bf215546Sopenharmony_ci   if (packing->CompressedBlockWidth &&
332bf215546Sopenharmony_ci       packing->SkipPixels % packing->CompressedBlockWidth) {
333bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_OPERATION,
334bf215546Sopenharmony_ci                  "%s(skip-pixels %% block-width)", caller);
335bf215546Sopenharmony_ci      return false;
336bf215546Sopenharmony_ci   }
337bf215546Sopenharmony_ci
338bf215546Sopenharmony_ci   if (dimensions > 1 &&
339bf215546Sopenharmony_ci       packing->CompressedBlockHeight &&
340bf215546Sopenharmony_ci       packing->SkipRows % packing->CompressedBlockHeight) {
341bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_OPERATION,
342bf215546Sopenharmony_ci                  "%s(skip-rows %% block-height)", caller);
343bf215546Sopenharmony_ci      return false;
344bf215546Sopenharmony_ci   }
345bf215546Sopenharmony_ci
346bf215546Sopenharmony_ci   if (dimensions > 2 &&
347bf215546Sopenharmony_ci       packing->CompressedBlockDepth &&
348bf215546Sopenharmony_ci       packing->SkipImages % packing->CompressedBlockDepth) {
349bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_OPERATION,
350bf215546Sopenharmony_ci                  "%s(skip-images %% block-depth)", caller);
351bf215546Sopenharmony_ci      return false;
352bf215546Sopenharmony_ci   }
353bf215546Sopenharmony_ci
354bf215546Sopenharmony_ci   return true;
355bf215546Sopenharmony_ci}
356