[Mesa-dev] [PATCH 2/2] st/mesa: implement ARB_internalformat_query
Ian Romanick
idr at freedesktop.org
Sun Jan 20 14:30:13 PST 2013
On 01/18/2013 08:55 PM, Marek Olšák wrote:
> ---
> src/mesa/state_tracker/st_cb_texture.c | 1 +
> src/mesa/state_tracker/st_extensions.c | 1 +
> src/mesa/state_tracker/st_format.c | 46 ++++++++++++++++++++++++++++++++
> src/mesa/state_tracker/st_format.h | 3 +++
> 4 files changed, 51 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
> index 7f07b74..3cea2df 100644
> --- a/src/mesa/state_tracker/st_cb_texture.c
> +++ b/src/mesa/state_tracker/st_cb_texture.c
> @@ -1555,6 +1555,7 @@ void
> st_init_texture_functions(struct dd_function_table *functions)
> {
> functions->ChooseTextureFormat = st_ChooseTextureFormat;
> + functions->QuerySamplesForFormat = st_QuerySamplesForFormat;
> functions->TexImage = st_TexImage;
> functions->TexSubImage = _mesa_store_texsubimage;
> functions->CompressedTexSubImage = _mesa_store_compressed_texsubimage;
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index aa70d5e..d52c840 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -520,6 +520,7 @@ void st_init_extensions(struct st_context *st)
> ctx->Extensions.ARB_fragment_shader = GL_TRUE;
> ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
> ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
> + ctx->Extensions.ARB_internalformat_query = GL_TRUE;
> ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
> ctx->Extensions.ARB_shader_objects = GL_TRUE;
> ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
> diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
> index af81f73..fedfd8e 100644
> --- a/src/mesa/state_tracker/st_format.c
> +++ b/src/mesa/state_tracker/st_format.c
> @@ -1642,6 +1642,52 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
> }
>
>
> +/**
> + * Called via ctx->Driver.ChooseTextureFormat().
> + */
> +size_t
> +st_QuerySamplesForFormat(struct gl_context *ctx, GLenum internalFormat,
> + int samples[16])
> +{
> + struct pipe_screen *screen = st_context(ctx)->pipe->screen;
> + enum pipe_format format;
> + unsigned i, num_sample_counts;
> +
> + /* If multisampling isn't supported, we should return 1.
> + * Otherwise, we should only return values > 1.
> + */
> + samples[0] = 1;
> +
> + if (ctx->Const.MaxSamples <= 1) {
> + return 1;
> + }
> +
> + /* Use Const.MaxSamples to make sure this returns a format
> + * with MSAA support. Requesting a format with one sample might return
> + * a different format.
> + */
> + format = st_choose_format(screen, internalFormat, GL_NONE, GL_NONE,
> + PIPE_TEXTURE_2D, ctx->Const.MaxSamples,
> + PIPE_BIND_RENDER_TARGET);
> + if (format == PIPE_FORMAT_NONE) {
> + return 1;
> + }
> +
> + /* Set samples counts in descending order. */
> + samples[0] = ctx->Const.MaxSamples;
> + num_sample_counts = 1;
> +
> + for (i = ctx->Const.MaxSamples-1; i > 1; i--) {
Part of the point of this extension is that some formats (small pixel
bit size) formats may be able to do more samples. This implementation
makes it impossible to expose that.
> + if (screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, i,
> + PIPE_BIND_RENDER_TARGET)) {
> + samples[num_sample_counts++] = i;
> + }
> + }
> +
> + return num_sample_counts;
> +}
> +
> +
> GLboolean
> st_sampler_compat_formats(enum pipe_format format1, enum pipe_format format2)
> {
> diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
> index 39397b1..cb6e5bc 100644
> --- a/src/mesa/state_tracker/st_format.h
> +++ b/src/mesa/state_tracker/st_format.h
> @@ -67,6 +67,9 @@ st_ChooseTextureFormat(struct gl_context * ctx, GLenum target,
> GLint internalFormat,
> GLenum format, GLenum type);
>
> +size_t
> +st_QuerySamplesForFormat(struct gl_context *ctx, GLenum internalFormat,
> + int samples[16]);
>
> /* can we use a sampler view to translate these formats
> only used to make TFP so far */
>
More information about the mesa-dev
mailing list