mesa: Add _mesa_set_sampler_filters method
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 9 Nov 2015 19:59:19 +0000 (11:59 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 11 Jan 2016 23:38:03 +0000 (15:38 -0800)
v2: Add filter enum assertions.  Suggested by Jason.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/mesa/main/samplerobj.c
src/mesa/main/samplerobj.h

index 17b3400526329e5aeacfdea11d41d28c9ea3b0ac..d74435eaf8bbb13b3572f7eee275f8c7cc2d2ac6 100644 (file)
@@ -509,6 +509,27 @@ set_sampler_wrap_r(struct gl_context *ctx, struct gl_sampler_object *samp,
    return INVALID_PARAM;
 }
 
+void
+_mesa_set_sampler_filters(struct gl_context *ctx,
+                          struct gl_sampler_object *samp,
+                          GLenum min_filter, GLenum mag_filter)
+{
+   assert(min_filter == GL_NEAREST ||
+          min_filter == GL_LINEAR ||
+          min_filter == GL_NEAREST_MIPMAP_NEAREST ||
+          min_filter == GL_LINEAR_MIPMAP_NEAREST ||
+          min_filter == GL_NEAREST_MIPMAP_LINEAR ||
+          min_filter == GL_LINEAR_MIPMAP_LINEAR);
+   assert(mag_filter == GL_NEAREST ||
+          mag_filter == GL_LINEAR);
+
+   if (samp->MinFilter == min_filter && samp->MagFilter == mag_filter)
+      return;
+
+   flush(ctx);
+   samp->MinFilter = min_filter;
+   samp->MagFilter = mag_filter;
+}
 
 static GLuint
 set_sampler_min_filter(struct gl_context *ctx, struct gl_sampler_object *samp,
index 1817c1a4468a9a42acc38bc118b649cf5c95e193..c35052e0ac36567f0836259aeb933bd9a99dd831 100644 (file)
@@ -84,6 +84,11 @@ extern void
 _mesa_set_sampler_wrap(struct gl_context *ctx, struct gl_sampler_object *samp,
                        GLenum s, GLenum t, GLenum r);
 
+extern void
+_mesa_set_sampler_filters(struct gl_context *ctx,
+                          struct gl_sampler_object *samp,
+                          GLenum min_filter, GLenum mag_filter);
+
 void GLAPIENTRY
 _mesa_GenSamplers(GLsizei count, GLuint *samplers);
 void GLAPIENTRY