d3d1x: improve CheckFormatSupport
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Mon, 17 Oct 2011 18:49:56 +0000 (20:49 +0200)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 21 Oct 2011 21:00:37 +0000 (23:00 +0200)
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h

index cf8c564d88962a04d07a48f5ca7f9776ecec1b8c..fdfaacc88b9e4230301ddfefaaafe990901e3e07 100644 (file)
@@ -303,6 +303,7 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
                SYNCHRONIZED;
 
                /* TODO: MSAA, advanced features */
+
                pipe_format format = dxgi_to_pipe_format[dxgi_format];
                if(!format)
                        return E_INVALIDARG;
@@ -311,32 +312,61 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
                if(support < 0)
                {
                        support = 0;
-                       unsigned buffer = D3D11_FORMAT_SUPPORT_BUFFER | D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER | D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER;
-                       unsigned sampler_view = D3D11_FORMAT_SUPPORT_SHADER_SAMPLE | D3D11_FORMAT_SUPPORT_MIP | D3D11_FORMAT_SUPPORT_MIP_AUTOGEN;
-                       if(util_format_is_depth_or_stencil(format))
-                               sampler_view |= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON;
-
-                       /* TODO: do this properly when Gallium drivers actually support index/vertex format queries */
-                        if(screen->is_format_supported(screen, format, PIPE_BUFFER, 0, PIPE_BIND_VERTEX_BUFFER)
-                                || (screen->is_format_supported(screen, format, PIPE_BUFFER, 0, PIPE_BIND_INDEX_BUFFER)
-                               || format == PIPE_FORMAT_R8_UNORM))
-                               support |= buffer;
+
+                       if(dxgi_format == DXGI_FORMAT_R8_UINT ||
+                          dxgi_format == DXGI_FORMAT_R16_UINT ||
+                          dxgi_format == DXGI_FORMAT_R32_UINT)
+                               support |= D3D11_FORMAT_SUPPORT_IA_INDEX_BUFFER;
+
+                       if(screen->is_format_supported(screen, format, PIPE_BUFFER, 0, PIPE_BIND_VERTEX_BUFFER))
+                               support |= D3D11_FORMAT_SUPPORT_IA_VERTEX_BUFFER;
+
                         if(screen->is_format_supported(screen, format, PIPE_BUFFER, 0, PIPE_BIND_STREAM_OUTPUT))
-                               support |= buffer | D3D11_FORMAT_SUPPORT_SO_BUFFER;
+                               support |= D3D11_FORMAT_SUPPORT_SO_BUFFER;
+
                         if(screen->is_format_supported(screen, format, PIPE_TEXTURE_1D, 0, PIPE_BIND_SAMPLER_VIEW))
-                               support |= D3D11_FORMAT_SUPPORT_TEXTURE1D | sampler_view;
+                               support |= D3D11_FORMAT_SUPPORT_TEXTURE1D;
                         if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW))
-                               support |= D3D11_FORMAT_SUPPORT_TEXTURE2D | sampler_view;
+                               support |= D3D11_FORMAT_SUPPORT_TEXTURE2D;
                         if(screen->is_format_supported(screen, format, PIPE_TEXTURE_CUBE, 0, PIPE_BIND_SAMPLER_VIEW))
-                               support |= D3D11_FORMAT_SUPPORT_TEXTURE2D | sampler_view;
+                               support |= D3D11_FORMAT_SUPPORT_TEXTURECUBE;
                         if(screen->is_format_supported(screen, format, PIPE_TEXTURE_3D, 0, PIPE_BIND_SAMPLER_VIEW))
-                               support |= D3D11_FORMAT_SUPPORT_TEXTURE3D | sampler_view;
-                        if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET))
+                               support |= D3D11_FORMAT_SUPPORT_TEXTURE3D;
+
+                       if(support & (D3D11_FORMAT_SUPPORT_TEXTURE1D | D3D11_FORMAT_SUPPORT_TEXTURE2D |
+                                     D3D11_FORMAT_SUPPORT_TEXTURE3D | D3D11_FORMAT_SUPPORT_TEXTURECUBE))
+                       {
+                               support |=
+                                       D3D11_FORMAT_SUPPORT_SHADER_LOAD |
+                                       D3D11_FORMAT_SUPPORT_SHADER_SAMPLE |
+                                       D3D11_FORMAT_SUPPORT_MIP |
+                                       D3D11_FORMAT_SUPPORT_MIP_AUTOGEN;
+                               if(util_format_is_depth_or_stencil(format))
+                                       support |= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON;
+                       }
+
+                       if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET | PIPE_BIND_BLENDABLE))
                                support |= D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_RENDER_TARGET | D3D11_FORMAT_SUPPORT_BLENDABLE;
-                        if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL))
+                       else
+                       if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_RENDER_TARGET))
+                               support |= D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_RENDER_TARGET;
+                       if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_DEPTH_STENCIL))
                                support |= D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_DEPTH_STENCIL;
-                        if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_DISPLAY_TARGET))
+                       if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_DISPLAY_TARGET))
                                support |= D3D11_FORMAT_SUPPORT_DISPLAY;
+
+                       unsigned ms;
+                       for(ms = 2; ms <= 8; ++ms)
+                       {
+                               if(screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, ms, PIPE_BIND_RENDER_TARGET))
+                               {
+                                       support |= D3D11_FORMAT_SUPPORT_MULTISAMPLE_RENDERTARGET | D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE;
+                                       break;
+                               }
+                       }
+                       if(ms <= 8 && screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, ms, PIPE_BIND_SAMPLER_VIEW))
+                               support |= D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD;
+
                        format_support[format] = support;
                }
                *out_format_support = support;