summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/vdpau.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-01-15 09:31:18 -0800
committerJason Ekstrand <[email protected]>2015-01-15 13:21:27 -0800
commit153b8b35257fb5d68735b5e43e48b0cdb8b15170 (patch)
tree05db6c87edc7a57a0b7b3457a35448962b4c1c76 /src/mesa/main/vdpau.c
parent4c99e3ae78ed3524d188f00b558f803a943aaa00 (diff)
util/hash_set: Rework the API to know about hashing
Previously, the set API required the user to do all of the hashing of keys as it passed them in. Since the hashing function is intrinsically tied to the comparison function, it makes sense for the hash set to know about it. Also, it makes for a somewhat clumsy API as the user is constantly calling hashing functions many of which have long names. This is especially bad when the standard call looks something like _mesa_set_add(ht, _mesa_pointer_hash(key), key); In the above case, there is no reason why the hash set shouldn't do the hashing for you. We leave the option for you to do your own hashing if it's more efficient, but it's no longer needed. Also, if you do do your own hashing, the hash set will assert that your hash matches what it expects out of the hashing function. This should make it harder to mess up your hashing. This is analygous to 94303a0750 where we did this for hash_table Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/main/vdpau.c')
-rw-r--r--src/mesa/main/vdpau.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/mesa/main/vdpau.c b/src/mesa/main/vdpau.c
index 89d731b6e74..0efa56e4f41 100644
--- a/src/mesa/main/vdpau.c
+++ b/src/mesa/main/vdpau.c
@@ -73,7 +73,8 @@ _mesa_VDPAUInitNV(const GLvoid *vdpDevice, const GLvoid *getProcAddress)
ctx->vdpDevice = vdpDevice;
ctx->vdpGetProcAddress = getProcAddress;
- ctx->vdpSurfaces = _mesa_set_create(NULL, _mesa_key_pointer_equal);
+ ctx->vdpSurfaces = _mesa_set_create(NULL, _mesa_hash_pointer,
+ _mesa_key_pointer_equal);
}
static void
@@ -179,7 +180,7 @@ register_surface(struct gl_context *ctx, GLboolean isOutput,
_mesa_reference_texobj(&surf->textures[i], tex);
}
- _mesa_set_add(ctx->vdpSurfaces, _mesa_hash_pointer(surf), surf);
+ _mesa_set_add(ctx->vdpSurfaces, surf);
return (GLintptr)surf;
}
@@ -227,7 +228,7 @@ _mesa_VDPAUIsSurfaceNV(GLintptr surface)
return false;
}
- if (!_mesa_set_search(ctx->vdpSurfaces, _mesa_hash_pointer(surf), surf)) {
+ if (!_mesa_set_search(ctx->vdpSurfaces, surf)) {
return false;
}
@@ -251,7 +252,7 @@ _mesa_VDPAUUnregisterSurfaceNV(GLintptr surface)
if (surface == 0)
return;
- entry = _mesa_set_search(ctx->vdpSurfaces, _mesa_hash_pointer(surf), surf);
+ entry = _mesa_set_search(ctx->vdpSurfaces, surf);
if (!entry) {
_mesa_error(ctx, GL_INVALID_VALUE, "VDPAUUnregisterSurfaceNV");
return;
@@ -280,7 +281,7 @@ _mesa_VDPAUGetSurfaceivNV(GLintptr surface, GLenum pname, GLsizei bufSize,
return;
}
- if (!_mesa_set_search(ctx->vdpSurfaces, _mesa_hash_pointer(surf), surf)) {
+ if (!_mesa_set_search(ctx->vdpSurfaces, surf)) {
_mesa_error(ctx, GL_INVALID_VALUE, "VDPAUGetSurfaceivNV");
return;
}
@@ -312,7 +313,7 @@ _mesa_VDPAUSurfaceAccessNV(GLintptr surface, GLenum access)
return;
}
- if (!_mesa_set_search(ctx->vdpSurfaces, _mesa_hash_pointer(surf), surf)) {
+ if (!_mesa_set_search(ctx->vdpSurfaces, surf)) {
_mesa_error(ctx, GL_INVALID_VALUE, "VDPAUSurfaceAccessNV");
return;
}
@@ -346,7 +347,7 @@ _mesa_VDPAUMapSurfacesNV(GLsizei numSurfaces, const GLintptr *surfaces)
for (i = 0; i < numSurfaces; ++i) {
struct vdp_surface *surf = (struct vdp_surface *)surfaces[i];
- if (!_mesa_set_search(ctx->vdpSurfaces, _mesa_hash_pointer(surf), surf)) {
+ if (!_mesa_set_search(ctx->vdpSurfaces, surf)) {
_mesa_error(ctx, GL_INVALID_VALUE, "VDPAUSurfaceAccessNV");
return;
}
@@ -400,7 +401,7 @@ _mesa_VDPAUUnmapSurfacesNV(GLsizei numSurfaces, const GLintptr *surfaces)
for (i = 0; i < numSurfaces; ++i) {
struct vdp_surface *surf = (struct vdp_surface *)surfaces[i];
- if (!_mesa_set_search(ctx->vdpSurfaces, _mesa_hash_pointer(surf), surf)) {
+ if (!_mesa_set_search(ctx->vdpSurfaces, surf)) {
_mesa_error(ctx, GL_INVALID_VALUE, "VDPAUSurfaceAccessNV");
return;
}