diff options
author | Timothy Arceri <[email protected]> | 2017-06-28 13:27:46 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-06-29 08:54:10 +1000 |
commit | 9853ca6037b92d176ea35dc0d213b66c25392dc0 (patch) | |
tree | cb053643fa4770095a967ffc7f9151eca2753bb4 /src | |
parent | 7d8937d23c618bf56f673bacbbfe0f1e4b632579 (diff) |
mesa: add pixel_storei() helper
Will be used to add KHR_no_error support.
Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/pixelstore.c | 103 |
1 files changed, 57 insertions, 46 deletions
diff --git a/src/mesa/main/pixelstore.c b/src/mesa/main/pixelstore.c index fc815337b8d..38e60723ca4 100644 --- a/src/mesa/main/pixelstore.c +++ b/src/mesa/main/pixelstore.c @@ -35,177 +35,181 @@ #include "mtypes.h" -void GLAPIENTRY -_mesa_PixelStorei( GLenum pname, GLint param ) +static ALWAYS_INLINE void +pixel_storei(GLenum pname, GLint param, bool no_error) { /* NOTE: this call can't be compiled into the display list */ GET_CURRENT_CONTEXT(ctx); switch (pname) { case GL_PACK_SWAP_BYTES: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE; break; case GL_PACK_LSB_FIRST: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE; break; case GL_PACK_ROW_LENGTH: - if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Pack.RowLength = param; break; case GL_PACK_IMAGE_HEIGHT: - if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Pack.ImageHeight = param; break; case GL_PACK_SKIP_PIXELS: - if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Pack.SkipPixels = param; break; case GL_PACK_SKIP_ROWS: - if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Pack.SkipRows = param; break; case GL_PACK_SKIP_IMAGES: - if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Pack.SkipImages = param; break; case GL_PACK_ALIGNMENT: - if (param!=1 && param!=2 && param!=4 && param!=8) + if (!no_error && param!=1 && param!=2 && param!=4 && param!=8) goto invalid_value_error; ctx->Pack.Alignment = param; break; case GL_PACK_INVERT_MESA: - if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.MESA_pack_invert) + if (!no_error && + (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.MESA_pack_invert)) goto invalid_enum_error; ctx->Pack.Invert = param; break; case GL_PACK_COMPRESSED_BLOCK_WIDTH: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Pack.CompressedBlockWidth = param; break; case GL_PACK_COMPRESSED_BLOCK_HEIGHT: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Pack.CompressedBlockHeight = param; break; case GL_PACK_COMPRESSED_BLOCK_DEPTH: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Pack.CompressedBlockDepth = param; break; case GL_PACK_COMPRESSED_BLOCK_SIZE: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Pack.CompressedBlockSize = param; break; case GL_UNPACK_SWAP_BYTES: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE; break; case GL_UNPACK_LSB_FIRST: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE; break; case GL_UNPACK_ROW_LENGTH: - if (ctx->API == API_OPENGLES) + if (!no_error && ctx->API == API_OPENGLES) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Unpack.RowLength = param; break; case GL_UNPACK_IMAGE_HEIGHT: - if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Unpack.ImageHeight = param; break; case GL_UNPACK_SKIP_PIXELS: - if (ctx->API == API_OPENGLES) + if (!no_error && ctx->API == API_OPENGLES) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Unpack.SkipPixels = param; break; case GL_UNPACK_SKIP_ROWS: - if (ctx->API == API_OPENGLES) + if (!no_error && ctx->API == API_OPENGLES) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Unpack.SkipRows = param; break; case GL_UNPACK_SKIP_IMAGES: - if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx)) goto invalid_enum_error; - if (param < 0) + if (!no_error && param < 0) goto invalid_value_error; ctx->Unpack.SkipImages = param; break; case GL_UNPACK_ALIGNMENT: - if (param!=1 && param!=2 && param!=4 && param!=8) + if (!no_error && param!=1 && param!=2 && param!=4 && param!=8) goto invalid_value_error; ctx->Unpack.Alignment = param; break; case GL_UNPACK_COMPRESSED_BLOCK_WIDTH: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Unpack.CompressedBlockWidth = param; break; case GL_UNPACK_COMPRESSED_BLOCK_HEIGHT: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Unpack.CompressedBlockHeight = param; break; case GL_UNPACK_COMPRESSED_BLOCK_DEPTH: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Unpack.CompressedBlockDepth = param; break; case GL_UNPACK_COMPRESSED_BLOCK_SIZE: - if (!_mesa_is_desktop_gl(ctx)) + if (!no_error && !_mesa_is_desktop_gl(ctx)) goto invalid_enum_error; - if (param<0) + if (!no_error && param<0) goto invalid_value_error; ctx->Unpack.CompressedBlockSize = param; break; default: - goto invalid_enum_error; + if (!no_error) + goto invalid_enum_error; + else + unreachable("invalid pixel store enum"); } return; @@ -221,6 +225,13 @@ invalid_value_error: void GLAPIENTRY +_mesa_PixelStorei( GLenum pname, GLint param ) +{ + pixel_storei(pname, param, false); +} + + +void GLAPIENTRY _mesa_PixelStoref( GLenum pname, GLfloat param ) { _mesa_PixelStorei( pname, IROUND(param) ); |