2 * Copyright © 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #include "brw_context.h"
25 #include "brw_state.h"
26 #include "main/context.h"
27 #include "main/formatquery.h"
28 #include "main/glformats.h"
31 brw_query_samples_for_format(struct gl_context
*ctx
, GLenum target
,
32 GLenum internalFormat
, int samples
[16])
34 struct brw_context
*brw
= brw_context(ctx
);
37 (void) internalFormat
;
55 if (internalFormat
== GL_RGBA32F
&& _mesa_is_gles(ctx
)) {
56 /* For GLES, we are allowed to return a smaller number of samples for
57 * GL_RGBA32F. See OpenGLES 3.2 spec, section 20.3.1 Internal Format
58 * Query Parameters, under SAMPLES:
60 * "A value less than or equal to the value of MAX_SAMPLES, if
61 * internalformat is RGBA16F, R32F, RG32F, or RGBA32F."
63 * In brw_render_target_supported, we prevent formats with a size
64 * greater than 8 bytes from using 8x MSAA on gen7.
86 brw_query_internal_format(struct gl_context
*ctx
, GLenum target
,
87 GLenum internalFormat
, GLenum pname
, GLint
*params
)
89 /* The Mesa layer gives us a temporary params buffer that is guaranteed
90 * to be non-NULL, and have at least 16 elements.
92 assert(params
!= NULL
);
96 brw_query_samples_for_format(ctx
, target
, internalFormat
, params
);
99 case GL_NUM_SAMPLE_COUNTS
: {
101 GLint dummy_buffer
[16];
103 num_samples
= brw_query_samples_for_format(ctx
, target
, internalFormat
,
105 params
[0] = (GLint
) num_samples
;
110 /* By default, we call the driver hook's fallback function from the frontend,
111 * which has generic implementation for all pnames.
113 _mesa_query_internal_format_default(ctx
, target
, internalFormat
, pname
,