gallium: remove PIPE_CAP_VERTEX_COLOR_CLAMP_CONTROL
authorMarek Olšák <maraeo@gmail.com>
Sat, 26 Mar 2011 12:19:23 +0000 (13:19 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 29 Mar 2011 10:50:27 +0000 (12:50 +0200)
The vertex color clamp control is a property of an API,
a lot like gl_rasterization_rules.

The state should be set according to the API being implemented, for example:
   OpenGL Compatibility: enabled by default
   OpenGL Core: disabled by default
   D3D11: always disabled

This patch also changes the way ARB_color_buffer_float is advertised.
If no SNORM or FLOAT render target is supported, fragment color clamping
is not required.

src/gallium/include/pipe/p_defines.h
src/mesa/state_tracker/st_extensions.c

index 4f6daa86a5914b35cc0723bde65143f7183aebc9..1c1a8f26454d41ba64d4a6f092bc6f2231cb23d7 100644 (file)
@@ -463,7 +463,6 @@ enum pipe_cap {
    PIPE_CAP_SHADER_STENCIL_EXPORT,
    PIPE_CAP_TGSI_INSTANCEID,
    PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR,
-   PIPE_CAP_VERTEX_COLOR_CLAMP_CONTROL,
    PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL
 };
 
index ba1a0af0628d7a33850629de927b0ffa94ed42a1..e3277904417517c6b9c6a6f00c2d947d9293fb72 100644 (file)
@@ -514,12 +514,34 @@ void st_init_extensions(struct st_context *st)
       ctx->Extensions.ARB_depth_clamp = GL_TRUE;
    }
 
-   /* this extension does not actually require support of floating point
-    * render targets, just clamping controls
+   /* This extension does not actually require support of floating point
+    * render targets, just clamping controls.
+    * Advertise this extension if either fragment color clamping is supported
+    * or no render targets having color values outside of the range [0, 1]
+    * are supported, in which case the fragment color clamping has no effect
+    * on rendering.
     */
-   if(screen->get_param(screen, PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL) &&
-      screen->get_param(screen, PIPE_CAP_VERTEX_COLOR_CLAMP_CONTROL))
+   if (screen->get_param(screen, PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL) ||
+       (!screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SNORM,
+                                     PIPE_TEXTURE_2D, 0,
+                                     PIPE_BIND_RENDER_TARGET) &&
+        !screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM,
+                                             PIPE_TEXTURE_2D, 0,
+                                             PIPE_BIND_RENDER_TARGET) &&
+        !screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_FLOAT,
+                                     PIPE_TEXTURE_2D, 0,
+                                     PIPE_BIND_RENDER_TARGET) &&
+        !screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_FLOAT,
+                                     PIPE_TEXTURE_2D, 0,
+                                     PIPE_BIND_RENDER_TARGET) &&
+        !screen->is_format_supported(screen, PIPE_FORMAT_R11G11B10_FLOAT,
+                                     PIPE_TEXTURE_2D, 0,
+                                     PIPE_BIND_RENDER_TARGET) &&
+        !screen->is_format_supported(screen, PIPE_FORMAT_R9G9B9E5_FLOAT,
+                                     PIPE_TEXTURE_2D, 0,
+                                     PIPE_BIND_RENDER_TARGET))) {
       ctx->Extensions.ARB_color_buffer_float = GL_TRUE;
+   }
 
    if (screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) {
       ctx->Extensions.ARB_shader_stencil_export = GL_TRUE;