diff options
Diffstat (limited to 'src')
80 files changed, 1645 insertions, 948 deletions
diff --git a/src/gallium/auxiliary/trace/trace_drm.h b/src/gallium/auxiliary/trace/trace_drm.h new file mode 100644 index 0000000000..892bd9860c --- /dev/null +++ b/src/gallium/auxiliary/trace/trace_drm.h @@ -0,0 +1,165 @@ +/* + * Copyright 2009 Jakob Bornecrantz <jakob@vmware.com> + *                Corbin Simpson <MostAwesomeDude@gmail.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#ifndef TRACE_DRM_H +#define TRACE_DRM_H + +#include "state_tracker/drm_api.h" + +#include "trace/tr_buffer.h" +#include "trace/tr_context.h" +#include "trace/tr_screen.h" +#include "trace/tr_texture.h" + +struct drm_api hooks; + +static struct pipe_screen * +trace_drm_create_screen(int fd, struct drm_create_screen_arg *arg) +{ +	struct pipe_screen *screen; + +	if (arg && arg->mode != DRM_CREATE_NORMAL) +		return NULL; + +	screen = hooks.create_screen(fd, arg); + +	return trace_screen_create(screen); +}; + +static struct pipe_context * +trace_drm_create_context(struct pipe_screen *_screen) +{ +	struct pipe_screen *screen; +	struct pipe_context *pipe; + +	if (trace_enabled()) +		screen = trace_screen(_screen)->screen; +	else +		screen = _screen; + +	pipe = hooks.create_context(screen); + +	if (trace_enabled()) +		pipe = trace_context_create(_screen, pipe); + +	return pipe; +}; + +static boolean +trace_drm_buffer_from_texture(struct pipe_texture *_texture, +                              struct pipe_buffer **_buffer, +                              unsigned *stride) +{ +	struct pipe_texture *texture; +	struct pipe_buffer *buffer = NULL; +	boolean result; + +	if (trace_enabled()) +		texture = trace_texture(_texture)->texture; +	else +		texture = _texture; + +	result = hooks.buffer_from_texture(texture, &buffer, stride); + +	if (result && _buffer) +		buffer = trace_buffer_create(trace_screen(texture->screen), buffer); + +	if (_buffer) +		*_buffer = buffer; +	else +		pipe_buffer_reference(&buffer, NULL); + +	return result; +} + +static struct pipe_buffer * +trace_drm_buffer_from_handle(struct pipe_screen *_screen, +                             const char *name, +                             unsigned handle) +{ +	struct pipe_screen *screen; +	struct pipe_buffer *result; + +	if (trace_enabled()) +		screen = trace_screen(_screen)->screen; +	else +		screen = _screen; + +	result = hooks.buffer_from_handle(screen, name, handle); + +	if (trace_enabled()) +		result = trace_buffer_create(trace_screen(_screen), result); + +	return result; +} + +static boolean +trace_drm_handle_from_buffer(struct pipe_screen *_screen, +                             struct pipe_buffer *_buffer, +                             unsigned *handle) +{ +	struct pipe_screen *screen; +	struct pipe_buffer *buffer; + +	if (trace_enabled()) { +		screen = trace_screen(_screen)->screen; +		buffer = trace_buffer(_buffer)->buffer; +	} else { +		screen = _screen; +		buffer = _buffer; +	} + +	return hooks.handle_from_buffer(screen, buffer, handle); +} + +static boolean +trace_drm_global_handle_from_buffer(struct pipe_screen *_screen, +                                    struct pipe_buffer *_buffer, +                                    unsigned *handle) +{ +	struct pipe_screen *screen; +	struct pipe_buffer *buffer; + +	if (trace_enabled()) { +		screen = trace_screen(_screen)->screen; +		buffer = trace_buffer(_buffer)->buffer; +	} else { +		screen = _screen; +		buffer = _buffer; +	} + +	return hooks.global_handle_from_buffer(screen, buffer, handle); +} + +struct drm_api drm_api_hooks = +{ +	.create_screen = trace_drm_create_screen, +	.create_context = trace_drm_create_context, + +	.buffer_from_texture = trace_drm_buffer_from_texture, +	.buffer_from_handle = trace_drm_buffer_from_handle, +	.handle_from_buffer = trace_drm_handle_from_buffer, +	.global_handle_from_buffer = trace_drm_global_handle_from_buffer, +}; + +#endif /* TRACE_DRM_H */ diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c index 9d95ad918c..758f706c51 100644 --- a/src/gallium/drivers/r300/r300_chipset.c +++ b/src/gallium/drivers/r300/r300_chipset.c @@ -34,7 +34,6 @@ void r300_parse_chipset(struct r300_capabilities* caps)      caps->is_r500 = FALSE;      caps->num_vert_fpus = 4; -      /* Note: These are not ordered by PCI ID. I leave that task to GCC,       * which will perform the ordering while collating jump tables. Instead,       * I've tried to group them according to capabilities and age. */ @@ -349,7 +348,4 @@ void r300_parse_chipset(struct r300_capabilities* caps)                  caps->pci_id);              break;      } - -    /* XXX SW TCL is broken so no forcing it off right now -    caps->has_tcl = FALSE; */  } diff --git a/src/gallium/drivers/r300/r300_chipset.h b/src/gallium/drivers/r300/r300_chipset.h index 21eebeae60..5b2e1f0568 100644 --- a/src/gallium/drivers/r300/r300_chipset.h +++ b/src/gallium/drivers/r300/r300_chipset.h @@ -34,8 +34,6 @@ struct r300_capabilities {      int family;      /* The number of vertex floating-point units */      int num_vert_fpus; -    /* The number of fragment pipes */ -    int num_frag_pipes;      /* Whether or not TCL is physically present */      boolean has_tcl;      /* Whether or not this is an RV515 or newer; R500s have many differences diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index a4e89c37d1..21c0fe2b80 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -129,7 +129,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,      if (!r300)          return NULL; -    /* XXX this could be refactored now? */      r300->winsys = r300_winsys;      r300->context.winsys = (struct pipe_winsys*)r300_winsys; @@ -146,8 +145,15 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,      r300->context.is_texture_referenced = r300_is_texture_referenced;      r300->context.is_buffer_referenced = r300_is_buffer_referenced; +    /* Create a Draw. This is used for vert collation and SW TCL. */      r300->draw = draw_create(); +    /* Enable our renderer. */      draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300)); +    /* Tell Draw that we can always do non-UCP clipping. */ +    draw_set_driver_clipping(r300->draw, TRUE); +    /* Force Draw to never do viewport transform, since (again) we can do +     * transform in hardware, always. */ +    draw_set_viewport_state(r300->draw, &r300_viewport_identity);      r300->blend_color_state = CALLOC_STRUCT(r300_blend_color_state);      r300->rs_block = CALLOC_STRUCT(r300_rs_block); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 96f1f11246..58f1fa0e2e 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -63,6 +63,11 @@ struct r300_rs_state {      /* Draw-specific rasterizer state */      struct pipe_rasterizer_state rs; +    /* Whether or not to enable the VTE. This is referenced at the very +     * last moment during emission of VTE state, to decide whether or not +     * the VTE should be used for transformation. */ +    boolean enable_vte; +      uint32_t vap_control_status;    /* R300_VAP_CNTL_STATUS: 0x2140 */      uint32_t point_size;            /* R300_GA_POINT_SIZE: 0x421c */      uint32_t point_minmax;          /* R300_GA_POINT_MINMAX: 0x4230 */ @@ -255,6 +260,11 @@ struct r300_vertex_shader {      } instructions[128]; /*< XXX magic number */  }; +static struct pipe_viewport_state r300_viewport_identity = { +    .scale = {1.0, 1.0, 1.0, 1.0}, +    .translate = {0.0, 0.0, 0.0, 0.0}, +}; +  struct r300_context {      /* Parent class */      struct pipe_context context; diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 1ff72172eb..ffc93eb591 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -152,10 +152,12 @@ void r500_fs_dump(struct r500_fragment_shader* fs)  static void r300_vs_op_dump(uint32_t op)  { -    if (op & 0x81) { -        debug_printf("PVS_MACRO_OP_2CLK_M2X_ADD\n"); -    } else if (op & 0x80) { -        debug_printf("   PVS_MACRO_OP_2CLK_MADD\n"); +    if (op & 0x80) { +        if (op & 0x1) { +            debug_printf("PVS_MACRO_OP_2CLK_M2X_ADD\n"); +        } else { +            debug_printf("   PVS_MACRO_OP_2CLK_MADD\n"); +        }      } else if (op & 0x40) {          debug_printf("%s\n", r300_vs_me_ops[op & 0x1f]);      } else { diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index c73d5a0b44..0cb0507fc8 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -163,6 +163,7 @@ void r300_emit_fb_state(struct r300_context* r300,      BEGIN_CS((8 * fb->nr_cbufs) + (fb->zsbuf ? 8 : 0) + 4);      for (i = 0; i < fb->nr_cbufs; i++) {          tex = (struct r300_texture*)fb->cbufs[i]->texture; +        assert(tex && tex->buffer && "cbuf is marked, but NULL!");          pixpitch = tex->stride / tex->tex.block.size;          OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1); @@ -177,7 +178,8 @@ void r300_emit_fb_state(struct r300_context* r300,      if (fb->zsbuf) {          tex = (struct r300_texture*)fb->zsbuf->texture; -        pixpitch = (tex->stride / tex->tex.block.size); +        assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); +        pixpitch = tex->stride / tex->tex.block.size;          OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1);          OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0); @@ -234,7 +236,7 @@ void r300_emit_rs_block_state(struct r300_context* r300,      }      for (i = 0; i < 8; i++) {          OUT_CS(rs->ip[i]); -        debug_printf("ip %d: 0x%08x\n", i, rs->ip[i]); +        /* debug_printf("ip %d: 0x%08x\n", i, rs->ip[i]); */      }      OUT_CS_REG_SEQ(R300_RS_COUNT, 2); @@ -248,11 +250,11 @@ void r300_emit_rs_block_state(struct r300_context* r300,      }      for (i = 0; i < 8; i++) {          OUT_CS(rs->inst[i]); -        debug_printf("inst %d: 0x%08x\n", i, rs->inst[i]); +        /* debug_printf("inst %d: 0x%08x\n", i, rs->inst[i]); */      } -    debug_printf("count: 0x%08x inst_count: 0x%08x\n", rs->count, -            rs->inst_count); +    /* debug_printf("count: 0x%08x inst_count: 0x%08x\n", rs->count, +     *        rs->inst_count); */      END_CS;  } @@ -334,22 +336,22 @@ void r300_emit_vertex_format_state(struct r300_context* r300)      OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2);      OUT_CS(r300->vertex_info.vinfo.hwfmt[2]);      OUT_CS(r300->vertex_info.vinfo.hwfmt[3]); -    for (i = 0; i < 4; i++) { -        debug_printf("hwfmt%d: 0x%08x\n", i, -                r300->vertex_info.vinfo.hwfmt[i]); -    } +    /* for (i = 0; i < 4; i++) { +     *    debug_printf("hwfmt%d: 0x%08x\n", i, +     *            r300->vertex_info.vinfo.hwfmt[i]); +     * } */      OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_0, 8);      for (i = 0; i < 8; i++) {          OUT_CS(r300->vertex_info.vap_prog_stream_cntl[i]); -        debug_printf("prog_stream_cntl%d: 0x%08x\n", i, -                r300->vertex_info.vap_prog_stream_cntl[i]); +        /* debug_printf("prog_stream_cntl%d: 0x%08x\n", i, +         *        r300->vertex_info.vap_prog_stream_cntl[i]); */      }      OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_EXT_0, 8);      for (i = 0; i < 8; i++) {          OUT_CS(r300->vertex_info.vap_prog_stream_cntl_ext[i]); -        debug_printf("prog_stream_cntl_ext%d: 0x%08x\n", i, -                r300->vertex_info.vap_prog_stream_cntl_ext[i]); +        /* debug_printf("prog_stream_cntl_ext%d: 0x%08x\n", i, +         *        r300->vertex_info.vap_prog_stream_cntl_ext[i]); */      }      END_CS;  } @@ -427,7 +429,11 @@ void r300_emit_viewport_state(struct r300_context* r300,      OUT_CS_32F(viewport->zscale);      OUT_CS_32F(viewport->zoffset); -    OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control); +    if (r300->rs_state->enable_vte) { +        OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control); +    } else { +        OUT_CS_REG(R300_VAP_VTE_CNTL, 0); +    }      END_CS;  } @@ -460,7 +466,6 @@ void r300_emit_dirty_state(struct r300_context* r300)      for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) {          tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]->texture;          assert(tex && tex->buffer && "cbuf is marked, but NULL!"); -        if (!tex->buffer) return;          r300->winsys->add_buffer(r300->winsys, tex->buffer,                  0, RADEON_GEM_DOMAIN_VRAM);      } @@ -468,10 +473,16 @@ void r300_emit_dirty_state(struct r300_context* r300)      if (r300->framebuffer_state.zsbuf) {          tex = (struct r300_texture*)r300->framebuffer_state.zsbuf->texture;          assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); -        if (!tex->buffer) return;          r300->winsys->add_buffer(r300->winsys, tex->buffer,                  0, RADEON_GEM_DOMAIN_VRAM);      } +    /* ...textures... */ +    for (i = 0; i < r300->texture_count; i++) { +        tex = r300->textures[i]; +        assert(tex && tex->buffer && "texture is marked, but NULL!"); +        r300->winsys->add_buffer(r300->winsys, tex->buffer, +                RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0); +    }      /* ...and vertex buffer. */      if (r300->vbo) {          r300->winsys->add_buffer(r300->winsys, r300->vbo, diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index d2c5998c26..a6f1efe356 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -87,23 +87,25 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)              } else {                  return 0;              } -            return 0;          case PIPE_CAP_GLSL: -            /* IN THEORY */ -            return 0; +            if (r300screen->caps->is_r500) { +                return 1; +            } else { +                return 0; +            }          case PIPE_CAP_S3TC:              /* IN THEORY */              return 0;          case PIPE_CAP_ANISOTROPIC_FILTER: -            /* IN THEORY */ -            return 0; +            return 1;          case PIPE_CAP_POINT_SPRITE:              /* IN THEORY */              return 0;          case PIPE_CAP_MAX_RENDER_TARGETS:              return 4;          case PIPE_CAP_OCCLUSION_QUERY: -            return 1; +            /* IN THEORY */ +            return 0;          case PIPE_CAP_TEXTURE_SHADOW_MAP:              /* IN THEORY */              return 0; @@ -152,17 +154,20 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)  static float r300_get_paramf(struct pipe_screen* pscreen, int param)  { +    struct r300_screen* r300screen = r300_screen(pscreen); +      switch (param) {          case PIPE_CAP_MAX_LINE_WIDTH:          case PIPE_CAP_MAX_LINE_WIDTH_AA: -            /* XXX this is the biggest thing that will fit in that register. -            * Perhaps the actual rendering limits are less? */ -            return 10922.0f;          case PIPE_CAP_MAX_POINT_WIDTH:          case PIPE_CAP_MAX_POINT_WIDTH_AA: -            /* XXX this is the biggest thing that will fit in that register. -             * Perhaps the actual rendering limits are less? */ -            return 10922.0f; +            /* The maximum dimensions of the colorbuffer are our practical +             * rendering limits. 2048 pixels should be enough for anybody. */ +            if (r300screen->caps->is_r500) { +                return 4096.0f; +            } else { +                return 2048.0f; +            }          case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:              return 16.0f;          case PIPE_CAP_MAX_TEXTURE_LOD_BIAS: @@ -230,9 +235,16 @@ static boolean r300_is_format_supported(struct pipe_screen* pscreen,          case PIPE_TEXTURE_2D:              return check_tex_2d_format(format,                  r300_screen(pscreen)->caps->is_r500); +        case PIPE_TEXTURE_1D: +        case PIPE_TEXTURE_3D: +        case PIPE_TEXTURE_CUBE: +            debug_printf("r300: Implementation error: Unsupported format " +                    "target: %d\n", target); +            break;          default: -            debug_printf("r300: Warning: Got unknown format target: %d\n", -                format); +            debug_printf("r300: Fatal: This is not a format target: %d\n", +                target); +            assert(0);              break;      } @@ -337,7 +349,6 @@ struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys)          return NULL;      caps->pci_id = r300_winsys->pci_id; -    caps->num_frag_pipes = r300_winsys->gb_pipes;      r300_parse_chipset(caps); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 0143e228c4..4e65fbbabe 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -62,8 +62,6 @@ static void* r300_create_blend_state(struct pipe_context* pipe,      }      /* PIPE_LOGICOP_* don't need to be translated, fortunately. */ -    /* XXX are logicops still allowed if blending's disabled? -     * Does Gallium take care of it for us? */      if (state->logicop_enable) {          blend->rop = R300_RB3D_ROPCNTL_ROP_ENABLE |                  (state->logicop_func) << R300_RB3D_ROPCNTL_ROP_SHIFT; @@ -121,7 +119,7 @@ static void r300_set_clip_state(struct pipe_context* pipe,                                  const struct pipe_clip_state* state)  {      struct r300_context* r300 = r300_context(pipe); -    /* XXX Draw */ +    /* XXX add HW TCL clipping setup */      draw_flush(r300->draw);      draw_set_clip_state(r300->draw, state);  } @@ -257,6 +255,7 @@ static void r300_set_edgeflags(struct pipe_context* pipe,                                 const unsigned* bitfield)  {      /* XXX you know it's bad when i915 has this blank too */ +    /* XXX and even worse, I have no idea WTF the bitfield is */  }  static void @@ -289,6 +288,7 @@ static void* r300_create_fs_state(struct pipe_context* pipe,      /* Copy state directly into shader. */      fs->state = *shader; +    fs->state.tokens = tgsi_dup_tokens(shader->tokens);      tgsi_scan_shader(shader->tokens, &fs->info); @@ -317,13 +317,15 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader)  /* Delete fragment shader state. */  static void r300_delete_fs_state(struct pipe_context* pipe, void* shader)  { +    struct r3xx_fragment_shader* fs = (struct r3xx_fragment_shader*)shader; +    FREE(fs->state.tokens);      FREE(shader);  }  static void r300_set_polygon_stipple(struct pipe_context* pipe,                                       const struct pipe_poly_stipple* state)  { -    /* XXX */ +    /* XXX no idea how to set this up, but not terribly important */  }  /* Create a new rasterizer state based on the CSO rasterizer state. @@ -341,6 +343,8 @@ static void* r300_create_rs_state(struct pipe_context* pipe,      /* Copy rasterizer state for Draw. */      rs->rs = *state; +    rs->enable_vte = !state->bypass_vs_clip_and_viewport; +      /* If bypassing TCL, or if no TCL engine is present, turn off the HW TCL.       * Else, enable HW TCL and force Draw's TCL off. */      if (state->bypass_vs_clip_and_viewport || @@ -555,43 +559,35 @@ static void r300_set_viewport_state(struct pipe_context* pipe,  {      struct r300_context* r300 = r300_context(pipe); -    draw_flush(r300->draw); - -    if (r300_screen(r300->context.screen)->caps->has_tcl) { -        /* Do the transform in HW. */ -        r300->viewport_state->vte_control = R300_VTX_W0_FMT; +    /* Do the transform in HW. */ +    r300->viewport_state->vte_control = R300_VTX_W0_FMT; -        if (state->scale[0] != 1.0f) { -            assert(state->scale[0] != 0.0f); -            r300->viewport_state->xscale = state->scale[0]; -            r300->viewport_state->vte_control |= R300_VPORT_X_SCALE_ENA; -        } -        if (state->scale[1] != 1.0f) { -            assert(state->scale[1] != 0.0f); -            r300->viewport_state->yscale = state->scale[1]; -            r300->viewport_state->vte_control |= R300_VPORT_Y_SCALE_ENA; -        } -        if (state->scale[2] != 1.0f) { -            assert(state->scale[2] != 0.0f); -            r300->viewport_state->zscale = state->scale[2]; -            r300->viewport_state->vte_control |= R300_VPORT_Z_SCALE_ENA; -        } -        if (state->translate[0] != 0.0f) { -            r300->viewport_state->xoffset = state->translate[0]; -            r300->viewport_state->vte_control |= R300_VPORT_X_OFFSET_ENA; -        } -        if (state->translate[1] != 0.0f) { -            r300->viewport_state->yoffset = state->translate[1]; -            r300->viewport_state->vte_control |= R300_VPORT_Y_OFFSET_ENA; -        } -        if (state->translate[2] != 0.0f) { -            r300->viewport_state->zoffset = state->translate[2]; -            r300->viewport_state->vte_control |= R300_VPORT_Z_OFFSET_ENA; -        } -    } else { -        r300->viewport_state->vte_control = 0; -        /* Have Draw do the actual transform. */ -        draw_set_viewport_state(r300->draw, state); +    if (state->scale[0] != 1.0f) { +        assert(state->scale[0] != 0.0f); +        r300->viewport_state->xscale = state->scale[0]; +        r300->viewport_state->vte_control |= R300_VPORT_X_SCALE_ENA; +    } +    if (state->scale[1] != 1.0f) { +        assert(state->scale[1] != 0.0f); +        r300->viewport_state->yscale = state->scale[1]; +        r300->viewport_state->vte_control |= R300_VPORT_Y_SCALE_ENA; +    } +    if (state->scale[2] != 1.0f) { +        assert(state->scale[2] != 0.0f); +        r300->viewport_state->zscale = state->scale[2]; +        r300->viewport_state->vte_control |= R300_VPORT_Z_SCALE_ENA; +    } +    if (state->translate[0] != 0.0f) { +        r300->viewport_state->xoffset = state->translate[0]; +        r300->viewport_state->vte_control |= R300_VPORT_X_OFFSET_ENA; +    } +    if (state->translate[1] != 0.0f) { +        r300->viewport_state->yoffset = state->translate[1]; +        r300->viewport_state->vte_control |= R300_VPORT_Y_OFFSET_ENA; +    } +    if (state->translate[2] != 0.0f) { +        r300->viewport_state->zoffset = state->translate[2]; +        r300->viewport_state->vte_control |= R300_VPORT_Z_OFFSET_ENA;      }      r300->dirty_state |= R300_NEW_VIEWPORT; @@ -631,6 +627,7 @@ static void* r300_create_vs_state(struct pipe_context* pipe,          struct r300_vertex_shader* vs = CALLOC_STRUCT(r300_vertex_shader);          /* Copy state directly into shader. */          vs->state = *shader; +        vs->state.tokens = tgsi_dup_tokens(shader->tokens);          tgsi_scan_shader(shader->tokens, &vs->info); @@ -676,6 +673,7 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)          struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader;          draw_delete_vertex_shader(r300->draw, vs->draw); +        FREE(vs->state.tokens);          FREE(shader);      } else {          draw_delete_vertex_shader(r300->draw, diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index c4c9784a00..caa5f3b543 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -162,26 +162,40 @@ static void r300_vs_tab_routes(struct r300_context* r300,  static void r300_vertex_psc(struct r300_context* r300,                              struct r300_vertex_format* vformat)  { +    struct r300_screen* r300screen = r300_screen(r300->context.screen);      struct vertex_info* vinfo = &vformat->vinfo;      int* tab = vformat->vs_tab;      uint32_t temp; -    int i; +    int i, attrib_count; -    debug_printf("r300: attrib count: %d\n", vinfo->num_attribs); -    for (i = 0; i < vinfo->num_attribs; i++) { -        debug_printf("r300: attrib: offset %d, interp %d, size %d," -               " tab %d\n", vinfo->attrib[i].src_index, -               vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit, -               tab[i]); +    /* Vertex shaders have no semantics on their inputs, +     * so PSC should just route stuff based on their info, +     * and not on attrib information. */ +    if (r300screen->caps->has_tcl) { +        attrib_count = r300->vs->info.num_inputs; +        debug_printf("r300: routing %d attribs in psc for vs\n", +                attrib_count); +    } else { +        attrib_count = vinfo->num_attribs; +        debug_printf("r300: attrib count: %d\n", attrib_count); +        for (i = 0; i < attrib_count; i++) { +            debug_printf("r300: attrib: offset %d, interp %d, size %d," +                   " tab %d\n", vinfo->attrib[i].src_index, +                   vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit, +                   tab[i]); +        }      } -    for (i = 0; i < vinfo->num_attribs; i++) { +    for (i = 0; i < attrib_count; i++) {          /* Make sure we have a proper destination for our attribute */          assert(tab[i] != -1);          /* Add the attribute to the PSC table. */ -        temp = translate_vertex_data_type(vinfo->attrib[i].emit) | -            (tab[i] << R300_DST_VEC_LOC_SHIFT); +        temp = r300screen->caps->has_tcl ? +            R300_DATA_TYPE_FLOAT_4 : +            translate_vertex_data_type(vinfo->attrib[i].emit); +        temp |= tab[i] << R300_DST_VEC_LOC_SHIFT; +          if (i & 1) {              vformat->vap_prog_stream_cntl[i >> 1] &= 0x0000ffff;              vformat->vap_prog_stream_cntl[i >> 1] |= temp << 16; @@ -206,7 +220,6 @@ static void r300_vertex_psc(struct r300_context* r300,  /* Update the vertex format. */  static void r300_update_vertex_format(struct r300_context* r300)  { -    struct r300_screen* r300screen = r300_screen(r300->context.screen);      struct r300_vertex_format vformat;      int i; diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 91b93fc367..22c8e199ae 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -353,25 +353,6 @@ static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format)  /* Non-CSO state. (For now.) */ -static INLINE uint32_t r300_translate_gb_pipes(int pipe_count) -{ -    switch (pipe_count) { -        case 1: -            return R300_GB_TILE_PIPE_COUNT_RV300; -            break; -        case 2: -            return R300_GB_TILE_PIPE_COUNT_R300; -            break; -        case 3: -            return R300_GB_TILE_PIPE_COUNT_R420_3P; -            break; -        case 4: -            return R300_GB_TILE_PIPE_COUNT_R420; -            break; -    } -    return 0; -} -  static INLINE uint32_t translate_vertex_data_type(int type) {      switch (type) {          case EMIT_1F: diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 8bd9b41bd7..9dde662802 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -34,36 +34,19 @@ void r300_emit_invariant_state(struct r300_context* r300)      struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps;      CS_LOCALS(r300); -    BEGIN_CS(30 + (caps->has_tcl ? 2: 0)); +    BEGIN_CS(26 + (caps->has_tcl ? 2: 0));      /*** Graphics Backend (GB) ***/      /* Various GB enables */      OUT_CS_REG(R300_GB_ENABLE, 0x0);      /* Subpixel multisampling for AA */      OUT_CS_REG(R300_GB_MSPOS0, 0x66666666); -    OUT_CS_REG(R300_GB_MSPOS1, 0x66666666); -    /* GB tile config and pipe setup */ -    OUT_CS_REG(R300_GB_TILE_CONFIG, R300_GB_TILE_DISABLE | -        r300_translate_gb_pipes(caps->num_frag_pipes)); +    OUT_CS_REG(R300_GB_MSPOS1, 0x6666666);      /* Source of fog depth */      OUT_CS_REG(R300_GB_SELECT, R300_GB_FOG_SELECT_1_1_W);      /* AA enable */      OUT_CS_REG(R300_GB_AA_CONFIG, 0x0); -    /*** Geometry Assembly (GA) ***/ -    /* GA errata fixes. */ -    if (caps->is_r500) { -        OUT_CS_REG(R300_GA_ENHANCE, -                R300_GA_ENHANCE_DEADLOCK_CNTL_PREVENT_TCL | -                R300_GA_ENHANCE_FASTSYNC_CNTL_ENABLE | -                R500_GA_ENHANCE_REG_READWRITE_ENABLE | -                R500_GA_ENHANCE_REG_NOSTALL_ENABLE); -    } else { -        OUT_CS_REG(R300_GA_ENHANCE, -                R300_GA_ENHANCE_DEADLOCK_CNTL_PREVENT_TCL | -                R300_GA_ENHANCE_FASTSYNC_CNTL_ENABLE); -    } -      /*** Fog (FG) ***/      OUT_CS_REG(R300_FG_FOG_BLEND, 0x0);      OUT_CS_REG(R300_FG_FOG_COLOR_R, 0x0); @@ -86,7 +69,7 @@ void r300_emit_invariant_state(struct r300_context* r300)      END_CS;      /* XXX unsorted stuff from surface_fill */ -    BEGIN_CS(79 + (caps->has_tcl ? 7 : 0)); +    BEGIN_CS(77 + (caps->has_tcl ? 7 : 0));      /* Flush PVS. */      OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); @@ -113,11 +96,14 @@ void r300_emit_invariant_state(struct r300_context* r300)      OUT_CS_32F(0.0);      OUT_CS_REG_SEQ(R300_GA_POINT_S1, 1);      OUT_CS_32F(1.0); +    /* XXX line tex stuffing */ +    OUT_CS_REG_SEQ(R300_GA_LINE_S0, 1); +    OUT_CS_32F(0.0); +    OUT_CS_REG_SEQ(R300_GA_LINE_S1, 1); +    OUT_CS_32F(1.0);      OUT_CS_REG(R300_GA_TRIANGLE_STIPPLE, 0x5 |          (0x5 << R300_GA_TRIANGLE_STIPPLE_Y_SHIFT_SHIFT));      /* XXX this big chunk should be refactored into rs_state */ -    OUT_CS_REG(R300_GA_LINE_S0, 0x00000000); -    OUT_CS_REG(R300_GA_LINE_S1, 0x3F800000);      OUT_CS_REG(R300_GA_SOLID_RG, 0x00000000);      OUT_CS_REG(R300_GA_SOLID_BA, 0x00000000);      OUT_CS_REG(R300_GA_POLY_MODE, 0x00000000); @@ -144,8 +130,6 @@ void r300_emit_invariant_state(struct r300_context* r300)      OUT_CS_REG(R300_VAP_VTX_STATE_CNTL, 0x1);      OUT_CS_REG(R300_VAP_VSM_VTX_ASSM, 0x405);      OUT_CS_REG(R300_SE_VTE_CNTL, 0x0000043F); -    /* Vertex size. */ -    OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8);      /* XXX */      OUT_CS_REG(R300_SC_CLIP_RULE, 0xaaaa); diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index 1b02239ee7..ed99c76c15 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -59,6 +59,12 @@ static void r300_fs_declare(struct r300_fs_asm* assembler,              }              break;          case TGSI_FILE_OUTPUT: +            /* Depth write. Mark the position of the output so we can +             * identify it later. */ +            if (decl->Semantic.SemanticName == TGSI_SEMANTIC_POSITION) { +                assembler->depth_output = decl->DeclarationRange.First; +            } +            break;          case TGSI_FILE_CONSTANT:              break;          case TGSI_FILE_TEMPORARY: @@ -120,6 +126,14 @@ static INLINE unsigned r300_fs_dst(struct r300_fs_asm* assembler,      return 0;  } +static INLINE boolean r300_fs_is_depr(struct r300_fs_asm* assembler, +                                      struct tgsi_dst_register* dst) +{ +    return (assembler->writes_depth && +            (dst->File == TGSI_FILE_OUTPUT) && +            (dst->Index == assembler->depth_output)); +} +  static INLINE unsigned r500_fix_swiz(unsigned s)  {      /* For historical reasons, the swizzle values x, y, z, w, and 0 are @@ -194,11 +208,17 @@ static INLINE uint32_t r300_alpha_op(unsigned op)  static INLINE uint32_t r500_rgba_op(unsigned op)  {      switch (op) { +        case TGSI_OPCODE_COS:          case TGSI_OPCODE_EX2:          case TGSI_OPCODE_LG2:          case TGSI_OPCODE_RCP:          case TGSI_OPCODE_RSQ: +        case TGSI_OPCODE_SIN:              return R500_ALU_RGBA_OP_SOP; +        case TGSI_OPCODE_DDX: +            return R500_ALU_RGBA_OP_MDH; +        case TGSI_OPCODE_DDY: +            return R500_ALU_RGBA_OP_MDV;          case TGSI_OPCODE_FRC:              return R500_ALU_RGBA_OP_FRC;          case TGSI_OPCODE_DP3: @@ -224,6 +244,8 @@ static INLINE uint32_t r500_rgba_op(unsigned op)  static INLINE uint32_t r500_alpha_op(unsigned op)  {      switch (op) { +        case TGSI_OPCODE_COS: +            return R500_ALPHA_OP_COS;          case TGSI_OPCODE_EX2:              return R500_ALPHA_OP_EX2;          case TGSI_OPCODE_LG2: @@ -234,6 +256,12 @@ static INLINE uint32_t r500_alpha_op(unsigned op)              return R500_ALPHA_OP_RSQ;          case TGSI_OPCODE_FRC:              return R500_ALPHA_OP_FRC; +        case TGSI_OPCODE_SIN: +            return R500_ALPHA_OP_SIN; +        case TGSI_OPCODE_DDX: +            return R500_ALPHA_OP_MDH; +        case TGSI_OPCODE_DDY: +            return R500_ALPHA_OP_MDV;          case TGSI_OPCODE_DP3:          case TGSI_OPCODE_DP4:          case TGSI_OPCODE_DPH: @@ -302,16 +330,21 @@ static INLINE void r500_emit_alu(struct r500_fragment_shader* fs,      int i = fs->instruction_count;      if (dst->DstRegister.File == TGSI_FILE_OUTPUT) { -        fs->instructions[i].inst0 = R500_INST_TYPE_OUT | -        R500_ALU_OMASK(dst->DstRegister.WriteMask); +        fs->instructions[i].inst0 = R500_INST_TYPE_OUT; +        if (r300_fs_is_depr(assembler, dst)) { +            fs->instructions[i].inst4 = R500_W_OMASK; +        } else { +            fs->instructions[i].inst0 |= +                R500_ALU_OMASK(dst->DstRegister.WriteMask); +        }      } else {          fs->instructions[i].inst0 = R500_INST_TYPE_ALU | -        R500_ALU_WMASK(dst->DstRegister.WriteMask); +            R500_ALU_WMASK(dst->DstRegister.WriteMask);      }      fs->instructions[i].inst0 |= R500_INST_TEX_SEM_WAIT; -    fs->instructions[i].inst4 = +    fs->instructions[i].inst4 |=          R500_ALPHA_ADDRD(r300_fs_dst(assembler, &dst->DstRegister));      fs->instructions[i].inst5 =          R500_ALU_RGBA_ADDRD(r300_fs_dst(assembler, &dst->DstRegister)); @@ -441,6 +474,9 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,       * AMD/ATI names for opcodes, please, as it facilitates using the       * documentation. */      switch (inst->Instruction.Opcode) { +        /* XXX trig needs extra prep */ +        case TGSI_OPCODE_COS: +        case TGSI_OPCODE_SIN:          /* The simple scalar ops. */          case TGSI_OPCODE_EX2:          case TGSI_OPCODE_LG2: @@ -452,6 +488,8 @@ static void r500_fs_instruction(struct r500_fragment_shader* fs,              inst->FullSrcRegisters[0].SrcRegister.SwizzleW =                  inst->FullSrcRegisters[0].SrcRegister.SwizzleX;              /* Fall through */ +        case TGSI_OPCODE_DDX: +        case TGSI_OPCODE_DDY:          case TGSI_OPCODE_FRC:              r500_emit_maths(fs, assembler, inst->FullSrcRegisters,                      &inst->FullDstRegisters[0], inst->Instruction.Opcode, 1); @@ -581,6 +619,8 @@ void r300_translate_fragment_shader(struct r300_context* r300,      }      /* Setup starting offset for immediates. */      assembler->imm_offset = consts->user_count; +    /* Enable depth writes, if needed. */ +    assembler->writes_depth = fs->info.writes_z;      /* Make sure we start at the beginning of the shader. */      if (is_r500) { diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h index 185fdd90f0..06260e61fe 100644 --- a/src/gallium/drivers/r300/r300_state_shader.h +++ b/src/gallium/drivers/r300/r300_state_shader.h @@ -57,6 +57,7 @@  #define R500_TEX_WMASK(x) ((x) << 11)  #define R500_ALU_WMASK(x) ((x) << 11)  #define R500_ALU_OMASK(x) ((x) << 15) +#define R500_W_OMASK (1 << 31)  /* TGSI constants. TGSI is like XML: If it can't solve your problems, you're   * not using enough of it. */ @@ -99,20 +100,17 @@ struct r300_fs_asm {      unsigned imm_offset;      /* Number of immediate constants. */      unsigned imm_count; +    /* Are depth writes enabled? */ +    boolean writes_depth; +    /* Depth write offset. This is the TGSI output that corresponds to +     * depth writes. */ +    unsigned depth_output;  };  void r300_translate_fragment_shader(struct r300_context* r300,                             struct r3xx_fragment_shader* fs);  static struct r300_fragment_shader r300_passthrough_fragment_shader = { -    /* XXX This is the emission code. TODO: decode -    OUT_CS_REG(R300_US_CONFIG, 0); -    OUT_CS_REG(R300_US_CODE_OFFSET, 0x0); -    OUT_CS_REG(R300_US_CODE_ADDR_0, 0x0); -    OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0); -    OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0); -    OUT_CS_REG(R300_US_CODE_ADDR_3, 0x400000); -*/      .alu_instruction_count = 1,      .tex_instruction_count = 0,      .indirections = 0, @@ -159,14 +157,6 @@ static struct r500_fragment_shader r500_passthrough_fragment_shader = {  };  static struct r300_fragment_shader r300_texture_fragment_shader = { -    /* XXX This is the emission code. TODO: decode -    OUT_CS_REG(R300_US_CONFIG, 0); -    OUT_CS_REG(R300_US_CODE_OFFSET, 0x0); -    OUT_CS_REG(R300_US_CODE_ADDR_0, 0x0); -    OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0); -    OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0); -    OUT_CS_REG(R300_US_CODE_ADDR_3, 0x400000); -*/      .alu_instruction_count = 1,      .tex_instruction_count = 0,      .indirections = 0, diff --git a/src/gallium/drivers/r300/r300_state_tcl.c b/src/gallium/drivers/r300/r300_state_tcl.c index ed9164db49..fdbcbf3db8 100644 --- a/src/gallium/drivers/r300/r300_state_tcl.c +++ b/src/gallium/drivers/r300/r300_state_tcl.c @@ -325,6 +325,8 @@ static void r300_vs_init(struct r300_vertex_shader* vs,                  break;          }      } + +    vs->instruction_count = 0;  }  void r300_translate_vertex_shader(struct r300_context* r300, diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index 4dd5b8af99..acb6192492 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -23,19 +23,17 @@  #include "r300_surface.h" -static void r300_surface_setup(struct pipe_context* pipe, -                               struct pipe_surface* dest, +static void r300_surface_setup(struct r300_context* r300, +                               struct r300_texture* dest,                                 unsigned x, unsigned y,                                 unsigned w, unsigned h)  { -    struct r300_context* r300 = r300_context(pipe); -    struct r300_capabilities* caps = r300_screen(pipe->screen)->caps; -    struct r300_texture* tex = (struct r300_texture*)dest->texture; -    unsigned pixpitch = tex->stride / tex->tex.block.size; +    struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; +    unsigned pixpitch = dest->stride / dest->tex.block.size;      CS_LOCALS(r300);      /* Make sure our target BO is okay. */ -    r300->winsys->add_buffer(r300->winsys, tex->buffer, +    r300->winsys->add_buffer(r300->winsys, dest->buffer,              0, RADEON_GEM_DOMAIN_VRAM);      if (r300->winsys->validate(r300->winsys)) {          r300->context.flush(&r300->context, 0, NULL); @@ -46,7 +44,22 @@ static void r300_surface_setup(struct pipe_context* pipe,      r300_emit_dsa_state(r300, &dsa_clear_state);      r300_emit_rs_state(r300, &rs_clear_state); -    BEGIN_CS(15); +    BEGIN_CS(24); + +    /* Viewport setup */ +    OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6); +    OUT_CS_32F((float)w); +    OUT_CS_32F((float)x); +    OUT_CS_32F((float)h); +    OUT_CS_32F((float)y); +    OUT_CS_32F(1.0); +    OUT_CS_32F(0.0); + +    OUT_CS_REG(R300_VAP_VTE_CNTL, R300_VPORT_X_SCALE_ENA | +            R300_VPORT_X_OFFSET_ENA | +            R300_VPORT_Y_SCALE_ENA | +            R300_VPORT_Y_OFFSET_ENA | +            R300_VTX_XY_FMT | R300_VTX_Z_FMT);      /* Pixel scissors. */      OUT_CS_REG_SEQ(R300_SC_SCISSORS_TL, 2); @@ -71,9 +84,9 @@ static void r300_surface_setup(struct pipe_context* pipe,      /* Setup colorbuffer. */      OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0, 1); -    OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0); +    OUT_CS_RELOC(dest->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);      OUT_CS_REG(R300_RB3D_COLORPITCH0, pixpitch | -        r300_translate_colorformat(tex->tex.format)); +        r300_translate_colorformat(dest->tex.format));      OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0xf);      END_CS; @@ -110,7 +123,7 @@ static void r300_surface_fill(struct pipe_context* pipe,          return;      } -    r300_surface_setup(r300, dest, x, y, w, h); +    r300_surface_setup(r300, tex, x, y, w, h);      /* Vertex shader setup */      if (caps->has_tcl) { @@ -134,7 +147,7 @@ static void r300_surface_fill(struct pipe_context* pipe,          r300_emit_rs_block_state(r300, &r300_rs_block_clear_state);      } -    BEGIN_CS(31); +    BEGIN_CS(26);      /* VAP stream control, mapping from input memory to PVS/RS memory */      if (caps->has_tcl) { @@ -161,27 +174,21 @@ static void r300_surface_fill(struct pipe_context* pipe,      /* Disable textures */      OUT_CS_REG(R300_TX_ENABLE, 0x0); -    /* Viewport setup */ -    OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6); -    OUT_CS_32F(1.0); -    OUT_CS_32F((float)x); -    OUT_CS_32F(1.0); -    OUT_CS_32F((float)y); -    OUT_CS_32F(1.0); -    OUT_CS_32F(0.0); -      /* The size of the point we're about to draw, in sixths of pixels */      OUT_CS_REG(R300_GA_POINT_SIZE, -        ((h * 6) & R300_POINTSIZE_Y_MASK) | +        ((h * 6)  & R300_POINTSIZE_Y_MASK) |          ((w * 6) << R300_POINTSIZE_X_SHIFT)); +    /* Vertex size. */ +    OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8); +      /* Packet3 with our point vertex */      OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 8);      OUT_CS(R300_PRIM_TYPE_POINT | R300_PRIM_WALK_RING |              (1 << R300_PRIM_NUM_VERTICES_SHIFT));      /* Position */ -    OUT_CS_32F(w / 2.0); -    OUT_CS_32F(h / 2.0); +    OUT_CS_32F(0.5); +    OUT_CS_32F(0.5);      OUT_CS_32F(1.0);      OUT_CS_32F(1.0);      /* Color */ @@ -190,11 +197,7 @@ static void r300_surface_fill(struct pipe_context* pipe,      OUT_CS_32F(b);      OUT_CS_32F(a); -    /* XXX figure out why this is 0xA and not 0x2 */      OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA); -    /* XXX OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT, -        R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE | -        R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE); */      END_CS; @@ -227,13 +230,20 @@ static void r300_surface_copy(struct pipe_context* pipe,                  srcx, srcy, w, h);      } +    /* Add our source texture to the BO list before emitting anything. +     * r300_surface_setup will flush if needed for us. */ +    r300->winsys->add_buffer(r300->winsys, srctex->buffer, +            RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0); + +    r300_surface_setup(r300, desttex, destx, desty, w, h); +      r300_emit_sampler(r300, &r300_sampler_copy_state, 0);      r300_emit_texture(r300, srctex, 0);      r300_flush_textures(r300);      /* Vertex shader setup */      if (caps->has_tcl) { -        r300_emit_vertex_shader(r300, &r300_texture_vertex_shader); +        r300_emit_vertex_shader(r300, &r300_passthrough_vertex_shader);      } else {          BEGIN_CS(4);          OUT_CS_REG(R300_VAP_CNTL_STATUS, R300_VAP_TCL_BYPASS); @@ -253,6 +263,7 @@ static void r300_surface_copy(struct pipe_context* pipe,          r300_emit_rs_block_state(r300, &r300_rs_block_copy_state);      } +    BEGIN_CS(28);      /* VAP stream control, mapping from input memory to PVS/RS memory */      if (caps->has_tcl) {          OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, @@ -275,33 +286,38 @@ static void r300_surface_copy(struct pipe_context* pipe,      /* Two components of texture 0 */      OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x2); +    /* Vertex size. */ +    OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8); +      /* Packet3 with our texcoords */ -    OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 8); +    OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 16);      OUT_CS(R300_PRIM_TYPE_QUADS | R300_PRIM_WALK_RING |              (4 << R300_PRIM_NUM_VERTICES_SHIFT));      /* (x    , y    ) */ -    OUT_CS_32F((float)destx); -    OUT_CS_32F((float)desty); -    OUT_CS_32F((float)srcx); -    OUT_CS_32F((float)srcy); +    OUT_CS_32F((float)(destx / dest->width)); +    OUT_CS_32F((float)(desty / dest->height)); +    OUT_CS_32F((float)(srcx  / dest->width)); +    OUT_CS_32F((float)(srcy  / dest->height));      /* (x    , y + h) */ -    OUT_CS_32F((float)destx); -    OUT_CS_32F((float)(desty + h)); -    OUT_CS_32F((float)srcx); -    OUT_CS_32F((float)(srcy + h)); +    OUT_CS_32F((float)(destx / dest->width)); +    OUT_CS_32F((float)((desty + h) / dest->height)); +    OUT_CS_32F((float)(srcx  / dest->width)); +    OUT_CS_32F((float)((srcy  + h) / dest->height));      /* (x + w, y + h) */ -    OUT_CS_32F((float)(destx + w)); -    OUT_CS_32F((float)(desty + h)); -    OUT_CS_32F((float)(srcx + w)); -    OUT_CS_32F((float)(srcy + h)); +    OUT_CS_32F((float)((destx + w) / dest->width)); +    OUT_CS_32F((float)((desty + h) / dest->height)); +    OUT_CS_32F((float)((srcx  + w) / dest->width)); +    OUT_CS_32F((float)((srcy  + h) / dest->height));      /* (x + w, y    ) */ -    OUT_CS_32F((float)(destx + w)); -    OUT_CS_32F((float)desty); -    OUT_CS_32F((float)(srcx + w)); -    OUT_CS_32F((float)srcy); +    OUT_CS_32F((float)((destx + w) / dest->width)); +    OUT_CS_32F((float)(desty / dest->height)); +    OUT_CS_32F((float)((srcx  + w) / dest->width)); +    OUT_CS_32F((float)(srcy  / dest->height));      OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA); +    END_CS; +      r300->dirty_hw++;  } diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index a833bb0399..a5ced8041c 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -45,9 +45,6 @@ struct r300_winsys {      /* PCI ID */      uint32_t pci_id; -    /* GB pipe count */ -    uint32_t gb_pipes; -      /* GART size. */      uint32_t gart_size; diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 59d6df8f2d..b89a7292e5 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -92,6 +92,7 @@ struct softpipe_context {      * queries.      */     uint64_t occlusion_count; +   unsigned active_query_count;     /** Mapped vertex buffers */     ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS]; diff --git a/src/gallium/drivers/softpipe/sp_quad_pipe.c b/src/gallium/drivers/softpipe/sp_quad_pipe.c index 892ef87ee9..b5f69b7426 100644 --- a/src/gallium/drivers/softpipe/sp_quad_pipe.c +++ b/src/gallium/drivers/softpipe/sp_quad_pipe.c @@ -80,7 +80,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp)           sp_push_quad_first( sp, sp->quad[i].blend, i );        } -      if (sp->depth_stencil->depth.occlusion_count) { +      if (sp->active_query_count) {           sp_push_quad_first( sp, sp->quad[i].occlusion, i );        } diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c index 93dab236d6..379cf4ad06 100644 --- a/src/gallium/drivers/softpipe/sp_query.c +++ b/src/gallium/drivers/softpipe/sp_query.c @@ -34,6 +34,7 @@  #include "util/u_memory.h"  #include "sp_context.h"  #include "sp_query.h" +#include "sp_state.h"  struct softpipe_query {     uint64_t start; @@ -69,6 +70,8 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)     struct softpipe_query *sq = softpipe_query(q);     sq->start = softpipe->occlusion_count; +   softpipe->active_query_count++; +   softpipe->dirty |= SP_NEW_QUERY;  } @@ -78,7 +81,9 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)     struct softpipe_context *softpipe = softpipe_context( pipe );     struct softpipe_query *sq = softpipe_query(q); +   softpipe->active_query_count--;     sq->end = softpipe->occlusion_count; +   softpipe->dirty |= SP_NEW_QUERY;  } diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 7380a6ae2b..a32fd3a1ba 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -127,6 +127,11 @@ softpipe_is_format_supported( struct pipe_screen *screen,                                unsigned tex_usage,                                 unsigned geom_flags )  { +   assert(target == PIPE_TEXTURE_1D || +          target == PIPE_TEXTURE_2D || +          target == PIPE_TEXTURE_3D || +          target == PIPE_TEXTURE_CUBE); +     switch(format) {     case PIPE_FORMAT_DXT1_RGB:     case PIPE_FORMAT_DXT1_RGBA: diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile index e087db169a..ecb69fb996 100644 --- a/src/gallium/drivers/trace/Makefile +++ b/src/gallium/drivers/trace/Makefile @@ -7,6 +7,7 @@ C_SOURCES = \  	tr_buffer.c \  	tr_context.c \  	tr_dump.c \ +	tr_dump_state.c \  	tr_screen.c \  	tr_state.c \  	tr_texture.c diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript index 4215215d1a..9b5af0d86f 100644 --- a/src/gallium/drivers/trace/SConscript +++ b/src/gallium/drivers/trace/SConscript @@ -8,6 +8,7 @@ trace = env.ConvenienceLibrary(          'tr_buffer.c',          'tr_context.c',          'tr_dump.c', +        'tr_dump_state.c',          'tr_screen.c',          'tr_state.c',          'tr_texture.c', diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 47280459a7..2ad5ca4998 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -31,11 +31,11 @@  #include "pipe/p_screen.h"  #include "tr_dump.h" +#include "tr_dump_state.h"  #include "tr_state.h"  #include "tr_buffer.h"  #include "tr_screen.h"  #include "tr_texture.h" -#include "tr_context.h"  static INLINE struct pipe_buffer * @@ -121,6 +121,9 @@ trace_context_draw_arrays(struct pipe_context *_pipe,     struct pipe_context *pipe = tr_ctx->pipe;     boolean result; +   if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) +      return 0; +     trace_dump_call_begin("pipe_context", "draw_arrays");     trace_dump_arg(ptr, pipe); @@ -150,6 +153,9 @@ trace_context_draw_elements(struct pipe_context *_pipe,     struct pipe_buffer *indexBuffer = tr_buf->buffer;     boolean result; +   if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) +      return 0; +     trace_screen_user_buffer_update(_pipe->screen, indexBuffer);     trace_dump_call_begin("pipe_context", "draw_elements"); @@ -187,6 +193,9 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,     struct pipe_buffer *indexBuffer = tr_buf->buffer;     boolean result; +   if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled) +      return 0; +     trace_screen_user_buffer_update(_pipe->screen, indexBuffer);     trace_dump_call_begin("pipe_context", "draw_range_elements"); @@ -573,23 +582,32 @@ trace_context_create_fs_state(struct pipe_context *_pipe,     trace_dump_call_end(); +   result = trace_shader_create(tr_ctx, state, result, TRACE_SHADER_FRAGMENT); +     return result;  }  static INLINE void  trace_context_bind_fs_state(struct pipe_context *_pipe, -                            void *state) +                            void *_state)  {     struct trace_context *tr_ctx = trace_context(_pipe); +   struct trace_shader *tr_shdr = trace_shader(_state);     struct pipe_context *pipe = tr_ctx->pipe; +   void *state = tr_shdr ? tr_shdr->state : NULL;     trace_dump_call_begin("pipe_context", "bind_fs_state");     trace_dump_arg(ptr, pipe);     trace_dump_arg(ptr, state); -   pipe->bind_fs_state(pipe, state);; +   tr_ctx->curr.fs = tr_shdr; + +   if (tr_shdr && tr_shdr->replaced) +      state = tr_shdr->replaced; + +   pipe->bind_fs_state(pipe, state);     trace_dump_call_end();  } @@ -597,19 +615,23 @@ trace_context_bind_fs_state(struct pipe_context *_pipe,  static INLINE void  trace_context_delete_fs_state(struct pipe_context *_pipe, -                              void *state) +                              void *_state)  {     struct trace_context *tr_ctx = trace_context(_pipe); +   struct trace_shader *tr_shdr = trace_shader(_state);     struct pipe_context *pipe = tr_ctx->pipe; +   void *state = tr_shdr->state;     trace_dump_call_begin("pipe_context", "delete_fs_state");     trace_dump_arg(ptr, pipe);     trace_dump_arg(ptr, state); -   pipe->delete_fs_state(pipe, state);; +   pipe->delete_fs_state(pipe, state);     trace_dump_call_end(); + +   trace_shader_destroy(tr_ctx, tr_shdr);  } @@ -626,28 +648,37 @@ trace_context_create_vs_state(struct pipe_context *_pipe,     trace_dump_arg(ptr, pipe);     trace_dump_arg(shader_state, state); -   result = pipe->create_vs_state(pipe, state);; +   result = pipe->create_vs_state(pipe, state);     trace_dump_ret(ptr, result);     trace_dump_call_end(); +   result = trace_shader_create(tr_ctx, state, result, TRACE_SHADER_VERTEX); +     return result;  }  static INLINE void  trace_context_bind_vs_state(struct pipe_context *_pipe, -                            void *state) +                            void *_state)  {     struct trace_context *tr_ctx = trace_context(_pipe); +   struct trace_shader *tr_shdr = trace_shader(_state);     struct pipe_context *pipe = tr_ctx->pipe; +   void *state = tr_shdr ? tr_shdr->state : NULL;     trace_dump_call_begin("pipe_context", "bind_vs_state");     trace_dump_arg(ptr, pipe);     trace_dump_arg(ptr, state); +   tr_ctx->curr.vs = tr_shdr; + +   if (tr_shdr && tr_shdr->replaced) +      state = tr_shdr->replaced; +     pipe->bind_vs_state(pipe, state);;     trace_dump_call_end(); @@ -656,10 +687,12 @@ trace_context_bind_vs_state(struct pipe_context *_pipe,  static INLINE void  trace_context_delete_vs_state(struct pipe_context *_pipe, -                              void *state) +                              void *_state)  {     struct trace_context *tr_ctx = trace_context(_pipe); +   struct trace_shader *tr_shdr = trace_shader(_state);     struct pipe_context *pipe = tr_ctx->pipe; +   void *state = tr_shdr->state;     trace_dump_call_begin("pipe_context", "delete_vs_state"); @@ -669,6 +702,8 @@ trace_context_delete_vs_state(struct pipe_context *_pipe,     pipe->delete_vs_state(pipe, state);;     trace_dump_call_end(); + +   trace_shader_destroy(tr_ctx, tr_shdr);  } @@ -1089,7 +1124,7 @@ trace_context_create(struct pipe_screen *_screen,     if(!pipe)        goto error1; -   if(!trace_dump_trace_enabled()) +   if(!trace_enabled())        goto error1;     tr_scr = trace_screen(_screen); @@ -1099,6 +1134,9 @@ trace_context_create(struct pipe_screen *_screen,     if(!tr_ctx)        goto error1; +   pipe_mutex_init(tr_ctx->list_mutex); +   make_empty_list(&tr_ctx->shaders); +     tr_ctx->base.winsys = _screen->winsys;     tr_ctx->base.screen = _screen;     tr_ctx->base.destroy = trace_context_destroy; diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h index 2512a0a232..86827f97b2 100644 --- a/src/gallium/drivers/trace/tr_context.h +++ b/src/gallium/drivers/trace/tr_context.h @@ -33,6 +33,7 @@  #include "util/u_debug.h"  #include "pipe/p_context.h" +#include "tr_screen.h"  #ifdef __cplusplus  extern "C" { @@ -45,7 +46,19 @@ struct trace_context     struct pipe_context *pipe; +   /* current state */ +   struct { +      struct trace_shader *fs; +      struct trace_shader *vs; +   } curr; + +   /* for list on screen */     struct tr_list list; + +   /* list of state objects */ +   pipe_mutex list_mutex; +   unsigned num_shaders; +   struct tr_list shaders;  }; diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c new file mode 100644 index 0000000000..23a2473b57 --- /dev/null +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -0,0 +1,490 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include "pipe/p_compiler.h" +#include "util/u_memory.h" +#include "tgsi/tgsi_dump.h" + +#include "tr_dump.h" +#include "tr_dump_state.h" + + +void trace_dump_format(enum pipe_format format) +{ +   trace_dump_enum(pf_name(format) ); +} + + +void trace_dump_block(const struct pipe_format_block *block) +{ +   trace_dump_struct_begin("pipe_format_block"); +   trace_dump_member(uint, block, size); +   trace_dump_member(uint, block, width); +   trace_dump_member(uint, block, height); +   trace_dump_struct_end(); +} + + +static void trace_dump_reference(const struct pipe_reference *reference) +{ +   trace_dump_struct_begin("pipe_reference"); +   trace_dump_member(int, &reference->count, count); +   trace_dump_struct_end(); +} + + +void trace_dump_template(const struct pipe_texture *templat) +{ +   if(!templat) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_texture"); + +   trace_dump_member(int, templat, target); +   trace_dump_member(format, templat, format); + +   trace_dump_member_begin("width"); +   trace_dump_array(uint, templat->width, 1); +   trace_dump_member_end(); + +   trace_dump_member_begin("height"); +   trace_dump_array(uint, templat->height, 1); +   trace_dump_member_end(); + +   trace_dump_member_begin("depth"); +   trace_dump_array(uint, templat->depth, 1); +   trace_dump_member_end(); + +   trace_dump_member_begin("block"); +   trace_dump_block(&templat->block); +   trace_dump_member_end(); + +   trace_dump_member(uint, templat, last_level); +   trace_dump_member(uint, templat, tex_usage); + +   trace_dump_struct_end(); +} + + +void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_rasterizer_state"); + +   trace_dump_member(bool, state, flatshade); +   trace_dump_member(bool, state, light_twoside); +   trace_dump_member(uint, state, front_winding); +   trace_dump_member(uint, state, cull_mode); +   trace_dump_member(uint, state, fill_cw); +   trace_dump_member(uint, state, fill_ccw); +   trace_dump_member(bool, state, offset_cw); +   trace_dump_member(bool, state, offset_ccw); +   trace_dump_member(bool, state, scissor); +   trace_dump_member(bool, state, poly_smooth); +   trace_dump_member(bool, state, poly_stipple_enable); +   trace_dump_member(bool, state, point_smooth); +   trace_dump_member(bool, state, point_sprite); +   trace_dump_member(bool, state, point_size_per_vertex); +   trace_dump_member(bool, state, multisample); +   trace_dump_member(bool, state, line_smooth); +   trace_dump_member(bool, state, line_stipple_enable); +   trace_dump_member(uint, state, line_stipple_factor); +   trace_dump_member(uint, state, line_stipple_pattern); +   trace_dump_member(bool, state, line_last_pixel); +   trace_dump_member(bool, state, bypass_vs_clip_and_viewport); +   trace_dump_member(bool, state, flatshade_first); +   trace_dump_member(bool, state, gl_rasterization_rules); + +   trace_dump_member(float, state, line_width); +   trace_dump_member(float, state, point_size); +   trace_dump_member(float, state, point_size_min); +   trace_dump_member(float, state, point_size_max); +   trace_dump_member(float, state, offset_units); +   trace_dump_member(float, state, offset_scale); + +   trace_dump_member_array(uint, state, sprite_coord_mode); + +   trace_dump_struct_end(); +} + + +void trace_dump_poly_stipple(const struct pipe_poly_stipple *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_poly_stipple"); + +   trace_dump_member_begin("stipple"); +   trace_dump_array(uint, +                    state->stipple, +                    Elements(state->stipple)); +   trace_dump_member_end(); + +   trace_dump_struct_end(); +} + + +void trace_dump_viewport_state(const struct pipe_viewport_state *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_viewport_state"); + +   trace_dump_member_array(float, state, scale); +   trace_dump_member_array(float, state, translate); + +   trace_dump_struct_end(); +} + + +void trace_dump_scissor_state(const struct pipe_scissor_state *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_scissor_state"); + +   trace_dump_member(uint, state, minx); +   trace_dump_member(uint, state, miny); +   trace_dump_member(uint, state, maxx); +   trace_dump_member(uint, state, maxy); + +   trace_dump_struct_end(); +} + + +void trace_dump_clip_state(const struct pipe_clip_state *state) +{ +   unsigned i; + +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_clip_state"); + +   trace_dump_member_begin("ucp"); +   trace_dump_array_begin(); +   for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) { +      trace_dump_elem_begin(); +      trace_dump_array(float, state->ucp[i], 4); +      trace_dump_elem_end(); +   } +   trace_dump_array_end(); +   trace_dump_member_end(); + +   trace_dump_member(uint, state, nr); + +   trace_dump_struct_end(); +} + + +void trace_dump_constant_buffer(const struct pipe_constant_buffer *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_constant_buffer"); + +   trace_dump_member(buffer_ptr, state, buffer); + +   trace_dump_struct_end(); +} + + +void trace_dump_shader_state(const struct pipe_shader_state *state) +{ +   static char str[8192]; + +   if(!state) { +      trace_dump_null(); +      return; +   } + +   tgsi_dump_str(state->tokens, 0, str, sizeof(str)); + +   trace_dump_struct_begin("pipe_shader_state"); + +   trace_dump_member_begin("tokens"); +   trace_dump_string(str); +   trace_dump_member_end(); + +   trace_dump_struct_end(); +} + + +void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state) +{ +   unsigned i; + +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_depth_stencil_alpha_state"); + +   trace_dump_member_begin("depth"); +   trace_dump_struct_begin("pipe_depth_state"); +   trace_dump_member(bool, &state->depth, enabled); +   trace_dump_member(bool, &state->depth, writemask); +   trace_dump_member(uint, &state->depth, func); +   trace_dump_struct_end(); +   trace_dump_member_end(); + +   trace_dump_member_begin("stencil"); +   trace_dump_array_begin(); +   for(i = 0; i < Elements(state->stencil); ++i) { +      trace_dump_elem_begin(); +      trace_dump_struct_begin("pipe_stencil_state"); +      trace_dump_member(bool, &state->stencil[i], enabled); +      trace_dump_member(uint, &state->stencil[i], func); +      trace_dump_member(uint, &state->stencil[i], fail_op); +      trace_dump_member(uint, &state->stencil[i], zpass_op); +      trace_dump_member(uint, &state->stencil[i], zfail_op); +      trace_dump_member(uint, &state->stencil[i], ref_value); +      trace_dump_member(uint, &state->stencil[i], valuemask); +      trace_dump_member(uint, &state->stencil[i], writemask); +      trace_dump_struct_end(); +      trace_dump_elem_end(); +   } +   trace_dump_array_end(); +   trace_dump_member_end(); + +   trace_dump_member_begin("alpha"); +   trace_dump_struct_begin("pipe_alpha_state"); +   trace_dump_member(bool, &state->alpha, enabled); +   trace_dump_member(uint, &state->alpha, func); +   trace_dump_member(float, &state->alpha, ref_value); +   trace_dump_struct_end(); +   trace_dump_member_end(); + +   trace_dump_struct_end(); +} + + +void trace_dump_blend_state(const struct pipe_blend_state *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_blend_state"); + +   trace_dump_member(bool, state, blend_enable); + +   trace_dump_member(uint, state, rgb_func); +   trace_dump_member(uint, state, rgb_src_factor); +   trace_dump_member(uint, state, rgb_dst_factor); + +   trace_dump_member(uint, state, alpha_func); +   trace_dump_member(uint, state, alpha_src_factor); +   trace_dump_member(uint, state, alpha_dst_factor); + +   trace_dump_member(bool, state, logicop_enable); +   trace_dump_member(uint, state, logicop_func); + +   trace_dump_member(uint, state, colormask); +   trace_dump_member(bool, state, dither); + +   trace_dump_struct_end(); +} + + +void trace_dump_blend_color(const struct pipe_blend_color *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_blend_color"); + +   trace_dump_member_array(float, state, color); + +   trace_dump_struct_end(); +} + + +void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state) +{ +   trace_dump_struct_begin("pipe_framebuffer_state"); + +   trace_dump_member(uint, state, width); +   trace_dump_member(uint, state, height); +   trace_dump_member(uint, state, nr_cbufs); +   trace_dump_member_array(ptr, state, cbufs); +   trace_dump_member(ptr, state, zsbuf); + +   trace_dump_struct_end(); +} + + +void trace_dump_sampler_state(const struct pipe_sampler_state *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_sampler_state"); + +   trace_dump_member(uint, state, wrap_s); +   trace_dump_member(uint, state, wrap_t); +   trace_dump_member(uint, state, wrap_r); +   trace_dump_member(uint, state, min_img_filter); +   trace_dump_member(uint, state, min_mip_filter); +   trace_dump_member(uint, state, mag_img_filter); +   trace_dump_member(bool, state, compare_mode); +   trace_dump_member(uint, state, compare_func); +   trace_dump_member(bool, state, normalized_coords); +   trace_dump_member(uint, state, prefilter); +   trace_dump_member(float, state, shadow_ambient); +   trace_dump_member(float, state, lod_bias); +   trace_dump_member(float, state, min_lod); +   trace_dump_member(float, state, max_lod); +   trace_dump_member_array(float, state, border_color); +   trace_dump_member(float, state, max_anisotropy); + +   trace_dump_struct_end(); +} + + +void trace_dump_surface(const struct pipe_surface *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_surface"); + +   trace_dump_reference(&state->reference); + +   trace_dump_member(format, state, format); +   trace_dump_member(uint, state, width); +   trace_dump_member(uint, state, height); + +   trace_dump_member(uint, state, layout); +   trace_dump_member(uint, state, offset); +   trace_dump_member(uint, state, usage); + +   trace_dump_member(ptr, state, texture); +   trace_dump_member(uint, state, face); +   trace_dump_member(uint, state, level); +   trace_dump_member(uint, state, zslice); + +   trace_dump_struct_end(); +} + + +void trace_dump_transfer(const struct pipe_transfer *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_transfer"); + +   trace_dump_member(format, state, format); +   trace_dump_member(uint, state, width); +   trace_dump_member(uint, state, height); + +   trace_dump_member_begin("block"); +   trace_dump_block(&state->block); +   trace_dump_member_end(); + +   trace_dump_member(uint, state, nblocksx); +   trace_dump_member(uint, state, nblocksy); +   trace_dump_member(uint, state, stride); +   trace_dump_member(uint, state, usage); + +   trace_dump_member(ptr, state, texture); +   trace_dump_member(uint, state, face); +   trace_dump_member(uint, state, level); +   trace_dump_member(uint, state, zslice); + +   trace_dump_struct_end(); +} + + +void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_vertex_buffer"); + +   trace_dump_member(uint, state, stride); +   trace_dump_member(uint, state, max_index); +   trace_dump_member(uint, state, buffer_offset); +   trace_dump_member(buffer_ptr, state, buffer); + +   trace_dump_struct_end(); +} + + +void trace_dump_vertex_element(const struct pipe_vertex_element *state) +{ +   if(!state) { +      trace_dump_null(); +      return; +   } + +   trace_dump_struct_begin("pipe_vertex_element"); + +   trace_dump_member(uint, state, src_offset); + +   trace_dump_member(uint, state, vertex_buffer_index); +   trace_dump_member(uint, state, nr_components); + +   trace_dump_member(format, state, src_format); + +   trace_dump_struct_end(); +} diff --git a/src/gallium/drivers/trace/tr_dump_state.h b/src/gallium/drivers/trace/tr_dump_state.h new file mode 100644 index 0000000000..05b821adb6 --- /dev/null +++ b/src/gallium/drivers/trace/tr_dump_state.h @@ -0,0 +1,78 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef TR_DUMP_STATE_H_ +#define TR_DUMP_STATE_H_ + +#include "pipe/p_format.h" +#include "pipe/p_state.h" +#include "pipe/p_shader_tokens.h" + + +void trace_dump_format(enum pipe_format format); + +void trace_dump_block(const struct pipe_format_block *block); + +void trace_dump_template(const struct pipe_texture *templat); + + +void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state); + +void trace_dump_poly_stipple(const struct pipe_poly_stipple *state); + +void trace_dump_viewport_state(const struct pipe_viewport_state *state); + +void trace_dump_scissor_state(const struct pipe_scissor_state *state); + +void trace_dump_clip_state(const struct pipe_clip_state *state); + +void trace_dump_constant_buffer(const struct pipe_constant_buffer *state); + +void trace_dump_token(const struct tgsi_token *token); + +void trace_dump_shader_state(const struct pipe_shader_state *state); + +void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state); + +void trace_dump_blend_state(const struct pipe_blend_state *state); + +void trace_dump_blend_color(const struct pipe_blend_color *state); + +void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state); + +void trace_dump_sampler_state(const struct pipe_sampler_state *state); + +void trace_dump_surface(const struct pipe_surface *state); + +void trace_dump_transfer(const struct pipe_transfer *state); + +void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state); + +void trace_dump_vertex_element(const struct pipe_vertex_element *state); + + +#endif /* TR_STATE_H */ diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 12a8535342..bc14248eeb 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -30,13 +30,15 @@  #include "tr_buffer.h"  #include "tr_dump.h" -#include "tr_state.h" +#include "tr_dump_state.h"  #include "tr_texture.h"  #include "tr_screen.h"  #include "pipe/p_inlines.h" +static boolean trace = FALSE; +  static const char *  trace_screen_get_name(struct pipe_screen *_screen)  { @@ -212,10 +214,12 @@ static struct pipe_texture *  trace_screen_texture_blanket(struct pipe_screen *_screen,                               const struct pipe_texture *templat,                               const unsigned *ppitch, -                             struct pipe_buffer *buffer) +                             struct pipe_buffer *_buffer)  {     struct trace_screen *tr_scr = trace_screen(_screen); +   struct trace_buffer *tr_buf = trace_buffer(_buffer);     struct pipe_screen *screen = tr_scr->screen; +   struct pipe_buffer *buffer = tr_buf->buffer;     unsigned pitch = *ppitch;     struct pipe_texture *result; @@ -818,16 +822,20 @@ trace_screen_destroy(struct pipe_screen *_screen)     struct pipe_screen *screen = tr_scr->screen;     trace_dump_call_begin("pipe_screen", "destroy"); -     trace_dump_arg(ptr, screen); +   trace_dump_call_end(); +   trace_dump_trace_end();     screen->destroy(screen); -   trace_dump_call_end(); +   FREE(tr_scr); +} -   trace_dump_trace_end(); -   FREE(tr_scr); +boolean +trace_enabled(void) +{ +   return trace;  } @@ -842,10 +850,13 @@ trace_screen_create(struct pipe_screen *screen)     trace_dump_init(); -   if(!trace_dump_trace_begin()) -      goto error1; +   if(trace_dump_trace_begin()) { +      trace_dumping_start(); +      trace = TRUE; +   } -   trace_dumping_start(); +   if (!trace) +      goto error1;     trace_dump_call_begin("", "pipe_screen_create"); diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h index 59f254166d..7fae182985 100644 --- a/src/gallium/drivers/trace/tr_screen.h +++ b/src/gallium/drivers/trace/tr_screen.h @@ -71,6 +71,13 @@ struct trace_screen  }; +/* + * tr_screen.c + */ + +boolean +trace_enabled(void); +  struct trace_screen *  trace_screen(struct pipe_screen *screen); diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c index a9570c1aeb..d8c11640bf 100644 --- a/src/gallium/drivers/trace/tr_state.c +++ b/src/gallium/drivers/trace/tr_state.c @@ -1,491 +1,66 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. +/* + * Copyright 2009 VMware, Inc.   * All Rights Reserved.   *   * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions:   * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software.   * - **************************************************************************/ - + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL + * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ -#include "pipe/p_compiler.h" -#include "util/u_memory.h" -#include "tgsi/tgsi_dump.h" - -#include "tr_dump.h"  #include "tr_state.h" +#include "util/u_memory.h" +#include "util/u_simple_list.h" -void trace_dump_format(enum pipe_format format) -{ -   trace_dump_enum(pf_name(format) ); -} - - -void trace_dump_block(const struct pipe_format_block *block) -{ -   trace_dump_struct_begin("pipe_format_block"); -   trace_dump_member(uint, block, size); -   trace_dump_member(uint, block, width); -   trace_dump_member(uint, block, height); -   trace_dump_struct_end(); -} - - -static void trace_dump_reference(const struct pipe_reference *reference) -{ -   trace_dump_struct_begin("pipe_reference"); -   trace_dump_member(int, &reference->count, count); -   trace_dump_struct_end(); -} - - -void trace_dump_template(const struct pipe_texture *templat) -{ -   if(!templat) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_texture"); - -   trace_dump_member(int, templat, target); -   trace_dump_member(format, templat, format); - -   trace_dump_member_begin("width"); -   trace_dump_array(uint, templat->width, 1); -   trace_dump_member_end(); - -   trace_dump_member_begin("height"); -   trace_dump_array(uint, templat->height, 1); -   trace_dump_member_end(); - -   trace_dump_member_begin("depth"); -   trace_dump_array(uint, templat->depth, 1); -   trace_dump_member_end(); - -   trace_dump_member_begin("block"); -   trace_dump_block(&templat->block); -   trace_dump_member_end(); - -   trace_dump_member(uint, templat, last_level); -   trace_dump_member(uint, templat, tex_usage); - -   trace_dump_struct_end(); -} - - -void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) -{ -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_rasterizer_state"); - -   trace_dump_member(bool, state, flatshade); -   trace_dump_member(bool, state, light_twoside); -   trace_dump_member(uint, state, front_winding); -   trace_dump_member(uint, state, cull_mode); -   trace_dump_member(uint, state, fill_cw); -   trace_dump_member(uint, state, fill_ccw); -   trace_dump_member(bool, state, offset_cw); -   trace_dump_member(bool, state, offset_ccw); -   trace_dump_member(bool, state, scissor); -   trace_dump_member(bool, state, poly_smooth); -   trace_dump_member(bool, state, poly_stipple_enable); -   trace_dump_member(bool, state, point_smooth); -   trace_dump_member(bool, state, point_sprite); -   trace_dump_member(bool, state, point_size_per_vertex); -   trace_dump_member(bool, state, multisample); -   trace_dump_member(bool, state, line_smooth); -   trace_dump_member(bool, state, line_stipple_enable); -   trace_dump_member(uint, state, line_stipple_factor); -   trace_dump_member(uint, state, line_stipple_pattern); -   trace_dump_member(bool, state, line_last_pixel); -   trace_dump_member(bool, state, bypass_vs_clip_and_viewport); -   trace_dump_member(bool, state, flatshade_first); -   trace_dump_member(bool, state, gl_rasterization_rules); - -   trace_dump_member(float, state, line_width); -   trace_dump_member(float, state, point_size); -   trace_dump_member(float, state, point_size_min); -   trace_dump_member(float, state, point_size_max); -   trace_dump_member(float, state, offset_units); -   trace_dump_member(float, state, offset_scale); - -   trace_dump_member_array(uint, state, sprite_coord_mode); - -   trace_dump_struct_end(); -} - - -void trace_dump_poly_stipple(const struct pipe_poly_stipple *state) -{ -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_poly_stipple"); - -   trace_dump_member_begin("stipple"); -   trace_dump_array(uint, -                    state->stipple, -                    Elements(state->stipple)); -   trace_dump_member_end(); - -   trace_dump_struct_end(); -} - - -void trace_dump_viewport_state(const struct pipe_viewport_state *state) -{ -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_viewport_state"); - -   trace_dump_member_array(float, state, scale); -   trace_dump_member_array(float, state, translate); - -   trace_dump_struct_end(); -} - - -void trace_dump_scissor_state(const struct pipe_scissor_state *state) -{ -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_scissor_state"); - -   trace_dump_member(uint, state, minx); -   trace_dump_member(uint, state, miny); -   trace_dump_member(uint, state, maxx); -   trace_dump_member(uint, state, maxy); - -   trace_dump_struct_end(); -} - - -void trace_dump_clip_state(const struct pipe_clip_state *state) -{ -   unsigned i; - -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_clip_state"); - -   trace_dump_member_begin("ucp"); -   trace_dump_array_begin(); -   for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) { -      trace_dump_elem_begin(); -      trace_dump_array(float, state->ucp[i], 4); -      trace_dump_elem_end(); -   } -   trace_dump_array_end(); -   trace_dump_member_end(); - -   trace_dump_member(uint, state, nr); - -   trace_dump_struct_end(); -} - - -void trace_dump_constant_buffer(const struct pipe_constant_buffer *state) -{ -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_constant_buffer"); - -   trace_dump_member(buffer_ptr, state, buffer); - -   trace_dump_struct_end(); -} - - -void trace_dump_shader_state(const struct pipe_shader_state *state) -{ -   static char str[8192]; - -   if(!state) { -      trace_dump_null(); -      return; -   } - -   tgsi_dump_str(state->tokens, 0, str, sizeof(str)); - -   trace_dump_struct_begin("pipe_shader_state"); - -   trace_dump_member_begin("tokens"); -   trace_dump_string(str); -   trace_dump_member_end(); - -   trace_dump_struct_end(); -} - - -void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state) -{ -   unsigned i; - -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_depth_stencil_alpha_state"); - -   trace_dump_member_begin("depth"); -   trace_dump_struct_begin("pipe_depth_state"); -   trace_dump_member(bool, &state->depth, enabled); -   trace_dump_member(bool, &state->depth, writemask); -   trace_dump_member(uint, &state->depth, func); -   trace_dump_member(bool, &state->depth, occlusion_count); -   trace_dump_struct_end(); -   trace_dump_member_end(); - -   trace_dump_member_begin("stencil"); -   trace_dump_array_begin(); -   for(i = 0; i < Elements(state->stencil); ++i) { -      trace_dump_elem_begin(); -      trace_dump_struct_begin("pipe_stencil_state"); -      trace_dump_member(bool, &state->stencil[i], enabled); -      trace_dump_member(uint, &state->stencil[i], func); -      trace_dump_member(uint, &state->stencil[i], fail_op); -      trace_dump_member(uint, &state->stencil[i], zpass_op); -      trace_dump_member(uint, &state->stencil[i], zfail_op); -      trace_dump_member(uint, &state->stencil[i], ref_value); -      trace_dump_member(uint, &state->stencil[i], valuemask); -      trace_dump_member(uint, &state->stencil[i], writemask); -      trace_dump_struct_end(); -      trace_dump_elem_end(); -   } -   trace_dump_array_end(); -   trace_dump_member_end(); - -   trace_dump_member_begin("alpha"); -   trace_dump_struct_begin("pipe_alpha_state"); -   trace_dump_member(bool, &state->alpha, enabled); -   trace_dump_member(uint, &state->alpha, func); -   trace_dump_member(float, &state->alpha, ref_value); -   trace_dump_struct_end(); -   trace_dump_member_end(); - -   trace_dump_struct_end(); -} - - -void trace_dump_blend_state(const struct pipe_blend_state *state) -{ -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_blend_state"); - -   trace_dump_member(bool, state, blend_enable); - -   trace_dump_member(uint, state, rgb_func); -   trace_dump_member(uint, state, rgb_src_factor); -   trace_dump_member(uint, state, rgb_dst_factor); - -   trace_dump_member(uint, state, alpha_func); -   trace_dump_member(uint, state, alpha_src_factor); -   trace_dump_member(uint, state, alpha_dst_factor); - -   trace_dump_member(bool, state, logicop_enable); -   trace_dump_member(uint, state, logicop_func); - -   trace_dump_member(uint, state, colormask); -   trace_dump_member(bool, state, dither); - -   trace_dump_struct_end(); -} - - -void trace_dump_blend_color(const struct pipe_blend_color *state) -{ -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_blend_color"); - -   trace_dump_member_array(float, state, color); - -   trace_dump_struct_end(); -} - - -void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state) -{ -   trace_dump_struct_begin("pipe_framebuffer_state"); - -   trace_dump_member(uint, state, width); -   trace_dump_member(uint, state, height); -   trace_dump_member(uint, state, nr_cbufs); -   trace_dump_member_array(ptr, state, cbufs); -   trace_dump_member(ptr, state, zsbuf); - -   trace_dump_struct_end(); -} - - -void trace_dump_sampler_state(const struct pipe_sampler_state *state) -{ -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_sampler_state"); - -   trace_dump_member(uint, state, wrap_s); -   trace_dump_member(uint, state, wrap_t); -   trace_dump_member(uint, state, wrap_r); -   trace_dump_member(uint, state, min_img_filter); -   trace_dump_member(uint, state, min_mip_filter); -   trace_dump_member(uint, state, mag_img_filter); -   trace_dump_member(bool, state, compare_mode); -   trace_dump_member(uint, state, compare_func); -   trace_dump_member(bool, state, normalized_coords); -   trace_dump_member(uint, state, prefilter); -   trace_dump_member(float, state, shadow_ambient); -   trace_dump_member(float, state, lod_bias); -   trace_dump_member(float, state, min_lod); -   trace_dump_member(float, state, max_lod); -   trace_dump_member_array(float, state, border_color); -   trace_dump_member(float, state, max_anisotropy); - -   trace_dump_struct_end(); -} - - -void trace_dump_surface(const struct pipe_surface *state) -{ -   if(!state) { -      trace_dump_null(); -      return; -   } - -   trace_dump_struct_begin("pipe_surface"); - -   trace_dump_reference(&state->reference); - -   trace_dump_member(format, state, format); -   trace_dump_member(uint, state, width); -   trace_dump_member(uint, state, height); - -   trace_dump_member(uint, state, layout); -   trace_dump_member(uint, state, offset); -   trace_dump_member(uint, state, usage); - -   trace_dump_member(ptr, state, texture); -   trace_dump_member(uint, state, face); -   trace_dump_member(uint, state, level); -   trace_dump_member(uint, state, zslice); - -   trace_dump_struct_end(); -} - +#include "tgsi/tgsi_parse.h" -void trace_dump_transfer(const struct pipe_transfer *state) +struct trace_shader * trace_shader_create(struct trace_context *tr_ctx, +                                          const struct pipe_shader_state *state, +                                          void *result, +                                          enum trace_shader_type type)  { -   if(!state) { -      trace_dump_null(); -      return; -   } +   struct trace_shader *tr_shdr = CALLOC_STRUCT(trace_shader); -   trace_dump_struct_begin("pipe_transfer"); +   tr_shdr->state = result; +   tr_shdr->type = type; +   tr_shdr->tokens = tgsi_dup_tokens(state->tokens); -   trace_dump_member(format, state, format); -   trace_dump_member(uint, state, width); -   trace_dump_member(uint, state, height); +   /* works on context as well */ +   trace_screen_add_to_list(tr_ctx, shaders, tr_shdr); -   trace_dump_member_begin("block"); -   trace_dump_block(&state->block); -   trace_dump_member_end(); - -   trace_dump_member(uint, state, nblocksx); -   trace_dump_member(uint, state, nblocksy); -   trace_dump_member(uint, state, stride); -   trace_dump_member(uint, state, usage); - -   trace_dump_member(ptr, state, texture); -   trace_dump_member(uint, state, face); -   trace_dump_member(uint, state, level); -   trace_dump_member(uint, state, zslice); - -   trace_dump_struct_end(); +   return tr_shdr;  } - -void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state) +void trace_shader_destroy(struct trace_context *tr_ctx, +                          struct trace_shader *tr_shdr)  { -   if(!state) { -      trace_dump_null(); -      return; -   } +   trace_screen_remove_from_list(tr_ctx, shaders, tr_shdr); -   trace_dump_struct_begin("pipe_vertex_buffer"); - -   trace_dump_member(uint, state, stride); -   trace_dump_member(uint, state, max_index); -   trace_dump_member(uint, state, buffer_offset); -   trace_dump_member(buffer_ptr, state, buffer); - -   trace_dump_struct_end(); -} - - -void trace_dump_vertex_element(const struct pipe_vertex_element *state) -{ -   if(!state) { -      trace_dump_null(); -      return; +   if (tr_shdr->replaced) { +      if (tr_shdr->type == TRACE_SHADER_FRAGMENT) +         tr_ctx->pipe->delete_fs_state(tr_ctx->pipe, tr_shdr->replaced); +      else if (tr_shdr->type == TRACE_SHADER_VERTEX) +         tr_ctx->pipe->delete_vs_state(tr_ctx->pipe, tr_shdr->replaced); +      else +         assert(0);     } -   trace_dump_struct_begin("pipe_vertex_element"); - -   trace_dump_member(uint, state, src_offset); - -   trace_dump_member(uint, state, vertex_buffer_index); -   trace_dump_member(uint, state, nr_components); - -   trace_dump_member(format, state, src_format); - -   trace_dump_struct_end(); +   FREE(tr_shdr->replaced_tokens); +   FREE(tr_shdr->tokens); +   FREE(tr_shdr);  } diff --git a/src/gallium/drivers/trace/tr_state.h b/src/gallium/drivers/trace/tr_state.h index 513ed0ac98..1c16042ee5 100644 --- a/src/gallium/drivers/trace/tr_state.h +++ b/src/gallium/drivers/trace/tr_state.h @@ -1,78 +1,68 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. +/* + * Copyright 2009 VMware, Inc.   * All Rights Reserved.   *   * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions:   * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software.   * - **************************************************************************/ - -#ifndef TR_STATE_H -#define TR_STATE_H - -#include "pipe/p_format.h" -#include "pipe/p_state.h" -#include "pipe/p_shader_tokens.h" - - -void trace_dump_format(enum pipe_format format); - -void trace_dump_block(const struct pipe_format_block *block); - -void trace_dump_template(const struct pipe_texture *templat); - - -void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state); - -void trace_dump_poly_stipple(const struct pipe_poly_stipple *state); - -void trace_dump_viewport_state(const struct pipe_viewport_state *state); - -void trace_dump_scissor_state(const struct pipe_scissor_state *state); - -void trace_dump_clip_state(const struct pipe_clip_state *state); + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL + * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ -void trace_dump_constant_buffer(const struct pipe_constant_buffer *state); +#ifndef TR_STATE_H_ +#define TR_STATE_H_ -void trace_dump_token(const struct tgsi_token *token); +#include "tr_context.h" -void trace_dump_shader_state(const struct pipe_shader_state *state); +struct tgsi_token; -void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state); +enum trace_shader_type { +   TRACE_SHADER_FRAGMENT = 0, +   TRACE_SHADER_VERTEX   = 1, +   TRACE_SHADER_GEOMETRY = 2, +}; -void trace_dump_blend_state(const struct pipe_blend_state *state); +struct trace_shader +{ +   struct tr_list list; -void trace_dump_blend_color(const struct pipe_blend_color *state); +   enum trace_shader_type type; -void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state); +   void *state; +   void *replaced; -void trace_dump_sampler_state(const struct pipe_sampler_state *state); +   struct tgsi_token *tokens; +   struct tgsi_token *replaced_tokens; -void trace_dump_surface(const struct pipe_surface *state); +   boolean disabled; +}; -void trace_dump_transfer(const struct pipe_transfer *state); -void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state); +static INLINE struct trace_shader * +trace_shader(void *state) +{ +   return (struct trace_shader *)state; +} -void trace_dump_vertex_element(const struct pipe_vertex_element *state); +struct trace_shader * trace_shader_create(struct trace_context *tr_ctx, +                                          const struct pipe_shader_state *state, +                                          void *result, +                                          enum trace_shader_type type); +void trace_shader_destroy(struct trace_context *tr_ctx, +                          struct trace_shader *tr_shdr); -#endif /* TR_STATE_H */ +#endif diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 15a2088df5..865cc8d0b6 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -138,6 +138,18 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv)     dri_drawable->pBackClipRects[0].x2 = dri_drawable->w;     dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; +   if (drawable->old_num == count && +       drawable->old_w == dri_drawable->w && +       drawable->old_h == dri_drawable->h && +       memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0) { +       return; +   } else { +      drawable->old_num = count; +      drawable->old_w = dri_drawable->w; +      drawable->old_h = dri_drawable->h; +      memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count); +   } +     for (i = 0; i < count; i++) {        enum pipe_format format = 0;        int index = 0; diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h index 78a66624aa..0f654d804a 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -46,6 +46,11 @@ struct dri_drawable     unsigned attachments[8];     unsigned num_attachments; +   __DRIbuffer old[8]; +   unsigned old_num; +   unsigned old_w; +   unsigned old_h; +     /* gallium */     struct st_framebuffer *stfb;     struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX]; diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c index 0c59d42d5c..2f48162526 100644 --- a/src/gallium/state_trackers/dri/dri_extensions.c +++ b/src/gallium/state_trackers/dri/dri_extensions.c @@ -36,9 +36,11 @@  #define need_GL_ARB_multisample  #define need_GL_ARB_occlusion_query  #define need_GL_ARB_point_parameters +#define need_GL_ARB_shader_objects  #define need_GL_ARB_texture_compression  #define need_GL_ARB_vertex_buffer_object  #define need_GL_ARB_vertex_program +#define need_GL_ARB_vertex_shader  #define need_GL_ARB_window_pos  #define need_GL_EXT_blend_color  #define need_GL_EXT_blend_equation_separate @@ -50,16 +52,23 @@  #define need_GL_EXT_multi_draw_arrays  #define need_GL_EXT_secondary_color  #define need_GL_NV_vertex_program +#define need_GL_VERSION_2_0 +#define need_GL_VERSION_2_1  #include "extension_helper.h"  /**   * Extension strings exported by the driver.   */  const struct dri_extension card_extensions[] = { +   {"GL_ARB_fragment_shader", NULL},     {"GL_ARB_multisample", GL_ARB_multisample_functions},     {"GL_ARB_multitexture", NULL},     {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, +   {"GL_ARB_pixel_buffer_object", NULL},     {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, +   {"GL_ARB_shading_language_100", GL_VERSION_2_0_functions }, +   {"GL_ARB_shading_language_120", GL_VERSION_2_1_functions }, +   {"GL_ARB_shader_objects", GL_ARB_shader_objects_functions},     {"GL_ARB_texture_border_clamp", NULL},     {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},     {"GL_ARB_texture_cube_map", NULL}, @@ -69,7 +78,7 @@ const struct dri_extension card_extensions[] = {     {"GL_ARB_texture_mirrored_repeat", NULL},     {"GL_ARB_texture_rectangle", NULL},     {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions}, -   {"GL_ARB_pixel_buffer_object", NULL}, +   {"GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions},     {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},     {"GL_ARB_window_pos", GL_ARB_window_pos_functions},     {"GL_EXT_blend_color", GL_EXT_blend_color_functions}, diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile index 692a3c8b76..e825aa718b 100644 --- a/src/gallium/state_trackers/egl/Makefile +++ b/src/gallium/state_trackers/egl/Makefile @@ -1,29 +1,19 @@ -TARGET     = libegldrm.a -CFILES     = $(wildcard ./*.c) -OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES)) -GALLIUMDIR = ../.. -TOP        = ../../../.. +TOP = ../../../.. +include $(TOP)/configs/current -include ${TOP}/configs/current +LIBNAME = egldrm -CFLAGS := \ -          -I${GALLIUMDIR}/include \ -          -I${GALLIUMDIR}/auxiliary \ -          -I${TOP}/src/mesa/drivers/dri/common \ -          -I${TOP}/src/mesa \ -          -I$(TOP)/include \ -          -I$(TOP)/src/egl/main \ -          ${LIBDRM_CFLAGS} \ -          ${CFLAGS} +LIBRARY_INCLUDES = \ +	-I$(TOP)/src/gallium/include \ +	-I$(TOP)/src/gallium/auxiliary \ +	-I$(TOP)/src/mesa/drivers/dri/common \ +	-I$(TOP)/src/mesa \ +	-I$(TOP)/include \ +	-I$(TOP)/src/egl/main \ +	$(shell pkg-config --cflags-only-I libdrm) -############################################# -.PHONY	= all clean +C_SOURCES = $(wildcard ./*.c) -all: ${TARGET} -${TARGET}: ${OBJECTS} -	ar rcs $@ $^ - -clean: -	rm -rf ${OBJECTS} ${TARGET} +include ../../Makefile.template diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.h b/src/gallium/state_trackers/wgl/shared/stw_device.h index 969e3843e7..e097f1f71e 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.h +++ b/src/gallium/state_trackers/wgl/shared/stw_device.h @@ -37,7 +37,7 @@  #include "stw_pixelformat.h" -#define STW_MAX_PIXELFORMATS   128 +#define STW_MAX_PIXELFORMATS   256  struct pipe_screen; diff --git a/src/gallium/winsys/drm/intel/SConscript b/src/gallium/winsys/drm/intel/SConscript new file mode 100644 index 0000000000..50d7b75ed6 --- /dev/null +++ b/src/gallium/winsys/drm/intel/SConscript @@ -0,0 +1,7 @@ +Import('*') + +SConscript(['gem/SConscript',]) + +if 'mesa' in env['statetrackers']: + +    SConscript(['dri/SConscript']) diff --git a/src/gallium/winsys/drm/intel/dri/Makefile b/src/gallium/winsys/drm/intel/dri/Makefile index a4704bc050..de39e759d8 100644 --- a/src/gallium/winsys/drm/intel/dri/Makefile +++ b/src/gallium/winsys/drm/intel/dri/Makefile @@ -6,6 +6,7 @@ LIBNAME = i915_dri.so  PIPE_DRIVERS = \  	$(TOP)/src/gallium/state_trackers/dri/libdridrm.a \  	$(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ +	$(TOP)/src/gallium/drivers/trace/libtrace.a \  	$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \  	$(TOP)/src/gallium/drivers/i915simple/libi915simple.a @@ -21,5 +22,5 @@ include ../../Makefile.template  DRI_LIB_DEPS += -ldrm_intel  symlinks: $(TOP)/$(LIB_DIR)/gallium -	@rm -f $(TOP)/lib/gallium/i965_dri.so -	ln -s i915_dri.so $(TOP)/lib/gallium/i965_dri.so +	@rm -f $(TOP)/$(LIB_DIR)/gallium/i965_dri.so +	ln -s i915_dri.so $(TOP)/$(LIB_DIR)/gallium/i965_dri.so diff --git a/src/gallium/winsys/drm/intel/dri/SConscript b/src/gallium/winsys/drm/intel/dri/SConscript new file mode 100644 index 0000000000..e14e96e32f --- /dev/null +++ b/src/gallium/winsys/drm/intel/dri/SConscript @@ -0,0 +1,16 @@ +Import('*') + +env = drienv.Clone() + +drivers = [ +    softpipe, +    i915simple, +    trace, +    inteldrm +] + +env.SharedLibrary( +    target ='i915_dri.so', +    source = COMMON_GALLIUM_SOURCES, +    LIBS = drivers + mesa + auxiliaries + env['LIBS'], +) diff --git a/src/gallium/winsys/drm/intel/gem/SConscript b/src/gallium/winsys/drm/intel/gem/SConscript new file mode 100644 index 0000000000..ea8a2e55f6 --- /dev/null +++ b/src/gallium/winsys/drm/intel/gem/SConscript @@ -0,0 +1,17 @@ +Import('*') + +env = drienv.Clone() + +inteldrm_sources = [ +    'intel_be_api.c', +    'intel_be_batchbuffer.c', +    'intel_be_context.c', +    'intel_be_device.c', +] + +inteldrm = env.ConvenienceLibrary( +    target ='inteldrm', +    source = inteldrm_sources, +) + +Export('inteldrm') diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_api.c b/src/gallium/winsys/drm/intel/gem/intel_be_api.c index f4ef7c2d88..a74be13bf7 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_api.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.c @@ -2,7 +2,13 @@  #include "intel_be_api.h"  #include "i915simple/i915_winsys.h" +#ifdef DEBUG +#include "trace/trace_drm.h" + +struct drm_api hooks = +#else  struct drm_api drm_api_hooks = +#endif  {  	/* intel_be_context.c */  	.create_context = intel_be_create_context, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 428d3f65a1..5406d2bbea 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -30,6 +30,10 @@  #include "radeon_drm.h" +#ifdef DEBUG +#include "trace/trace_drm.h" +#endif +  /* Create a pipe_screen. */  struct pipe_screen* radeon_create_screen(int drmFB,  					 struct drm_create_screen_arg *arg) @@ -112,7 +116,11 @@ boolean radeon_global_handle_from_buffer(struct pipe_screen* screen,      return TRUE;  } +#ifdef DEBUG +struct drm_api hooks = { +#else  struct drm_api drm_api_hooks = { +#endif      .create_screen = radeon_create_screen,      .create_context = radeon_create_context,      /* XXX fix this */ diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index be70ead68d..65366e242c 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -57,10 +57,6 @@ static boolean radeon_r300_validate(struct r300_winsys* winsys)          (struct radeon_winsys_priv*)winsys->radeon_winsys;      struct radeon_cs_space_check* sc = priv->sc; -    debug_printf("Validation count: %d\n", priv->bo_count); -    for (i = 0; i < priv->bo_count; i++) { -        debug_printf("BO %d: %p rd: %d wd: %d\n", i, sc[i].bo, sc[i].read_domains, sc[i].write_domain); -    }      retval = radeon_cs_space_check(priv->cs, sc, priv->bo_count);      if (retval == RADEON_CS_SPACE_OP_TO_BIG) { @@ -152,44 +148,44 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys)  /* Helper function to do the ioctls needed for setup and init. */  static void do_ioctls(struct r300_winsys* winsys, int fd)  { -    struct drm_radeon_gem_info info = {0}; +    struct drm_radeon_gem_info gem_info = {0};      drm_radeon_getparam_t gp = {0}; +    struct drm_radeon_info info = {0};      int target = 0;      int retval; +    info.value = ⌖      gp.value = ⌖ -    /* First, get the number of pixel pipes */ -    gp.param = RADEON_PARAM_NUM_GB_PIPES; -    retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); +    /* First, get PCI ID */ +    info.request = RADEON_INFO_DEVICE_ID; +    retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));      if (retval) { -        fprintf(stderr, "%s: Failed to get GB pipe count, error number %d\n", +        fprintf(stderr, "%s: New ioctl for PCI ID failed " +                "(error number %d), trying classic ioctl...\n",                  __FUNCTION__, retval); -        exit(1); -    } -    winsys->gb_pipes = target; - -    /* Then, get PCI ID */ -    gp.param = RADEON_PARAM_DEVICE_ID; -    retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); -    if (retval) { -        fprintf(stderr, "%s: Failed to get PCI ID, error number %d\n", -                __FUNCTION__, retval); -        exit(1); +        gp.param = RADEON_PARAM_DEVICE_ID; +        retval = drmCommandWriteRead(fd, DRM_RADEON_GETPARAM, &gp, +                sizeof(gp)); +        if (retval) { +            fprintf(stderr, "%s: Failed to get PCI ID, " +                    "error number %d\n", __FUNCTION__, retval); +            exit(1); +        }      }      winsys->pci_id = target; -    /* Finally, retrieve MM info */ +    /* Then, retrieve MM info */      retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO, -            &info, sizeof(info)); +            &gem_info, sizeof(gem_info));      if (retval) {          fprintf(stderr, "%s: Failed to get MM info, error number %d\n",                  __FUNCTION__, retval);          exit(1);      } -    winsys->gart_size = info.gart_size; +    winsys->gart_size = gem_info.gart_size;      /* XXX */ -    winsys->vram_size = info.vram_visible; +    winsys->vram_size = gem_info.vram_visible;  }  struct r300_winsys* diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h index 5c373cd084..a2e0e58248 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.h @@ -31,5 +31,18 @@  #include "radeon_buffer.h" +/* protect us from bonghits */ +#ifndef RADEON_INFO_DEVICE_ID +#define RADEON_INFO_DEVICE_ID 0 +#endif +#ifndef DRM_RADEON_INFO +#define DRM_RADEON_INFO 0x1 +struct drm_radeon_info { +	uint32_t		request; +	uint32_t		pad; +	uint64_t		value; +}; +#endif +  struct r300_winsys*  radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys); diff --git a/src/gallium/winsys/drm/radeon/dri/Makefile b/src/gallium/winsys/drm/radeon/dri/Makefile index c218ee9d01..a9889444de 100644 --- a/src/gallium/winsys/drm/radeon/dri/Makefile +++ b/src/gallium/winsys/drm/radeon/dri/Makefile @@ -10,6 +10,7 @@ PIPE_DRIVERS = \  	$(TOP)/src/gallium/state_trackers/dri/libdridrm.a \  	$(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \  	$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ +	$(TOP)/src/gallium/drivers/trace/libtrace.a \  	$(TOP)/src/gallium/drivers/r300/libr300.a  C_SOURCES = \ diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile index d989b3aa93..6a1448d1b9 100644 --- a/src/gallium/winsys/drm/radeon/egl/Makefile +++ b/src/gallium/winsys/drm/radeon/egl/Makefile @@ -8,6 +8,7 @@ PIPE_DRIVERS = \  	$(TOP)/src/gallium/state_trackers/egl/libegldrm.a \  	$(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \  	$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ +	$(TOP)/src/gallium/drivers/trace/libtrace.a \  	$(TOP)/src/gallium/drivers/r300/libr300.a  DRIVER_SOURCES = diff --git a/src/glx/x11/drisw_glx.c b/src/glx/x11/drisw_glx.c index 5e3d763cff..b843ce484f 100644 --- a/src/glx/x11/drisw_glx.c +++ b/src/glx/x11/drisw_glx.c @@ -405,6 +405,8 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen,     psp->createContext = driCreateContext;     psp->createDrawable = driCreateDrawable;     psp->swapBuffers = driSwapBuffers; +   psp->waitX = NULL; +   psp->waitGL = NULL;     return psp; diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index b9e0706d31..ec3e69e4fe 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -1319,28 +1319,29 @@ PUBLIC XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *attribList)      ** Eliminate visuals that don't meet minimum requirements      ** Compute a score for those that do      ** Remember which visual, if any, got the highest score +    ** If no visual is acceptable, return None +    ** Otherwise, create an XVisualInfo list with just the selected X visual +    ** and return this.      */      for ( modes = psc->visuals ; modes != NULL ; modes = modes->next ) {  	if ( fbconfigs_compatible( & test_config, modes )  	     && ((best_config == NULL)  		 || (fbconfig_compare( (const __GLcontextModes * const * const)&modes, &best_config ) < 0)) ) { -	    best_config = modes; -	} -    } +	    XVisualInfo visualTemplate; +	    XVisualInfo *newList; +	    int  i; -    /* -    ** If no visual is acceptable, return None -    ** Otherwise, create an XVisualInfo list with just the selected X visual -    ** and return this. -    */ -    if (best_config != NULL) { -	XVisualInfo visualTemplate; -	int  i; +	    visualTemplate.screen = screen; +	    visualTemplate.visualid = modes->visualID; +	    newList = XGetVisualInfo( dpy, VisualScreenMask|VisualIDMask, +				      &visualTemplate, &i ); -	visualTemplate.screen = screen; -	visualTemplate.visualid = best_config->visualID; -	visualList = XGetVisualInfo( dpy, VisualScreenMask|VisualIDMask, -				     &visualTemplate, &i ); +	    if (newList) { +		Xfree(visualList); +		visualList = newList; +		best_config = modes; +	    } +	}      }      return visualList; diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index 9f4bd1699f..beaf9a4b12 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -19,6 +19,7 @@ DRIVER_SOURCES = \  	intel_batchbuffer.c \  	intel_clear.c \  	intel_extensions.c \ +	intel_generatemipmap.c \  	intel_mipmap_tree.c \  	intel_tex_layout.c \  	intel_tex_image.c \ diff --git a/src/mesa/drivers/dri/i915/i915_tex_layout.c b/src/mesa/drivers/dri/i915/i915_tex_layout.c index d44a2f47b3..40bcf7a9af 100644 --- a/src/mesa/drivers/dri/i915/i915_tex_layout.c +++ b/src/mesa/drivers/dri/i915/i915_tex_layout.c @@ -55,6 +55,17 @@ static GLint step_offsets[6][2] = {     [FACE_NEG_Z] = {-1, 1},  }; + +static GLint bottom_offsets[6] = { +   [FACE_POS_X] = 16 + 0 * 8, +   [FACE_POS_Y] = 16 + 1 * 8, +   [FACE_POS_Z] = 16 + 2 * 8, +   [FACE_NEG_X] = 16 + 3 * 8, +   [FACE_NEG_Y] = 16 + 4 * 8, +   [FACE_NEG_Z] = 16 + 5 * 8, +}; + +  /**   * Cube texture map layout for i830M-GM915.   * @@ -297,7 +308,7 @@ i915_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)   * +---+   +---+   +---+   +---+   +---+   +---+   *   * The bottom row continues with the remaining 2x2 then the 1x1 mip contents - * in order, with each of them aligned to a 4x4 block boundary.  Thus, for + * in order, with each of them aligned to a 8x8 block boundary.  Thus, for   * 32x32 cube maps and smaller, the bottom row layout is going to dictate the   * pitch of the tree.  For a tree with 4x4 images, the pitch is at least   * 14 * 8 = 112 texels, for 2x2 it is at least 12 * 8 texels, and for 1x1 @@ -375,10 +386,11 @@ i945_miptree_layout_cube(struct intel_context *intel,  	       x = (face - 4) * 8;  	       break;  	    } +	    break;  	 case 2:  	    y = mt->total_height - 4; -	    x = 16 + face * 8; +	    x = bottom_offsets[face];  	    break;  	 case 1: @@ -454,7 +466,10 @@ i945_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)  {     switch (mt->target) {     case GL_TEXTURE_CUBE_MAP: -      i945_miptree_layout_cube(intel, mt); +      if (mt->compressed) +	 i945_miptree_layout_cube(intel, mt); +      else +	 i915_miptree_layout_cube(intel, mt);        break;     case GL_TEXTURE_3D:        i945_miptree_layout_3d(intel, mt); diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h index 62c98bd8bb..bc7756ceab 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.h +++ b/src/mesa/drivers/dri/i965/brw_eu.h @@ -97,7 +97,7 @@ struct brw_glsl_call;  #define BRW_EU_MAX_INSN_STACK 5 -#define BRW_EU_MAX_INSN 4000 +#define BRW_EU_MAX_INSN 10000  struct brw_compile {     struct brw_instruction store[BRW_EU_MAX_INSN]; diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index cd65f57bbc..3e476fd3be 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -319,6 +319,9 @@ static void brw_wm_populate_key( struct brw_context *brw,        key->drawable_height = brw->intel.driDrawable->h;     } +   /* CACHE_NEW_VS_PROG */ +   key->vp_outputs_written = brw->vs.prog_data->outputs_written & DO_SETUP_BITS; +     /* The unique fragment program ID */     key->program_string_id = fp->id;  } @@ -357,7 +360,7 @@ const struct brw_tracked_state brw_wm_prog = {        .brw   = (BRW_NEW_FRAGMENT_PROGRAM |  		BRW_NEW_WM_INPUT_DIMENSIONS |  		BRW_NEW_REDUCED_PRIMITIVE), -      .cache = 0 +      .cache = CACHE_NEW_VS_PROG,     },     .prepare = brw_prepare_wm_prog  }; diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index 59ead757b5..fb15c03e83 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -75,6 +75,7 @@ struct brw_wm_prog_key {     GLuint program_string_id:32;     GLuint origin_x, origin_y;     GLuint drawable_height; +   GLuint vp_outputs_written;  }; diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index efe8b5126c..4936703799 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -302,7 +302,7 @@ static void prealloc_reg(struct brw_wm_compile *c)  {      int i, j;      struct brw_reg reg; -    int nr_interp_regs = 0; +    int urb_read_length = 0;      GLuint inputs = FRAG_BIT_WPOS | c->fp_interp_emitted | c->fp_deriv_emitted;      GLuint reg_index = 0; @@ -366,18 +366,29 @@ static void prealloc_reg(struct brw_wm_compile *c)      }      /* fragment shader inputs */ -    for (i = 0; i < FRAG_ATTRIB_MAX; i++) { -	if (inputs & (1<<i)) { -	    nr_interp_regs++; -	    reg = brw_vec8_grf(reg_index, 0); -	    for (j = 0; j < 4; j++) -		set_reg(c, PROGRAM_PAYLOAD, i, j, reg); -	    reg_index += 2; -	} +    for (i = 0; i < VERT_RESULT_MAX; i++) { +       int fp_input; + +       if (i >= VERT_RESULT_VAR0) +	  fp_input = i - VERT_RESULT_VAR0 + FRAG_ATTRIB_VAR0; +       else if (i <= VERT_RESULT_TEX7) +	  fp_input = i; +       else +	  fp_input = -1; + +       if (fp_input >= 0 && inputs & (1 << fp_input)) { +	  urb_read_length = reg_index; +	  reg = brw_vec8_grf(reg_index, 0); +	  for (j = 0; j < 4; j++) +	     set_reg(c, PROGRAM_PAYLOAD, fp_input, j, reg); +       } +       if (c->key.vp_outputs_written & (1 << i)) { +	  reg_index += 2; +       }      }      c->prog_data.first_curbe_grf = c->key.nr_depth_regs * 2; -    c->prog_data.urb_read_length = nr_interp_regs * 2; +    c->prog_data.urb_read_length = urb_read_length;      c->prog_data.curb_read_length = c->nr_creg;      c->emit_mask_reg = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, reg_index, 0);      reg_index++; @@ -509,6 +520,14 @@ static struct brw_reg get_src_reg(struct brw_wm_compile *c,      const GLuint nr = 1;      const GLuint component = GET_SWZ(src->Swizzle, channel); +    /* Extended swizzle terms */ +    if (component == SWIZZLE_ZERO) { +       return brw_imm_f(0.0F); +    } +    else if (component == SWIZZLE_ONE) { +       return brw_imm_f(1.0F); +    } +      if (c->fp->use_const_buffer &&          (src->File == PROGRAM_STATE_VAR ||           src->File == PROGRAM_CONSTANT || @@ -806,27 +825,26 @@ static void emit_fb_write(struct brw_wm_compile *c,      }      if (c->key.dest_depth_reg) { -        GLuint comp = c->key.dest_depth_reg / 2; -        GLuint off = c->key.dest_depth_reg % 2; +        const GLuint comp = c->key.dest_depth_reg / 2; +        const GLuint off = c->key.dest_depth_reg % 2; -        assert(comp == 1); -        assert(off == 0); -#if 0 -        /* XXX do we need this code?   comp always 1, off always 0, it seems */          if (off != 0) { +            /* XXX this code needs review/testing */ +            struct brw_reg arg1_0 = get_src_reg(c, inst, 1, comp); +            struct brw_reg arg1_1 = get_src_reg(c, inst, 1, comp+1); +              brw_push_insn_state(p);              brw_set_compression_control(p, BRW_COMPRESSION_NONE); -            brw_MOV(p, brw_message_reg(nr), offset(arg1[comp],1)); +            brw_MOV(p, brw_message_reg(nr), offset(arg1_0, 1));              /* 2nd half? */ -            brw_MOV(p, brw_message_reg(nr+1), arg1[comp+1]); +            brw_MOV(p, brw_message_reg(nr+1), arg1_1);              brw_pop_insn_state(p);          }          else -#endif          { -           struct brw_reg src =  get_src_reg(c, inst, 1, 1); -           brw_MOV(p, brw_message_reg(nr), src); +            struct brw_reg src =  get_src_reg(c, inst, 1, 1); +            brw_MOV(p, brw_message_reg(nr), src);          }          nr += 2;     } diff --git a/src/mesa/drivers/dri/i965/brw_wm_iz.c b/src/mesa/drivers/dri/i965/brw_wm_iz.c index bd60ac9b31..8fd067abe7 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_iz.c +++ b/src/mesa/drivers/dri/i965/brw_wm_iz.c @@ -116,6 +116,10 @@ const struct {   { C, 0, 1, 1, 1 }   }; +/** + * \param line_aa  AA_NEVER, AA_ALWAYS or AA_SOMETIMES + * \param lookup  bitmask of IZ_* flags + */  void brw_wm_lookup_iz( GLuint line_aa,  		       GLuint lookup,  		       struct brw_wm_prog_key *key ) diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass2.c b/src/mesa/drivers/dri/i965/brw_wm_pass2.c index 780edbc42e..6faea018fb 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_pass2.c +++ b/src/mesa/drivers/dri/i965/brw_wm_pass2.c @@ -69,8 +69,6 @@ static void prealloc_reg(struct brw_wm_compile *c,   */  static void init_registers( struct brw_wm_compile *c )  { -   struct brw_context *brw = c->func.brw; -   GLuint inputs = (brw->vs.prog_data->outputs_written & DO_SETUP_BITS);     GLuint nr_interp_regs = 0;     GLuint i = 0;     GLuint j; @@ -85,16 +83,19 @@ static void init_registers( struct brw_wm_compile *c )        prealloc_reg(c, &c->creg[j], i++);     for (j = 0; j < FRAG_ATTRIB_MAX; j++) { -      if (inputs & (1<<j)) { -	 /* index for vs output and ps input are not the same  -	    in shader varying */ -	 GLuint index; -	 if (j > FRAG_ATTRIB_VAR0) -	     index = j - (VERT_RESULT_VAR0 - FRAG_ATTRIB_VAR0); +      if (c->key.vp_outputs_written & (1<<j)) { +	 int fp_index; + +	 if (j >= VERT_RESULT_VAR0) +	    fp_index = j - (VERT_RESULT_VAR0 - FRAG_ATTRIB_VAR0); +	 else if (j <= VERT_RESULT_TEX7) +	    fp_index = j;  	 else -	     index = j; +	    fp_index = -1; +  	 nr_interp_regs++; -	 prealloc_reg(c, &c->payload.input_interp[index], i++); +	 if (fp_index >= 0) +	    prealloc_reg(c, &c->payload.input_interp[fp_index], i++);        }     } diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index c604ef0162..3fc18ff1f3 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -178,6 +178,16 @@ static void brw_update_sampler_state(struct wm_sampler_entry *key,        sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CUBE;        sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CUBE;     } +   else if (key->tex_target == GL_TEXTURE_1D) { +      /* There's a bug in 1D texture sampling - it actually pays +       * attention to the wrap_t value, though it should not. +       * Override the wrap_t value here to GL_REPEAT to keep +       * any nonexistent border pixels from floating in. +       */ +      sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r); +      sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s); +      sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_WRAP; +   }     else {        sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r);        sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s); diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c index f6b0d769c6..0db1f392c0 100644 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c @@ -214,6 +214,7 @@ intel_bufferobj_map(GLcontext * ctx,     struct intel_context *intel = intel_context(ctx);     struct intel_buffer_object *intel_obj = intel_buffer_object(obj);     GLboolean read_only = (access == GL_READ_ONLY_ARB); +   GLboolean write_only = (access == GL_WRITE_ONLY_ARB);     assert(intel_obj); @@ -225,7 +226,14 @@ intel_bufferobj_map(GLcontext * ctx,        return NULL;     } -   dri_bo_map(intel_obj->buffer, !read_only); +   if (write_only && intel->intelScreen->kernel_exec_fencing) { +      drm_intel_gem_bo_map_gtt(intel_obj->buffer); +      intel_obj->mapped_gtt = GL_TRUE; +   } else { +      drm_intel_bo_map(intel_obj->buffer, !read_only); +      intel_obj->mapped_gtt = GL_FALSE; +   } +     obj->Pointer = intel_obj->buffer->virtual;     return obj->Pointer;  } @@ -243,7 +251,11 @@ intel_bufferobj_unmap(GLcontext * ctx,     assert(intel_obj);     if (intel_obj->buffer != NULL) {        assert(obj->Pointer); -      dri_bo_unmap(intel_obj->buffer); +      if (intel_obj->mapped_gtt) { +	 drm_intel_gem_bo_unmap_gtt(intel_obj->buffer); +      } else { +	 drm_intel_bo_unmap(intel_obj->buffer); +      }        obj->Pointer = NULL;     }     return GL_TRUE; diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.h b/src/mesa/drivers/dri/intel/intel_buffer_objects.h index bf6dbd58f2..7ef723833c 100644 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.h +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.h @@ -46,6 +46,7 @@ struct intel_buffer_object     struct intel_region *region; /* Is there a zero-copy texture                                     associated with this (pixel)                                     buffer object? */ +   GLboolean mapped_gtt;  }; diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index 4f4ea45b74..df5c3fc176 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -276,7 +276,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)        ctx->Driver.Enable(ctx, GL_DEPTH_TEST,                           (ctx->Depth.Test && fb->Visual.depthBits > 0));        ctx->Driver.Enable(ctx, GL_STENCIL_TEST, -                         (ctx->Stencil._Enabled && fb->Visual.stencilBits > 0)); +                         (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0));     }     else {        /* Mesa's Stencil._Enabled field is updated when diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c index aed95c7c56..4dfaee8a4a 100644 --- a/src/mesa/drivers/dri/intel/intel_clear.c +++ b/src/mesa/drivers/dri/intel/intel_clear.c @@ -30,6 +30,7 @@  #include "main/enums.h"  #include "main/image.h"  #include "main/mtypes.h" +#include "main/arrayobj.h"  #include "main/attrib.h"  #include "main/blend.h"  #include "main/bufferobj.h" @@ -66,6 +67,45 @@  			      BUFFER_BIT_COLOR6 |			\  			      BUFFER_BIT_COLOR7) + +/** + * Per-context one-time init of things for intl_clear_tris(). + * Basically set up a private array object for vertex/color arrays. + */ +static void +init_clear(GLcontext *ctx) +{ +   struct intel_context *intel = intel_context(ctx); +   struct gl_array_object *arraySave = NULL; +   const GLuint arrayBuffer = ctx->Array.ArrayBufferObj->Name; +   const GLuint elementBuffer = ctx->Array.ElementArrayBufferObj->Name; + +   /* create new array object */ +   intel->clear.arrayObj = _mesa_new_array_object(ctx, ~0); + +   /* save current array object, bind new one */ +   _mesa_reference_array_object(ctx, &arraySave, ctx->Array.ArrayObj); +   _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, intel->clear.arrayObj); + +   /* one-time setup of vertex arrays (pos, color) */ +   _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, 0); +   _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); +   _mesa_ColorPointer(4, GL_FLOAT, 4 * sizeof(GLfloat), intel->clear.color); +   _mesa_VertexPointer(3, GL_FLOAT, 3 * sizeof(GLfloat), intel->clear.vertices); +   _mesa_Enable(GL_COLOR_ARRAY); +   _mesa_Enable(GL_VERTEX_ARRAY); + +   /* restore original array object */ +   _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, arraySave); +   _mesa_reference_array_object(ctx, &arraySave, NULL); + +   /* restore original buffer objects */ +   _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, arrayBuffer); +   _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, elementBuffer); +} + + +  /**   * Perform glClear where mask contains only color, depth, and/or stencil.   * @@ -78,14 +118,16 @@ void  intel_clear_tris(GLcontext *ctx, GLbitfield mask)  {     struct intel_context *intel = intel_context(ctx); -   GLfloat vertices[4][3]; -   GLfloat color[4][4];     GLfloat dst_z;     struct gl_framebuffer *fb = ctx->DrawBuffer;     int i;     GLboolean saved_fp_enable = GL_FALSE, saved_vp_enable = GL_FALSE;     GLuint saved_shader_program = 0;     unsigned int saved_active_texture; +   struct gl_array_object *arraySave = NULL; + +   if (!intel->clear.arrayObj) +      init_clear(ctx);     assert((mask & ~(TRI_CLEAR_COLOR_BITS | BUFFER_BIT_DEPTH |  		    BUFFER_BIT_STENCIL)) == 0); @@ -98,7 +140,6 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)  		    GL_STENCIL_BUFFER_BIT |  		    GL_TRANSFORM_BIT |  		    GL_CURRENT_BIT); -   _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);     saved_active_texture = ctx->Texture.CurrentUnit;     /* Disable existing GL state we don't want to apply to a clear. */ @@ -149,18 +190,14 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)        }     } -#if FEATURE_ARB_vertex_buffer_object -   _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, 0); -   _mesa_BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); -#endif +   /* save current array object, bind our private one */ +   _mesa_reference_array_object(ctx, &arraySave, ctx->Array.ArrayObj); +   _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, intel->clear.arrayObj);     intel_meta_set_passthrough_transform(intel);     for (i = 0; i < 4; i++) { -      color[i][0] = ctx->Color.ClearColor[0]; -      color[i][1] = ctx->Color.ClearColor[1]; -      color[i][2] = ctx->Color.ClearColor[2]; -      color[i][3] = ctx->Color.ClearColor[3]; +      COPY_4FV(intel->clear.color[i], ctx->Color.ClearColor);     }     /* convert clear Z from [0,1] to NDC coord in [-1,1] */ @@ -169,23 +206,18 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)     /* Prepare the vertices, which are the same regardless of which buffer we're      * drawing to.      */ -   vertices[0][0] = fb->_Xmin; -   vertices[0][1] = fb->_Ymin; -   vertices[0][2] = dst_z; -   vertices[1][0] = fb->_Xmax; -   vertices[1][1] = fb->_Ymin; -   vertices[1][2] = dst_z; -   vertices[2][0] = fb->_Xmax; -   vertices[2][1] = fb->_Ymax; -   vertices[2][2] = dst_z; -   vertices[3][0] = fb->_Xmin; -   vertices[3][1] = fb->_Ymax; -   vertices[3][2] = dst_z; - -   _mesa_ColorPointer(4, GL_FLOAT, 4 * sizeof(GLfloat), &color); -   _mesa_VertexPointer(3, GL_FLOAT, 3 * sizeof(GLfloat), &vertices); -   _mesa_Enable(GL_COLOR_ARRAY); -   _mesa_Enable(GL_VERTEX_ARRAY); +   intel->clear.vertices[0][0] = fb->_Xmin; +   intel->clear.vertices[0][1] = fb->_Ymin; +   intel->clear.vertices[0][2] = dst_z; +   intel->clear.vertices[1][0] = fb->_Xmax; +   intel->clear.vertices[1][1] = fb->_Ymin; +   intel->clear.vertices[1][2] = dst_z; +   intel->clear.vertices[2][0] = fb->_Xmax; +   intel->clear.vertices[2][1] = fb->_Ymax; +   intel->clear.vertices[2][2] = dst_z; +   intel->clear.vertices[3][0] = fb->_Xmin; +   intel->clear.vertices[3][1] = fb->_Ymax; +   intel->clear.vertices[3][2] = dst_z;     while (mask != 0) {        GLuint this_mask = 0; @@ -223,8 +255,10 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)        /* Control writing of the stencil clear value to stencil. */        if (this_mask & BUFFER_BIT_STENCIL) {  	 _mesa_Enable(GL_STENCIL_TEST); -	 _mesa_StencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); -	 _mesa_StencilFuncSeparate(GL_FRONT, GL_ALWAYS, ctx->Stencil.Clear, +	 _mesa_StencilOpSeparate(GL_FRONT_AND_BACK, +				 GL_REPLACE, GL_REPLACE, GL_REPLACE); +	 _mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS, +				   ctx->Stencil.Clear,  				   ctx->Stencil.WriteMask[0]);        } else {  	 _mesa_Disable(GL_STENCIL_TEST); @@ -246,8 +280,11 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)     if (saved_shader_program)        _mesa_UseProgramObjectARB(saved_shader_program); -   _mesa_PopClientAttrib();     _mesa_PopAttrib(); + +   /* restore current array object */ +   _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, arraySave); +   _mesa_reference_array_object(ctx, &arraySave, NULL);  }  static const char *buffer_names[] = { diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 8b3e50f9b6..49eadc7532 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -28,6 +28,7 @@  #include "main/glheader.h"  #include "main/context.h" +#include "main/arrayobj.h"  #include "main/extensions.h"  #include "main/framebuffer.h"  #include "main/imports.h" @@ -393,7 +394,7 @@ intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)      if (!driContext->driScreenPriv->dri2.enabled)  	return; -    if (!intel->internal_viewport_call) { +    if (!intel->internal_viewport_call && ctx->DrawBuffer->Name == 0) {         intel_update_renderbuffers(driContext, driContext->driDrawablePriv);         if (driContext->driDrawablePriv != driContext->driReadablePriv)  	  intel_update_renderbuffers(driContext, driContext->driReadablePriv); @@ -755,6 +756,9 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)        INTEL_FIREVERTICES(intel); +      if (intel->clear.arrayObj) +         _mesa_delete_array_object(&intel->ctx, intel->clear.arrayObj); +        intel->vtbl.destroy(intel);        release_texture_heaps = (intel->ctx.Shared->RefCount == 1); diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index c16732d7b5..e931e401e9 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -225,6 +225,14 @@ struct intel_context     GLuint ClearColor565;     GLuint ClearColor8888; +   /* info for intel_clear_tris() */ +   struct +   { +      struct gl_array_object *arrayObj; +      GLfloat vertices[4][3]; +      GLfloat color[4][4]; +   } clear; +     /* Offsets of fields within the current vertex:      */     GLuint coloroffset; diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c index 9ec1b4ec2f..1e8b1878ab 100644 --- a/src/mesa/drivers/dri/intel/intel_extensions.c +++ b/src/mesa/drivers/dri/intel/intel_extensions.c @@ -48,6 +48,7 @@  #define need_GL_EXT_point_parameters  #define need_GL_EXT_secondary_color  #define need_GL_EXT_stencil_two_side +#define need_GL_APPLE_vertex_array_object  #define need_GL_ATI_separate_stencil  #define need_GL_ATI_envmap_bumpmap  #define need_GL_NV_point_sprite @@ -95,6 +96,7 @@ static const struct dri_extension card_extensions[] = {     { "GL_EXT_texture_lod_bias",           NULL },     { "GL_3DFX_texture_compression_FXT1",  NULL },     { "GL_APPLE_client_storage",           NULL }, +   { "GL_APPLE_vertex_array_object",      GL_APPLE_vertex_array_object_functions},     { "GL_MESA_pack_invert",               NULL },     { "GL_MESA_ycbcr_texture",             NULL },     { "GL_NV_blend_square",                NULL }, diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 65e62947ef..2728823142 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -236,7 +236,7 @@ intel_get_param(__DRIscreenPrivate *psp, int param, int *value)     ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));     if (ret) { -      fprintf(stderr, "drm_i915_getparam: %d\n", ret); +      _mesa_warning(NULL, "drm_i915_getparam: %d\n", ret);        return GL_FALSE;     } diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index b71fe2a7ae..ddbb13e74a 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -208,7 +208,7 @@ try_pbo_upload(struct intel_context *intel,     if (!pbo ||         intel->ctx._ImageTransferState ||         unpack->SkipPixels || unpack->SkipRows) { -      _mesa_printf("%s: failure 1\n", __FUNCTION__); +      DBG("%s: failure 1\n", __FUNCTION__);        return GL_FALSE;     } @@ -264,7 +264,7 @@ try_pbo_zcopy(struct intel_context *intel,     if (!pbo ||         intel->ctx._ImageTransferState ||         unpack->SkipPixels || unpack->SkipRows) { -      _mesa_printf("%s: failure 1\n", __FUNCTION__); +      DBG("%s: failure 1\n", __FUNCTION__);        return GL_FALSE;     } @@ -283,7 +283,7 @@ try_pbo_zcopy(struct intel_context *intel,     dst_stride = intelImage->mt->pitch;     if (src_stride != dst_stride || dst_offset != 0 || src_offset != 0) { -      _mesa_printf("%s: failure 2\n", __FUNCTION__); +      DBG("%s: failure 2\n", __FUNCTION__);        return GL_FALSE;     } diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h index 9c2f340cfa..90c2aea155 100644 --- a/src/mesa/main/arrayobj.h +++ b/src/mesa/main/arrayobj.h @@ -57,6 +57,7 @@ _mesa_initialize_array_object( GLcontext *ctx,                                 struct gl_array_object *obj, GLuint name ); +  /*   * API functions   */ diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 9c5a5908a2..83301f1e62 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -368,12 +368,18 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,              att->Complete = GL_FALSE;              return;           } +         if (texImage->TexFormat->TexelBytes == 0) { +            att_incomplete("compressed internalformat"); +            att->Complete = GL_FALSE; +            return; +         }        }        else if (format == GL_DEPTH) {           if (texImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {              /* OK */           }           else if (ctx->Extensions.EXT_packed_depth_stencil && +                  ctx->Extensions.ARB_depth_texture &&                    texImage->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT) {              /* OK */           } @@ -384,10 +390,19 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,           }        }        else { -         /* no such thing as stencil textures */ -         att_incomplete("illegal stencil texture"); -         att->Complete = GL_FALSE; -         return; +         ASSERT(format == GL_STENCIL); +         ASSERT(att->Renderbuffer->StencilBits); +         if (ctx->Extensions.EXT_packed_depth_stencil && +             ctx->Extensions.ARB_depth_texture && +             att->Renderbuffer->_BaseFormat == GL_DEPTH_STENCIL_EXT) { +            /* OK */ +         } +         else { +            /* no such thing as stencil-only textures */ +            att_incomplete("illegal stencil texture"); +            att->Complete = GL_FALSE; +            return; +         }        }     }     else if (att->Type == GL_RENDERBUFFER_EXT) { diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index bc8658beff..872982fa43 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -1370,6 +1370,9 @@ make_2d_stack_mipmap(GLenum datatype, GLuint comps, GLint border,  /**   * Down-sample a texture image to produce the next lower mipmap level. + * \param comps  components per texel (1, 2, 3 or 4) + * \param srcRowStride  stride between source rows, in texels + * \param dstRowStride  stride between destination rows, in texels   */  void  _mesa_generate_mipmap_level(GLenum target, @@ -1478,9 +1481,12 @@ next_mipmap_level_size(GLenum target, GLint border,  /** - * For GL_SGIX_generate_mipmap: - * Generate a complete set of mipmaps from texObj's base-level image. + * Automatic mipmap generation. + * This is the fallback/default function for ctx->Driver.GenerateMipmap(). + * Generate a complete set of mipmaps from texObj's BaseLevel image.   * Stop at texObj's MaxLevel or when we get to the 1x1 texture. + * For cube maps, target will be one of + * GL_TEXTURE_CUBE_MAP_POSITIVE/NEGATIVE_X/Y/Z; never GL_TEXTURE_CUBE_MAP.   */  void  _mesa_generate_mipmap(GLcontext *ctx, GLenum target, diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 0024efc0e6..d51e7b76ec 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -281,7 +281,8 @@ valid_texture_object(const struct gl_texture_object *tex)        _mesa_problem(NULL, "invalid reference to a deleted texture object");        return GL_FALSE;     default: -      _mesa_problem(NULL, "invalid texture object Target value"); +      _mesa_problem(NULL, "invalid texture object Target 0x%x, Id = %u", +                    tex->Target, tex->Name);        return GL_FALSE;     }  } diff --git a/src/mesa/main/texrender.c b/src/mesa/main/texrender.c index 49de6f5b8a..cc74d58fbd 100644 --- a/src/mesa/main/texrender.c +++ b/src/mesa/main/texrender.c @@ -507,6 +507,7 @@ update_wrapper(GLcontext *ctx, const struct gl_renderbuffer_attachment *att)     trb->Base.BlueBits = trb->TexImage->TexFormat->BlueBits;     trb->Base.AlphaBits = trb->TexImage->TexFormat->AlphaBits;     trb->Base.DepthBits = trb->TexImage->TexFormat->DepthBits; +   trb->Base.StencilBits = trb->TexImage->TexFormat->StencilBits;  } diff --git a/src/mesa/shader/prog_instruction.c b/src/mesa/shader/prog_instruction.c index ae3a003fee..44c961927a 100644 --- a/src/mesa/shader/prog_instruction.c +++ b/src/mesa/shader/prog_instruction.c @@ -343,7 +343,10 @@ _mesa_opcode_string(gl_inst_opcode opcode)  {     if (opcode < MAX_OPCODE)        return InstInfo[opcode].Name; -   else -      return "OP?"; +   else { +      static char s[20]; +      _mesa_snprintf(s, sizeof(s), "OP%u", opcode); +      return s; +   }  } diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index e6f9a91069..de7fef1f86 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -75,7 +75,11 @@ file_string(gl_register_file f, gl_prog_print_mode mode)     case PROGRAM_UNDEFINED:        return "UNDEFINED";     default: -      return "Unknown program file!"; +      { +         static char s[20]; +         _mesa_snprintf(s, sizeof(s), "FILE%u", f); +         return s; +      }     }  } @@ -736,7 +740,10 @@ _mesa_fprint_instruction_opt(FILE *f,                                  mode, prog);        }        else { -         _mesa_fprintf(f, "Other opcode %d\n", inst->Opcode); +         fprint_alu_instruction(f, inst, +                                _mesa_opcode_string(inst->Opcode), +                                3/*_mesa_num_inst_src_regs(inst->Opcode)*/, +                                mode, prog);        }        break;     } diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 3ba7b26928..5d4d8eee02 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -24,11 +24,12 @@   * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.   *    **************************************************************************/ - /* -  * Authors: -  *   Keith Whitwell <keith@tungstengraphics.com> -  *   Brian Paul -  */ + +/* + * Authors: + *   Keith Whitwell <keith@tungstengraphics.com> + *   Brian Paul + */  #include "main/imports.h"  #include "shader/prog_parameter.h" @@ -44,19 +45,21 @@  #include "st_program.h"  #include "st_inlines.h" +  /**   * Pass the given program parameters to the graphics pipe as a   * constant buffer. - * \param id  either PIPE_SHADER_VERTEX or PIPE_SHADER_FRAGMENT + * \param shader_type  either PIPE_SHADER_VERTEX or PIPE_SHADER_FRAGMENT   */  void st_upload_constants( struct st_context *st,                            struct gl_program_parameter_list *params, -                          unsigned id) +                          unsigned shader_type)  {     struct pipe_context *pipe = st->pipe; -   struct pipe_constant_buffer *cbuf = &st->state.constants[id]; +   struct pipe_constant_buffer *cbuf = &st->state.constants[shader_type]; -   assert(id == PIPE_SHADER_VERTEX || id == PIPE_SHADER_FRAGMENT); +   assert(shader_type == PIPE_SHADER_VERTEX || +          shader_type == PIPE_SHADER_FRAGMENT);     /* update constants */     if (params && params->NumParameters) { @@ -68,13 +71,14 @@ void st_upload_constants( struct st_context *st,         * avoid gratuitous rendering synchronization.         */        pipe_buffer_reference(&cbuf->buffer, NULL ); -      cbuf->buffer = pipe_buffer_create(pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT, +      cbuf->buffer = pipe_buffer_create(pipe->screen, 16, +                                        PIPE_BUFFER_USAGE_CONSTANT,  					paramBytes ); -      if (0) -      { -	 printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n",  -                __FUNCTION__, id, params->NumParameters, params->StateFlags); +      if (0) { +	 debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n",  +                      __FUNCTION__, shader_type, params->NumParameters, +                      params->StateFlags);           _mesa_print_parameter_list(params);        } @@ -84,15 +88,16 @@ void st_upload_constants( struct st_context *st,  				       0, paramBytes,  				       params->ParameterValues); -      st->pipe->set_constant_buffer(st->pipe, id, 0, cbuf); +      st->pipe->set_constant_buffer(st->pipe, shader_type, 0, cbuf);     }     else { -      st->constants.tracked_state[id].dirty.mesa = 0; -      //  st->pipe->set_constant_buffer(st->pipe, id, 0, NULL); +      st->constants.tracked_state[shader_type].dirty.mesa = 0x0;     }  } -/* Vertex shader: + +/** + * Vertex shader:   */  static void update_vs_constants(struct st_context *st )  { @@ -102,6 +107,7 @@ static void update_vs_constants(struct st_context *st )     st_upload_constants( st, params, PIPE_SHADER_VERTEX );  } +  const struct st_tracked_state st_update_vs_constants = {     "st_update_vs_constants",				/* name */     {							/* dirty */ @@ -111,7 +117,10 @@ const struct st_tracked_state st_update_vs_constants = {     update_vs_constants					/* update */  }; -/* Fragment shader: + + +/** + * Fragment shader:   */  static void update_fs_constants(struct st_context *st )  { @@ -121,6 +130,7 @@ static void update_fs_constants(struct st_context *st )     st_upload_constants( st, params, PIPE_SHADER_FRAGMENT );  } +  const struct st_tracked_state st_update_fs_constants = {     "st_update_fs_constants",				/* name */     {							/* dirty */ diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index f23186c73d..4d897b677e 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -98,8 +98,6 @@ update_framebuffer_state( struct st_context *st )     struct st_renderbuffer *strb;     GLuint i; -   memset(framebuffer, 0, sizeof(*framebuffer)); -     framebuffer->width = fb->Width;     framebuffer->height = fb->Height; @@ -120,13 +118,20 @@ update_framebuffer_state( struct st_context *st )           }           if (strb->surface) { -            framebuffer->cbufs[framebuffer->nr_cbufs] = strb->surface; +            pipe_surface_reference(&framebuffer->cbufs[framebuffer->nr_cbufs], +                                   strb->surface);              framebuffer->nr_cbufs++;           }           strb->defined = GL_TRUE; /* we'll be drawing something */        }     } +   for (i = framebuffer->nr_cbufs; i < PIPE_MAX_COLOR_BUFS; i++) { +      pipe_surface_reference(&framebuffer->cbufs[i], NULL); +   } +   /* +    * Depth/Stencil renderbuffer/surface. +    */     strb = st_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer);     if (strb) {        strb = st_renderbuffer(strb->Base.Wrapped); @@ -134,15 +139,14 @@ update_framebuffer_state( struct st_context *st )           /* rendering to a GL texture, may have to update surface */           update_renderbuffer_surface(st, strb);        } - -      framebuffer->zsbuf = strb->surface; +      pipe_surface_reference(&framebuffer->zsbuf, strb->surface);     }     else {        strb = st_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer);        if (strb) {           strb = st_renderbuffer(strb->Base.Wrapped);           assert(strb->surface); -         framebuffer->zsbuf = strb->surface; +         pipe_surface_reference(&framebuffer->zsbuf, strb->surface);        }     } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index a94e11fff1..f5d802055f 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -28,6 +28,7 @@  #include "main/imports.h"  #include "main/mtypes.h" +#include "main/arrayobj.h"  #include "main/bufferobj.h"  #include "st_inlines.h" @@ -307,4 +308,8 @@ st_init_bufferobject_functions(struct dd_function_table *functions)     functions->MapBufferRange = st_bufferobj_map_range;     functions->FlushMappedBufferRange = st_bufferobj_flush_mapped_range;     functions->UnmapBuffer = st_bufferobj_unmap; + +   /* For GL_APPLE_vertex_array_object */ +   functions->NewArrayObject = _mesa_new_array_object; +   functions->DeleteArrayObject = _mesa_delete_array_object;  } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 2a1f21c51c..e536029e86 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -233,6 +233,7 @@ void st_destroy_context( struct st_context *st )     struct pipe_context *pipe = st->pipe;     struct cso_context *cso = st->cso_context;     GLcontext *ctx = st->ctx; +   GLuint i;     /* need to unbind and destroy CSO objects before anything else */     cso_release_all(st->cso_context); @@ -240,6 +241,12 @@ void st_destroy_context( struct st_context *st )     st_reference_fragprog(st, &st->fp, NULL);     st_reference_vertprog(st, &st->vp, NULL); +   /* release framebuffer surfaces */ +   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { +      pipe_surface_reference(&st->state.framebuffer.cbufs[i], NULL); +   } +   pipe_surface_reference(&st->state.framebuffer.zsbuf, NULL); +     _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache);     _vbo_DestroyContext(st->ctx); diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 8f6be50774..d526dfcf52 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -168,6 +168,8 @@ void st_init_extensions(struct st_context *st)     ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;     ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; +   ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; +     ctx->Extensions.NV_blend_square = GL_TRUE;     ctx->Extensions.NV_texgen_reflection = GL_TRUE; diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index e159b4c9db..dc6d77825f 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -87,7 +87,7 @@ st_render_mipmap(struct st_context *st,     assert(target != GL_TEXTURE_3D); /* not done yet */     /* check if we can render in the texture's format */ -   if (!screen->is_format_supported(screen, pt->format, target, +   if (!screen->is_format_supported(screen, pt->format, pt->target,                                      PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {        return FALSE;     } @@ -123,6 +123,7 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,        struct pipe_transfer *srcTrans, *dstTrans;        const ubyte *srcData;        ubyte *dstData; +      int srcStride, dstStride;        srcTrans = st_cond_flush_get_tex_transfer(st_context(ctx), pt, face,  						srcLevel, zslice, @@ -139,14 +140,17 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,        srcData = (ubyte *) screen->transfer_map(screen, srcTrans);        dstData = (ubyte *) screen->transfer_map(screen, dstTrans); +      srcStride = srcTrans->stride / srcTrans->block.size; +      dstStride = dstTrans->stride / dstTrans->block.size; +        _mesa_generate_mipmap_level(target, datatype, comps,                     0 /*border*/,                     pt->width[srcLevel], pt->height[srcLevel], pt->depth[srcLevel],                     srcData, -                   srcTrans->stride, /* stride in bytes */ +                   srcStride, /* stride in texels */                     pt->width[dstLevel], pt->height[dstLevel], pt->depth[dstLevel],                     dstData, -                   dstTrans->stride); /* stride in bytes */ +                   dstStride); /* stride in texels */        screen->transfer_unmap(screen, srcTrans);        screen->transfer_unmap(screen, dstTrans); diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 31bfb5c952..0067d3eeb7 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1329,7 +1329,7 @@ static void  opt_sample_rgb_2d(GLcontext *ctx,                    const struct gl_texture_object *tObj,                    GLuint n, const GLfloat texcoords[][4], -                  const GLfloat lambda[], GLchan rgba[][4]) +                  const GLfloat lambda[], GLfloat rgba[][4])  {     const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];     const GLfloat width = (GLfloat) img->Width; @@ -1351,9 +1351,9 @@ opt_sample_rgb_2d(GLcontext *ctx,        GLint j = IFLOOR(texcoords[k][1] * height) & rowMask;        GLint pos = (j << shift) | i;        GLchan *texel = ((GLchan *) img->Data) + 3*pos; -      rgba[k][RCOMP] = texel[0]; -      rgba[k][GCOMP] = texel[1]; -      rgba[k][BCOMP] = texel[2]; +      rgba[k][RCOMP] = CHAN_TO_FLOAT(texel[0]); +      rgba[k][GCOMP] = CHAN_TO_FLOAT(texel[1]); +      rgba[k][BCOMP] = CHAN_TO_FLOAT(texel[2]);     }  } @@ -1370,7 +1370,7 @@ static void  opt_sample_rgba_2d(GLcontext *ctx,                     const struct gl_texture_object *tObj,                     GLuint n, const GLfloat texcoords[][4], -                   const GLfloat lambda[], GLchan rgba[][4]) +                   const GLfloat lambda[], GLfloat rgba[][4])  {     const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];     const GLfloat width = (GLfloat) img->Width; @@ -1392,7 +1392,10 @@ opt_sample_rgba_2d(GLcontext *ctx,        const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask;        const GLint pos = (row << shift) | col;        const GLchan *texel = ((GLchan *) img->Data) + (pos << 2);    /* pos*4 */ -      COPY_4V(rgba[i], texel); +      rgba[i][RCOMP] = CHAN_TO_FLOAT(texel[0]); +      rgba[i][GCOMP] = CHAN_TO_FLOAT(texel[1]); +      rgba[i][BCOMP] = CHAN_TO_FLOAT(texel[2]); +      rgba[i][ACOMP] = CHAN_TO_FLOAT(texel[3]);     }  } @@ -1425,7 +1428,6 @@ sample_lambda_2d(GLcontext *ctx,        case GL_NEAREST:           if (repeatNoBorderPOT) {              switch (tImg->TexFormat->MesaFormat) { -#if 0              case MESA_FORMAT_RGB:                 opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart,                                   NULL, rgba + minStart); @@ -1434,7 +1436,6 @@ sample_lambda_2d(GLcontext *ctx,  	       opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart,                                    NULL, rgba + minStart);                 break; -#endif              default:                 sample_nearest_2d(ctx, tObj, m, texcoords + minStart,                                   NULL, rgba + minStart ); @@ -1484,7 +1485,6 @@ sample_lambda_2d(GLcontext *ctx,        case GL_NEAREST:           if (repeatNoBorderPOT) {              switch (tImg->TexFormat->MesaFormat) { -#if 0              case MESA_FORMAT_RGB:                 opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart,                                   NULL, rgba + magStart); @@ -1493,7 +1493,6 @@ sample_lambda_2d(GLcontext *ctx,  	       opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart,                                    NULL, rgba + magStart);                 break; -#endif              default:                 sample_nearest_2d(ctx, tObj, m, texcoords + magStart,                                   NULL, rgba + magStart ); @@ -3180,7 +3179,6 @@ _swrast_choose_texture_sample_func( GLcontext *ctx,           }           else {              /* check for a few optimized cases */ -#if 0              const struct gl_texture_image *img = t->Image[0][t->BaseLevel];              ASSERT(t->MinFilter == GL_NEAREST);              if (t->WrapS == GL_REPEAT && @@ -3197,10 +3195,6 @@ _swrast_choose_texture_sample_func( GLcontext *ctx,                       img->TexFormat->MesaFormat == MESA_FORMAT_RGBA) {                 return &opt_sample_rgba_2d;              } -#else -            if (0) -               ; -#endif              else {                 return &sample_nearest_2d;              }  | 
