diff options
author | Brian <[email protected]> | 2007-11-08 09:16:14 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2007-11-08 09:16:14 -0700 |
commit | 2c1184626879cb349bcdc87eebb82da87f1a9f85 (patch) | |
tree | e4cccd7728b6a885f257f79586e6b9efaa5184ea /src/mesa | |
parent | 98c539d337fec8b4e21d9788b52ff551462e90d6 (diff) |
Fix some issues hit when rendering to a depth-only renderbuffer (shadowtex).
Added 16bpp case to translate_depth_format().
Added framebuffer_size() to determine framebuffer size.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state_emit.c | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/src/mesa/pipe/i915simple/i915_state_emit.c b/src/mesa/pipe/i915simple/i915_state_emit.c index ee44e526cac..d793e92a14d 100644 --- a/src/mesa/pipe/i915simple/i915_state_emit.c +++ b/src/mesa/pipe/i915simple/i915_state_emit.c @@ -50,8 +50,44 @@ static unsigned translate_format( unsigned format ) static unsigned translate_depth_format( unsigned zformat ) { - assert(zformat == PIPE_FORMAT_S8_Z24); - return DEPTH_FRMT_24_FIXED_8_OTHER; + switch (zformat) { + case PIPE_FORMAT_S8_Z24: + return DEPTH_FRMT_24_FIXED_8_OTHER; + case PIPE_FORMAT_U_Z16: + return DEPTH_FRMT_16_FIXED; + default: + assert(0); + return 0; + } +} + + +/** + * Examine framebuffer state to determine width, height. + */ +static boolean +framebuffer_size(const struct pipe_framebuffer_state *fb, + uint *width, uint *height) +{ + if (fb->cbufs[0]) { + *width = fb->cbufs[0]->width; + *height = fb->cbufs[0]->height; + return TRUE; + } + else if (fb->zbuf) { + *width = fb->zbuf->width; + *height = fb->zbuf->height; + return TRUE; + } + else if (fb->sbuf) { + *width = fb->sbuf->width; + *height = fb->sbuf->height; + return TRUE; + } + else { + *width = *height = 0; + return FALSE; + } } @@ -207,9 +243,14 @@ i915_emit_hardware_state(struct i915_context *i915 ) } { - unsigned cformat = translate_format( i915->framebuffer.cbufs[0]->format ); - unsigned zformat = 0; + unsigned cformat, zformat = 0; + if (i915->framebuffer.cbufs[0]) + cformat = i915->framebuffer.cbufs[0]->format; + else + cformat = PIPE_FORMAT_U_A8_R8_G8_B8; /* arbitrary */ + cformat = translate_format(cformat); + if (i915->framebuffer.zbuf) zformat = translate_depth_format( i915->framebuffer.zbuf->format ); @@ -322,8 +363,9 @@ i915_emit_hardware_state(struct i915_context *i915 ) /* drawing surface size */ /* 6 dwords, 0 relocs */ { - int w = i915->framebuffer.cbufs[0]->width; - int h = i915->framebuffer.cbufs[0]->height; + uint w, h; + boolean k = framebuffer_size(&i915->framebuffer, &w, &h); + assert(k); OUT_BATCH(_3DSTATE_DRAW_RECT_CMD); OUT_BATCH(0); @@ -336,4 +378,3 @@ i915_emit_hardware_state(struct i915_context *i915 ) i915->hardware_dirty = 0; } - |