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
);
63 FLUSH_VERTICES(ctx
, 0);
64 ctx
->NewDriverState
|=
65 ctx
->DriverFlags
.NewNvConservativeRasterizationParams
;
67 ctx
->ConservativeRasterDilate
=
69 ctx
->Const
.ConservativeRasterDilateRange
[0],
70 ctx
->Const
.ConservativeRasterDilateRange
[1]);
72 case GL_CONSERVATIVE_RASTER_MODE_NV
:
73 if (!no_error
&& !ctx
->Extensions
.NV_conservative_raster_pre_snap_triangles
)
74 goto invalid_pname_enum
;
76 if (!no_error
&& param
!= GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV
&&
77 param
!= GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV
) {
78 _mesa_error(ctx
, GL_INVALID_ENUM
,
79 "%s(pname=%s)", func
, _mesa_enum_to_string(param
));
83 FLUSH_VERTICES(ctx
, 0);
84 ctx
->NewDriverState
|=
85 ctx
->DriverFlags
.NewNvConservativeRasterizationParams
;
87 ctx
->ConservativeRasterMode
= param
;
90 goto invalid_pname_enum
;
97 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=%s)",
98 func
, _mesa_enum_to_string(pname
));
102 _mesa_ConservativeRasterParameteriNV_no_error(GLenum pname
, GLint param
)
104 conservative_raster_parameter(pname
, param
, true,
105 "glConservativeRasterParameteriNV");
109 _mesa_ConservativeRasterParameteriNV(GLenum pname
, GLint param
)
111 conservative_raster_parameter(pname
, param
, false,
112 "glConservativeRasterParameteriNV");
116 _mesa_ConservativeRasterParameterfNV_no_error(GLenum pname
, GLfloat param
)
118 conservative_raster_parameter(pname
, param
, true,
119 "glConservativeRasterParameterfNV");
123 _mesa_ConservativeRasterParameterfNV(GLenum pname
, GLfloat param
)
125 conservative_raster_parameter(pname
, param
, false,
126 "glConservativeRasterParameterfNV");
130 _mesa_init_conservative_raster(struct gl_context
*ctx
)
132 ctx
->ConservativeRasterDilate
= 0.0;
133 ctx
->ConservativeRasterMode
= GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV
;