gallium: Check for OOM condition when creating a sampler view.
authorMichal Krol <michal@vmware.com>
Thu, 11 Mar 2010 14:30:21 +0000 (15:30 +0100)
committerMichal Krol <michal@vmware.com>
Thu, 11 Mar 2010 14:30:21 +0000 (15:30 +0100)
src/gallium/drivers/cell/ppu/cell_pipe_state.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/i965/brw_pipe_sampler.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/nv30/nv30_state.c
src/gallium/drivers/nv40/nv40_state.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/softpipe/sp_state_sampler.c
src/gallium/drivers/svga/svga_pipe_sampler.c

index 2fc82933e4d49ec30e9f41f5de0661e75d6aa09e..059ce8597bcf9883fd4a26564d803a4b1d81eb9e 100644 (file)
@@ -298,11 +298,13 @@ cell_create_sampler_view(struct pipe_context *pipe,
 {
    struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
 
-   *view = *templ;
-   view->reference.count = 1;
-   view->texture = NULL;
-   pipe_texture_reference(&view->texture, texture);
-   view->context = pipe;
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
 
    return view;
 }
index 884abe622b34b2f4463afa5abab56997abbad1fd..e54997736f977ad8131b1cf22fb9d18a6efe6ed8 100644 (file)
@@ -598,11 +598,13 @@ i915_create_sampler_view(struct pipe_context *pipe,
 {
    struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
 
-   *view = *templ;
-   view->reference.count = 1;
-   view->texture = NULL;
-   pipe_texture_reference(&view->texture, texture);
-   view->context = pipe;
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
 
    return view;
 }
index fbc3a07d61ecfc97d4531ed1d1d167c6dddb532b..d2aa2bc9f3579d9669ac5e7fdd83de87373479b0 100644 (file)
@@ -219,11 +219,13 @@ brw_create_sampler_view(struct pipe_context *pipe,
 {
    struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
 
-   *view = *templ;
-   view->reference.count = 1;
-   view->texture = NULL;
-   pipe_texture_reference(&view->texture, texture);
-   view->context = pipe;
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
 
    return view;
 }
index 2df86a081484e5d0563b5678a9c93eba5b29e70e..2645441b58c9460a108bd296dffeab45687d2394 100644 (file)
@@ -170,11 +170,13 @@ llvmpipe_create_sampler_view(struct pipe_context *pipe,
 {
    struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
 
-   *view = *templ;
-   view->reference.count = 1;
-   view->texture = NULL;
-   pipe_texture_reference(&view->texture, texture);
-   view->context = pipe;
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
 
    return view;
 }
index 321575da0a9462c7ffa7ea3a4eafcba3c7ef5a57..fb3075f4c814165c766310bbdb9ebe45a5074dbf 100644 (file)
@@ -304,11 +304,13 @@ nv30_create_sampler_view(struct pipe_context *pipe,
 {
        struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
 
-       *view = *templ;
-       view->reference.count = 1;
-       view->texture = NULL;
-       pipe_texture_reference(&view->texture, texture);
-       view->context = pipe;
+       if (view) {
+               *view = *templ;
+               view->reference.count = 1;
+               view->texture = NULL;
+               pipe_texture_reference(&view->texture, texture);
+               view->context = pipe;
+       }
 
        return view;
 }
index 120dc42f7b1beebbefa8c2cfabaac0c438ec1320..28a48a63f1c6e0f08c3e7f031148b95a8bb516af 100644 (file)
@@ -314,11 +314,13 @@ nv40_create_sampler_view(struct pipe_context *pipe,
 {
        struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
 
-       *view = *templ;
-       view->reference.count = 1;
-       view->texture = NULL;
-       pipe_texture_reference(&view->texture, texture);
-       view->context = pipe;
+       if (view) {
+               *view = *templ;
+               view->reference.count = 1;
+               view->texture = NULL;
+               pipe_texture_reference(&view->texture, texture);
+               view->context = pipe;
+       }
 
        return view;
 }
index 09bbf6c60e2c03699021ef0b2f551684a95fb3c4..d73ec78fda85b3bd18ce67020f6b1fe55e800bf5 100644 (file)
@@ -980,11 +980,13 @@ r300_create_sampler_view(struct pipe_context *pipe,
    struct r300_context *r300 = r300_context(pipe);
    struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
 
-   *view = *templ;
-   view->reference.count = 1;
-   view->texture = NULL;
-   pipe_texture_reference(&view->texture, texture);
-   view->context = pipe;
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
 
    return view;
 }
index 68ea13f8d51c61de3318da45db98a64a9f636bbd..d501952bba9e5846830cd723952ea82e74fd65c9 100644 (file)
@@ -128,11 +128,13 @@ softpipe_create_sampler_view(struct pipe_context *pipe,
 {
    struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
 
-   *view = *templ;
-   view->reference.count = 1;
-   view->texture = NULL;
-   pipe_texture_reference(&view->texture, texture);
-   view->context = pipe;
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
 
    return view;
 }
index ebd1b9499728f4b57fa5741b08f691439751fdc9..82d525ca33f90fe93492f4b5ed6a7ad730c756c9 100644 (file)
@@ -183,11 +183,13 @@ svga_create_sampler_view(struct pipe_context *pipe,
 {
    struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
 
-   *view = *templ;
-   view->reference.count = 1;
-   view->texture = NULL;
-   pipe_texture_reference(&view->texture, texture);
-   view->context = pipe;
+   if (view) {
+      *view = *templ;
+      view->reference.count = 1;
+      view->texture = NULL;
+      pipe_texture_reference(&view->texture, texture);
+      view->context = pipe;
+   }
 
    return view;
 }