summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstorage.c
diff options
context:
space:
mode:
authorAndres Rodriguez <[email protected]>2017-07-12 18:45:11 -0400
committerTimothy Arceri <[email protected]>2017-08-06 12:42:06 +1000
commitfc790c50ccb060cf8d07a5be59d8b3868a627784 (patch)
treea2f660e23a932a94cd9e68985e4c08878b7a4544 /src/mesa/main/texstorage.c
parent49f4ecc67773c082d93708bdf111acc4248678da (diff)
mesa: hook up memoryobject tex(ture)storage api
V2 (Timothy Arceri): - formating fixes V3 (Timothy): - error check memory == 0 before lookup Signed-off-by: Andres Rodriguez <[email protected]> Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/mesa/main/texstorage.c')
-rw-r--r--src/mesa/main/texstorage.c76
1 files changed, 54 insertions, 22 deletions
diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c
index 7a61a4f4786..e0930abe3f8 100644
--- a/src/mesa/main/texstorage.c
+++ b/src/mesa/main/texstorage.c
@@ -304,12 +304,14 @@ _mesa_AllocTextureStorage_sw(struct gl_context *ctx,
static GLboolean
tex_storage_error_check(struct gl_context *ctx,
struct gl_texture_object *texObj,
+ struct gl_memory_object *memObj,
GLuint dims, GLenum target,
GLsizei levels, GLenum internalformat,
GLsizei width, GLsizei height, GLsizei depth,
bool dsa)
{
- const char* suffix = dsa ? "ture" : "";
+ const char* suffix = dsa ? (memObj ? "tureMem" : "ture") :
+ (memObj ? "Mem" : "");
/* Legal format checking has been moved to texstorage and texturestorage in
* order to allow meta functions to use legacy formats. */
@@ -389,18 +391,20 @@ tex_storage_error_check(struct gl_context *ctx,
static ALWAYS_INLINE void
texture_storage(struct gl_context *ctx, GLuint dims,
struct gl_texture_object *texObj,
- GLenum target, GLsizei levels,
- GLenum internalformat, GLsizei width,
- GLsizei height, GLsizei depth, bool dsa, bool no_error)
+ struct gl_memory_object *memObj, GLenum target,
+ GLsizei levels, GLenum internalformat, GLsizei width,
+ GLsizei height, GLsizei depth, GLuint64 offset, bool dsa,
+ bool no_error)
{
GLboolean sizeOK = GL_TRUE, dimensionsOK = GL_TRUE;
mesa_format texFormat;
- const char* suffix = dsa ? "ture" : "";
+ const char* suffix = dsa ? (memObj ? "tureMem" : "ture") :
+ (memObj ? "Mem" : "");
assert(texObj);
if (!no_error) {
- if (tex_storage_error_check(ctx, texObj, dims, target, levels,
+ if (tex_storage_error_check(ctx, texObj, memObj, dims, target, levels,
internalformat, width, height, depth, dsa)) {
return; /* error was recorded */
}
@@ -454,18 +458,30 @@ texture_storage(struct gl_context *ctx, GLuint dims,
return;
}
- /* Do actual texture memory allocation */
- if (!ctx->Driver.AllocTextureStorage(ctx, texObj, levels,
- width, height, depth)) {
- /* Reset the texture images' info to zeros.
- * Strictly speaking, we probably don't have to do this since
- * generating GL_OUT_OF_MEMORY can leave things in an undefined
- * state but this puts things in a consistent state.
- */
- clear_texture_fields(ctx, texObj);
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTex%sStorage%uD",
- suffix, dims);
- return;
+ /* Setup the backing memory */
+ if (memObj) {
+ if (!ctx->Driver.SetTextureStorageForMemoryObject(ctx, texObj, memObj,
+ levels,
+ width, height, depth,
+ offset)) {
+
+ clear_texture_fields(ctx, texObj);
+ return;
+ }
+ }
+ else {
+ if (!ctx->Driver.AllocTextureStorage(ctx, texObj, levels,
+ width, height, depth)) {
+ /* Reset the texture images' info to zeros.
+ * Strictly speaking, we probably don't have to do this since
+ * generating GL_OUT_OF_MEMORY can leave things in an undefined
+ * state but this puts things in a consistent state.
+ */
+ clear_texture_fields(ctx, texObj);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTex%sStorage%uD",
+ suffix, dims);
+ return;
+ }
}
_mesa_set_texture_view_state(ctx, texObj, target, levels);
@@ -482,8 +498,8 @@ texture_storage_error(struct gl_context *ctx, GLuint dims,
GLenum internalformat, GLsizei width,
GLsizei height, GLsizei depth, bool dsa)
{
- texture_storage(ctx, dims, texObj, target, levels, internalformat, width,
- height, depth, dsa, false);
+ texture_storage(ctx, dims, texObj, NULL, target, levels, internalformat,
+ width, height, depth, dsa, 0, false);
}
@@ -494,8 +510,8 @@ texture_storage_no_error(struct gl_context *ctx, GLuint dims,
GLenum internalformat, GLsizei width,
GLsizei height, GLsizei depth, bool dsa)
{
- texture_storage(ctx, dims, texObj, target, levels, internalformat, width,
- height, depth, dsa, true);
+ texture_storage(ctx, dims, texObj, NULL, target, levels, internalformat,
+ width, height, depth, dsa, 0, true);
}
@@ -784,3 +800,19 @@ _mesa_TextureStorage3DEXT(GLuint texture, GLenum target, GLsizei levels,
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTextureStorage3DEXT not supported");
}
+
+
+void
+_mesa_texture_storage_memory(struct gl_context *ctx, GLuint dims,
+ struct gl_texture_object *texObj,
+ struct gl_memory_object *memObj,
+ GLenum target, GLsizei levels,
+ GLenum internalformat, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLuint64 offset, bool dsa)
+{
+ assert(memObj);
+
+ texture_storage(ctx, dims, texObj, memObj, target, levels, internalformat,
+ width, height, depth, offset, dsa, false);
+}