Mesa (gallium-sampler-view): gallium: Check for OOM condition when creating a sampler view.

Michał Król michal at kemper.freedesktop.org
Thu Mar 11 14:31:27 UTC 2010


Module: Mesa
Branch: gallium-sampler-view
Commit: 530b9910c2fd25344e6d28b6d9aa0eaad31618e7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=530b9910c2fd25344e6d28b6d9aa0eaad31618e7

Author: Michal Krol <michal at vmware.com>
Date:   Thu Mar 11 15:30:21 2010 +0100

gallium: Check for OOM condition when creating a sampler view.

---

 src/gallium/drivers/cell/ppu/cell_pipe_state.c  |   12 +++++++-----
 src/gallium/drivers/i915/i915_state.c           |   12 +++++++-----
 src/gallium/drivers/i965/brw_pipe_sampler.c     |   12 +++++++-----
 src/gallium/drivers/llvmpipe/lp_state_sampler.c |   12 +++++++-----
 src/gallium/drivers/nv30/nv30_state.c           |   12 +++++++-----
 src/gallium/drivers/nv40/nv40_state.c           |   12 +++++++-----
 src/gallium/drivers/r300/r300_state.c           |   12 +++++++-----
 src/gallium/drivers/softpipe/sp_state_sampler.c |   12 +++++++-----
 src/gallium/drivers/svga/svga_pipe_sampler.c    |   12 +++++++-----
 9 files changed, 63 insertions(+), 45 deletions(-)

diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
index 2fc8293..059ce85 100644
--- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -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;
 }
diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c
index 884abe6..e549977 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -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;
 }
diff --git a/src/gallium/drivers/i965/brw_pipe_sampler.c b/src/gallium/drivers/i965/brw_pipe_sampler.c
index fbc3a07..d2aa2bc 100644
--- a/src/gallium/drivers/i965/brw_pipe_sampler.c
+++ b/src/gallium/drivers/i965/brw_pipe_sampler.c
@@ -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;
 }
diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
index 2df86a0..2645441 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
@@ -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;
 }
diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
index 321575d..fb3075f 100644
--- a/src/gallium/drivers/nv30/nv30_state.c
+++ b/src/gallium/drivers/nv30/nv30_state.c
@@ -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;
 }
diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
index 120dc42..28a48a6 100644
--- a/src/gallium/drivers/nv40/nv40_state.c
+++ b/src/gallium/drivers/nv40/nv40_state.c
@@ -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;
 }
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 09bbf6c..d73ec78 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -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;
 }
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 68ea13f..d501952 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -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;
 }
diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c
index ebd1b94..82d525c 100644
--- a/src/gallium/drivers/svga/svga_pipe_sampler.c
+++ b/src/gallium/drivers/svga/svga_pipe_sampler.c
@@ -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;
 }




More information about the mesa-commit mailing list