summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2020-03-06 20:19:11 -0500
committerMarge Bot <eric+marge@anholt.net>2020-04-30 22:01:55 +0000
commita82889e53733ffe11bf3c7a8be5fe53e382d02aa (patch)
tree53ff287d840afde84979646614e83b1a22cb46a6
parent3707cef4fb3c4a2f5e015ea2525fcd41d8875f0b (diff)
mesa: add glInternalBufferSubDataCopyMESA for glthread
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4314>
-rw-r--r--src/mapi/glapi/gen/gl_API.xml13
-rw-r--r--src/mapi/glapi/gen/gl_marshal.py1
-rw-r--r--src/mapi/glapi/gen/static_data.py1
-rw-r--r--src/mesa/main/bufferobj.c41
-rw-r--r--src/mesa/main/bufferobj.h5
-rw-r--r--src/mesa/main/tests/dispatch_sanity.cpp4
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c2
7 files changed, 66 insertions, 1 deletions
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index d421e778091..4477f5833e3 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -13286,6 +13286,19 @@
</function>
</category>
+<category name="GL_MESA_internal_functions">
+ <!-- Internal function for glthread to implement BufferSubData as a GPU copy. -->
+ <function name="InternalBufferSubDataCopyMESA" es2="2.0">
+ <param name="srcBuffer" type="GLintptr"/> <!-- "struct gl_buffer_object *" really -->
+ <param name="srcOffset" type="GLuint"/>
+ <param name="dstTargetOrName" type="GLuint"/>
+ <param name="dstOffset" type="GLintptr"/>
+ <param name="size" type="GLsizeiptr"/>
+ <param name="named" type="GLboolean"/>
+ <param name="ext_dsa" type="GLboolean"/>
+ </function>
+</category>
+
<xi:include href="OES_EGL_image.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="EXT_EGL_image_storage.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py
index 656381a0513..29032645fce 100644
--- a/src/mapi/glapi/gen/gl_marshal.py
+++ b/src/mapi/glapi/gen/gl_marshal.py
@@ -32,6 +32,7 @@ import sys
header = """
#include "api_exec.h"
#include "glthread_marshal.h"
+#include "bufferobj.h"
#include "dispatch.h"
#define COMPAT (ctx->API != API_OPENGL_CORE)
diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py
index 9b15e329be9..27651b3efef 100644
--- a/src/mapi/glapi/gen/static_data.py
+++ b/src/mapi/glapi/gen/static_data.py
@@ -1643,6 +1643,7 @@ offsets = {
"CopyImageSubDataNV": 1607,
"ViewportSwizzleNV": 1608,
"AlphaToCoverageDitherControlNV": 1609,
+ "InternalBufferSubDataCopyMESA": 1610,
}
functions = [
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index c8116cfda53..40118d261b9 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -3159,6 +3159,47 @@ _mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer,
"glCopyNamedBufferSubData");
}
+void GLAPIENTRY
+_mesa_InternalBufferSubDataCopyMESA(GLintptr srcBuffer, GLuint srcOffset,
+ GLuint dstTargetOrName, GLintptr dstOffset,
+ GLsizeiptr size, GLboolean named,
+ GLboolean ext_dsa)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *src = (struct gl_buffer_object *)srcBuffer;
+ struct gl_buffer_object *dst;
+ const char *func;
+
+ /* Handle behavior for all 3 variants. */
+ if (named && ext_dsa) {
+ func = "glNamedBufferSubDataEXT";
+ dst = _mesa_lookup_bufferobj(ctx, dstTargetOrName);
+ if (!_mesa_handle_bind_buffer_gen(ctx, dstTargetOrName, &dst, func))
+ goto done;
+ } else if (named) {
+ func = "glNamedBufferSubData";
+ dst = _mesa_lookup_bufferobj_err(ctx, dstTargetOrName, func);
+ if (!dst)
+ goto done;
+ } else {
+ assert(!ext_dsa);
+ func = "glBufferSubData";
+ dst = get_buffer(ctx, func, dstTargetOrName, GL_INVALID_OPERATION);
+ if (!dst)
+ goto done;
+ }
+
+ if (!validate_buffer_sub_data(ctx, dst, dstOffset, size, func))
+ goto done; /* the error is already set */
+
+ dst->MinMaxCacheDirty = true;
+ ctx->Driver.CopyBufferSubData(ctx, src, dst, srcOffset, dstOffset, size);
+
+done:
+ /* The caller passes the reference to this function, so unreference it. */
+ _mesa_reference_buffer_object(ctx, &src, NULL);
+}
+
static bool
validate_map_buffer_range(struct gl_context *ctx,
struct gl_buffer_object *bufObj, GLintptr offset,
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index d1291677222..9a22d4de440 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -359,6 +359,11 @@ void GLAPIENTRY
_mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer,
GLintptr readOffset, GLintptr writeOffset,
GLsizeiptr size);
+void GLAPIENTRY
+_mesa_InternalBufferSubDataCopyMESA(GLintptr srcBuffer, GLuint srcOffset,
+ GLuint dstTargetOrName, GLintptr dstOffset,
+ GLsizeiptr size, GLboolean named,
+ GLboolean ext_dsa);
void * GLAPIENTRY
_mesa_MapBufferRange_no_error(GLenum target, GLintptr offset,
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 6ff28309c6d..7c29833131a 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -1442,6 +1442,8 @@ const struct function common_desktop_functions_possible[] = {
/* GL_NV_viewport_swizzle */
{ "glViewportSwizzleNV", 11, -1 },
+ { "glInternalBufferSubDataCopyMESA", 11, -1 },
+
{ NULL, 0, -1 }
};
@@ -2457,6 +2459,8 @@ const struct function gles2_functions_possible[] = {
/* GL_KHR_parallel_shader_compile */
{ "glMaxShaderCompilerThreadsKHR", 20, -1 },
+ { "glInternalBufferSubDataCopyMESA", 20, -1 },
+
{ NULL, 0, -1 }
};
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 33778df0afa..01422bb7908 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -605,7 +605,7 @@ st_copy_buffer_subdata(struct gl_context *ctx,
/* buffer should not already be mapped */
assert(!_mesa_check_disallowed_mapping(src));
- assert(!_mesa_check_disallowed_mapping(dst));
+ /* dst can be mapped, just not the same range as the target range */
u_box_1d(readOffset, size, &box);