1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/*
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Mesa 3-D graphics library
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright (C) 2011  VMware, Inc.  All Rights Reserved.
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the "Software"),
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to deal in the Software without restriction, including without limitation
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and/or sell copies of the Software, and to permit persons to whom the
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Software is furnished to do so, subject to the following conditions:
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice shall be included
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * in all copies or substantial portions of the Software.
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef SAMPLEROBJ_H
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define SAMPLEROBJ_H
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct dd_function_table;
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic inline struct gl_sampler_object *
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_get_samplerobj(struct gl_context *ctx, GLuint unit)
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (ctx->Texture.Unit[unit].Sampler)
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return ctx->Texture.Unit[unit].Sampler;
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   else if (ctx->Texture.Unit[unit]._Current)
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return &ctx->Texture.Unit[unit]._Current->Sampler;
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   else
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      return NULL;
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** Does the given filter state do mipmap filtering? */
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic inline GLboolean
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_is_mipmap_filter(const struct gl_sampler_object *samp)
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   return samp->MinFilter != GL_NEAREST && samp->MinFilter != GL_LINEAR;
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_reference_sampler_object_(struct gl_context *ctx,
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                struct gl_sampler_object **ptr,
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                                struct gl_sampler_object *samp);
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic inline void
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_reference_sampler_object(struct gl_context *ctx,
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               struct gl_sampler_object **ptr,
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                               struct gl_sampler_object *samp)
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (*ptr != samp)
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      _mesa_reference_sampler_object_(ctx, ptr, samp);
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name);
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern struct gl_sampler_object *
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_new_sampler_object(struct gl_context *ctx, GLuint name);
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_delete_sampler_object(struct gl_context *ctx,
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                            struct gl_sampler_object *sampObj);
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_init_sampler_object_functions(struct dd_function_table *driver);
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_init_sampler_object_dispatch(struct _glapi_table *disp);
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void GLAPIENTRY
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_BindSampler(GLuint unit, GLuint sampler);
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void GLAPIENTRY
86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_GenSamplers(GLsizei count, GLuint *samplers);
87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void GLAPIENTRY
89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_DeleteSamplers(GLsizei count, const GLuint *samplers);
90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void GLAPIENTRY
92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org_mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param);
93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif /* SAMPLEROBJ_H */
95