diff options
author | Christian König <[email protected]> | 2011-06-05 00:11:41 +0200 |
---|---|---|
committer | Christian König <[email protected]> | 2011-06-05 00:11:41 +0200 |
commit | 1eb957bb4108123bea95b818e0544e3b5f255e08 (patch) | |
tree | d7febd8e6cc841ab16dca53f031322ec47d5ccd9 /src/gallium/drivers/r300 | |
parent | a6c76c8a90dc8995feed3c61b02dbd8408149036 (diff) | |
parent | 6491e9593d5cbc5644eb02593a2f562447efdcbb (diff) |
Merge remote-tracking branch 'origin/master' into pipe-video
Diffstat (limited to 'src/gallium/drivers/r300')
-rw-r--r-- | src/gallium/drivers/r300/r300_blit.c | 40 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_debug.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_emit.c | 13 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_hyperz.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_query.c | 70 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_render.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_screen.h | 23 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state.c | 38 |
9 files changed, 100 insertions, 95 deletions
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 4ec77df8fb7..388ebcdbf32 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -30,14 +30,24 @@ enum r300_blitter_op /* bitmask */ { - R300_CLEAR = 1, - R300_CLEAR_SURFACE = 2, - R300_COPY = 4 + R300_STOP_QUERY = 1, + R300_SAVE_TEXTURES = 2, + R300_SAVE_FRAMEBUFFER = 4, + R300_IGNORE_RENDER_COND = 8, + + R300_CLEAR = R300_STOP_QUERY, + + R300_CLEAR_SURFACE = R300_STOP_QUERY | R300_SAVE_FRAMEBUFFER, + + R300_COPY = R300_STOP_QUERY | R300_SAVE_FRAMEBUFFER | + R300_SAVE_TEXTURES | R300_IGNORE_RENDER_COND, + + R300_DECOMPRESS = R300_STOP_QUERY | R300_IGNORE_RENDER_COND, }; static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op op) { - if (r300->query_current) { + if ((op & R300_STOP_QUERY) && r300->query_current) { r300->blitter_saved_query = r300->query_current; r300_stop_query(r300); } @@ -57,11 +67,11 @@ static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op o util_blitter_save_vertex_buffers(r300->blitter, r300->vbuf_mgr->nr_vertex_buffers, r300->vbuf_mgr->vertex_buffer); - if (op & (R300_CLEAR_SURFACE | R300_COPY)) { + if (op & R300_SAVE_FRAMEBUFFER) { util_blitter_save_framebuffer(r300->blitter, r300->fb_state.state); } - if (op & R300_COPY) { + if (op & R300_SAVE_TEXTURES) { struct r300_textures_state* state = (struct r300_textures_state*)r300->textures_state.state; @@ -73,6 +83,14 @@ static void r300_blitter_begin(struct r300_context* r300, enum r300_blitter_op o r300->blitter, state->sampler_view_count, (struct pipe_sampler_view**)state->sampler_views); } + + if (op & R300_IGNORE_RENDER_COND) { + /* Save the flag. */ + r300->blitter_saved_skip_rendering = r300->skip_rendering+1; + r300->skip_rendering = FALSE; + } else { + r300->blitter_saved_skip_rendering = 0; + } } static void r300_blitter_end(struct r300_context *r300) @@ -81,6 +99,11 @@ static void r300_blitter_end(struct r300_context *r300) r300_resume_query(r300, r300->blitter_saved_query); r300->blitter_saved_query = NULL; } + + if (r300->blitter_saved_skip_rendering) { + /* Restore the flag. */ + r300->skip_rendering = r300->blitter_saved_skip_rendering-1; + } } static uint32_t r300_depth_clear_cb_value(enum pipe_format format, @@ -234,6 +257,9 @@ static void r300_clear(struct pipe_context* pipe, /* Setup Hyper-Z clears. */ if (r300->hyperz_enabled) { + DBG(r300, DBG_HYPERZ, "r300: Clear memory: %s%s\n", + zmask_clear ? "ZMASK " : "", hiz_clear ? "HIZ" : ""); + if (zmask_clear) { hyperz_dcv = hyperz->zb_depthclearvalue = r300_depth_clear_value(fb->zsbuf->format, depth, stencil); @@ -371,7 +397,7 @@ void r300_decompress_zmask(struct r300_context *r300) r300->zmask_decompress = TRUE; r300_mark_atom_dirty(r300, &r300->hyperz_state); - r300_blitter_begin(r300, R300_CLEAR); + r300_blitter_begin(r300, R300_DECOMPRESS); util_blitter_clear_depth_custom(r300->blitter, fb->width, fb->height, 0, r300->dsa_decompress_zmask); r300_blitter_end(r300); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 139dd210b8f..d71db0001a9 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -584,6 +584,8 @@ struct r300_context { uint32_t zbuffer_bpp; /* Whether rendering is conditional and should be skipped. */ boolean skip_rendering; + /* The flag above saved by blitter. */ + unsigned char blitter_saved_skip_rendering; /* Point sprites texcoord index, 1 bit per texcoord */ int sprite_coord_enable; /* Whether two-sided color selection is enabled (AKA light_twoside). */ diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index b60cfd1f248..9a0052ac6d1 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -27,7 +27,7 @@ #include <stdio.h> static const struct debug_named_value debug_options[] = { - { "info", DBG_INFO, "Print hardware info"}, + { "info", DBG_INFO, "Print hardware info (printed by default on debug builds"}, { "fp", DBG_FP, "Log fragment program compilation" }, { "vp", DBG_VP, "Log vertex program compilation" }, { "pstat", DBG_P_STAT, "Log vertex/fragment program stats" }, @@ -37,14 +37,11 @@ static const struct debug_named_value debug_options[] = { { "psc", DBG_PSC, "Log vertex stream registers" }, { "tex", DBG_TEX, "Log basic info about textures" }, { "texalloc", DBG_TEXALLOC, "Log texture mipmap tree info" }, - { "fall", DBG_FALL, "Log fallbacks" }, { "rs", DBG_RS, "Log rasterizer" }, { "fb", DBG_FB, "Log framebuffer" }, { "cbzb", DBG_CBZB, "Log fast color clear info" }, { "hyperz", DBG_HYPERZ, "Log HyperZ info" }, - { "upload", DBG_UPLOAD, "Log user buffer upload info" }, { "scissor", DBG_SCISSOR, "Log scissor info" }, - { "fakeocc", DBG_FAKE_OCC, "Use fake occlusion queries" }, { "anisohq", DBG_ANISOHQ, "Use high quality anisotropic filtering" }, { "notiling", DBG_NO_TILING, "Disable tiling" }, { "noimmd", DBG_NO_IMMD, "Disable immediate mode" }, diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 874037ed9fd..d214af4cd5b 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -439,6 +439,19 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state) OUT_CS_REG(R300_ZB_ZMASK_OFFSET, 0); OUT_CS_REG(R300_ZB_ZMASK_PITCH, surf->pitch_zmask); } + /* Set up a dummy zbuffer. Otherwise occlusion queries won't work. + * Use the first colorbuffer, we will disable writes in the DSA state + * so as not to corrupt it. */ + } else if (fb->nr_cbufs) { + surf = r300_surface(fb->cbufs[0]); + + OUT_CS_REG(R300_ZB_FORMAT, R300_DEPTHFORMAT_16BIT_INT_Z); + + OUT_CS_REG(R300_ZB_DEPTHOFFSET, 0); + OUT_CS_RELOC(surf); + + OUT_CS_REG(R300_ZB_DEPTHPITCH, 4 | R300_DEPTHMICROTILE_TILED_SQUARE); + OUT_CS_RELOC(surf); } END_CS; diff --git a/src/gallium/drivers/r300/r300_hyperz.c b/src/gallium/drivers/r300/r300_hyperz.c index e946d61d0ed..0f021e9f4e8 100644 --- a/src/gallium/drivers/r300/r300_hyperz.c +++ b/src/gallium/drivers/r300/r300_hyperz.c @@ -195,6 +195,7 @@ static void r300_update_hyperz(struct r300_context* r300) } return; } + DBG(r300, DBG_HYPERZ, "r300: Z-func: %i\n", dsa->dsa.depth.func); /* Set the HiZ function if needed. */ if (r300->hiz_func == HIZ_FUNC_NONE) { diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index 9752a519491..782f041e926 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -156,75 +156,23 @@ static void r300_render_condition(struct pipe_context *pipe, uint64_t result = 0; boolean wait; + r300->skip_rendering = FALSE; + if (query) { wait = mode == PIPE_RENDER_COND_WAIT || mode == PIPE_RENDER_COND_BY_REGION_WAIT; - if (!r300_get_query_result(pipe, query, wait, &result)) { - r300->skip_rendering = FALSE; - } else { + if (r300_get_query_result(pipe, query, wait, &result)) { r300->skip_rendering = result == 0; } - } else { - r300->skip_rendering = FALSE; } } -/*************************************************************************** - * Fake occlusion queries (for debugging) - ***************************************************************************/ - -static unsigned r300_fake_query; - -static struct pipe_query *r300_fake_create_query(struct pipe_context *pipe, - unsigned query_type) -{ - return (struct pipe_query*)&r300_fake_query; -} - -static void r300_fake_destroy_query(struct pipe_context* pipe, - struct pipe_query* query) -{ -} - -static void r300_fake_begin_query(struct pipe_context* pipe, - struct pipe_query* query) -{ -} - -static void r300_fake_end_query(struct pipe_context* pipe, - struct pipe_query* query) -{ -} - -static boolean r300_fake_get_query_result(struct pipe_context* pipe, - struct pipe_query* query, - boolean wait, void* vresult) -{ - uint64_t *result = (uint64_t*)vresult; - *result = 1000000; - return TRUE; -} - -static void r300_fake_render_condition(struct pipe_context *pipe, - struct pipe_query *query, uint mode) -{ -} - void r300_init_query_functions(struct r300_context* r300) { - if (DBG_ON(r300, DBG_FAKE_OCC)) { - r300->context.create_query = r300_fake_create_query; - r300->context.destroy_query = r300_fake_destroy_query; - r300->context.begin_query = r300_fake_begin_query; - r300->context.end_query = r300_fake_end_query; - r300->context.get_query_result = r300_fake_get_query_result; - r300->context.render_condition = r300_fake_render_condition; - } else { - r300->context.create_query = r300_create_query; - r300->context.destroy_query = r300_destroy_query; - r300->context.begin_query = r300_begin_query; - r300->context.end_query = r300_end_query; - r300->context.get_query_result = r300_get_query_result; - r300->context.render_condition = r300_render_condition; - } + r300->context.create_query = r300_create_query; + r300->context.destroy_query = r300_destroy_query; + r300->context.begin_query = r300_begin_query; + r300->context.end_query = r300_end_query; + r300->context.get_query_result = r300_get_query_result; + r300->context.render_condition = r300_render_condition; } diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 429b85545f7..b24e7faa644 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -1200,6 +1200,9 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter, const float zeros[4] = {0, 0, 0, 0}; CS_LOCALS(r300); + if (r300->skip_rendering) + return; + r300->context.set_vertex_buffers(&r300->context, 0, NULL); if (type == UTIL_BLITTER_ATTRIB_TEXCOORD) diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index bca86edb1d7..e5c53bf3500 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -88,23 +88,20 @@ radeon_winsys(struct pipe_screen *screen) { #define DBG_TEX (1 << 5) #define DBG_TEXALLOC (1 << 6) #define DBG_RS (1 << 7) -#define DBG_FALL (1 << 8) -#define DBG_FB (1 << 9) -#define DBG_RS_BLOCK (1 << 10) -#define DBG_CBZB (1 << 11) -#define DBG_HYPERZ (1 << 12) -#define DBG_SCISSOR (1 << 13) -#define DBG_UPLOAD (1 << 14) -#define DBG_INFO (1 << 15) +#define DBG_FB (1 << 8) +#define DBG_RS_BLOCK (1 << 9) +#define DBG_CBZB (1 << 10) +#define DBG_HYPERZ (1 << 11) +#define DBG_SCISSOR (1 << 12) +#define DBG_INFO (1 << 13) /* Features. */ #define DBG_ANISOHQ (1 << 16) #define DBG_NO_TILING (1 << 17) #define DBG_NO_IMMD (1 << 18) -#define DBG_FAKE_OCC (1 << 19) -#define DBG_NO_OPT (1 << 20) -#define DBG_NO_CBZB (1 << 21) -#define DBG_NO_ZMASK (1 << 22) -#define DBG_NO_HIZ (1 << 23) +#define DBG_NO_OPT (1 << 19) +#define DBG_NO_CBZB (1 << 20) +#define DBG_NO_ZMASK (1 << 21) +#define DBG_NO_HIZ (1 << 22) /* Statistics. */ #define DBG_P_STAT (1 << 25) /*@}*/ diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index bc6c67dd034..7127ea1ac16 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -549,6 +549,10 @@ static void* dsa->z_stencil_control |= (r300_translate_depth_stencil_function(state->depth.func) << R300_Z_FUNC_SHIFT); + } else { + /* We must enable depth test, otherwise occlusion queries won't work. */ + dsa->z_buffer_control |= R300_Z_ENABLE; + dsa->z_stencil_control |= R300_ZS_ALWAYS; } /* Stencil buffer setup. */ @@ -632,11 +636,13 @@ static void* OUT_CB_REG(R500_FG_ALPHA_VALUE, dsa->alpha_value); END_CB; + /* We must enable depth test, otherwise occlusion queries won't work. + * We setup a dummy zbuffer to silent the CS checker, see emit_fb_state. */ BEGIN_CB(dsa->cb_zb_no_readwrite, 10); OUT_CB_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function); OUT_CB_REG_SEQ(R300_ZB_CNTL, 3); - OUT_CB(0); - OUT_CB(0); + OUT_CB(R300_Z_ENABLE); + OUT_CB(R300_ZS_ALWAYS); OUT_CB(0); OUT_CB_REG(R500_ZB_STENCILREFMASK_BF, 0); OUT_CB_REG(R500_FG_ALPHA_VALUE, dsa->alpha_value); @@ -645,8 +651,8 @@ static void* BEGIN_CB(dsa->cb_fp16_zb_no_readwrite, 10); OUT_CB_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function_fp16); OUT_CB_REG_SEQ(R300_ZB_CNTL, 3); - OUT_CB(0); - OUT_CB(0); + OUT_CB(R300_Z_ENABLE); + OUT_CB(R300_ZS_ALWAYS); OUT_CB(0); OUT_CB_REG(R500_ZB_STENCILREFMASK_BF, 0); OUT_CB_REG(R500_FG_ALPHA_VALUE, dsa->alpha_value); @@ -792,12 +798,14 @@ void r300_mark_fb_state_dirty(struct r300_context *r300, /* Now compute the fb_state atom size. */ r300->fb_state.size = 2 + (8 * state->nr_cbufs); - if (r300->cbzb_clear) + if (r300->cbzb_clear) { r300->fb_state.size += 10; - else if (state->zsbuf) { + } else if (state->zsbuf) { r300->fb_state.size += 10; if (r300->hyperz_enabled) r300->fb_state.size += 8; + } else if (state->nr_cbufs) { + r300->fb_state.size += 10; } /* The size of the rest of atoms stays the same. */ @@ -1457,6 +1465,8 @@ r300_create_sampler_view(struct pipe_context *pipe, boolean dxtc_swizzle = r300_screen(pipe->screen)->caps.dxtc_swizzle; if (view) { + unsigned hwformat; + view->base = *templ; view->base.reference.count = 1; view->base.context = pipe; @@ -1468,11 +1478,19 @@ r300_create_sampler_view(struct pipe_context *pipe, view->swizzle[2] = templ->swizzle_b; view->swizzle[3] = templ->swizzle_a; + hwformat = r300_translate_texformat(templ->format, + view->swizzle, + is_r500, + dxtc_swizzle); + + if (hwformat == ~0) { + fprintf(stderr, "r300: Ooops. Got unsupported format %s in %s.\n", + util_format_short_name(templ->format), __func__); + } + assert(hwformat != ~0); + view->format = tex->tx_format; - view->format.format1 |= r300_translate_texformat(templ->format, - view->swizzle, - is_r500, - dxtc_swizzle); + view->format.format1 |= hwformat; if (is_r500) { view->format.format2 |= r500_tx_format_msb_bit(templ->format); } |