const struct vertex_info *vinfo;
};
-void draw_pt_emit_prepare( struct pt_emit *emit,
- unsigned prim,
- unsigned *max_vertices )
+
+void
+draw_pt_emit_prepare(struct pt_emit *emit,
+ unsigned prim,
+ unsigned *max_vertices)
{
struct draw_context *draw = emit->draw;
const struct vertex_info *vinfo;
unsigned dst_offset;
struct translate_key hw_key;
unsigned i;
-
- /* XXX: need to flush to get prim_vbuf.c to release its allocation??
+
+ /* XXX: need to flush to get prim_vbuf.c to release its allocation??
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
-
/* XXX: may need to defensively reset this later on as clipping can
* clobber this state in the render backend.
*/
*/
emit->vinfo = vinfo = draw->render->get_vertex_info(draw->render);
-
/* Translate from pipeline vertices to hw vertices.
*/
dst_offset = 0;
hw_key.output_stride = vinfo->size * 4;
if (!emit->translate ||
- translate_key_compare(&emit->translate->key, &hw_key) != 0)
- {
- translate_key_sanitize(&hw_key);
- emit->translate = translate_cache_find(emit->cache, &hw_key);
- }
+ translate_key_compare(&emit->translate->key, &hw_key) != 0) {
+ translate_key_sanitize(&hw_key);
+ emit->translate = translate_cache_find(emit->cache, &hw_key);
+ }
- *max_vertices = (draw->render->max_vertex_buffer_bytes /
+ *max_vertices = (draw->render->max_vertex_buffer_bytes /
(vinfo->size * 4));
}
-void draw_pt_emit( struct pt_emit *emit,
- const struct draw_vertex_info *vert_info,
- const struct draw_prim_info *prim_info)
+void
+draw_pt_emit(struct pt_emit *emit,
+ const struct draw_vertex_info *vert_info,
+ const struct draw_prim_info *prim_info)
{
const float (*vertex_data)[4] = (const float (*)[4])vert_info->verts->data;
unsigned vertex_count = vert_info->count;
unsigned start, i;
void *hw_verts;
- /* XXX: need to flush to get prim_vbuf.c to release its allocation??
+ /* XXX: need to flush to get prim_vbuf.c to release its allocation??
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
return;
}
- translate->set_buffer(translate,
- 0,
+ translate->set_buffer(translate,
+ 0,
vertex_data,
stride,
~0);
- translate->set_buffer(translate,
- 1,
+ translate->set_buffer(translate,
+ 1,
&draw->rasterizer->point_size,
0,
~0);
/* fetch/translate vertex attribs to fill hw_verts[] */
- translate->run( translate,
- 0,
- vertex_count,
- draw->instance_id,
- hw_verts );
+ translate->run(translate,
+ 0,
+ vertex_count,
+ draw->instance_id,
+ hw_verts );
- render->unmap_vertices( render,
- 0,
- vertex_count - 1 );
+ render->unmap_vertices(render, 0, vertex_count - 1);
for (start = i = 0;
i < prim_info->primitive_count;
}
-void draw_pt_emit_linear(struct pt_emit *emit,
- const struct draw_vertex_info *vert_info,
- const struct draw_prim_info *prim_info)
+void
+draw_pt_emit_linear(struct pt_emit *emit,
+ const struct draw_vertex_info *vert_info,
+ const struct draw_prim_info *prim_info)
{
const float (*vertex_data)[4] = (const float (*)[4])vert_info->verts->data;
unsigned stride = vert_info->stride;
#if 0
debug_printf("Linear emit\n");
#endif
- /* XXX: need to flush to get prim_vbuf.c to release its allocation??
+ /* XXX: need to flush to get prim_vbuf.c to release its allocation??
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
unsigned i;
for (i = 0; i < count; i++) {
debug_printf("\n\n%s vertex %d:\n", __FUNCTION__, i);
- draw_dump_emitted_vertex( emit->vinfo,
- (const uint8_t *)hw_verts +
+ draw_dump_emitted_vertex( emit->vinfo,
+ (const uint8_t *)hw_verts +
translate->key.output_stride * i );
}
}
return;
}
-struct pt_emit *draw_pt_emit_create( struct draw_context *draw )
+
+struct pt_emit *
+draw_pt_emit_create(struct draw_context *draw)
{
struct pt_emit *emit = CALLOC_STRUCT(pt_emit);
if (!emit)
return emit;
}
-void draw_pt_emit_destroy( struct pt_emit *emit )
+
+void
+draw_pt_emit_destroy(struct pt_emit *emit)
{
if (emit->cache)
translate_cache_destroy(emit->cache);
};
-/* Perform the fetch from API vertex elements & vertex buffers, to a
+/**
+ * Perform the fetch from API vertex elements & vertex buffers, to a
* contiguous set of float[4] attributes as required for the
* vertex_shader->run_linear() method.
*
* directly to hw vertices.
*
*/
-void draw_pt_fetch_prepare( struct pt_fetch *fetch,
- unsigned vs_input_count,
- unsigned vertex_size,
- unsigned instance_id_index )
+void
+draw_pt_fetch_prepare(struct pt_fetch *fetch,
+ unsigned vs_input_count,
+ unsigned vertex_size,
+ unsigned instance_id_index)
{
struct draw_context *draw = fetch->draw;
unsigned nr_inputs;
translate_key_sanitize(&key);
fetch->translate = translate_cache_find(fetch->cache, &key);
}
-
}
-
-
-void draw_pt_fetch_run( struct pt_fetch *fetch,
- const unsigned *elts,
- unsigned count,
- char *verts )
+void
+draw_pt_fetch_run(struct pt_fetch *fetch,
+ const unsigned *elts,
+ unsigned count,
+ char *verts)
{
struct draw_context *draw = fetch->draw;
struct translate *translate = fetch->translate;
unsigned i;
for (i = 0; i < draw->pt.nr_vertex_buffers; i++) {
- translate->set_buffer(translate,
- i,
- ((char *)draw->pt.user.vbuffer[i] +
+ translate->set_buffer(translate,
+ i,
+ ((char *)draw->pt.user.vbuffer[i] +
draw->pt.vertex_buffer[i].buffer_offset),
draw->pt.vertex_buffer[i].stride,
draw->pt.max_index);
}
translate->run_elts( translate,
- elts,
+ elts,
count,
draw->instance_id,
verts );
-
}
-void draw_pt_fetch_run_linear( struct pt_fetch *fetch,
- unsigned start,
- unsigned count,
- char *verts )
+void
+draw_pt_fetch_run_linear(struct pt_fetch *fetch,
+ unsigned start,
+ unsigned count,
+ char *verts)
{
struct draw_context *draw = fetch->draw;
struct translate *translate = fetch->translate;
}
-struct pt_fetch *draw_pt_fetch_create( struct draw_context *draw )
+struct pt_fetch *
+draw_pt_fetch_create(struct draw_context *draw)
{
struct pt_fetch *fetch = CALLOC_STRUCT(pt_fetch);
if (!fetch)
return fetch;
}
-void draw_pt_fetch_destroy( struct pt_fetch *fetch )
+
+void
+draw_pt_fetch_destroy(struct pt_fetch *fetch)
{
if (fetch->cache)
translate_cache_destroy(fetch->cache);
FREE(fetch);
}
-
/**************************************************************************
- *
+ *
* Copyright 2007 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
* 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.
* 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 "translate/translate.h"
#include "translate/translate_cache.h"
-/* The simplest 'middle end' in the new vertex code.
- *
+/* The simplest 'middle end' in the new vertex code.
+ *
* The responsibilities of a middle end are to:
* - perform vertex fetch using
* - draw vertex element/buffer state
* - a list of fetch indices we received as an input
* - run the vertex shader
- * - cliptest,
- * - clip coord calculation
+ * - cliptest,
+ * - clip coord calculation
* - viewport transformation
* - if necessary, run the primitive pipeline, passing it:
* - a linear array of vertex_header vertices constructed here
struct fetch_emit_middle_end {
struct draw_pt_middle_end base;
struct draw_context *draw;
-
+
struct translate *translate;
const struct vertex_info *vinfo;
};
-
-
static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
unsigned prim,
unsigned opt,
const struct vertex_info *vinfo;
unsigned i, dst_offset;
struct translate_key key;
-
- unsigned gs_out_prim = (draw->gs.geometry_shader ?
+ unsigned gs_out_prim = (draw->gs.geometry_shader ?
draw->gs.geometry_shader->output_primitive :
prim);
-
-
draw->render->set_primitive(draw->render, gs_out_prim);
-
+
/* Must do this after set_primitive() above:
*/
vinfo = feme->vinfo = draw->render->get_vertex_info(draw->render);
-
-
/* Transform from API vertices to HW vertices, skipping the
* pipeline_vertex intermediate step.
key.element[i].instance_divisor = src->instance_divisor;
key.element[i].output_format = output_format;
key.element[i].output_offset = dst_offset;
-
+
dst_offset += emit_sz;
}
/* Don't bother with caching at this stage:
*/
if (!feme->translate ||
- translate_key_compare(&feme->translate->key, &key) != 0)
+ translate_key_compare(&feme->translate->key, &key) != 0)
{
translate_key_sanitize(&key);
feme->translate = translate_cache_find(feme->cache,
&key);
-
- feme->translate->set_buffer(feme->translate,
- draw->pt.nr_vertex_buffers,
+ feme->translate->set_buffer(feme->translate,
+ draw->pt.nr_vertex_buffers,
&feme->point_size,
0,
~0);
}
-
+
feme->point_size = draw->rasterizer->point_size;
for (i = 0; i < draw->pt.nr_vertex_buffers; i++) {
- feme->translate->set_buffer(feme->translate,
- i,
- ((char *)draw->pt.user.vbuffer[i] +
+ feme->translate->set_buffer(feme->translate,
+ i,
+ ((char *)draw->pt.user.vbuffer[i] +
draw->pt.vertex_buffer[i].buffer_offset),
draw->pt.vertex_buffer[i].stride,
draw->pt.max_index);
}
- *max_vertices = (draw->render->max_vertex_buffer_bytes /
+ *max_vertices = (draw->render->max_vertex_buffer_bytes /
(vinfo->size * 4));
}
-
-
-
static void fetch_emit_run( struct draw_pt_middle_end *middle,
const unsigned *fetch_elts,
unsigned fetch_count,
struct fetch_emit_middle_end *feme = (struct fetch_emit_middle_end *)middle;
struct draw_context *draw = feme->draw;
void *hw_verts;
-
- /* XXX: need to flush to get prim_vbuf.c to release its allocation??
+
+ /* XXX: need to flush to get prim_vbuf.c to release its allocation??
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
assert(0);
return;
}
-
-
+
/* Single routine to fetch vertices and emit HW verts.
*/
- feme->translate->run_elts( feme->translate,
+ feme->translate->run_elts( feme->translate,
fetch_elts,
fetch_count,
draw->instance_id,
unsigned i;
for (i = 0; i < fetch_count; i++) {
debug_printf("\n\nvertex %d:\n", i);
- draw_dump_emitted_vertex( feme->vinfo,
+ draw_dump_emitted_vertex( feme->vinfo,
(const uint8_t *)hw_verts + feme->vinfo->size * 4 * i );
}
}
- draw->render->unmap_vertices( draw->render,
- 0,
+ draw->render->unmap_vertices( draw->render,
+ 0,
(ushort)(fetch_count - 1) );
/* XXX: Draw arrays path to avoid re-emitting index list again and
* again.
*/
- draw->render->draw_elements( draw->render,
- draw_elts,
+ draw->render->draw_elements( draw->render,
+ draw_elts,
draw_count );
- /* Done -- that was easy, wasn't it:
+ /* Done -- that was easy, wasn't it:
*/
draw->render->release_vertices( draw->render );
if (!draw->render->allocate_vertices( draw->render,
(ushort)feme->translate->key.output_stride,
- (ushort)count ))
+ (ushort)count ))
goto fail;
hw_verts = draw->render->map_vertices( draw->render );
- if (!hw_verts)
+ if (!hw_verts)
goto fail;
/* Single routine to fetch vertices and emit HW verts.
return FALSE;
hw_verts = draw->render->map_vertices( draw->render );
- if (!hw_verts)
+ if (!hw_verts)
return FALSE;
/* Single routine to fetch vertices and emit HW verts.
/* XXX: Draw arrays path to avoid re-emitting index list again and
* again.
*/
- draw->render->draw_elements( draw->render,
- draw_elts,
+ draw->render->draw_elements( draw->render,
+ draw_elts,
draw_count );
/* Done -- that was easy, wasn't it:
}
-
-
static void fetch_emit_finish( struct draw_pt_middle_end *middle )
{
/* nothing to do */
}
+
static void fetch_emit_destroy( struct draw_pt_middle_end *middle )
{
struct fetch_emit_middle_end *feme = (struct fetch_emit_middle_end *)middle;
fetch_emit->base.destroy = fetch_emit_destroy;
fetch_emit->draw = draw;
-
+
return &fetch_emit->base;
}
/**************************************************************************
- *
+ *
* Copyright 2007 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
* 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.
* 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.
- *
+ *
**************************************************************************/
/*
struct draw_pt_middle_end base;
struct draw_context *draw;
-
/* Temporaries:
*/
const float *constants;
struct draw_vs_variant_key key;
struct draw_vs_variant *active;
-
const struct vertex_info *vinfo;
};
-static void fse_prepare( struct draw_pt_middle_end *middle,
- unsigned prim,
- unsigned opt,
- unsigned *max_vertices )
+static void
+fse_prepare(struct draw_pt_middle_end *middle,
+ unsigned prim,
+ unsigned opt,
+ unsigned *max_vertices)
{
struct fetch_shade_emit *fse = (struct fetch_shade_emit *)middle;
struct draw_context *draw = fse->draw;
*/
fse->vinfo = vinfo = draw->render->get_vertex_info(draw->render);
-
fse->key.output_stride = vinfo->size * 4;
fse->key.nr_outputs = vinfo->num_attribs;
fse->key.nr_inputs = num_vs_inputs;
fse->key.clip = draw->clip_xy || draw->clip_z || draw->clip_user;
fse->key.const_vbuffers = 0;
- memset(fse->key.element, 0,
+ memset(fse->key.element, 0,
fse->key.nr_elements * sizeof(fse->key.element[0]));
for (i = 0; i < num_vs_inputs; i++) {
fse->key.element[i].in.offset = src->src_offset;
nr_vbs = MAX2(nr_vbs, src->vertex_buffer_index + 1);
}
-
+
for (i = 0; i < 5 && i < nr_vbs; i++) {
if (draw->pt.vertex_buffer[i].stride == 0)
fse->key.const_vbuffers |= (1<<i);
}
if (0) debug_printf("%s: lookup const_vbuffers: %x\n", __FUNCTION__, fse->key.const_vbuffers);
-
+
{
unsigned dst_offset = 0;
fse->key.element[i].out.format = vinfo->attrib[i].emit;
fse->key.element[i].out.vs_output = vinfo->attrib[i].src_index;
fse->key.element[i].out.offset = dst_offset;
-
+
dst_offset += emit_sz;
assert(fse->key.output_stride >= dst_offset);
}
}
-
- fse->active = draw_vs_lookup_variant( draw->vs.vertex_shader,
+ fse->active = draw_vs_lookup_variant( draw->vs.vertex_shader,
&fse->key );
if (!fse->active) {
return ;
}
- if (0) debug_printf("%s: found const_vbuffers: %x\n", __FUNCTION__,
+ if (0) debug_printf("%s: found const_vbuffers: %x\n", __FUNCTION__,
fse->active->key.const_vbuffers);
/* Now set buffer pointers:
*/
for (i = 0; i < draw->pt.nr_vertex_buffers; i++) {
- fse->active->set_buffer( fse->active,
- i,
- ((const ubyte *) draw->pt.user.vbuffer[i] +
+ fse->active->set_buffer( fse->active,
+ i,
+ ((const ubyte *) draw->pt.user.vbuffer[i] +
draw->pt.vertex_buffer[i].buffer_offset),
draw->pt.vertex_buffer[i].stride,
draw->pt.max_index );
}
- *max_vertices = (draw->render->max_vertex_buffer_bytes /
+ *max_vertices = (draw->render->max_vertex_buffer_bytes /
(vinfo->size * 4));
/* Probably need to do this somewhere (or fix exec shader not to
-static void fse_run_linear( struct draw_pt_middle_end *middle,
- unsigned start,
- unsigned count,
- unsigned prim_flags )
+static void
+fse_run_linear(struct draw_pt_middle_end *middle,
+ unsigned start,
+ unsigned count,
+ unsigned prim_flags)
{
struct fetch_shade_emit *fse = (struct fetch_shade_emit *)middle;
struct draw_context *draw = fse->draw;
* Clipping is done elsewhere -- either by the API or on hardware,
* or for some other reason not required...
*/
- fse->active->run_linear( fse->active,
+ fse->active->run_linear( fse->active,
start, count,
hw_verts );
-
if (0) {
unsigned i;
for (i = 0; i < count; i++) {
fse->key.output_stride,
fse->key.output_stride * i);
- draw_dump_emitted_vertex( fse->vinfo,
+ draw_dump_emitted_vertex( fse->vinfo,
(const uint8_t *)hw_verts + fse->key.output_stride * i );
}
}
-
+
draw->render->unmap_vertices( draw->render, 0, (ushort)(count - 1) );
/* Draw arrays path to avoid re-emitting index list again and
draw->render->draw_arrays( draw->render,
0,
count );
-
draw->render->release_vertices( draw->render );
struct fetch_shade_emit *fse = (struct fetch_shade_emit *)middle;
struct draw_context *draw = fse->draw;
void *hw_verts;
-
- /* XXX: need to flush to get prim_vbuf.c to release its allocation??
+
+ /* XXX: need to flush to get prim_vbuf.c to release its allocation??
*/
draw_do_flush( draw, DRAW_FLUSH_BACKEND );
(ushort)fetch_count ))
goto fail;
- hw_verts = draw->render->map_vertices( draw->render );
- if (!hw_verts)
+ hw_verts = draw->render->map_vertices( draw->render );
+ if (!hw_verts)
goto fail;
-
-
+
/* Single routine to fetch vertices, run shader and emit HW verts.
*/
- fse->active->run_elts( fse->active,
+ fse->active->run_elts( fse->active,
fetch_elts,
fetch_count,
hw_verts );
-
if (0) {
unsigned i;
for (i = 0; i < fetch_count; i++) {
debug_printf("\n\n%s vertex %d:\n", __FUNCTION__, i);
- draw_dump_emitted_vertex( fse->vinfo,
- (const uint8_t *)hw_verts +
+ draw_dump_emitted_vertex( fse->vinfo,
+ (const uint8_t *)hw_verts +
fse->key.output_stride * i );
}
}
draw->render->unmap_vertices( draw->render, 0, (ushort)(fetch_count - 1) );
-
- draw->render->draw_elements( draw->render,
- draw_elts,
- draw_count );
+ draw->render->draw_elements( draw->render,
+ draw_elts,
+ draw_count );
draw->render->release_vertices( draw->render );
return;
-static boolean fse_run_linear_elts( struct draw_pt_middle_end *middle,
- unsigned start,
- unsigned count,
- const ushort *draw_elts,
- unsigned draw_count,
- unsigned prim_flags )
+static boolean
+fse_run_linear_elts(struct draw_pt_middle_end *middle,
+ unsigned start,
+ unsigned count,
+ const ushort *draw_elts,
+ unsigned draw_count,
+ unsigned prim_flags)
{
struct fetch_shade_emit *fse = (struct fetch_shade_emit *)middle;
struct draw_context *draw = fse->draw;
return FALSE;
hw_verts = draw->render->map_vertices( draw->render );
- if (!hw_verts)
+ if (!hw_verts)
return FALSE;
/* Single routine to fetch vertices, run shader and emit HW verts.
* Clipping is done elsewhere -- either by the API or on hardware,
* or for some other reason not required...
*/
- fse->active->run_linear( fse->active,
+ fse->active->run_linear( fse->active,
start, count,
hw_verts );
-
- draw->render->draw_elements( draw->render,
- draw_elts,
+ draw->render->draw_elements( draw->render,
+ draw_elts,
draw_count );
-
draw->render->unmap_vertices( draw->render, 0, (ushort)(count - 1) );
-static void fse_finish( struct draw_pt_middle_end *middle )
+static void
+fse_finish(struct draw_pt_middle_end *middle)
{
}
static void
-fse_destroy( struct draw_pt_middle_end *middle )
+fse_destroy(struct draw_pt_middle_end *middle)
{
FREE(middle);
}
-struct draw_pt_middle_end *draw_pt_middle_fse( struct draw_context *draw )
+
+struct draw_pt_middle_end *
+draw_pt_middle_fse(struct draw_context *draw)
{
struct fetch_shade_emit *fse = CALLOC_STRUCT(fetch_shade_emit);
if (!fse)