diff options
author | Chris Forbes <[email protected]> | 2014-01-21 22:54:10 +1300 |
---|---|---|
committer | Chris Forbes <[email protected]> | 2014-04-10 18:27:41 +1200 |
commit | b7f011fdc9007c35921f6271b983ef4ccc6799e4 (patch) | |
tree | 9d1d5f0de8625edfb4ceda154bad1a5aa4be22aa | |
parent | 93fa16bdd13e67bc3a824bf3408f207c4ff0e894 (diff) |
i965: Add driver hook for TextureView
We need to wire the original texture's mt into the view. All the hard
work of setting up an appropriate tree of gl_texture_image structures
has already been done by core mesa.
Signed-off-by: Chris Forbes <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Acked-by: Eric Anholt <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_tex.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_tex.c b/src/mesa/drivers/dri/i965/intel_tex.c index 0e08aab5633..3b14796d844 100644 --- a/src/mesa/drivers/dri/i965/intel_tex.c +++ b/src/mesa/drivers/dri/i965/intel_tex.c @@ -237,6 +237,46 @@ intel_unmap_texture_image(struct gl_context *ctx, intel_miptree_unmap(brw, mt, tex_image->Level, slice); } +static GLboolean +intel_texture_view(struct gl_context *ctx, + struct gl_texture_object *texObj, + struct gl_texture_object *origTexObj) +{ + struct intel_texture_object *intel_tex = intel_texture_object(texObj); + struct intel_texture_object *intel_orig_tex = intel_texture_object(origTexObj); + + assert(intel_orig_tex->mt); + intel_miptree_reference(&intel_tex->mt, intel_orig_tex->mt); + + /* Since we can only make views of immutable-format textures, + * we can assume that everything is in origTexObj's miptree. + * + * Mesa core has already made us a copy of all the teximage objects, + * except it hasn't copied our mt pointers, etc. + */ + const int numFaces = _mesa_num_tex_faces(texObj->Target); + const int numLevels = texObj->NumLevels; + + int face; + int level; + + for (face = 0; face < numFaces; face++) { + for (level = 0; level < numLevels; level++) { + struct gl_texture_image *image = texObj->Image[face][level]; + struct intel_texture_image *intel_image = intel_texture_image(image); + + intel_miptree_reference(&intel_image->mt, intel_orig_tex->mt); + } + } + + /* The miptree is in a validated state, so no need to check later. */ + intel_tex->needs_validate = false; + intel_tex->validated_first_level = 0; + intel_tex->validated_last_level = numLevels - 1; + + return GL_TRUE; +} + void intelInitTextureFuncs(struct dd_function_table *functions) { @@ -249,4 +289,5 @@ intelInitTextureFuncs(struct dd_function_table *functions) functions->AllocTextureStorage = intel_alloc_texture_storage; functions->MapTextureImage = intel_map_texture_image; functions->UnmapTextureImage = intel_unmap_texture_image; + functions->TextureView = intel_texture_view; } |