From 2366b9bc9c3548601d3603fbd00473de400e8970 Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Fri, 4 Sep 2015 14:02:50 +0200 Subject: [PATCH] Support for QUAD_STRIP and POLYGON (Fill and point rendering only) --- hw/xbox/nv2a.c | 15 ++++++++++++--- hw/xbox/nv2a_shaders.c | 13 ++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/hw/xbox/nv2a.c b/hw/xbox/nv2a.c index 34109acb21..470ad86546 100644 --- a/hw/xbox/nv2a.c +++ b/hw/xbox/nv2a.c @@ -1101,9 +1101,9 @@ static const GLenum kelvin_primitive_map[] = { GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, - GL_LINES_ADJACENCY, // GL_QUADS, - // GL_QUAD_STRIP, - // GL_POLYGON, + GL_LINES_ADJACENCY, /* QUADS */ + GL_LINE_STRIP_ADJACENCY, /* QUAD_STRIP */ + GL_TRIANGLE_FAN /* POLYGON */ }; static const GLenum pgraph_texture_min_filter_map[] = { @@ -5329,6 +5329,15 @@ static void pgraph_method(NV2AState *d, assert(front_mode < ARRAYSIZE(pgraph_polygon_mode_map)); glPolygonMode(GL_FRONT_AND_BACK, pgraph_polygon_mode_map[front_mode]); + /* FIXME: Line rendering for POLYGON can be done using line loop, + * QUADS and QUAD_STRIP need a geometry shader. Also what + * about the interpolation / provoking vertex for flat + * shaded points / lines? + */ + assert(!((pg->primitive_mode == PRIM_TYPE_QUADS || + pg->primitive_mode == PRIM_TYPE_QUAD_STRIP || + pg->primitive_mode == PRIM_TYPE_POLYGON) && + front_mode == NV_PGRAPH_SETUPRASTER_FRONTFACEMODE_LINE)); /* Polygon offset */ /* FIXME: GL implementation-specific, maybe do this in VS? */ diff --git a/hw/xbox/nv2a_shaders.c b/hw/xbox/nv2a_shaders.c index 082d883c9d..59f9a1cd95 100644 --- a/hw/xbox/nv2a_shaders.c +++ b/hw/xbox/nv2a_shaders.c @@ -39,6 +39,7 @@ static QString* generate_geometry_shader(enum ShaderPrimitiveMode primitive_mode qstring_append(s, "\n"); switch (primitive_mode) { case PRIM_TYPE_QUADS: + case PRIM_TYPE_QUAD_STRIP: qstring_append(s, "layout(lines_adjacency) in;\n"); qstring_append(s, "layout(triangle_strip, max_vertices = 4) out;\n"); break; @@ -63,6 +64,15 @@ static QString* generate_geometry_shader(enum ShaderPrimitiveMode primitive_mode generate_geometry_shader_pass_vertex(s, "2"); qstring_append(s, "EndPrimitive();\n"); break; + case PRIM_TYPE_QUAD_STRIP: + qstring_append(s, "if ((gl_PrimitiveIDIn & 1) == 0) {\n"); + generate_geometry_shader_pass_vertex(s, "0"); + generate_geometry_shader_pass_vertex(s, "1"); + generate_geometry_shader_pass_vertex(s, "2"); + generate_geometry_shader_pass_vertex(s, "3"); + qstring_append(s, " EndPrimitive();\n" + "}"); + break; default: assert(false); break; @@ -593,7 +603,8 @@ ShaderBinding* generate_shaders(const ShaderState state) { int i, j; - bool with_geom = state.primitive_mode == PRIM_TYPE_QUADS; + bool with_geom = state.primitive_mode == PRIM_TYPE_QUADS || + state.primitive_mode == PRIM_TYPE_QUAD_STRIP; char vtx_prefix = with_geom ? 'v' : 'g'; GLuint program = glCreateProgram();