Re: [Mesa-dev] [PATCH v02 37/37] i965: Port gen4+ state emitting code to genxml.
On Monday, April 24, 2017 3:19:32 PM PDT Rafael Antognolli wrote: > On this patch, we port: >- brw_polygon_stipple >- brw_polygon_stipple_offset >- brw_line_stipple >- brw_drawing_rect > > v2: >- Also emit states for gen4-5 with this code. > > Signed-off-by: Rafael Antognolli > --- > src/mesa/drivers/dri/i965/Makefile.sources | 1 +- > src/mesa/drivers/dri/i965/brw_misc_state.c | 147 +- > src/mesa/drivers/dri/i965/brw_state.h | 5 +- > src/mesa/drivers/dri/i965/gen6_viewport_state.c | 60 +- > src/mesa/drivers/dri/i965/genX_state_upload.c | 193 +++-- > 5 files changed, 176 insertions(+), 230 deletions(-) > delete mode 100644 src/mesa/drivers/dri/i965/gen6_viewport_state.c > > diff --git a/src/mesa/drivers/dri/i965/Makefile.sources > b/src/mesa/drivers/dri/i965/Makefile.sources > index 098ceba..f89d5c2 100644 > --- a/src/mesa/drivers/dri/i965/Makefile.sources > +++ b/src/mesa/drivers/dri/i965/Makefile.sources > @@ -86,7 +86,6 @@ i965_FILES = \ > gen6_scissor_state.c \ > gen6_sol.c \ > gen6_urb.c \ > - gen6_viewport_state.c \ > gen7_cs_state.c \ > gen7_l3_state.c \ > gen7_misc_state.c \ > diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c > b/src/mesa/drivers/dri/i965/brw_misc_state.c > index 83c1810..afa7e08 100644 > --- a/src/mesa/drivers/dri/i965/brw_misc_state.c > +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c > @@ -44,32 +44,6 @@ > #include "main/fbobject.h" > #include "main/glformats.h" > > -/* Constant single cliprect for framebuffer object or DRI2 drawing */ > -static void > -upload_drawing_rect(struct brw_context *brw) > -{ > - struct gl_context *ctx = &brw->ctx; > - const struct gl_framebuffer *fb = ctx->DrawBuffer; > - const unsigned int fb_width = _mesa_geometric_width(fb); > - const unsigned int fb_height = _mesa_geometric_height(fb); > - > - BEGIN_BATCH(4); > - OUT_BATCH(_3DSTATE_DRAWING_RECTANGLE << 16 | (4 - 2)); > - OUT_BATCH(0); /* xmin, ymin */ > - OUT_BATCH(((fb_width - 1) & 0x) | ((fb_height - 1) << 16)); > - OUT_BATCH(0); > - ADVANCE_BATCH(); > -} > - > -const struct brw_tracked_state brw_drawing_rect = { > - .dirty = { > - .mesa = _NEW_BUFFERS, > - .brw = BRW_NEW_BLORP | > - BRW_NEW_CONTEXT, > - }, > - .emit = upload_drawing_rect > -}; > - > /** > * Upload pointers to the per-stage state. > * > @@ -696,127 +670,6 @@ const struct brw_tracked_state brw_depthbuffer = { > .emit = brw_emit_depthbuffer, > }; > > -/** > - * Polygon stipple packet > - */ > -static void > -upload_polygon_stipple(struct brw_context *brw) > -{ > - struct gl_context *ctx = &brw->ctx; > - GLuint i; > - > - /* _NEW_POLYGON */ > - if (!ctx->Polygon.StippleFlag) > - return; > - > - BEGIN_BATCH(33); > - OUT_BATCH(_3DSTATE_POLY_STIPPLE_PATTERN << 16 | (33 - 2)); > - > - /* Polygon stipple is provided in OpenGL order, i.e. bottom > -* row first. If we're rendering to a window (i.e. the > -* default frame buffer object, 0), then we need to invert > -* it to match our pixel layout. But if we're rendering > -* to a FBO (i.e. any named frame buffer object), we *don't* > -* need to invert - we already match the layout. > -*/ > - if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) { > - for (i = 0; i < 32; i++) > - OUT_BATCH(ctx->PolygonStipple[31 - i]); /* invert */ > - } else { > - for (i = 0; i < 32; i++) > - OUT_BATCH(ctx->PolygonStipple[i]); > - } > - ADVANCE_BATCH(); > -} > - > -const struct brw_tracked_state brw_polygon_stipple = { > - .dirty = { > - .mesa = _NEW_POLYGON | > - _NEW_POLYGONSTIPPLE, > - .brw = BRW_NEW_CONTEXT, > - }, > - .emit = upload_polygon_stipple > -}; > - > -/** > - * Polygon stipple offset packet > - */ > -static void > -upload_polygon_stipple_offset(struct brw_context *brw) > -{ > - struct gl_context *ctx = &brw->ctx; > - > - /* _NEW_POLYGON */ > - if (!ctx->Polygon.StippleFlag) > - return; > - > - BEGIN_BATCH(2); > - OUT_BATCH(_3DSTATE_POLY_STIPPLE_OFFSET << 16 | (2-2)); > - > - /* _NEW_BUFFERS > -* > -* If we're drawing to a system window we have to invert the Y axis > -* in order to match the OpenGL pixel coordinate system, and our > -* offset must be matched to the window position. If we're drawing > -* to a user-created FBO then our native pixel coordinate system > -* works just fine, and there's no window system to worry about. > -*/ > - if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) > - OUT_BATCH((32 - (_mesa_geometric_height(ctx->DrawBuffer) & 31)) & 31); > - else > - OUT_BATCH(0); > - ADVANCE_BATCH(); > -} > - > -const struct brw_tracked_state brw_polygon_stipple_offset = { > - .dirty = { > - .mesa = _NEW_BUFFERS | > - _NEW_POLYGON, > - .brw = BRW_NEW_CONTEXT, > - }, > - .emit = upload_polygon_stipple_offset > -}; >
[Mesa-dev] [PATCH v02 37/37] i965: Port gen4+ state emitting code to genxml.
On this patch, we port: - brw_polygon_stipple - brw_polygon_stipple_offset - brw_line_stipple - brw_drawing_rect v2: - Also emit states for gen4-5 with this code. Signed-off-by: Rafael Antognolli --- src/mesa/drivers/dri/i965/Makefile.sources | 1 +- src/mesa/drivers/dri/i965/brw_misc_state.c | 147 +- src/mesa/drivers/dri/i965/brw_state.h | 5 +- src/mesa/drivers/dri/i965/gen6_viewport_state.c | 60 +- src/mesa/drivers/dri/i965/genX_state_upload.c | 193 +++-- 5 files changed, 176 insertions(+), 230 deletions(-) delete mode 100644 src/mesa/drivers/dri/i965/gen6_viewport_state.c diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index 098ceba..f89d5c2 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -86,7 +86,6 @@ i965_FILES = \ gen6_scissor_state.c \ gen6_sol.c \ gen6_urb.c \ - gen6_viewport_state.c \ gen7_cs_state.c \ gen7_l3_state.c \ gen7_misc_state.c \ diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c index 83c1810..afa7e08 100644 --- a/src/mesa/drivers/dri/i965/brw_misc_state.c +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c @@ -44,32 +44,6 @@ #include "main/fbobject.h" #include "main/glformats.h" -/* Constant single cliprect for framebuffer object or DRI2 drawing */ -static void -upload_drawing_rect(struct brw_context *brw) -{ - struct gl_context *ctx = &brw->ctx; - const struct gl_framebuffer *fb = ctx->DrawBuffer; - const unsigned int fb_width = _mesa_geometric_width(fb); - const unsigned int fb_height = _mesa_geometric_height(fb); - - BEGIN_BATCH(4); - OUT_BATCH(_3DSTATE_DRAWING_RECTANGLE << 16 | (4 - 2)); - OUT_BATCH(0); /* xmin, ymin */ - OUT_BATCH(((fb_width - 1) & 0x) | ((fb_height - 1) << 16)); - OUT_BATCH(0); - ADVANCE_BATCH(); -} - -const struct brw_tracked_state brw_drawing_rect = { - .dirty = { - .mesa = _NEW_BUFFERS, - .brw = BRW_NEW_BLORP | - BRW_NEW_CONTEXT, - }, - .emit = upload_drawing_rect -}; - /** * Upload pointers to the per-stage state. * @@ -696,127 +670,6 @@ const struct brw_tracked_state brw_depthbuffer = { .emit = brw_emit_depthbuffer, }; -/** - * Polygon stipple packet - */ -static void -upload_polygon_stipple(struct brw_context *brw) -{ - struct gl_context *ctx = &brw->ctx; - GLuint i; - - /* _NEW_POLYGON */ - if (!ctx->Polygon.StippleFlag) - return; - - BEGIN_BATCH(33); - OUT_BATCH(_3DSTATE_POLY_STIPPLE_PATTERN << 16 | (33 - 2)); - - /* Polygon stipple is provided in OpenGL order, i.e. bottom -* row first. If we're rendering to a window (i.e. the -* default frame buffer object, 0), then we need to invert -* it to match our pixel layout. But if we're rendering -* to a FBO (i.e. any named frame buffer object), we *don't* -* need to invert - we already match the layout. -*/ - if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) { - for (i = 0; i < 32; i++) - OUT_BATCH(ctx->PolygonStipple[31 - i]); /* invert */ - } else { - for (i = 0; i < 32; i++) -OUT_BATCH(ctx->PolygonStipple[i]); - } - ADVANCE_BATCH(); -} - -const struct brw_tracked_state brw_polygon_stipple = { - .dirty = { - .mesa = _NEW_POLYGON | - _NEW_POLYGONSTIPPLE, - .brw = BRW_NEW_CONTEXT, - }, - .emit = upload_polygon_stipple -}; - -/** - * Polygon stipple offset packet - */ -static void -upload_polygon_stipple_offset(struct brw_context *brw) -{ - struct gl_context *ctx = &brw->ctx; - - /* _NEW_POLYGON */ - if (!ctx->Polygon.StippleFlag) - return; - - BEGIN_BATCH(2); - OUT_BATCH(_3DSTATE_POLY_STIPPLE_OFFSET << 16 | (2-2)); - - /* _NEW_BUFFERS -* -* If we're drawing to a system window we have to invert the Y axis -* in order to match the OpenGL pixel coordinate system, and our -* offset must be matched to the window position. If we're drawing -* to a user-created FBO then our native pixel coordinate system -* works just fine, and there's no window system to worry about. -*/ - if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) - OUT_BATCH((32 - (_mesa_geometric_height(ctx->DrawBuffer) & 31)) & 31); - else - OUT_BATCH(0); - ADVANCE_BATCH(); -} - -const struct brw_tracked_state brw_polygon_stipple_offset = { - .dirty = { - .mesa = _NEW_BUFFERS | - _NEW_POLYGON, - .brw = BRW_NEW_CONTEXT, - }, - .emit = upload_polygon_stipple_offset -}; - -/** - * Line stipple packet - */ -static void -upload_line_stipple(struct brw_context *brw) -{ - struct gl_context *ctx = &brw->ctx; - GLfloat tmp; - GLint tmpi; - - if (!ctx->Line.StippleFlag) - return; - - BEGIN_BATCH(3); - OUT_BATCH(_3DSTATE_LINE_STIPPLE_PATTERN << 16 | (3 - 2)); - OUT_BATCH(ctx->Line.StipplePattern); - - if (brw