gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* Copyright 2007 VMware, Inc.
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
* 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.
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Authors:
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* Keith Whitwell <keithw@vmware.com>
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "draw/draw_context.h"
|
2010-06-09 16:13:34 +01:00
|
|
|
#include "draw/draw_gs.h"
|
2020-02-17 07:13:11 +00:00
|
|
|
#include "draw/draw_tess.h"
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
#include "draw/draw_private.h"
|
|
|
|
#include "draw/draw_pt.h"
|
2013-04-11 14:11:29 +01:00
|
|
|
#include "draw/draw_vbuf.h"
|
2010-07-16 18:10:25 +01:00
|
|
|
#include "draw/draw_vs.h"
|
2008-11-05 15:58:40 +00:00
|
|
|
#include "tgsi/tgsi_dump.h"
|
2008-11-12 16:03:58 +00:00
|
|
|
#include "util/u_math.h"
|
2009-06-19 16:45:23 +01:00
|
|
|
#include "util/u_prim.h"
|
2019-06-27 23:05:31 +01:00
|
|
|
#include "util/format/u_format.h"
|
2010-08-25 07:02:12 +01:00
|
|
|
#include "util/u_draw.h"
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
|
2010-04-22 18:20:31 +01:00
|
|
|
|
2010-04-28 22:27:08 +01:00
|
|
|
DEBUG_GET_ONCE_BOOL_OPTION(draw_fse, "DRAW_FSE", FALSE)
|
|
|
|
DEBUG_GET_ONCE_BOOL_OPTION(draw_no_fse, "DRAW_NO_FSE", FALSE)
|
2010-04-22 18:20:31 +01:00
|
|
|
|
2008-04-16 10:03:18 +01:00
|
|
|
/* Overall we split things into:
|
2010-08-07 13:44:02 +01:00
|
|
|
* - frontend -- prepare fetch_elts, draw_elts - eg vsplit
|
2008-04-16 10:03:18 +01:00
|
|
|
* - middle -- fetch, shade, cliptest, viewport
|
|
|
|
* - pipeline -- the prim pipeline: clipping, wide lines, etc
|
|
|
|
* - backend -- the vbuf_render provided by the driver.
|
|
|
|
*/
|
2008-04-19 13:20:26 +01:00
|
|
|
static boolean
|
2011-01-24 01:11:59 +00:00
|
|
|
draw_pt_arrays(struct draw_context *draw,
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
unsigned prim,
|
2021-05-18 16:10:02 +01:00
|
|
|
bool index_bias_varies,
|
2021-04-11 14:49:49 +01:00
|
|
|
const struct pipe_draw_start_count_bias *draw_info,
|
2021-03-25 19:23:33 +00:00
|
|
|
unsigned num_draws)
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
{
|
|
|
|
struct draw_pt_front_end *frontend = NULL;
|
|
|
|
struct draw_pt_middle_end *middle = NULL;
|
2021-06-16 06:25:12 +01:00
|
|
|
unsigned opt = PT_SHADE;
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
|
2021-06-16 06:25:12 +01:00
|
|
|
unsigned out_prim = prim;
|
2020-02-17 07:13:11 +00:00
|
|
|
|
2021-06-16 06:25:12 +01:00
|
|
|
if (draw->gs.geometry_shader)
|
|
|
|
out_prim = draw->gs.geometry_shader->output_primitive;
|
|
|
|
else if (draw->tes.tess_eval_shader)
|
|
|
|
out_prim = get_tes_output_prim(draw->tes.tess_eval_shader);
|
2010-06-23 18:06:52 +01:00
|
|
|
|
2021-06-16 06:25:12 +01:00
|
|
|
if (!draw->render) {
|
|
|
|
opt |= PT_PIPELINE;
|
|
|
|
}
|
2008-10-06 12:22:55 +01:00
|
|
|
|
2021-06-16 06:25:12 +01:00
|
|
|
if (draw_need_pipeline(draw,
|
|
|
|
draw->rasterizer,
|
|
|
|
out_prim)) {
|
|
|
|
opt |= PT_PIPELINE;
|
|
|
|
}
|
2010-06-09 16:13:34 +01:00
|
|
|
|
2021-06-16 06:25:12 +01:00
|
|
|
if ((draw->clip_xy ||
|
|
|
|
draw->clip_z ||
|
|
|
|
draw->clip_user) && !draw->pt.test_fse) {
|
|
|
|
opt |= PT_CLIPTEST;
|
2008-04-16 10:03:18 +01:00
|
|
|
}
|
2010-06-09 16:13:34 +01:00
|
|
|
|
2010-07-10 07:02:35 +01:00
|
|
|
if (draw->pt.middle.llvm) {
|
2010-04-26 15:31:37 +01:00
|
|
|
middle = draw->pt.middle.llvm;
|
|
|
|
} else {
|
2021-06-16 06:29:15 +01:00
|
|
|
if (opt == PT_SHADE && !draw->pt.no_fse)
|
2010-04-26 15:31:37 +01:00
|
|
|
middle = draw->pt.middle.fetch_shade_emit;
|
|
|
|
else
|
|
|
|
middle = draw->pt.middle.general;
|
|
|
|
}
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
|
2011-01-24 01:11:59 +00:00
|
|
|
frontend = draw->pt.frontend;
|
|
|
|
|
2015-12-04 06:12:30 +00:00
|
|
|
if (frontend) {
|
2011-01-24 01:11:59 +00:00
|
|
|
if (draw->pt.prim != prim || draw->pt.opt != opt) {
|
|
|
|
/* In certain conditions switching primitives requires us to flush
|
|
|
|
* and validate the different stages. One example is when smooth
|
|
|
|
* lines are active but first drawn with triangles and then with
|
|
|
|
* lines.
|
|
|
|
*/
|
|
|
|
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
|
|
|
|
frontend = NULL;
|
|
|
|
} else if (draw->pt.eltSize != draw->pt.user.eltSize) {
|
|
|
|
/* Flush draw state if eltSize changed.
|
|
|
|
* This could be improved so only the frontend is flushed since it
|
|
|
|
* converts all indices to ushorts and the fetch part of the middle
|
2012-12-07 19:41:22 +00:00
|
|
|
* always prepares both linear and indexed.
|
2011-01-24 01:11:59 +00:00
|
|
|
*/
|
|
|
|
frontend->flush( frontend, DRAW_FLUSH_STATE_CHANGE );
|
|
|
|
frontend = NULL;
|
|
|
|
}
|
|
|
|
}
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
|
2011-01-24 01:11:59 +00:00
|
|
|
if (!frontend) {
|
|
|
|
frontend = draw->pt.front.vsplit;
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
|
2011-01-24 01:11:59 +00:00
|
|
|
frontend->prepare( frontend, prim, middle, opt );
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
|
2011-01-24 01:11:59 +00:00
|
|
|
draw->pt.frontend = frontend;
|
|
|
|
draw->pt.eltSize = draw->pt.user.eltSize;
|
|
|
|
draw->pt.prim = prim;
|
|
|
|
draw->pt.opt = opt;
|
|
|
|
}
|
|
|
|
|
2012-12-07 20:58:34 +00:00
|
|
|
if (draw->pt.rebind_parameters) {
|
|
|
|
/* update constants, viewport dims, clip planes, etc */
|
|
|
|
middle->bind_parameters(middle);
|
|
|
|
draw->pt.rebind_parameters = FALSE;
|
|
|
|
}
|
|
|
|
|
2021-03-25 19:08:18 +00:00
|
|
|
|
2021-03-25 19:23:33 +00:00
|
|
|
for (unsigned i = 0; i < num_draws; i++) {
|
|
|
|
unsigned count = draw_info[i].count;
|
|
|
|
/* Sanitize primitive length:
|
|
|
|
*/
|
2021-03-25 19:08:18 +00:00
|
|
|
unsigned first, incr;
|
|
|
|
|
|
|
|
if (prim == PIPE_PRIM_PATCHES) {
|
|
|
|
first = draw->pt.vertices_per_patch;
|
|
|
|
incr = draw->pt.vertices_per_patch;
|
|
|
|
} else
|
|
|
|
draw_pt_split_prim(prim, &first, &incr);
|
2021-03-25 19:23:33 +00:00
|
|
|
count = draw_pt_trim_count(draw_info[i].count, first, incr);
|
2021-05-18 16:10:02 +01:00
|
|
|
draw->pt.user.eltBias = draw->pt.user.eltSize ?
|
|
|
|
(index_bias_varies ? draw_info[i].index_bias : draw_info[0].index_bias) :
|
|
|
|
0;
|
2021-03-25 19:23:33 +00:00
|
|
|
if (count >= first)
|
|
|
|
frontend->run( frontend, draw_info[i].start, count );
|
2021-03-25 19:08:18 +00:00
|
|
|
|
2021-03-25 19:23:33 +00:00
|
|
|
if (draw->pt.user.increment_draw_id)
|
|
|
|
draw->pt.user.drawid++;
|
|
|
|
}
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-01-24 01:11:59 +00:00
|
|
|
void draw_pt_flush( struct draw_context *draw, unsigned flags )
|
|
|
|
{
|
2012-12-07 20:58:34 +00:00
|
|
|
assert(flags);
|
|
|
|
|
2011-01-24 01:11:59 +00:00
|
|
|
if (draw->pt.frontend) {
|
|
|
|
draw->pt.frontend->flush( draw->pt.frontend, flags );
|
|
|
|
|
|
|
|
/* don't prepare if we only are flushing the backend */
|
2012-12-07 20:58:34 +00:00
|
|
|
if (flags & DRAW_FLUSH_STATE_CHANGE)
|
2011-01-24 01:11:59 +00:00
|
|
|
draw->pt.frontend = NULL;
|
|
|
|
}
|
2012-12-07 20:58:34 +00:00
|
|
|
|
|
|
|
if (flags & DRAW_FLUSH_PARAMETER_CHANGE) {
|
|
|
|
draw->pt.rebind_parameters = TRUE;
|
|
|
|
}
|
2011-01-24 01:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
|
|
|
|
boolean draw_pt_init( struct draw_context *draw )
|
|
|
|
{
|
2010-04-22 18:20:31 +01:00
|
|
|
draw->pt.test_fse = debug_get_option_draw_fse();
|
|
|
|
draw->pt.no_fse = debug_get_option_draw_no_fse();
|
2008-05-12 19:40:20 +01:00
|
|
|
|
2010-08-07 08:12:14 +01:00
|
|
|
draw->pt.front.vsplit = draw_pt_vsplit(draw);
|
|
|
|
if (!draw->pt.front.vsplit)
|
2008-04-24 21:22:47 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2008-05-28 23:54:18 +01:00
|
|
|
draw->pt.middle.fetch_shade_emit = draw_pt_middle_fse( draw );
|
|
|
|
if (!draw->pt.middle.fetch_shade_emit)
|
|
|
|
return FALSE;
|
2008-05-12 15:20:38 +01:00
|
|
|
|
2010-04-26 15:31:37 +01:00
|
|
|
draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit( draw );
|
2008-04-19 13:20:26 +01:00
|
|
|
if (!draw->pt.middle.general)
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2021-02-24 18:42:49 +00:00
|
|
|
#ifdef DRAW_LLVM_AVAILABLE
|
2010-08-15 06:37:31 +01:00
|
|
|
if (draw->llvm)
|
2010-04-26 15:31:37 +01:00
|
|
|
draw->pt.middle.llvm = draw_pt_fetch_pipeline_or_emit_llvm( draw );
|
|
|
|
#endif
|
|
|
|
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void draw_pt_destroy( struct draw_context *draw )
|
|
|
|
{
|
2010-04-26 15:31:37 +01:00
|
|
|
if (draw->pt.middle.llvm) {
|
|
|
|
draw->pt.middle.llvm->destroy( draw->pt.middle.llvm );
|
|
|
|
draw->pt.middle.llvm = NULL;
|
|
|
|
}
|
|
|
|
|
2008-04-19 13:20:26 +01:00
|
|
|
if (draw->pt.middle.general) {
|
|
|
|
draw->pt.middle.general->destroy( draw->pt.middle.general );
|
|
|
|
draw->pt.middle.general = NULL;
|
|
|
|
}
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
|
2008-05-12 19:40:20 +01:00
|
|
|
if (draw->pt.middle.fetch_shade_emit) {
|
|
|
|
draw->pt.middle.fetch_shade_emit->destroy( draw->pt.middle.fetch_shade_emit );
|
|
|
|
draw->pt.middle.fetch_shade_emit = NULL;
|
|
|
|
}
|
|
|
|
|
2010-08-07 08:12:14 +01:00
|
|
|
if (draw->pt.front.vsplit) {
|
|
|
|
draw->pt.front.vsplit->destroy( draw->pt.front.vsplit );
|
|
|
|
draw->pt.front.vsplit = NULL;
|
2008-04-24 21:22:47 +01:00
|
|
|
}
|
gallium: beginnings of draw module vertex rework
Trying to put a structure in place that we can actually optimize.
Initially just implementing a passthrough mode, this will fairly soon
replace all the vertex_cache/prim_queue/shader_queue stuff that's so
hard to understand...
Split the vertex processing into a couple of distinct stages:
- Frontend
- Prepares two lists of elements (fetch and draw) to be processed
by the next stage. This stage doesn't fetch or draw vertices, but
makes the decision which to draw. Multiple implementations of this
will implement different strategies, currently just a vcache
implementation.
- MiddleEnd
- Takes the list of fetch elements, fetches them, runs the vertex
shader, cliptest, viewport transform on them to produce a
linear array of vertex_header vertices.
- Passes that list of vertices, plus the draw_elements (which index
into that list) onto the backend
- Backend
- Either the existing primitive/clipping pipeline, or the vbuf_render
hardware backend provided by the driver.
Currently, the middle-end is the old passthrough code, and it build hardware
vertices, not vertex_header vertices as above. It may be that passthrough
is a special case in this respect.
2008-03-23 16:44:59 +00:00
|
|
|
}
|
2008-04-18 20:36:38 +01:00
|
|
|
|
|
|
|
|
2008-11-06 21:57:20 +00:00
|
|
|
/**
|
|
|
|
* Debug- print the first 'count' vertices.
|
|
|
|
*/
|
|
|
|
static void
|
2021-04-11 15:26:29 +01:00
|
|
|
draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count, int index_bias)
|
2008-11-06 21:57:20 +00:00
|
|
|
{
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
debug_printf("Draw arrays(prim = %u, start = %u, count = %u)\n",
|
|
|
|
prim, start, count);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
2009-11-21 00:03:48 +00:00
|
|
|
uint ii = 0;
|
|
|
|
uint j;
|
2008-11-06 21:57:20 +00:00
|
|
|
|
2010-08-25 07:02:12 +01:00
|
|
|
if (draw->pt.user.eltSize) {
|
2008-11-06 21:57:20 +00:00
|
|
|
/* indexed arrays */
|
2010-08-25 07:02:12 +01:00
|
|
|
|
2008-11-06 21:57:20 +00:00
|
|
|
switch (draw->pt.user.eltSize) {
|
|
|
|
case 1:
|
|
|
|
{
|
2012-05-25 16:44:53 +01:00
|
|
|
const ubyte *elem = (const ubyte *) draw->pt.user.elts;
|
2008-11-06 21:57:20 +00:00
|
|
|
ii = elem[start + i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
{
|
2012-05-25 16:44:53 +01:00
|
|
|
const ushort *elem = (const ushort *) draw->pt.user.elts;
|
2008-11-06 21:57:20 +00:00
|
|
|
ii = elem[start + i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
{
|
2012-05-25 16:44:53 +01:00
|
|
|
const uint *elem = (const uint *) draw->pt.user.elts;
|
2008-11-06 21:57:20 +00:00
|
|
|
ii = elem[start + i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
2010-04-19 17:14:04 +01:00
|
|
|
return;
|
2008-11-06 21:57:20 +00:00
|
|
|
}
|
2021-04-11 15:26:29 +01:00
|
|
|
ii += index_bias;
|
2010-04-19 17:14:04 +01:00
|
|
|
debug_printf("Element[%u + %u] + %i -> Vertex %u:\n", start, i,
|
2021-04-11 15:26:29 +01:00
|
|
|
index_bias, ii);
|
2008-11-06 21:57:20 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* non-indexed arrays */
|
|
|
|
ii = start + i;
|
|
|
|
debug_printf("Vertex %u:\n", ii);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < draw->pt.nr_vertex_elements; j++) {
|
|
|
|
uint buf = draw->pt.vertex_element[j].vertex_buffer_index;
|
2013-05-09 04:48:20 +01:00
|
|
|
ubyte *ptr = (ubyte *) draw->pt.user.vbuffer[buf].map;
|
2010-08-03 21:13:13 +01:00
|
|
|
|
|
|
|
if (draw->pt.vertex_element[j].instance_divisor) {
|
|
|
|
ii = draw->instance_id / draw->pt.vertex_element[j].instance_divisor;
|
|
|
|
}
|
|
|
|
|
2010-07-29 20:44:44 +01:00
|
|
|
ptr += draw->pt.vertex_buffer[buf].buffer_offset;
|
2009-01-26 18:45:45 +00:00
|
|
|
ptr += draw->pt.vertex_buffer[buf].stride * ii;
|
2008-11-06 21:57:20 +00:00
|
|
|
ptr += draw->pt.vertex_element[j].src_offset;
|
|
|
|
|
|
|
|
debug_printf(" Attr %u: ", j);
|
|
|
|
switch (draw->pt.vertex_element[j].src_format) {
|
|
|
|
case PIPE_FORMAT_R32_FLOAT:
|
|
|
|
{
|
|
|
|
float *v = (float *) ptr;
|
2010-07-16 18:10:25 +01:00
|
|
|
debug_printf("R %f @ %p\n", v[0], (void *) v);
|
2008-11-06 21:57:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PIPE_FORMAT_R32G32_FLOAT:
|
|
|
|
{
|
|
|
|
float *v = (float *) ptr;
|
2010-07-16 18:10:25 +01:00
|
|
|
debug_printf("RG %f %f @ %p\n", v[0], v[1], (void *) v);
|
2008-11-06 21:57:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PIPE_FORMAT_R32G32B32_FLOAT:
|
|
|
|
{
|
|
|
|
float *v = (float *) ptr;
|
2010-07-16 18:10:25 +01:00
|
|
|
debug_printf("RGB %f %f %f @ %p\n", v[0], v[1], v[2], (void *) v);
|
2008-11-06 21:57:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PIPE_FORMAT_R32G32B32A32_FLOAT:
|
|
|
|
{
|
|
|
|
float *v = (float *) ptr;
|
2010-07-16 18:10:25 +01:00
|
|
|
debug_printf("RGBA %f %f %f %f @ %p\n", v[0], v[1], v[2], v[3],
|
2008-11-06 21:57:20 +00:00
|
|
|
(void *) v);
|
|
|
|
}
|
|
|
|
break;
|
2010-07-16 18:10:25 +01:00
|
|
|
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
|
|
|
{
|
|
|
|
ubyte *u = (ubyte *) ptr;
|
|
|
|
debug_printf("BGRA %d %d %d %d @ %p\n", u[0], u[1], u[2], u[3],
|
|
|
|
(void *) u);
|
|
|
|
}
|
|
|
|
break;
|
2013-04-25 21:50:07 +01:00
|
|
|
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
|
|
|
{
|
|
|
|
ubyte *u = (ubyte *) ptr;
|
|
|
|
debug_printf("ARGB %d %d %d %d @ %p\n", u[0], u[1], u[2], u[3],
|
|
|
|
(void *) u);
|
|
|
|
}
|
|
|
|
break;
|
2008-11-06 21:57:20 +00:00
|
|
|
default:
|
2010-07-16 18:10:25 +01:00
|
|
|
debug_printf("other format %s (fix me)\n",
|
|
|
|
util_format_name(draw->pt.vertex_element[j].src_format));
|
2008-11-06 21:57:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-04-18 20:36:38 +01:00
|
|
|
|
|
|
|
|
2010-10-22 02:03:38 +01:00
|
|
|
/** Helper code for below */
|
2021-03-25 18:58:22 +00:00
|
|
|
static inline void
|
|
|
|
prim_restart_loop(struct draw_context *draw,
|
|
|
|
const struct pipe_draw_info *info,
|
2021-04-11 15:26:29 +01:00
|
|
|
const struct pipe_draw_start_count_bias *draw_info,
|
2021-03-25 18:58:22 +00:00
|
|
|
const void *elements)
|
|
|
|
{
|
|
|
|
const unsigned elt_max = draw->pt.user.eltMax;
|
2021-04-11 15:26:29 +01:00
|
|
|
struct pipe_draw_start_count_bias cur = *draw_info;
|
2021-03-25 18:58:22 +00:00
|
|
|
cur.count = 0;
|
|
|
|
|
|
|
|
/* The largest index within a loop using the i variable as the index.
|
|
|
|
* Used for overflow detection */
|
|
|
|
const unsigned MAX_LOOP_IDX = 0xffffffff;
|
2010-10-22 02:03:38 +01:00
|
|
|
|
2021-04-11 15:26:29 +01:00
|
|
|
for (unsigned j = 0; j < draw_info->count; j++) {
|
2021-03-25 18:58:22 +00:00
|
|
|
unsigned restart_idx = 0;
|
2021-04-11 15:26:29 +01:00
|
|
|
unsigned i = draw_overflow_uadd(draw_info->start, j, MAX_LOOP_IDX);
|
2021-03-25 18:58:22 +00:00
|
|
|
switch (draw->pt.user.eltSize) {
|
|
|
|
case 1:
|
|
|
|
restart_idx = ((const uint8_t*)elements)[i];
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
restart_idx = ((const uint16_t*)elements)[i];
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
restart_idx = ((const uint32_t*)elements)[i];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0 && "bad eltSize in draw_arrays()");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < elt_max && restart_idx == info->restart_index) {
|
|
|
|
if (cur.count > 0) {
|
|
|
|
/* draw elts up to prev pos */
|
2021-05-18 16:10:02 +01:00
|
|
|
draw_pt_arrays(draw, info->mode, info->index_bias_varies, &cur, 1);
|
2021-03-25 18:58:22 +00:00
|
|
|
}
|
|
|
|
/* begin new prim at next elt */
|
|
|
|
cur.start = i + 1;
|
|
|
|
cur.count = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cur.count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cur.count > 0) {
|
2021-05-18 16:10:02 +01:00
|
|
|
draw_pt_arrays(draw, info->mode, info->index_bias_varies, &cur, 1);
|
2021-03-25 18:58:22 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-22 02:03:38 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* For drawing prims with primitive restart enabled.
|
|
|
|
* Scan for restart indexes and draw the runs of elements/vertices between
|
|
|
|
* the restarts.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
draw_pt_arrays_restart(struct draw_context *draw,
|
2020-11-01 14:04:40 +00:00
|
|
|
const struct pipe_draw_info *info,
|
2021-04-11 14:49:49 +01:00
|
|
|
const struct pipe_draw_start_count_bias *draw_info,
|
2021-03-25 19:04:43 +00:00
|
|
|
unsigned num_draws)
|
2010-10-22 02:03:38 +01:00
|
|
|
{
|
|
|
|
const unsigned prim = info->mode;
|
|
|
|
|
|
|
|
assert(info->primitive_restart);
|
|
|
|
|
2012-09-14 16:03:25 +01:00
|
|
|
if (draw->pt.user.eltSize) {
|
2010-10-22 02:03:38 +01:00
|
|
|
/* indexed prims (draw_elements) */
|
2021-03-25 19:04:43 +00:00
|
|
|
for (unsigned i = 0; i < num_draws; i++)
|
2021-04-11 15:26:29 +01:00
|
|
|
prim_restart_loop(draw, info, &draw_info[i], draw->pt.user.elts);
|
2010-10-22 02:03:38 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Non-indexed prims (draw_arrays).
|
2019-12-04 01:38:14 +00:00
|
|
|
* Primitive restart should have been handled in gallium frontends.
|
2010-10-22 02:03:38 +01:00
|
|
|
*/
|
2021-05-18 16:10:02 +01:00
|
|
|
draw_pt_arrays(draw, prim, info->index_bias_varies, draw_info, num_draws);
|
2010-10-22 02:03:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-29 11:52:29 +00:00
|
|
|
/**
|
|
|
|
* Resolve true values within pipe_draw_info.
|
|
|
|
* If we're rendering from transform feedback/stream output
|
|
|
|
* buffers both the count and max_index need to be computed
|
|
|
|
* from the attached stream output target.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
resolve_draw_info(const struct pipe_draw_info *raw_info,
|
2020-11-01 11:38:32 +00:00
|
|
|
const struct pipe_draw_indirect_info *indirect,
|
2021-04-11 14:49:49 +01:00
|
|
|
const struct pipe_draw_start_count_bias *raw_draw,
|
2014-03-06 23:43:44 +00:00
|
|
|
struct pipe_draw_info *info,
|
2021-04-11 14:49:49 +01:00
|
|
|
struct pipe_draw_start_count_bias *draw,
|
2014-03-06 23:43:44 +00:00
|
|
|
struct pipe_vertex_buffer *vertex_buffer)
|
2013-03-29 11:52:29 +00:00
|
|
|
{
|
|
|
|
memcpy(info, raw_info, sizeof(struct pipe_draw_info));
|
2021-04-11 14:49:49 +01:00
|
|
|
memcpy(draw, raw_draw, sizeof(struct pipe_draw_start_count_bias));
|
2013-03-29 11:52:29 +00:00
|
|
|
|
2021-03-25 18:17:50 +00:00
|
|
|
struct draw_so_target *target =
|
|
|
|
(struct draw_so_target *)indirect->count_from_stream_output;
|
|
|
|
assert(vertex_buffer != NULL);
|
|
|
|
draw->count = vertex_buffer->stride == 0 ? 0 :
|
|
|
|
target->internal_offset / vertex_buffer->stride;
|
|
|
|
|
|
|
|
/* Stream output draw can not be indexed */
|
|
|
|
debug_assert(!info->index_size);
|
|
|
|
info->max_index = draw->count - 1;
|
2013-03-29 11:52:29 +00:00
|
|
|
}
|
2010-08-25 07:02:12 +01:00
|
|
|
|
2021-03-05 00:08:31 +00:00
|
|
|
/*
|
|
|
|
* Loop over all instances and execute draws for them.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
draw_instances(struct draw_context *draw,
|
2021-07-15 06:25:24 +01:00
|
|
|
unsigned drawid_offset,
|
2021-03-05 00:08:31 +00:00
|
|
|
const struct pipe_draw_info *info,
|
2021-04-11 14:49:49 +01:00
|
|
|
const struct pipe_draw_start_count_bias *draws,
|
2021-03-25 19:04:43 +00:00
|
|
|
unsigned num_draws)
|
2021-03-05 00:08:31 +00:00
|
|
|
{
|
|
|
|
unsigned instance;
|
|
|
|
|
|
|
|
draw->start_instance = info->start_instance;
|
|
|
|
|
|
|
|
for (instance = 0; instance < info->instance_count; instance++) {
|
|
|
|
unsigned instance_idx = instance + info->start_instance;
|
|
|
|
draw->instance_id = instance;
|
|
|
|
/* check for overflow */
|
|
|
|
if (instance_idx < instance ||
|
|
|
|
instance_idx < draw->start_instance) {
|
|
|
|
/* if we overflown just set the instance id to the max */
|
|
|
|
draw->instance_id = 0xffffffff;
|
|
|
|
}
|
|
|
|
|
2021-07-15 06:25:24 +01:00
|
|
|
draw->pt.user.drawid = drawid_offset;
|
2021-03-05 00:08:31 +00:00
|
|
|
draw_new_instance(draw);
|
|
|
|
|
|
|
|
if (info->primitive_restart) {
|
2021-03-25 19:04:43 +00:00
|
|
|
draw_pt_arrays_restart(draw, info, draws, num_draws);
|
2021-03-05 00:08:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2021-05-18 16:10:02 +01:00
|
|
|
draw_pt_arrays(draw, info->mode, info->index_bias_varies, draws, num_draws);
|
2021-03-05 00:08:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-25 07:02:12 +01:00
|
|
|
/**
|
|
|
|
* Draw vertex arrays.
|
|
|
|
* This is the main entrypoint into the drawing module. If drawing an indexed
|
2012-12-07 19:26:18 +00:00
|
|
|
* primitive, the draw_set_indexes() function should have already been called
|
|
|
|
* to specify the element/index buffer information.
|
2010-08-25 07:02:12 +01:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
draw_vbo(struct draw_context *draw,
|
2020-11-01 11:38:32 +00:00
|
|
|
const struct pipe_draw_info *info,
|
2021-04-11 18:35:38 +01:00
|
|
|
unsigned drawid_offset,
|
2020-11-01 14:04:40 +00:00
|
|
|
const struct pipe_draw_indirect_info *indirect,
|
2021-04-11 14:49:49 +01:00
|
|
|
const struct pipe_draw_start_count_bias *draws,
|
2021-08-13 07:29:56 +01:00
|
|
|
unsigned num_draws,
|
|
|
|
uint8_t patch_vertices)
|
2010-08-25 07:02:12 +01:00
|
|
|
{
|
2011-11-12 18:50:32 +00:00
|
|
|
unsigned index_limit;
|
2013-07-09 04:45:55 +01:00
|
|
|
unsigned fpstate = util_fpstate_get();
|
2013-03-29 11:52:29 +00:00
|
|
|
struct pipe_draw_info resolved_info;
|
2021-04-11 14:49:49 +01:00
|
|
|
struct pipe_draw_start_count_bias resolved_draw;
|
2021-03-25 18:17:50 +00:00
|
|
|
struct pipe_draw_info *use_info = (struct pipe_draw_info *)info;
|
2021-04-11 14:49:49 +01:00
|
|
|
struct pipe_draw_start_count_bias *use_draws = (struct pipe_draw_start_count_bias *)draws;
|
2013-03-29 11:52:29 +00:00
|
|
|
|
2019-03-25 03:17:31 +00:00
|
|
|
if (info->instance_count == 0)
|
|
|
|
return;
|
|
|
|
|
2013-07-09 04:45:55 +01:00
|
|
|
/* Make sure that denorms are treated like zeros. This is
|
|
|
|
* the behavior required by D3D10. OpenGL doesn't care.
|
|
|
|
*/
|
|
|
|
util_fpstate_set_denorms_to_zero(fpstate);
|
|
|
|
|
2021-03-25 18:17:50 +00:00
|
|
|
if (indirect && indirect->count_from_stream_output) {
|
|
|
|
resolve_draw_info(info, indirect, &draws[0], &resolved_info,
|
|
|
|
&resolved_draw, &(draw->pt.vertex_buffer[0]));
|
|
|
|
use_info = &resolved_info;
|
|
|
|
use_draws = &resolved_draw;
|
|
|
|
num_draws = 1;
|
|
|
|
}
|
2013-03-29 11:52:29 +00:00
|
|
|
|
2017-04-02 15:24:39 +01:00
|
|
|
if (info->index_size)
|
2010-08-25 07:02:12 +01:00
|
|
|
assert(draw->pt.user.elts);
|
2013-05-14 04:07:14 +01:00
|
|
|
|
2021-03-25 18:17:50 +00:00
|
|
|
draw->pt.user.min_index = use_info->index_bounds_valid ? use_info->min_index : 0;
|
|
|
|
draw->pt.user.max_index = use_info->index_bounds_valid ? use_info->max_index : ~0;
|
|
|
|
draw->pt.user.eltSize = use_info->index_size ? draw->pt.user.eltSizeIB : 0;
|
2021-04-11 18:35:38 +01:00
|
|
|
draw->pt.user.drawid = drawid_offset;
|
2021-03-25 19:22:27 +00:00
|
|
|
draw->pt.user.increment_draw_id = use_info->increment_draw_id;
|
2021-03-04 03:56:52 +00:00
|
|
|
draw->pt.user.viewid = 0;
|
2021-08-13 07:29:56 +01:00
|
|
|
draw->pt.vertices_per_patch = patch_vertices;
|
2020-02-17 07:13:11 +00:00
|
|
|
|
2021-03-25 19:04:43 +00:00
|
|
|
if (0) {
|
|
|
|
for (unsigned i = 0; i < num_draws; i++)
|
|
|
|
debug_printf("draw_vbo(mode=%u start=%u count=%u):\n",
|
|
|
|
use_info->mode, use_draws[i].start, use_draws[i].count);
|
|
|
|
}
|
2010-08-03 21:12:47 +01:00
|
|
|
|
|
|
|
if (0)
|
2008-11-05 15:58:40 +00:00
|
|
|
tgsi_dump(draw->vs.vertex_shader->state.tokens, 0);
|
2010-08-03 21:12:47 +01:00
|
|
|
|
|
|
|
if (0) {
|
|
|
|
unsigned int i;
|
2008-11-05 15:58:40 +00:00
|
|
|
debug_printf("Elements:\n");
|
|
|
|
for (i = 0; i < draw->pt.nr_vertex_elements; i++) {
|
2010-07-16 18:10:25 +01:00
|
|
|
debug_printf(" %u: src_offset=%u inst_div=%u vbuf=%u format=%s\n",
|
|
|
|
i,
|
|
|
|
draw->pt.vertex_element[i].src_offset,
|
|
|
|
draw->pt.vertex_element[i].instance_divisor,
|
|
|
|
draw->pt.vertex_element[i].vertex_buffer_index,
|
2010-02-17 15:44:38 +00:00
|
|
|
util_format_name(draw->pt.vertex_element[i].src_format));
|
2008-11-05 15:58:40 +00:00
|
|
|
}
|
|
|
|
debug_printf("Buffers:\n");
|
|
|
|
for (i = 0; i < draw->pt.nr_vertex_buffers; i++) {
|
2013-05-09 04:48:20 +01:00
|
|
|
debug_printf(" %u: stride=%u offset=%u size=%d ptr=%p\n",
|
2010-07-16 18:10:25 +01:00
|
|
|
i,
|
2009-01-26 18:45:45 +00:00
|
|
|
draw->pt.vertex_buffer[i].stride,
|
2008-11-05 15:58:40 +00:00
|
|
|
draw->pt.vertex_buffer[i].buffer_offset,
|
2013-05-30 01:07:35 +01:00
|
|
|
(int) draw->pt.user.vbuffer[i].size,
|
2013-05-09 04:48:20 +01:00
|
|
|
draw->pt.user.vbuffer[i].map);
|
2008-11-05 15:58:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-25 19:04:43 +00:00
|
|
|
if (0) {
|
|
|
|
for (unsigned i = 0; i < num_draws; i++)
|
2021-05-18 16:10:02 +01:00
|
|
|
draw_print_arrays(draw, use_info->mode, use_draws[i].start, MIN2(use_draws[i].count, 20),
|
|
|
|
use_info->index_bias_varies ? use_draws[i].index_bias : use_draws[0].index_bias);
|
2021-03-25 19:04:43 +00:00
|
|
|
}
|
2010-08-03 21:12:47 +01:00
|
|
|
|
2011-11-12 18:50:32 +00:00
|
|
|
index_limit = util_draw_max_index(draw->pt.vertex_buffer,
|
|
|
|
draw->pt.vertex_element,
|
|
|
|
draw->pt.nr_vertex_elements,
|
2021-03-25 18:17:50 +00:00
|
|
|
use_info);
|
2021-02-24 18:42:49 +00:00
|
|
|
#ifdef DRAW_LLVM_AVAILABLE
|
2013-06-24 23:52:24 +01:00
|
|
|
if (!draw->llvm)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (index_limit == 0) {
|
2016-01-05 20:03:05 +00:00
|
|
|
/* one of the buffers is too small to do any valid drawing */
|
2013-06-24 23:52:24 +01:00
|
|
|
debug_warning("draw: VBO too small to draw anything\n");
|
2013-07-09 04:45:55 +01:00
|
|
|
util_fpstate_set(fpstate);
|
2013-06-24 23:52:24 +01:00
|
|
|
return;
|
|
|
|
}
|
2011-11-12 18:50:32 +00:00
|
|
|
}
|
|
|
|
|
2013-04-11 14:11:29 +01:00
|
|
|
/* If we're collecting stats then make sure we start from scratch */
|
|
|
|
if (draw->collect_statistics) {
|
|
|
|
memset(&draw->statistics, 0, sizeof(draw->statistics));
|
|
|
|
}
|
|
|
|
|
2011-11-12 18:50:32 +00:00
|
|
|
draw->pt.max_index = index_limit - 1;
|
2021-03-25 18:17:50 +00:00
|
|
|
draw->start_index = use_draws[0].start;
|
2011-11-12 18:50:32 +00:00
|
|
|
|
2011-03-31 14:40:25 +01:00
|
|
|
/*
|
|
|
|
* TODO: We could use draw->pt.max_index to further narrow
|
2019-12-04 01:38:14 +00:00
|
|
|
* the min_index/max_index hints given by gallium frontends.
|
2011-03-31 14:40:25 +01:00
|
|
|
*/
|
|
|
|
|
2021-03-25 18:17:50 +00:00
|
|
|
if (use_info->view_mask) {
|
|
|
|
u_foreach_bit(i, use_info->view_mask) {
|
2021-03-04 03:56:52 +00:00
|
|
|
draw->pt.user.viewid = i;
|
2021-07-15 06:25:24 +01:00
|
|
|
draw_instances(draw, drawid_offset, use_info, use_draws, num_draws);
|
2021-03-04 03:56:52 +00:00
|
|
|
}
|
|
|
|
} else
|
2021-07-15 06:25:24 +01:00
|
|
|
draw_instances(draw, drawid_offset, use_info, use_draws, num_draws);
|
2013-04-11 14:11:29 +01:00
|
|
|
|
|
|
|
/* If requested emit the pipeline statistics for this run */
|
|
|
|
if (draw->collect_statistics) {
|
|
|
|
draw->render->pipeline_statistics(draw->render, &draw->statistics);
|
|
|
|
}
|
2013-07-09 04:45:55 +01:00
|
|
|
util_fpstate_set(fpstate);
|
2009-12-29 22:21:01 +00:00
|
|
|
}
|