aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-07-21 11:51:47 +0200
committerSamuel Pitoiset <[email protected]>2017-08-02 12:54:31 +0200
commit589450c4a2aec2482136b25fd7be0fa596731da4 (patch)
treee547ccd34a4ad9207135bebb1ef3fbf89304319f /src/mesa
parentc8191213b5572a1e00d6c1da5fcf73aa3b304f02 (diff)
mesa: add clear_buffer_sub_data_error() helper
And make clear_buffer_sub_data() always inline. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/bufferobj.c52
1 files changed, 35 insertions, 17 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 2d1b652dfc0..61f680cf315 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -2270,31 +2270,35 @@ _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
/**
* \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);
@@ -2323,6 +2327,17 @@ clear_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
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)
@@ -2334,8 +2349,8 @@ _mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format,
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
@@ -2349,8 +2364,9 @@ _mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat,
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);
}
@@ -2367,8 +2383,9 @@ _mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
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
@@ -2385,8 +2402,9 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
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