st/va: Check NULL pointer
[mesa.git] / src / gallium / state_trackers / nine / basetexture9.c
index 110df79769e75501fea1dabc449477b3d4065a72..829a7c61f50568a3b07b936d0c41faecdb6ee1e6 100644 (file)
@@ -57,7 +57,8 @@ NineBaseTexture9_ctor( struct NineBaseTexture9 *This,
     user_assert(!(Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) ||
                 Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL);
     user_assert(!(Usage & D3DUSAGE_DYNAMIC) ||
-                Pool != D3DPOOL_MANAGED, D3DERR_INVALIDCALL);
+                !(Pool == D3DPOOL_MANAGED ||
+                  Pool == D3DPOOL_SCRATCH), D3DERR_INVALIDCALL);
 
     hr = NineResource9_ctor(&This->base, pParams, initResource, alloc, Type, Pool, Usage);
     if (FAILED(hr))
@@ -108,7 +109,7 @@ NineBaseTexture9_dtor( struct NineBaseTexture9 *This )
     NineResource9_dtor(&This->base);
 }
 
-DWORD WINAPI
+DWORD NINE_WINAPI
 NineBaseTexture9_SetLOD( struct NineBaseTexture9 *This,
                          DWORD LODNew )
 {
@@ -129,7 +130,7 @@ NineBaseTexture9_SetLOD( struct NineBaseTexture9 *This,
     return old;
 }
 
-DWORD WINAPI
+DWORD NINE_WINAPI
 NineBaseTexture9_GetLOD( struct NineBaseTexture9 *This )
 {
     DBG("This=%p\n", This);
@@ -137,7 +138,7 @@ NineBaseTexture9_GetLOD( struct NineBaseTexture9 *This )
     return This->managed.lod;
 }
 
-DWORD WINAPI
+DWORD NINE_WINAPI
 NineBaseTexture9_GetLevelCount( struct NineBaseTexture9 *This )
 {
     DBG("This=%p\n", This);
@@ -147,7 +148,7 @@ NineBaseTexture9_GetLevelCount( struct NineBaseTexture9 *This )
     return This->base.info.last_level + 1;
 }
 
-HRESULT WINAPI
+HRESULT NINE_WINAPI
 NineBaseTexture9_SetAutoGenFilterType( struct NineBaseTexture9 *This,
                                        D3DTEXTUREFILTERTYPE FilterType )
 {
@@ -164,7 +165,7 @@ NineBaseTexture9_SetAutoGenFilterType( struct NineBaseTexture9 *This,
     return D3D_OK;
 }
 
-D3DTEXTUREFILTERTYPE WINAPI
+D3DTEXTUREFILTERTYPE NINE_WINAPI
 NineBaseTexture9_GetAutoGenFilterType( struct NineBaseTexture9 *This )
 {
     DBG("This=%p\n", This);
@@ -318,7 +319,7 @@ NineBaseTexture9_UploadSelf( struct NineBaseTexture9 *This )
 
             if (tex->dirty_box.width) {
                 for (l = min_level_dirty; l <= last_level; ++l) {
-                    u_box_minify_2d(&box, &tex->dirty_box, l);
+                    u_box_minify_3d(&box, &tex->dirty_box, l);
                     NineVolume9_UploadSelf(tex->volumes[l], &box);
                 }
                 memset(&tex->dirty_box, 0, sizeof(tex->dirty_box));
@@ -382,11 +383,10 @@ NineBaseTexture9_UploadSelf( struct NineBaseTexture9 *This )
     return D3D_OK;
 }
 
-void WINAPI
+void NINE_WINAPI
 NineBaseTexture9_GenerateMipSubLevels( struct NineBaseTexture9 *This )
 {
-    struct pipe_resource *resource = This->base.resource;
-
+    struct pipe_resource *resource;
     unsigned base_level = 0;
     unsigned last_level = This->base.info.last_level - This->managed.lod;
     unsigned first_layer = 0;
@@ -409,6 +409,8 @@ NineBaseTexture9_GenerateMipSubLevels( struct NineBaseTexture9 *This )
 
     last_layer = util_max_layer(This->view[0]->texture, base_level);
 
+    resource = This->base.resource;
+
     util_gen_mipmap(This->pipe, resource,
                     resource->format, base_level, last_level,
                     first_layer, last_layer, filter);
@@ -481,9 +483,9 @@ NineBaseTexture9_CreatePipeResource( struct NineBaseTexture9 *This,
     return D3D_OK;
 }
 
-#define SWIZZLE_TO_REPLACE(s) (s == UTIL_FORMAT_SWIZZLE_0 || \
-                               s == UTIL_FORMAT_SWIZZLE_1 || \
-                               s == UTIL_FORMAT_SWIZZLE_NONE)
+#define SWIZZLE_TO_REPLACE(s) (s == PIPE_SWIZZLE_0 || \
+                               s == PIPE_SWIZZLE_1 || \
+                               s == PIPE_SWIZZLE_NONE)
 
 HRESULT
 NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
@@ -509,10 +511,10 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
 
     pipe_sampler_view_reference(&This->view[sRGB], NULL);
 
-    swizzle[0] = PIPE_SWIZZLE_RED;
-    swizzle[1] = PIPE_SWIZZLE_GREEN;
-    swizzle[2] = PIPE_SWIZZLE_BLUE;
-    swizzle[3] = PIPE_SWIZZLE_ALPHA;
+    swizzle[0] = PIPE_SWIZZLE_X;
+    swizzle[1] = PIPE_SWIZZLE_Y;
+    swizzle[2] = PIPE_SWIZZLE_Z;
+    swizzle[3] = PIPE_SWIZZLE_W;
     desc = util_format_description(resource->format);
     if (desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
         /* msdn doc is incomplete here and wrong.
@@ -526,19 +528,19 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
          * all channel */
         if (This->format == D3DFMT_DF16 ||
             This->format == D3DFMT_DF24) {
-            swizzle[1] = PIPE_SWIZZLE_ZERO;
-            swizzle[2] = PIPE_SWIZZLE_ZERO;
-            swizzle[3] = PIPE_SWIZZLE_ONE;
+            swizzle[1] = PIPE_SWIZZLE_0;
+            swizzle[2] = PIPE_SWIZZLE_0;
+            swizzle[3] = PIPE_SWIZZLE_1;
         } else {
-            swizzle[1] = PIPE_SWIZZLE_RED;
-            swizzle[2] = PIPE_SWIZZLE_RED;
-            swizzle[3] = PIPE_SWIZZLE_RED;
+            swizzle[1] = PIPE_SWIZZLE_X;
+            swizzle[2] = PIPE_SWIZZLE_X;
+            swizzle[3] = PIPE_SWIZZLE_X;
         }
     } else if (resource->format == PIPE_FORMAT_RGTC2_UNORM) {
-        swizzle[0] = PIPE_SWIZZLE_GREEN;
-        swizzle[1] = PIPE_SWIZZLE_RED;
-        swizzle[2] = PIPE_SWIZZLE_ONE;
-        swizzle[3] = PIPE_SWIZZLE_ONE;
+        swizzle[0] = PIPE_SWIZZLE_Y;
+        swizzle[1] = PIPE_SWIZZLE_X;
+        swizzle[2] = PIPE_SWIZZLE_1;
+        swizzle[3] = PIPE_SWIZZLE_1;
     } else if (resource->format != PIPE_FORMAT_A8_UNORM &&
                resource->format != PIPE_FORMAT_RGTC1_UNORM) {
         /* exceptions:
@@ -548,7 +550,7 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
          * should have 1.0 for non-defined values */
         for (i = 0; i < 4; i++) {
             if (SWIZZLE_TO_REPLACE(desc->swizzle[i]))
-                swizzle[i] = PIPE_SWIZZLE_ONE;
+                swizzle[i] = PIPE_SWIZZLE_1;
         }
     }
 
@@ -578,7 +580,7 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
     return This->view ? D3D_OK : D3DERR_DRIVERINTERNALERROR;
 }
 
-void WINAPI
+void NINE_WINAPI
 NineBaseTexture9_PreLoad( struct NineBaseTexture9 *This )
 {
     DBG("This=%p\n", This);