[Mesa-dev] [PATCH 5/7] mesa: implement glBindSamplers()

Maxence Le Doré maxence.ledore at gmail.com
Thu Jan 2 16:27:35 PST 2014


---
 src/mesa/main/samplerobj.c | 36 ++++++++++++++++++++++++++++++++++++
 src/mesa/main/samplerobj.h |  2 ++
 2 files changed, 38 insertions(+)

diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 7285ef5..a219630 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -1434,6 +1434,42 @@ invalid_pname:
 }
 
 
+void GLAPIENTRY
+_mesa_BindSamplers(GLuint first, GLsizei count, const GLuint *samplers)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   int i = 0;
+
+   if(first + count > ctx->Const.MaxCombinedTextureImageUnits) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glBindSamplers(first+count)");
+      return;
+   }
+
+   for (i = 0; i < count; i++) {
+      GLuint sampler;
+      struct gl_sampler_object *sampObj;
+
+      if(samplers == NULL)
+        sampler = 0;
+      else
+        sampler = samplers[i];
+
+      if(sampler != 0) {
+        sampObj = _mesa_lookup_samplerobj(ctx, sampler);
+        if(sampler)
+          _mesa_BindSampler(first + i, sampler);
+        else
+          _mesa_error(ctx, GL_INVALID_VALUE,
+                      "glBindSamplers(samplers[%i]=%u is invalid)",
+                      i, sampler);
+        }
+      else
+        _mesa_BindSampler(first + i, 0);
+      }
+   }
+}
+
+
 void
 _mesa_init_sampler_object_functions(struct dd_function_table *driver)
 {
diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index c72b1cd..0e030d3 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -100,5 +100,7 @@ void GLAPIENTRY
 _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params);
 void GLAPIENTRY
 _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params);
+void GLAPIENTRY
+_mesa_BindSamplers(GLuint first, GLsizei count, const GLuint *samplers);
 
 #endif /* SAMPLEROBJ_H */
-- 
1.8.5.2



More information about the mesa-dev mailing list