17117f1b4Smrg 27117f1b4Smrg/* 37117f1b4Smrg * Mesa 3-D graphics library 47117f1b4Smrg * 57117f1b4Smrg * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. 67117f1b4Smrg * 77117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 87117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 97117f1b4Smrg * to deal in the Software without restriction, including without limitation 107117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 117117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 127117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 137117f1b4Smrg * 147117f1b4Smrg * The above copyright notice and this permission notice shall be included 157117f1b4Smrg * in all copies or substantial portions of the Software. 167117f1b4Smrg * 177117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 187117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 197117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 247117f1b4Smrg */ 257117f1b4Smrg 267117f1b4Smrg 277117f1b4Smrg#include "glheader.h" 287117f1b4Smrg#include "enums.h" 297117f1b4Smrg#include "context.h" 307117f1b4Smrg#include "hint.h" 317ec681f3Smrg 323464ebd5Sriastradh#include "mtypes.h" 337117f1b4Smrg 347117f1b4Smrg 357117f1b4Smrg 367117f1b4Smrgvoid GLAPIENTRY 377117f1b4Smrg_mesa_Hint( GLenum target, GLenum mode ) 387117f1b4Smrg{ 397117f1b4Smrg GET_CURRENT_CONTEXT(ctx); 407117f1b4Smrg 417117f1b4Smrg if (MESA_VERBOSE & VERBOSE_API) 423464ebd5Sriastradh _mesa_debug(ctx, "glHint %s %s\n", 4301e04c3fSmrg _mesa_enum_to_string(target), 4401e04c3fSmrg _mesa_enum_to_string(mode)); 457117f1b4Smrg 467117f1b4Smrg if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { 477117f1b4Smrg _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); 487117f1b4Smrg return; 497117f1b4Smrg } 507117f1b4Smrg 517117f1b4Smrg switch (target) { 527117f1b4Smrg case GL_FOG_HINT: 53af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 54af69d88dSmrg goto invalid_target; 557117f1b4Smrg if (ctx->Hint.Fog == mode) 567117f1b4Smrg return; 577ec681f3Smrg FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT); 587117f1b4Smrg ctx->Hint.Fog = mode; 597117f1b4Smrg break; 607117f1b4Smrg case GL_LINE_SMOOTH_HINT: 61af69d88dSmrg if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES) 62af69d88dSmrg goto invalid_target; 637117f1b4Smrg if (ctx->Hint.LineSmooth == mode) 647117f1b4Smrg return; 657ec681f3Smrg FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT); 667117f1b4Smrg ctx->Hint.LineSmooth = mode; 677117f1b4Smrg break; 687117f1b4Smrg case GL_PERSPECTIVE_CORRECTION_HINT: 69af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 70af69d88dSmrg goto invalid_target; 717117f1b4Smrg if (ctx->Hint.PerspectiveCorrection == mode) 727117f1b4Smrg return; 737ec681f3Smrg FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT); 747117f1b4Smrg ctx->Hint.PerspectiveCorrection = mode; 757117f1b4Smrg break; 767117f1b4Smrg case GL_POINT_SMOOTH_HINT: 77af69d88dSmrg if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) 78af69d88dSmrg goto invalid_target; 797117f1b4Smrg if (ctx->Hint.PointSmooth == mode) 807117f1b4Smrg return; 817ec681f3Smrg FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT); 827117f1b4Smrg ctx->Hint.PointSmooth = mode; 837117f1b4Smrg break; 847117f1b4Smrg case GL_POLYGON_SMOOTH_HINT: 85af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 86af69d88dSmrg goto invalid_target; 877117f1b4Smrg if (ctx->Hint.PolygonSmooth == mode) 887117f1b4Smrg return; 897ec681f3Smrg FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT); 907117f1b4Smrg ctx->Hint.PolygonSmooth = mode; 917117f1b4Smrg break; 927117f1b4Smrg 937117f1b4Smrg /* GL_ARB_texture_compression */ 947117f1b4Smrg case GL_TEXTURE_COMPRESSION_HINT_ARB: 95af69d88dSmrg if (!_mesa_is_desktop_gl(ctx)) 96af69d88dSmrg goto invalid_target; 977117f1b4Smrg if (ctx->Hint.TextureCompression == mode) 987117f1b4Smrg return; 997ec681f3Smrg FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT); 1007117f1b4Smrg ctx->Hint.TextureCompression = mode; 1017117f1b4Smrg break; 1027117f1b4Smrg 1037117f1b4Smrg /* GL_SGIS_generate_mipmap */ 1047117f1b4Smrg case GL_GENERATE_MIPMAP_HINT_SGIS: 105af69d88dSmrg if (ctx->API == API_OPENGL_CORE) 106af69d88dSmrg goto invalid_target; 1077117f1b4Smrg if (ctx->Hint.GenerateMipmap == mode) 1087117f1b4Smrg return; 1097ec681f3Smrg FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT); 1107117f1b4Smrg ctx->Hint.GenerateMipmap = mode; 1117117f1b4Smrg break; 1127117f1b4Smrg 1137117f1b4Smrg /* GL_ARB_fragment_shader */ 1147117f1b4Smrg case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB: 115af69d88dSmrg if (ctx->API == API_OPENGLES || !ctx->Extensions.ARB_fragment_shader) 116af69d88dSmrg goto invalid_target; 1177117f1b4Smrg if (ctx->Hint.FragmentShaderDerivative == mode) 1187117f1b4Smrg return; 1197ec681f3Smrg FLUSH_VERTICES(ctx, _NEW_HINT, GL_HINT_BIT); 1207117f1b4Smrg ctx->Hint.FragmentShaderDerivative = mode; 1217117f1b4Smrg break; 1227117f1b4Smrg 1237117f1b4Smrg default: 124af69d88dSmrg goto invalid_target; 1257117f1b4Smrg } 126af69d88dSmrg return; 127af69d88dSmrg 128af69d88dSmrginvalid_target: 129af69d88dSmrg _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)"); 130af69d88dSmrg return; 1317117f1b4Smrg} 1327117f1b4Smrg 133b9abf16eSmaya/* GL_ARB_parallel_shader_compile */ 134b9abf16eSmayavoid GLAPIENTRY 135b9abf16eSmaya_mesa_MaxShaderCompilerThreadsKHR(GLuint count) 136b9abf16eSmaya{ 137b9abf16eSmaya GET_CURRENT_CONTEXT(ctx); 138b9abf16eSmaya 139b9abf16eSmaya ctx->Hint.MaxShaderCompilerThreads = count; 140b9abf16eSmaya 141b9abf16eSmaya if (ctx->Driver.SetMaxShaderCompilerThreads) 142b9abf16eSmaya ctx->Driver.SetMaxShaderCompilerThreads(ctx, count); 143b9abf16eSmaya} 1447117f1b4Smrg 1457117f1b4Smrg/**********************************************************************/ 1467117f1b4Smrg/***** Initialization *****/ 1477117f1b4Smrg/**********************************************************************/ 1487117f1b4Smrg 1493464ebd5Sriastradhvoid _mesa_init_hint( struct gl_context * ctx ) 1507117f1b4Smrg{ 1517117f1b4Smrg /* Hint group */ 1527117f1b4Smrg ctx->Hint.PerspectiveCorrection = GL_DONT_CARE; 1537117f1b4Smrg ctx->Hint.PointSmooth = GL_DONT_CARE; 1547117f1b4Smrg ctx->Hint.LineSmooth = GL_DONT_CARE; 1557117f1b4Smrg ctx->Hint.PolygonSmooth = GL_DONT_CARE; 1567117f1b4Smrg ctx->Hint.Fog = GL_DONT_CARE; 1577117f1b4Smrg ctx->Hint.TextureCompression = GL_DONT_CARE; 1587117f1b4Smrg ctx->Hint.GenerateMipmap = GL_DONT_CARE; 1597117f1b4Smrg ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE; 160b9abf16eSmaya ctx->Hint.MaxShaderCompilerThreads = 0xffffffff; 1617117f1b4Smrg} 162