r300g: Miscellania. Avoid draw segfaults, s/true/TRUE/, etc.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 1 Nov 2009 19:54:52 +0000 (11:54 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Sun, 1 Nov 2009 19:54:52 +0000 (11:54 -0800)
Cleared out my git stash.

src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_debug.c
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_vs.c

index b1738452de07d26ef39233a2486982a13797dc15..ae7015634ccd82e334d8000afaedfeac9ffa4dfc 100644 (file)
@@ -339,7 +339,7 @@ void r300_init_surface_functions(struct r300_context* r300);
 
 static INLINE boolean DBG_ON(struct r300_context * ctx, unsigned flags)
 {
-    return (ctx->debug & flags) ? true : false;
+    return (ctx->debug & flags) ? TRUE : FALSE;
 }
 
 static INLINE void DBG(struct r300_context * ctx, unsigned flags, const char * fmt, ...)
index 421253ca722f9b67ae431a8bbde139a2c939f2fa..2a6ed54ac9bd20d297cdebf3f02468441aa17ad0 100644 (file)
@@ -49,7 +49,7 @@ static struct debug_option debug_options[] = {
 void r300_init_debug(struct r300_context * ctx)
 {
     const char * options = debug_get_option("RADEON_DEBUG", 0);
-    boolean printhint = false;
+    boolean printhint = FALSE;
     size_t length;
     struct debug_option * opt;
 
@@ -71,14 +71,14 @@ void r300_init_debug(struct r300_context * ctx)
 
             if (!opt->name) {
                 debug_printf("Unknown debug option: %s\n", options);
-                printhint = true;
+                printhint = TRUE;
             }
 
             options += length;
         }
 
         if (!ctx->debug)
-            printhint = true;
+            printhint = TRUE;
     }
 
     if (printhint || ctx->debug & DBG_HELP) {
index 5b03c1aa6c1f2090ac619b8dc30ee9d244da242d..79972dbb49e682b50416b1ba0e944412262e0ce6 100644 (file)
@@ -800,7 +800,7 @@ validate:
     for (i = 0; i < r300->texture_count; i++) {
         tex = r300->textures[i];
         if (!tex)
-           continue;
+            continue;
         if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
                     RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
             r300->context.flush(&r300->context, 0, NULL);
index 4cf01389d2b3d5a529e19b75b8b39fd00fea265c..af063d4b20a9f52dd5231fed4802ec9adc798f14 100644 (file)
@@ -281,7 +281,9 @@ static void
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    draw_flush(r300->draw);
+    if (r300->draw) {
+        draw_flush(r300->draw);
+    }
 
     r300->framebuffer_state = *state;
 
@@ -444,10 +446,13 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
     struct r300_context* r300 = r300_context(pipe);
     struct r300_rs_state* rs = (struct r300_rs_state*)state;
 
-    draw_flush(r300->draw);
-    draw_set_rasterizer_state(r300->draw, &rs->rs);
+    if (r300->draw) {
+        draw_flush(r300->draw);
+        draw_set_rasterizer_state(r300->draw, &rs->rs);
+    }
 
     r300->rs_state = rs;
+    /* XXX Clean these up when we move to atom emits */
     r300->dirty_state |= R300_NEW_RASTERIZER;
     r300->dirty_state |= R300_NEW_RS_BLOCK;
     r300->dirty_state |= R300_NEW_SCISSOR;
@@ -623,8 +628,10 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
 
     r300->vertex_buffer_count = count;
 
-    draw_flush(r300->draw);
-    draw_set_vertex_buffers(r300->draw, count, buffers);
+    if (r300->draw) {
+        draw_flush(r300->draw);
+        draw_set_vertex_buffers(r300->draw, count, buffers);
+    }
 }
 
 static void r300_set_vertex_elements(struct pipe_context* pipe,
@@ -633,8 +640,15 @@ static void r300_set_vertex_elements(struct pipe_context* pipe,
 {
     struct r300_context* r300 = r300_context(pipe);
 
-    draw_flush(r300->draw);
-    draw_set_vertex_elements(r300->draw, count, elements);
+    memcpy(r300->vertex_elements, elements,
+        sizeof(struct pipe_vertex_element) * count);
+
+    r300->vertex_element_count = count;
+
+    if (r300->draw) {
+        draw_flush(r300->draw);
+        draw_set_vertex_elements(r300->draw, count, elements);
+    }
 }
 
 static void* r300_create_vs_state(struct pipe_context* pipe,
index eca85879a7f71fe4ecb02244703e4ad26ab33d67..74ef416dc140149cb9272d9cf0313565aa6e3815 100644 (file)
@@ -37,7 +37,7 @@ static void set_vertex_inputs_outputs(struct r300_vertex_program_compiler * c)
     struct tgsi_shader_info* info = &vs->info;
     struct tgsi_parse_context parser;
     struct tgsi_full_declaration * decl;
-    boolean pointsize = false;
+    boolean pointsize = FALSE;
     int out_colors = 0;
     int colors = 0;
     int out_generic = 0;
@@ -52,7 +52,7 @@ static void set_vertex_inputs_outputs(struct r300_vertex_program_compiler * c)
     for (i = 0; i < info->num_outputs; i++) {
         switch (info->output_semantic_name[i]) {
             case TGSI_SEMANTIC_PSIZE:
-                pointsize = true;
+                pointsize = TRUE;
                 break;
             case TGSI_SEMANTIC_COLOR:
                 out_colors++;