Lines Matching refs:r300
71 static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300,
74 struct r300_rs_state* rs = (struct r300_rs_state*)r300->rs_state.state;
116 void r500_emit_index_bias(struct r300_context *r300, int index_bias)
118 CS_LOCALS(r300);
126 static void r300_emit_draw_init(struct r300_context *r300, unsigned mode,
129 CS_LOCALS(r300);
135 r300_provoking_vertex_fixes(r300, mode));
148 static void r300_split_index_bias(struct r300_context *r300, int index_bias,
151 struct pipe_vertex_buffer *vb, *vbufs = r300->vertex_buffer;
152 struct pipe_vertex_element *velem = r300->velems->velem;
161 for (i = 0; i < r300->velems->count; i++) {
188 * \param r300 The context.
193 static boolean r300_reserve_cs_dwords(struct r300_context *r300,
204 cs_dwords += r300_get_num_dirty_dwords(r300);
206 if (r300->screen->caps.is_r500)
215 cs_dwords += r300_get_num_cs_end_dwords(r300);
218 if (cs_dwords > (RADEON_MAX_CMDBUF_DWORDS - r300->cs->cdw)) {
219 r300_flush(&r300->context, RADEON_FLUSH_ASYNC, NULL);
228 * \param r300 The context.
236 static boolean r300_emit_states(struct r300_context *r300,
250 if (!r300_emit_buffer_validate(r300, validate_vbos,
252 fprintf(stderr, "r300: CS space validation failed. "
259 r300_emit_dirty_state(r300);
261 if (r300->screen->caps.is_r500) {
262 if (r300->screen->caps.has_tcl)
263 r500_emit_index_bias(r300, index_bias);
265 r500_emit_index_bias(r300, 0);
269 (r300->vertex_arrays_dirty ||
270 r300->vertex_arrays_indexed != indexed ||
271 r300->vertex_arrays_offset != buffer_offset ||
272 r300->vertex_arrays_instance_id != instance_id)) {
273 r300_emit_vertex_arrays(r300, buffer_offset, indexed, instance_id);
275 r300->vertex_arrays_dirty = FALSE;
276 r300->vertex_arrays_indexed = indexed;
277 r300->vertex_arrays_offset = buffer_offset;
278 r300->vertex_arrays_instance_id = instance_id;
282 r300_emit_vertex_arrays_swtcl(r300, indexed);
290 * \param r300 The context.
299 static boolean r300_prepare_for_rendering(struct r300_context *r300,
308 if (r300_reserve_cs_dwords(r300, flags, cs_dwords))
311 return r300_emit_states(r300, flags, index_buffer, buffer_offset,
315 static boolean immd_is_good_idea(struct r300_context *r300,
318 if (DBG_ON(r300, DBG_NO_IMMD)) {
322 if (count * r300->velems->vertex_size_dwords > IMMD_DWORDS) {
326 /* Buffers can only be used for read by r300 (except query buffers, but
335 static void r300_draw_arrays_immediate(struct r300_context *r300,
340 unsigned vertex_element_count = r300->velems->count;
344 unsigned vertex_size = r300->velems->vertex_size_dwords;
360 CS_LOCALS(r300);
362 if (!r300_prepare_for_rendering(r300, PREP_EMIT_STATES, NULL, dwords, 0, 0, -1))
367 velem = &r300->velems->velem[i];
368 size[i] = r300->velems->format_size[i] / 4;
370 vbuf = &r300->vertex_buffer[vbi];
375 map[vbi] = (uint32_t*)r300->rws->buffer_map(
377 r300->cs, PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED);
383 r300_emit_draw_init(r300, info->mode, info->count-1);
401 vbi = r300->velems->velem[i].vertex_buffer_index;
404 r300->rws->buffer_unmap(r300_resource(r300->vertex_buffer[vbi].buffer)->cs_buf);
410 static void r300_emit_draw_arrays(struct r300_context *r300,
415 CS_LOCALS(r300);
418 fprintf(stderr, "r300: Got a huge number of vertices: %i, "
423 r300_emit_draw_init(r300, mode, count-1);
436 static void r300_emit_draw_elements(struct r300_context *r300,
447 CS_LOCALS(r300);
450 fprintf(stderr, "r300: Got a huge number of vertices: %i, "
455 DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, max %u\n",
458 r300_emit_draw_init(r300, mode, max_index);
508 static void r300_draw_elements_immediate(struct r300_context *r300,
514 unsigned index_size = r300->index_buffer.index_size;
517 CS_LOCALS(r300);
520 if (!r300_prepare_for_rendering(r300,
525 r300_emit_draw_init(r300, info->mode, info->max_index);
532 ptr1 = (uint8_t*)r300->index_buffer.user_buffer;
538 if (info->index_bias && !r300->screen->caps.is_r500) {
556 ptr2 = (uint16_t*)r300->index_buffer.user_buffer;
562 if (info->index_bias && !r300->screen->caps.is_r500) {
575 ptr4 = (uint32_t*)r300->index_buffer.user_buffer;
582 if (info->index_bias && !r300->screen->caps.is_r500) {
593 static void r300_draw_elements(struct r300_context *r300,
597 struct pipe_resource *indexBuffer = r300->index_buffer.buffer;
598 unsigned indexSize = r300->index_buffer.index_size;
602 boolean alt_num_verts = r300->screen->caps.is_r500 &&
608 if (info->index_bias && !r300->screen->caps.is_r500) {
609 r300_split_index_bias(r300, info->index_bias, &buffer_offset,
613 r300_translate_index_buffer(r300, &r300->index_buffer, &indexBuffer,
619 uint16_t *ptr = r300->rws->buffer_map(r300_resource(orgIndexBuffer)->cs_buf,
620 r300->cs,
630 r300_upload_index_buffer(r300, &indexBuffer, indexSize, &start,
633 r300->rws->buffer_unmap(r300_resource(orgIndexBuffer)->cs_buf);
635 if (r300->index_buffer.user_buffer)
636 r300_upload_index_buffer(r300, &indexBuffer, indexSize,
638 r300->index_buffer.user_buffer);
642 if (!r300_prepare_for_rendering(r300,
649 r300_emit_draw_elements(r300, indexBuffer, indexSize,
660 r300_emit_draw_elements(r300, indexBuffer, indexSize,
669 if (!r300_prepare_for_rendering(r300,
684 static void r300_draw_arrays(struct r300_context *r300,
688 boolean alt_num_verts = r300->screen->caps.is_r500 &&
695 if (!r300_prepare_for_rendering(r300,
701 r300_emit_draw_arrays(r300, info->mode, count);
709 r300_emit_draw_arrays(r300, info->mode, short_count);
716 if (!r300_prepare_for_rendering(r300,
725 static void r300_draw_arrays_instanced(struct r300_context *r300,
731 r300_draw_arrays(r300, info, i);
734 static void r300_draw_elements_instanced(struct r300_context *r300,
740 r300_draw_elements(r300, info, i);
743 static unsigned r300_max_vertex_count(struct r300_context *r300)
745 unsigned i, nr = r300->velems->count;
746 struct pipe_vertex_element *velems = r300->velems->velem;
751 &r300->vertex_buffer[velems[i].vertex_buffer_index];
778 value = r300->velems->format_size[i];
795 struct r300_context* r300 = r300_context(pipe);
800 if (r300->skip_rendering ||
805 r300_update_derived_state(r300);
809 unsigned max_count = r300_max_vertex_count(r300);
812 fprintf(stderr, "r300: Skipping a draw command. There is a buffer "
823 info.start += r300->index_buffer.offset / r300->index_buffer.index_size;
827 r300->index_buffer.user_buffer) {
828 r300_draw_elements_immediate(r300, &info);
830 r300_draw_elements(r300, &info, -1);
833 r300_draw_elements_instanced(r300, &info);
837 if (immd_is_good_idea(r300, info.count)) {
838 r300_draw_arrays_immediate(r300, &info);
840 r300_draw_arrays(r300, &info, -1);
843 r300_draw_arrays_instanced(r300, &info);
857 struct r300_context* r300 = r300_context(pipe);
860 if (r300->skip_rendering) {
864 r300_update_derived_state(r300);
866 r300_reserve_cs_dwords(r300,
871 r300->draw_vbo_locked = TRUE;
872 r300->draw_first_emitted = FALSE;
873 draw_vbo(r300->draw, info);
874 draw_flush(r300->draw);
875 r300->draw_vbo_locked = FALSE;
884 struct r300_context* r300;
908 struct r300_context* r300 = r300render->r300;
910 return &r300->vertex_info;
918 struct r300_context* r300 = r300render->r300;
919 struct pipe_screen* screen = r300->context.screen;
922 DBG(r300, DBG_DRAW, "r300: render_allocate_vertices (size: %d)\n", size);
924 if (size + r300->draw_vbo_offset > r300->draw_vbo_size)
926 pipe_resource_reference(&r300->vbo, NULL);
927 r300->vbo = pipe_buffer_create(screen,
931 r300->draw_vbo_offset = 0;
932 r300->draw_vbo_size = R300_MAX_DRAW_VBO_SIZE;
937 return (r300->vbo) ? TRUE : FALSE;
943 struct r300_context* r300r300;
947 DBG(r300, DBG_DRAW, "r300: render_map_vertices\n");
949 r300render->vbo_ptr = pipe_buffer_map(&r300render->r300->context,
950 r300->vbo,
957 return ((uint8_t*)r300render->vbo_ptr + r300->draw_vbo_offset);
965 struct pipe_context* context = &r300render->r300->context;
966 struct r300_context* r300 = r300render->r300;
970 DBG(r300, DBG_DRAW, "r300: render_unmap_vertices\n");
982 struct r300_context* r300 = r300render->r300;
984 DBG(r300, DBG_DRAW, "r300: render_release_vertices\n");
986 r300->draw_vbo_offset += r300render->vbo_max_used;
1004 struct r300_context* r300 = r300render->r300;
1009 CS_LOCALS(r300);
1012 DBG(r300, DBG_DRAW, "r300: render_draw_arrays (count: %d)\n", count);
1014 if (r300->draw_first_emitted) {
1015 if (!r300_prepare_for_rendering(r300,
1020 if (!r300_emit_states(r300,
1028 r300_provoking_vertex_fixes(r300, r300render->prim));
1035 r300->draw_first_emitted = TRUE;
1043 struct r300_context* r300 = r300render->r300;
1046 unsigned max_index = (r300->draw_vbo_size - r300->draw_vbo_offset) /
1047 (r300render->r300->vertex_info.size * 4) - 1;
1051 CS_LOCALS(r300);
1052 DBG(r300, DBG_DRAW, "r300: render_draw_elements (count: %d)\n", count);
1054 if (r300->draw_first_emitted) {
1055 if (!r300_prepare_for_rendering(r300,
1060 if (!r300_emit_states(r300,
1069 end_cs_dwords = r300_get_num_cs_end_dwords(r300);
1072 free_dwords = RADEON_MAX_CMDBUF_DWORDS - r300->cs->cdw;
1078 r300_provoking_vertex_fixes(r300, r300render->prim));
1097 if (!r300_prepare_for_rendering(r300,
1102 end_cs_dwords = r300_get_num_cs_end_dwords(r300);
1106 r300->draw_first_emitted = TRUE;
1114 static struct vbuf_render* r300_render_create(struct r300_context* r300)
1118 r300render->r300 = r300;
1136 struct draw_stage* r300_draw_stage(struct r300_context* r300)
1141 render = r300_render_create(r300);
1147 stage = draw_vbuf_stage(r300->draw, render);
1154 draw_set_render(r300->draw, render);
1159 void r300_draw_flush_vbuf(struct r300_context *r300)
1161 pipe_resource_reference(&r300->vbo, NULL);
1162 r300->draw_vbo_size = 0;
1181 struct r300_context *r300 = r300_context(util_blitter_get_pipe(blitter));
1182 unsigned last_sprite_coord_enable = r300->sprite_coord_enable;
1186 type == UTIL_BLITTER_ATTRIB_COLOR || !r300->draw ? 8 : 4;
1190 CS_LOCALS(r300);
1192 if (r300->skip_rendering)
1195 r300->context.set_vertex_buffers(&r300->context, 0, NULL);
1198 r300->sprite_coord_enable = 1;
1200 r300_update_derived_state(r300);
1203 r300->viewport_state.dirty = FALSE;
1205 if (!r300_prepare_for_rendering(r300, PREP_EMIT_STATES, NULL, dwords, 0, 0, -1))
1208 DBG(r300, DBG_DRAW, "r300: draw_rectangle\n");
1252 r300_mark_atom_dirty(r300, &r300->rs_state);
1253 r300_mark_atom_dirty(r300, &r300->viewport_state);
1255 r300->sprite_coord_enable = last_sprite_coord_enable;
1261 struct r300_context *r300 = r300_context(pipe);
1263 struct r300_aa_state *aa = (struct r300_aa_state*)r300->aa_state.state;
1281 DBG(r300, DBG_DRAW, "r300: Resolving resource...\n");
1288 r300->aa_state.size = 10;
1289 r300_mark_atom_dirty(r300, &r300->aa_state);
1293 r300->context.clear_render_target(pipe,
1301 r300->aa_state.size = 4;
1302 r300_mark_atom_dirty(r300, &r300->aa_state);
1308 void r300_init_render_functions(struct r300_context *r300)
1311 if (r300->screen->caps.has_tcl) {
1312 r300->context.draw_vbo = r300_draw_vbo;
1314 r300->context.draw_vbo = r300_swtcl_draw_vbo;
1317 r300->context.resource_resolve = r300_resource_resolve;
1320 if (!r300->screen->caps.is_r500)
1321 r300_plug_in_stencil_ref_fallback(r300);