2 * Mesa 3-D graphics library
4 * Copyright (C) 2018 Rhys Perry
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
27 * \file conservativeraster.c
28 * glConservativeRasterParameteriNV and glConservativeRasterParameterfNV functions
31 #include "conservativeraster.h"
35 static ALWAYS_INLINE
void
36 conservative_raster_parameter(GLenum pname
, GLfloat param
,
37 bool no_error
, const char *func
)
39 GET_CURRENT_CONTEXT(ctx
);
41 if (!no_error
&& !ctx
->Extensions
.NV_conservative_raster_dilate
&&
42 !ctx
->Extensions
.NV_conservative_raster_pre_snap_triangles
) {
43 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s not supported", func
);
47 if (MESA_VERBOSE
& VERBOSE_API
)
48 _mesa_debug(ctx
, "%s(%s, %g)\n",
49 func
, _mesa_enum_to_string(pname
), param
);
51 ASSERT_OUTSIDE_BEGIN_END(ctx
);
54 case GL_CONSERVATIVE_RASTER_DILATE_NV
:
55 if (!no_error
&& !ctx
->Extensions
.NV_conservative_raster_dilate
)
56 goto invalid_pname_enum
;
58 if (!no_error
&& param
<0.0) {
59 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(param=%g)", func
, param
);
62 ctx
->ConservativeRasterDilate
=
64 ctx
->Const
.ConservativeRasterDilateRange
[0],
65 ctx
->Const
.ConservativeRasterDilateRange
[1]);
67 case GL_CONSERVATIVE_RASTER_MODE_NV
:
68 if (!no_error
&& !ctx
->Extensions
.NV_conservative_raster_pre_snap_triangles
)
69 goto invalid_pname_enum
;
71 if (!no_error
&& param
!= GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV
&&
72 param
!= GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV
) {
73 _mesa_error(ctx
, GL_INVALID_ENUM
,
74 "%s(pname=%s)", func
, _mesa_enum_to_string(param
));
77 ctx
->ConservativeRasterMode
= param
;
80 goto invalid_pname_enum
;
84 FLUSH_VERTICES(ctx
, 0);
85 ctx
->NewDriverState
|=
86 ctx
->DriverFlags
.NewNvConservativeRasterizationParams
;
91 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)",
92 func
, _mesa_enum_to_string(pname
));
96 _mesa_ConservativeRasterParameteriNV_no_error(GLenum pname
, GLint param
)
98 conservative_raster_parameter(pname
, param
, true,
99 "glConservativeRasterParameteriNV");
103 _mesa_ConservativeRasterParameteriNV(GLenum pname
, GLint param
)
105 conservative_raster_parameter(pname
, param
, false,
106 "glConservativeRasterParameteriNV");
110 _mesa_ConservativeRasterParameterfNV_no_error(GLenum pname
, GLfloat param
)
112 conservative_raster_parameter(pname
, param
, true,
113 "glConservativeRasterParameterfNV");
117 _mesa_ConservativeRasterParameterfNV(GLenum pname
, GLfloat param
)
119 conservative_raster_parameter(pname
, param
, false,
120 "glConservativeRasterParameterfNV");
124 _mesa_init_conservative_raster(struct gl_context
*ctx
)
126 ctx
->ConservativeRasterDilate
= 0.0;
127 ctx
->ConservativeRasterMode
= GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV
;