[Mesa-dev] [PATCH 02/14] gallium: Obtain ARB_framebuffer_no_attachment constants
Marek Olšák
maraeo at gmail.com
Sun Mar 27 16:43:37 UTC 2016
On Sun, Mar 27, 2016 at 4:38 AM, Edward O'Callaghan
<eocallaghan at alterapraxis.com> wrote:
> Set default values for the constants required in
> ARB_framebuffer_no_attachments and obtained the number
> of layers from ``PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS``.
>
> We also obtain the MaxFramebufferSamples value using
> a query back to the driver for PIPE_FORMAT_NONE.
>
> Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
> ---
> src/mesa/state_tracker/st_extensions.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index 59777ee..658dfec 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -1050,6 +1050,33 @@ void st_init_extensions(struct pipe_screen *screen,
> extensions->AMD_vertex_shader_viewport_index = GL_TRUE;
> }
>
> + /* ARB_framebuffer_no_attachments */
> + consts->MaxFramebufferWidth = consts->MaxViewportWidth;
> + consts->MaxFramebufferHeight = consts->MaxViewportHeight;
> + enum pipe_format void_formats[] = {
> + PIPE_FORMAT_NONE
> + };
In general, we don't allow declarations after code. You can insert a
new code block to work around it or you can move this to the block
that calls get_max_samples_for_formats several times.
> + /* Assumes maximum number of samples of 32 */
> + consts->MaxFramebufferSamples =
> + get_max_samples_for_formats(screen, ARRAY_SIZE(void_formats),
> + void_formats, 32,
> + PIPE_BIND_RENDER_TARGET);
> +
> + /* N.B., we cheat here a little by assuming that
> + * PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS has the same
> + * number of layers as we need, although we technically
> + * could have more the generality is not really useful
> + * in practicality.
> + */
> + consts->MaxFramebufferLayers
> + = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS);
Please initialize constants in st_init_limits if possible. There are
some exceptions, but they don't apply in this case.
Also, "=" should be on the previous line.
> +
> + if ((consts->MaxSamples >= 4 && consts->MaxFramebufferLayers >= 2048)
> + || (consts->MaxFramebufferSamples >= consts->MaxSamples &&
> + consts->MaxFramebufferLayers >= consts->MaxArrayTextureLayers))
> + if (screen->get_param(screen, PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT))
> + extensions->ARB_framebuffer_no_attachments = GL_TRUE;
Please merge this into one if statement. Also, "||" and all other
operators should not begin a new line, instead they should be at the
end of the previous line.
Marek
More information about the mesa-dev
mailing list