1bf215546Sopenharmony_ci
2bf215546Sopenharmony_ci/*
3bf215546Sopenharmony_ci * Mesa 3-D graphics library
4bf215546Sopenharmony_ci *
5bf215546Sopenharmony_ci * Copyright (C) 1999-2002  Brian Paul   All Rights Reserved.
6bf215546Sopenharmony_ci *
7bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
8bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
9bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
10bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
12bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included
15bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
16bf215546Sopenharmony_ci *
17bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
24bf215546Sopenharmony_ci */
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci#include "glheader.h"
28bf215546Sopenharmony_ci#include "enums.h"
29bf215546Sopenharmony_ci#include "context.h"
30bf215546Sopenharmony_ci#include "hint.h"
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_ci#include "mtypes.h"
33bf215546Sopenharmony_ci#include "api_exec_decl.h"
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_ci#include "pipe/p_screen.h"
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_civoid GLAPIENTRY
38bf215546Sopenharmony_ci_mesa_Hint( GLenum target, GLenum mode )
39bf215546Sopenharmony_ci{
40bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_ci   if (MESA_VERBOSE & VERBOSE_API)
43bf215546Sopenharmony_ci      _mesa_debug(ctx, "glHint %s %s\n",
44bf215546Sopenharmony_ci                  _mesa_enum_to_string(target),
45bf215546Sopenharmony_ci                  _mesa_enum_to_string(mode));
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_ci   if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) {
48bf215546Sopenharmony_ci      _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)");
49bf215546Sopenharmony_ci      return;
50bf215546Sopenharmony_ci   }
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_ci   switch (target) {
53bf215546Sopenharmony_ci      case GL_FOG_HINT:
54bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
55bf215546Sopenharmony_ci            goto invalid_target;
56bf215546Sopenharmony_ci         if (ctx->Hint.Fog == mode)
57bf215546Sopenharmony_ci	    return;
58bf215546Sopenharmony_ci	 FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT);
59bf215546Sopenharmony_ci         ctx->Hint.Fog = mode;
60bf215546Sopenharmony_ci         break;
61bf215546Sopenharmony_ci      case GL_LINE_SMOOTH_HINT:
62bf215546Sopenharmony_ci         if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
63bf215546Sopenharmony_ci            goto invalid_target;
64bf215546Sopenharmony_ci         if (ctx->Hint.LineSmooth == mode)
65bf215546Sopenharmony_ci	    return;
66bf215546Sopenharmony_ci	 FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT);
67bf215546Sopenharmony_ci         ctx->Hint.LineSmooth = mode;
68bf215546Sopenharmony_ci         break;
69bf215546Sopenharmony_ci      case GL_PERSPECTIVE_CORRECTION_HINT:
70bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
71bf215546Sopenharmony_ci            goto invalid_target;
72bf215546Sopenharmony_ci         if (ctx->Hint.PerspectiveCorrection == mode)
73bf215546Sopenharmony_ci	    return;
74bf215546Sopenharmony_ci	 FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT);
75bf215546Sopenharmony_ci         ctx->Hint.PerspectiveCorrection = mode;
76bf215546Sopenharmony_ci         break;
77bf215546Sopenharmony_ci      case GL_POINT_SMOOTH_HINT:
78bf215546Sopenharmony_ci         if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES)
79bf215546Sopenharmony_ci            goto invalid_target;
80bf215546Sopenharmony_ci         if (ctx->Hint.PointSmooth == mode)
81bf215546Sopenharmony_ci	    return;
82bf215546Sopenharmony_ci	 FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT);
83bf215546Sopenharmony_ci         ctx->Hint.PointSmooth = mode;
84bf215546Sopenharmony_ci         break;
85bf215546Sopenharmony_ci      case GL_POLYGON_SMOOTH_HINT:
86bf215546Sopenharmony_ci         if (!_mesa_is_desktop_gl(ctx))
87bf215546Sopenharmony_ci            goto invalid_target;
88bf215546Sopenharmony_ci         if (ctx->Hint.PolygonSmooth == mode)
89bf215546Sopenharmony_ci	    return;
90bf215546Sopenharmony_ci	 FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT);
91bf215546Sopenharmony_ci         ctx->Hint.PolygonSmooth = mode;
92bf215546Sopenharmony_ci         break;
93bf215546Sopenharmony_ci
94bf215546Sopenharmony_ci      /* GL_ARB_texture_compression */
95bf215546Sopenharmony_ci      case GL_TEXTURE_COMPRESSION_HINT_ARB:
96bf215546Sopenharmony_ci         if (!_mesa_is_desktop_gl(ctx))
97bf215546Sopenharmony_ci            goto invalid_target;
98bf215546Sopenharmony_ci	 if (ctx->Hint.TextureCompression == mode)
99bf215546Sopenharmony_ci	    return;
100bf215546Sopenharmony_ci	 FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT);
101bf215546Sopenharmony_ci	 ctx->Hint.TextureCompression = mode;
102bf215546Sopenharmony_ci         break;
103bf215546Sopenharmony_ci
104bf215546Sopenharmony_ci      /* GL_SGIS_generate_mipmap */
105bf215546Sopenharmony_ci      case GL_GENERATE_MIPMAP_HINT_SGIS:
106bf215546Sopenharmony_ci         if (ctx->API == API_OPENGL_CORE)
107bf215546Sopenharmony_ci            goto invalid_target;
108bf215546Sopenharmony_ci         if (ctx->Hint.GenerateMipmap == mode)
109bf215546Sopenharmony_ci            return;
110bf215546Sopenharmony_ci	 FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT);
111bf215546Sopenharmony_ci	 ctx->Hint.GenerateMipmap = mode;
112bf215546Sopenharmony_ci         break;
113bf215546Sopenharmony_ci
114bf215546Sopenharmony_ci      /* GL_ARB_fragment_shader */
115bf215546Sopenharmony_ci      case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
116bf215546Sopenharmony_ci         if (ctx->API == API_OPENGLES || !ctx->Extensions.ARB_fragment_shader)
117bf215546Sopenharmony_ci            goto invalid_target;
118bf215546Sopenharmony_ci         if (ctx->Hint.FragmentShaderDerivative == mode)
119bf215546Sopenharmony_ci            return;
120bf215546Sopenharmony_ci         FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT);
121bf215546Sopenharmony_ci         ctx->Hint.FragmentShaderDerivative = mode;
122bf215546Sopenharmony_ci         break;
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_ci      default:
125bf215546Sopenharmony_ci         goto invalid_target;
126bf215546Sopenharmony_ci   }
127bf215546Sopenharmony_ci   return;
128bf215546Sopenharmony_ci
129bf215546Sopenharmony_ciinvalid_target:
130bf215546Sopenharmony_ci   _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
131bf215546Sopenharmony_ci   return;
132bf215546Sopenharmony_ci}
133bf215546Sopenharmony_ci
134bf215546Sopenharmony_ci/* GL_ARB_parallel_shader_compile */
135bf215546Sopenharmony_civoid GLAPIENTRY
136bf215546Sopenharmony_ci_mesa_MaxShaderCompilerThreadsKHR(GLuint count)
137bf215546Sopenharmony_ci{
138bf215546Sopenharmony_ci   GET_CURRENT_CONTEXT(ctx);
139bf215546Sopenharmony_ci
140bf215546Sopenharmony_ci   ctx->Hint.MaxShaderCompilerThreads = count;
141bf215546Sopenharmony_ci
142bf215546Sopenharmony_ci   struct pipe_screen *screen = ctx->screen;
143bf215546Sopenharmony_ci   if (screen->set_max_shader_compiler_threads)
144bf215546Sopenharmony_ci      screen->set_max_shader_compiler_threads(screen, count);
145bf215546Sopenharmony_ci}
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ci/**********************************************************************/
148bf215546Sopenharmony_ci/*****                      Initialization                        *****/
149bf215546Sopenharmony_ci/**********************************************************************/
150bf215546Sopenharmony_ci
151bf215546Sopenharmony_civoid _mesa_init_hint( struct gl_context * ctx )
152bf215546Sopenharmony_ci{
153bf215546Sopenharmony_ci   /* Hint group */
154bf215546Sopenharmony_ci   ctx->Hint.PerspectiveCorrection = GL_DONT_CARE;
155bf215546Sopenharmony_ci   ctx->Hint.PointSmooth = GL_DONT_CARE;
156bf215546Sopenharmony_ci   ctx->Hint.LineSmooth = GL_DONT_CARE;
157bf215546Sopenharmony_ci   ctx->Hint.PolygonSmooth = GL_DONT_CARE;
158bf215546Sopenharmony_ci   ctx->Hint.Fog = GL_DONT_CARE;
159bf215546Sopenharmony_ci   ctx->Hint.TextureCompression = GL_DONT_CARE;
160bf215546Sopenharmony_ci   ctx->Hint.GenerateMipmap = GL_DONT_CARE;
161bf215546Sopenharmony_ci   ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE;
162bf215546Sopenharmony_ci   ctx->Hint.MaxShaderCompilerThreads = 0xffffffff;
163bf215546Sopenharmony_ci}
164