[Mesa-dev] [PATCH] Support unlimited number of display connections
There is a limit of 10 display connections, which was a problem for apps/tests that were continuously opening/closing display connections. This fix uses XAddExtension() and XESetCloseDisplay() to keep track of the status of the display connections from the X server, freeing mesa-related data as X displays get destroyed by the X server. Poster child is the VTK "TimingTests" --- src/gallium/state_trackers/glx/xlib/xm_api.c | 121 ++- 1 file changed, 102 insertions(+), 19 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 2f5e1f5..2130f90 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -110,14 +110,6 @@ void xmesa_set_driver( const struct xm_driver *templ ) } -/* - * XXX replace this with a linked list, or better yet, try to attach the - * gallium/mesa extra bits to the X Display object with XAddExtension(). - */ -#define MAX_DISPLAYS 10 -static struct xmesa_display Displays[MAX_DISPLAYS]; -static int NumDisplays = 0; - static int xmesa_get_param(struct st_manager *smapi, enum st_manager_param param) @@ -130,31 +122,121 @@ xmesa_get_param(struct st_manager *smapi, } } +/* linked list of XMesaDisplay hooks per display */ +typedef struct _XMesaExtDisplayInfo { + struct _XMesaExtDisplayInfo *next; + Display *display; + XExtCodes *codes; + struct xmesa_display mesaDisplay; +} XMesaExtDisplayInfo; + +typedef struct _XMesaExtInfo { + XMesaExtDisplayInfo *head; + int ndisplays; +} XMesaExtInfo; + +static XMesaExtInfo MesaExtInfo; + +/* hook to delete XMesaDisplay on XDestroyDisplay */ +static int +xmesa_close_display(Display *display, XExtCodes *codes) +{ + XMesaExtDisplayInfo *info, *prev; + + assert(MesaExtInfo.ndisplays > 0); + assert(MesaExtInfo.head); + + _XLockMutex(_Xglobal_lock); + /* first find display */ + prev = NULL; + for (info = MesaExtInfo.head; info; info = info->next) { + if (info->display == display) { + prev = info; + break; + } + } + + if (info == NULL) { + /* no display found */ + _XUnlockMutex(_Xglobal_lock); + return 0; + } + + /* remove display entry from list */ + if (prev != MesaExtInfo.head) { + prev->next = info->next; + } else { + MesaExtInfo.head = info->next; + } + MesaExtInfo.ndisplays--; + + _XUnlockMutex(_Xglobal_lock); + + /* don't forget to clean up mesaDisplay */ + XMesaDisplay xmdpy = >mesaDisplay; + + if (xmdpy->screen) { + xmdpy->screen->destroy(xmdpy->screen); + } + free(xmdpy->smapi); + + XFree((char *) info); + return 1; +} + static XMesaDisplay xmesa_init_display( Display *display ) { pipe_static_mutex(init_mutex); XMesaDisplay xmdpy; - int i; + XMesaExtDisplayInfo *info; + + if (display == NULL) { + return NULL; + } pipe_mutex_lock(init_mutex); - /* Look for XMesaDisplay which corresponds to 'display' */ - for (i = 0; i < NumDisplays; i++) { - if (Displays[i].display == display) { + /* Look for XMesaDisplay which corresponds to this display */ + info = MesaExtInfo.head; + while(info) { + if (info->display == display) { /* Found it */ pipe_mutex_unlock(init_mutex); - return [i]; + return >mesaDisplay; } + info = info->next; } - /* Create new XMesaDisplay */ + /* Not found. Create new XMesaDisplay */ + /* first allocate X-related resources and hook destroy callback */ - assert(NumDisplays < MAX_DISPLAYS); - xmdpy = [NumDisplays]; - NumDisplays++; - - if (!xmdpy->display && display) { + /* allocate mesa display info */ + info = (XMesaExtDisplayInfo *) Xmalloc(sizeof(XMesaExtDisplayInfo)); + if (info == NULL) { + pipe_mutex_unlock(init_mutex); + return NULL; + } + info->display = display; + info->codes = XAddExtension(display); + if (info->codes == NULL) { + /* could not allocate extension. Fail */ + Xfree(info); + pipe_mutex_unlock(init_mutex); + return NULL; + } + XESetCloseDisplay(display, info->codes->extension, xmesa_close_display); + xmdpy = >mesaDisplay; /* to be filled out below */ + + /* chain to the list of displays */ + _XLockMutex(_Xglobal_lock); + info->next = MesaExtInfo.head; + MesaExtInfo.head = info; + MesaExtInfo.ndisplays++; + _XUnlockMutex(_Xglobal_lock); + + /* now create the new XMesaDisplay info */ + if (display) { xmdpy->display = display; xmdpy->screen = driver.create_pipe_screen(display); xmdpy->smapi = CALLOC_STRUCT(st_manager); @@ -185,6 +267,7 @@ xmesa_init_display( Display *display ) return xmdpy; } + /**/ /* X Utility Functions*/ /**/ --
[Mesa-dev] [PATCH v2] Support unlimited number of display connections
There is a limit of 10 display connections, which was a problem for apps/tests that were continuously opening/closing display connections. This fix uses XAddExtension() and XESetCloseDisplay() to keep track of the status of the display connections from the X server, freeing mesa-related data as X displays get destroyed by the X server. Poster child is the VTK "TimingTests" v2: Added missing initializer in struct --- src/gallium/state_trackers/glx/xlib/xm_api.c | 122 ++- 1 file changed, 103 insertions(+), 19 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 2f5e1f5..2f1bfae 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -110,14 +110,6 @@ void xmesa_set_driver( const struct xm_driver *templ ) } -/* - * XXX replace this with a linked list, or better yet, try to attach the - * gallium/mesa extra bits to the X Display object with XAddExtension(). - */ -#define MAX_DISPLAYS 10 -static struct xmesa_display Displays[MAX_DISPLAYS]; -static int NumDisplays = 0; - static int xmesa_get_param(struct st_manager *smapi, enum st_manager_param param) @@ -130,34 +122,125 @@ xmesa_get_param(struct st_manager *smapi, } } +/* linked list of XMesaDisplay hooks per display */ +typedef struct _XMesaExtDisplayInfo { + struct _XMesaExtDisplayInfo *next; + Display *display; + XExtCodes *codes; + struct xmesa_display mesaDisplay; +} XMesaExtDisplayInfo; + +typedef struct _XMesaExtInfo { + XMesaExtDisplayInfo *head; + int ndisplays; +} XMesaExtInfo; + +static XMesaExtInfo MesaExtInfo; + +/* hook to delete XMesaDisplay on XDestroyDisplay */ +static int +xmesa_close_display(Display *display, XExtCodes *codes) +{ + XMesaExtDisplayInfo *info, *prev; + + assert(MesaExtInfo.ndisplays > 0); + assert(MesaExtInfo.head); + + _XLockMutex(_Xglobal_lock); + /* first find display */ + prev = NULL; + for (info = MesaExtInfo.head; info; info = info->next) { + if (info->display == display) { + prev = info; + break; + } + } + + if (info == NULL) { + /* no display found */ + _XUnlockMutex(_Xglobal_lock); + return 0; + } + + /* remove display entry from list */ + if (prev != MesaExtInfo.head) { + prev->next = info->next; + } else { + MesaExtInfo.head = info->next; + } + MesaExtInfo.ndisplays--; + + _XUnlockMutex(_Xglobal_lock); + + /* don't forget to clean up mesaDisplay */ + XMesaDisplay xmdpy = >mesaDisplay; + + if (xmdpy->screen) { + xmdpy->screen->destroy(xmdpy->screen); + } + free(xmdpy->smapi); + + XFree((char *) info); + return 1; +} + static XMesaDisplay xmesa_init_display( Display *display ) { pipe_static_mutex(init_mutex); XMesaDisplay xmdpy; - int i; + XMesaExtDisplayInfo *info; + + if (display == NULL) { + return NULL; + } pipe_mutex_lock(init_mutex); - /* Look for XMesaDisplay which corresponds to 'display' */ - for (i = 0; i < NumDisplays; i++) { - if (Displays[i].display == display) { + /* Look for XMesaDisplay which corresponds to this display */ + info = MesaExtInfo.head; + while(info) { + if (info->display == display) { /* Found it */ pipe_mutex_unlock(init_mutex); - return [i]; + return >mesaDisplay; } + info = info->next; } - /* Create new XMesaDisplay */ + /* Not found. Create new XMesaDisplay */ + /* first allocate X-related resources and hook destroy callback */ - assert(NumDisplays < MAX_DISPLAYS); - xmdpy = [NumDisplays]; - NumDisplays++; - - if (!xmdpy->display && display) { + /* allocate mesa display info */ + info = (XMesaExtDisplayInfo *) Xmalloc(sizeof(XMesaExtDisplayInfo)); + if (info == NULL) { + pipe_mutex_unlock(init_mutex); + return NULL; + } + info->display = display; + info->codes = XAddExtension(display); + if (info->codes == NULL) { + /* could not allocate extension. Fail */ + Xfree(info); + pipe_mutex_unlock(init_mutex); + return NULL; + } + XESetCloseDisplay(display, info->codes->extension, xmesa_close_display); + xmdpy = >mesaDisplay; /* to be filled out below */ + + /* chain to the list of displays */ + _XLockMutex(_Xglobal_lock); + info->next = MesaExtInfo.head; + MesaExtInfo.head = info; + MesaExtInfo.ndisplays++; + _XUnlockMutex(_Xglobal_lock); + + /* now create the new XMesaDisplay info */ + if (display) { xmdpy->display = display; xmdpy->screen = driver.create_pipe_screen(display); xmdpy->smapi = CALLOC_STRUCT(st_manager); + xmdpy->pipe = NULL; if (xmdpy->smapi) { xmdpy->smapi->screen = xmdpy->screen; xmdpy->smapi->get_param = xmesa_get_param; @@ -185,6 +268,7 @@ xmesa_init_display( Display *display ) return xmdpy; } +
[Mesa-dev] [PATCH] gallium/swr: Cleaned up some context-resource management
Removed bound_to_context. We now pick up the context from the screen instead of the resource itself. The resource could be out-of-date and point to a pipe that is already freed. Fixes manywin mesa xdemo. --- src/gallium/drivers/swr/swr_context.cpp | 16 +++- src/gallium/drivers/swr/swr_resource.h | 18 ++ src/gallium/drivers/swr/swr_screen.cpp | 8 src/gallium/drivers/swr/swr_screen.h| 1 + src/gallium/drivers/swr/swr_state.cpp | 10 +- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index c8cb145..78b8fdf 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -129,7 +129,7 @@ swr_transfer_map(struct pipe_context *pipe, swr_fence_submit(swr_context(pipe), screen->flush_fence); swr_fence_finish(pipe->screen, screen->flush_fence, 0); -swr_resource_unused(pipe, spr); +swr_resource_unused(resource); } } } @@ -206,8 +206,8 @@ swr_resource_copy(struct pipe_context *pipe, swr_store_dirty_resource(pipe, dst, SWR_TILE_RESOLVED); swr_fence_finish(pipe->screen, screen->flush_fence, 0); - swr_resource_unused(pipe, swr_resource(src)); - swr_resource_unused(pipe, swr_resource(dst)); + swr_resource_unused(src); + swr_resource_unused(dst); if ((dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) || (dst->target != PIPE_BUFFER && src->target != PIPE_BUFFER)) { @@ -293,6 +293,7 @@ static void swr_destroy(struct pipe_context *pipe) { struct swr_context *ctx = swr_context(pipe); + struct swr_screen *screen = swr_screen(pipe->screen); if (ctx->blitter) util_blitter_destroy(ctx->blitter); @@ -306,6 +307,9 @@ swr_destroy(struct pipe_context *pipe) swr_destroy_scratch_buffers(ctx); + assert(screen); + screen->pipe = NULL; + FREE(ctx); } @@ -324,9 +328,10 @@ swr_render_condition(struct pipe_context *pipe, } struct pipe_context * -swr_create_context(struct pipe_screen *screen, void *priv, unsigned flags) +swr_create_context(struct pipe_screen *p_screen, void *priv, unsigned flags) { struct swr_context *ctx = CALLOC_STRUCT(swr_context); + struct swr_screen *screen = swr_screen(p_screen); ctx->blendJIT = new std::unordered_map; @@ -347,7 +352,8 @@ swr_create_context(struct pipe_screen *screen, void *priv, unsigned flags) if (ctx->swrContext == NULL) goto fail; - ctx->pipe.screen = screen; + screen->pipe = >pipe; + ctx->pipe.screen = p_screen; ctx->pipe.destroy = swr_destroy; ctx->pipe.priv = priv; ctx->pipe.create_surface = swr_create_surface; diff --git a/src/gallium/drivers/swr/swr_resource.h b/src/gallium/drivers/swr/swr_resource.h index 2fdc768..59cf028 100644 --- a/src/gallium/drivers/swr/swr_resource.h +++ b/src/gallium/drivers/swr/swr_resource.h @@ -54,9 +54,6 @@ struct swr_resource { unsigned mip_offsets[PIPE_MAX_TEXTURE_LEVELS]; enum swr_resource_status status; - - /* pipe_context to which resource is currently bound. */ - struct pipe_context *bound_to_context; }; @@ -120,24 +117,21 @@ swr_resource_status & operator|=(enum swr_resource_status & a, } static INLINE void -swr_resource_read(struct pipe_context *pipe, struct swr_resource *resource) +swr_resource_read(struct pipe_resource *resource) { - resource->status |= SWR_RESOURCE_READ; - resource->bound_to_context = pipe; + swr_resource(resource)->status |= SWR_RESOURCE_READ; } static INLINE void -swr_resource_write(struct pipe_context *pipe, struct swr_resource *resource) +swr_resource_write(struct pipe_resource *resource) { - resource->status |= SWR_RESOURCE_WRITE; - resource->bound_to_context = pipe; + swr_resource(resource)->status |= SWR_RESOURCE_WRITE; } static INLINE void -swr_resource_unused(struct pipe_context *pipe, struct swr_resource *resource) +swr_resource_unused(struct pipe_resource *resource) { - resource->status = SWR_RESOURCE_UNUSED; - resource->bound_to_context = nullptr; + swr_resource(resource)->status = SWR_RESOURCE_UNUSED; } #endif diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index e46df47..f9e52be 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -620,7 +620,7 @@ swr_resource_destroy(struct pipe_screen *p_screen, struct pipe_resource *pt) { struct swr_screen *screen = swr_screen(p_screen); struct swr_resource *spr = swr_resource(pt); - struct pipe_context *pipe = spr->bound_to_context; + struct pipe_context *pipe = screen->pipe; /* Only wait on fence if the resource is being used */ if (pipe && spr->status) { @@ -630,7 +630,7 @@ swr_resource_destroy(struct pipe_screen *p_screen, struct pipe_resource *pt)
[Mesa-dev] [PATCH] GLX: Don't destroy screen on XCloseDisplay()
screen may still be used by other resources that are not yet freed. To correctly fix this there will be a need to account for resources differently, but this quick fix is not any worse than the original code that leaked screens anyway. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index cee4f18..5799cce 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -174,9 +174,13 @@ xmesa_close_display(Display *display) /* don't forget to clean up mesaDisplay */ XMesaDisplay xmdpy = >mesaDisplay; - if (xmdpy->screen) { - xmdpy->screen->destroy(xmdpy->screen); - } + /** +* XXX: Don't destroy the screens here, since there may still +* be some dangling screen pointers that are used after this point +* if (xmdpy->screen) { +*xmdpy->screen->destroy(xmdpy->screen); +* } +*/ free(xmdpy->smapi); XFree((char *) info); -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 2/2] Hang off screen destructor off main XCloseDisplay() callback.
This resolves some order dependencies between the already existing callback the newly created one. --- src/gallium/state_trackers/glx/xlib/glx_api.c | 1 + src/gallium/state_trackers/glx/xlib/xm_api.c | 58 +++ src/gallium/state_trackers/glx/xlib/xm_api.h | 3 ++ 3 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 0456d44..1c541b7 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -615,6 +615,7 @@ close_display_callback(Display *dpy, XExtCodes *codes) { xmesa_destroy_buffers_on_display(dpy); destroy_visuals_on_display(dpy); + xmesa_close_display(dpy); return 0; } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 2f1bfae..cee4f18 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -126,7 +126,6 @@ xmesa_get_param(struct st_manager *smapi, typedef struct _XMesaExtDisplayInfo { struct _XMesaExtDisplayInfo *next; Display *display; - XExtCodes *codes; struct xmesa_display mesaDisplay; } XMesaExtDisplayInfo; @@ -138,8 +137,8 @@ typedef struct _XMesaExtInfo { static XMesaExtInfo MesaExtInfo; /* hook to delete XMesaDisplay on XDestroyDisplay */ -static int -xmesa_close_display(Display *display, XExtCodes *codes) +extern void +xmesa_close_display(Display *display) { XMesaExtDisplayInfo *info, *prev; @@ -159,7 +158,7 @@ xmesa_close_display(Display *display, XExtCodes *codes) if (info == NULL) { /* no display found */ _XUnlockMutex(_Xglobal_lock); - return 0; + return; } /* remove display entry from list */ @@ -181,7 +180,6 @@ xmesa_close_display(Display *display, XExtCodes *codes) free(xmdpy->smapi); XFree((char *) info); - return 1; } static XMesaDisplay @@ -218,14 +216,6 @@ xmesa_init_display( Display *display ) return NULL; } info->display = display; - info->codes = XAddExtension(display); - if (info->codes == NULL) { - /* could not allocate extension. Fail */ - Xfree(info); - pipe_mutex_unlock(init_mutex); - return NULL; - } - XESetCloseDisplay(display, info->codes->extension, xmesa_close_display); xmdpy = >mesaDisplay; /* to be filled out below */ /* chain to the list of displays */ @@ -236,32 +226,30 @@ xmesa_init_display( Display *display ) _XUnlockMutex(_Xglobal_lock); /* now create the new XMesaDisplay info */ - if (display) { - xmdpy->display = display; - xmdpy->screen = driver.create_pipe_screen(display); - xmdpy->smapi = CALLOC_STRUCT(st_manager); - xmdpy->pipe = NULL; - if (xmdpy->smapi) { - xmdpy->smapi->screen = xmdpy->screen; - xmdpy->smapi->get_param = xmesa_get_param; - } + assert(display); + + xmdpy->display = display; + xmdpy->screen = driver.create_pipe_screen(display); + xmdpy->smapi = CALLOC_STRUCT(st_manager); + xmdpy->pipe = NULL; + if (xmdpy->smapi) { + xmdpy->smapi->screen = xmdpy->screen; + xmdpy->smapi->get_param = xmesa_get_param; + } - if (xmdpy->screen && xmdpy->smapi) { - pipe_mutex_init(xmdpy->mutex); + if (xmdpy->screen && xmdpy->smapi) { + pipe_mutex_init(xmdpy->mutex); + } + else { + if (xmdpy->screen) { + xmdpy->screen->destroy(xmdpy->screen); + xmdpy->screen = NULL; } - else { - if (xmdpy->screen) { -xmdpy->screen->destroy(xmdpy->screen); -xmdpy->screen = NULL; - } - free(xmdpy->smapi); - xmdpy->smapi = NULL; + free(xmdpy->smapi); + xmdpy->smapi = NULL; - xmdpy->display = NULL; - } + xmdpy->display = NULL; } - if (!xmdpy->display || xmdpy->display != display) - xmdpy = NULL; pipe_mutex_unlock(init_mutex); diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h index ffdffc0..ccf35a5 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.h +++ b/src/gallium/state_trackers/glx/xlib/xm_api.h @@ -378,6 +378,9 @@ xmesa_check_buffer_size(XMesaBuffer b); extern void xmesa_destroy_buffers_on_display(Display *dpy); +extern void +xmesa_close_display(Display *dpy); + static inline GLuint xmesa_buffer_width(XMesaBuffer b) { -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 1/2] Support unlimited number of display connections
There is a limit of 10 display connections, which was a problem for apps/tests that were continuously opening/closing display connections. This fix uses XAddExtension() and XESetCloseDisplay() to keep track of the status of the display connections from the X server, freeing mesa-related data as X displays get destroyed by the X server. Poster child is the VTK "TimingTests" --- src/gallium/state_trackers/glx/xlib/xm_api.c | 122 ++- 1 file changed, 103 insertions(+), 19 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 2f5e1f5..2f1bfae 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -110,14 +110,6 @@ void xmesa_set_driver( const struct xm_driver *templ ) } -/* - * XXX replace this with a linked list, or better yet, try to attach the - * gallium/mesa extra bits to the X Display object with XAddExtension(). - */ -#define MAX_DISPLAYS 10 -static struct xmesa_display Displays[MAX_DISPLAYS]; -static int NumDisplays = 0; - static int xmesa_get_param(struct st_manager *smapi, enum st_manager_param param) @@ -130,34 +122,125 @@ xmesa_get_param(struct st_manager *smapi, } } +/* linked list of XMesaDisplay hooks per display */ +typedef struct _XMesaExtDisplayInfo { + struct _XMesaExtDisplayInfo *next; + Display *display; + XExtCodes *codes; + struct xmesa_display mesaDisplay; +} XMesaExtDisplayInfo; + +typedef struct _XMesaExtInfo { + XMesaExtDisplayInfo *head; + int ndisplays; +} XMesaExtInfo; + +static XMesaExtInfo MesaExtInfo; + +/* hook to delete XMesaDisplay on XDestroyDisplay */ +static int +xmesa_close_display(Display *display, XExtCodes *codes) +{ + XMesaExtDisplayInfo *info, *prev; + + assert(MesaExtInfo.ndisplays > 0); + assert(MesaExtInfo.head); + + _XLockMutex(_Xglobal_lock); + /* first find display */ + prev = NULL; + for (info = MesaExtInfo.head; info; info = info->next) { + if (info->display == display) { + prev = info; + break; + } + } + + if (info == NULL) { + /* no display found */ + _XUnlockMutex(_Xglobal_lock); + return 0; + } + + /* remove display entry from list */ + if (prev != MesaExtInfo.head) { + prev->next = info->next; + } else { + MesaExtInfo.head = info->next; + } + MesaExtInfo.ndisplays--; + + _XUnlockMutex(_Xglobal_lock); + + /* don't forget to clean up mesaDisplay */ + XMesaDisplay xmdpy = >mesaDisplay; + + if (xmdpy->screen) { + xmdpy->screen->destroy(xmdpy->screen); + } + free(xmdpy->smapi); + + XFree((char *) info); + return 1; +} + static XMesaDisplay xmesa_init_display( Display *display ) { pipe_static_mutex(init_mutex); XMesaDisplay xmdpy; - int i; + XMesaExtDisplayInfo *info; + + if (display == NULL) { + return NULL; + } pipe_mutex_lock(init_mutex); - /* Look for XMesaDisplay which corresponds to 'display' */ - for (i = 0; i < NumDisplays; i++) { - if (Displays[i].display == display) { + /* Look for XMesaDisplay which corresponds to this display */ + info = MesaExtInfo.head; + while(info) { + if (info->display == display) { /* Found it */ pipe_mutex_unlock(init_mutex); - return [i]; + return >mesaDisplay; } + info = info->next; } - /* Create new XMesaDisplay */ + /* Not found. Create new XMesaDisplay */ + /* first allocate X-related resources and hook destroy callback */ - assert(NumDisplays < MAX_DISPLAYS); - xmdpy = [NumDisplays]; - NumDisplays++; - - if (!xmdpy->display && display) { + /* allocate mesa display info */ + info = (XMesaExtDisplayInfo *) Xmalloc(sizeof(XMesaExtDisplayInfo)); + if (info == NULL) { + pipe_mutex_unlock(init_mutex); + return NULL; + } + info->display = display; + info->codes = XAddExtension(display); + if (info->codes == NULL) { + /* could not allocate extension. Fail */ + Xfree(info); + pipe_mutex_unlock(init_mutex); + return NULL; + } + XESetCloseDisplay(display, info->codes->extension, xmesa_close_display); + xmdpy = >mesaDisplay; /* to be filled out below */ + + /* chain to the list of displays */ + _XLockMutex(_Xglobal_lock); + info->next = MesaExtInfo.head; + MesaExtInfo.head = info; + MesaExtInfo.ndisplays++; + _XUnlockMutex(_Xglobal_lock); + + /* now create the new XMesaDisplay info */ + if (display) { xmdpy->display = display; xmdpy->screen = driver.create_pipe_screen(display); xmdpy->smapi = CALLOC_STRUCT(st_manager); + xmdpy->pipe = NULL; if (xmdpy->smapi) { xmdpy->smapi->screen = xmdpy->screen; xmdpy->smapi->get_param = xmesa_get_param; @@ -185,6 +268,7 @@ xmesa_init_display( Display *display ) return xmdpy; } + /**/
[Mesa-dev] [PATCH] gallium/swr: Make flat shading tris work.
- Incorporate flatshade flag into the shader generation - Use provoking vertex (vc) in shader when flat shading. --- src/gallium/drivers/swr/swr_shader.cpp | 4 src/gallium/drivers/swr/swr_shader.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp index 90f0f22..83e3216 100644 --- a/src/gallium/drivers/swr/swr_shader.cpp +++ b/src/gallium/drivers/swr/swr_shader.cpp @@ -102,6 +102,7 @@ swr_generate_fs_key(struct swr_jit_fs_key , key.nr_cbufs = ctx->framebuffer.nr_cbufs; key.light_twoside = ctx->rasterizer->light_twoside; + key.flatshade = ctx->rasterizer->flatshade; memcpy(_output_semantic_name, >vs->info.base.output_semantic_name, sizeof(key.vs_output_semantic_name)); @@ -491,6 +492,9 @@ BuilderSWR::CompileFS(struct swr_context *ctx, swr_jit_fs_key ) if (interpMode == TGSI_INTERPOLATE_CONSTANT) { inputs[attrib][channel] = wrap(va); +} else if ((interpMode == TGSI_INTERPOLATE_COLOR) && + (key.flatshade == true)) { + inputs[attrib][channel] = wrap(vc); } else { Value *vk = FSUB(FSUB(VIMMED1(1.0f), vi), vj); diff --git a/src/gallium/drivers/swr/swr_shader.h b/src/gallium/drivers/swr/swr_shader.h index 4814b9d..3f79570 100644 --- a/src/gallium/drivers/swr/swr_shader.h +++ b/src/gallium/drivers/swr/swr_shader.h @@ -51,6 +51,7 @@ struct swr_jit_sampler_key { struct swr_jit_fs_key : swr_jit_sampler_key { unsigned nr_cbufs; unsigned light_twoside; + unsigned flatshade; ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; ubyte vs_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS]; }; -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] [swr] fix index buffers with non-zero indices
Fix issue with index buffers that do not contain 0 index. Use core BaseVertex functionality to offset index buffer indices, instead of offsetting vertex buffer to point before the buffer origin. --- src/gallium/drivers/swr/swr_draw.cpp | 2 +- src/gallium/drivers/swr/swr_state.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp index c4d5e5c..88000e5 100644 --- a/src/gallium/drivers/swr/swr_draw.cpp +++ b/src/gallium/drivers/swr/swr_draw.cpp @@ -200,7 +200,7 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) info->count, info->instance_count, info->start, - info->index_bias, + info->index_bias - info->min_index, info->start_instance); else SwrDrawInstanced(ctx->swrContext, diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index f1f4963..f03f814 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -1133,7 +1133,7 @@ swr_update_derived(struct pipe_context *pipe, memcpy(scratch, ptr, size); ptr = scratch; scratch += size; -p_data = (const uint8_t *)ptr - base; +p_data = (const uint8_t *)ptr; } swrVertexBuffers[i] = {0}; -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] [swr] Align query results allocation
Some query results struct contents are declared as cache line aligned. Use aligned malloc, and align the whole struct, to be safe. Fixes crash when compiling with clang. CC:--- src/gallium/drivers/swr/swr_query.cpp | 7 --- src/gallium/drivers/swr/swr_query.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/swr/swr_query.cpp b/src/gallium/drivers/swr/swr_query.cpp index 6eb0781..e097790 100644 --- a/src/gallium/drivers/swr/swr_query.cpp +++ b/src/gallium/drivers/swr/swr_query.cpp @@ -29,7 +29,7 @@ #include "swr_query.h" #include "swr_screen.h" #include "swr_state.h" - +#include "common/os.h" static struct swr_query * swr_query(struct pipe_query *p) @@ -45,7 +45,8 @@ swr_create_query(struct pipe_context *pipe, unsigned type, unsigned index) assert(type < PIPE_QUERY_TYPES); assert(index < MAX_SO_STREAMS); - pq = CALLOC_STRUCT(swr_query); + pq = (struct swr_query *) AlignedMalloc(sizeof(struct swr_query), 64); + memset(pq, 0, sizeof(*pq)); if (pq) { pq->type = type; @@ -67,7 +68,7 @@ swr_destroy_query(struct pipe_context *pipe, struct pipe_query *q) swr_fence_reference(pipe->screen, >fence, NULL); } - FREE(pq); + AlignedFree(pq); } diff --git a/src/gallium/drivers/swr/swr_query.h b/src/gallium/drivers/swr/swr_query.h index c5160ce..1c736e4 100644 --- a/src/gallium/drivers/swr/swr_query.h +++ b/src/gallium/drivers/swr/swr_query.h @@ -34,7 +34,7 @@ struct swr_query_result { uint64_t timestamp_end; }; -struct swr_query { +OSALIGNLINE(struct) swr_query { unsigned type; /* PIPE_QUERY_* */ unsigned index; -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] [swr] Update fs texture & sampler state logic
In swr_update_derived() update texture and sampler state on a new fragment shader. GALLIUM_HUD can update fs using a previously bound texture and sampler. --- src/gallium/drivers/swr/swr_state.cpp | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 41e0356..f1f4963 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -1283,7 +1283,8 @@ swr_update_derived(struct pipe_context *pipe, SwrSetPixelShaderState(ctx->swrContext, ); /* JIT sampler state */ - if (ctx->dirty & SWR_NEW_SAMPLER) { + if (ctx->dirty & (SWR_NEW_SAMPLER | +SWR_NEW_FS)) { swr_update_sampler_state(ctx, PIPE_SHADER_FRAGMENT, key.nr_samplers, @@ -1291,7 +1292,9 @@ swr_update_derived(struct pipe_context *pipe, } /* JIT sampler view state */ - if (ctx->dirty & (SWR_NEW_SAMPLER_VIEW | SWR_NEW_FRAMEBUFFER)) { + if (ctx->dirty & (SWR_NEW_SAMPLER_VIEW | +SWR_NEW_FRAMEBUFFER | +SWR_NEW_FS)) { swr_update_texture_state(ctx, PIPE_SHADER_FRAGMENT, key.nr_sampler_views, -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 1/2] [util] add extern "C" guards
Added extern "C" __cplusplus guards on headers that did not have them. --- src/gallium/auxiliary/util/u_transfer.h | 8 src/gallium/auxiliary/util/u_upload_mgr.h | 7 +++ 2 files changed, 15 insertions(+) diff --git a/src/gallium/auxiliary/util/u_transfer.h b/src/gallium/auxiliary/util/u_transfer.h index ab787ab..1408498 100644 --- a/src/gallium/auxiliary/util/u_transfer.h +++ b/src/gallium/auxiliary/util/u_transfer.h @@ -10,6 +10,10 @@ struct pipe_context; struct winsys_handle; +#ifdef __cplusplus +extern "C" { +#endif + boolean u_default_resource_get_handle(struct pipe_screen *screen, struct pipe_resource *resource, struct winsys_handle *handle); @@ -95,4 +99,8 @@ void u_transfer_flush_region_vtbl( struct pipe_context *pipe, void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx, struct pipe_transfer *transfer ); +#ifdef __cplusplus +} // extern "C" { +#endif + #endif diff --git a/src/gallium/auxiliary/util/u_upload_mgr.h b/src/gallium/auxiliary/util/u_upload_mgr.h index 633291e..4538291 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.h +++ b/src/gallium/auxiliary/util/u_upload_mgr.h @@ -38,6 +38,9 @@ struct pipe_context; struct pipe_resource; +#ifdef __cplusplus +extern "C" { +#endif /** * Create the upload manager. @@ -109,4 +112,8 @@ void u_upload_data(struct u_upload_mgr *upload, unsigned *out_offset, struct pipe_resource **outbuf); +#ifdef __cplusplus +} // extern "C" { +#endif + #endif -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 2/2] [swr] remove unneeded extern "C"
the guards have been added to the header files that needed them. --- src/gallium/drivers/swr/swr_context.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index 2e37bac..3e17edc 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -34,11 +34,8 @@ #include "util/u_format.h" #include "util/u_atomic.h" #include "util/u_upload_mgr.h" - -extern "C" { #include "util/u_transfer.h" #include "util/u_surface.h" -} #include "api.h" #include "backend.h" -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] [swr] fix index buffers with non-zero indices
Fix issue with index buffers that do not contain a 0 index. 0 index can be a non-valid index if the (copied) vertex buffers are a subset of the user's (which happens because we only copy the range between min & max). Core will use an index passed in from the driver to replace invalid indices. Only do this for calls that contain non-zero indices, to minimize performance cost. --- src/gallium/drivers/swr/rasterizer/core/state.h| 1 + .../drivers/swr/rasterizer/jitter/fetch_jit.cpp| 60 +++--- .../drivers/swr/rasterizer/jitter/fetch_jit.h | 2 + src/gallium/drivers/swr/swr_draw.cpp | 1 + src/gallium/drivers/swr/swr_state.cpp | 4 ++ 5 files changed, 62 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/state.h b/src/gallium/drivers/swr/rasterizer/core/state.h index 2f3b913..05347dc 100644 --- a/src/gallium/drivers/swr/rasterizer/core/state.h +++ b/src/gallium/drivers/swr/rasterizer/core/state.h @@ -524,6 +524,7 @@ struct SWR_VERTEX_BUFFER_STATE const uint8_t *pData; uint32_t size; uint32_t numaNode; +uint32_t minVertex; // min vertex (for bounds checking) uint32_t maxVertex; // size / pitch. precalculated value used by fetch shader for OOB checks uint32_t partialInboundsSize; // size % pitch. precalculated value used by fetch shader for partially OOB vertices }; diff --git a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp index 901bce6..ffa7605 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp @@ -309,11 +309,29 @@ void FetchJit::JitLoadVertices(const FETCH_COMPILE_STATE , Value* str Value* startVertexOffset = MUL(Z_EXT(startOffset, mInt64Ty), stride); +Value *minVertex = NULL; +Value *minVertexOffset = NULL; +if (fetchState.bPartialVertexBuffer) { +// fetch min index for low bounds checking +minVertex = GEP(streams, {C(ied.StreamIndex), C(SWR_VERTEX_BUFFER_STATE_minVertex)}); +minVertex = LOAD(minVertex); +if (!fetchState.bDisableIndexOOBCheck) { +minVertexOffset = MUL(Z_EXT(minVertex, mInt64Ty), stride); +} +} + // Load from the stream. for(uint32_t lane = 0; lane < mVWidth; ++lane) { // Get index Value* index = VEXTRACT(vCurIndices, C(lane)); + +if (fetchState.bPartialVertexBuffer) { +// clamp below minvertex +Value *isBelowMin = ICMP_SLT(index, minVertex); +index = SELECT(isBelowMin, minVertex, index); +} + index = Z_EXT(index, mInt64Ty); Value*offset = MUL(index, stride); @@ -321,10 +339,14 @@ void FetchJit::JitLoadVertices(const FETCH_COMPILE_STATE , Value* str offset = ADD(offset, startVertexOffset); if (!fetchState.bDisableIndexOOBCheck) { -// check for out of bound access, including partial OOB, and mask them to 0 +// check for out of bound access, including partial OOB, and replace them with minVertex Value *endOffset = ADD(offset, C((int64_t)info.Bpp)); Value *oob = ICMP_ULE(endOffset, size); -offset = SELECT(oob, offset, ConstantInt::get(mInt64Ty, 0)); +if (fetchState.bPartialVertexBuffer) { +offset = SELECT(oob, offset, minVertexOffset); +} else { +offset = SELECT(oob, offset, ConstantInt::get(mInt64Ty, 0)); +} } Value*pointer = GEP(stream, offset); @@ -732,6 +754,13 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE , Value *maxVertex = GEP(streams, {C(ied.StreamIndex), C(SWR_VERTEX_BUFFER_STATE_maxVertex)}); maxVertex = LOAD(maxVertex); +Value *minVertex = NULL; +if (fetchState.bPartialVertexBuffer) { +// min vertex index for low bounds OOB checking +minVertex = GEP(streams, {C(ied.StreamIndex), C(SWR_VERTEX_BUFFER_STATE_minVertex)}); +minVertex = LOAD(minVertex); +} + Value *vCurIndices; Value *startOffset; if(ied.InstanceEnable) @@ -769,9 +798,16 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE , // if we have a start offset, subtract from max vertex. Used for OOB check maxVertex = SUB(Z_EXT(maxVertex, mInt64Ty), Z_EXT(startOffset, mInt64Ty)); -Value* neg = ICMP_SLT(maxVertex, C((int64_t)0)); +Value* maxNeg = ICMP_SLT(maxVertex, C((int64_t)0)); // if we have a negative value, we're already OOB. clamp at 0. -maxVertex = SELECT(neg, C(0), TRUNC(maxVertex, mInt32Ty)); +maxVertex = SELECT(maxNeg,
[Mesa-dev] [PATCH 1/2] [swr] Add fetch shader cache
For now, the cache key is all of FETCH_COMPILE_STATE. Use new/delete for swr_vertex_element_state, since we have to call the constructors/destructors of the struct elements. --- src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.h | 2 +- src/gallium/drivers/swr/swr_draw.cpp | 19 +++ src/gallium/drivers/swr/swr_shader.cpp| 14 ++ src/gallium/drivers/swr/swr_shader.h | 15 +++ src/gallium/drivers/swr/swr_state.cpp | 6 -- src/gallium/drivers/swr/swr_state.h | 9 + 6 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.h b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.h index 1547453..622608a 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.h +++ b/src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.h @@ -94,7 +94,7 @@ enum ComponentControl // struct FETCH_COMPILE_STATE { -uint32_t numAttribs; +uint32_t numAttribs {0}; INPUT_ELEMENT_DESC layout[KNOB_NUM_ATTRIBUTES]; SWR_FORMAT indexType; uint32_t cutIndex{ 0x }; diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp index c4d5e5c..4bdd3bb 100644 --- a/src/gallium/drivers/swr/swr_draw.cpp +++ b/src/gallium/drivers/swr/swr_draw.cpp @@ -141,19 +141,22 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) } struct swr_vertex_element_state *velems = ctx->velems; - if (!velems->fsFunc - || (velems->fsState.cutIndex != info->restart_index) - || (velems->fsState.bEnableCutIndex != info->primitive_restart)) { - - velems->fsState.cutIndex = info->restart_index; - velems->fsState.bEnableCutIndex = info->primitive_restart; - - /* Create Fetch Shader */ + velems->fsState.cutIndex = info->restart_index; + velems->fsState.bEnableCutIndex = info->primitive_restart; + + swr_jit_fetch_key key; + swr_generate_fetch_key(key, velems); + auto search = velems->map.find(key); + if (search != velems->map.end()) { + velems->fsFunc = search->second; + } else { HANDLE hJitMgr = swr_screen(ctx->pipe.screen)->hJitMgr; velems->fsFunc = JitCompileFetch(hJitMgr, velems->fsState); debug_printf("fetch shader %p\n", velems->fsFunc); assert(velems->fsFunc && "Error: FetchShader = NULL"); + + velems->map.insert(std::make_pair(key, velems->fsFunc)); } SwrSetFetchFunc(ctx->swrContext, velems->fsFunc); diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp index 979a28b..676938c 100644 --- a/src/gallium/drivers/swr/swr_shader.cpp +++ b/src/gallium/drivers/swr/swr_shader.cpp @@ -61,6 +61,11 @@ bool operator==(const swr_jit_vs_key , const swr_jit_vs_key ) return !memcmp(, , sizeof(lhs)); } +bool operator==(const swr_jit_fetch_key , const swr_jit_fetch_key ) +{ + return !memcmp(, , sizeof(lhs)); +} + static void swr_generate_sampler_key(const struct lp_tgsi_info , struct swr_context *ctx, @@ -157,6 +162,15 @@ swr_generate_vs_key(struct swr_jit_vs_key , swr_generate_sampler_key(swr_vs->info, ctx, PIPE_SHADER_VERTEX, key); } +void +swr_generate_fetch_key(struct swr_jit_fetch_key , + struct swr_vertex_element_state *velems) +{ + memset(, 0, sizeof(key)); + + key.fsState = velems->fsState; +} + struct BuilderSWR : public Builder { BuilderSWR(JitManager *pJitMgr, const char *pName) : Builder(pJitMgr) diff --git a/src/gallium/drivers/swr/swr_shader.h b/src/gallium/drivers/swr/swr_shader.h index 7e3399c..266573f 100644 --- a/src/gallium/drivers/swr/swr_shader.h +++ b/src/gallium/drivers/swr/swr_shader.h @@ -42,6 +42,9 @@ void swr_generate_vs_key(struct swr_jit_vs_key , struct swr_context *ctx, swr_vertex_shader *swr_vs); +void swr_generate_fetch_key(struct swr_jit_fetch_key , +struct swr_vertex_element_state *velems); + struct swr_jit_sampler_key { unsigned nr_samplers; unsigned nr_sampler_views; @@ -60,6 +63,10 @@ struct swr_jit_vs_key : swr_jit_sampler_key { unsigned clip_plane_mask; // from rasterizer state & vs_info }; +struct swr_jit_fetch_key { + FETCH_COMPILE_STATE fsState; +}; + namespace std { template <> struct hash { @@ -75,7 +82,15 @@ template <> struct hash { return util_hash_crc32(, sizeof(k)); } }; + +template <> struct hash { + std::size_t operator()(const swr_jit_fetch_key ) const + { + return util_hash_crc32(, sizeof(k)); + } +}; }; bool operator==(const swr_jit_fs_key , const swr_jit_fs_key ); bool operator==(const swr_jit_vs_key , const swr_jit_vs_key ); +bool operator==(const swr_jit_fetch_key , const swr_jit_fetch_key ); diff --git
[Mesa-dev] [PATCH] [swr] fix windows build
move util/u_upload_mgr.h inside extern "C" --- src/gallium/drivers/swr/swr_context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index 2e37bac..04ff146 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -33,9 +33,9 @@ #include "util/u_inlines.h" #include "util/u_format.h" #include "util/u_atomic.h" -#include "util/u_upload_mgr.h" extern "C" { +#include "util/u_upload_mgr.h" #include "util/u_transfer.h" #include "util/u_surface.h" } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/5] swr: [rasterizer core] Frontend dependency work
Add frontend dependency concept in the DRAW_CONTEXT, which allows serialization of frontend work if necessary. --- src/gallium/drivers/swr/rasterizer/core/api.cpp | 3 +++ src/gallium/drivers/swr/rasterizer/core/context.h | 3 ++- src/gallium/drivers/swr/rasterizer/core/threads.cpp | 14 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp index e67ede2..5f941e8 100644 --- a/src/gallium/drivers/swr/rasterizer/core/api.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp @@ -317,7 +317,10 @@ DRAW_CONTEXT* GetDrawContext(SWR_CONTEXT *pContext, bool isSplitDraw = false) SWR_ASSERT(pCurDrawContext->pArena->IsEmpty() == true); +// Reset dependency pCurDrawContext->dependent = false; +pCurDrawContext->dependentFE = false; + pCurDrawContext->pContext = pContext; pCurDrawContext->isCompute = false; // Dispatch has to set this to true. diff --git a/src/gallium/drivers/swr/rasterizer/core/context.h b/src/gallium/drivers/swr/rasterizer/core/context.h index 9a26e33..a9de63b 100644 --- a/src/gallium/drivers/swr/rasterizer/core/context.h +++ b/src/gallium/drivers/swr/rasterizer/core/context.h @@ -404,7 +404,8 @@ struct DRAW_CONTEXT CachingArena* pArena; uint32_tdrawId; -booldependent; +booldependentFE;// Frontend work is dependent on all previous FE +booldependent; // Backend work is dependent on all previous BE boolisCompute; // Is this DC a compute context? boolcleanupState; // True if this is the last draw using an entry in the state ring. volatile bool doneFE; // Is FE work done for this draw? diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp index ea5542a..701a550 100644 --- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp @@ -313,6 +313,11 @@ bool CheckDependency(SWR_CONTEXT *pContext, DRAW_CONTEXT *pDC, uint32_t lastReti return pDC->dependent && IDComparesLess(lastRetiredDraw, pDC->drawId - 1); } +bool CheckDependencyFE(SWR_CONTEXT *pContext, DRAW_CONTEXT *pDC, uint32_t lastRetiredDraw) +{ +return pDC->dependentFE && IDComparesLess(lastRetiredDraw, pDC->drawId - 1); +} + // /// @brief Update client stats. INLINE void UpdateClientStats(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONTEXT* pDC) @@ -595,6 +600,7 @@ INLINE void CompleteDrawFE(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONTEX // Ensure all streaming writes are globally visible before marking this FE done _mm_mfence(); pDC->doneFE = true; + InterlockedDecrement((volatile LONG*)>drawsOutstandingFE); } @@ -606,7 +612,7 @@ void WorkOnFifoFE(SWR_CONTEXT *pContext, uint32_t workerId, uint32_t ) { uint32_t dcSlot = curDrawFE % KNOB_MAX_DRAWS_IN_FLIGHT; DRAW_CONTEXT *pDC = >dcRing[dcSlot]; -if (pDC->isCompute || pDC->doneFE || pDC->FeLock) +if (pDC->isCompute || pDC->doneFE) { CompleteDrawContextInl(pContext, workerId, pDC); curDrawFE++; @@ -617,6 +623,7 @@ void WorkOnFifoFE(SWR_CONTEXT *pContext, uint32_t workerId, uint32_t ) } } +uint32_t lastRetiredFE = curDrawFE - 1; uint32_t curDraw = curDrawFE; while (IDComparesLess(curDraw, drawEnqueued)) { @@ -625,6 +632,11 @@ void WorkOnFifoFE(SWR_CONTEXT *pContext, uint32_t workerId, uint32_t ) if (!pDC->isCompute && !pDC->FeLock) { +if (CheckDependencyFE(pContext, pDC, lastRetiredFE)) +{ +return; +} + uint32_t initial = InterlockedCompareExchange((volatile uint32_t*)>FeLock, 1, 0); if (initial == 0) { -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/5] swr: [rasterizer archrast] Add thread tags to event files.
This allows the post-processor to easily detect the API thread and to process frame information. The frame information is needed to optimized how data is processed from worker threads. --- src/gallium/drivers/swr/rasterizer/archrast/events.proto | 8 src/gallium/drivers/swr/rasterizer/core/api.cpp | 8 +--- src/gallium/drivers/swr/rasterizer/scripts/gen_archrast.py| 5 + .../drivers/swr/rasterizer/scripts/templates/ar_event_h.template | 3 ++- .../rasterizer/scripts/templates/ar_eventhandlerfile_h.template | 4 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/archrast/events.proto b/src/gallium/drivers/swr/rasterizer/archrast/events.proto index 4ddb7c9..107d7a3 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/events.proto +++ b/src/gallium/drivers/swr/rasterizer/archrast/events.proto @@ -97,6 +97,14 @@ event End uint32_t count; }; +event ThreadStartApiEvent +{ +}; + +event ThreadStartWorkerEvent +{ +}; + event DrawInstancedEvent { uint32_t drawId; diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp index 2269240..e67ede2 100644 --- a/src/gallium/drivers/swr/rasterizer/core/api.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp @@ -112,10 +112,11 @@ HANDLE SwrCreateContext( pContext->ppScratch = new uint8_t*[pContext->NumWorkerThreads]; pContext->pStats = new SWR_STATS[pContext->NumWorkerThreads]; -#if KNOB_ENABLE_AR +#if defined(KNOB_ENABLE_AR) // Setup ArchRast thread contexts which includes +1 for API thread. pContext->pArContext = new HANDLE[pContext->NumWorkerThreads+1]; pContext->pArContext[pContext->NumWorkerThreads] = ArchRast::CreateThreadContext(); +_AR_EVENT(pContext->pArContext[pContext->NumWorkerThreads], ThreadStartApiEvent()); #endif // Allocate scratch space for workers. @@ -133,9 +134,10 @@ HANDLE SwrCreateContext( pContext->ppScratch[i] = (uint8_t*)AlignedMalloc(32 * sizeof(KILOBYTE), KNOB_SIMD_WIDTH * 4); #endif -#if KNOB_ENABLE_AR +#if defined(KNOB_ENABLE_AR) // Initialize worker thread context for ArchRast. pContext->pArContext[i] = ArchRast::CreateThreadContext(); +_AR_EVENT(pContext->pArContext[i], ThreadStartWorkerEvent()); #endif } @@ -383,7 +385,7 @@ void SwrDestroyContext(HANDLE hContext) AlignedFree(pContext->ppScratch[i]); #endif -#if KNOB_ENABLE_AR +#if defined(KNOB_ENABLE_AR) ArchRast::DestroyThreadContext(pContext->pArContext[i]); #endif } diff --git a/src/gallium/drivers/swr/rasterizer/scripts/gen_archrast.py b/src/gallium/drivers/swr/rasterizer/scripts/gen_archrast.py index 1b89a91..901d6d8 100644 --- a/src/gallium/drivers/swr/rasterizer/scripts/gen_archrast.py +++ b/src/gallium/drivers/swr/rasterizer/scripts/gen_archrast.py @@ -49,6 +49,8 @@ def parse_event_fields(lines, idx, event_dict): field_types = [] end_of_event = False +num_fields = 0 + # record all fields in event definition. # note: we don't check if there's a leading brace. while not end_of_event and idx < len(lines): @@ -60,11 +62,14 @@ def parse_event_fields(lines, idx, event_dict): if field: field_types.append(field.group(2)) field_names.append(field.group(4)) +num_fields += 1 end_of_event = re.match(r"(\s*)};", line) event_dict['field_types'] = field_types event_dict['field_names'] = field_names +event_dict['num_fields'] = num_fields + return idx def parse_enums(lines, idx, event_dict): diff --git a/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_event_h.template b/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_event_h.template index e5c94c7..b0e6796 100644 --- a/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_event_h.template +++ b/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_event_h.template @@ -86,9 +86,10 @@ namespace ArchRast ${field_types[i]} ${field_names[i]}, % endif % if i == len(field_names)-1: -${field_types[i]} ${field_names[i]}) +${field_types[i]} ${field_names[i]} % endif % endfor +) { % for i in range(len(field_names)): data.${field_names[i]} = ${field_names[i]}; diff --git a/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_eventhandlerfile_h.template b/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_eventhandlerfile_h.template index 1924b15..6a62f17 100644 --- a/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_eventhandlerfile_h.template +++ b/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_eventhandlerfile_h.template @@ -83,7 +83,11 @@ namespace ArchRast % for name in protos['event_names']: virtual void handle(${name}& event) { +% if
[Mesa-dev] [PATCH 2/5] swr: [rasterizer core] Remove deprecated simd intrinsics
Used in abandoned all-or-nothing approach to converting to AVX512 --- .../drivers/swr/rasterizer/common/simdintrin.h | 633 - .../drivers/swr/rasterizer/core/format_types.h | 189 -- src/gallium/drivers/swr/rasterizer/core/knobs.h| 5 - src/gallium/drivers/swr/rasterizer/core/utils.h| 164 +- 4 files changed, 1 insertion(+), 990 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/common/simdintrin.h b/src/gallium/drivers/swr/rasterizer/common/simdintrin.h index 7671031..10c0955 100644 --- a/src/gallium/drivers/swr/rasterizer/common/simdintrin.h +++ b/src/gallium/drivers/swr/rasterizer/common/simdintrin.h @@ -36,30 +36,6 @@ typedef __m256 simdscalar; typedef __m256i simdscalari; typedef uint8_t simdmask; -#elif KNOB_SIMD_WIDTH == 16 -#if ENABLE_AVX512_EMULATION -struct simdscalar -{ -__m256 lo; -__m256 hi; -}; -struct simdscalard -{ -__m256d lo; -__m256d hi; -}; -struct simdscalari -{ -__m256i lo; -__m256i hi; -}; -typedef uint16_t simdmask; -#else -typedef __m512 simdscalar; -typedef __m512d simdscalard; -typedef __m512i simdscalari; -typedef __mask16 simdmask; -#endif #else #error Unsupported vector width #endif @@ -655,615 +631,6 @@ void _simdvec_transpose(simdvector ) SWR_ASSERT(false, "Need to implement 8 wide version"); } -#elif KNOB_SIMD_WIDTH == 16 - -#if ENABLE_AVX512_EMULATION - -#define SIMD_EMU_AVX512_0(type, func, intrin) \ -INLINE type func()\ -{\ -type result;\ -\ -result.lo = intrin();\ -result.hi = intrin();\ -\ -return result;\ -} - -#define SIMD_EMU_AVX512_1(type, func, intrin) \ -INLINE type func(type a)\ -{\ -type result;\ -\ -result.lo = intrin(a.lo);\ -result.hi = intrin(a.hi);\ -\ -return result;\ -} - -#define SIMD_EMU_AVX512_2(type, func, intrin) \ -INLINE type func(type a, type b)\ -{\ -type result;\ -\ -result.lo = intrin(a.lo, b.lo);\ -result.hi = intrin(a.hi, b.hi);\ -\ -return result;\ -} - -#define SIMD_EMU_AVX512_3(type, func, intrin) \ -INLINE type func(type a, type b, type c)\ -{\ -type result;\ -\ -result.lo = intrin(a.lo, b.lo, c.lo);\ -result.hi = intrin(a.hi, b.hi, c.hi);\ -\ -return result;\ -} - -SIMD_EMU_AVX512_0(simdscalar, _simd_setzero_ps, _mm256_setzero_ps) -SIMD_EMU_AVX512_0(simdscalari, _simd_setzero_si, _mm256_setzero_si256) - -INLINE simdscalar _simd_set1_ps(float a) -{ -simdscalar result; - -result.lo = _mm256_set1_ps(a); -result.hi = _mm256_set1_ps(a); - -return result; -} - -INLINE simdscalari _simd_set1_epi8(char a) -{ -simdscalari result; - -result.lo = _mm256_set1_epi8(a); -result.hi = _mm256_set1_epi8(a); - -return result; -} - -INLINE simdscalari _simd_set1_epi32(int a) -{ -simdscalari result; - -result.lo = _mm256_set1_epi32(a); -result.hi = _mm256_set1_epi32(a); - -return result; -} - -INLINE simdscalari _simd_set_epi32(int e7, int e6, int e5, int e4, int e3, int e2, int e1, int e0) -{ -simdscalari result; - -result.lo = _mm256_set_epi32(e7, e6, e5, e4, e3, e2, e1, e0); -result.hi = _mm256_set_epi32(e7, e6, e5, e4, e3, e2, e1, e0); - -return result; -} - -INLINE simdscalari _simd_set_epi32(int e15, int e14, int e13, int e12, int e11, int e10, int e9, int e8, int e7, int e6, int e5, int e4, int e3, int e2, int e1, int e0) -{ -simdscalari result; - -result.lo = _mm256_set_epi32(e7, e6, e5, e4, e3, e2, e1, e0); -result.hi = _mm256_set_epi32(e15, e14, e13, e12, e11, e10, e9, e8); - -return result; -} - -INLINE simdscalar _simd_load_ps(float const *m) -{ -float const *n = reinterpret_cast(reinterpret_cast(m) + sizeof(simdscalar::lo)); - -simdscalar result; - -result.lo = _mm256_load_ps(m); -result.hi = _mm256_load_ps(n); - -return result; -} - -INLINE simdscalar _simd_loadu_ps(float const *m) -{ -float const *n = reinterpret_cast(reinterpret_cast(m) + sizeof(simdscalar::lo)); - -simdscalar result; - -result.lo = _mm256_loadu_ps(m); -result.hi = _mm256_loadu_ps(n); - -return result; -} - -INLINE simdscalar _simd_load1_ps(float const *m) -{ -simdscalar result; - -result.lo = _mm256_broadcast_ss(m); -result.hi = _mm256_broadcast_ss(m); - -return result; -} - -INLINE simdscalari _simd_load_si(simdscalari const *m) -{ -simdscalari result; - -result.lo = _mm256_load_si256([0].lo); -result.hi = _mm256_load_si256([0].hi); - -return result; -} - -INLINE simdscalari _simd_loadu_si(simdscalari const *m) -{ -simdscalari result; - -result.lo = _mm256_loadu_si256([0].lo); -result.hi = _mm256_loadu_si256([0].hi); - -return result; -} - -INLINE simdscalar _simd_broadcast_ss(float const *m) -{ -simdscalar result; - -result.lo = _mm256_broadcast_ss(m); -result.hi = _mm256_broadcast_ss(m); - -return result; -} - -INLINE simdscalar _simd_broadcast_ps(__m128 const *m) -{ -simdscalar result; - -result.lo =
[Mesa-dev] [PATCH 3/5] swr: [rasterizer core] Refactor/cleanup backends
Used for common code reuse and simplification --- .../drivers/swr/rasterizer/core/backend.cpp| 561 - src/gallium/drivers/swr/rasterizer/core/backend.h | 150 +- 2 files changed, 351 insertions(+), 360 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/backend.cpp b/src/gallium/drivers/swr/rasterizer/core/backend.cpp index f71c2b2..3b22892 100644 --- a/src/gallium/drivers/swr/rasterizer/core/backend.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/backend.cpp @@ -451,134 +451,95 @@ void BackendSingleSample(DRAW_CONTEXT *pDC, uint32_t workerId, uint32_t x, uint3 AR_BEGIN(BESingleSampleBackend, pDC->drawId); AR_BEGIN(BESetup, pDC->drawId); -const API_STATE& state = GetApiState(pDC); -const SWR_RASTSTATE& rastState = state.rastState; -const SWR_PS_STATE *pPSState = -const SWR_BLEND_STATE *pBlendState = -uint64_t coverageMask = work.coverageMask[0]; +const API_STATE = GetApiState(pDC); -// broadcast scalars BarycentricCoeffs coeffs; -coeffs.vIa = _simd_broadcast_ss([0]); -coeffs.vIb = _simd_broadcast_ss([1]); -coeffs.vIc = _simd_broadcast_ss([2]); - -coeffs.vJa = _simd_broadcast_ss([0]); -coeffs.vJb = _simd_broadcast_ss([1]); -coeffs.vJc = _simd_broadcast_ss([2]); - -coeffs.vZa = _simd_broadcast_ss([0]); -coeffs.vZb = _simd_broadcast_ss([1]); -coeffs.vZc = _simd_broadcast_ss([2]); +SetupBarycentricCoeffs(, work); -coeffs.vRecipDet = _simd_broadcast_ss(); +uint8_t *pColorBuffer[SWR_NUM_RENDERTARGETS], *pDepthBuffer, *pStencilBuffer; +SetupRenderBuffers(pColorBuffer, , , state.psState.numRenderTargets, renderBuffers); -coeffs.vAOneOverW = _simd_broadcast_ss([0]); -coeffs.vBOneOverW = _simd_broadcast_ss([1]); -coeffs.vCOneOverW = _simd_broadcast_ss([2]); +SWR_PS_CONTEXT psContext; +SetupPixelShaderContext(, work); -uint8_t *pColorBase[SWR_NUM_RENDERTARGETS]; -uint32_t NumRT = state.psState.numRenderTargets; -for(uint32_t rt = 0; rt < NumRT; ++rt) -{ -pColorBase[rt] = renderBuffers.pColor[rt]; -} -uint8_t *pDepthBase = renderBuffers.pDepth, *pStencilBase = renderBuffers.pStencil; AR_END(BESetup, 1); -SWR_PS_CONTEXT psContext; -psContext.pAttribs = work.pAttribs; -psContext.pPerspAttribs = work.pPerspAttribs; -psContext.frontFace = work.triFlags.frontFacing; -psContext.primID = work.triFlags.primID; - -// save Ia/Ib/Ic and Ja/Jb/Jc if we need to reevaluate i/j/k in the shader because of pull attribs -psContext.I = work.I; -psContext.J = work.J; -psContext.recipDet = work.recipDet; -psContext.pRecipW = work.pRecipW; -psContext.pSamplePosX = (const float*)::MultisampleT::samplePosX; -psContext.pSamplePosY = (const float*)::MultisampleT::samplePosY; -psContext.rasterizerSampleCount = T::MultisampleT::numSamples; +psContext.vY.UL = _simd_add_ps(vULOffsetsY, _simd_set1_ps(static_cast(y))); +psContext.vY.center = _simd_add_ps(vCenterOffsetsY, _simd_set1_ps(static_cast(y))); -for(uint32_t yy = y; yy < y + KNOB_TILE_Y_DIM; yy += SIMD_TILE_Y_DIM) +const simdscalar dy = _simd_set1_ps(static_cast(SIMD_TILE_Y_DIM)); + +for (uint32_t yy = y; yy < y + KNOB_TILE_Y_DIM; yy += SIMD_TILE_Y_DIM) { -// UL pixel corner -psContext.vY.UL = _simd_add_ps(vULOffsetsY, _simd_set1_ps((float)yy)); -// pixel center -psContext.vY.center = _simd_add_ps(vCenterOffsetsY, _simd_set1_ps((float)yy)); +psContext.vX.UL = _simd_add_ps(vULOffsetsX, _simd_set1_ps(static_cast(x))); +psContext.vX.center = _simd_add_ps(vCenterOffsetsX, _simd_set1_ps(static_cast(x))); -for(uint32_t xx = x; xx < x + KNOB_TILE_X_DIM; xx += SIMD_TILE_X_DIM) +const simdscalar dx = _simd_set1_ps(static_cast(SIMD_TILE_X_DIM)); + +for (uint32_t xx = x; xx < x + KNOB_TILE_X_DIM; xx += SIMD_TILE_X_DIM) { #if USE_8x2_TILE_BACKEND const bool useAlternateOffset = ((xx & SIMD_TILE_X_DIM) != 0); #endif -if(coverageMask & MASK) +simdmask coverageMask = work.coverageMask[0] & MASK; + +if (coverageMask) { -psContext.vX.UL = _simd_add_ps(vULOffsetsX, _simd_set1_ps((float)xx)); -// pixel center -psContext.vX.center = _simd_add_ps(vCenterOffsetsX, _simd_set1_ps((float)xx)); +if (state.depthHottileEnable && state.depthBoundsState.depthBoundsTestEnable) +{ +static_assert(KNOB_DEPTH_HOT_TILE_FORMAT == R32_FLOAT, "Unsupported depth hot tile format"); + +const simdscalar z = _simd_load_ps(reinterpret_cast(pDepthBuffer)); -if(T::InputCoverage != SWR_INPUT_COVERAGE_NONE) +const float minz = state.depthBoundsState.depthBoundsTestMinValue; +const float maxz =
[Mesa-dev] [PATCH 5/5] swr: [rasterizer] added EventHandlerFile contructor
--- .../rasterizer/scripts/templates/ar_eventhandlerfile_h.template| 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_eventhandlerfile_h.template b/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_eventhandlerfile_h.template index 6a62f17..5310bf5 100644 --- a/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_eventhandlerfile_h.template +++ b/src/gallium/drivers/swr/rasterizer/scripts/templates/ar_eventhandlerfile_h.template @@ -60,7 +60,12 @@ namespace ArchRast sprintf(buf, "%s\\ar_event%d_%d.bin", outDir.str().c_str(), GetCurrentThreadId(), id); mFilename = std::string(buf); #else -SWR_ASSERT(0); +char buf[255]; +// There could be multiple threads creating thread pools. We +// want to make sure they are uniquly identified by adding in +// the creator's thread id into the filename. +sprintf(buf, "%s/ar_event%d_%d.bin", "/tmp", GetCurrentThreadId(), id); +mFilename = std::string(buf); #endif } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/3] swr: Support windows builds
- Added SConscript files - better handling of NOMINMAX for inclusion - Reorder header files in swr_context.cpp to handle NOMINMAX better, since mesa header files include windows.h before we get a chance to #define NOMINMAX - cleaner support for .dll and .so prefix/suffix across OSes - added PUBLIC for some protos - added swr_gdi_swap() which is call from libgl_gdi.c --- src/gallium/drivers/swr/Makefile.am| 8 ++ src/gallium/drivers/swr/SConscript | 46 +++ src/gallium/drivers/swr/SConscript-arch| 175 + src/gallium/drivers/swr/rasterizer/common/os.h | 5 +- src/gallium/drivers/swr/swr_context.cpp| 16 +-- src/gallium/drivers/swr/swr_context.h | 2 + src/gallium/drivers/swr/swr_loader.cpp | 37 +- src/gallium/drivers/swr/swr_public.h | 11 +- src/gallium/drivers/swr/swr_screen.cpp | 25 +--- 9 files changed, 291 insertions(+), 34 deletions(-) create mode 100644 src/gallium/drivers/swr/SConscript create mode 100644 src/gallium/drivers/swr/SConscript-arch diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am index dd1c2e6..0ec4af2 --- a/src/gallium/drivers/swr/Makefile.am +++ b/src/gallium/drivers/swr/Makefile.am @@ -217,6 +217,12 @@ libswrAVX2_la_CXXFLAGS = \ libswrAVX2_la_SOURCES = \ $(COMMON_SOURCES) +# XXX: $(SWR_AVX_CXXFLAGS) should not be included, but we end up including +# simdintrin.h, which throws a warning if AVX is not enabled +libmesaswr_la_CXXFLAGS = \ + $(COMMON_CXXFLAGS) \ + $(SWR_AVX_CXXFLAGS) + # XXX: Don't ship these generated sources for now, since they are specific # to the LLVM version they are generated from. Thus a release tarball # containing the said files, generated against eg. LLVM 3.8 will fail to build @@ -235,6 +241,8 @@ libswrAVX2_la_LDFLAGS = \ include $(top_srcdir)/install-gallium-links.mk EXTRA_DIST = \ + SConscipt \ + SConscript-arch \ rasterizer/archrast/events.proto \ rasterizer/jitter/scripts/gen_llvm_ir_macros.py \ rasterizer/jitter/scripts/gen_llvm_types.py \ diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript new file mode 100644 index 000..c470bbd --- /dev/null +++ b/src/gallium/drivers/swr/SConscript @@ -0,0 +1,46 @@ +Import('*') + +from sys import executable as python_cmd +import distutils.version +import os.path + +if not 'swr' in COMMAND_LINE_TARGETS: +Return() + +if not env['llvm']: +print 'warning: LLVM disabled: not building swr' +Return() + +env.MSVC2013Compat() + +swr_arch = 'avx' +VariantDir('avx', '.', duplicate=0) +SConscript('avx/SConscript-arch', exports='swr_arch') + +swr_arch = 'avx2' +VariantDir('avx2', '.', duplicate=0) +SConscript('avx2/SConscript-arch', exports='swr_arch') + +env = env.Clone() + +source = env.ParseSourceList('Makefile.sources', [ +'LOADER_SOURCES' +]) + +env.Prepend(CPPPATH = [ +'rasterizer/scripts' +]) + +swr = env.ConvenienceLibrary( + target = 'swr', + source = source, + ) +# treat arch libs as dependencies, even though they are not linked +# into swr, so we don't have to build them separately +Depends(swr, ['swrAVX', 'swrAVX2']) + +env.Alias('swr', swr) + +env.Prepend(LIBS = [swr]) + +Export('swr') diff --git a/src/gallium/drivers/swr/SConscript-arch b/src/gallium/drivers/swr/SConscript-arch new file mode 100644 index 000..f7d5b5a --- /dev/null +++ b/src/gallium/drivers/swr/SConscript-arch @@ -0,0 +1,175 @@ +Import('*') + +from sys import executable as python_cmd +import distutils.version +import os.path + +if not env['llvm']: +print 'warning: LLVM disabled: not building swr' +Return() + +Import('swr_arch') + +# construct llvm include dir +llvm_includedir = os.path.join(os.environ['LLVM'], 'include') + +# get path for arch-specific build-path. +# That's where generated files reside. +build_path = Dir('.').abspath + +env.Prepend(CPPPATH = [ +build_path + '/.', +build_path + '/rasterizer', +build_path + '/rasterizer/core', +build_path + '/rasterizer/jitter', +build_path + '/rasterizer/scripts', +build_path + '/rasterizer/archrast' +]) + +env = env.Clone() + +env.MSVC2013Compat() + +env.Append(CPPDEFINES = [ + '__STDC_CONSTANT_MACROS', + '__STDC_LIMIT_MACROS' + ]) + +if not env['msvc'] : +env.Append(CCFLAGS = [ +'-std=c++11', +]) + +swrroot = '#src/gallium/drivers/swr/' + +env.CodeGenerate( +target = 'rasterizer/scripts/gen_knobs.cpp', +script = swrroot + 'rasterizer/scripts/gen_knobs.py', +source = [], +command = python_cmd + ' $SCRIPT ' + Dir('rasterizer/scripts').abspath +#command = python_cmd + ' $SCRIPT ' + 'rasterizer/scripts' +) + +env.CodeGenerate( +target = 'rasterizer/scripts/gen_knobs.h', +script = swrroot + 'rasterizer/scripts/gen_knobs.py', +source = [], +command = python_cmd + ' $SCRIPT ' +
[Mesa-dev] [PATCH 2/3] mesa: added msvc HAS_TRIVIAL_DESTRUCTOR implementation
not having it on windows causes a CANARY assertion in src/util/ralloc.c:get_header() Tested only on MSVC 19.00 (DevStudio 14.0), so #ifdef guards reflect that. --- src/util/macros.h | 5 + 1 file changed, 5 insertions(+) diff --git a/src/util/macros.h b/src/util/macros.h index 27d1b62..12b26d3 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -175,6 +175,11 @@ do { \ # if __has_feature(has_trivial_destructor) # define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) # endif +# elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) +# if _MSC_VER >= 1900 +# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) +# else +# endif # endif # ifndef HAS_TRIVIAL_DESTRUCTOR /* It's always safe (if inefficient) to assume that a -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] gallium/scons: OpenSWR Windows support
- Added code to create screen and handle swaps in libgl_gdi.c - Added call to swr SConscript - included llvm 3.9 support for scons (windows swr only support 3.9 and later) - include -DHAVE_SWR to subdirs that need it To buils SWR on windows, use "scons swr libgl-gdi" --- scons/llvm.py | 21 +++-- src/gallium/SConscript| 1 + src/gallium/targets/libgl-gdi/SConscript | 4 src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 +++- src/gallium/targets/libgl-xlib/SConscript | 4 src/gallium/targets/osmesa/SConscript | 4 6 files changed, 55 insertions(+), 7 deletions(-) diff --git a/scons/llvm.py b/scons/llvm.py index 1fc8a3f..977e47a 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -106,7 +106,24 @@ def generate(env): ]) env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) # LIBS should match the output of `llvm-config --libs engine mcjit bitwriter x86asmprinter` -if llvm_version >= distutils.version.LooseVersion('3.7'): +if llvm_version >= distutils.version.LooseVersion('3.9'): +env.Prepend(LIBS = [ +'LLVMX86Disassembler', 'LLVMX86AsmParser', +'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', +'LLVMDebugInfoCodeView', 'LLVMCodeGen', +'LLVMScalarOpts', 'LLVMInstCombine', +'LLVMInstrumentation', 'LLVMTransformUtils', +'LLVMBitWriter', 'LLVMX86Desc', +'LLVMMCDisassembler', 'LLVMX86Info', +'LLVMX86AsmPrinter', 'LLVMX86Utils', +'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', +'LLVMAnalysis', 'LLVMProfileData', +'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', +'LLVMBitReader', 'LLVMMC', 'LLVMCore', +'LLVMSupport', +'LLVMIRReader', 'LLVMASMParser' +]) +elif llvm_version >= distutils.version.LooseVersion('3.7'): env.Prepend(LIBS = [ 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', @@ -203,7 +220,7 @@ def generate(env): if '-fno-rtti' in cxxflags: env.Append(CXXFLAGS = ['-fno-rtti']) -components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler'] +components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler', 'irreader'] env.ParseConfig('llvm-config --libs ' + ' '.join(components)) env.ParseConfig('llvm-config --ldflags') diff --git a/src/gallium/SConscript b/src/gallium/SConscript index f98268f..9273db7 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -18,6 +18,7 @@ SConscript([ 'drivers/softpipe/SConscript', 'drivers/svga/SConscript', 'drivers/trace/SConscript', +'drivers/swr/SConscript', ]) # diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 2a52363..ef8050b 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -30,6 +30,10 @@ if env['llvm']: env.Append(CPPDEFINES = 'HAVE_LLVMPIPE') drivers += [llvmpipe] +if 'swr' in COMMAND_LINE_TARGETS : +env.Append(CPPDEFINES = 'HAVE_SWR') +drivers += [swr] + if env['gcc'] and env['machine'] != 'x86_64': # DEF parser in certain versions of MinGW is busted, as does not behave as # MSVC. mingw-w64 works fine. diff --git a/src/gallium/targets/libgl-gdi/libgl_gdi.c b/src/gallium/targets/libgl-gdi/libgl_gdi.c index 922c186..12576db 100644 --- a/src/gallium/targets/libgl-gdi/libgl_gdi.c +++ b/src/gallium/targets/libgl-gdi/libgl_gdi.c @@ -51,9 +51,12 @@ #include "llvmpipe/lp_public.h" #endif +#ifdef HAVE_SWR +#include "swr/swr_public.h" +#endif static boolean use_llvmpipe = FALSE; - +static boolean use_swr = FALSE; static struct pipe_screen * gdi_screen_create(void) @@ -69,6 +72,8 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE default_driver = "llvmpipe"; +#elif HAVE_SWR + default_driver = "swr"; #else default_driver = "softpipe"; #endif @@ -78,15 +83,21 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE if (strcmp(driver, "llvmpipe") == 0) { screen = llvmpipe_create_screen( winsys ); + if (screen) + use_llvmpipe = TRUE; + } +#endif +#ifdef HAVE_SWR + if (strcmp(driver, "swr") == 0) { + screen = swr_create_screen( winsys ); + if (screen) + use_swr = TRUE; } -#else - (void) driver; #endif + (void) driver; if (screen == NULL) { screen = softpipe_create_screen( winsys ); - } else { - use_llvmpipe = TRUE; } if(!screen) @@ -128,6 +139,13 @@ gdi_present(struct pipe_screen *screen, } #endif +#ifdef HAVE_SWR + if (use_swr) { +
[Mesa-dev] [PATCH 0/3] swr: Support Windows builds
Changes to support windows builds for OpenSWR driver. These are divided into 3 patches: - scons and core mesa-related changes - a fix in macros.h to implement HAS_TRIVIAL_DESTRUCTOR - swr-specific changes The way to build SWR on windows is using scons. Build using the following command line: "scons swr libgl-gdi". This will produce 3 .dlls. The (main) opengl32.dll, and 2 swr-specific dlls that are loaded dynamically at runtime depending on the underlying architecture (swrAVX.dll and swrAVX2.dll). The default software renderer is llvmpipe, and, like on linux, you enable SWR by setting the GALLIUM_DRIVER variable to "swr". George Kyriazis (3): gallium/scons: OpenSWR Windows support mesa: added msvc HAS_TRIVIAL_DESTRUCTOR implementation swr: Support windows builds scons/llvm.py | 21 ++- src/gallium/SConscript | 1 + src/gallium/drivers/swr/Makefile.am| 8 ++ src/gallium/drivers/swr/SConscript | 46 +++ src/gallium/drivers/swr/SConscript-arch| 175 + src/gallium/drivers/swr/rasterizer/common/os.h | 5 +- src/gallium/drivers/swr/swr_context.cpp| 16 +-- src/gallium/drivers/swr/swr_context.h | 2 + src/gallium/drivers/swr/swr_loader.cpp | 37 +- src/gallium/drivers/swr/swr_public.h | 11 +- src/gallium/drivers/swr/swr_screen.cpp | 25 +--- src/gallium/targets/libgl-gdi/SConscript | 4 + src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 +++- src/gallium/targets/libgl-xlib/SConscript | 4 + src/gallium/targets/osmesa/SConscript | 4 + src/util/macros.h | 5 + 16 files changed, 351 insertions(+), 41 deletions(-) create mode 100644 src/gallium/drivers/swr/SConscript create mode 100644 src/gallium/drivers/swr/SConscript-arch -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 2/8] scons: ignore .hpp files in parse_source_list()
Drivers that contain C++ .hpp files need to ignore them too, along with .h files, when building source file lists. --- scons/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scons/custom.py b/scons/custom.py index bdb4039..544b15d 100644 --- a/scons/custom.py +++ b/scons/custom.py @@ -281,7 +281,7 @@ def parse_source_list(env, filename, names=None): # cause duplicate actions. f = f[len(cur_srcdir + '/'):] # do not include any headers -if f.endswith('.h'): +if f.endswith(tuple(['.h','.hpp'])): continue srcs.append(f) -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 5/8] gallium scons: Added swr driver to scons
Enable swr builds by "scons swr=1 libgl-gdi" (windows only) --- src/gallium/SConscript | 1 + src/gallium/drivers/swr/SConscript | 199 + 2 files changed, 200 insertions(+) create mode 100644 src/gallium/drivers/swr/SConscript diff --git a/src/gallium/SConscript b/src/gallium/SConscript index f98268f..9273db7 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -18,6 +18,7 @@ SConscript([ 'drivers/softpipe/SConscript', 'drivers/svga/SConscript', 'drivers/trace/SConscript', +'drivers/swr/SConscript', ]) # diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript new file mode 100644 index 000..afd3d12 --- /dev/null +++ b/src/gallium/drivers/swr/SConscript @@ -0,0 +1,199 @@ +Import('*') + +from sys import executable as python_cmd +import os.path +import SCons.Script.SConscript + +if 'swr' in SCons.Script.ARGUMENTS and not SCons.Script.ARGUMENTS['swr']: +Return() + +if not env['llvm']: +print 'warning: LLVM disabled: not building swr' +Return() + + +env.MSVC2013Compat() + +env = env.Clone() + +# construct llvm include dir +llvm_includedir = os.path.join(os.environ['LLVM'], 'include') + +# the loader is included in the mesa lib itself +# All the remaining files are in loadable modules +loadersource = env.ParseSourceList('Makefile.sources', [ +'LOADER_SOURCES' +]) + +env.Append(CPPDEFINES = [ +'__STDC_CONSTANT_MACROS', +'__STDC_LIMIT_MACROS' +]) + +if not env['msvc'] : +env.Append(CCFLAGS = [ +'-std=c++11', +]) + +swrroot = '#src/gallium/drivers/swr/' + +env.CodeGenerate( +target = 'rasterizer/scripts/gen_knobs.cpp', +script = swrroot + 'rasterizer/scripts/gen_knobs.py', +source = [], +command = python_cmd + ' $SCRIPT ' + Dir('rasterizer/scripts').abspath +) + +env.CodeGenerate( +target = 'rasterizer/scripts/gen_knobs.h', +script = swrroot + 'rasterizer/scripts/gen_knobs.py', +source = [], +command = python_cmd + ' $SCRIPT ' + Dir('rasterizer/scripts').abspath +) + +env.CodeGenerate( +target = 'rasterizer/jitter/state_llvm.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py', +source = 'rasterizer/core/state.h', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_gen.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'), +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_gen.cpp', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'), +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_x86.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = '', +command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_h' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_x86.cpp', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = '', +command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_cpp' +) + +env.CodeGenerate( +target = 'swr_context_llvm.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py', +source = 'swr_context.h', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET' +) + +env.CodeGenerate( +target = 'rasterizer/archrast/gen_ar_event.h', +script = swrroot + 'rasterizer/scripts/gen_archrast.py', +source = 'rasterizer/archrast/events.proto', +command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_h' +) + +env.CodeGenerate( +target = 'rasterizer/archrast/gen_ar.event.cpp', +script = swrroot + 'rasterizer/scripts/gen_archrast.py', +source = 'rasterizer/archrast/events.proto', +command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen-event_cpp' +) + +env.CodeGenerate( +target = 'rasterizer/archrast/gen_ar_eventhandler.h', +script = swrroot + 'rasterizer/scripts/gen_archrast.py', +source = 'rasterizer/archrast/events.proto', +command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandler_h' +) + +env.CodeGenerate( +target = 'rasterizer/archrast/gen_ar_eventhandlerfile.h', +script = swrroot + 'rasterizer/scripts/gen_archrast.py', +source = 'rasterizer/archrast/events.proto', +command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandlerfile_h' +) + +source = [ +'rasterizer/scripts/gen_knobs.cpp', +'rasterizer/jitter/builder_gen.cpp', +'rasterizer/jitter/builder_x86.cpp', +] + +source += env.ParseSourceList(swrroot + 'Makefile.sources',
[Mesa-dev] [PATCH v2 7/8] swr: Added swr windows support
- moving some header files around for proper inclusion of windows.h - OS agnostic loading of arch-specific loadable modules - PUBLIC function declaration - better handling on NOMINMAX around windows.h inclusion. --- src/gallium/drivers/swr/rasterizer/common/os.h | 5 - src/gallium/drivers/swr/swr_context.cpp| 16 +++ src/gallium/drivers/swr/swr_context.h | 2 ++ src/gallium/drivers/swr/swr_loader.cpp | 28 +++--- src/gallium/drivers/swr/swr_public.h | 11 ++ src/gallium/drivers/swr/swr_screen.cpp | 25 +++ 6 files changed, 53 insertions(+), 34 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/common/os.h b/src/gallium/drivers/swr/rasterizer/common/os.h index ac52b60..28e7ff5 100644 --- a/src/gallium/drivers/swr/rasterizer/common/os.h +++ b/src/gallium/drivers/swr/rasterizer/common/os.h @@ -33,8 +33,11 @@ #ifndef NOMINMAX #define NOMINMAX -#endif #include +#undef NOMINMAX +#else +#include +#endif #include #include diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index cbc60e0..27273e0 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -21,6 +21,14 @@ * IN THE SOFTWARE. ***/ +#include "swr_context.h" +#include "swr_memory.h" +#include "swr_screen.h" +#include "swr_resource.h" +#include "swr_scratch.h" +#include "swr_query.h" +#include "swr_fence.h" + #include "util/u_memory.h" #include "util/u_inlines.h" #include "util/u_format.h" @@ -31,14 +39,6 @@ extern "C" { #include "util/u_surface.h" } -#include "swr_context.h" -#include "swr_memory.h" -#include "swr_screen.h" -#include "swr_resource.h" -#include "swr_scratch.h" -#include "swr_query.h" -#include "swr_fence.h" - #include "api.h" #include "backend.h" diff --git a/src/gallium/drivers/swr/swr_context.h b/src/gallium/drivers/swr/swr_context.h index eecfe0d..04e11fe 100644 --- a/src/gallium/drivers/swr/swr_context.h +++ b/src/gallium/drivers/swr/swr_context.h @@ -24,6 +24,8 @@ #ifndef SWR_CONTEXT_H #define SWR_CONTEXT_H +#include "common/os.h" + #include "pipe/p_context.h" #include "pipe/p_state.h" #include "util/u_blitter.h" diff --git a/src/gallium/drivers/swr/swr_loader.cpp b/src/gallium/drivers/swr/swr_loader.cpp index 2113c37..4f3329e 100644 --- a/src/gallium/drivers/swr/swr_loader.cpp +++ b/src/gallium/drivers/swr/swr_loader.cpp @@ -25,14 +25,17 @@ #include "util/u_dl.h" #include "swr_public.h" +#include "swr_screen.h" +#include "swr_resource.h" + #include -#include typedef pipe_screen *(*screen_create_proc)(struct sw_winsys *winsys); struct pipe_screen * swr_create_screen(struct sw_winsys *winsys) { + char filename[256]; fprintf(stderr, "SWR detected "); util_dl_library *pLibrary = nullptr; @@ -40,14 +43,15 @@ swr_create_screen(struct sw_winsys *winsys) util_cpu_detect(); if (util_cpu_caps.has_avx2) { fprintf(stderr, "AVX2\n"); - pLibrary = util_dl_open("libswrAVX2.so"); + sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX2", UTIL_DL_EXT); } else if (util_cpu_caps.has_avx) { fprintf(stderr, "AVX\n"); - pLibrary = util_dl_open("libswrAVX.so"); + sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX", UTIL_DL_EXT); } else { fprintf(stderr, "no AVX/AVX2 support. Aborting!\n"); exit(-1); } + pLibrary = util_dl_open(filename); if (!pLibrary) { fprintf(stderr, "SWR library load failure: %s\n", util_dl_error()); @@ -65,3 +69,21 @@ swr_create_screen(struct sw_winsys *winsys) return pScreenCreate(winsys); } + + +#ifdef _WIN32 +// swap function called from libl_gdi.c + +void +swr_gdi_swap(struct pipe_screen *screen, + struct pipe_resource *res, + void *hDC) +{ + screen->flush_frontbuffer(screen, + res, + 0, 0, + hDC, + NULL); +} + +#endif /* _WIN32 */ diff --git a/src/gallium/drivers/swr/swr_public.h b/src/gallium/drivers/swr/swr_public.h index 0814c3b..fede820 100644 --- a/src/gallium/drivers/swr/swr_public.h +++ b/src/gallium/drivers/swr/swr_public.h @@ -32,12 +32,15 @@ struct sw_displaytarget; extern "C" { #endif -struct pipe_screen *swr_create_screen(struct sw_winsys *winsys); +PUBLIC struct pipe_screen *swr_create_screen(struct sw_winsys *winsys); -struct sw_winsys *swr_get_winsys(struct pipe_screen *pipe); - -struct sw_displaytarget *swr_get_displaytarget(struct pipe_resource *resource); +#ifdef _WIN32 +void +swr_gdi_swap(struct pipe_screen *screen, + struct pipe_resource *res, + void *hDC); +#endif /* _WIN32 */ #ifdef __cplusplus } diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index
[Mesa-dev] [PATCH v2 3/8] scons: added llvm 3.9 support.
--- scons/llvm.py | 21 +++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scons/llvm.py b/scons/llvm.py index 1fc8a3f..977e47a 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -106,7 +106,24 @@ def generate(env): ]) env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) # LIBS should match the output of `llvm-config --libs engine mcjit bitwriter x86asmprinter` -if llvm_version >= distutils.version.LooseVersion('3.7'): +if llvm_version >= distutils.version.LooseVersion('3.9'): +env.Prepend(LIBS = [ +'LLVMX86Disassembler', 'LLVMX86AsmParser', +'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', +'LLVMDebugInfoCodeView', 'LLVMCodeGen', +'LLVMScalarOpts', 'LLVMInstCombine', +'LLVMInstrumentation', 'LLVMTransformUtils', +'LLVMBitWriter', 'LLVMX86Desc', +'LLVMMCDisassembler', 'LLVMX86Info', +'LLVMX86AsmPrinter', 'LLVMX86Utils', +'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', +'LLVMAnalysis', 'LLVMProfileData', +'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', +'LLVMBitReader', 'LLVMMC', 'LLVMCore', +'LLVMSupport', +'LLVMIRReader', 'LLVMASMParser' +]) +elif llvm_version >= distutils.version.LooseVersion('3.7'): env.Prepend(LIBS = [ 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', @@ -203,7 +220,7 @@ def generate(env): if '-fno-rtti' in cxxflags: env.Append(CXXFLAGS = ['-fno-rtti']) -components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler'] +components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler', 'irreader'] env.ParseConfig('llvm-config --libs ' + ' '.join(components)) env.ParseConfig('llvm-config --ldflags') -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 4/8] gallium: Added SWR support for gdi
Added hooks for screen creation and swap. Still keep llvmpipe the default software renderer. --- src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 +++- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/gallium/targets/libgl-gdi/libgl_gdi.c b/src/gallium/targets/libgl-gdi/libgl_gdi.c index 922c186..12576db 100644 --- a/src/gallium/targets/libgl-gdi/libgl_gdi.c +++ b/src/gallium/targets/libgl-gdi/libgl_gdi.c @@ -51,9 +51,12 @@ #include "llvmpipe/lp_public.h" #endif +#ifdef HAVE_SWR +#include "swr/swr_public.h" +#endif static boolean use_llvmpipe = FALSE; - +static boolean use_swr = FALSE; static struct pipe_screen * gdi_screen_create(void) @@ -69,6 +72,8 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE default_driver = "llvmpipe"; +#elif HAVE_SWR + default_driver = "swr"; #else default_driver = "softpipe"; #endif @@ -78,15 +83,21 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE if (strcmp(driver, "llvmpipe") == 0) { screen = llvmpipe_create_screen( winsys ); + if (screen) + use_llvmpipe = TRUE; + } +#endif +#ifdef HAVE_SWR + if (strcmp(driver, "swr") == 0) { + screen = swr_create_screen( winsys ); + if (screen) + use_swr = TRUE; } -#else - (void) driver; #endif + (void) driver; if (screen == NULL) { screen = softpipe_create_screen( winsys ); - } else { - use_llvmpipe = TRUE; } if(!screen) @@ -128,6 +139,13 @@ gdi_present(struct pipe_screen *screen, } #endif +#ifdef HAVE_SWR + if (use_swr) { + swr_gdi_swap(screen, res, hDC); + return; + } +#endif + winsys = softpipe_screen(screen)->winsys, dt = softpipe_resource(res)->dt, gdi_sw_display(winsys, dt, hDC); -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 0/8] Support windows builds for OpenSWR
Changes to support Windows scons builds for OpenSWR driver Build on windows using the following command line: scons swr=1 libgl-gdi This will produce 3 .dlls. The (main) opengl32.dll, and 2 swr-specific dlls that are loaded dynamically at runtime depending on the underlying CPU architecture (swrAVX.dll and swrAVX2.dll). The default software renderer is still llvmpipe, and, like on linux, you enable SWR by setting the GALLIUM_DRIVER variable to "swr". George Kyriazis (8): mesa: removed redundant #else scons: ignore .hpp files in parse_source_list() scons: added llvm 3.9 support. gallium: Added SWR support for gdi gallium scons: Added swr driver to scons gallium: Enable swr driver swr: Added swr windows support swr: Fix linux build scons/custom.py| 2 +- scons/llvm.py | 21 ++- src/gallium/SConscript | 1 + src/gallium/drivers/swr/Makefile.am| 7 + src/gallium/drivers/swr/SConscript | 199 + src/gallium/drivers/swr/rasterizer/common/os.h | 5 +- src/gallium/drivers/swr/swr_context.cpp| 16 +- src/gallium/drivers/swr/swr_context.h | 2 + src/gallium/drivers/swr/swr_loader.cpp | 28 +++- src/gallium/drivers/swr/swr_public.h | 11 +- src/gallium/drivers/swr/swr_screen.cpp | 25 +--- src/gallium/targets/libgl-gdi/SConscript | 6 + src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 +++- src/gallium/targets/libgl-xlib/SConscript | 6 + src/gallium/targets/osmesa/SConscript | 6 + src/util/macros.h | 1 - 16 files changed, 321 insertions(+), 43 deletions(-) create mode 100644 src/gallium/drivers/swr/SConscript -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 1/8] mesa: removed redundant #else
--- src/util/macros.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/macros.h b/src/util/macros.h index 0563fa5..3730abe 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -178,7 +178,6 @@ do { \ # elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) # if _MSC_VER >= 1800 # define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) -# else # endif # endif # ifndef HAS_TRIVIAL_DESTRUCTOR -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 6/8] gallium: Enable swr driver
--- src/gallium/targets/libgl-gdi/SConscript | 6 ++ src/gallium/targets/libgl-xlib/SConscript | 6 ++ src/gallium/targets/osmesa/SConscript | 6 ++ 3 files changed, 18 insertions(+) diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 2a52363..0cedc8b 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -3,6 +3,8 @@ Import('*') +import SCons.Script.SConscript + env = env.Clone() env.Append(CPPPATH = [ @@ -30,6 +32,10 @@ if env['llvm']: env.Append(CPPDEFINES = 'HAVE_LLVMPIPE') drivers += [llvmpipe] +if 'swr' in SCons.Script.ARGUMENTS and SCons.Script.ARGUMENTS['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +drivers += [swr] + if env['gcc'] and env['machine'] != 'x86_64': # DEF parser in certain versions of MinGW is busted, as does not behave as # MSVC. mingw-w64 works fine. diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 0a4f31b..c66a751 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -3,6 +3,8 @@ Import('*') +import SCons.Script.SConscript + env = env.Clone() env.Append(CPPPATH = [ @@ -48,6 +50,10 @@ if env['llvm']: env.Append(CPPDEFINES = ['GALLIUM_LLVMPIPE']) env.Prepend(LIBS = [llvmpipe]) +if 'swr' in SCons.Script.ARGUMENTS and not SCons.Script.ARGUMENTS['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +env.Prepend(LIBS = [swr]) + if env['platform'] != 'darwin': # Disallow undefined symbols, except with Address Sanitizer, since libasan # is not linked on shared libs, as it should be LD_PRELOAD'ed instead diff --git a/src/gallium/targets/osmesa/SConscript b/src/gallium/targets/osmesa/SConscript index 7a2a00c..f390d1e 100644 --- a/src/gallium/targets/osmesa/SConscript +++ b/src/gallium/targets/osmesa/SConscript @@ -1,5 +1,7 @@ Import('*') +import SCons.Script.SConscript + env = env.Clone() env.Prepend(CPPPATH = [ @@ -30,6 +32,10 @@ if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') env.Prepend(LIBS = [llvmpipe]) +if 'swr' in SCons.Script.ARGUMENTS and not SCons.Script.ARGUMENTS['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +env.Prepend(LIBS = [swr]) + if env['platform'] == 'windows': if env['gcc'] and env['machine'] != 'x86_64': sources += ['osmesa.mingw.def'] -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 8/8] swr: Fix linux build
Added compiler flags for libmesaswr, since it now includes core header files. --- src/gallium/drivers/swr/Makefile.am | 7 +++ 1 file changed, 7 insertions(+) diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am index dd1c2e6..843d3b5 --- a/src/gallium/drivers/swr/Makefile.am +++ b/src/gallium/drivers/swr/Makefile.am @@ -217,6 +217,12 @@ libswrAVX2_la_CXXFLAGS = \ libswrAVX2_la_SOURCES = \ $(COMMON_SOURCES) +# XXX: $(SWR_AVX_CXXFLAGS) should not be included, but we end up including +# simdintrin.h, which throws a warning if AVX is not enabled +libmesaswr_la_CXXFLAGS = \ + $(COMMON_CXXFLAGS) \ + $(SWR_AVX_CXXFLAGS) + # XXX: Don't ship these generated sources for now, since they are specific # to the LLVM version they are generated from. Thus a release tarball # containing the said files, generated against eg. LLVM 3.8 will fail to build @@ -235,6 +241,7 @@ libswrAVX2_la_LDFLAGS = \ include $(top_srcdir)/install-gallium-links.mk EXTRA_DIST = \ + SConscript \ rasterizer/archrast/events.proto \ rasterizer/jitter/scripts/gen_llvm_ir_macros.py \ rasterizer/jitter/scripts/gen_llvm_types.py \ -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] docs: fix minor edits and reviewer suggestions
--- docs/submittingpatches.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/submittingpatches.html b/docs/submittingpatches.html index 2d18c74..be49a2e 100644 --- a/docs/submittingpatches.html +++ b/docs/submittingpatches.html @@ -41,7 +41,7 @@ components. git bisect.) Patches should be properly formatted. Patches should be sufficiently tested before submitting. -Patches should be submitted to submitted to mesa-dev +Patches should be submitted to mesa-dev for review using git send-email. @@ -104,6 +104,7 @@ that should be documented with: Reviewed-by: Joe Hacker jhac...@foo.com Acked-by: Joe Hacker jhac...@foo.com +Patch series that have some of their parts acked/reviewed by someone, should contain above tags for the parts that have been reviewed in subsequent versions of the patch series (v2/v3/etc.), so that reviewers know which parts have already been reviewed. In order for your patch to reach the prospective reviewer easier/faster, use the script scripts/get_reviewer.pl to get a list of individuals and include them in the CC list. @@ -334,6 +335,7 @@ be rejected: Git tips +Become familiar with git rebase -i ..., especially reording and fixup patches, since it will help you send subsequent versions of patches. Test for build breakage between patches e.g last 8 commits. git rebase -i --exec="make -j4" HEAD~8 -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] gdi: Add GALLIUM_TRACE and GALLIUM_RBUG to gdi
--- src/gallium/targets/libgl-gdi/SConscript | 1 + src/gallium/targets/libgl-gdi/libgl_gdi.c | 4 2 files changed, 5 insertions(+) diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index d3251ca..adb3581 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -41,6 +41,7 @@ if env['gcc'] and env['machine'] != 'x86_64': else: sources += ['#src/gallium/state_trackers/wgl/opengl32.def'] +env.Append(CPPDEFINES = ['GALLIUM_TRACE', 'GALLIUM_RBUG']) drivers += [trace, rbug] env['no_import_lib'] = 1 diff --git a/src/gallium/targets/libgl-gdi/libgl_gdi.c b/src/gallium/targets/libgl-gdi/libgl_gdi.c index 12576db..4b0819f 100644 --- a/src/gallium/targets/libgl-gdi/libgl_gdi.c +++ b/src/gallium/targets/libgl-gdi/libgl_gdi.c @@ -55,6 +55,8 @@ #include "swr/swr_public.h" #endif +#include "target-helpers/inline_debug_helper.h" + static boolean use_llvmpipe = FALSE; static boolean use_swr = FALSE; @@ -100,6 +102,8 @@ gdi_screen_create(void) screen = softpipe_create_screen( winsys ); } + screen = debug_screen_wrap(screen); + if(!screen) goto no_screen; -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 06/11] swr: renamed duplicate swr_create_screen()
There are 2 swr_create_screen() functions. One in swr_loader.cpp, which is used during driver init, and the other is hiding in swr_screen.cpp, which ends up in the arch-specific .dll/.so. Rename the second one to swr_create_screen_internal(), to avoid confusion in header files. --- src/gallium/drivers/swr/swr_loader.cpp | 2 +- src/gallium/drivers/swr/swr_public.h | 4 src/gallium/drivers/swr/swr_screen.cpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/swr/swr_loader.cpp b/src/gallium/drivers/swr/swr_loader.cpp index 2113c37..9d79fa5 100644 --- a/src/gallium/drivers/swr/swr_loader.cpp +++ b/src/gallium/drivers/swr/swr_loader.cpp @@ -54,7 +54,7 @@ swr_create_screen(struct sw_winsys *winsys) exit(-1); } - util_dl_proc pScreenProc = util_dl_get_proc_address(pLibrary, "swr_create_screen"); + util_dl_proc pScreenProc = util_dl_get_proc_address(pLibrary, "swr_create_screen_internal"); if (!pScreenProc) { fprintf(stderr, "SWR library search failure: %s\n", util_dl_error()); diff --git a/src/gallium/drivers/swr/swr_public.h b/src/gallium/drivers/swr/swr_public.h index 0814c3b..7ef81bf 100644 --- a/src/gallium/drivers/swr/swr_public.h +++ b/src/gallium/drivers/swr/swr_public.h @@ -32,8 +32,12 @@ struct sw_displaytarget; extern "C" { #endif +// driver entry point struct pipe_screen *swr_create_screen(struct sw_winsys *winsys); +// arch-specific dll entry point +PUBLIC struct pipe_screen *swr_create_screen_internal(struct sw_winsys *winsys); + struct sw_winsys *swr_get_winsys(struct pipe_screen *pipe); struct sw_displaytarget *swr_get_displaytarget(struct pipe_resource *resource); diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index cc79f28..8a85128 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -986,7 +986,7 @@ swr_destroy_screen(struct pipe_screen *p_screen) PUBLIC struct pipe_screen * -swr_create_screen(struct sw_winsys *winsys) +swr_create_screen_internal(struct sw_winsys *winsys) { struct swr_screen *screen = CALLOC_STRUCT(swr_screen); -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 00/11] Support windows builds for OpenSWR
Changes to support Windows scons builds for OpenSWR driver, since scons is the only supported build system for windows. Scons swr build will not work at this point. Also, windows scons swr build requires llvm version 3.9 (and above). Build on windows using the following command line: scons swr=1 libgl-gdi Make sure you have the LLVM environment variable set, per build instructions. This will produce 3 .dlls. The (main) opengl32.dll, and 2 swr-specific dlls that are loaded dynamically at runtime depending on the underlying CPU architecture (swrAVX.dll and swrAVX2.dll). The default software renderer is still llvmpipe, and, like on linux, you enable SWR by setting the GALLIUM_DRIVER variable to "swr". George Kyriazis (11): mesa: removed redundant #else scons: ignore .hpp files in parse_source_list() scons: add llvm 3.9 support. gallium: Added SWR support for gdi swr: Handle windows.h and NOMINMAX swr: renamed duplicate swr_create_screen() swr: Windows-related changes scons: Add swr compile option swr: Modify gen_knobs.{cpp|h} creation script gallium: swr: Added swr build for windows gallium: Add support for SWR compilation common.py | 1 + scons/custom.py| 2 +- scons/llvm.py | 21 +- src/gallium/SConscript | 1 + src/gallium/drivers/swr/Makefile.am| 15 +- src/gallium/drivers/swr/SConscript | 216 + .../drivers/swr/rasterizer/scripts/gen_knobs.py| 51 ++--- src/gallium/drivers/swr/swr_context.cpp| 16 +- src/gallium/drivers/swr/swr_context.h | 2 + src/gallium/drivers/swr/swr_loader.cpp | 29 ++- src/gallium/drivers/swr/swr_public.h | 11 +- src/gallium/drivers/swr/swr_screen.cpp | 27 +-- src/gallium/targets/libgl-gdi/SConscript | 4 + src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 ++- src/gallium/targets/libgl-xlib/SConscript | 4 + src/gallium/targets/osmesa/SConscript | 4 + src/util/macros.h | 1 - 17 files changed, 364 insertions(+), 69 deletions(-) create mode 100644 src/gallium/drivers/swr/SConscript -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 04/11] gallium: Added SWR support for gdi
Added hooks for screen creation and swap. Still keep llvmpipe the default software renderer. v2: split from bigger patch v3: reword commit message Reviewed-by: Emil Velikov--- src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 +++- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/gallium/targets/libgl-gdi/libgl_gdi.c b/src/gallium/targets/libgl-gdi/libgl_gdi.c index 922c186..12576db 100644 --- a/src/gallium/targets/libgl-gdi/libgl_gdi.c +++ b/src/gallium/targets/libgl-gdi/libgl_gdi.c @@ -51,9 +51,12 @@ #include "llvmpipe/lp_public.h" #endif +#ifdef HAVE_SWR +#include "swr/swr_public.h" +#endif static boolean use_llvmpipe = FALSE; - +static boolean use_swr = FALSE; static struct pipe_screen * gdi_screen_create(void) @@ -69,6 +72,8 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE default_driver = "llvmpipe"; +#elif HAVE_SWR + default_driver = "swr"; #else default_driver = "softpipe"; #endif @@ -78,15 +83,21 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE if (strcmp(driver, "llvmpipe") == 0) { screen = llvmpipe_create_screen( winsys ); + if (screen) + use_llvmpipe = TRUE; + } +#endif +#ifdef HAVE_SWR + if (strcmp(driver, "swr") == 0) { + screen = swr_create_screen( winsys ); + if (screen) + use_swr = TRUE; } -#else - (void) driver; #endif + (void) driver; if (screen == NULL) { screen = softpipe_create_screen( winsys ); - } else { - use_llvmpipe = TRUE; } if(!screen) @@ -128,6 +139,13 @@ gdi_present(struct pipe_screen *screen, } #endif +#ifdef HAVE_SWR + if (use_swr) { + swr_gdi_swap(screen, res, hDC); + return; + } +#endif + winsys = softpipe_screen(screen)->winsys, dt = softpipe_resource(res)->dt, gdi_sw_display(winsys, dt, hDC); -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 10/11] gallium: swr: Added swr build for windows
v4: Add windows-specific gen_knobs.{cpp|h} changes v5: remove aggresive squashing of gen_knobs.py to this commit Reviewed-by: Emil Velikov--- src/gallium/SConscript | 1 + src/gallium/drivers/swr/SConscript | 216 + 2 files changed, 217 insertions(+) create mode 100644 src/gallium/drivers/swr/SConscript diff --git a/src/gallium/SConscript b/src/gallium/SConscript index f98268f..9273db7 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -18,6 +18,7 @@ SConscript([ 'drivers/softpipe/SConscript', 'drivers/svga/SConscript', 'drivers/trace/SConscript', +'drivers/swr/SConscript', ]) # diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript new file mode 100644 index 000..0de51a7 --- /dev/null +++ b/src/gallium/drivers/swr/SConscript @@ -0,0 +1,216 @@ +Import('*') + +from sys import executable as python_cmd +import os.path +import distutils.version + +if not env['swr']: +Return() + +if not env['llvm']: +print 'warning: LLVM disabled: not building swr' +env['swr'] = False +Return() + +if env['LLVM_VERSION'] < distutils.version.LooseVersion('3.9'): +print "warning: swr requires LLVM >= 3.9: not building swr" +env['swr'] = False +Return() + +if env['platform'] != 'windows': +print "warning: swr scons build only supports windows: not building swr" +env['swr'] = False +Return() + +env.MSVC2013Compat() + +env = env.Clone() + +# construct llvm include dir +if env['platform'] == 'windows': +# on windows there is no llvm-config, so LLVM is defined +llvm_includedir = os.path.join(os.environ['LLVM'], 'include') +else: +llvm_includedir = env.backtick('llvm-config --includedir').rstrip() +print "llvm include dir %s" % llvm_includedir + +# the loader is included in the mesa lib itself +# All the remaining files are in loadable modules +loadersource = env.ParseSourceList('Makefile.sources', [ +'LOADER_SOURCES' +]) + +env.Append(CPPDEFINES = [ +'__STDC_CONSTANT_MACROS', +'__STDC_LIMIT_MACROS' +]) + +if not env['msvc'] : +env.Append(CCFLAGS = [ +'-std=c++11', +]) + +swrroot = '#src/gallium/drivers/swr/' + +env.CodeGenerate( +target = 'rasterizer/scripts/gen_knobs.cpp', +script = swrroot + 'rasterizer/scripts/gen_knobs.py', +source = 'rasterizer/scripts/templates/knobs.template', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp' +) + +env.CodeGenerate( +target = 'rasterizer/scripts/gen_knobs.h', +script = swrroot + 'rasterizer/scripts/gen_knobs.py', +source = 'rasterizer/scripts/templates/knobs.template', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/state_llvm.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py', +source = 'rasterizer/core/state.h', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_gen.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'), +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_gen.cpp', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'), +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_x86.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = '', +command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_h' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_x86.cpp', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = '', +command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_cpp' +) + +env.CodeGenerate( +target = 'swr_context_llvm.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py', +source = 'swr_context.h', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET' +) + +env.CodeGenerate( +target = 'rasterizer/archrast/gen_ar_event.h', +script = swrroot + 'rasterizer/scripts/gen_archrast.py', +source = 'rasterizer/archrast/events.proto', +command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_h' +) + +env.CodeGenerate( +target = 'rasterizer/archrast/gen_ar_event.cpp', +script = swrroot + 'rasterizer/scripts/gen_archrast.py', +source = 'rasterizer/archrast/events.proto', +command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_cpp' +) + +env.CodeGenerate( +target =
[Mesa-dev] [PATCH v5 01/11] mesa: removed redundant #else
Reviewed-by: Emil Velikov--- src/util/macros.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/macros.h b/src/util/macros.h index 733bf42..6f55ac6 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -178,7 +178,6 @@ do { \ # elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) # if _MSC_VER >= 1800 # define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) -# else # endif # endif # ifndef HAS_TRIVIAL_DESTRUCTOR -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 11/11] gallium: Add support for SWR compilation
Include swr library and include -DHAVE_SWR in the compile line. v3: split to a separate commit Reviewed-by: Emil Velikov--- src/gallium/targets/libgl-gdi/SConscript | 4 src/gallium/targets/libgl-xlib/SConscript | 4 src/gallium/targets/osmesa/SConscript | 4 3 files changed, 12 insertions(+) diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 2a52363..d3251ca 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -30,6 +30,10 @@ if env['llvm']: env.Append(CPPDEFINES = 'HAVE_LLVMPIPE') drivers += [llvmpipe] +if env['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +drivers += [swr] + if env['gcc'] and env['machine'] != 'x86_64': # DEF parser in certain versions of MinGW is busted, as does not behave as # MSVC. mingw-w64 works fine. diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 0a4f31b..d01bb3c 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -48,6 +48,10 @@ if env['llvm']: env.Append(CPPDEFINES = ['GALLIUM_LLVMPIPE']) env.Prepend(LIBS = [llvmpipe]) +if env['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +env.Prepend(LIBS = [swr]) + if env['platform'] != 'darwin': # Disallow undefined symbols, except with Address Sanitizer, since libasan # is not linked on shared libs, as it should be LD_PRELOAD'ed instead diff --git a/src/gallium/targets/osmesa/SConscript b/src/gallium/targets/osmesa/SConscript index 7a2a00c..47937a2 100644 --- a/src/gallium/targets/osmesa/SConscript +++ b/src/gallium/targets/osmesa/SConscript @@ -30,6 +30,10 @@ if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') env.Prepend(LIBS = [llvmpipe]) +if env['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +env.Prepend(LIBS = [swr]) + if env['platform'] == 'windows': if env['gcc'] and env['machine'] != 'x86_64': sources += ['osmesa.mingw.def'] -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 02/11] scons: ignore .hpp files in parse_source_list()
Drivers that contain C++ .hpp files need to ignore them too, along with .h files, when building source file lists. Reviewed-by: Emil Velikov--- scons/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scons/custom.py b/scons/custom.py index bdb4039..544b15d 100644 --- a/scons/custom.py +++ b/scons/custom.py @@ -281,7 +281,7 @@ def parse_source_list(env, filename, names=None): # cause duplicate actions. f = f[len(cur_srcdir + '/'):] # do not include any headers -if f.endswith('.h'): +if f.endswith(tuple(['.h','.hpp'])): continue srcs.append(f) -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 03/11] scons: add llvm 3.9 support.
v2: reworded commit message Reviewed-by: Emil Velikov--- scons/llvm.py | 21 +++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scons/llvm.py b/scons/llvm.py index 1fc8a3f..977e47a 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -106,7 +106,24 @@ def generate(env): ]) env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) # LIBS should match the output of `llvm-config --libs engine mcjit bitwriter x86asmprinter` -if llvm_version >= distutils.version.LooseVersion('3.7'): +if llvm_version >= distutils.version.LooseVersion('3.9'): +env.Prepend(LIBS = [ +'LLVMX86Disassembler', 'LLVMX86AsmParser', +'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', +'LLVMDebugInfoCodeView', 'LLVMCodeGen', +'LLVMScalarOpts', 'LLVMInstCombine', +'LLVMInstrumentation', 'LLVMTransformUtils', +'LLVMBitWriter', 'LLVMX86Desc', +'LLVMMCDisassembler', 'LLVMX86Info', +'LLVMX86AsmPrinter', 'LLVMX86Utils', +'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', +'LLVMAnalysis', 'LLVMProfileData', +'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', +'LLVMBitReader', 'LLVMMC', 'LLVMCore', +'LLVMSupport', +'LLVMIRReader', 'LLVMASMParser' +]) +elif llvm_version >= distutils.version.LooseVersion('3.7'): env.Prepend(LIBS = [ 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', @@ -203,7 +220,7 @@ def generate(env): if '-fno-rtti' in cxxflags: env.Append(CXXFLAGS = ['-fno-rtti']) -components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler'] +components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler', 'irreader'] env.ParseConfig('llvm-config --libs ' + ' '.join(components)) env.ParseConfig('llvm-config --ldflags') -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 07/11] swr: Windows-related changes
- Handle dynamic library loading for windows - Implement swap for gdi - fix prototypes - update include paths on configure-based build for swr_loader.cpp v2: split to multiple patches v3: split and reshuffle some more; renamed title v4: move Makefile.am changes to other commit. Modify header files --- src/gallium/drivers/swr/swr_loader.cpp | 27 --- src/gallium/drivers/swr/swr_public.h | 9 + 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/swr/swr_loader.cpp b/src/gallium/drivers/swr/swr_loader.cpp index 9d79fa5..4d71a67 100644 --- a/src/gallium/drivers/swr/swr_loader.cpp +++ b/src/gallium/drivers/swr/swr_loader.cpp @@ -25,14 +25,16 @@ #include "util/u_dl.h" #include "swr_public.h" +#include "pipe/p_screen.h" + #include -#include typedef pipe_screen *(*screen_create_proc)(struct sw_winsys *winsys); struct pipe_screen * swr_create_screen(struct sw_winsys *winsys) { + char filename[256]; fprintf(stderr, "SWR detected "); util_dl_library *pLibrary = nullptr; @@ -40,14 +42,15 @@ swr_create_screen(struct sw_winsys *winsys) util_cpu_detect(); if (util_cpu_caps.has_avx2) { fprintf(stderr, "AVX2\n"); - pLibrary = util_dl_open("libswrAVX2.so"); + sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX2", UTIL_DL_EXT); } else if (util_cpu_caps.has_avx) { fprintf(stderr, "AVX\n"); - pLibrary = util_dl_open("libswrAVX.so"); + sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX", UTIL_DL_EXT); } else { fprintf(stderr, "no AVX/AVX2 support. Aborting!\n"); exit(-1); } + pLibrary = util_dl_open(filename); if (!pLibrary) { fprintf(stderr, "SWR library load failure: %s\n", util_dl_error()); @@ -65,3 +68,21 @@ swr_create_screen(struct sw_winsys *winsys) return pScreenCreate(winsys); } + + +#ifdef _WIN32 +// swap function called from libl_gdi.c + +void +swr_gdi_swap(struct pipe_screen *screen, + struct pipe_resource *res, + void *hDC) +{ + screen->flush_frontbuffer(screen, + res, + 0, 0, + hDC, + NULL); +} + +#endif /* _WIN32 */ diff --git a/src/gallium/drivers/swr/swr_public.h b/src/gallium/drivers/swr/swr_public.h index 7ef81bf..4b15070 100644 --- a/src/gallium/drivers/swr/swr_public.h +++ b/src/gallium/drivers/swr/swr_public.h @@ -38,10 +38,11 @@ struct pipe_screen *swr_create_screen(struct sw_winsys *winsys); // arch-specific dll entry point PUBLIC struct pipe_screen *swr_create_screen_internal(struct sw_winsys *winsys); -struct sw_winsys *swr_get_winsys(struct pipe_screen *pipe); - -struct sw_displaytarget *swr_get_displaytarget(struct pipe_resource *resource); - +#ifdef _WIN32 +void swr_gdi_swap(struct pipe_screen *screen, + struct pipe_resource *res, + void *hDC); +#endif /* _WIN32 */ #ifdef __cplusplus } -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v5 09/11] swr: Modify gen_knobs.{cpp|h} creation script
Modify gen_knobs.py so that each invocation creates a single generated file. This is more similar to how the other generators behave. v5: remove Scoscript edits from this commit; moved to commit that first adds SConscript Acked-by: Emil Velikov--- src/gallium/drivers/swr/Makefile.am| 15 ++- .../drivers/swr/rasterizer/scripts/gen_knobs.py| 51 -- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am index dd1c2e6..b22ded0 100644 --- a/src/gallium/drivers/swr/Makefile.am +++ b/src/gallium/drivers/swr/Makefile.am @@ -71,11 +71,21 @@ swr_context_llvm.h: rasterizer/jitter/scripts/gen_llvm_types.py swr_context.h --input $(srcdir)/swr_context.h \ --output swr_context_llvm.h -rasterizer/scripts/gen_knobs.cpp rasterizer/scripts/gen_knobs.h: rasterizer/scripts/gen_knobs.py rasterizer/scripts/knob_defs.py rasterizer/scripts/templates/knobs.template +rasterizer/scripts/gen_knobs.cpp: rasterizer/scripts/gen_knobs.py rasterizer/scripts/knob_defs.py rasterizer/scripts/templates/knobs.template $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/scripts/gen_knobs.py \ - rasterizer/scripts + --input $(srcdir)/rasterizer/scripts/templates/knobs.template \ + --output rasterizer/scripts/gen_knobs.cpp \ + --gen_cpp + +rasterizer/scripts/gen_knobs.h: rasterizer/scripts/gen_knobs.py rasterizer/scripts/knob_defs.py rasterizer/scripts/templates/knobs.template + $(MKDIR_GEN) + $(PYTHON_GEN) \ + $(srcdir)/rasterizer/scripts/gen_knobs.py \ + --input $(srcdir)/rasterizer/scripts/templates/knobs.template \ + --output rasterizer/scripts/gen_knobs.h \ + --gen_h rasterizer/jitter/state_llvm.h: rasterizer/jitter/scripts/gen_llvm_types.py rasterizer/core/state.h $(MKDIR_GEN) @@ -235,6 +245,7 @@ libswrAVX2_la_LDFLAGS = \ include $(top_srcdir)/install-gallium-links.mk EXTRA_DIST = \ + SConscript \ rasterizer/archrast/events.proto \ rasterizer/jitter/scripts/gen_llvm_ir_macros.py \ rasterizer/jitter/scripts/gen_llvm_types.py \ diff --git a/src/gallium/drivers/swr/rasterizer/scripts/gen_knobs.py b/src/gallium/drivers/swr/rasterizer/scripts/gen_knobs.py index 3d003fb..225082e 100644 --- a/src/gallium/drivers/swr/rasterizer/scripts/gen_knobs.py +++ b/src/gallium/drivers/swr/rasterizer/scripts/gen_knobs.py @@ -23,13 +23,14 @@ from __future__ import print_function import os import sys +import argparse import knob_defs from mako.template import Template from mako.exceptions import RichTraceback def write_template_to_string(template_filename, **kwargs): try: -template = Template(filename=template_filename) +template = Template(filename=os.path.abspath(template_filename)) # Split + Join fixes line-endings for whatever platform you are using return '\n'.join(template.render(**kwargs).splitlines()) except: @@ -40,37 +41,39 @@ def write_template_to_string(template_filename, **kwargs): print("%s: %s" % (str(traceback.error.__class__.__name__), traceback.error)) def write_template_to_file(template_filename, output_filename, **kwargs): +output_dirname = os.path.dirname(output_filename) +if not os.path.exists(output_dirname): +os.makedirs(output_dirname) with open(output_filename, "w") as outfile: print(write_template_to_string(template_filename, **kwargs), file=outfile) def main(args=sys.argv[1:]): -if len(args) != 1: -print('Usage:', sys.argv[0], '', file=sys.stderr) -return 1 -output_dir = args[0] -if not os.path.isdir(output_dir): -if os.path.exists(output_dir): -print('ERROR: Invalid output directory:', output_dir, file=sys.stderr) -return 1 +# parse args +parser = argparse.ArgumentParser() +parser.add_argument("--input", "-i", help="Path to knobs.template", required=True) +parser.add_argument("--output", "-o", help="Path to output file", required=True) +parser.add_argument("--gen_h", "-gen_h", help="Generate gen_knobs.h", action="store_true", default=False) +parser.add_argument("--gen_cpp", "-gen_cpp", help="Generate gen_knobs.cpp", action="store_true", required=False) -try: -os.makedirs(output_dir) -except: -print('ERROR: Could not create output directory:', output_dir, file=sys.stderr) -return 1 +args = parser.parse_args() -# Output path exists, now just run the template -template_file = os.sep.join([sys.path[0], 'templates', 'knobs.template']) -output_file = os.sep.join([output_dir, 'gen_knobs.cpp']) -output_header = os.sep.join([output_dir, 'gen_knobs.h']) +if args.input: +if
[Mesa-dev] [PATCH v5 08/11] scons: Add swr compile option
To buils The SWR driver (currently optional, not compiled by default) v3: add option as opposed to target Reviewed-by: Emil Velikov--- common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/common.py b/common.py index fb0884e..704ad2e 100644 --- a/common.py +++ b/common.py @@ -110,5 +110,6 @@ def AddOptions(opts): opts.Add(BoolOption('texture_float', 'enable floating-point textures and renderbuffers', 'no')) +opts.Add(BoolOption('swr', 'Build OpenSWR', 'no')) if host_platform == 'windows': opts.Add('MSVC_VERSION', 'Microsoft Visual C/C++ version') -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 06/10] swr: renamed duplicate swr_create_screen()
There are 2 swr_create_screen() functions. One in swr_loader.cpp, which is used during driver init, and the other is hiding in swr_screen.cpp, which ends up in the arch-specific .dll/.so. Rename the second one to swr_create_screen_internal(), to avoid confusion in header files. --- src/gallium/drivers/swr/swr_loader.cpp | 2 +- src/gallium/drivers/swr/swr_public.h | 4 src/gallium/drivers/swr/swr_screen.cpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/swr/swr_loader.cpp b/src/gallium/drivers/swr/swr_loader.cpp index 2113c37..9d79fa5 100644 --- a/src/gallium/drivers/swr/swr_loader.cpp +++ b/src/gallium/drivers/swr/swr_loader.cpp @@ -54,7 +54,7 @@ swr_create_screen(struct sw_winsys *winsys) exit(-1); } - util_dl_proc pScreenProc = util_dl_get_proc_address(pLibrary, "swr_create_screen"); + util_dl_proc pScreenProc = util_dl_get_proc_address(pLibrary, "swr_create_screen_internal"); if (!pScreenProc) { fprintf(stderr, "SWR library search failure: %s\n", util_dl_error()); diff --git a/src/gallium/drivers/swr/swr_public.h b/src/gallium/drivers/swr/swr_public.h index 0814c3b..7ef81bf 100644 --- a/src/gallium/drivers/swr/swr_public.h +++ b/src/gallium/drivers/swr/swr_public.h @@ -32,8 +32,12 @@ struct sw_displaytarget; extern "C" { #endif +// driver entry point struct pipe_screen *swr_create_screen(struct sw_winsys *winsys); +// arch-specific dll entry point +PUBLIC struct pipe_screen *swr_create_screen_internal(struct sw_winsys *winsys); + struct sw_winsys *swr_get_winsys(struct pipe_screen *pipe); struct sw_displaytarget *swr_get_displaytarget(struct pipe_resource *resource); diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index cc79f28..8a85128 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -986,7 +986,7 @@ swr_destroy_screen(struct pipe_screen *p_screen) PUBLIC struct pipe_screen * -swr_create_screen(struct sw_winsys *winsys) +swr_create_screen_internal(struct sw_winsys *winsys) { struct swr_screen *screen = CALLOC_STRUCT(swr_screen); -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 04/10] gallium: Added SWR support for gdi
Added hooks for screen creation and swap. Still keep llvmpipe the default software renderer. --- src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 +++- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/gallium/targets/libgl-gdi/libgl_gdi.c b/src/gallium/targets/libgl-gdi/libgl_gdi.c index 922c186..12576db 100644 --- a/src/gallium/targets/libgl-gdi/libgl_gdi.c +++ b/src/gallium/targets/libgl-gdi/libgl_gdi.c @@ -51,9 +51,12 @@ #include "llvmpipe/lp_public.h" #endif +#ifdef HAVE_SWR +#include "swr/swr_public.h" +#endif static boolean use_llvmpipe = FALSE; - +static boolean use_swr = FALSE; static struct pipe_screen * gdi_screen_create(void) @@ -69,6 +72,8 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE default_driver = "llvmpipe"; +#elif HAVE_SWR + default_driver = "swr"; #else default_driver = "softpipe"; #endif @@ -78,15 +83,21 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE if (strcmp(driver, "llvmpipe") == 0) { screen = llvmpipe_create_screen( winsys ); + if (screen) + use_llvmpipe = TRUE; + } +#endif +#ifdef HAVE_SWR + if (strcmp(driver, "swr") == 0) { + screen = swr_create_screen( winsys ); + if (screen) + use_swr = TRUE; } -#else - (void) driver; #endif + (void) driver; if (screen == NULL) { screen = softpipe_create_screen( winsys ); - } else { - use_llvmpipe = TRUE; } if(!screen) @@ -128,6 +139,13 @@ gdi_present(struct pipe_screen *screen, } #endif +#ifdef HAVE_SWR + if (use_swr) { + swr_gdi_swap(screen, res, hDC); + return; + } +#endif + winsys = softpipe_screen(screen)->winsys, dt = softpipe_resource(res)->dt, gdi_sw_display(winsys, dt, hDC); -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 03/10] scons: add llvm 3.9 support.
--- scons/llvm.py | 21 +++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scons/llvm.py b/scons/llvm.py index 1fc8a3f..977e47a 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -106,7 +106,24 @@ def generate(env): ]) env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) # LIBS should match the output of `llvm-config --libs engine mcjit bitwriter x86asmprinter` -if llvm_version >= distutils.version.LooseVersion('3.7'): +if llvm_version >= distutils.version.LooseVersion('3.9'): +env.Prepend(LIBS = [ +'LLVMX86Disassembler', 'LLVMX86AsmParser', +'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', +'LLVMDebugInfoCodeView', 'LLVMCodeGen', +'LLVMScalarOpts', 'LLVMInstCombine', +'LLVMInstrumentation', 'LLVMTransformUtils', +'LLVMBitWriter', 'LLVMX86Desc', +'LLVMMCDisassembler', 'LLVMX86Info', +'LLVMX86AsmPrinter', 'LLVMX86Utils', +'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', +'LLVMAnalysis', 'LLVMProfileData', +'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', +'LLVMBitReader', 'LLVMMC', 'LLVMCore', +'LLVMSupport', +'LLVMIRReader', 'LLVMASMParser' +]) +elif llvm_version >= distutils.version.LooseVersion('3.7'): env.Prepend(LIBS = [ 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', @@ -203,7 +220,7 @@ def generate(env): if '-fno-rtti' in cxxflags: env.Append(CXXFLAGS = ['-fno-rtti']) -components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler'] +components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler', 'irreader'] env.ParseConfig('llvm-config --libs ' + ' '.join(components)) env.ParseConfig('llvm-config --ldflags') -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 10/10] gallium: Add support for SWR compilation
Include swr library and include -DHAVE_SWR in the compile line. --- src/gallium/targets/libgl-gdi/SConscript | 4 src/gallium/targets/libgl-xlib/SConscript | 4 src/gallium/targets/osmesa/SConscript | 4 3 files changed, 12 insertions(+) diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 2a52363..d3251ca 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -30,6 +30,10 @@ if env['llvm']: env.Append(CPPDEFINES = 'HAVE_LLVMPIPE') drivers += [llvmpipe] +if env['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +drivers += [swr] + if env['gcc'] and env['machine'] != 'x86_64': # DEF parser in certain versions of MinGW is busted, as does not behave as # MSVC. mingw-w64 works fine. diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 0a4f31b..d01bb3c 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -48,6 +48,10 @@ if env['llvm']: env.Append(CPPDEFINES = ['GALLIUM_LLVMPIPE']) env.Prepend(LIBS = [llvmpipe]) +if env['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +env.Prepend(LIBS = [swr]) + if env['platform'] != 'darwin': # Disallow undefined symbols, except with Address Sanitizer, since libasan # is not linked on shared libs, as it should be LD_PRELOAD'ed instead diff --git a/src/gallium/targets/osmesa/SConscript b/src/gallium/targets/osmesa/SConscript index 7a2a00c..47937a2 100644 --- a/src/gallium/targets/osmesa/SConscript +++ b/src/gallium/targets/osmesa/SConscript @@ -30,6 +30,10 @@ if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') env.Prepend(LIBS = [llvmpipe]) +if env['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +env.Prepend(LIBS = [swr]) + if env['platform'] == 'windows': if env['gcc'] and env['machine'] != 'x86_64': sources += ['osmesa.mingw.def'] -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 09/10] gallium: swr: Added swr build for windows
Also, modify gen_knobs.py so that each invocation creates a single generated file. This is more similar to how the other generators behave. --- src/gallium/SConscript | 1 + src/gallium/drivers/swr/Makefile.am| 15 +- src/gallium/drivers/swr/SConscript | 216 + .../drivers/swr/rasterizer/scripts/gen_knobs.py| 51 ++--- 4 files changed, 257 insertions(+), 26 deletions(-) create mode 100644 src/gallium/drivers/swr/SConscript diff --git a/src/gallium/SConscript b/src/gallium/SConscript index f98268f..9273db7 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -18,6 +18,7 @@ SConscript([ 'drivers/softpipe/SConscript', 'drivers/svga/SConscript', 'drivers/trace/SConscript', +'drivers/swr/SConscript', ]) # diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am index dd1c2e6..b22ded0 100644 --- a/src/gallium/drivers/swr/Makefile.am +++ b/src/gallium/drivers/swr/Makefile.am @@ -71,11 +71,21 @@ swr_context_llvm.h: rasterizer/jitter/scripts/gen_llvm_types.py swr_context.h --input $(srcdir)/swr_context.h \ --output swr_context_llvm.h -rasterizer/scripts/gen_knobs.cpp rasterizer/scripts/gen_knobs.h: rasterizer/scripts/gen_knobs.py rasterizer/scripts/knob_defs.py rasterizer/scripts/templates/knobs.template +rasterizer/scripts/gen_knobs.cpp: rasterizer/scripts/gen_knobs.py rasterizer/scripts/knob_defs.py rasterizer/scripts/templates/knobs.template $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/scripts/gen_knobs.py \ - rasterizer/scripts + --input $(srcdir)/rasterizer/scripts/templates/knobs.template \ + --output rasterizer/scripts/gen_knobs.cpp \ + --gen_cpp + +rasterizer/scripts/gen_knobs.h: rasterizer/scripts/gen_knobs.py rasterizer/scripts/knob_defs.py rasterizer/scripts/templates/knobs.template + $(MKDIR_GEN) + $(PYTHON_GEN) \ + $(srcdir)/rasterizer/scripts/gen_knobs.py \ + --input $(srcdir)/rasterizer/scripts/templates/knobs.template \ + --output rasterizer/scripts/gen_knobs.h \ + --gen_h rasterizer/jitter/state_llvm.h: rasterizer/jitter/scripts/gen_llvm_types.py rasterizer/core/state.h $(MKDIR_GEN) @@ -235,6 +245,7 @@ libswrAVX2_la_LDFLAGS = \ include $(top_srcdir)/install-gallium-links.mk EXTRA_DIST = \ + SConscript \ rasterizer/archrast/events.proto \ rasterizer/jitter/scripts/gen_llvm_ir_macros.py \ rasterizer/jitter/scripts/gen_llvm_types.py \ diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript new file mode 100644 index 000..0de51a7 --- /dev/null +++ b/src/gallium/drivers/swr/SConscript @@ -0,0 +1,216 @@ +Import('*') + +from sys import executable as python_cmd +import os.path +import distutils.version + +if not env['swr']: +Return() + +if not env['llvm']: +print 'warning: LLVM disabled: not building swr' +env['swr'] = False +Return() + +if env['LLVM_VERSION'] < distutils.version.LooseVersion('3.9'): +print "warning: swr requires LLVM >= 3.9: not building swr" +env['swr'] = False +Return() + +if env['platform'] != 'windows': +print "warning: swr scons build only supports windows: not building swr" +env['swr'] = False +Return() + +env.MSVC2013Compat() + +env = env.Clone() + +# construct llvm include dir +if env['platform'] == 'windows': +# on windows there is no llvm-config, so LLVM is defined +llvm_includedir = os.path.join(os.environ['LLVM'], 'include') +else: +llvm_includedir = env.backtick('llvm-config --includedir').rstrip() +print "llvm include dir %s" % llvm_includedir + +# the loader is included in the mesa lib itself +# All the remaining files are in loadable modules +loadersource = env.ParseSourceList('Makefile.sources', [ +'LOADER_SOURCES' +]) + +env.Append(CPPDEFINES = [ +'__STDC_CONSTANT_MACROS', +'__STDC_LIMIT_MACROS' +]) + +if not env['msvc'] : +env.Append(CCFLAGS = [ +'-std=c++11', +]) + +swrroot = '#src/gallium/drivers/swr/' + +env.CodeGenerate( +target = 'rasterizer/scripts/gen_knobs.cpp', +script = swrroot + 'rasterizer/scripts/gen_knobs.py', +source = 'rasterizer/scripts/templates/knobs.template', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp' +) + +env.CodeGenerate( +target = 'rasterizer/scripts/gen_knobs.h', +script = swrroot + 'rasterizer/scripts/gen_knobs.py', +source = 'rasterizer/scripts/templates/knobs.template', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/state_llvm.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py', +source = 'rasterizer/core/state.h', +command = python_cmd + '
[Mesa-dev] [PATCH v4 00/10] Support windows builds for OpenSWR
Changes to support Windows scons builds for OpenSWR driver, since scons is the only supported build system for windows. Scons swr build will not work at this point. Also, windows scons swr build requires llvm version 3.9 (and above). Build on windows using the following command line: scons swr=1 libgl-gdi Make sure you have the LLVM environment variable set, per build instructions. This will produce 3 .dlls. The (main) opengl32.dll, and 2 swr-specific dlls that are loaded dynamically at runtime depending on the underlying CPU architecture (swrAVX.dll and swrAVX2.dll). The default software renderer is still llvmpipe, and, like on linux, you enable SWR by setting the GALLIUM_DRIVER variable to "swr". George Kyriazis (10): mesa: removed redundant #else scons: ignore .hpp files in parse_source_list() scons: add llvm 3.9 support. gallium: Added SWR support for gdi swr: Handle windows.h and NOMINMAX swr: renamed duplicate swr_create_screen() swr: Windows-related changes scons: Add swr compile option gallium: swr: Added swr build for windows gallium: Add support for SWR compilation common.py | 1 + scons/custom.py| 2 +- scons/llvm.py | 21 +- src/gallium/SConscript | 1 + src/gallium/drivers/swr/Makefile.am| 15 +- src/gallium/drivers/swr/SConscript | 216 + .../drivers/swr/rasterizer/scripts/gen_knobs.py| 51 ++--- src/gallium/drivers/swr/swr_context.cpp| 16 +- src/gallium/drivers/swr/swr_context.h | 2 + src/gallium/drivers/swr/swr_loader.cpp | 29 ++- src/gallium/drivers/swr/swr_public.h | 11 +- src/gallium/drivers/swr/swr_screen.cpp | 27 +-- src/gallium/targets/libgl-gdi/SConscript | 4 + src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 ++- src/gallium/targets/libgl-xlib/SConscript | 4 + src/gallium/targets/osmesa/SConscript | 4 + src/util/macros.h | 1 - 17 files changed, 364 insertions(+), 69 deletions(-) create mode 100644 src/gallium/drivers/swr/SConscript -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 07/10] swr: Windows-related changes
- Handle dynamic library loading for windows - Implement swap for gdi - fix prototypes - update include paths on configure-based build for swr_loader.cpp --- src/gallium/drivers/swr/swr_loader.cpp | 27 --- src/gallium/drivers/swr/swr_public.h | 9 + 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/swr/swr_loader.cpp b/src/gallium/drivers/swr/swr_loader.cpp index 9d79fa5..4d71a67 100644 --- a/src/gallium/drivers/swr/swr_loader.cpp +++ b/src/gallium/drivers/swr/swr_loader.cpp @@ -25,14 +25,16 @@ #include "util/u_dl.h" #include "swr_public.h" +#include "pipe/p_screen.h" + #include -#include typedef pipe_screen *(*screen_create_proc)(struct sw_winsys *winsys); struct pipe_screen * swr_create_screen(struct sw_winsys *winsys) { + char filename[256]; fprintf(stderr, "SWR detected "); util_dl_library *pLibrary = nullptr; @@ -40,14 +42,15 @@ swr_create_screen(struct sw_winsys *winsys) util_cpu_detect(); if (util_cpu_caps.has_avx2) { fprintf(stderr, "AVX2\n"); - pLibrary = util_dl_open("libswrAVX2.so"); + sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX2", UTIL_DL_EXT); } else if (util_cpu_caps.has_avx) { fprintf(stderr, "AVX\n"); - pLibrary = util_dl_open("libswrAVX.so"); + sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX", UTIL_DL_EXT); } else { fprintf(stderr, "no AVX/AVX2 support. Aborting!\n"); exit(-1); } + pLibrary = util_dl_open(filename); if (!pLibrary) { fprintf(stderr, "SWR library load failure: %s\n", util_dl_error()); @@ -65,3 +68,21 @@ swr_create_screen(struct sw_winsys *winsys) return pScreenCreate(winsys); } + + +#ifdef _WIN32 +// swap function called from libl_gdi.c + +void +swr_gdi_swap(struct pipe_screen *screen, + struct pipe_resource *res, + void *hDC) +{ + screen->flush_frontbuffer(screen, + res, + 0, 0, + hDC, + NULL); +} + +#endif /* _WIN32 */ diff --git a/src/gallium/drivers/swr/swr_public.h b/src/gallium/drivers/swr/swr_public.h index 7ef81bf..4b15070 100644 --- a/src/gallium/drivers/swr/swr_public.h +++ b/src/gallium/drivers/swr/swr_public.h @@ -38,10 +38,11 @@ struct pipe_screen *swr_create_screen(struct sw_winsys *winsys); // arch-specific dll entry point PUBLIC struct pipe_screen *swr_create_screen_internal(struct sw_winsys *winsys); -struct sw_winsys *swr_get_winsys(struct pipe_screen *pipe); - -struct sw_displaytarget *swr_get_displaytarget(struct pipe_resource *resource); - +#ifdef _WIN32 +void swr_gdi_swap(struct pipe_screen *screen, + struct pipe_resource *res, + void *hDC); +#endif /* _WIN32 */ #ifdef __cplusplus } -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 08/10] scons: Add swr compile option
To buils The SWR driver (currently optional, not compiled by default) --- common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/common.py b/common.py index fb0884e..704ad2e 100644 --- a/common.py +++ b/common.py @@ -110,5 +110,6 @@ def AddOptions(opts): opts.Add(BoolOption('texture_float', 'enable floating-point textures and renderbuffers', 'no')) +opts.Add(BoolOption('swr', 'Build OpenSWR', 'no')) if host_platform == 'windows': opts.Add('MSVC_VERSION', 'Microsoft Visual C/C++ version') -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 05/10] swr: Handle windows.h and NOMINMAX
Reorder header files so that we have a chance to defined NOMINMAX before mesa include files include windows.h --- src/gallium/drivers/swr/swr_context.cpp | 16 src/gallium/drivers/swr/swr_context.h | 2 ++ src/gallium/drivers/swr/swr_screen.cpp | 25 +++-- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index a5ab236..3f57712 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -21,6 +21,14 @@ * IN THE SOFTWARE. ***/ +#include "swr_context.h" +#include "swr_memory.h" +#include "swr_screen.h" +#include "swr_resource.h" +#include "swr_scratch.h" +#include "swr_query.h" +#include "swr_fence.h" + #include "util/u_memory.h" #include "util/u_inlines.h" #include "util/u_format.h" @@ -31,14 +39,6 @@ extern "C" { #include "util/u_surface.h" } -#include "swr_context.h" -#include "swr_memory.h" -#include "swr_screen.h" -#include "swr_resource.h" -#include "swr_scratch.h" -#include "swr_query.h" -#include "swr_fence.h" - #include "api.h" #include "backend.h" diff --git a/src/gallium/drivers/swr/swr_context.h b/src/gallium/drivers/swr/swr_context.h index eecfe0d..04e11fe 100644 --- a/src/gallium/drivers/swr/swr_context.h +++ b/src/gallium/drivers/swr/swr_context.h @@ -24,6 +24,8 @@ #ifndef SWR_CONTEXT_H #define SWR_CONTEXT_H +#include "common/os.h" + #include "pipe/p_context.h" #include "pipe/p_state.h" #include "util/u_blitter.h" diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index 0c8f5db..cc79f28 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -21,6 +21,13 @@ * IN THE SOFTWARE. ***/ +#include "swr_context.h" +#include "swr_public.h" +#include "swr_screen.h" +#include "swr_resource.h" +#include "swr_fence.h" +#include "gen_knobs.h" + #include "pipe/p_screen.h" #include "pipe/p_defines.h" #include "util/u_memory.h" @@ -35,13 +42,6 @@ extern "C" { #include "gallivm/lp_bld_limits.h" } -#include "swr_public.h" -#include "swr_screen.h" -#include "swr_context.h" -#include "swr_resource.h" -#include "swr_fence.h" -#include "gen_knobs.h" - #include "jit_api.h" #include @@ -1023,14 +1023,3 @@ swr_create_screen(struct sw_winsys *winsys) return >base; } -struct sw_winsys * -swr_get_winsys(struct pipe_screen *pipe) -{ - return ((struct swr_screen *)pipe)->winsys; -} - -struct sw_displaytarget * -swr_get_displaytarget(struct pipe_resource *resource) -{ - return ((struct swr_resource *)resource)->display_target; -} -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 02/10] scons: ignore .hpp files in parse_source_list()
Drivers that contain C++ .hpp files need to ignore them too, along with .h files, when building source file lists. --- scons/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scons/custom.py b/scons/custom.py index bdb4039..544b15d 100644 --- a/scons/custom.py +++ b/scons/custom.py @@ -281,7 +281,7 @@ def parse_source_list(env, filename, names=None): # cause duplicate actions. f = f[len(cur_srcdir + '/'):] # do not include any headers -if f.endswith('.h'): +if f.endswith(tuple(['.h','.hpp'])): continue srcs.append(f) -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 01/10] mesa: removed redundant #else
--- src/util/macros.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/macros.h b/src/util/macros.h index 733bf42..6f55ac6 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -178,7 +178,6 @@ do { \ # elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) # if _MSC_VER >= 1800 # define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) -# else # endif # endif # ifndef HAS_TRIVIAL_DESTRUCTOR -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 02/10] scons: ignore .hpp files in parse_source_list()
Drivers that contain C++ .hpp files need to ignore them too, along with .h files, when building source file lists. --- scons/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scons/custom.py b/scons/custom.py index bdb4039..544b15d 100644 --- a/scons/custom.py +++ b/scons/custom.py @@ -281,7 +281,7 @@ def parse_source_list(env, filename, names=None): # cause duplicate actions. f = f[len(cur_srcdir + '/'):] # do not include any headers -if f.endswith('.h'): +if f.endswith(tuple(['.h','.hpp'])): continue srcs.append(f) -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 10/10] swr: Modify gen_knobs.{cpp|h} creation script
Modify gen_knobs.py so that each invocation creates a single generated file. This is more similar to how the other generators behave. --- src/gallium/drivers/swr/Makefile.am| 14 +- src/gallium/drivers/swr/SConscript | 17 +--- .../drivers/swr/rasterizer/scripts/gen_knobs.py| 51 -- 3 files changed, 49 insertions(+), 33 deletions(-) mode change 100644 => 100755 src/gallium/drivers/swr/Makefile.am diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am old mode 100644 new mode 100755 index 305154f..5cac5f2 --- a/src/gallium/drivers/swr/Makefile.am +++ b/src/gallium/drivers/swr/Makefile.am @@ -71,11 +71,21 @@ swr_context_llvm.h: rasterizer/jitter/scripts/gen_llvm_types.py swr_context.h --input $(srcdir)/swr_context.h \ --output swr_context_llvm.h -rasterizer/scripts/gen_knobs.cpp rasterizer/scripts/gen_knobs.h: rasterizer/scripts/gen_knobs.py rasterizer/scripts/knob_defs.py rasterizer/scripts/templates/knobs.template +rasterizer/scripts/gen_knobs.cpp: rasterizer/scripts/gen_knobs.py rasterizer/scripts/knob_defs.py rasterizer/scripts/templates/knobs.template $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/scripts/gen_knobs.py \ - rasterizer/scripts + --input $(srcdir)/rasterizer/scripts/templates/knobs.template \ + --output rasterizer/scripts/gen_knobs.cpp \ + --gen_cpp + +rasterizer/scripts/gen_knobs.h: rasterizer/scripts/gen_knobs.py rasterizer/scripts/knob_defs.py rasterizer/scripts/templates/knobs.template + $(MKDIR_GEN) + $(PYTHON_GEN) \ + $(srcdir)/rasterizer/scripts/gen_knobs.py \ + --input $(srcdir)/rasterizer/scripts/templates/knobs.template \ + --output rasterizer/scripts/gen_knobs.h \ + --gen_h rasterizer/jitter/state_llvm.h: rasterizer/jitter/scripts/gen_llvm_types.py rasterizer/core/state.h $(MKDIR_GEN) diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript index 0c8011e..0de51a7 100755 --- a/src/gallium/drivers/swr/SConscript +++ b/src/gallium/drivers/swr/SConscript @@ -55,15 +55,15 @@ swrroot = '#src/gallium/drivers/swr/' env.CodeGenerate( target = 'rasterizer/scripts/gen_knobs.cpp', script = swrroot + 'rasterizer/scripts/gen_knobs.py', -source = [], -command = python_cmd + ' $SCRIPT ' + Dir('rasterizer/scripts').abspath +source = 'rasterizer/scripts/templates/knobs.template', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp' ) env.CodeGenerate( target = 'rasterizer/scripts/gen_knobs.h', script = swrroot + 'rasterizer/scripts/gen_knobs.py', -source = [], -command = python_cmd + ' $SCRIPT ' + Dir('rasterizer/scripts').abspath +source = 'rasterizer/scripts/templates/knobs.template', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h' ) env.CodeGenerate( @@ -116,10 +116,10 @@ env.CodeGenerate( ) env.CodeGenerate( -target = 'rasterizer/archrast/gen_ar.event.cpp', +target = 'rasterizer/archrast/gen_ar_event.cpp', script = swrroot + 'rasterizer/scripts/gen_archrast.py', source = 'rasterizer/archrast/events.proto', -command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen-event_cpp' +command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_cpp' ) env.CodeGenerate( @@ -136,12 +136,15 @@ env.CodeGenerate( command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandlerfile_h' ) -source = [ +# Auto-generated .cpp files (that need to generate object files) +built_sources = [ 'rasterizer/scripts/gen_knobs.cpp', 'rasterizer/jitter/builder_gen.cpp', 'rasterizer/jitter/builder_x86.cpp', +'rasterizer/archrast/gen_ar_event.cpp', ] +source = built_sources source += env.ParseSourceList(swrroot + 'Makefile.sources', [ 'CXX_SOURCES', 'ARCHRAST_CXX_SOURCES', diff --git a/src/gallium/drivers/swr/rasterizer/scripts/gen_knobs.py b/src/gallium/drivers/swr/rasterizer/scripts/gen_knobs.py index 3d003fb..225082e 100644 --- a/src/gallium/drivers/swr/rasterizer/scripts/gen_knobs.py +++ b/src/gallium/drivers/swr/rasterizer/scripts/gen_knobs.py @@ -23,13 +23,14 @@ from __future__ import print_function import os import sys +import argparse import knob_defs from mako.template import Template from mako.exceptions import RichTraceback def write_template_to_string(template_filename, **kwargs): try: -template = Template(filename=template_filename) +template = Template(filename=os.path.abspath(template_filename)) # Split + Join fixes line-endings for whatever platform you are using return '\n'.join(template.render(**kwargs).splitlines()) except: @@ -40,37 +41,39 @@ def
[Mesa-dev] [PATCH v3 01/10] mesa: removed redundant #else
--- src/util/macros.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/macros.h b/src/util/macros.h index 0563fa5..3730abe 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -178,7 +178,6 @@ do { \ # elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) # if _MSC_VER >= 1800 # define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) -# else # endif # endif # ifndef HAS_TRIVIAL_DESTRUCTOR -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 03/10] scons: add llvm 3.9 support.
--- scons/llvm.py | 21 +++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scons/llvm.py b/scons/llvm.py index 1fc8a3f..977e47a 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -106,7 +106,24 @@ def generate(env): ]) env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) # LIBS should match the output of `llvm-config --libs engine mcjit bitwriter x86asmprinter` -if llvm_version >= distutils.version.LooseVersion('3.7'): +if llvm_version >= distutils.version.LooseVersion('3.9'): +env.Prepend(LIBS = [ +'LLVMX86Disassembler', 'LLVMX86AsmParser', +'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', +'LLVMDebugInfoCodeView', 'LLVMCodeGen', +'LLVMScalarOpts', 'LLVMInstCombine', +'LLVMInstrumentation', 'LLVMTransformUtils', +'LLVMBitWriter', 'LLVMX86Desc', +'LLVMMCDisassembler', 'LLVMX86Info', +'LLVMX86AsmPrinter', 'LLVMX86Utils', +'LLVMMCJIT', 'LLVMExecutionEngine', 'LLVMTarget', +'LLVMAnalysis', 'LLVMProfileData', +'LLVMRuntimeDyld', 'LLVMObject', 'LLVMMCParser', +'LLVMBitReader', 'LLVMMC', 'LLVMCore', +'LLVMSupport', +'LLVMIRReader', 'LLVMASMParser' +]) +elif llvm_version >= distutils.version.LooseVersion('3.7'): env.Prepend(LIBS = [ 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', 'LLVMX86CodeGen', 'LLVMSelectionDAG', 'LLVMAsmPrinter', @@ -203,7 +220,7 @@ def generate(env): if '-fno-rtti' in cxxflags: env.Append(CXXFLAGS = ['-fno-rtti']) -components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler'] +components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter', 'mcdisassembler', 'irreader'] env.ParseConfig('llvm-config --libs ' + ' '.join(components)) env.ParseConfig('llvm-config --ldflags') -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 00/10] Support windows builds for OpenSWR
Changes to support Windows scons builds for OpenSWR driver, since scons is the only supported build system for windows. Scons swr build will not work at this point. Also, windows scons swr build requires llvm version 3.9 (and above). Build on windows using the following command line: scons swr=1 libgl-gdi Make sure you have the LLVM environment variable set, per build instructions. This will produce 3 .dlls. The (main) opengl32.dll, and 2 swr-specific dlls that are loaded dynamically at runtime depending on the underlying CPU architecture (swrAVX.dll and swrAVX2.dll). The default software renderer is still llvmpipe, and, like on linux, you enable SWR by setting the GALLIUM_DRIVER variable to "swr". George Kyriazis (10): mesa: removed redundant #else scons: ignore .hpp files in parse_source_list() scons: add llvm 3.9 support. gallium: Added SWR support for gdi swr: Handle windows.h and NOMINMAX swr: Windows-related changes scons: Add swr compile option gallium: swr: Added swr build for windows gallium: Add support for SWR compilation swr: Modify gen_knobs.{cpp|h} creation script common.py | 1 + scons/custom.py| 2 +- scons/llvm.py | 21 +- src/gallium/SConscript | 1 + src/gallium/drivers/swr/Makefile.am| 21 +- src/gallium/drivers/swr/SConscript | 216 + .../drivers/swr/rasterizer/scripts/gen_knobs.py| 51 ++--- src/gallium/drivers/swr/swr_context.cpp| 16 +- src/gallium/drivers/swr/swr_context.h | 2 + src/gallium/drivers/swr/swr_loader.cpp | 28 ++- src/gallium/drivers/swr/swr_public.h | 11 +- src/gallium/drivers/swr/swr_screen.cpp | 25 +-- src/gallium/targets/libgl-gdi/SConscript | 4 + src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 ++- src/gallium/targets/libgl-xlib/SConscript | 4 + src/gallium/targets/osmesa/SConscript | 4 + src/util/macros.h | 1 - 17 files changed, 368 insertions(+), 68 deletions(-) mode change 100644 => 100755 src/gallium/drivers/swr/Makefile.am create mode 100755 src/gallium/drivers/swr/SConscript -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 09/10] gallium: Add support for SWR compilation
Include swr library and include -DHAVE_SWR in the compile line. --- src/gallium/targets/libgl-gdi/SConscript | 4 src/gallium/targets/libgl-xlib/SConscript | 4 src/gallium/targets/osmesa/SConscript | 4 3 files changed, 12 insertions(+) diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript index 2a52363..d3251ca 100644 --- a/src/gallium/targets/libgl-gdi/SConscript +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -30,6 +30,10 @@ if env['llvm']: env.Append(CPPDEFINES = 'HAVE_LLVMPIPE') drivers += [llvmpipe] +if env['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +drivers += [swr] + if env['gcc'] and env['machine'] != 'x86_64': # DEF parser in certain versions of MinGW is busted, as does not behave as # MSVC. mingw-w64 works fine. diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 0a4f31b..d01bb3c 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -48,6 +48,10 @@ if env['llvm']: env.Append(CPPDEFINES = ['GALLIUM_LLVMPIPE']) env.Prepend(LIBS = [llvmpipe]) +if env['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +env.Prepend(LIBS = [swr]) + if env['platform'] != 'darwin': # Disallow undefined symbols, except with Address Sanitizer, since libasan # is not linked on shared libs, as it should be LD_PRELOAD'ed instead diff --git a/src/gallium/targets/osmesa/SConscript b/src/gallium/targets/osmesa/SConscript index 7a2a00c..47937a2 100644 --- a/src/gallium/targets/osmesa/SConscript +++ b/src/gallium/targets/osmesa/SConscript @@ -30,6 +30,10 @@ if env['llvm']: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') env.Prepend(LIBS = [llvmpipe]) +if env['swr']: +env.Append(CPPDEFINES = 'HAVE_SWR') +env.Prepend(LIBS = [swr]) + if env['platform'] == 'windows': if env['gcc'] and env['machine'] != 'x86_64': sources += ['osmesa.mingw.def'] -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 06/10] swr: Windows-related changes
- Handle dynamic library loading for windows - Implement swap for gdi - fix prototypes - update include paths on configure-based build for swr_loader.cpp --- src/gallium/drivers/swr/Makefile.am| 7 +++ src/gallium/drivers/swr/swr_loader.cpp | 28 +--- src/gallium/drivers/swr/swr_public.h | 11 +++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am index dd1c2e6..305154f 100644 --- a/src/gallium/drivers/swr/Makefile.am +++ b/src/gallium/drivers/swr/Makefile.am @@ -217,6 +217,12 @@ libswrAVX2_la_CXXFLAGS = \ libswrAVX2_la_SOURCES = \ $(COMMON_SOURCES) +# XXX: $(SWR_AVX_CXXFLAGS) should not be included, but we end up including +# simdintrin.h, which throws a warning if AVX is not enabled +libmesaswr_la_CXXFLAGS = \ + $(COMMON_CXXFLAGS) \ + $(SWR_AVX_CXXFLAGS) + # XXX: Don't ship these generated sources for now, since they are specific # to the LLVM version they are generated from. Thus a release tarball # containing the said files, generated against eg. LLVM 3.8 will fail to build @@ -235,6 +241,7 @@ libswrAVX2_la_LDFLAGS = \ include $(top_srcdir)/install-gallium-links.mk EXTRA_DIST = \ + SConscript \ rasterizer/archrast/events.proto \ rasterizer/jitter/scripts/gen_llvm_ir_macros.py \ rasterizer/jitter/scripts/gen_llvm_types.py \ diff --git a/src/gallium/drivers/swr/swr_loader.cpp b/src/gallium/drivers/swr/swr_loader.cpp index 2113c37..4f3329e 100644 --- a/src/gallium/drivers/swr/swr_loader.cpp +++ b/src/gallium/drivers/swr/swr_loader.cpp @@ -25,14 +25,17 @@ #include "util/u_dl.h" #include "swr_public.h" +#include "swr_screen.h" +#include "swr_resource.h" + #include -#include typedef pipe_screen *(*screen_create_proc)(struct sw_winsys *winsys); struct pipe_screen * swr_create_screen(struct sw_winsys *winsys) { + char filename[256]; fprintf(stderr, "SWR detected "); util_dl_library *pLibrary = nullptr; @@ -40,14 +43,15 @@ swr_create_screen(struct sw_winsys *winsys) util_cpu_detect(); if (util_cpu_caps.has_avx2) { fprintf(stderr, "AVX2\n"); - pLibrary = util_dl_open("libswrAVX2.so"); + sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX2", UTIL_DL_EXT); } else if (util_cpu_caps.has_avx) { fprintf(stderr, "AVX\n"); - pLibrary = util_dl_open("libswrAVX.so"); + sprintf(filename, "%s%s%s", UTIL_DL_PREFIX, "swrAVX", UTIL_DL_EXT); } else { fprintf(stderr, "no AVX/AVX2 support. Aborting!\n"); exit(-1); } + pLibrary = util_dl_open(filename); if (!pLibrary) { fprintf(stderr, "SWR library load failure: %s\n", util_dl_error()); @@ -65,3 +69,21 @@ swr_create_screen(struct sw_winsys *winsys) return pScreenCreate(winsys); } + + +#ifdef _WIN32 +// swap function called from libl_gdi.c + +void +swr_gdi_swap(struct pipe_screen *screen, + struct pipe_resource *res, + void *hDC) +{ + screen->flush_frontbuffer(screen, + res, + 0, 0, + hDC, + NULL); +} + +#endif /* _WIN32 */ diff --git a/src/gallium/drivers/swr/swr_public.h b/src/gallium/drivers/swr/swr_public.h index 0814c3b..fede820 100644 --- a/src/gallium/drivers/swr/swr_public.h +++ b/src/gallium/drivers/swr/swr_public.h @@ -32,12 +32,15 @@ struct sw_displaytarget; extern "C" { #endif -struct pipe_screen *swr_create_screen(struct sw_winsys *winsys); +PUBLIC struct pipe_screen *swr_create_screen(struct sw_winsys *winsys); -struct sw_winsys *swr_get_winsys(struct pipe_screen *pipe); - -struct sw_displaytarget *swr_get_displaytarget(struct pipe_resource *resource); +#ifdef _WIN32 +void +swr_gdi_swap(struct pipe_screen *screen, + struct pipe_resource *res, + void *hDC); +#endif /* _WIN32 */ #ifdef __cplusplus } -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 08/10] gallium: swr: Added swr build for windows
--- src/gallium/SConscript | 1 + src/gallium/drivers/swr/SConscript | 213 + 2 files changed, 214 insertions(+) create mode 100755 src/gallium/drivers/swr/SConscript diff --git a/src/gallium/SConscript b/src/gallium/SConscript index f98268f..9273db7 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -18,6 +18,7 @@ SConscript([ 'drivers/softpipe/SConscript', 'drivers/svga/SConscript', 'drivers/trace/SConscript', +'drivers/swr/SConscript', ]) # diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript new file mode 100755 index 000..0c8011e --- /dev/null +++ b/src/gallium/drivers/swr/SConscript @@ -0,0 +1,213 @@ +Import('*') + +from sys import executable as python_cmd +import os.path +import distutils.version + +if not env['swr']: +Return() + +if not env['llvm']: +print 'warning: LLVM disabled: not building swr' +env['swr'] = False +Return() + +if env['LLVM_VERSION'] < distutils.version.LooseVersion('3.9'): +print "warning: swr requires LLVM >= 3.9: not building swr" +env['swr'] = False +Return() + +if env['platform'] != 'windows': +print "warning: swr scons build only supports windows: not building swr" +env['swr'] = False +Return() + +env.MSVC2013Compat() + +env = env.Clone() + +# construct llvm include dir +if env['platform'] == 'windows': +# on windows there is no llvm-config, so LLVM is defined +llvm_includedir = os.path.join(os.environ['LLVM'], 'include') +else: +llvm_includedir = env.backtick('llvm-config --includedir').rstrip() +print "llvm include dir %s" % llvm_includedir + +# the loader is included in the mesa lib itself +# All the remaining files are in loadable modules +loadersource = env.ParseSourceList('Makefile.sources', [ +'LOADER_SOURCES' +]) + +env.Append(CPPDEFINES = [ +'__STDC_CONSTANT_MACROS', +'__STDC_LIMIT_MACROS' +]) + +if not env['msvc'] : +env.Append(CCFLAGS = [ +'-std=c++11', +]) + +swrroot = '#src/gallium/drivers/swr/' + +env.CodeGenerate( +target = 'rasterizer/scripts/gen_knobs.cpp', +script = swrroot + 'rasterizer/scripts/gen_knobs.py', +source = [], +command = python_cmd + ' $SCRIPT ' + Dir('rasterizer/scripts').abspath +) + +env.CodeGenerate( +target = 'rasterizer/scripts/gen_knobs.h', +script = swrroot + 'rasterizer/scripts/gen_knobs.py', +source = [], +command = python_cmd + ' $SCRIPT ' + Dir('rasterizer/scripts').abspath +) + +env.CodeGenerate( +target = 'rasterizer/jitter/state_llvm.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py', +source = 'rasterizer/core/state.h', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_gen.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'), +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_gen.cpp', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'), +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_x86.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = '', +command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_h' +) + +env.CodeGenerate( +target = 'rasterizer/jitter/builder_x86.cpp', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py', +source = '', +command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_cpp' +) + +env.CodeGenerate( +target = 'swr_context_llvm.h', +script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py', +source = 'swr_context.h', +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET' +) + +env.CodeGenerate( +target = 'rasterizer/archrast/gen_ar_event.h', +script = swrroot + 'rasterizer/scripts/gen_archrast.py', +source = 'rasterizer/archrast/events.proto', +command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_h' +) + +env.CodeGenerate( +target = 'rasterizer/archrast/gen_ar.event.cpp', +script = swrroot + 'rasterizer/scripts/gen_archrast.py', +source = 'rasterizer/archrast/events.proto', +command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen-event_cpp' +) + +env.CodeGenerate( +target = 'rasterizer/archrast/gen_ar_eventhandler.h', +script = swrroot + 'rasterizer/scripts/gen_archrast.py', +source = 'rasterizer/archrast/events.proto', +command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandler_h' +) + +env.CodeGenerate( +target =
[Mesa-dev] [PATCH v3 05/10] swr: Handle windows.h and NOMINMAX
Reorder header files so that we have a chance to defined NOMINMAX before mesa include files include windows.h --- src/gallium/drivers/swr/swr_context.cpp | 16 src/gallium/drivers/swr/swr_context.h | 2 ++ src/gallium/drivers/swr/swr_screen.cpp | 25 +++-- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index 6c0782a..f84b3c5 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -21,6 +21,14 @@ * IN THE SOFTWARE. ***/ +#include "swr_context.h" +#include "swr_memory.h" +#include "swr_screen.h" +#include "swr_resource.h" +#include "swr_scratch.h" +#include "swr_query.h" +#include "swr_fence.h" + #include "util/u_memory.h" #include "util/u_inlines.h" #include "util/u_format.h" @@ -31,14 +39,6 @@ extern "C" { #include "util/u_surface.h" } -#include "swr_context.h" -#include "swr_memory.h" -#include "swr_screen.h" -#include "swr_resource.h" -#include "swr_scratch.h" -#include "swr_query.h" -#include "swr_fence.h" - #include "api.h" #include "backend.h" diff --git a/src/gallium/drivers/swr/swr_context.h b/src/gallium/drivers/swr/swr_context.h index eecfe0d..04e11fe 100644 --- a/src/gallium/drivers/swr/swr_context.h +++ b/src/gallium/drivers/swr/swr_context.h @@ -24,6 +24,8 @@ #ifndef SWR_CONTEXT_H #define SWR_CONTEXT_H +#include "common/os.h" + #include "pipe/p_context.h" #include "pipe/p_state.h" #include "util/u_blitter.h" diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index fa16edd..04a1d36 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -21,6 +21,13 @@ * IN THE SOFTWARE. ***/ +#include "swr_context.h" +#include "swr_public.h" +#include "swr_screen.h" +#include "swr_resource.h" +#include "swr_fence.h" +#include "gen_knobs.h" + #include "pipe/p_screen.h" #include "pipe/p_defines.h" #include "util/u_memory.h" @@ -35,13 +42,6 @@ extern "C" { #include "gallivm/lp_bld_limits.h" } -#include "swr_public.h" -#include "swr_screen.h" -#include "swr_context.h" -#include "swr_resource.h" -#include "swr_fence.h" -#include "gen_knobs.h" - #include "jit_api.h" #include @@ -1021,14 +1021,3 @@ swr_create_screen(struct sw_winsys *winsys) return >base; } -struct sw_winsys * -swr_get_winsys(struct pipe_screen *pipe) -{ - return ((struct swr_screen *)pipe)->winsys; -} - -struct sw_displaytarget * -swr_get_displaytarget(struct pipe_resource *resource) -{ - return ((struct swr_resource *)resource)->display_target; -} -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 07/10] scons: Add swr compile option
To buils The SWR driver (currently optional, not compiled by default) --- common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/common.py b/common.py index fb0884e..704ad2e 100644 --- a/common.py +++ b/common.py @@ -110,5 +110,6 @@ def AddOptions(opts): opts.Add(BoolOption('texture_float', 'enable floating-point textures and renderbuffers', 'no')) +opts.Add(BoolOption('swr', 'Build OpenSWR', 'no')) if host_platform == 'windows': opts.Add('MSVC_VERSION', 'Microsoft Visual C/C++ version') -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 04/10] gallium: Added SWR support for gdi
Added hooks for screen creation and swap. Still keep llvmpipe the default software renderer. --- src/gallium/targets/libgl-gdi/libgl_gdi.c | 28 +++- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/gallium/targets/libgl-gdi/libgl_gdi.c b/src/gallium/targets/libgl-gdi/libgl_gdi.c index 922c186..12576db 100644 --- a/src/gallium/targets/libgl-gdi/libgl_gdi.c +++ b/src/gallium/targets/libgl-gdi/libgl_gdi.c @@ -51,9 +51,12 @@ #include "llvmpipe/lp_public.h" #endif +#ifdef HAVE_SWR +#include "swr/swr_public.h" +#endif static boolean use_llvmpipe = FALSE; - +static boolean use_swr = FALSE; static struct pipe_screen * gdi_screen_create(void) @@ -69,6 +72,8 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE default_driver = "llvmpipe"; +#elif HAVE_SWR + default_driver = "swr"; #else default_driver = "softpipe"; #endif @@ -78,15 +83,21 @@ gdi_screen_create(void) #ifdef HAVE_LLVMPIPE if (strcmp(driver, "llvmpipe") == 0) { screen = llvmpipe_create_screen( winsys ); + if (screen) + use_llvmpipe = TRUE; + } +#endif +#ifdef HAVE_SWR + if (strcmp(driver, "swr") == 0) { + screen = swr_create_screen( winsys ); + if (screen) + use_swr = TRUE; } -#else - (void) driver; #endif + (void) driver; if (screen == NULL) { screen = softpipe_create_screen( winsys ); - } else { - use_llvmpipe = TRUE; } if(!screen) @@ -128,6 +139,13 @@ gdi_present(struct pipe_screen *screen, } #endif +#ifdef HAVE_SWR + if (use_swr) { + swr_gdi_swap(screen, res, hDC); + return; + } +#endif + winsys = softpipe_screen(screen)->winsys, dt = softpipe_resource(res)->dt, gdi_sw_display(winsys, dt, hDC); -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] swr: Templetize std::max to work on windows
--- src/gallium/drivers/swr/swr_clear.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/swr/swr_clear.cpp b/src/gallium/drivers/swr/swr_clear.cpp index f59179f..e752ee0 100644 --- a/src/gallium/drivers/swr/swr_clear.cpp +++ b/src/gallium/drivers/swr/swr_clear.cpp @@ -46,20 +46,20 @@ swr_clear(struct pipe_context *pipe, for (unsigned i = 0; i < fb->nr_cbufs; ++i) if (fb->cbufs[i] && (buffers & (PIPE_CLEAR_COLOR0 << i))) { clearMask |= (SWR_ATTACHMENT_COLOR0_BIT << i); -layers = std::max(layers, fb->cbufs[i]->u.tex.last_layer - +layers = std::max(layers, fb->cbufs[i]->u.tex.last_layer - fb->cbufs[i]->u.tex.first_layer + 1); } } if (buffers & PIPE_CLEAR_DEPTH && fb->zsbuf) { clearMask |= SWR_ATTACHMENT_DEPTH_BIT; - layers = std::max(layers, fb->zsbuf->u.tex.last_layer - + layers = std::max(layers, fb->zsbuf->u.tex.last_layer - fb->zsbuf->u.tex.first_layer + 1); } if (buffers & PIPE_CLEAR_STENCIL && fb->zsbuf) { clearMask |= SWR_ATTACHMENT_STENCIL_BIT; - layers = std::max(layers, fb->zsbuf->u.tex.last_layer - + layers = std::max(layers, fb->zsbuf->u.tex.last_layer - fb->zsbuf->u.tex.first_layer + 1); } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] [swr] Always defer memory free in swr_resource_destroy
Defer delete on regular resources. This ensures that any work being done on the resource is completed before freeing up the resource's memory. --- src/gallium/drivers/swr/swr_screen.cpp | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index cc8030e..5012388 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -880,18 +880,11 @@ swr_resource_destroy(struct pipe_screen *p_screen, struct pipe_resource *pt) winsys->displaytarget_destroy(winsys, spr->display_target); } else { - /* For regular resources, if the resource is being used, defer deletion - * (use aligned-free) */ - if (pipe && spr->status) { - swr_resource_unused(pt); - swr_fence_work_free(screen->flush_fence, - spr->swr.pBaseAddress, true); - swr_fence_work_free(screen->flush_fence, - spr->secondary.pBaseAddress, true); - } else { - AlignedFree(spr->swr.pBaseAddress); - AlignedFree(spr->secondary.pBaseAddress); - } + /* For regular resources, defer deletion */ + swr_resource_unused(pt); + swr_fence_work_free(screen->flush_fence, spr->swr.pBaseAddress, true); + swr_fence_work_free(screen->flush_fence, + spr->secondary.pBaseAddress, true); } FREE(spr); -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2] swr: Fix type to match parameters of std::max()
Include propagation of comparisons further down. --- src/gallium/drivers/swr/swr_clear.cpp | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/swr/swr_clear.cpp b/src/gallium/drivers/swr/swr_clear.cpp index f59179f..08eead8 100644 --- a/src/gallium/drivers/swr/swr_clear.cpp +++ b/src/gallium/drivers/swr/swr_clear.cpp @@ -35,7 +35,7 @@ swr_clear(struct pipe_context *pipe, struct pipe_framebuffer_state *fb = >framebuffer; UINT clearMask = 0; - int layers = 0; + unsigned layers = 0; if (!swr_check_render_cond(pipe)) return; @@ -47,20 +47,20 @@ swr_clear(struct pipe_context *pipe, if (fb->cbufs[i] && (buffers & (PIPE_CLEAR_COLOR0 << i))) { clearMask |= (SWR_ATTACHMENT_COLOR0_BIT << i); layers = std::max(layers, fb->cbufs[i]->u.tex.last_layer - - fb->cbufs[i]->u.tex.first_layer + 1); + fb->cbufs[i]->u.tex.first_layer + 1u); } } if (buffers & PIPE_CLEAR_DEPTH && fb->zsbuf) { clearMask |= SWR_ATTACHMENT_DEPTH_BIT; layers = std::max(layers, fb->zsbuf->u.tex.last_layer - -fb->zsbuf->u.tex.first_layer + 1); +fb->zsbuf->u.tex.first_layer + 1u); } if (buffers & PIPE_CLEAR_STENCIL && fb->zsbuf) { clearMask |= SWR_ATTACHMENT_STENCIL_BIT; layers = std::max(layers, fb->zsbuf->u.tex.last_layer - -fb->zsbuf->u.tex.first_layer + 1); +fb->zsbuf->u.tex.first_layer + 1u); } #if 0 // XXX HACK, override clear color alpha. On ubuntu, clears are @@ -68,7 +68,7 @@ swr_clear(struct pipe_context *pipe, ((union pipe_color_union *)color)->f[3] = 1.0; /* cast off your const'd-ness */ #endif - for (int i = 0; i < layers; ++i) { + for (unsigned i = 0; i < layers; ++i) { swr_update_draw_context(ctx); SwrClearRenderTarget(ctx->swrContext, clearMask, i, color->f, depth, stencil, @@ -76,11 +76,11 @@ swr_clear(struct pipe_context *pipe, // Mask out the attachments that are out of layers. if (fb->zsbuf && - fb->zsbuf->u.tex.last_layer - fb->zsbuf->u.tex.first_layer <= i) + fb->zsbuf->u.tex.last_layer <= fb->zsbuf->u.tex.first_layer + i) clearMask &= ~(SWR_ATTACHMENT_DEPTH_BIT | SWR_ATTACHMENT_STENCIL_BIT); for (unsigned c = 0; c < fb->nr_cbufs; ++c) { const struct pipe_surface *sf = fb->cbufs[c]; - if (sf && sf->u.tex.last_layer - sf->u.tex.first_layer <= i) + if (sf && (sf->u.tex.last_layer <= sf->u.tex.first_layer + i)) clearMask &= ~(SWR_ATTACHMENT_COLOR0_BIT << c); } } -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] swr: fix windows build break
Explicitly declare lp_native_vector_width inside an extern "C", since we cannot include the correct header file inside extern "C". --- src/gallium/drivers/swr/swr_screen.cpp | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index a9905d7..f858f68 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -21,6 +21,19 @@ * IN THE SOFTWARE. ***/ +/* + * extern block below has to be before any #includes. + * Windows decorates global variables, and the first extern wins, + * so the first declaration of lp_native_vector_width has to be + * the correct one. The right approach, of course, is to include + * the correct .h files, however that doesn't work since + * header files eventually include system header files, + * which do not work inside extern "C". + */ +extern "C" { + extern unsigned lp_native_vector_width; +} + #include "swr_context.h" #include "swr_public.h" #include "swr_screen.h" @@ -39,9 +52,6 @@ #include "state_tracker/sw_winsys.h" -extern "C" { -#include "gallivm/lp_bld_limits.h" -} #include "jit_api.h" -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3] swr: fix windows build break
wrap lp_bld_type.h around extern "C". Windows decorates global variables, so when used from .cpp files, need to use an undecorated version. --- src/gallium/auxiliary/gallivm/lp_bld_type.h | 7 +++ src/gallium/drivers/swr/swr_screen.cpp | 4 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index 7fb449f..afe8722 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -41,6 +41,10 @@ #include "pipe/p_compiler.h" #include "gallivm/lp_bld.h" +#ifdef __cplusplus +extern "C" { +#endif + /** * Native SIMD architecture width available at runtime. * @@ -449,5 +453,8 @@ lp_build_context_init(struct lp_build_context *bld, unsigned lp_build_count_ir_module(LLVMModuleRef module); +#ifdef __cplusplus +} +#endif #endif /* !LP_BLD_TYPE_H */ diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index a9905d7..3b010fe 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -39,10 +39,6 @@ #include "state_tracker/sw_winsys.h" -extern "C" { -#include "gallivm/lp_bld_limits.h" -} - #include "jit_api.h" #include "memory/TilingFunctions.h" -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2] swr: fix windows build break
wrap lp_native_vector_width around extern "C" for C++. Windows decorates global variables, so when used from .cpp files, need to use an undecorated version. --- src/gallium/auxiliary/gallivm/lp_bld_type.h | 7 +++ src/gallium/drivers/swr/swr_screen.cpp | 4 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index 7fb449f..1d12974 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -47,7 +47,14 @@ * Using this width should give the best performance, * and it determines the necessary alignment of vector variables. */ +#ifdef __cplusplus +// extern "C" for windows, since msdev decorates global vars +extern "C" { extern unsigned lp_native_vector_width; +} +#else +extern unsigned lp_native_vector_width; +#endif /** * Maximum supported vector width (not necessarily supported at run-time). diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index a9905d7..3b010fe 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -39,10 +39,6 @@ #include "state_tracker/sw_winsys.h" -extern "C" { -#include "gallivm/lp_bld_limits.h" -} - #include "jit_api.h" #include "memory/TilingFunctions.h" -- 2.10.0.windows.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3] swr: [rasterizer codegen] Fix windows build
Fix codegen build break that was introduced earlier v2: update rules for gen_knobs.cpp and gen_knobs.h v3: Introduce bldroot and revert generator file changes, making patch simpler. --- src/gallium/drivers/swr/SConscript | 38 +++--- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript index ad16162..18d6c9b 100644 --- a/src/gallium/drivers/swr/SConscript +++ b/src/gallium/drivers/swr/SConscript @@ -47,20 +47,25 @@ if not env['msvc'] : ]) swrroot = '#src/gallium/drivers/swr/' +bldroot = Dir('.').abspath env.CodeGenerate( target = 'rasterizer/codegen/gen_knobs.cpp', script = swrroot + 'rasterizer/codegen/gen_knobs.py', -source = 'rasterizer/codegen/templates/gen_knobs.cpp', -command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp' +source = '', +command = python_cmd + ' $SCRIPT --output $TARGET --gen_cpp' ) +Depends('rasterizer/codegen/gen_knobs.cpp', +swrroot + 'rasterizer/codegen/templates/gen_knobs.cpp') env.CodeGenerate( target = 'rasterizer/codegen/gen_knobs.h', script = swrroot + 'rasterizer/codegen/gen_knobs.py', -source = 'rasterizer/codegen/templates/gen_knobs.cpp', -command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h' +source = '', +command = python_cmd + ' $SCRIPT --output $TARGET --gen_h' ) +Depends('rasterizer/codegen/gen_knobs.cpp', +swrroot + 'rasterizer/codegen/templates/gen_knobs.cpp') env.CodeGenerate( target = 'rasterizer/jitter/gen_state_llvm.h', @@ -68,20 +73,26 @@ env.CodeGenerate( source = 'rasterizer/core/state.h', command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET' ) +Depends('rasterizer/jitter/gen_state_llvm.h', +swrroot + 'rasterizer/codegen/templates/gen_llvm.hpp') env.CodeGenerate( target = 'rasterizer/jitter/gen_builder.hpp', script = swrroot + 'rasterizer/codegen/gen_llvm_ir_macros.py', source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'), -command = python_cmd + ' $SCRIPT --input $SOURCE --output rasterizer/jitter --gen_h' +command = python_cmd + ' $SCRIPT --input $SOURCE --output ' + bldroot + '/rasterizer/jitter --gen_h' ) +Depends('rasterizer/jitter/gen_builder.hpp', +swrroot + 'rasterizer/codegen/templates/gen_builder.hpp') env.CodeGenerate( target = 'rasterizer/jitter/gen_builder_x86.hpp', script = swrroot + 'rasterizer/codegen/gen_llvm_ir_macros.py', source = '', -command = python_cmd + ' $SCRIPT --output rasterizer/jitter --gen_x86_h' +command = python_cmd + ' $SCRIPT --output ' + bldroot + '/rasterizer/jitter --gen_x86_h' ) +Depends('rasterizer/jitter/gen_builder.hpp', +swrroot + 'rasterizer/codegen/templates/gen_builder.hpp') env.CodeGenerate( target = './gen_swr_context_llvm.h', @@ -89,6 +100,8 @@ env.CodeGenerate( source = 'swr_context.h', command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET' ) +Depends('rasterizer/jitter/gen_state_llvm.h', +swrroot + 'rasterizer/codegen/templates/gen_llvm.hpp') env.CodeGenerate( target = 'rasterizer/archrast/gen_ar_event.hpp', @@ -96,6 +109,8 @@ env.CodeGenerate( source = 'rasterizer/archrast/events.proto', command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_h' ) +Depends('rasterizer/jitter/gen_state_llvm.h', +swrroot + 'rasterizer/codegen/templates/gen_ar_event.hpp') env.CodeGenerate( target = 'rasterizer/archrast/gen_ar_event.cpp', @@ -103,6 +118,8 @@ env.CodeGenerate( source = 'rasterizer/archrast/events.proto', command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_cpp' ) +Depends('rasterizer/jitter/gen_state_llvm.h', +swrroot + 'rasterizer/codegen/templates/gen_ar_event.cpp') env.CodeGenerate( target = 'rasterizer/archrast/gen_ar_eventhandler.hpp', @@ -110,6 +127,8 @@ env.CodeGenerate( source = 'rasterizer/archrast/events.proto', command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandler_h' ) +Depends('rasterizer/jitter/gen_state_llvm.h', +swrroot + 'rasterizer/codegen/templates/gen_ar_eventhandler.hpp') env.CodeGenerate( target = 'rasterizer/archrast/gen_ar_eventhandlerfile.hpp', @@ -117,6 +136,8 @@ env.CodeGenerate( source = 'rasterizer/archrast/events.proto', command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandlerfile_h' ) +Depends('rasterizer/jitter/gen_state_llvm.h', +swrroot + 'rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp') # 5 SWR_MULTISAMPLE_TYPE_COUNT # 2 SWR_MSAA_SAMPLE_PATTERN_COUNT @@ -127,8 +148,11 @@ env.CodeGenerate( env.CodeGenerate( target = 'rasterizer/core/gen_BackendPixelRate0.cpp', script = swrroot + 'rasterizer/codegen/gen_backends.py', -command = python_cmd +
[Mesa-dev] [PATCH v2 10/10] swr: [rasterizer codegen] Fix windows build
Fix codegen build break that was introduced earlier v2: update rules for gen_knobs.cpp and gen_knobs.h --- src/gallium/drivers/swr/Makefile.am| 4 +-- src/gallium/drivers/swr/SConscript | 15 ++- .../drivers/swr/rasterizer/codegen/gen_backends.py | 30 ++ .../swr/rasterizer/codegen/gen_llvm_ir_macros.py | 20 +++ 4 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am index 515a9089cc..cc37abf3e8 100644 --- a/src/gallium/drivers/swr/Makefile.am +++ b/src/gallium/drivers/swr/Makefile.am @@ -97,14 +97,14 @@ rasterizer/jitter/gen_builder.hpp: rasterizer/codegen/gen_llvm_ir_macros.py rast $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_llvm_ir_macros.py \ --input $(LLVM_INCLUDEDIR)/llvm/IR/IRBuilder.h \ - --output rasterizer/jitter \ + --output $@ \ --gen_h rasterizer/jitter/gen_builder_x86.hpp: rasterizer/codegen/gen_llvm_ir_macros.py rasterizer/codegen/templates/gen_builder.hpp rasterizer/codegen/gen_common.py $(MKDIR_GEN) $(PYTHON_GEN) \ $(srcdir)/rasterizer/codegen/gen_llvm_ir_macros.py \ - --output rasterizer/jitter \ + --output $@ \ --gen_x86_h rasterizer/archrast/gen_ar_event.hpp: rasterizer/codegen/gen_archrast.py rasterizer/codegen/templates/gen_ar_event.hpp rasterizer/archrast/events.proto rasterizer/codegen/gen_common.py diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript index ad16162c29..aa4a8e6d55 100644 --- a/src/gallium/drivers/swr/SConscript +++ b/src/gallium/drivers/swr/SConscript @@ -51,15 +51,15 @@ swrroot = '#src/gallium/drivers/swr/' env.CodeGenerate( target = 'rasterizer/codegen/gen_knobs.cpp', script = swrroot + 'rasterizer/codegen/gen_knobs.py', -source = 'rasterizer/codegen/templates/gen_knobs.cpp', -command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp' +source = '', +command = python_cmd + ' $SCRIPT --output $TARGET --gen_cpp' ) env.CodeGenerate( target = 'rasterizer/codegen/gen_knobs.h', script = swrroot + 'rasterizer/codegen/gen_knobs.py', -source = 'rasterizer/codegen/templates/gen_knobs.cpp', -command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h' +source = '', +command = python_cmd + ' $SCRIPT --output $TARGET --gen_h' ) env.CodeGenerate( @@ -73,14 +73,14 @@ env.CodeGenerate( target = 'rasterizer/jitter/gen_builder.hpp', script = swrroot + 'rasterizer/codegen/gen_llvm_ir_macros.py', source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'), -command = python_cmd + ' $SCRIPT --input $SOURCE --output rasterizer/jitter --gen_h' +command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h' ) env.CodeGenerate( target = 'rasterizer/jitter/gen_builder_x86.hpp', script = swrroot + 'rasterizer/codegen/gen_llvm_ir_macros.py', source = '', -command = python_cmd + ' $SCRIPT --output rasterizer/jitter --gen_x86_h' +command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_h' ) env.CodeGenerate( @@ -127,7 +127,8 @@ env.CodeGenerate( env.CodeGenerate( target = 'rasterizer/core/gen_BackendPixelRate0.cpp', script = swrroot + 'rasterizer/codegen/gen_backends.py', -command = python_cmd + ' $SCRIPT --output rasterizer/core --dim 5 2 3 2 2 2 --split 0 --cpp' +source = swrroot + 'rasterizer/codegen/templates/gen_backend.cpp', +command = python_cmd + ' $SCRIPT --output $TARGET --template $SOURCE --dim 5 2 3 2 2 2 --split 0 --cpp' ) # Auto-generated .cpp files (that need to generate object files) diff --git a/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py b/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py index 242ab7a73e..8f7ba94ba1 100644 --- a/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py +++ b/src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py @@ -34,7 +34,10 @@ def main(args=sys.argv[1:]): parser = ArgumentParser("Generate files and initialization functions for all permutuations of BackendPixelRate.") parser.add_argument('--dim', help="gBackendPixelRateTable array dimensions", nargs='+', type=int, required=True) parser.add_argument('--outdir', help="output directory", nargs='?', type=str, default=thisDir) +parser.add_argument('--output', help="output filename", nargs='?', type=str) +parser.add_argument('--template', help="input template", nargs='?', type=str) parser.add_argument('--split', help="how many lines of initialization per file [0=no split]", nargs='?', type=int, default='512') +parser.add_argument('--index', help="file to output", nargs='?', type=int, default=0) parser.add_argument('--cpp', help="Generate cpp file(s)",
[Mesa-dev] [PATCH] swr: add linux to scons build
Make swr compile for both linux and windows. --- src/gallium/drivers/swr/SConscript| 7 +-- src/gallium/targets/libgl-xlib/SConscript | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript index eca5dba..5e3784b 100644 --- a/src/gallium/drivers/swr/SConscript +++ b/src/gallium/drivers/swr/SConscript @@ -17,11 +17,6 @@ if env['LLVM_VERSION'] < distutils.version.LooseVersion('3.9'): env['swr'] = False Return() -if env['platform'] != 'windows': -print "warning: swr scons build only supports windows: not building swr" -env['swr'] = False -Return() - env.MSVC2013Compat() env = env.Clone() @@ -205,7 +200,7 @@ envavx2.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX2']) if env['platform'] == 'windows': envavx2.Append(CCFLAGS = ['/arch:AVX2']) else: -envavx2.Append(CCFLAGS = ['-mavx2']) +envavx2.Append(CCFLAGS = ['-mavx2', '-mfma', '-mbmi2', '-mf16c']) swrAVX2 = envavx2.SharedLibrary( target = 'swrAVX2', diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index d01bb3c..a81ac79 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -49,7 +49,7 @@ if env['llvm']: env.Prepend(LIBS = [llvmpipe]) if env['swr']: -env.Append(CPPDEFINES = 'HAVE_SWR') +env.Append(CPPDEFINES = 'GALLIUM_SWR') env.Prepend(LIBS = [swr]) if env['platform'] != 'darwin': -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] swr: Add polygon stipple support
Add polygon stipple functionality to the fragment shader. Explicitly turn off polygon stipple for lines and points, since we do them using tris. --- src/gallium/drivers/swr/swr_context.h | 4 ++- src/gallium/drivers/swr/swr_shader.cpp | 56 ++ src/gallium/drivers/swr/swr_shader.h | 1 + src/gallium/drivers/swr/swr_state.cpp | 27 ++-- src/gallium/drivers/swr/swr_state.h| 5 +++ 5 files changed, 84 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/swr/swr_context.h b/src/gallium/drivers/swr/swr_context.h index be65a20..9d80c70 100644 --- a/src/gallium/drivers/swr/swr_context.h +++ b/src/gallium/drivers/swr/swr_context.h @@ -98,6 +98,8 @@ struct swr_draw_context { float userClipPlanes[PIPE_MAX_CLIP_PLANES][4]; + uint32_t polyStipple[32]; + SWR_SURFACE_STATE renderTargets[SWR_NUM_ATTACHMENTS]; void *pStats; }; @@ -127,7 +129,7 @@ struct swr_context { struct pipe_constant_buffer constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS]; struct pipe_framebuffer_state framebuffer; - struct pipe_poly_stipple poly_stipple; + struct swr_poly_stipple poly_stipple; struct pipe_scissor_state scissor; SWR_RECT swr_scissor; struct pipe_sampler_view * diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp index 6fc0596..d8f5512 100644 --- a/src/gallium/drivers/swr/swr_shader.cpp +++ b/src/gallium/drivers/swr/swr_shader.cpp @@ -165,6 +165,9 @@ swr_generate_fs_key(struct swr_jit_fs_key , sizeof(key.vs_output_semantic_idx)); swr_generate_sampler_key(swr_fs->info, ctx, PIPE_SHADER_FRAGMENT, key); + + key.poly_stipple_enable = ctx->rasterizer->poly_stipple_enable && + ctx->poly_stipple.prim_is_poly; } void @@ -1099,17 +1102,58 @@ BuilderSWR::CompileFS(struct swr_context *ctx, swr_jit_fs_key ) memset(_values, 0, sizeof(system_values)); struct lp_build_mask_context mask; + bool uses_mask = false; - if (swr_fs->info.base.uses_kill) { - Value *mask_val = LOAD(pPS, {0, SWR_PS_CONTEXT_activeMask}, "activeMask"); + if (swr_fs->info.base.uses_kill || + key.poly_stipple_enable) { + Value *vActiveMask = NULL; + if (swr_fs->info.base.uses_kill) { + vActiveMask = LOAD(pPS, {0, SWR_PS_CONTEXT_activeMask}, "activeMask"); + } + if (key.poly_stipple_enable) { + // first get fragment xy coords and clip to stipple bounds + Value *vXf = LOAD(pPS, {0, SWR_PS_CONTEXT_vX, PixelPositions_UL}); + Value *vYf = LOAD(pPS, {0, SWR_PS_CONTEXT_vY, PixelPositions_UL}); + Value *vXu = FP_TO_UI(vXf, mSimdInt32Ty); + Value *vYu = FP_TO_UI(vYf, mSimdInt32Ty); + + // stipple pattern is 32x32, which means that one line of stipple + // is stored in one word: + // vXstipple is bit offset inside 32-bit stipple word + // vYstipple is word index is stipple array + Value *vXstipple = AND(vXu, VIMMED1(0x1f)); // & (32-1) + Value *vYstipple = AND(vYu, VIMMED1(0x1f)); // & (32-1) + + // grab stipple pattern base address + Value *stipplePtr = GEP(hPrivateData, {0, swr_draw_context_polyStipple, 0}); + stipplePtr = BITCAST(stipplePtr, mInt8PtrTy); + + // peform a gather to grab stipple words for each lane + Value *vStipple = GATHERDD(VUNDEF_I(), stipplePtr, vYstipple, +VIMMED1(0x), C((char)4)); + + // create a mask with one bit corresponding to the x stipple + // and AND it with the pattern, to see if we have a bit + Value *vBitMask = LSHR(VIMMED1(0x8000), vXstipple); + Value *vStippleMask = AND(vStipple, vBitMask); + vStippleMask = ICMP_NE(vStippleMask, VIMMED1(0)); + vStippleMask = VMASK(vStippleMask); + + if (swr_fs->info.base.uses_kill) { +vActiveMask = AND(vActiveMask, vStippleMask); + } else { +vActiveMask = vStippleMask; + } + } lp_build_mask_begin( - , gallivm, lp_type_float_vec(32, 32 * 8), wrap(mask_val)); + , gallivm, lp_type_float_vec(32, 32 * 8), wrap(vActiveMask)); + uses_mask = true; } lp_build_tgsi_soa(gallivm, swr_fs->pipe.tokens, lp_type_float_vec(32, 32 * 8), - swr_fs->info.base.uses_kill ? : NULL, // mask + uses_mask ? : NULL, // mask wrap(consts_ptr), wrap(const_sizes_ptr), _values, @@ -1172,13 +1216,13 @@ BuilderSWR::CompileFS(struct swr_context *ctx, swr_jit_fs_key ) } LLVMValueRef mask_result = 0; - if (swr_fs->info.base.uses_kill) { + if (uses_mask) { mask_result = lp_build_mask_end(); } IRB()->SetInsertPoint(unwrap(LLVMGetInsertBlock(gallivm->builder))); - if (swr_fs->info.base.uses_kill) { + if (uses_mask) {
[Mesa-dev] [PATCH] swr: Fix swr osmesa build
--- src/gallium/targets/osmesa/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/targets/osmesa/SConscript b/src/gallium/targets/osmesa/SConscript index 47937a2..7be1b48 100644 --- a/src/gallium/targets/osmesa/SConscript +++ b/src/gallium/targets/osmesa/SConscript @@ -31,7 +31,7 @@ if env['llvm']: env.Prepend(LIBS = [llvmpipe]) if env['swr']: -env.Append(CPPDEFINES = 'HAVE_SWR') +env.Append(CPPDEFINES = 'GALLIUM_SWR') env.Prepend(LIBS = [swr]) if env['platform'] == 'windows': -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] swr: fix transform feedback logic
The shader that is used to copy vertex data out of the vs/gs shaders to the user-specified buffer (streamout os SO shader) was not using the correct offsets. Adjust the offsets that are used just for the SO shader: - Make sure that position is handled in the same special way as in the vs/gs shaders - Use the correct offset to be passed in the core - consolidate register slot mapping logic into one function, since it's been calculated in 2 different places (one for calcuating the slot mask, and one for the register offsets themselves Also make room for all attibutes in the backend vertex area. Fixes: - all vtk GL2PS tests - 18 piglit tests (16 ext_transform_feedback tests, arb-quads-follow-provoking-vertex and primitive-type gl_points --- src/gallium/drivers/swr/swr_draw.cpp | 11 --- src/gallium/drivers/swr/swr_state.cpp | 31 +-- src/gallium/drivers/swr/swr_state.h | 3 +++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp index 62ad3f7..218de0f 100644 --- a/src/gallium/drivers/swr/swr_draw.cpp +++ b/src/gallium/drivers/swr/swr_draw.cpp @@ -26,6 +26,7 @@ #include "swr_resource.h" #include "swr_fence.h" #include "swr_query.h" +#include "swr_state.h" #include "jit_api.h" #include "util/u_draw.h" @@ -81,8 +82,11 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) offsets[output_buffer] = so->output[i].dst_offset; } +unsigned attrib_slot = so->output[i].register_index; +attrib_slot = swr_so_adjust_attrib(attrib_slot, ctx->vs); + state.stream.decl[num].bufferIndex = output_buffer; -state.stream.decl[num].attribSlot = so->output[i].register_index - 1; +state.stream.decl[num].attribSlot = attrib_slot; state.stream.decl[num].componentMask = ((1 << so->output[i].num_components) - 1) << so->output[i].start_component; @@ -130,9 +134,10 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) SWR_FRONTEND_STATE feState = {0}; feState.vsVertexSize = - VERTEX_ATTRIB_START_SLOT + + VERTEX_ATTRIB_START_SLOT + ctx->vs->info.base.num_outputs - - (ctx->vs->info.base.writes_position ? 1 : 0); + - (ctx->vs->info.base.writes_position ? 1 : 0) + + ctx->fs->info.base.num_outputs; if (ctx->rasterizer->flatshade_first) { feState.provokingVertex = {1, 0, 0}; diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 501fdea..3e07929 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -345,13 +345,15 @@ swr_create_vs_state(struct pipe_context *pipe, // soState.streamToRasterizer not used for (uint32_t i = 0; i < stream_output->num_outputs; i++) { + unsigned attrib_slot = stream_output->output[i].register_index; + attrib_slot = swr_so_adjust_attrib(attrib_slot, swr_vs); swr_vs->soState.streamMasks[stream_output->output[i].stream] |= -1 << (stream_output->output[i].register_index - 1); +(1 << attrib_slot); } for (uint32_t i = 0; i < MAX_SO_STREAMS; i++) { swr_vs->soState.streamNumEntries[i] = _mm_popcnt_u32(swr_vs->soState.streamMasks[i]); -swr_vs->soState.vertexAttribOffset[i] = VERTEX_ATTRIB_START_SLOT; // TODO: optimize +swr_vs->soState.vertexAttribOffset[i] = 0; } } @@ -1777,6 +1779,31 @@ swr_update_derived(struct pipe_context *pipe, ctx->dirty = post_update_dirty_flags; } +unsigned +swr_so_adjust_attrib(unsigned in_attrib, + swr_vertex_shader *swr_vs) +{ + ubyte semantic_name; + unsigned attrib; + + attrib = in_attrib + VERTEX_ATTRIB_START_SLOT; + + if (swr_vs) { + semantic_name = swr_vs->info.base.output_semantic_name[in_attrib]; + if (semantic_name == TGSI_SEMANTIC_POSITION) { + attrib = VERTEX_POSITION_SLOT; + } else { + for (int i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) { +if (swr_vs->info.base.output_semantic_name[i] == TGSI_SEMANTIC_POSITION) { + attrib--; + break; +} + } + } + } + + return attrib; +} static struct pipe_stream_output_target * swr_create_so_target(struct pipe_context *pipe, diff --git a/src/gallium/drivers/swr/swr_state.h b/src/gallium/drivers/swr/swr_state.h index 7940a96..8cbd463 100644 --- a/src/gallium/drivers/swr/swr_state.h +++ b/src/gallium/drivers/swr/swr_state.h @@ -110,6 +110,9 @@ struct swr_derived_state { void swr_update_derived(struct pipe_context *, const struct pipe_draw_info * = nullptr); +unsigned swr_so_adjust_attrib(unsigned in_attrib, + swr_vertex_shader *swr_vs); + /* * Conversion functions:
[Mesa-dev] [PATCH v2] swr: fix transform feedback logic
The shader that is used to copy vertex data out of the vs/gs shaders to the user-specified buffer (streamout or SO shader) was not using the correct offsets. Adjust the offsets that are used just for the SO shader: - Make sure that position is handled in the same special way as in the vs/gs shaders - Use the correct offset to be passed in the core - consolidate register slot mapping logic into one function, since it's been calculated in 2 different places (one for calcuating the slot mask, and one for the register offsets themselves Also make room for all attibutes in the backend vertex area. Fixes: - all vtk GL2PS tests - 18 piglit tests (16 ext_transform_feedback tests, arb-quads-follow-provoking-vertex and primitive-type gl_points v2: - take care of more SGV slots in slot mapping logic - trim feState.vsVertexSize - fix GS interface and incorporate GS while calculating vsVertexSize Note that vsVertexSize is used in the core as the one parameter that controls vertex size between all stages, so it has to be adjusted appropriately for the whole vs/gs/fs pipeline. fixes: - fixes total of 20 piglit tests CC: 17.2--- src/gallium/drivers/swr/swr_draw.cpp | 38 +- src/gallium/drivers/swr/swr_shader.cpp | 32 +++- src/gallium/drivers/swr/swr_shader.h | 3 +++ src/gallium/drivers/swr/swr_state.cpp | 5 +++-- 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp index 62ad3f7..38a711e 100644 --- a/src/gallium/drivers/swr/swr_draw.cpp +++ b/src/gallium/drivers/swr/swr_draw.cpp @@ -81,8 +81,11 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) offsets[output_buffer] = so->output[i].dst_offset; } +unsigned attrib_slot = so->output[i].register_index; +attrib_slot = swr_so_adjust_attrib(attrib_slot, ctx->vs); + state.stream.decl[num].bufferIndex = output_buffer; -state.stream.decl[num].attribSlot = so->output[i].register_index - 1; +state.stream.decl[num].attribSlot = attrib_slot; state.stream.decl[num].componentMask = ((1 << so->output[i].num_components) - 1) << so->output[i].start_component; @@ -129,10 +132,35 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) * XXX setup provokingVertex & topologyProvokingVertex */ SWR_FRONTEND_STATE feState = {0}; - feState.vsVertexSize = - VERTEX_ATTRIB_START_SLOT + - + ctx->vs->info.base.num_outputs - - (ctx->vs->info.base.writes_position ? 1 : 0); + // feState.vsVertexSize seeds the PA size that is used as an interface + // between all the shader stages, so it has to be large enough to + // incorporate all interfaces between stages + + // max of gs and vs num_outputs + feState.vsVertexSize = ctx->vs->info.base.num_outputs; + if (ctx->gs && + ctx->gs->info.base.num_outputs > feState.vsVertexSize) { + feState.vsVertexSize = ctx->gs->info.base.num_outputs; + } + + if (ctx->vs->info.base.num_outputs) + // gs does not adjust for position in SGV slot at input from vs + if (!ctx->gs) + feState.vsVertexSize--; + + // other (non-SGV) slots start at VERTEX_ATTRIB_START_SLOT + feState.vsVertexSize += VERTEX_ATTRIB_START_SLOT; + + // The PA in the clipper does not handle BE vertex sizes + // different from FE. Increase vertexsize only for the cases that needed it + + // primid needs a slot + if (ctx->fs->info.base.uses_primid) + feState.vsVertexSize++; + // sprite coord enable + if (ctx->rasterizer->sprite_coord_enable) + feState.vsVertexSize++; + if (ctx->rasterizer->flatshade_first) { feState.provokingVertex = {1, 0, 0}; diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp index 83b49c4..0a81eaa 100644 --- a/src/gallium/drivers/swr/swr_shader.cpp +++ b/src/gallium/drivers/swr/swr_shader.cpp @@ -414,7 +414,10 @@ BuilderSWR::swr_gs_llvm_emit_vertex(const struct lp_build_tgsi_gs_iface *gs_base } else if (iface->info->output_semantic_name[attrib] == TGSI_SEMANTIC_POSITION) { attribSlot = VERTEX_POSITION_SLOT; } else { - attribSlot = VERTEX_ATTRIB_START_SLOT + attrib - 1; + attribSlot = VERTEX_ATTRIB_START_SLOT + attrib; + if (iface->info->writes_position) { + attribSlot--; + } } #if USE_SIMD16_FRONTEND @@ -923,6 +926,33 @@ swr_compile_vs(struct swr_context *ctx, swr_jit_vs_key ) return func; } +unsigned +swr_so_adjust_attrib(unsigned in_attrib, + swr_vertex_shader *swr_vs) +{ + ubyte semantic_name; + unsigned attrib; + + attrib = in_attrib + VERTEX_ATTRIB_START_SLOT; + + if (swr_vs) { + semantic_name =
[Mesa-dev] [PATCH 2/2] swr: Fix polygonmode for front==back
Add logic for converting enums and also making sure stipple works. CC:--- src/gallium/drivers/swr/swr_state.cpp | 14 +- src/gallium/drivers/swr/swr_state.h | 20 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 56b1374..24a6759 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -201,6 +201,12 @@ swr_create_rasterizer_state(struct pipe_context *pipe, struct pipe_rasterizer_state *state; state = (pipe_rasterizer_state *)mem_dup(rast, sizeof *rast); + if (state) { + if (state->fill_front != state->fill_back) { + assert(0 && "front != back polygon mode not supported"); + } + } + return state; } @@ -1153,6 +1159,10 @@ swr_update_derived(struct pipe_context *pipe, rastState->slopeScaledDepthBias = 0; rastState->depthBiasClamp = 0; } + + /* translate polygon mode, at least for the front==back case */ + rastState->fillMode = swr_convert_fill_mode(rasterizer->fill_front); + struct pipe_surface *zb = fb->zsbuf; if (zb && swr_resource(zb->texture)->has_depth) rastState->depthFormat = swr_resource(zb->texture)->swr.format; @@ -1423,7 +1433,9 @@ swr_update_derived(struct pipe_context *pipe, /* and points, since we rasterize them as triangles, too */ /* Has to be before fragment shader, since it sets SWR_NEW_FS */ if (p_draw_info) { - bool new_prim_is_poly = (u_reduced_prim(p_draw_info->mode) == PIPE_PRIM_TRIANGLES); + bool new_prim_is_poly = + (u_reduced_prim(p_draw_info->mode) == PIPE_PRIM_TRIANGLES) && + (ctx->derived.rastState.fillMode == SWR_FILLMODE_SOLID); if (new_prim_is_poly != ctx->poly_stipple.prim_is_poly) { ctx->dirty |= SWR_NEW_FS; ctx->poly_stipple.prim_is_poly = new_prim_is_poly; diff --git a/src/gallium/drivers/swr/swr_state.h b/src/gallium/drivers/swr/swr_state.h index 9a8c4e1..7940a96 100644 --- a/src/gallium/drivers/swr/swr_state.h +++ b/src/gallium/drivers/swr/swr_state.h @@ -376,4 +376,24 @@ swr_convert_prim_topology(const unsigned mode) return TOP_UNKNOWN; } }; + +/* + * convert mesa PIPE_POLYGON_MODE_X to SWR enum SWR_FILLMODE + */ +static INLINE enum SWR_FILLMODE +swr_convert_fill_mode(const unsigned mode) +{ + switch(mode) { + case PIPE_POLYGON_MODE_FILL: + return SWR_FILLMODE_SOLID; + case PIPE_POLYGON_MODE_LINE: + return SWR_FILLMODE_WIREFRAME; + case PIPE_POLYGON_MODE_POINT: + return SWR_FILLMODE_POINT; + default: + assert(0 && "Unknown fillmode"); + return SWR_FILLMODE_SOLID; // at least do something sensible + } +} + #endif -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] swr: [rasterizer core] support polygonmode point
add support in the binner: Split BinPoints into BinPostSetupPoints, so we can use it from BinTriangles, since setup is already done. CC:--- src/gallium/drivers/swr/rasterizer/core/binner.cpp | 175 ++--- 1 file changed, 117 insertions(+), 58 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp index 9d36f21..f69db29 100644 --- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp @@ -36,9 +36,11 @@ // Function Prototype void BinPostSetupLines(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[3], simdscalar vRecipW[2], uint32_t primMask, simdscalari primID, simdscalari viewportIdx); +void BinPostSetupPoints(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[], uint32_t primMask, simdscalari primID, simdscalari viewportIdx); #if USE_SIMD16_FRONTEND void BinPostSetupLines_simd16(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simd16vector prims[3], simd16scalar vRecipW[2], uint32_t primMask, simd16scalari primID, simd16scalari viewportIdx); +void BinPostSetupPoints_simd16(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[], uint32_t primMask, simdscalari primID, simdscalari viewportIdx); #endif // @@ -745,6 +747,14 @@ void BinTriangles( AR_END(FEBinTriangles, 1); return; +} else if (rastState.fillMode == SWR_FILLMODE_POINT) +{ +// bin 3 points + +BinPostSetupPoints(pDC, pa, workerId, [0], triMask, primID, viewportIdx); +BinPostSetupPoints(pDC, pa, workerId, [1], triMask, primID, viewportIdx); +BinPostSetupPoints(pDC, pa, workerId, [2], triMask, primID, viewportIdx); +return; } /// Note: these variable initializations must stay above any 'goto endBenTriangles' @@ -1494,18 +1504,11 @@ PFN_PROCESS_PRIMS_SIMD16 GetBinTrianglesFunc_simd16(bool IsConservative) #endif -// -/// @brief Bin SIMD points to the backend. Only supports point size of 1 -/// @param pDC - pointer to draw context. -/// @param pa - The primitive assembly object. -/// @param workerId - thread's worker id. Even thread has a unique id. -/// @param tri - Contains point position data for SIMDs worth of points. -/// @param primID - Primitive ID for each point. -void BinPoints( +void BinPostSetupPoints( DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, -simdvector prim[3], +simdvector prim[], uint32_t primMask, simdscalari primID, simdscalari viewportIdx) @@ -1517,7 +1520,6 @@ void BinPoints( simdvector& primVerts = prim[0]; const API_STATE& state = GetApiState(pDC); -const SWR_FRONTEND_STATE& feState = state.frontendState; const SWR_GS_STATE& gsState = state.gsState; const SWR_RASTSTATE& rastState = state.rastState; const uint32_t *pViewportIndex = (uint32_t *) @@ -1526,30 +1528,6 @@ void BinPoints( PFN_PROCESS_ATTRIBUTES pfnProcessAttribs = GetProcessAttributesFunc(1, state.backendState.swizzleEnable, state.backendState.constantInterpolationMask); -if (!feState.vpTransformDisable) -{ -// perspective divide -simdscalar vRecipW0 = _simd_div_ps(_simd_set1_ps(1.0f), primVerts.w); -primVerts.x = _simd_mul_ps(primVerts.x, vRecipW0); -primVerts.y = _simd_mul_ps(primVerts.y, vRecipW0); -primVerts.z = _simd_mul_ps(primVerts.z, vRecipW0); - -// viewport transform to screen coords -if (state.gsState.emitsViewportArrayIndex) -{ -viewportTransform<1>(, state.vpMatrices, viewportIdx); -} -else -{ -viewportTransform<1>(, state.vpMatrices); -} -} - -// adjust for pixel center location -simdscalar offset = g_pixelOffsets[rastState.pixelLocation]; -primVerts.x = _simd_add_ps(primVerts.x, offset); -primVerts.y = _simd_add_ps(primVerts.y, offset); - // convert to fixed point simdscalari vXi, vYi; vXi = fpToFixedPointVertical(primVerts.x); @@ -1837,40 +1815,35 @@ void BinPoints( AR_END(FEBinPoints, 1); } -#if USE_SIMD16_FRONTEND -void BinPoints_simd16( +// +/// @brief Bin SIMD points to the backend. Only supports point size of 1 +/// @param pDC - pointer to draw context. +/// @param pa - The primitive assembly object. +/// @param workerId - thread's worker id. Even thread has a unique id. +/// @param tri - Contains point position data for SIMDs worth of points. +/// @param primID - Primitive ID for each point. +void BinPoints( DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, -simd16vector prim[3], +simdvector prim[3],
[Mesa-dev] [PATCH v2 1/2] swr: [rasterizer core] support polygonmode point
add support in the binner: Split BinPoints into BinPostSetupPoints, so we can use it from BinTriangles, since setup is already done. v2: remove cc stable --- src/gallium/drivers/swr/rasterizer/core/binner.cpp | 175 ++--- 1 file changed, 117 insertions(+), 58 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp index 9d36f21..f69db29 100644 --- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp @@ -36,9 +36,11 @@ // Function Prototype void BinPostSetupLines(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[3], simdscalar vRecipW[2], uint32_t primMask, simdscalari primID, simdscalari viewportIdx); +void BinPostSetupPoints(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[], uint32_t primMask, simdscalari primID, simdscalari viewportIdx); #if USE_SIMD16_FRONTEND void BinPostSetupLines_simd16(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simd16vector prims[3], simd16scalar vRecipW[2], uint32_t primMask, simd16scalari primID, simd16scalari viewportIdx); +void BinPostSetupPoints_simd16(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[], uint32_t primMask, simdscalari primID, simdscalari viewportIdx); #endif // @@ -745,6 +747,14 @@ void BinTriangles( AR_END(FEBinTriangles, 1); return; +} else if (rastState.fillMode == SWR_FILLMODE_POINT) +{ +// bin 3 points + +BinPostSetupPoints(pDC, pa, workerId, [0], triMask, primID, viewportIdx); +BinPostSetupPoints(pDC, pa, workerId, [1], triMask, primID, viewportIdx); +BinPostSetupPoints(pDC, pa, workerId, [2], triMask, primID, viewportIdx); +return; } /// Note: these variable initializations must stay above any 'goto endBenTriangles' @@ -1494,18 +1504,11 @@ PFN_PROCESS_PRIMS_SIMD16 GetBinTrianglesFunc_simd16(bool IsConservative) #endif -// -/// @brief Bin SIMD points to the backend. Only supports point size of 1 -/// @param pDC - pointer to draw context. -/// @param pa - The primitive assembly object. -/// @param workerId - thread's worker id. Even thread has a unique id. -/// @param tri - Contains point position data for SIMDs worth of points. -/// @param primID - Primitive ID for each point. -void BinPoints( +void BinPostSetupPoints( DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, -simdvector prim[3], +simdvector prim[], uint32_t primMask, simdscalari primID, simdscalari viewportIdx) @@ -1517,7 +1520,6 @@ void BinPoints( simdvector& primVerts = prim[0]; const API_STATE& state = GetApiState(pDC); -const SWR_FRONTEND_STATE& feState = state.frontendState; const SWR_GS_STATE& gsState = state.gsState; const SWR_RASTSTATE& rastState = state.rastState; const uint32_t *pViewportIndex = (uint32_t *) @@ -1526,30 +1528,6 @@ void BinPoints( PFN_PROCESS_ATTRIBUTES pfnProcessAttribs = GetProcessAttributesFunc(1, state.backendState.swizzleEnable, state.backendState.constantInterpolationMask); -if (!feState.vpTransformDisable) -{ -// perspective divide -simdscalar vRecipW0 = _simd_div_ps(_simd_set1_ps(1.0f), primVerts.w); -primVerts.x = _simd_mul_ps(primVerts.x, vRecipW0); -primVerts.y = _simd_mul_ps(primVerts.y, vRecipW0); -primVerts.z = _simd_mul_ps(primVerts.z, vRecipW0); - -// viewport transform to screen coords -if (state.gsState.emitsViewportArrayIndex) -{ -viewportTransform<1>(, state.vpMatrices, viewportIdx); -} -else -{ -viewportTransform<1>(, state.vpMatrices); -} -} - -// adjust for pixel center location -simdscalar offset = g_pixelOffsets[rastState.pixelLocation]; -primVerts.x = _simd_add_ps(primVerts.x, offset); -primVerts.y = _simd_add_ps(primVerts.y, offset); - // convert to fixed point simdscalari vXi, vYi; vXi = fpToFixedPointVertical(primVerts.x); @@ -1837,40 +1815,35 @@ void BinPoints( AR_END(FEBinPoints, 1); } -#if USE_SIMD16_FRONTEND -void BinPoints_simd16( +// +/// @brief Bin SIMD points to the backend. Only supports point size of 1 +/// @param pDC - pointer to draw context. +/// @param pa - The primitive assembly object. +/// @param workerId - thread's worker id. Even thread has a unique id. +/// @param tri - Contains point position data for SIMDs worth of points. +/// @param primID - Primitive ID for each point. +void BinPoints( DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, -simd16vector prim[3], +simdvector prim[3], uint32_t primMask,
[Mesa-dev] [PATCH v2 2/2] swr: Fix polygonmode for front==back
Add logic for converting enums and also making sure stipple works. v2: remove cc stable, and remove "not implemented" assert --- src/gallium/drivers/swr/swr_state.cpp | 8 +++- src/gallium/drivers/swr/swr_state.h | 20 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 56b1374..12b4e9d 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -1153,6 +1153,10 @@ swr_update_derived(struct pipe_context *pipe, rastState->slopeScaledDepthBias = 0; rastState->depthBiasClamp = 0; } + + /* translate polygon mode, at least for the front==back case */ + rastState->fillMode = swr_convert_fill_mode(rasterizer->fill_front); + struct pipe_surface *zb = fb->zsbuf; if (zb && swr_resource(zb->texture)->has_depth) rastState->depthFormat = swr_resource(zb->texture)->swr.format; @@ -1423,7 +1427,9 @@ swr_update_derived(struct pipe_context *pipe, /* and points, since we rasterize them as triangles, too */ /* Has to be before fragment shader, since it sets SWR_NEW_FS */ if (p_draw_info) { - bool new_prim_is_poly = (u_reduced_prim(p_draw_info->mode) == PIPE_PRIM_TRIANGLES); + bool new_prim_is_poly = + (u_reduced_prim(p_draw_info->mode) == PIPE_PRIM_TRIANGLES) && + (ctx->derived.rastState.fillMode == SWR_FILLMODE_SOLID); if (new_prim_is_poly != ctx->poly_stipple.prim_is_poly) { ctx->dirty |= SWR_NEW_FS; ctx->poly_stipple.prim_is_poly = new_prim_is_poly; diff --git a/src/gallium/drivers/swr/swr_state.h b/src/gallium/drivers/swr/swr_state.h index 9a8c4e1..7940a96 100644 --- a/src/gallium/drivers/swr/swr_state.h +++ b/src/gallium/drivers/swr/swr_state.h @@ -376,4 +376,24 @@ swr_convert_prim_topology(const unsigned mode) return TOP_UNKNOWN; } }; + +/* + * convert mesa PIPE_POLYGON_MODE_X to SWR enum SWR_FILLMODE + */ +static INLINE enum SWR_FILLMODE +swr_convert_fill_mode(const unsigned mode) +{ + switch(mode) { + case PIPE_POLYGON_MODE_FILL: + return SWR_FILLMODE_SOLID; + case PIPE_POLYGON_MODE_LINE: + return SWR_FILLMODE_WIREFRAME; + case PIPE_POLYGON_MODE_POINT: + return SWR_FILLMODE_POINT; + default: + assert(0 && "Unknown fillmode"); + return SWR_FILLMODE_SOLID; // at least do something sensible + } +} + #endif -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] swr: invalidate attachment on transition change
Consider the following RT attachment order: 1. Attach surfaces attachments 0 & 1, and render with them 2. Detach 0 & 1 3. Re-attach 0 & 1 to different surfaces 4. Render with the new attachment The definition of a tile being resolved is that local changes have been flushed out to the surface, hence there is no need to reload the tile before it's written to. For an invalid tile, the tile has to be reloaded from the surface before rendering. Stage (2) was marking hot tiles for attachements 0 & 1 as RESOLVED, which means that the hot tiles can be written out to memory with no need to read them back in (they are "clean"). They need to be marked as resolved here, because a surface may be destroyed after a detach, and we don't want to have un-resolved tiles that may force a readback from a NULL (destroyed) surface. (Part of a destroy is detach all attachments first) Stage (3), during the no att -> att transition, we need to realize that the "new" surface tiles need to be fetched fresh from the new surface, instead of using the resolved tiles, that belong to a stale attachment. This is done by marking the hot tiles as invalid in stage (3), when we realize that a new attachment is being made, so that they are re-fetched during rendering in stage (4). Also note that hot tiles are indexed by attachment. - Fixes VTK dual depth-peeling tests. - No piglit changes --- src/gallium/drivers/swr/swr_draw.cpp | 19 +++ src/gallium/drivers/swr/swr_resource.h | 4 src/gallium/drivers/swr/swr_state.cpp | 5 + 3 files changed, 28 insertions(+) diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp index 03c82a7..ac300e2 100644 --- a/src/gallium/drivers/swr/swr_draw.cpp +++ b/src/gallium/drivers/swr/swr_draw.cpp @@ -215,6 +215,25 @@ swr_finish(struct pipe_context *pipe) swr_fence_reference(pipe->screen, , NULL); } +/* + * Invalidate tiles so they can be reloaded back when needed + */ +void +swr_invalidate_render_target(struct pipe_context *pipe, + uint32_t attachment, + uint16_t width, uint16_t height) +{ + struct swr_context *ctx = swr_context(pipe); + + /* grab the rect from the passed in arguments */ + swr_update_draw_context(ctx); + SWR_RECT full_rect = + {0, 0, (int32_t)width, (int32_t)height}; + SwrInvalidateTiles(ctx->swrContext, + 1 << attachment, + full_rect); +} + /* * Store SWR HotTiles back to renderTarget surface. diff --git a/src/gallium/drivers/swr/swr_resource.h b/src/gallium/drivers/swr/swr_resource.h index ae9954c..4effd46 100644 --- a/src/gallium/drivers/swr/swr_resource.h +++ b/src/gallium/drivers/swr/swr_resource.h @@ -96,6 +96,10 @@ swr_resource_data(struct pipe_resource *resource) } +void swr_invalidate_render_target(struct pipe_context *pipe, + uint32_t attachment, + uint16_t width, uint16_t height); + void swr_store_render_target(struct pipe_context *pipe, uint32_t attachment, enum SWR_TILE_STATE post_tile_state); diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 08549e5..deae4e6 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -933,6 +933,11 @@ swr_change_rt(struct swr_context *ctx, * INVALID so they are reloaded from surface. */ swr_store_render_target(>pipe, attachment, SWR_TILE_INVALID); need_fence = true; + } else { + /* if no previous attachment, invalidate tiles that may be marked + * RESOLVED because of an old attachment */ + swr_invalidate_render_target(>pipe, attachment, sf->width, sf->height); + /* no need to set fence here */ } /* Make new attachment */ -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] swr/rast: Include definition of missing function
Inline function SWR_MULTISAMPLE_POS::PrecalcSampleData() was missing definition. Include definition in core/state_funcs.h. Fixes windows build. --- src/gallium/drivers/swr/swr_state.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index c87393c..12da99f 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -31,6 +31,7 @@ #include "jit_api.h" #include "gen_state_llvm.h" #include "core/multisample.h" +#include "core/state_funcs.h" #include "gallivm/lp_bld_tgsi.h" #include "util/u_format.h" -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 1/2] swr/rast: support polygonmode point
Add support for polygonmode point in the binner. This is done by splitting BinPostSetupPoints from BinPoints, so the earlier call can be called from BinTriangles. Setup has already been done at the time BinPostSetupPoints needs to be called. This checkin just adds support in the rasterizer. A separate checkin will add the appropriate driver support. v2: remove cc stable v3: modified commit message and subject line --- src/gallium/drivers/swr/rasterizer/core/binner.cpp | 168 ++--- 1 file changed, 116 insertions(+), 52 deletions(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp index d011741..4c6a5b1 100644 --- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp @@ -36,9 +36,11 @@ // Function Prototype void BinPostSetupLines(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[3], simdscalar vRecipW[2], uint32_t primMask, simdscalari primID, simdscalari viewportIdx); +void BinPostSetupPoints(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[], uint32_t primMask, simdscalari primID, simdscalari viewportIdx); #if USE_SIMD16_FRONTEND void BinPostSetupLines_simd16(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simd16vector prims[3], simd16scalar vRecipW[2], uint32_t primMask, simd16scalari primID, simd16scalari viewportIdx); +void BinPostSetupPoints_simd16(DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, simdvector prims[], uint32_t primMask, simdscalari primID, simdscalari viewportIdx); #endif // @@ -745,6 +747,14 @@ void BinTriangles( AR_END(FEBinTriangles, 1); return; +} else if (rastState.fillMode == SWR_FILLMODE_POINT) +{ +// bin 3 points + +BinPostSetupPoints(pDC, pa, workerId, [0], triMask, primID, viewportIdx); +BinPostSetupPoints(pDC, pa, workerId, [1], triMask, primID, viewportIdx); +BinPostSetupPoints(pDC, pa, workerId, [2], triMask, primID, viewportIdx); +return; } /// Note: these variable initializations must stay above any 'goto endBenTriangles' @@ -1494,14 +1504,7 @@ PFN_PROCESS_PRIMS_SIMD16 GetBinTrianglesFunc_simd16(bool IsConservative) #endif -// -/// @brief Bin SIMD points to the backend. Only supports point size of 1 -/// @param pDC - pointer to draw context. -/// @param pa - The primitive assembly object. -/// @param workerId - thread's worker id. Even thread has a unique id. -/// @param tri - Contains point position data for SIMDs worth of points. -/// @param primID - Primitive ID for each point. -void BinPoints( +void BinPostSetupPoints( DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, @@ -1517,7 +1520,6 @@ void BinPoints( simdvector& primVerts = prim[0]; const API_STATE& state = GetApiState(pDC); -const SWR_FRONTEND_STATE& feState = state.frontendState; const SWR_GS_STATE& gsState = state.gsState; const SWR_RASTSTATE& rastState = state.rastState; const uint32_t *pViewportIndex = (uint32_t *) @@ -1526,25 +1528,6 @@ void BinPoints( PFN_PROCESS_ATTRIBUTES pfnProcessAttribs = GetProcessAttributesFunc(1, state.backendState.swizzleEnable, state.backendState.constantInterpolationMask); -if (!feState.vpTransformDisable) -{ -// perspective divide -simdscalar vRecipW0 = _simd_div_ps(_simd_set1_ps(1.0f), primVerts.w); -primVerts.x = _simd_mul_ps(primVerts.x, vRecipW0); -primVerts.y = _simd_mul_ps(primVerts.y, vRecipW0); -primVerts.z = _simd_mul_ps(primVerts.z, vRecipW0); - -// viewport transform to screen coords -if (state.gsState.emitsViewportArrayIndex) -{ -viewportTransform<1>(, state.vpMatrices, viewportIdx); -} -else -{ -viewportTransform<1>(, state.vpMatrices); -} -} - // adjust for pixel center location simdscalar offset = g_pixelOffsets[rastState.pixelLocation]; primVerts.x = _simd_add_ps(primVerts.x, offset); @@ -1837,40 +1820,35 @@ void BinPoints( AR_END(FEBinPoints, 1); } -#if USE_SIMD16_FRONTEND -void SIMDAPI BinPoints_simd16( +// +/// @brief Bin SIMD points to the backend. Only supports point size of 1 +/// @param pDC - pointer to draw context. +/// @param pa - The primitive assembly object. +/// @param workerId - thread's worker id. Even thread has a unique id. +/// @param tri - Contains point position data for SIMDs worth of points. +/// @param primID - Primitive ID for each point. +void BinPoints( DRAW_CONTEXT *pDC, PA_STATE& pa, uint32_t workerId, -simd16vector prim[3], +simdvector prim[3], uint32_t primMask, -
[Mesa-dev] [PATCH v3 2/2] swr: fix polygonmode for front==back
Rasterizer core only supports polygonmode front==back. Add logic for populating fillMode for the rasterizer only for that case correctly. Provide enum conversion between mesa enums and core enums. The core renders lines/points as tris. Previously, code would enable stipple for polygonmode != FILL. Modify stipple enable logic so that this works correctly. No regressions in vtk tests. Fixes the following piglit tests: pointsprite gl-1.0-edgeflag-const v2: remove cc stable, and remove "not implemented" assert v3: modified commit message --- src/gallium/drivers/swr/swr_state.cpp | 8 +++- src/gallium/drivers/swr/swr_state.h | 20 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 56b1374..12b4e9d 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -1153,6 +1153,10 @@ swr_update_derived(struct pipe_context *pipe, rastState->slopeScaledDepthBias = 0; rastState->depthBiasClamp = 0; } + + /* translate polygon mode, at least for the front==back case */ + rastState->fillMode = swr_convert_fill_mode(rasterizer->fill_front); + struct pipe_surface *zb = fb->zsbuf; if (zb && swr_resource(zb->texture)->has_depth) rastState->depthFormat = swr_resource(zb->texture)->swr.format; @@ -1423,7 +1427,9 @@ swr_update_derived(struct pipe_context *pipe, /* and points, since we rasterize them as triangles, too */ /* Has to be before fragment shader, since it sets SWR_NEW_FS */ if (p_draw_info) { - bool new_prim_is_poly = (u_reduced_prim(p_draw_info->mode) == PIPE_PRIM_TRIANGLES); + bool new_prim_is_poly = + (u_reduced_prim(p_draw_info->mode) == PIPE_PRIM_TRIANGLES) && + (ctx->derived.rastState.fillMode == SWR_FILLMODE_SOLID); if (new_prim_is_poly != ctx->poly_stipple.prim_is_poly) { ctx->dirty |= SWR_NEW_FS; ctx->poly_stipple.prim_is_poly = new_prim_is_poly; diff --git a/src/gallium/drivers/swr/swr_state.h b/src/gallium/drivers/swr/swr_state.h index 9a8c4e1..7940a96 100644 --- a/src/gallium/drivers/swr/swr_state.h +++ b/src/gallium/drivers/swr/swr_state.h @@ -376,4 +376,24 @@ swr_convert_prim_topology(const unsigned mode) return TOP_UNKNOWN; } }; + +/* + * convert mesa PIPE_POLYGON_MODE_X to SWR enum SWR_FILLMODE + */ +static INLINE enum SWR_FILLMODE +swr_convert_fill_mode(const unsigned mode) +{ + switch(mode) { + case PIPE_POLYGON_MODE_FILL: + return SWR_FILLMODE_SOLID; + case PIPE_POLYGON_MODE_LINE: + return SWR_FILLMODE_WIREFRAME; + case PIPE_POLYGON_MODE_POINT: + return SWR_FILLMODE_POINT; + default: + assert(0 && "Unknown fillmode"); + return SWR_FILLMODE_SOLID; // at least do something sensible + } +} + #endif -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] swr: Handle resource across context changes
Swr caches fb contents in tiles. Those tiles are stored on a per-context basis. When switching contexts that share resources we need to make sure that the tiles of the old context are being stored and the tiles of the new context are being invalidated (marked as invalid, hence contents need to be reloaded). The context does not get any dirty bits to identify this case. This has to be, then, coordinated by the resources that are being shared between the contexts. Add a "curr_pipe" hook in swr_resource that will allow us to identify a MakeCurrent of the above form during swr_update_derived(). At that time, we invalidate the tiles of the new context. The old context, will need to have already store its tiles by that time, which happens during glFlush(). glFlush() is being called at the beginning of MakeCurrent. So, the sequence of operations is: - At the beginning of glXMakeCurrent(), glFlush() will store the tiles of all bound surfaces of the old context. - After the store, a fence will guarantee that the all tile store make it to the surface - During swr_update_derived(), when we validate the new context, we check all resources to see what changed, and if so, we invalidate the current tiles. Fixes rendering problems with CEI/Ensight. --- src/gallium/drivers/swr/swr_context.cpp | 14 +-- src/gallium/drivers/swr/swr_draw.cpp| 19 -- src/gallium/drivers/swr/swr_resource.h | 3 +++ src/gallium/drivers/swr/swr_state.cpp | 44 + 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index e95bd3b..34d9a25 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -365,10 +365,20 @@ swr_destroy(struct pipe_context *pipe) util_blitter_destroy(ctx->blitter); for (unsigned i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { - pipe_surface_reference(>framebuffer.cbufs[i], NULL); + if (ctx->framebuffer.cbufs[i]) { + struct swr_resource *res = swr_resource(ctx->framebuffer.cbufs[i]->texture); + /* NULL curr_pipe, so we don't have a reference to a deleted pipe */ + res->curr_pipe = NULL; + pipe_surface_reference(>framebuffer.cbufs[i], NULL); + } } - pipe_surface_reference(>framebuffer.zsbuf, NULL); + if (ctx->framebuffer.zsbuf) { + struct swr_resource *res = swr_resource(ctx->framebuffer.zsbuf->texture); + /* NULL curr_pipe, so we don't have a reference to a deleted pipe */ + res->curr_pipe = NULL; + pipe_surface_reference(>framebuffer.zsbuf, NULL); + } for (unsigned i = 0; i < ARRAY_SIZE(ctx->sampler_views[0]); i++) { pipe_sampler_view_reference(>sampler_views[PIPE_SHADER_FRAGMENT][i], NULL); diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp index d7f24d6..57660c7 100644 --- a/src/gallium/drivers/swr/swr_draw.cpp +++ b/src/gallium/drivers/swr/swr_draw.cpp @@ -239,14 +239,17 @@ swr_flush(struct pipe_context *pipe, { struct swr_context *ctx = swr_context(pipe); struct swr_screen *screen = swr_screen(pipe->screen); - struct pipe_surface *cb = ctx->framebuffer.cbufs[0]; - - /* If the current renderTarget is the display surface, store tiles back to -* the surface, in preparation for present (swr_flush_frontbuffer). -* Other renderTargets get stored back when attachment changes or -* swr_surface_destroy */ - if (cb && swr_resource(cb->texture)->display_target) - swr_store_dirty_resource(pipe, cb->texture, SWR_TILE_RESOLVED); + + for (int i=0; i < ctx->framebuffer.nr_cbufs; i++) { + struct pipe_surface *cb = ctx->framebuffer.cbufs[i]; + if (cb) { + swr_store_dirty_resource(pipe, cb->texture, SWR_TILE_RESOLVED); + } + } + if (ctx->framebuffer.zsbuf) { + swr_store_dirty_resource(pipe, ctx->framebuffer.zsbuf->texture, + SWR_TILE_RESOLVED); + } if (fence) swr_fence_reference(pipe->screen, fence, screen->flush_fence); diff --git a/src/gallium/drivers/swr/swr_resource.h b/src/gallium/drivers/swr/swr_resource.h index 4a2d669..1269433 100644 --- a/src/gallium/drivers/swr/swr_resource.h +++ b/src/gallium/drivers/swr/swr_resource.h @@ -54,6 +54,9 @@ struct swr_resource { size_t secondary_mip_offsets[PIPE_MAX_TEXTURE_LEVELS]; enum swr_resource_status status; + + /* last pipe that used (validated) this resource */ + struct pipe_context *curr_pipe; }; diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 93108de..893bd6e 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -953,6 +953,47 @@ swr_change_rt(struct swr_context *ctx, return need_fence; } +/* + * for cases where resources are shared between contexts, invalidate + * this ctx's resource. so it can be fetched fresh.
[Mesa-dev] [PATCH 2/2] swr: Remove unneeeded comparison
No need to check if screen->pipe != pipe, so we can just assign it. Just do it. --- src/gallium/drivers/swr/swr_state.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 893bd6e..c6da4fc 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -1074,8 +1074,7 @@ swr_update_derived(struct pipe_context *pipe, } /* Update screen->pipe to current pipe context. */ - if (screen->pipe != pipe) - screen->pipe = pipe; + screen->pipe = pipe; /* Any state that requires dirty flags to be re-triggered sets this mask */ /* For example, user_buffer vertex and index buffers. */ -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] gallium/u_tests: fix ifdef for sync_file fences
include libsync.h only when libdrm is compiled in --- src/gallium/auxiliary/util/u_tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c index 2e931c0..3cc79af 100644 --- a/src/gallium/auxiliary/util/u_tests.c +++ b/src/gallium/auxiliary/util/u_tests.c @@ -490,7 +490,7 @@ null_fragment_shader(struct pipe_context *ctx) util_report_result(qresult.u64 == 2); } -#ifdef PIPE_OS_LINUX +#if defined(PIPE_OS_LINUX) && defined(HAVE_LIBDRM) #include #else #define sync_merge(str, fd1, fd2) (-1) -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] swr/scons: Fix intermittent build failure
gen_rasterizer*.cpp now depend on gen_ar_eventhandler.hpp. Account for new dependency. --- src/gallium/drivers/swr/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript index e35eff7..9204ecb 100644 --- a/src/gallium/drivers/swr/SConscript +++ b/src/gallium/drivers/swr/SConscript @@ -167,6 +167,7 @@ env.CodeGenerate( Depends(genRasterizerFiles, ['rasterizer/core/backends/gen_rasterizer.hpp', 'rasterizer/archrast/gen_ar_event.hpp', + 'rasterizer/archrast/gen_ar_eventhandler.hpp', 'rasterizer/codegen/gen_knobs.h'] ) -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] swr: Account for VBO index_bias in offsets
Account for info.index_bias when calculating buffers offsets. Fixes the follow piglit tests: arb_draw_elements_base_vertex-drawelements-user_varrays arb_draw_elements_base_vertex-negative-index-user_varrays --- src/gallium/drivers/swr/swr_state.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 4530d37..d320c90 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -1012,8 +1012,8 @@ swr_user_vbuf_range(const struct pipe_draw_info *info, *size = elems * vb->stride; } else if (vb->stride) { elems = info->max_index - info->min_index + 1; - *totelems = info->max_index + 1; - *base = info->min_index * vb->stride; + *totelems = (info->max_index + info->index_bias) + 1; + *base = (info->min_index + info->index_bias) * vb->stride; *size = elems * vb->stride; } else { *totelems = 1; @@ -1304,7 +1304,7 @@ swr_update_derived(struct pipe_context *pipe, uint32_t base; swr_user_vbuf_range(, ctx->velems, vb, i, , , ); partial_inbounds = 0; -min_vertex_index = info.min_index; +min_vertex_index = info.min_index + info.index_bias; size = AlignUp(size, 4); /* If size of client memory copy is too large, don't copy. The -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] util: Remove dependency on gallium header file
Do not depend on gallium/include/pipe/p_config.h for PIPE_OS_* defines. Use standard OS defines instead. --- src/util/os_time.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/util/os_time.c b/src/util/os_time.c index 72dc7e4..1c34bfd 100644 --- a/src/util/os_time.c +++ b/src/util/os_time.c @@ -34,12 +34,9 @@ #include "os_time.h" -/* TODO: fix this dependency */ -#include "gallium/include/pipe/p_config.h" - #include "util/u_atomic.h" -#if defined(PIPE_OS_UNIX) +#if defined(__unix__) # include /* usleep */ # include /* timeval */ # include /* timeval */ @@ -55,19 +52,19 @@ int64_t os_time_get_nano(void) { -#if defined(PIPE_OS_LINUX) +#if defined(__linux__) struct timespec tv; clock_gettime(CLOCK_MONOTONIC, ); return tv.tv_nsec + tv.tv_sec*INT64_C(10); -#elif defined(PIPE_OS_UNIX) +#elif defined(__unix__) struct timeval tv; gettimeofday(, NULL); return tv.tv_usec*INT64_C(1000) + tv.tv_sec*INT64_C(10); -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#elif defined(_MSC_VER) static LARGE_INTEGER frequency; LARGE_INTEGER counter; @@ -95,16 +92,16 @@ os_time_get_nano(void) void os_time_sleep(int64_t usecs) { -#if defined(PIPE_OS_LINUX) +#if defined(__linux__) struct timespec time; time.tv_sec = usecs / 100; time.tv_nsec = (usecs % 100) * 1000; while (clock_nanosleep(CLOCK_MONOTONIC, 0, , ) == EINTR); -#elif defined(PIPE_OS_UNIX) +#elif defined(__unix__) usleep(usecs); -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#elif defined(_MSC_VER) DWORD dwMilliseconds = (DWORD) ((usecs + 999) / 1000); /* Avoid Sleep(O) as that would cause to sleep for an undetermined duration */ if (dwMilliseconds) { @@ -148,7 +145,7 @@ os_wait_until_zero(volatile int *var, uint64_t timeout) if (timeout == OS_TIMEOUT_INFINITE) { while (p_atomic_read(var)) { -#if defined(PIPE_OS_UNIX) +#if defined(__unix__) sched_yield(); #endif } @@ -162,7 +159,7 @@ os_wait_until_zero(volatile int *var, uint64_t timeout) if (os_time_timeout(start_time, end_time, os_time_get_nano())) return false; -#if defined(PIPE_OS_UNIX) +#if defined(__unix__) sched_yield(); #endif } @@ -184,7 +181,7 @@ os_wait_until_zero_abs_timeout(volatile int *var, int64_t timeout) if (os_time_get_nano() >= timeout) return false; -#if defined(PIPE_OS_UNIX) +#if defined(__unix__) sched_yield(); #endif } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] util: Remove dependency on gallium header file
Do not depend on gallium/include/pipe/p_config.h for PIPE_OS_* defines. Use standard OS defines instead. --- src/util/os_time.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/util/os_time.c b/src/util/os_time.c index 72dc7e4..1c34bfd 100644 --- a/src/util/os_time.c +++ b/src/util/os_time.c @@ -34,12 +34,9 @@ #include "os_time.h" -/* TODO: fix this dependency */ -#include "gallium/include/pipe/p_config.h" - #include "util/u_atomic.h" -#if defined(PIPE_OS_UNIX) +#if defined(__unix__) # include /* usleep */ # include /* timeval */ # include /* timeval */ @@ -55,19 +52,19 @@ int64_t os_time_get_nano(void) { -#if defined(PIPE_OS_LINUX) +#if defined(__linux__) struct timespec tv; clock_gettime(CLOCK_MONOTONIC, ); return tv.tv_nsec + tv.tv_sec*INT64_C(10); -#elif defined(PIPE_OS_UNIX) +#elif defined(__unix__) struct timeval tv; gettimeofday(, NULL); return tv.tv_usec*INT64_C(1000) + tv.tv_sec*INT64_C(10); -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#elif defined(_MSC_VER) static LARGE_INTEGER frequency; LARGE_INTEGER counter; @@ -95,16 +92,16 @@ os_time_get_nano(void) void os_time_sleep(int64_t usecs) { -#if defined(PIPE_OS_LINUX) +#if defined(__linux__) struct timespec time; time.tv_sec = usecs / 100; time.tv_nsec = (usecs % 100) * 1000; while (clock_nanosleep(CLOCK_MONOTONIC, 0, , ) == EINTR); -#elif defined(PIPE_OS_UNIX) +#elif defined(__unix__) usleep(usecs); -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) +#elif defined(_MSC_VER) DWORD dwMilliseconds = (DWORD) ((usecs + 999) / 1000); /* Avoid Sleep(O) as that would cause to sleep for an undetermined duration */ if (dwMilliseconds) { @@ -148,7 +145,7 @@ os_wait_until_zero(volatile int *var, uint64_t timeout) if (timeout == OS_TIMEOUT_INFINITE) { while (p_atomic_read(var)) { -#if defined(PIPE_OS_UNIX) +#if defined(__unix__) sched_yield(); #endif } @@ -162,7 +159,7 @@ os_wait_until_zero(volatile int *var, uint64_t timeout) if (os_time_timeout(start_time, end_time, os_time_get_nano())) return false; -#if defined(PIPE_OS_UNIX) +#if defined(__unix__) sched_yield(); #endif } @@ -184,7 +181,7 @@ os_wait_until_zero_abs_timeout(volatile int *var, int64_t timeout) if (os_time_get_nano() >= timeout) return false; -#if defined(PIPE_OS_UNIX) +#if defined(__unix__) sched_yield(); #endif } -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] util: fix compatibility of timespec_get() across OSes
while timespec_get() is supposed to hide OS differences, compatibility doesn't cover old OSes (like CentOS 6) where timespec_get() does not exist. Fall back to using os_get_time_nano(), but separate out the functionality that populates struct timespec, so it can also be called from _util_queue_fence_wait_timeout(), where timespec_get() was initially called. --- src/util/os_time.c | 31 --- src/util/os_time.h | 6 ++ src/util/u_queue.c | 5 - 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/util/os_time.c b/src/util/os_time.c index 1c34bfd..a3cef81 100644 --- a/src/util/os_time.c +++ b/src/util/os_time.c @@ -48,37 +48,36 @@ # error Unsupported OS #endif - -int64_t -os_time_get_nano(void) +void +os_time_get_sec_nano(int64_t *sec, int64_t *nsec) { #if defined(__linux__) - struct timespec tv; - clock_gettime(CLOCK_MONOTONIC, ); - return tv.tv_nsec + tv.tv_sec*INT64_C(10); + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, ); + *sec = ts.tv_sec; + *nsec = ts.tv_nsec; #elif defined(__unix__) struct timeval tv; gettimeofday(, NULL); - return tv.tv_usec*INT64_C(1000) + tv.tv_sec*INT64_C(10); + *sec = tv.tv_sec; + *nsec = tv.tv_usec * INT64_T(1000); #elif defined(_MSC_VER) static LARGE_INTEGER frequency; LARGE_INTEGER counter; - int64_t secs, nanosecs; if(!frequency.QuadPart) QueryPerformanceFrequency(); QueryPerformanceCounter(); /* Compute seconds and nanoseconds parts separately to * reduce severity of precision loss. */ - secs = counter.QuadPart / frequency.QuadPart; - nanosecs = (counter.QuadPart % frequency.QuadPart) * INT64_C(10) + *sec = counter.QuadPart / frequency.QuadPart; + *nsec = (counter.QuadPart % frequency.QuadPart) * INT64_C(10) / frequency.QuadPart; - return secs*INT64_C(10) + nanosecs; #else @@ -87,6 +86,16 @@ os_time_get_nano(void) #endif } +int64_t +os_time_get_nano(void) +{ + int64_t secs, nanosecs; + + os_time_get_sec_nano(, ); + + return secs*INT64_C(10) + nanosecs; +} + void diff --git a/src/util/os_time.h b/src/util/os_time.h index 049ab11..6169431 100644 --- a/src/util/os_time.h +++ b/src/util/os_time.h @@ -46,6 +46,12 @@ extern "C" { #define OS_TIMEOUT_INFINITE 0xull /* + * Get the current time in seconds and nanoseconds from an unknown base. + */ +void +os_time_get_sec_nano(int64_t *sec, int64_t *nsec); + +/* * Get the current time in nanoseconds from an unknown base. */ int64_t diff --git a/src/util/u_queue.c b/src/util/u_queue.c index 43c28ac..753d59e 100644 --- a/src/util/u_queue.c +++ b/src/util/u_queue.c @@ -168,9 +168,12 @@ _util_queue_fence_wait_timeout(struct util_queue_fence *fence, int64_t rel = abs_timeout - os_time_get_nano(); if (rel > 0) { + int64_t sec, nsec; struct timespec ts; - timespec_get(, TIME_UTC); + os_time_get_sec_nano(, ); + ts.tv_sec = sec; + ts.tv_nsec = nsec; ts.tv_sec += abs_timeout / (1000*1000*1000); ts.tv_nsec += abs_timeout % (1000*1000*1000); -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] swr/scons: Fix another intermittent build failure
gen_BackendPixelRate*.cpp depends on gen_ar_eventhandler.hpp. Fix missing dependency. --- src/gallium/drivers/swr/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/swr/SConscript b/src/gallium/drivers/swr/SConscript index 9204ecb..eca4830 100644 --- a/src/gallium/drivers/swr/SConscript +++ b/src/gallium/drivers/swr/SConscript @@ -146,6 +146,7 @@ env.CodeGenerate( Depends(backendPixelRateFiles, ['rasterizer/core/backends/gen_BackendPixelRate.hpp', 'rasterizer/archrast/gen_ar_event.hpp', + 'rasterizer/archrast/gen_ar_eventhandler.hpp', 'rasterizer/codegen/gen_knobs.h'] ) -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/7] swr/rast: Use binner topology to assemble backend attributes
Previously was using the draw topology, which may change if GS or Tess are active. Only affected attributes marked with constant interpolation, which limited the impact. --- src/gallium/drivers/swr/rasterizer/core/binner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/binner.cpp b/src/gallium/drivers/swr/rasterizer/core/binner.cpp index 9f8dc88..7b9c20e 100644 --- a/src/gallium/drivers/swr/rasterizer/core/binner.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/binner.cpp @@ -81,7 +81,7 @@ INLINE void ProcessAttributes( // Conservative Rasterization requires degenerate tris to have constant attribute interpolation uint32_t constantInterpMask = IsDegenerate::value ? 0x : backendState.constantInterpolationMask; const uint32_t provokingVertex = pDC->pState->state.frontendState.topologyProvokingVertex; -const PRIMITIVE_TOPOLOGY topo = pDC->pState->state.topology; +const PRIMITIVE_TOPOLOGY topo = pa.binTopology; static const float constTable[3][4] = { { 0.0f, 0.0f, 0.0f, 0.0f }, -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/7] swr/rast: Change formatting
--- src/gallium/drivers/swr/rasterizer/core/api.cpp | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp index a2ee85d..3458793 100644 --- a/src/gallium/drivers/swr/rasterizer/core/api.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp @@ -475,7 +475,12 @@ void SetupDefaultState(SWR_CONTEXT *pContext) pState->depthBoundsState.depthBoundsTestMaxValue = 1.0f; } -void SwrSync(HANDLE hContext, PFN_CALLBACK_FUNC pfnFunc, uint64_t userData, uint64_t userData2, uint64_t userData3) +void SWR_API SwrSync( +HANDLE hContext, +PFN_CALLBACK_FUNC pfnFunc, +uint64_t userData, +uint64_t userData2, +uint64_t userData3) { SWR_ASSERT(pfnFunc != nullptr); -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev