samplerobj.h revision af69d88d
13464ebd5Sriastradh/*
23464ebd5Sriastradh * Mesa 3-D graphics library
33464ebd5Sriastradh *
43464ebd5Sriastradh * Copyright (C) 2011  VMware, Inc.  All Rights Reserved.
53464ebd5Sriastradh *
63464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a
73464ebd5Sriastradh * copy of this software and associated documentation files (the "Software"),
83464ebd5Sriastradh * to deal in the Software without restriction, including without limitation
93464ebd5Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense,
103464ebd5Sriastradh * and/or sell copies of the Software, and to permit persons to whom the
113464ebd5Sriastradh * Software is furnished to do so, subject to the following conditions:
123464ebd5Sriastradh *
133464ebd5Sriastradh * The above copyright notice and this permission notice shall be included
143464ebd5Sriastradh * in all copies or substantial portions of the Software.
153464ebd5Sriastradh *
163464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
173464ebd5Sriastradh * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
183464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
233464ebd5Sriastradh */
243464ebd5Sriastradh
253464ebd5Sriastradh
263464ebd5Sriastradh
273464ebd5Sriastradh#ifndef SAMPLEROBJ_H
283464ebd5Sriastradh#define SAMPLEROBJ_H
293464ebd5Sriastradh
303464ebd5Sriastradhstruct dd_function_table;
313464ebd5Sriastradh
32af69d88dSmrgstatic inline struct gl_sampler_object *
333464ebd5Sriastradh_mesa_get_samplerobj(struct gl_context *ctx, GLuint unit)
343464ebd5Sriastradh{
353464ebd5Sriastradh   if (ctx->Texture.Unit[unit].Sampler)
363464ebd5Sriastradh      return ctx->Texture.Unit[unit].Sampler;
37af69d88dSmrg   else if (ctx->Texture.Unit[unit]._Current)
383464ebd5Sriastradh      return &ctx->Texture.Unit[unit]._Current->Sampler;
39af69d88dSmrg   else
40af69d88dSmrg      return NULL;
41af69d88dSmrg}
42af69d88dSmrg
43af69d88dSmrg
44af69d88dSmrg/** Does the given filter state do mipmap filtering? */
45af69d88dSmrgstatic inline GLboolean
46af69d88dSmrg_mesa_is_mipmap_filter(const struct gl_sampler_object *samp)
47af69d88dSmrg{
48af69d88dSmrg   return samp->MinFilter != GL_NEAREST && samp->MinFilter != GL_LINEAR;
493464ebd5Sriastradh}
503464ebd5Sriastradh
51af69d88dSmrg
523464ebd5Sriastradhextern void
53af69d88dSmrg_mesa_reference_sampler_object_(struct gl_context *ctx,
54af69d88dSmrg                                struct gl_sampler_object **ptr,
55af69d88dSmrg                                struct gl_sampler_object *samp);
56af69d88dSmrg
57af69d88dSmrgstatic inline void
583464ebd5Sriastradh_mesa_reference_sampler_object(struct gl_context *ctx,
593464ebd5Sriastradh                               struct gl_sampler_object **ptr,
60af69d88dSmrg                               struct gl_sampler_object *samp)
61af69d88dSmrg{
62af69d88dSmrg   if (*ptr != samp)
63af69d88dSmrg      _mesa_reference_sampler_object_(ctx, ptr, samp);
64af69d88dSmrg}
653464ebd5Sriastradh
66af69d88dSmrgextern struct gl_sampler_object *
67af69d88dSmrg_mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name);
683464ebd5Sriastradh
693464ebd5Sriastradhextern struct gl_sampler_object *
703464ebd5Sriastradh_mesa_new_sampler_object(struct gl_context *ctx, GLuint name);
713464ebd5Sriastradh
723464ebd5Sriastradhextern void
733464ebd5Sriastradh_mesa_init_sampler_object_functions(struct dd_function_table *driver);
743464ebd5Sriastradh
75af69d88dSmrgvoid GLAPIENTRY
76af69d88dSmrg_mesa_GenSamplers(GLsizei count, GLuint *samplers);
77af69d88dSmrgvoid GLAPIENTRY
78af69d88dSmrg_mesa_DeleteSamplers(GLsizei count, const GLuint *samplers);
79af69d88dSmrgGLboolean GLAPIENTRY
80af69d88dSmrg_mesa_IsSampler(GLuint sampler);
81af69d88dSmrgvoid GLAPIENTRY
82af69d88dSmrg_mesa_BindSampler(GLuint unit, GLuint sampler);
83af69d88dSmrgvoid GLAPIENTRY
84af69d88dSmrg_mesa_BindSamplers(GLuint first, GLsizei count, const GLuint *samplers);
85af69d88dSmrgvoid GLAPIENTRY
86af69d88dSmrg_mesa_SamplerParameteri(GLuint sampler, GLenum pname, GLint param);
87af69d88dSmrgvoid GLAPIENTRY
88af69d88dSmrg_mesa_SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param);
89af69d88dSmrgvoid GLAPIENTRY
90af69d88dSmrg_mesa_SamplerParameteriv(GLuint sampler, GLenum pname, const GLint *params);
91af69d88dSmrgvoid GLAPIENTRY
92af69d88dSmrg_mesa_SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat *params);
93af69d88dSmrgvoid GLAPIENTRY
94af69d88dSmrg_mesa_SamplerParameterIiv(GLuint sampler, GLenum pname, const GLint *params);
95af69d88dSmrgvoid GLAPIENTRY
96af69d88dSmrg_mesa_SamplerParameterIuiv(GLuint sampler, GLenum pname, const GLuint *params);
97af69d88dSmrgvoid GLAPIENTRY
98af69d88dSmrg_mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params);
99af69d88dSmrgvoid GLAPIENTRY
100af69d88dSmrg_mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params);
101af69d88dSmrgvoid GLAPIENTRY
102af69d88dSmrg_mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params);
103af69d88dSmrgvoid GLAPIENTRY
104af69d88dSmrg_mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params);
1053464ebd5Sriastradh
1063464ebd5Sriastradh#endif /* SAMPLEROBJ_H */
107