mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-17 07:00:20 +01:00
i965: Change type of brw_context.primitive from GLenum to hardware primitive
For example, GL_TRIANLGES is converted to _3DPRIM_TRILIST. The conversion is necessary because HiZ and MSAA resolve operations emit a 3DPRIM_RECTLIST, which cannot be conveyed by GLenum. As a consequence, brw_gs_prog_key.primitive is also converted. v2 ---- - [anholt] Split brw_set_prim into brw/gen6 variants in previous commit, since not much code is really shared between the two. - [anholt] Replace switch statements with table lookups, since this is a hot path. Reviewed-by: Eric Anholt <eric@anho.net> Signed-off-by: Chad Versace <chad@chad-versace.us>
This commit is contained in:
parent
9559ca600d
commit
f378e8fea0
4 changed files with 41 additions and 43 deletions
|
|
@ -583,7 +583,7 @@ struct brw_query_object {
|
|||
struct brw_context
|
||||
{
|
||||
struct intel_context intel; /**< base class, must be first field */
|
||||
GLuint primitive;
|
||||
GLuint primitive; /**< Hardware primitive, such as _3DPRIM_TRILIST. */
|
||||
|
||||
GLboolean emit_state_always;
|
||||
GLboolean has_surface_tile_offset;
|
||||
|
|
|
|||
|
|
@ -79,53 +79,51 @@ static const GLenum reduced_prim[GL_POLYGON+1] = {
|
|||
* programs be immune to the active primitive (ie. cope with all
|
||||
* possibilities). That may not be realistic however.
|
||||
*/
|
||||
static GLuint brw_set_prim(struct brw_context *brw,
|
||||
const struct _mesa_prim *prim)
|
||||
static void brw_set_prim(struct brw_context *brw,
|
||||
const struct _mesa_prim *prim)
|
||||
{
|
||||
struct gl_context *ctx = &brw->intel.ctx;
|
||||
GLenum mode = prim->mode;
|
||||
uint32_t hw_prim = prim_to_hw_prim[prim->mode];
|
||||
|
||||
DBG("PRIM: %s\n", _mesa_lookup_enum_by_nr(prim->mode));
|
||||
|
||||
/* Slight optimization to avoid the GS program when not needed:
|
||||
*/
|
||||
if (mode == GL_QUAD_STRIP &&
|
||||
if (prim->mode == GL_QUAD_STRIP &&
|
||||
ctx->Light.ShadeModel != GL_FLAT &&
|
||||
ctx->Polygon.FrontMode == GL_FILL &&
|
||||
ctx->Polygon.BackMode == GL_FILL)
|
||||
mode = GL_TRIANGLE_STRIP;
|
||||
hw_prim = _3DPRIM_TRISTRIP;
|
||||
|
||||
if (prim->mode == GL_QUADS && prim->count == 4 &&
|
||||
ctx->Light.ShadeModel != GL_FLAT &&
|
||||
ctx->Polygon.FrontMode == GL_FILL &&
|
||||
ctx->Polygon.BackMode == GL_FILL) {
|
||||
mode = GL_TRIANGLE_FAN;
|
||||
hw_prim = _3DPRIM_TRIFAN;
|
||||
}
|
||||
|
||||
if (mode != brw->primitive) {
|
||||
brw->primitive = mode;
|
||||
if (hw_prim != brw->primitive) {
|
||||
brw->primitive = hw_prim;
|
||||
brw->state.dirty.brw |= BRW_NEW_PRIMITIVE;
|
||||
|
||||
if (reduced_prim[mode] != brw->intel.reduced_primitive) {
|
||||
brw->intel.reduced_primitive = reduced_prim[mode];
|
||||
if (reduced_prim[prim->mode] != brw->intel.reduced_primitive) {
|
||||
brw->intel.reduced_primitive = reduced_prim[prim->mode];
|
||||
brw->state.dirty.brw |= BRW_NEW_REDUCED_PRIMITIVE;
|
||||
}
|
||||
}
|
||||
|
||||
return prim_to_hw_prim[mode];
|
||||
}
|
||||
|
||||
static GLuint gen6_set_prim(struct brw_context *brw,
|
||||
const struct _mesa_prim *prim)
|
||||
static void gen6_set_prim(struct brw_context *brw,
|
||||
const struct _mesa_prim *prim)
|
||||
{
|
||||
uint32_t hw_prim = prim_to_hw_prim[prim->mode];
|
||||
|
||||
DBG("PRIM: %s\n", _mesa_lookup_enum_by_nr(prim->mode));
|
||||
|
||||
if (prim->mode != brw->primitive) {
|
||||
brw->primitive = prim->mode;
|
||||
if (hw_prim != brw->primitive) {
|
||||
brw->primitive = hw_prim;
|
||||
brw->state.dirty.brw |= BRW_NEW_PRIMITIVE;
|
||||
}
|
||||
|
||||
return prim_to_hw_prim[mode];
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -331,7 +329,6 @@ static GLboolean brw_try_draw_prims( struct gl_context *ctx,
|
|||
intel_prepare_render(intel);
|
||||
|
||||
for (i = 0; i < nr_prims; i++) {
|
||||
uint32_t hw_prim;
|
||||
int estimated_max_prim_size;
|
||||
|
||||
estimated_max_prim_size = 512; /* batchbuffer commands */
|
||||
|
|
@ -349,9 +346,9 @@ static GLboolean brw_try_draw_prims( struct gl_context *ctx,
|
|||
intel_batchbuffer_require_space(intel, estimated_max_prim_size, false);
|
||||
|
||||
if (intel->gen < 6)
|
||||
hw_prim = brw_set_prim(brw, &prim[i]);
|
||||
brw_set_prim(brw, &prim[i]);
|
||||
else
|
||||
hw_prim = gen6_set_prim(brw, &prim[i]);
|
||||
gen6_set_prim(brw, &prim[i]);
|
||||
|
||||
if (brw->state.dirty.brw) {
|
||||
brw_validate_state(brw);
|
||||
|
|
@ -388,9 +385,9 @@ static GLboolean brw_try_draw_prims( struct gl_context *ctx,
|
|||
}
|
||||
|
||||
if (intel->gen >= 7)
|
||||
gen7_emit_prim(brw, &prim[i], hw_prim);
|
||||
gen7_emit_prim(brw, &prim[i], brw->primitive);
|
||||
else
|
||||
brw_emit_prim(brw, &prim[i], hw_prim);
|
||||
brw_emit_prim(brw, &prim[i], brw->primitive);
|
||||
|
||||
intel->no_batch_wrap = GL_FALSE;
|
||||
|
||||
|
|
|
|||
|
|
@ -86,13 +86,13 @@ static void compile_gs_prog( struct brw_context *brw,
|
|||
*/
|
||||
|
||||
switch (key->primitive) {
|
||||
case GL_QUADS:
|
||||
case _3DPRIM_QUADLIST:
|
||||
brw_gs_quads( &c, key );
|
||||
break;
|
||||
case GL_QUAD_STRIP:
|
||||
case _3DPRIM_QUADSTRIP:
|
||||
brw_gs_quad_strip( &c, key );
|
||||
break;
|
||||
case GL_LINE_LOOP:
|
||||
case _3DPRIM_LINELOOP:
|
||||
brw_gs_lines( &c );
|
||||
break;
|
||||
default:
|
||||
|
|
@ -122,17 +122,18 @@ static void compile_gs_prog( struct brw_context *brw,
|
|||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
static const GLenum gs_prim[GL_POLYGON+1] = {
|
||||
GL_POINTS,
|
||||
GL_LINES,
|
||||
GL_LINE_LOOP,
|
||||
GL_LINES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES,
|
||||
GL_TRIANGLES,
|
||||
GL_QUADS,
|
||||
GL_QUAD_STRIP,
|
||||
GL_TRIANGLES
|
||||
static const GLenum gs_prim[] = {
|
||||
[_3DPRIM_POINTLIST] = _3DPRIM_POINTLIST,
|
||||
[_3DPRIM_LINELIST] = _3DPRIM_LINELIST,
|
||||
[_3DPRIM_LINELOOP] = _3DPRIM_LINELOOP,
|
||||
[_3DPRIM_LINESTRIP] = _3DPRIM_LINELIST,
|
||||
[_3DPRIM_TRILIST] = _3DPRIM_TRILIST,
|
||||
[_3DPRIM_TRISTRIP] = _3DPRIM_TRILIST,
|
||||
[_3DPRIM_TRIFAN] = _3DPRIM_TRILIST,
|
||||
[_3DPRIM_QUADLIST] = _3DPRIM_QUADLIST,
|
||||
[_3DPRIM_QUADSTRIP] = _3DPRIM_QUADSTRIP,
|
||||
[_3DPRIM_POLYGON] = _3DPRIM_TRILIST,
|
||||
[_3DPRIM_RECTLIST] = _3DPRIM_RECTLIST,
|
||||
};
|
||||
|
||||
static void populate_key( struct brw_context *brw,
|
||||
|
|
@ -151,7 +152,7 @@ static void populate_key( struct brw_context *brw,
|
|||
|
||||
/* _NEW_LIGHT */
|
||||
key->pv_first = (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION);
|
||||
if (key->primitive == GL_QUADS && ctx->Light.ShadeModel != GL_FLAT) {
|
||||
if (key->primitive == _3DPRIM_QUADLIST && ctx->Light.ShadeModel != GL_FLAT) {
|
||||
/* Provide consistent primitive order with brw_set_prim's
|
||||
* optimization of single quads to trifans.
|
||||
*/
|
||||
|
|
@ -163,9 +164,9 @@ static void populate_key( struct brw_context *brw,
|
|||
|
||||
key->need_gs_prog = (intel->gen >= 6)
|
||||
? 0
|
||||
: (brw->primitive == GL_QUADS ||
|
||||
brw->primitive == GL_QUAD_STRIP ||
|
||||
brw->primitive == GL_LINE_LOOP);
|
||||
: (brw->primitive == _3DPRIM_QUADLIST ||
|
||||
brw->primitive == _3DPRIM_QUADSTRIP ||
|
||||
brw->primitive == _3DPRIM_LINELOOP);
|
||||
}
|
||||
|
||||
/* Calculate interpolants for triangle and line rasterization.
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
struct brw_gs_prog_key {
|
||||
GLbitfield64 attrs;
|
||||
GLuint primitive:4;
|
||||
GLuint primitive:8; /**< Hardware primitive, such as _3DPRIM_TRILIST. */
|
||||
GLuint pv_first:1;
|
||||
GLuint need_gs_prog:1;
|
||||
GLuint userclip_active:1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue