return format;
}
+/**
+ * Returns a corresponding base format for a given internal floating point
+ * format as specifed by OES_texture_float.
+ */
+static GLenum
+oes_float_internal_format(const struct gl_context *ctx,
+ GLenum format, GLenum type)
+{
+ switch (type) {
+ case GL_FLOAT:
+ if (ctx->Extensions.OES_texture_float) {
+ switch (format) {
+ case GL_RGBA32F:
+ return GL_RGBA;
+ case GL_RGB32F:
+ return GL_RGB;
+ case GL_ALPHA32F_ARB:
+ return GL_ALPHA;
+ case GL_LUMINANCE32F_ARB:
+ return GL_LUMINANCE;
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ return GL_LUMINANCE_ALPHA;
+ default:
+ break;
+ }
+ }
+ break;
+
+ case GL_HALF_FLOAT_OES:
+ if (ctx->Extensions.OES_texture_half_float) {
+ switch (format) {
+ case GL_RGBA16F:
+ return GL_RGBA;
+ case GL_RGB16F:
+ return GL_RGB;
+ case GL_ALPHA16F_ARB:
+ return GL_ALPHA;
+ case GL_LUMINANCE16F_ARB:
+ return GL_LUMINANCE;
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ return GL_LUMINANCE_ALPHA;
+ default:
+ break;
+ }
+ }
+ break;
+ }
+ return format;
+}
+
/**
* Install gl_texture_image in a gl_texture_object according to the target
}
if (xoffset + subWidth > (GLint) destImage->Width) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset+width)", func);
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset %d + width %d > %u)", func,
+ xoffset, subWidth, destImage->Width);
return GL_TRUE;
}
return GL_TRUE;
}
if (yoffset + subHeight > (GLint) destImage->Height) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(yoffset+height)", func);
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(yoffset %d + height %d > %u)",
+ func, yoffset, subHeight, destImage->Height);
return GL_TRUE;
}
}
if (target == GL_TEXTURE_CUBE_MAP)
depth = 6;
if (zoffset + subDepth > depth) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(zoffset+depth)", func);
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(zoffset %d + depth %d > %u)",
+ func, zoffset, subDepth, depth);
return GL_TRUE;
}
}
*
* This should also be applicable for glTexStorage3D(). Other available
* targets for these functions are: TEXTURE_3D and TEXTURE_CUBE_MAP_ARRAY.
+ *
+ * Section 8.7, page 179 of OpenGL ES 3.2 adds:
+ *
+ * An INVALID_OPERATION error is generated by CompressedTexImage3D
+ * if internalformat is one of the the formats in table 8.17 and target is
+ * not TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY or TEXTURE_3D.
+ *
+ * An INVALID_OPERATION error is generated by CompressedTexImage3D
+ * if internalformat is TEXTURE_CUBE_MAP_ARRAY and the “Cube Map
+ * Array” column of table 8.17 is not checked, or if internalformat
+ * is TEXTURE_- 3D and the “3D Tex.” column of table 8.17 is not
+ * checked.
+ *
+ * The instances of <internalformat> above should say <target>.
+ *
+ * Such table 8.17 has checked "Cube Map Array" column for all the
+ * cases. So in practice, TEXTURE_CUBE_MAP_ARRAY is now valid for OpenGL ES 3.2
*/
- if (layout == MESA_FORMAT_LAYOUT_ETC2 && _mesa_is_gles3(ctx))
+ if (layout == MESA_FORMAT_LAYOUT_ETC2 && _mesa_is_gles3(ctx) &&
+ !_mesa_is_gles32(ctx))
return write_error(error, GL_INVALID_OPERATION);
target_can_be_compresed = _mesa_has_texture_cube_map_array(ctx);
break;
* \param format pixel data format given by the user.
* \param type pixel data type given by the user.
* \param internalFormat internal format given by the user.
- * \param dimensions texture image dimensions (must be 1, 2 or 3).
* \param callerName name of the caller function to print in the error message
*
* \return true if a error is found, false otherwise
*/
static bool
texture_format_error_check_gles(struct gl_context *ctx, GLenum format,
- GLenum type, GLenum internalFormat,
- GLuint dimensions, const char *callerName)
+ GLenum type, GLenum internalFormat, const char *callerName)
{
- GLenum err;
-
- if (_mesa_is_gles3(ctx)) {
- err = _mesa_es3_error_check_format_and_type(ctx, format, type,
- internalFormat);
- if (err != GL_NO_ERROR) {
- _mesa_error(ctx, err,
- "%s(format = %s, type = %s, internalformat = %s)",
- callerName, _mesa_enum_to_string(format),
- _mesa_enum_to_string(type),
- _mesa_enum_to_string(internalFormat));
- return true;
- }
- }
- else {
- err = _mesa_es_error_check_format_and_type(ctx, format, type, dimensions);
- if (err != GL_NO_ERROR) {
- _mesa_error(ctx, err, "%s(format = %s, type = %s)",
- callerName, _mesa_enum_to_string(format),
- _mesa_enum_to_string(type));
- return true;
- }
+ GLenum err = _mesa_es3_error_check_format_and_type(ctx, format, type,
+ internalFormat);
+ if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err,
+ "%s(format = %s, type = %s, internalformat = %s)",
+ callerName, _mesa_enum_to_string(format),
+ _mesa_enum_to_string(type),
+ _mesa_enum_to_string(internalFormat));
+ return true;
}
return false;
* Formats and types that require additional extensions (e.g., GL_FLOAT
* requires GL_OES_texture_float) are filtered elsewhere.
*/
+ char bufCallerName[20];
+ snprintf(bufCallerName, 20, "glTexImage%dD", dimensions);
if (_mesa_is_gles(ctx) &&
- texture_format_error_check_gles(ctx, format, type, internalFormat,
- dimensions, "glTexImage%dD")) {
+ texture_format_error_check_gles(ctx, format, type,
+ internalFormat, bufCallerName)) {
return GL_TRUE;
}
texImage = _mesa_select_tex_image(texObj, target, level);
if (!texImage) {
/* non-existant texture level */
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture image)",
- callerName);
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture level %d)",
+ callerName, level);
return GL_TRUE;
}
return GL_TRUE;
}
+ GLenum internalFormat = _mesa_is_gles(ctx) ?
+ oes_float_internal_format(ctx, texImage->InternalFormat, type) :
+ texImage->InternalFormat;
+
/* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the
* combinations of format, internalFormat, and type that can be used.
* Formats and types that require additional extensions (e.g., GL_FLOAT
*/
if (_mesa_is_gles(ctx) &&
texture_format_error_check_gles(ctx, format, type,
- texImage->InternalFormat,
- dimensions, callerName)) {
+ internalFormat, callerName)) {
return GL_TRUE;
}
_mesa_is_enum_format_unsigned_int(internalFormat) !=
_mesa_is_enum_format_unsigned_int(rb_internal_format)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glCopyTexImage%dD(signed vs unsigned integer)", dimensions);
+ "glCopyTexImage%dD(signed vs unsigned integer)",
+ dimensions);
return GL_TRUE;
}
}
if (!texImage) {
/* destination image does not exist */
_mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(invalid texture image)", caller);
+ "%s(invalid texture level %d)", caller, level);
return GL_TRUE;
}
/* see if we've already chosen a format for the previous level */
if (level > 0) {
struct gl_texture_image *prevImage =
- _mesa_select_tex_image(texObj, target, level - 1);
+ _mesa_select_tex_image(texObj, target, level - 1);
/* See if the prev level is defined and has an internal format which
* matches the new internal format.
*/
}
}
- /* If the application requested compression to an S3TC format but we don't
- * have the DXTn library, force a generic compressed format instead.
- */
- if (internalFormat != format && format != GL_NONE) {
- const GLenum before = internalFormat;
-
- switch (internalFormat) {
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- if (!ctx->Mesa_DXTn)
- internalFormat = GL_COMPRESSED_RGB;
- break;
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- if (!ctx->Mesa_DXTn)
- internalFormat = GL_COMPRESSED_RGBA;
- break;
- default:
- break;
- }
-
- if (before != internalFormat) {
- _mesa_warning(ctx,
- "DXT compression requested (%s), "
- "but libtxc_dxtn library not installed. Using %s "
- "instead.",
- _mesa_enum_to_string(before),
- _mesa_enum_to_string(internalFormat));
- }
- }
-
- /* choose format from scratch */
f = ctx->Driver.ChooseTextureFormat(ctx, target, internalFormat,
format, type);
assert(f != MESA_FORMAT_NONE);
* rarely-tested software fallback rendering.
*/
if (border && ctx->Const.StripTextureBorder) {
- strip_texture_border(target, &width, &height, &depth, unpack,
- &unpack_no_border);
+ strip_texture_border(target, &width, &height, &depth, unpack,
+ &unpack_no_border);
border = 0;
- unpack = &unpack_no_border;
+ unpack = &unpack_no_border;
}
if (ctx->NewState & _NEW_PIXEL)
- _mesa_update_state(ctx);
+ _mesa_update_state(ctx);
_mesa_lock_texture(ctx, texObj);
{
- texImage = _mesa_get_tex_image(ctx, texObj, target, level);
+ texImage = _mesa_get_tex_image(ctx, texObj, target, level);
- if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s%uD", func, dims);
- }
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s%uD", func, dims);
+ }
else {
ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
}
}
+
/* This is a wrapper around teximage() so that we can force the KHR_no_error
* logic to be inlined without inlining the function into all the callers.
*/
ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
ctx->Driver.EGLImageTargetTexture2D(ctx, target,
- texObj, texImage, image);
+ texObj, texImage, image);
_mesa_dirty_texobj(ctx, texObj);
}
}
}
+
static void
copytexsubimage_by_slice(struct gl_context *ctx,
struct gl_texture_image *texImage,
}
}
+
static GLboolean
formats_differ_in_component_sizes(mesa_format f1, mesa_format f2)
{
x += border;
width -= border * 2;
if (dims == 2) {
- y += border;
- height -= border * 2;
+ y += border;
+ height -= border * 2;
}
border = 0;
}
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
if (!texImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims);
}
else {
GLint srcX = x, srcY = y, dstX = 0, dstY = 0, dstZ = 0;
border, false);
}
+
static void
copyteximage_no_error(struct gl_context *ctx, GLuint dims, GLenum target,
GLint level, GLenum internalFormat, GLint x, GLint y,
}
-
void GLAPIENTRY
_mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
GLint x, GLint y, GLsizei width, GLsizei height,
void GLAPIENTRY
-_mesa_CopyTexSubImage1D( GLenum target, GLint level,
- GLint xoffset, GLint x, GLint y, GLsizei width )
+_mesa_CopyTexSubImage1D(GLenum target, GLint level,
+ GLint xoffset, GLint x, GLint y, GLsizei width)
{
struct gl_texture_object* texObj;
const char *self = "glCopyTexSubImage1D";
x, y, width, 1, self);
}
+
void GLAPIENTRY
-_mesa_CopyTexSubImage2D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint x, GLint y, GLsizei width, GLsizei height )
+_mesa_CopyTexSubImage2D(GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height)
{
struct gl_texture_object* texObj;
const char *self = "glCopyTexSubImage2D";
}
-
void GLAPIENTRY
-_mesa_CopyTexSubImage3D( GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLint x, GLint y, GLsizei width, GLsizei height )
+_mesa_CopyTexSubImage3D(GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height)
{
struct gl_texture_object* texObj;
const char *self = "glCopyTexSubImage3D";
zoffset, x, y, width, height, self);
}
+
void GLAPIENTRY
_mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
GLint xoffset, GLint x, GLint y, GLsizei width)
0, x, y, width, 1, self);
}
+
void GLAPIENTRY
_mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
GLint xoffset, GLint yoffset,
}
-
void GLAPIENTRY
_mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
x, y, width, 1);
}
+
void GLAPIENTRY
_mesa_CopyTexSubImage2D_no_error(GLenum target, GLint level, GLint xoffset,
GLint yoffset, GLint x, GLint y, GLsizei width,
yoffset, 0, x, y, width, height);
}
+
void GLAPIENTRY
_mesa_CopyTexSubImage3D_no_error(GLenum target, GLint level, GLint xoffset,
GLint yoffset, GLint zoffset, GLint x, GLint y,
yoffset, zoffset, x, y, width, height);
}
+
void GLAPIENTRY
_mesa_CopyTextureSubImage1D_no_error(GLuint texture, GLint level, GLint xoffset,
GLint x, GLint y, GLsizei width)
xoffset, 0, 0, x, y, width, 1);
}
+
void GLAPIENTRY
_mesa_CopyTextureSubImage2D_no_error(GLuint texture, GLint level, GLint xoffset,
GLint yoffset, GLint x, GLint y,
xoffset, yoffset, 0, x, y, width, height);
}
+
void GLAPIENTRY
_mesa_CopyTextureSubImage3D_no_error(GLuint texture, GLint level, GLint xoffset,
GLint yoffset, GLint zoffset, GLint x,
return true;
}
+
static struct gl_texture_object *
get_tex_obj_for_clear(struct gl_context *ctx,
const char *function,
return numFaces;
}
+
void GLAPIENTRY
-_mesa_ClearTexSubImage( GLuint texture, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, const void *data )
+_mesa_ClearTexSubImage(GLuint texture, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, const void *data)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_texture_object *texObj;
}
if (numImages == 1) {
- if (check_clear_tex_image(ctx, "glClearTexSubImage",
- texImages[0],
+ if (check_clear_tex_image(ctx, "glClearTexSubImage", texImages[0],
format, type, data, clearValue[0])) {
ctx->Driver.ClearTexSubImage(ctx,
texImages[0],
/* loop over cube face images */
for (i = zoffset; i < zoffset + depth; i++) {
assert(i < MAX_FACES);
- if (!check_clear_tex_image(ctx, "glClearTexSubImage",
- texImages[i],
+ if (!check_clear_tex_image(ctx, "glClearTexSubImage", texImages[i],
format, type, data, clearValue[i]))
goto out;
}
_mesa_unlock_texture(ctx, texObj);
}
+
void GLAPIENTRY
_mesa_ClearTexImage( GLuint texture, GLint level,
GLenum format, GLenum type, const void *data )
texObj, level, texImages);
for (i = 0; i < numImages; i++) {
- if (!check_clear_tex_image(ctx, "glClearTexImage",
- texImages[i],
- format, type, data,
- clearValue[i]))
+ if (!check_clear_tex_image(ctx, "glClearTexImage", texImages[i], format,
+ type, data, clearValue[i]))
goto out;
}
*/
static GLboolean
compressed_subtexture_target_check(struct gl_context *ctx, GLenum target,
- GLint dims, GLenum format, bool dsa,
+ GLint dims, GLenum intFormat, bool dsa,
const char *caller)
{
GLboolean targetOK;
+ mesa_format format;
+ enum mesa_format_layout layout;
if (dsa && target == GL_TEXTURE_RECTANGLE) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", caller,
* which is (at this time) only bptc. Otherwise we'd say s3tc (and
* more) are valid here, which they are not, but of course not
* mentioned by core spec.
+ *
+ * Also, from GL_KHR_texture_compression_astc_{hdr,ldr}:
+ *
+ * "Add a second new column "3D Tex." which is empty for all non-ASTC
+ * formats. If only the LDR profile is supported by the implementation,
+ * this column is also empty for all ASTC formats. If both the LDR and HDR
+ * profiles are supported, this column is checked for all ASTC formats."
+ *
+ * "An INVALID_OPERATION error is generated by CompressedTexSubImage3D if
+ * <format> is one of the formats in table 8.19 and <target> is not
+ * TEXTURE_2D_ARRAY, TEXTURE_CUBE_MAP_ARRAY, or TEXTURE_3D.
+ *
+ * An INVALID_OPERATION error is generated by CompressedTexSubImage3D if
+ * <format> is TEXTURE_CUBE_MAP_ARRAY and the "Cube Map Array" column of
+ * table 8.19 is *not* checked, or if <format> is TEXTURE_3D and the "3D
+ * Tex." column of table 8.19 is *not* checked"
+ *
+ * And from GL_KHR_texture_compression_astc_sliced_3d:
+ *
+ * "Modify the "3D Tex." column to be checked for all ASTC formats."
*/
- switch (format) {
- /* These are the only 3D compression formats supported at this time */
- case GL_COMPRESSED_RGBA_BPTC_UNORM:
- case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
- case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
- case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
+ format = _mesa_glenum_to_compressed_format(intFormat);
+ layout = _mesa_get_format_layout(format);
+ switch (layout) {
+ case MESA_FORMAT_LAYOUT_BPTC:
/* valid format */
break;
+ case MESA_FORMAT_LAYOUT_ASTC:
+ targetOK =
+ ctx->Extensions.KHR_texture_compression_astc_hdr ||
+ ctx->Extensions.KHR_texture_compression_astc_sliced_3d;
+ break;
default:
/* invalid format */
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(invalid target %s for format %s)", caller,
_mesa_enum_to_string(target),
- _mesa_enum_to_string(format));
+ _mesa_enum_to_string(intFormat));
return GL_TRUE;
}
break;
/* this will catch any invalid compressed format token */
if (!_mesa_is_compressed_format(ctx, format)) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "%s(format)", callerName);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(format)", callerName);
return GL_TRUE;
}
if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(level=%d)",
- callerName, level);
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(level=%d)", callerName, level);
return GL_TRUE;
}
expectedSize = compressed_tex_size(width, height, depth, format);
if (expectedSize != imageSize) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "%s(size=%d)",
- callerName, imageSize);
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(size=%d)", callerName, imageSize);
return GL_TRUE;
}
texImage = _mesa_select_tex_image(texObj, target, level);
if (!texImage) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(invalid texture image)",
- callerName);
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture level %d)",
+ callerName, level);
return GL_TRUE;
}
if ((GLint) format != texImage->InternalFormat) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(format=%s)",
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(format=%s)",
callerName, _mesa_enum_to_string(format));
return GL_TRUE;
}
if (compressedteximage_only_format(ctx, format)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(format=%s cannot be updated)",
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(format=%s cannot be updated)",
callerName, _mesa_enum_to_string(format));
return GL_TRUE;
}
- if (error_check_subtexture_negative_dimensions(ctx, dims,
- width, height, depth,
- callerName)) {
+ if (error_check_subtexture_negative_dimensions(ctx, dims, width, height,
+ depth, callerName)) {
return GL_TRUE;
}
- if (error_check_subtexture_dimensions(ctx, dims,
- texImage, xoffset, yoffset, zoffset,
- width, height, depth,
+ if (error_check_subtexture_dimensions(ctx, dims, texImage, xoffset, yoffset,
+ zoffset, width, height, depth,
callerName)) {
return GL_TRUE;
}
const GLvoid *data, bool dsa, bool no_error,
const char *caller)
{
- struct gl_texture_object *texObj;
+ struct gl_texture_object *texObj = NULL;
struct gl_texture_image *texImage;
GET_CURRENT_CONTEXT(ctx);
}
/* Copy in each face. */
- for (int i = 0; i < 6; ++i) {
+ for (int i = zoffset; i < zoffset + depth; ++i) {
texImage = texObj->Image[i][level];
assert(texImage);
compressed_texture_sub_image(ctx, 3, texObj, texImage,
texObj->Target, level, xoffset, yoffset,
- zoffset, width, height, 1, format,
+ 0, width, height, 1, format,
imageSize, pixels);
/* Compressed images don't have a client format */
}
GLboolean
-_mesa_is_renderable_texture_format(struct gl_context *ctx, GLenum internalformat)
+_mesa_is_renderable_texture_format(const struct gl_context *ctx,
+ GLenum internalformat)
{
/* Everything that is allowed for renderbuffers,
* except for a base format of GL_STENCIL_INDEX, unless supported.
static void
texture_image_multisample(struct gl_context *ctx, GLuint dims,
struct gl_texture_object *texObj,
+ struct gl_memory_object *memObj,
GLenum target, GLsizei samples,
GLint internalformat, GLsizei width,
GLsizei height, GLsizei depth,
GLboolean fixedsamplelocations,
- GLboolean immutable, const char *func)
+ GLboolean immutable, GLuint64 offset,
+ const char *func)
{
struct gl_texture_image *texImage;
GLboolean sizeOK, dimensionsOK, samplesOK;
}
if (!check_multisample_target(dims, target, dsa)) {
- if (dsa) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(target)", func);
- return;
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func);
- return;
- }
+ GLenum err = dsa ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
+ _mesa_error(ctx, err, "%s(target=%s)", func,
+ _mesa_enum_to_string(target));
+ return;
}
/* check that the specified internalformat is color/depth/stencil-renderable;
* However, if samples is not supported, then no error is generated.
*/
if (!samplesOK && !_mesa_is_proxy_texture(target)) {
- _mesa_error(ctx, sample_count_error, "%s(samples)", func);
+ _mesa_error(ctx, sample_count_error, "%s(samples=%d)", func, samples);
return;
}
samples, fixedsamplelocations);
if (width > 0 && height > 0 && depth > 0) {
- if (!ctx->Driver.AllocTextureStorage(ctx, texObj, 1,
- width, height, depth)) {
- /* tidy up the texture image state. strictly speaking,
- * we're allowed to just leave this in whatever state we
- * like, but being tidy is good.
- */
- _mesa_init_teximage_fields(ctx, texImage,
- 0, 0, 0, 0, internalformat, texFormat);
+ if (memObj) {
+ if (!ctx->Driver.SetTextureStorageForMemoryObject(ctx, texObj,
+ memObj, 1, width,
+ height, depth,
+ offset)) {
+
+ _mesa_init_teximage_fields(ctx, texImage, 0, 0, 0, 0,
+ internalformat, texFormat);
+ }
+ } else {
+ if (!ctx->Driver.AllocTextureStorage(ctx, texObj, 1,
+ width, height, depth)) {
+ /* tidy up the texture image state. strictly speaking,
+ * we're allowed to just leave this in whatever state we
+ * like, but being tidy is good.
+ */
+ _mesa_init_teximage_fields(ctx, texImage, 0, 0, 0, 0,
+ internalformat, texFormat);
+ }
}
}
if (!texObj)
return;
- texture_image_multisample(ctx, 2, texObj, target, samples,
+ texture_image_multisample(ctx, 2, texObj, NULL, target, samples,
internalformat, width, height, 1,
- fixedsamplelocations, GL_FALSE,
+ fixedsamplelocations, GL_FALSE, 0,
"glTexImage2DMultisample");
}
if (!texObj)
return;
- texture_image_multisample(ctx, 3, texObj, target, samples,
+ texture_image_multisample(ctx, 3, texObj, NULL, target, samples,
internalformat, width, height, depth,
- fixedsamplelocations, GL_FALSE,
+ fixedsamplelocations, GL_FALSE, 0,
"glTexImage3DMultisample");
}
if (!valid_texstorage_ms_parameters(width, height, 1, samples, 2))
return;
- texture_image_multisample(ctx, 2, texObj, target, samples,
+ texture_image_multisample(ctx, 2, texObj, NULL, target, samples,
internalformat, width, height, 1,
- fixedsamplelocations, GL_TRUE,
+ fixedsamplelocations, GL_TRUE, 0,
"glTexStorage2DMultisample");
}
if (!valid_texstorage_ms_parameters(width, height, depth, samples, 3))
return;
- texture_image_multisample(ctx, 3, texObj, target, samples,
+ texture_image_multisample(ctx, 3, texObj, NULL, target, samples,
internalformat, width, height, depth,
- fixedsamplelocations, GL_TRUE,
+ fixedsamplelocations, GL_TRUE, 0,
"glTexStorage3DMultisample");
}
if (!valid_texstorage_ms_parameters(width, height, 1, samples, 2))
return;
- texture_image_multisample(ctx, 2, texObj, texObj->Target, samples,
- internalformat, width, height, 1,
- fixedsamplelocations, GL_TRUE,
+ texture_image_multisample(ctx, 2, texObj, NULL, texObj->Target,
+ samples, internalformat, width, height, 1,
+ fixedsamplelocations, GL_TRUE, 0,
"glTextureStorage2DMultisample");
}
if (!valid_texstorage_ms_parameters(width, height, depth, samples, 3))
return;
- texture_image_multisample(ctx, 3, texObj, texObj->Target, samples,
+ texture_image_multisample(ctx, 3, texObj, NULL, texObj->Target, samples,
internalformat, width, height, depth,
- fixedsamplelocations, GL_TRUE,
+ fixedsamplelocations, GL_TRUE, 0,
"glTextureStorage3DMultisample");
}
+
+void
+_mesa_texture_storage_ms_memory(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_object *texObj,
+ struct gl_memory_object *memObj,
+ GLenum target, GLsizei samples,
+ GLenum internalFormat, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLboolean fixedSampleLocations,
+ GLuint64 offset, const char* func)
+{
+ assert(memObj);
+
+ texture_image_multisample(ctx, dims, texObj, memObj, target, samples,
+ internalFormat, width, height, depth,
+ fixedSampleLocations, GL_TRUE, offset,
+ func);
+}