d3d1x: use resource format if view format is UNKNOWN
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Mon, 17 Oct 2011 18:50:23 +0000 (20:50 +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 401e3121c43304ec48e0e456eb4369df517a8e04..8f740ba5af9ad83180f96edea3442dbbf62db496 100644 (file)
@@ -973,9 +973,10 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
 #endif
                SYNCHRONIZED;
 
+               const struct pipe_resource* resource = ((GalliumD3D11Resource<>*)iresource)->resource;
+
                if(!desc)
                {
-                       struct pipe_resource* resource = ((GalliumD3D11Resource<>*)iresource)->resource;
                        init_pipe_to_dxgi_format();
                        memset(&def_desc, 0, sizeof(def_desc));
                        def_desc.Format = pipe_to_dxgi_format[resource->format];
@@ -1030,7 +1031,7 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
                memset(&templat, 0, sizeof(templat));
                if(invalid(format >= DXGI_FORMAT_COUNT))
                        return E_INVALIDARG;
-               templat.format = dxgi_to_pipe_format[desc->Format];
+               templat.format = (desc->Format == DXGI_FORMAT_UNKNOWN) ? resource->format : dxgi_to_pipe_format[desc->Format];
                if(!templat.format)
                        return E_NOTIMPL;
                templat.swizzle_r = PIPE_SWIZZLE_RED;
@@ -1102,10 +1103,11 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
        {
                SYNCHRONIZED;
 
+               const struct pipe_resource* resource = ((GalliumD3D11Resource<>*)iresource)->resource;
+
                D3D11_RENDER_TARGET_VIEW_DESC def_desc;
                if(!desc)
                {
-                       struct pipe_resource* resource = ((GalliumD3D11Resource<>*)iresource)->resource;
                        init_pipe_to_dxgi_format();
                        memset(&def_desc, 0, sizeof(def_desc));
                        def_desc.Format = pipe_to_dxgi_format[resource->format];
@@ -1148,7 +1150,7 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
                memset(&templat, 0, sizeof(templat));
                if(invalid(desc->format >= DXGI_FORMAT_COUNT))
                        return E_INVALIDARG;
-               templat.format = dxgi_to_pipe_format[desc->Format];
+               templat.format = (desc->Format == DXGI_FORMAT_UNKNOWN) ? resource->format : dxgi_to_pipe_format[desc->Format];
                if(!templat.format)
                        return E_NOTIMPL;
                templat.usage = PIPE_BIND_RENDER_TARGET;
@@ -1196,10 +1198,11 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
        {
                SYNCHRONIZED;
 
+               const struct pipe_resource* resource = ((GalliumD3D11Resource<>*)iresource)->resource;
+
                D3D11_DEPTH_STENCIL_VIEW_DESC def_desc;
                if(!desc)
                {
-                       struct pipe_resource* resource = ((GalliumD3D11Resource<>*)iresource)->resource;
                        init_pipe_to_dxgi_format();
                        memset(&def_desc, 0, sizeof(def_desc));
                        def_desc.Format = pipe_to_dxgi_format[resource->format];
@@ -1234,7 +1237,7 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
                memset(&templat, 0, sizeof(templat));
                if(invalid(desc->format >= DXGI_FORMAT_COUNT))
                        return E_INVALIDARG;
-               templat.format = dxgi_to_pipe_format[desc->Format];
+               templat.format = (desc->Format == DXGI_FORMAT_UNKNOWN) ? resource->format : dxgi_to_pipe_format[desc->Format];
                if(!templat.format)
                        return E_NOTIMPL;
                templat.usage = PIPE_BIND_DEPTH_STENCIL;