r600g: init_flushed_depth_texture should be able to report errors
authorMarek Olšák <maraeo@gmail.com>
Tue, 17 Jul 2012 22:05:14 +0000 (00:05 +0200)
committerMarek Olšák <maraeo@gmail.com>
Tue, 17 Jul 2012 22:21:53 +0000 (00:21 +0200)
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_resource.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_texture.c

index 5486a96ed92d51d5090f97f88f47524a84ad70fc..3efc85e6750ced0f982533d5bf71c80517ba492b 100644 (file)
@@ -989,12 +989,11 @@ static struct pipe_sampler_view *evergreen_create_sampler_view(struct pipe_conte
        }
 
        if (tmp->is_depth && !tmp->is_flushing_texture) {
-               r600_init_flushed_depth_texture(ctx, texture, NULL);
-               tmp = tmp->flushed_depth_texture;
-               if (!tmp) {
+               if (!r600_init_flushed_depth_texture(ctx, texture, NULL)) {
                        FREE(view);
                        return NULL;
                }
+               tmp = tmp->flushed_depth_texture;
        }
 
        endian = r600_colorformat_endian_swap(format);
index 0046ce78b8376235c61dfad3e6bf39d8421ad8af..8e5225e2c6fd32ef20377d32c2dc0f121063d073 100644 (file)
@@ -89,7 +89,7 @@ static INLINE struct r600_resource *r600_resource(struct pipe_resource *r)
        return (struct r600_resource*)r;
 }
 
-void r600_init_flushed_depth_texture(struct pipe_context *ctx,
+bool r600_init_flushed_depth_texture(struct pipe_context *ctx,
                                     struct pipe_resource *texture,
                                     struct r600_resource_texture **staging);
 void r600_texture_depth_flush(struct pipe_context *ctx,
index e14aeacc781a4c3ad5be91a39f7e88ed4310f9e1..899d13949d7266f4a9d6681215aa4fb729327bee 100644 (file)
@@ -1006,12 +1006,11 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c
        }
 
        if (tmp->is_depth && !tmp->is_flushing_texture) {
-               r600_init_flushed_depth_texture(ctx, texture, NULL);
-               tmp = tmp->flushed_depth_texture;
-               if (!tmp) {
+               if (!r600_init_flushed_depth_texture(ctx, texture, NULL)) {
                        FREE(view);
                        return NULL;
                }
+               tmp = tmp->flushed_depth_texture;
        }
 
        endian = r600_colorformat_endian_swap(format);
index cbb9e5a9f48bef70ac6ff8cd7d82c177d2b6d351..5a6d755e10983ebe690228e6845b80cf6c154f86 100644 (file)
@@ -738,7 +738,7 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
                                                                  stride, 0, buf, FALSE, &surface);
 }
 
-void r600_init_flushed_depth_texture(struct pipe_context *ctx,
+bool r600_init_flushed_depth_texture(struct pipe_context *ctx,
                                     struct pipe_resource *texture,
                                     struct r600_resource_texture **staging)
 {
@@ -748,7 +748,7 @@ void r600_init_flushed_depth_texture(struct pipe_context *ctx,
                        staging : &rtex->flushed_depth_texture;
 
        if (!staging && rtex->flushed_depth_texture)
-               return; /* it's ready */
+               return true; /* it's ready */
 
        resource.target = texture->target;
        resource.format = texture->format;
@@ -768,11 +768,11 @@ void r600_init_flushed_depth_texture(struct pipe_context *ctx,
        *flushed_depth_texture = (struct r600_resource_texture *)ctx->screen->resource_create(ctx->screen, &resource);
        if (*flushed_depth_texture == NULL) {
                R600_ERR("failed to create temporary texture to hold flushed depth\n");
-               return;
+               return false;
        }
 
        (*flushed_depth_texture)->is_flushing_texture = TRUE;
-
+       return true;
 }
 
 void r600_texture_depth_flush(struct pipe_context *ctx,
@@ -783,19 +783,14 @@ void r600_texture_depth_flush(struct pipe_context *ctx,
 {
        struct r600_resource_texture *rtex = (struct r600_resource_texture*)texture;
 
-       r600_init_flushed_depth_texture(ctx, texture, staging);
+       if (!r600_init_flushed_depth_texture(ctx, texture, staging))
+               return;
 
        if (staging) {
-               if (!*staging)
-                       return; /* error */
-
                r600_blit_uncompress_depth(ctx, rtex, *staging,
                                           first_level, last_level,
                                           first_layer, last_layer);
        } else {
-               if (!rtex->flushed_depth_texture)
-                       return; /* error */
-
                r600_blit_uncompress_depth(ctx, rtex, NULL,
                                           first_level, last_level,
                                           first_layer, last_layer);