summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/get.c12
-rw-r--r--src/mesa/main/samplerobj.c2
-rw-r--r--src/mesa/main/samplerobj.h2
3 files changed, 14 insertions, 2 deletions
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index e2ccc29b84..82ded7b192 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -34,6 +34,7 @@
#include "state.h"
#include "texcompress.h"
#include "framebuffer.h"
+#include "samplerobj.h"
/* This is a table driven implemetation of the glGet*v() functions.
* The basic idea is that most getters just look up an int somewhere
@@ -1837,7 +1838,16 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
{
struct gl_sampler_object *samp =
ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler;
- v->value_int = samp ? samp->Name : 0;
+
+ /*
+ * The sampler object may have been deleted on another context,
+ * so we try to lookup the sampler object before returning its Name.
+ */
+ if (samp && _mesa_lookup_samplerobj(ctx, samp->Name)) {
+ v->value_int = samp->Name;
+ } else {
+ v->value_int = 0;
+ }
}
break;
/* GL_ARB_uniform_buffer_object */
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index c746e42bb0..cb5a076615 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -40,7 +40,7 @@
#include "main/samplerobj.h"
-static struct gl_sampler_object *
+struct gl_sampler_object *
_mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name)
{
if (name == 0)
diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index e70ee4881a..2f98a41c68 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -62,6 +62,8 @@ _mesa_reference_sampler_object(struct gl_context *ctx,
_mesa_reference_sampler_object_(ctx, ptr, samp);
}
+extern struct gl_sampler_object *
+_mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name);
extern void
_mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name);