verts[3].tex[1] = tex->Ttop;
/* upload new vertex data */
- _mesa_buffer_sub_data(ctx, copypix->buf_obj, 0, sizeof(verts), verts,
- __func__);
+ _mesa_buffer_sub_data(ctx, copypix->buf_obj, 0, sizeof(verts), verts);
}
_mesa_set_enable(ctx, tex->Target, GL_TRUE);
}
/* upload new vertex data */
- _mesa_buffer_sub_data(ctx, bitmap->buf_obj, 0, sizeof(verts), verts,
- __func__);
+ _mesa_buffer_sub_data(ctx, bitmap->buf_obj, 0, sizeof(verts), verts);
}
/* choose different foreground/background alpha values */
_mesa_set_viewport(ctx, 0, 0, 0, width, height);
/* upload new vertex data */
- _mesa_buffer_sub_data(ctx, decompress->buf_obj, 0, sizeof(verts), verts,
- __func__);
+ _mesa_buffer_sub_data(ctx, decompress->buf_obj, 0, sizeof(verts), verts);
/* setup texture state */
_mesa_BindTexture(target, texObj->Name);
verts[3].st[i][1] = t1;
}
- _mesa_buffer_sub_data(ctx, drawtex->buf_obj, 0, sizeof(verts), verts,
- __func__);
+ _mesa_buffer_sub_data(ctx, drawtex->buf_obj, 0, sizeof(verts), verts);
}
_mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
-/**
- * Implementation for glBufferSubData and glNamedBufferSubData.
- *
- * \param ctx GL context.
- * \param bufObj The buffer object.
- * \param offset Offset of the first byte of the subdata range.
- * \param size Size, in bytes, of the subdata range.
- * \param data The data store.
- * \param func Name of calling function for recording errors.
- *
- */
-void
-_mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
- GLintptr offset, GLsizeiptr size, const GLvoid *data,
- const char *func)
+static bool
+validate_buffer_sub_data(struct gl_context *ctx,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size,
+ const char *func)
{
if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size,
true, func)) {
/* error already recorded */
- return;
+ return false;
}
if (bufObj->Immutable &&
!(bufObj->StorageFlags & GL_DYNAMIC_STORAGE_BIT)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", func);
- return;
+ return false;
}
- if (size == 0)
- return;
-
- bufObj->NumSubDataCalls++;
-
if ((bufObj->Usage == GL_STATIC_DRAW ||
bufObj->Usage == GL_STATIC_COPY) &&
- bufObj->NumSubDataCalls >= BUFFER_WARNING_CALL_COUNT) {
+ bufObj->NumSubDataCalls >= BUFFER_WARNING_CALL_COUNT - 1) {
/* If the application declared the buffer as static draw/copy or stream
* draw, it should not be frequently modified with glBufferSubData.
*/
_mesa_enum_to_string(bufObj->Usage));
}
+ return true;
+}
+
+
+/**
+ * Implementation for glBufferSubData and glNamedBufferSubData.
+ *
+ * \param ctx GL context.
+ * \param bufObj The buffer object.
+ * \param offset Offset of the first byte of the subdata range.
+ * \param size Size, in bytes, of the subdata range.
+ * \param data The data store.
+ * \param func Name of calling function for recording errors.
+ *
+ */
+void
+_mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size, const GLvoid *data)
+{
+ if (size == 0)
+ return;
+
+ bufObj->NumSubDataCalls++;
bufObj->Written = GL_TRUE;
bufObj->MinMaxCacheDirty = true;
{
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ const char *func = "glBufferSubData";
- bufObj = get_buffer(ctx, "glBufferSubData", target, GL_INVALID_OPERATION);
+ bufObj = get_buffer(ctx, func, target, GL_INVALID_OPERATION);
if (!bufObj)
return;
- _mesa_buffer_sub_data(ctx, bufObj, offset, size, data, "glBufferSubData");
+ if (validate_buffer_sub_data(ctx, bufObj, offset, size, func))
+ _mesa_buffer_sub_data(ctx, bufObj, offset, size, data);
}
void GLAPIENTRY
{
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ const char *func = "glNamedBufferSubData";
- bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferSubData");
+ bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, func);
if (!bufObj)
return;
- _mesa_buffer_sub_data(ctx, bufObj, offset, size, data,
- "glNamedBufferSubData");
+ if (validate_buffer_sub_data(ctx, bufObj, offset, size, func))
+ _mesa_buffer_sub_data(ctx, bufObj, offset, size, data);
}