summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Pohjolainen <topi.pohjolainen@intel.com>2017-12-07 08:34:53 +0200
committerTopi Pohjolainen <topi.pohjolainen@intel.com>2017-12-12 12:26:06 +0200
commita1fa3ba8c62d11f53e5f820aadab04b3f1127840 (patch)
tree540203a55b11b32e7c57b61beca04b82a7c4fe5c
parent7be7b214bc5ec6cd7e2f886c65b9127bb9258a41 (diff)
i965: Add SetTextureStorageForMemoryObject() driver hookext_memory_object
-rw-r--r--src/mesa/drivers/dri/i965/brw_memory_obj.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_memory_obj.c b/src/mesa/drivers/dri/i965/brw_memory_obj.c
index bd1917ebe4..4bb035ace0 100644
--- a/src/mesa/drivers/dri/i965/brw_memory_obj.c
+++ b/src/mesa/drivers/dri/i965/brw_memory_obj.c
@@ -30,6 +30,8 @@
#include "brw_context.h"
#include "brw_defines.h"
#include "brw_memory_obj.h"
+#include "intel_fbo.h" /* for intel_quantize_num_samples() */
+#include "intel_mipmap_tree.h"
static struct gl_memory_object *
brw_memory_obj_alloc(struct gl_context *ctx, GLuint name)
@@ -73,9 +75,54 @@ brw_import_memory_obj_fd(struct gl_context *ctx,
close(fd);
}
+static GLboolean
+brw_tex_storage_for_mem_obj(struct gl_context *ctx,
+ struct gl_texture_object *tex_obj,
+ struct gl_memory_object *mem_obj,
+ GLsizei levels, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLuint64 offset)
+{
+ struct brw_context *brw = brw_context(ctx);
+ struct gl_texture_image *first_image = tex_obj->Image[0][0];
+ const unsigned num_samples = intel_quantize_num_samples(
+ brw->screen, first_image->NumSamples);
+ const struct intel_memory_object *intel_mem_obj =
+ (struct intel_memory_object *)mem_obj;
+ struct intel_texture_object *intel_tex_obj =
+ (struct intel_texture_object *)tex_obj;
+
+ if (intel_mem_obj->bo == NULL)
+ return FALSE;
+
+ intel_get_image_dims(first_image, &width, &height, &depth);
+
+ const enum isl_tiling tiling =
+ isl_tiling_from_i915_tiling(intel_mem_obj->bo->tiling_mode);
+ intel_tex_obj->mt = make_surface(brw, tex_obj->Target,
+ first_image->TexFormat, 0, levels - 1,
+ width, height, depth,
+ MAX2(num_samples, 1), 1 << tiling,
+ ISL_SURF_USAGE_TEXTURE_BIT, BO_ALLOC_BUSY,
+ 0, intel_mem_obj->bo);
+ if (intel_tex_obj->mt == NULL)
+ return FALSE;
+
+ brw_bo_reference(intel_mem_obj->bo);
+
+ /* The miptree is in a validated state, so no need to check later. */
+ intel_tex_obj->needs_validate = false;
+ intel_tex_obj->validated_first_level = 0;
+ intel_tex_obj->validated_last_level = levels - 1;
+ intel_tex_obj->_Format = intel_tex_obj->mt->format;
+
+ return TRUE;
+}
+
void brw_init_memory_obj_functions(struct dd_function_table *functions)
{
functions->NewMemoryObject = brw_memory_obj_alloc;
functions->DeleteMemoryObject = brw_memory_obj_free;
functions->ImportMemoryObjectFd = brw_import_memory_obj_fd;
+ functions->SetTextureStorageForMemoryObject = brw_tex_storage_for_mem_obj;
}