/**
* \param subdata true if caller is *SubData, false if *Data
*/
-static void
+static ALWAYS_INLINE void
clear_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
GLenum internalformat, GLintptr offset, GLsizeiptr size,
GLenum format, GLenum type, const GLvoid *data,
- const char *func, bool subdata)
+ const char *func, bool subdata, bool no_error)
{
mesa_format mesaFormat;
GLubyte clearValue[MAX_PIXEL_BYTES];
GLsizeiptr clearValueSize;
/* This checks for disallowed mappings. */
- if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size,
- subdata, func)) {
+ if (!no_error && !buffer_object_subdata_range_good(ctx, bufObj, offset, size,
+ subdata, func)) {
return;
}
- mesaFormat = validate_clear_buffer_format(ctx, internalformat,
- format, type, func);
+ if (no_error) {
+ mesaFormat = _mesa_get_texbuffer_format(ctx, internalformat);
+ } else {
+ mesaFormat = validate_clear_buffer_format(ctx, internalformat,
+ format, type, func);
+ }
- if (mesaFormat == MESA_FORMAT_NONE) {
+ if (mesaFormat == MESA_FORMAT_NONE)
return;
- }
clearValueSize = _mesa_get_format_bytes(mesaFormat);
- if (offset % clearValueSize != 0 || size % clearValueSize != 0) {
+ if (!no_error &&
+ (offset % clearValueSize != 0 || size % clearValueSize != 0)) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(offset or size is not a multiple of "
"internalformat size)", func);
clearValue, clearValueSize, bufObj);
}
+static void
+clear_buffer_sub_data_error(struct gl_context *ctx,
+ struct gl_buffer_object *bufObj,
+ GLenum internalformat, GLintptr offset,
+ GLsizeiptr size, GLenum format, GLenum type,
+ const GLvoid *data, const char *func, bool subdata)
+{
+ clear_buffer_sub_data(ctx, bufObj, internalformat, offset, size, format,
+ type, data, func, subdata, false);
+}
+
void GLAPIENTRY
_mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format,
GLenum type, const GLvoid *data)
if (!bufObj)
return;
- clear_buffer_sub_data(ctx, bufObj, internalformat, 0, bufObj->Size,
- format, type, data, "glClearBufferData", false);
+ clear_buffer_sub_data_error(ctx, bufObj, internalformat, 0, bufObj->Size,
+ format, type, data, "glClearBufferData", false);
}
void GLAPIENTRY
if (!bufObj)
return;
- clear_buffer_sub_data(ctx, bufObj, internalformat, 0, bufObj->Size,
- format, type, data, "glClearNamedBufferData", false);
+ clear_buffer_sub_data_error(ctx, bufObj, internalformat, 0, bufObj->Size,
+ format, type, data, "glClearNamedBufferData",
+ false);
}
if (!bufObj)
return;
- clear_buffer_sub_data(ctx, bufObj, internalformat, offset, size,
- format, type, data, "glClearBufferSubData", true);
+ clear_buffer_sub_data_error(ctx, bufObj, internalformat, offset, size,
+ format, type, data, "glClearBufferSubData",
+ true);
}
void GLAPIENTRY
if (!bufObj)
return;
- clear_buffer_sub_data(ctx, bufObj, internalformat, offset, size, format,
- type, data, "glClearNamedBufferSubData", true);
+ clear_buffer_sub_data_error(ctx, bufObj, internalformat, offset, size,
+ format, type, data, "glClearNamedBufferSubData",
+ true);
}
static GLboolean