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