st/mesa: implement ARB_internalformat_query v2
authorMarek Olšák <maraeo@gmail.com>
Sat, 19 Jan 2013 01:54:16 +0000 (02:54 +0100)
committerMarek Olšák <maraeo@gmail.com>
Thu, 24 Jan 2013 17:39:28 +0000 (18:39 +0100)
Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_extensions.c
src/mesa/state_tracker/st_format.c
src/mesa/state_tracker/st_format.h

index 7f07b741ee0e81908a327b3f3ce5afcc11d978d0..3cea2df07d9462a850d6049332a79ec6ed160205 100644 (file)
@@ -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;
index fbe1ad8f89ca02d603cb465657f02133dc4c1945..af54cf7c8bb2584c3399cbb4463aaf8f158a2b33 100644 (file)
@@ -516,6 +516,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;
index af81f732d215e4a1bea79fb0189ea7aa10bee082..7ef063953c3de61d19b64b784c1e7954bb353cf8 100644 (file)
@@ -1642,6 +1642,40 @@ 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, bind, num_sample_counts = 0;
+
+   if (_mesa_is_depth_or_stencil_format(internalFormat))
+      bind = PIPE_BIND_DEPTH_STENCIL;
+   else
+      bind = PIPE_BIND_RENDER_TARGET;
+
+   /* Set sample counts in descending order. */
+   for (i = 16; i > 1; i--) {
+      format = st_choose_format(screen, internalFormat, GL_NONE, GL_NONE,
+                                PIPE_TEXTURE_2D, i, bind);
+
+      if (format != PIPE_FORMAT_NONE) {
+         samples[num_sample_counts++] = i;
+      }
+   }
+
+   if (!num_sample_counts) {
+      samples[num_sample_counts++] = 1;
+   }
+
+   return num_sample_counts;
+}
+
+
 GLboolean
 st_sampler_compat_formats(enum pipe_format format1, enum pipe_format format2)
 {
index 39397b17aa6cc156713c6fde43a2409ea307840f..cb6e5bc9687fb3818110ff13c51f1c8bc7b55845 100644 (file)
@@ -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 */