[Mesa-dev] [PATCH 2/4] atomic: Use CPU-side KMS fence synchronisation

2017-05-02 Thread Daniel Stone
Atomic does not let us have multiple requests in flight at once; if we
don't synchronise with the request completion on the CPU side, we can
get -EBUSY from the atomic commit.

We already have everything required to do this, namely the out-fence
from the last commit. Block on that with a CPU-side wait before we call
atomic commit, to make sure we'll never attempt to queue an atomic
commit before the previous one has completed.

Signed-off-by: Daniel Stone 
---
 common.c |  1 +
 common.h |  1 +
 drm-atomic.c | 21 -
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/common.c b/common.c
index bf2f78e..a2cf630 100644
--- a/common.c
+++ b/common.c
@@ -155,6 +155,7 @@ int init_egl(struct egl *egl, const struct gbm *gbm)
get_proc_dpy(eglCreateSyncKHR, "EGL_KHR_fence_sync");
get_proc_dpy(eglDestroySyncKHR, "EGL_KHR_fence_sync");
get_proc_dpy(eglWaitSyncKHR, "EGL_KHR_fence_sync");
+   get_proc_dpy(eglClientWaitSyncKHR, "EGL_KHR_fence_sync");
get_proc_dpy(eglDupNativeFenceFDANDROID, 
"EGL_ANDROID_native_fence_sync");
 
printf("Using display %p with EGL version %d.%d\n",
diff --git a/common.h b/common.h
index 639bd87..0acf4c0 100644
--- a/common.h
+++ b/common.h
@@ -79,6 +79,7 @@ struct egl {
PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR;
PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR;
PFNEGLWAITSYNCKHRPROC eglWaitSyncKHR;
+   PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR;
PFNEGLDUPNATIVEFENCEFDANDROIDPROC eglDupNativeFenceFDANDROID;
 
void (*draw)(unsigned i);
diff --git a/drm-atomic.c b/drm-atomic.c
index 0f3c4f2..65caacd 100644
--- a/drm-atomic.c
+++ b/drm-atomic.c
@@ -210,6 +210,7 @@ static int atomic_run(const struct gbm *gbm, const struct 
egl *egl)
 
if (drm.kms_out_fence_fd != -1) {
kms_fence = create_fence(egl, drm.kms_out_fence_fd);
+   assert(kms_fence);
 
/* driver now has ownership of the fence fd: */
drm.kms_out_fence_fd = -1;
@@ -220,7 +221,6 @@ static int atomic_run(const struct gbm *gbm, const struct 
egl *egl)
 * the buffer that is still on screen.
 */
egl->eglWaitSyncKHR(egl->display, kms_fence, 0);
-   egl->eglDestroySyncKHR(egl->display, kms_fence);
}
 
egl->draw(i++);
@@ -229,6 +229,7 @@ static int atomic_run(const struct gbm *gbm, const struct 
egl *egl)
 * signaled when gpu rendering done
 */
gpu_fence = create_fence(egl, EGL_NO_NATIVE_FENCE_FD_ANDROID);
+   assert(gpu_fence);
 
eglSwapBuffers(egl->display, egl->surface);
 
@@ -246,6 +247,24 @@ static int atomic_run(const struct gbm *gbm, const struct 
egl *egl)
return -1;
}
 
+   if (kms_fence) {
+   EGLint status;
+
+   /* Wait on the CPU side for the _previous_ commit to
+* complete before we post the flip through KMS, as
+* atomic will reject the commit if we post a new one
+* whilst the previous one is still pending.
+*/
+   do {
+   status = egl->eglClientWaitSyncKHR(egl->display,
+  kms_fence,
+  0,
+  
EGL_FOREVER_KHR);
+   } while (status != EGL_CONDITION_SATISFIED_KHR);
+
+   egl->eglDestroySyncKHR(egl->display, kms_fence);
+   }
+
/*
 * Here you could also update drm plane layers if you want
 * hw composition
-- 
2.12.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/4] common: Check for extensions before resolving symbols

2017-05-02 Thread Daniel Stone
eglGetProcAddress is allowed to return any old garbage for symbols it
doesn't know about. To avoid any mishaps, check for the appropriate
extension presence (split into EGL client extension, EGL display
extension, and GL extension, checks) before we look up any symbols
through it.

The walk through the extension list is taken from libepoxy.

Signed-off-by: Daniel Stone 
---
 common.c | 63 +++
 1 file changed, 51 insertions(+), 12 deletions(-)

diff --git a/common.c b/common.c
index 610ff87..bf2f78e 100644
--- a/common.c
+++ b/common.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017 Rob Clark 
+ * Copyright © 2013 Intel Corporation
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -23,6 +24,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -78,6 +80,26 @@ const struct gbm * init_gbm(int drm_fd, int w, int h, 
uint64_t modifier)
return &gbm;
 }
 
+static bool has_ext(const char *extension_list, const char *ext)
+{
+   const char *ptr = extension_list;
+   int len = strlen(ext);
+
+   if (ptr == NULL || *ptr == '\0')
+   return false;
+
+   while (true) {
+   ptr = strstr(ptr, ext);
+   if (!ptr)
+   return false;
+
+   if (ptr[len] == ' ' || ptr[len] == '\0')
+   return true;
+
+   ptr += len;
+   }
+}
+
 int init_egl(struct egl *egl, const struct gbm *gbm)
 {
EGLint major, minor, n;
@@ -96,19 +118,24 @@ int init_egl(struct egl *egl, const struct gbm *gbm)
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_NONE
};
+   const char *egl_exts_client, *egl_exts_dpy, *gl_exts;
+
+#define get_proc_client(name, ext) do { \
+   if (has_ext(egl_exts_client, ext)) \
+   egl->name = (void *)eglGetProcAddress(#name); \
+   } while (0)
+#define get_proc_dpy(name, ext) do { \
+   if (has_ext(egl_exts_dpy, ext)) \
+   egl->name = (void *)eglGetProcAddress(#name); \
+   } while (0)
 
-#define get_proc(name) do { \
-   egl->name = (void *)eglGetProcAddress(#name); \
+#define get_proc_gl(name, ext) do { \
+   if (has_ext(gl_exts, ext)) \
+   egl->name = (void *)eglGetProcAddress(#name); \
} while (0)
 
-   get_proc(eglGetPlatformDisplayEXT);
-   get_proc(eglCreateImageKHR);
-   get_proc(eglDestroyImageKHR);
-   get_proc(glEGLImageTargetTexture2DOES);
-   get_proc(eglCreateSyncKHR);
-   get_proc(eglDestroySyncKHR);
-   get_proc(eglWaitSyncKHR);
-   get_proc(eglDupNativeFenceFDANDROID);
+   egl_exts_client = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
+   get_proc_client(eglGetPlatformDisplayEXT, "EGL_EXT_platform_base");
 
if (egl->eglGetPlatformDisplayEXT) {
egl->display = 
egl->eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR,
@@ -122,6 +149,14 @@ int init_egl(struct egl *egl, const struct gbm *gbm)
return -1;
}
 
+   egl_exts_dpy = eglQueryString(egl->display, EGL_EXTENSIONS);
+   get_proc_dpy(eglCreateImageKHR, "EGL_KHR_image_base");
+   get_proc_dpy(eglDestroyImageKHR, "EGL_KHR_image_base");
+   get_proc_dpy(eglCreateSyncKHR, "EGL_KHR_fence_sync");
+   get_proc_dpy(eglDestroySyncKHR, "EGL_KHR_fence_sync");
+   get_proc_dpy(eglWaitSyncKHR, "EGL_KHR_fence_sync");
+   get_proc_dpy(eglDupNativeFenceFDANDROID, 
"EGL_ANDROID_native_fence_sync");
+
printf("Using display %p with EGL version %d.%d\n",
egl->display, major, minor);
 
@@ -129,7 +164,8 @@ int init_egl(struct egl *egl, const struct gbm *gbm)
printf("EGL information:\n");
printf("  version: \"%s\"\n", eglQueryString(egl->display, 
EGL_VERSION));
printf("  vendor: \"%s\"\n", eglQueryString(egl->display, EGL_VENDOR));
-   printf("  extensions: \"%s\"\n", eglQueryString(egl->display, 
EGL_EXTENSIONS));
+   printf("  client extensions: \"%s\"\n", egl_exts_client);
+   printf("  display extensions: \"%s\"\n", egl_exts_dpy);
printf("===\n");
 
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
@@ -159,14 +195,17 @@ int init_egl(struct egl *egl, const struct gbm *gbm)
/* connect the context to the surface */
eglMakeCurrent(egl->display, egl->surface, egl->surface, egl->context);
 
+   gl_exts = (char *) glGetString(GL_EXTENSIONS);
printf("OpenGL ES 2.x information:\n");
printf("  version: \"%s\"\n", glGetString(GL_VERSION));
printf("  shading language version: \"%s\"\n", 
glGetString(GL_SHADING_LANGUAGE_VERSION));
printf("  vendor: \"%s\"\n", glGetString(GL_VENDOR));
printf("  renderer: \"%s\"\n", glGetString(GL_RENDERER)

Re: [Mesa-dev] [PATCH 06/17] st/mesa: unify TCS, TES, GS st_*_program structures

2017-05-02 Thread Emil Velikov
Hi Marek,

Nice work.

Small question - have you considered subclassing st_{vp,fp,cp}_program
around st_common_program?
It should allow us to remove even more code :-)

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] mesa/varray: make use of dispatch KHR_no_error support

2017-05-02 Thread Nicolai Hähnle

I like it!

Reviewed-by: Nicolai Hähnle 

On 27.04.2017 07:33, Timothy Arceri wrote:

Make use of dispatch KHR_no_error support for varray functions.
---
 src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml |   2 +-
 src/mapi/glapi/gen/GL3x.xml|   3 +-
 src/mapi/glapi/gen/es_EXT.xml  |   3 +-
 src/mapi/glapi/gen/gl_API.xml  |   9 +
 src/mesa/main/varray.c | 492 -
 src/mesa/main/varray.h |  40 +-
 6 files changed, 369 insertions(+), 180 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml 
b/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml
index 211642f..6d76003 100644
--- a/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml
+++ b/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml
@@ -44,21 +44,21 @@
 
 
 
 

 
 
 
 

-
+
 
 
 
 
 
 

 
 
 
diff --git a/src/mapi/glapi/gen/GL3x.xml b/src/mapi/glapi/gen/GL3x.xml
index f38a287..d2c768d 100644
--- a/src/mapi/glapi/gen/GL3x.xml
+++ b/src/mapi/glapi/gen/GL3x.xml
@@ -250,20 +250,21 @@
 
 
   

   
   

   

   
 
 
 
 
 
   

   
 
@@ -617,18 +618,18 @@


 
   
   
   
   
   
   

-  
+  
 
 
   

 

 
diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml
index 3e705eb..271f0c0 100644
--- a/src/mapi/glapi/gen/es_EXT.xml
+++ b/src/mapi/glapi/gen/es_EXT.xml
@@ -311,21 +311,22 @@
 

 
 
 
 
 
 
 

-
+
 
 
 
 
 

 
 
 
 
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index d19cfd2..83f4c01 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -3147,20 +3147,21 @@
 
 
 

 
 
 
 

 
 
 
 
 
 
 

 
 
@@ -3177,70 +3178,75 @@
 
 
 
 
 
 
 

 
 
 
 
 

 
 
 
 

 
 
 
 
 

 
 
 
 
 
 

 
 
 
 
 
 

 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
@@ -4718,20 +4724,21 @@
 
 
 

 
 
 
 

 
 
 
 
 
 

 
 
 
@@ -4855,20 +4862,21 @@
 
 
 

 
 
 
 

 
 
 
 
 
 
 

 
 
@@ -5810,20 +5818,21 @@
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 709f6d4..eda86ec 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -570,374 +570,496 @@ update_array(struct gl_context *ctx,
array->Stride = stride;
array->Ptr = ptr;

/* Update the vertex buffer binding */
GLsizei effectiveStride = stride != 0 ? stride : array->_ElementSize;
_mesa_bind_vertex_buffer(ctx, vao, attrib,
 ctx->Array.ArrayBufferObj, (GLintptr) ptr,
 effectiveStride);
 }

+void GLAPIENTRY
+_mesa_VertexPointer_no_error(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *ptr)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+
+   update_array(ctx, VERT_ATTRIB_POS, GL_RGBA, 4, size, type, stride,
+GL_FALSE, GL_FALSE, GL_FALSE, ptr);
+}
+

 void GLAPIENTRY
 _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
 {
GET_CURRENT_CONTEXT(ctx);

FLUSH_VERTICES(ctx, 0);

GLenum format = GL_RGBA;
-   if (!_mesa_is_no_error_enabled(ctx)) {
-  GLbitfield legalTypes = (ctx->API == API_OPENGLES)
- ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT)
- : (SHORT_BIT | INT_BIT | FLOAT_BIT |
-DOUBLE_BIT | HALF_BIT |
-UNSIGNED_INT_2_10_10_10_REV_BIT |
-INT_2_10_10_10_REV_BIT);
-
-  if (!validate_array_and_format(ctx, "glVertexPointer", VERT_ATTRIB_POS,
- legalTypes, 2, 4, size, type, stride,
- GL_FALSE, GL_FALSE, GL_FALSE, format,
- ptr, ctx->Array.VAO))
- return;
-   }
+   GLbitfield legalTypes = (ctx->API == API_OPENGLES)
+  ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT)
+  : (SHORT_BIT | INT_BIT | FLOAT_BIT |
+ DOUBLE_BIT | HALF_BIT |
+ UNSIGNED_INT_2_10_10_10_REV_BIT |
+ INT_2_10_10_10_REV_BIT);
+
+   if (!valida

Re: [Mesa-dev] [PATCH 1/2] glapi: add KHR_no_error support to dispatch table generation

2017-05-02 Thread Nicolai Hähnle

On 27.04.2017 07:33, Timothy Arceri wrote:

This will allows us to create no error versions of functions
noted by a _no_error suffix. We also need to set a no_error
attribute equal to "true" in the xml.
---
 src/mapi/glapi/gen/gl_XML.py |  5 +
 src/mapi/glapi/gen/gl_genexec.py | 19 ++-
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index c688906..603ef73 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -669,20 +669,25 @@ class gl_function( gl_item ):
 if exec_flavor:
 self.exec_flavor = exec_flavor

 deprecated = element.get('deprecated', 'none')
 if deprecated != 'none':
 self.deprecated = Decimal(deprecated)

 if not is_attr_true(element, 'desktop', 'true'):
 self.desktop = False

+if is_attr_true(element, 'no_error'):
+self.has_no_error_variant = True
+else:
+self.has_no_error_variant = False
+
 if alias:
 true_name = alias
 else:
 true_name = name

 # Only try to set the offset when a non-alias entry-point
 # is being processed.

 if name in static_data.offsets:
 self.offset = static_data.offsets[name]
diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py
index 3a75419..ba82045 100644
--- a/src/mapi/glapi/gen/gl_genexec.py
+++ b/src/mapi/glapi/gen/gl_genexec.py
@@ -167,21 +167,21 @@ class PrintCode(gl_XML.gl_print_base):

 def printRealHeader(self):
 print header

 def printRealFooter(self):
 print footer

 def printBody(self, api):
 # Collect SET_* calls by the condition under which they should
 # be called.
-settings_by_condition = collections.defaultdict(lambda: [])
+settings_by_condition = collections.defaultdict(lambda: 
collections.defaultdict(lambda: []))
 for f in api.functionIterateAll():
 if f.exec_flavor not in exec_flavor_map:
 raise Exception(
 'Unrecognized exec flavor {0!r}'.format(f.exec_flavor))
 condition_parts = []
 if f.name in apiexec.functions:
 ex = apiexec.functions[f.name]
 unconditional_count = 0

 if ex.compatibility is not None:
@@ -225,28 +225,37 @@ class PrintCode(gl_XML.gl_print_base):

 if not condition_parts:
 # This function does not exist in any API.
 continue
 condition = ' || '.join(condition_parts)
 prefix = exec_flavor_map[f.exec_flavor]
 if prefix is None:
 # This function is not implemented, or is dispatched
 # dynamically.
 continue
-settings_by_condition[condition].append(
-'SET_{0}(exec, {1}{0});'.format(f.name, prefix, f.name))
+if f.has_no_error_variant:
+
settings_by_condition[condition]['_mesa_is_no_error_enabled(ctx)'].append(
+'SET_{0}(exec, {1}{0}_no_error);'.format(f.name, prefix, 
f.name))
+
settings_by_condition[condition]['!_mesa_is_no_error_enabled(ctx)'].append(
+'SET_{0}(exec, {1}{0});'.format(f.name, prefix, f.name))
+else:
+settings_by_condition[condition]['true'].append(
+'SET_{0}(exec, {1}{0});'.format(f.name, prefix, f.name))
 # Print out an if statement for each unique condition, with
 # the SET_* calls nested inside it.
 for condition in sorted(settings_by_condition.keys()):
 print '   if ({0}) {{'.format(condition)
-for setting in sorted(settings_by_condition[condition]):
-print '  {0}'.format(setting)
+for khr_no_error in 
sorted(settings_by_condition[condition].keys()):
+print '  if ({0}) {{'.format(khr_no_error)
+for setting in 
sorted(settings_by_condition[condition][khr_no_error]):
+print ' {0}'.format(setting)
+print '  }'
 print '   }'


I think this could be kept a bit simpler by saying

   no_error_condition = '({0}) && 
_mesa_is_no_error_enabled(ctx)'.format(condition)
   error_condition = '({0}) && 
!_mesa_is_no_error_enabled(ctx)'.format(condition)

   settings_by_condition[no_error_condition].append(...)
   settings_by_condition[error_condition].append(...)

Though I don't feel too strongly about it.

Cheers,
Nicolai




 def _parser():
 """Parse arguments and return namespace."""
 parser = argparse.ArgumentParser()
 parser.add_argument('-f',
 dest='filename',
 default='gl_and_es_API.xml',
 help='an xml file describing an API')




--
Lerne, wie die

[Mesa-dev] [PATCH] mesa/vbo: reduce prim array size

2017-05-02 Thread Bartosz Tomczyk
We always use only single element.
---
 src/mesa/vbo/vbo_exec_array.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 15382eaaae..cbef610d96 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -462,7 +462,7 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint 
start,
 GLuint drawID)
 {
struct vbo_context *vbo = vbo_context(ctx);
-   struct _mesa_prim prim[2];
+   struct _mesa_prim prim[1];
 
if (skip_validated_draw(ctx))
   return;
@@ -1409,7 +1409,7 @@ vbo_draw_transform_feedback(struct gl_context *ctx, 
GLenum mode,
 GLuint stream, GLuint numInstances)
 {
struct vbo_context *vbo = vbo_context(ctx);
-   struct _mesa_prim prim[2];
+   struct _mesa_prim prim[1];
 
if (!_mesa_validate_DrawTransformFeedback(ctx, mode, obj, stream,
  numInstances)) {
-- 
2.12.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] c11/threads: rework Windows thrd_current() comment

2017-05-02 Thread Eric Engestrom
On Saturday, 2017-04-29 14:51:15 +0100, Emil Velikov wrote:
> From: Emil Velikov 
> 
> Drop the misleading "will not match the one returned by thread_create"
> hunk and provide more clarity as to what/why GetCurrentThread() isn't
> the solution we're looking for.
> 
> Cc: José Fonseca 
> Signed-off-by: Emil Velikov 
> ---
>  include/c11/threads_win32.h | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/include/c11/threads_win32.h b/include/c11/threads_win32.h
> index d017c31c34e..7ffd3ae3a23 100644
> --- a/include/c11/threads_win32.h
> +++ b/include/c11/threads_win32.h
> @@ -502,9 +502,13 @@ thrd_current(void)
>  HANDLE hCurrentThread;
>  BOOL bRet;
>  
> -/* GetCurrentThread() returns a pseudo-handle, which is useless.  We need
> - * to call DuplicateHandle to get a real handle.  However the handle 
> value
> - * will not match the one returned by thread_create.
> +/* GetCurrentThread() returns a pseudo-handle, which we need
> + * to pass to DuplicateHandle. Only the resulting handle can be used
> + * from other threads.
> + *
> + * Note that neither handle can be compared to the one by thread_create.
> + * Only the thread IDs - as returned by GetThreadId and 
> GetCurrentThreadId

nit: `GetThreadId()` & `GetCurrentThreadId()` (with parentheses) for 
consistency?

Reviewed-by: Eric Engestrom 

> + * can be compared directly.
>   *
>   * Other potential solutions would be:
>   * - define thrd_t as a thread Ids, but this would mean we'd need to 
> OpenThread for many operations
> -- 
> 2.12.2
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] glapi: add KHR_no_error support to dispatch table generation

2017-05-02 Thread Timothy Arceri

Ping. Any thoughts/comments on this approach?

On 27/04/17 15:33, Timothy Arceri wrote:

This will allows us to create no error versions of functions
noted by a _no_error suffix. We also need to set a no_error
attribute equal to "true" in the xml.
---
  src/mapi/glapi/gen/gl_XML.py |  5 +
  src/mapi/glapi/gen/gl_genexec.py | 19 ++-
  2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index c688906..603ef73 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -669,20 +669,25 @@ class gl_function( gl_item ):
  if exec_flavor:
  self.exec_flavor = exec_flavor
  
  deprecated = element.get('deprecated', 'none')

  if deprecated != 'none':
  self.deprecated = Decimal(deprecated)
  
  if not is_attr_true(element, 'desktop', 'true'):

  self.desktop = False
  
+if is_attr_true(element, 'no_error'):

+self.has_no_error_variant = True
+else:
+self.has_no_error_variant = False
+
  if alias:
  true_name = alias
  else:
  true_name = name
  
  # Only try to set the offset when a non-alias entry-point

  # is being processed.
  
  if name in static_data.offsets:

  self.offset = static_data.offsets[name]
diff --git a/src/mapi/glapi/gen/gl_genexec.py b/src/mapi/glapi/gen/gl_genexec.py
index 3a75419..ba82045 100644
--- a/src/mapi/glapi/gen/gl_genexec.py
+++ b/src/mapi/glapi/gen/gl_genexec.py
@@ -167,21 +167,21 @@ class PrintCode(gl_XML.gl_print_base):
  
  def printRealHeader(self):

  print header
  
  def printRealFooter(self):

  print footer
  
  def printBody(self, api):

  # Collect SET_* calls by the condition under which they should
  # be called.
-settings_by_condition = collections.defaultdict(lambda: [])
+settings_by_condition = collections.defaultdict(lambda: 
collections.defaultdict(lambda: []))
  for f in api.functionIterateAll():
  if f.exec_flavor not in exec_flavor_map:
  raise Exception(
  'Unrecognized exec flavor {0!r}'.format(f.exec_flavor))
  condition_parts = []
  if f.name in apiexec.functions:
  ex = apiexec.functions[f.name]
  unconditional_count = 0
  
  if ex.compatibility is not None:

@@ -225,28 +225,37 @@ class PrintCode(gl_XML.gl_print_base):
  
  if not condition_parts:

  # This function does not exist in any API.
  continue
  condition = ' || '.join(condition_parts)
  prefix = exec_flavor_map[f.exec_flavor]
  if prefix is None:
  # This function is not implemented, or is dispatched
  # dynamically.
  continue
-settings_by_condition[condition].append(
-'SET_{0}(exec, {1}{0});'.format(f.name, prefix, f.name))
+if f.has_no_error_variant:
+
settings_by_condition[condition]['_mesa_is_no_error_enabled(ctx)'].append(
+'SET_{0}(exec, {1}{0}_no_error);'.format(f.name, prefix, 
f.name))
+
settings_by_condition[condition]['!_mesa_is_no_error_enabled(ctx)'].append(
+'SET_{0}(exec, {1}{0});'.format(f.name, prefix, f.name))
+else:
+settings_by_condition[condition]['true'].append(
+'SET_{0}(exec, {1}{0});'.format(f.name, prefix, f.name))
  # Print out an if statement for each unique condition, with
  # the SET_* calls nested inside it.
  for condition in sorted(settings_by_condition.keys()):
  print '   if ({0}) {{'.format(condition)
-for setting in sorted(settings_by_condition[condition]):
-print '  {0}'.format(setting)
+for khr_no_error in 
sorted(settings_by_condition[condition].keys()):
+print '  if ({0}) {{'.format(khr_no_error)
+for setting in 
sorted(settings_by_condition[condition][khr_no_error]):
+print ' {0}'.format(setting)
+print '  }'
  print '   }'
  
  
  def _parser():

  """Parse arguments and return namespace."""
  parser = argparse.ArgumentParser()
  parser.add_argument('-f',
  dest='filename',
  default='gl_and_es_API.xml',
  help='an xml file describing an API')


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] mapi: replace mapi_table abstraction

2017-05-02 Thread Eric Engestrom
On Friday, 2017-04-28 13:15:19 +0100, Emil Velikov wrote:
> From: Emil Velikov 
> 
> Replace all instances of mapi_table with the actual struct _glapi_table.
> The former may have been needed when the OpenVG was around. But since
> that one is long gone, there' no point in having the current confusing
> mix of the two.
> 
> Signed-off-by: Emil Velikov 

Patches #1 and #3 are
Reviewed-by: Eric Engestrom 

> ---
>  src/mapi/entry.c   |  2 +-
>  src/mapi/glapi/glapi.c |  2 +-
>  src/mapi/mapi_abi.py   |  2 +-
>  src/mapi/mapi_glapi.c  |  2 +-
>  src/mapi/table.h   | 10 +-
>  src/mapi/u_current.c   | 20 ++--
>  src/mapi/u_current.h   | 15 ++-
>  7 files changed, 25 insertions(+), 28 deletions(-)
> 
> diff --git a/src/mapi/entry.c b/src/mapi/entry.c
> index 27d0db40efc..167386d8a9a 100644
> --- a/src/mapi/entry.c
> +++ b/src/mapi/entry.c
> @@ -53,7 +53,7 @@
>  
>  #include 
>  
> -static inline const struct mapi_table *
> +static inline const struct _glapi_table *
>  entry_current_get(void)
>  {
>  #ifdef MAPI_MODE_BRIDGE
> diff --git a/src/mapi/glapi/glapi.c b/src/mapi/glapi/glapi.c
> index 194b9ee865d..55258a476c7 100644
> --- a/src/mapi/glapi/glapi.c
> +++ b/src/mapi/glapi/glapi.c
> @@ -60,5 +60,5 @@ _glapi_set_context(void *context)
>  void
>  _glapi_set_dispatch(struct _glapi_table *dispatch)
>  {
> -   u_current_set_table((const struct mapi_table *) dispatch);
> +   u_current_set_table((const struct _glapi_table *) dispatch);
>  }
> diff --git a/src/mapi/mapi_abi.py b/src/mapi/mapi_abi.py
> index 2343182d116..adb5d77126d 100644
> --- a/src/mapi/mapi_abi.py
> +++ b/src/mapi/mapi_abi.py
> @@ -437,7 +437,7 @@ class ABIPrinter(object):
>  if ent.ret:
>  ret = 'return '
>  stmt1 = self.indent
> -stmt1 += 'const struct mapi_table *_tbl = %s();' % (
> +stmt1 += 'const struct _glapi_table *_tbl = %s();' % (
>  self.current_get)
>  stmt2 = self.indent
>  stmt2 += 'mapi_func _func = ((const mapi_func *) _tbl)[%d];' % (
> diff --git a/src/mapi/mapi_glapi.c b/src/mapi/mapi_glapi.c
> index 9f02edb7cd3..3a376e81bdd 100644
> --- a/src/mapi/mapi_glapi.c
> +++ b/src/mapi/mapi_glapi.c
> @@ -65,7 +65,7 @@ _glapi_set_context(void *context)
>  void
>  _glapi_set_dispatch(struct _glapi_table *dispatch)
>  {
> -   u_current_set_table((const struct mapi_table *) dispatch);
> +   u_current_set_table((const struct _glapi_table *) dispatch);
>  }
>  
>  /**
> diff --git a/src/mapi/table.h b/src/mapi/table.h
> index a1af40c6fc1..f488b6d8a75 100644
> --- a/src/mapi/table.h
> +++ b/src/mapi/table.h
> @@ -37,7 +37,7 @@
>  #define MAPI_TABLE_NUM_SLOTS (MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC)
>  #define MAPI_TABLE_SIZE (MAPI_TABLE_NUM_SLOTS * sizeof(mapi_func))
>  
> -struct mapi_table;
> +struct _glapi_table;
>  
>  extern const mapi_func table_noop_array[];
>  
> @@ -52,17 +52,17 @@ table_set_noop_handler(nop_handler_proc func);
>  /**
>   * Get the no-op dispatch table.
>   */
> -static inline const struct mapi_table *
> +static inline const struct _glapi_table *
>  table_get_noop(void)
>  {
> -   return (const struct mapi_table *) table_noop_array;
> +   return (const struct _glapi_table *) table_noop_array;
>  }
>  
>  /**
>   * Set the function of a slot.
>   */
>  static inline void
> -table_set_func(struct mapi_table *tbl, int slot, mapi_func func)
> +table_set_func(struct _glapi_table *tbl, int slot, mapi_func func)
>  {
> mapi_func *funcs = (mapi_func *) tbl;
> funcs[slot] = func;
> @@ -72,7 +72,7 @@ table_set_func(struct mapi_table *tbl, int slot, mapi_func 
> func)
>   * Return the function of a slot.
>   */
>  static inline mapi_func
> -table_get_func(const struct mapi_table *tbl, int slot)
> +table_get_func(const struct _glapi_table *tbl, int slot)
>  {
> const mapi_func *funcs = (const mapi_func *) tbl;
> return funcs[slot];
> diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c
> index 7e7e275f2e3..1402cea45d5 100644
> --- a/src/mapi/u_current.c
> +++ b/src/mapi/u_current.c
> @@ -99,17 +99,17 @@ extern void (*__glapi_noop_table[])(void);
>  /*@{*/
>  #if defined(GLX_USE_TLS)
>  
> -__thread struct mapi_table *u_current_table
> +__thread struct _glapi_table *u_current_table
>  __attribute__((tls_model("initial-exec")))
> -= (struct mapi_table *) table_noop_array;
> += (struct _glapi_table *) table_noop_array;
>  
>  __thread void *u_current_context
>  __attribute__((tls_model("initial-exec")));
>  
>  #else
>  
> -struct mapi_table *u_current_table =
> -   (struct mapi_table *) table_noop_array;
> +struct _glapi_table *u_current_table =
> +   (struct _glapi_table *) table_noop_array;
>  void *u_current_context;
>  
>  tss_t u_current_table_tsd;
> @@ -259,17 +259,17 @@ u_current_get_context_internal(void)
>   * table (__glapi_noop_table).
>   */
>  void
> -u_current_set_table(const struct mapi_table *tbl)
> +u_current_set_table(con

Re: [Mesa-dev] [PATCH] radv/wsi: report presentation error per image request

2017-05-02 Thread Daniel Stone
On 2 May 2017 at 04:41, Dave Airlie  wrote:
> This ports
> 0fcb92c17dee681bd39c08ddf0abc358a27337c7
> anv: wsi: report presentation error per image request
>
> This fixes:
> dEQP-VK.wsi.xlib.incremental_present.scale_none.*

Reviewed-by: Daniel Stone 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v03 12/38] i965: Split out enum from brw_eu_defines.h

2017-05-02 Thread Emil Velikov
On 2 May 2017 at 09:32, Emil Velikov  wrote:
> Hi Rafael,
>
> On 2 May 2017 at 02:43, Rafael Antognolli  wrote:
>> We need to use some enums inside genX_state_upload.c, but including the
>> whole header will cause several conflicts between things defined in this
>> header and the genxml auto-generated headers.
>>
>> So create a separate header that is included both by brw_eu_defines.h
>> and genX_state_upload.c.
>>
>> Signed-off-by: Rafael Antognolli 
>> Acked-by: Reviewed-by: Kenneth Graunke 
>> ---
>>  src/intel/Makefile.sources  |  1 +-
>>  src/intel/compiler/brw_defines_common.h | 46 ++-
>>  src/intel/compiler/brw_eu_defines.h | 22 +
>>  3 files changed, 48 insertions(+), 21 deletions(-)
>>  create mode 100644 src/intel/compiler/brw_defines_common.h
>>
>> diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources
>> index e9a39a6..652f376 100644
>> --- a/src/intel/Makefile.sources
>> +++ b/src/intel/Makefile.sources
>> @@ -27,6 +27,7 @@ COMPILER_FILES = \
>> compiler/brw_compiler.h \
>> compiler/brw_dead_control_flow.cpp \
>> compiler/brw_dead_control_flow.h \
>> +   compiler/brw_defines_common.h \
> Amazing, thank you!
>
>> compiler/brw_disasm.c \
>> compiler/brw_eu.c \
>> compiler/brw_eu_compact.c \
>> diff --git a/src/intel/compiler/brw_defines_common.h 
>> b/src/intel/compiler/brw_defines_common.h
>> new file mode 100644
>> index 000..fdae125
>> --- /dev/null
>> +++ b/src/intel/compiler/brw_defines_common.h
>
>> +
>> +#ifndef BRW_DEFINES_COMMON_H
> You want a "#define BRW_DEFINES_COMMON_H" here
>
>> +#endif // BRW_DEFINES_COMMON_H
>> +
> And this line should be at the end of the file.
>
Forgot to mention: the above is trivial, so I don't bother resending
the series just for that.

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v03 12/38] i965: Split out enum from brw_eu_defines.h

2017-05-02 Thread Emil Velikov
Hi Rafael,

On 2 May 2017 at 02:43, Rafael Antognolli  wrote:
> We need to use some enums inside genX_state_upload.c, but including the
> whole header will cause several conflicts between things defined in this
> header and the genxml auto-generated headers.
>
> So create a separate header that is included both by brw_eu_defines.h
> and genX_state_upload.c.
>
> Signed-off-by: Rafael Antognolli 
> Acked-by: Reviewed-by: Kenneth Graunke 
> ---
>  src/intel/Makefile.sources  |  1 +-
>  src/intel/compiler/brw_defines_common.h | 46 ++-
>  src/intel/compiler/brw_eu_defines.h | 22 +
>  3 files changed, 48 insertions(+), 21 deletions(-)
>  create mode 100644 src/intel/compiler/brw_defines_common.h
>
> diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources
> index e9a39a6..652f376 100644
> --- a/src/intel/Makefile.sources
> +++ b/src/intel/Makefile.sources
> @@ -27,6 +27,7 @@ COMPILER_FILES = \
> compiler/brw_compiler.h \
> compiler/brw_dead_control_flow.cpp \
> compiler/brw_dead_control_flow.h \
> +   compiler/brw_defines_common.h \
Amazing, thank you!

> compiler/brw_disasm.c \
> compiler/brw_eu.c \
> compiler/brw_eu_compact.c \
> diff --git a/src/intel/compiler/brw_defines_common.h 
> b/src/intel/compiler/brw_defines_common.h
> new file mode 100644
> index 000..fdae125
> --- /dev/null
> +++ b/src/intel/compiler/brw_defines_common.h

> +
> +#ifndef BRW_DEFINES_COMMON_H
You want a "#define BRW_DEFINES_COMMON_H" here

> +#endif // BRW_DEFINES_COMMON_H
> +
And this line should be at the end of the file.

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH 2/3] i965/vec4: fix register width for DF VGRF and UNIFORM

2017-05-02 Thread Samuel Iglesias Gonsálvez
On Mon, 2017-05-01 at 14:55 +0200, Samuel Iglesias Gonsálvez wrote:
> El Viernes, 28 de abril de 2017 16:27:56 Francisco Jerez escribió:
> > Samuel Iglesias Gonsálvez  writes:
> > > On gen7, the swizzles used in DF align16 instructions works for
> > > element
> > > size of 32 bits, so we can address only 2 consecutive DFs. As we
> > > assumed
> > > that in the rest of the code and prepare the instructions for
> > > this
> > > (scalarize_df()), we need to set it to two again.
> > > 
> > > However, for DF align1 instructions, a width of 2 is wrong as we
> > > are not
> > > reading the data we want. For example, an uniform would have a
> > > region of
> > > <0, 2, 1> so it would repeat the first 2 DFs, when we wanted to
> > > access
> > > to the first 4.
> > > 
> > > This patch sets the default one to 4 and then modifies the width
> > > of
> > > align16 instruction's DF sources when we translate the logical
> > > swizzle
> > > to the physical one.
> > > 
> > > Signed-off-by: Samuel Iglesias Gonsálvez 
> > > Cc: "17.1" 
> > > ---
> > > 
> > >  src/intel/compiler/brw_vec4.cpp | 13 -
> > >  1 file changed, 8 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/src/intel/compiler/brw_vec4.cpp
> > > b/src/intel/compiler/brw_vec4.cpp index 95f96ea69c0..8b755e1b75e
> > > 100644
> > > --- a/src/intel/compiler/brw_vec4.cpp
> > > +++ b/src/intel/compiler/brw_vec4.cpp
> > > @@ -2003,9 +2003,7 @@ vec4_visitor::convert_to_hw_regs()
> > > 
> > >   struct brw_reg reg;
> > >   switch (src.file) {
> > >   case VGRF: {
> > > 
> > > -const unsigned type_size = type_sz(src.type);
> > > -const unsigned width = REG_SIZE / 2 / MAX2(4,
> > > type_size);
> > > -reg = byte_offset(brw_vecn_grf(width, src.nr, 0),
> > > src.offset);
> > > +reg = byte_offset(brw_vecn_grf(4, src.nr, 0),
> > > src.offset);
> > > 
> > >  reg.type = src.type;
> > >  reg.abs = src.abs;
> > >  reg.negate = src.negate;
> > > 
> > > @@ -2013,12 +2011,11 @@ vec4_visitor::convert_to_hw_regs()
> > > 
> > >   }
> > >   
> > >   case UNIFORM: {
> > > 
> > > -const unsigned width = REG_SIZE / 2 / MAX2(4,
> > > type_sz(src.type));> 
> > >  reg = stride(byte_offset(brw_vec4_grf(
> > >  
> > >  prog_data-
> > > >base.dispatch_grf_star
> > >  t_reg +
> > >  src.nr / 2, src.nr % 2 *
> > > 4),
> > >   
> > >   src.offset),
> > > 
> > > - 0, width, 1);
> > > + 0, 4, 1);
> > > 
> > >  reg.type = src.type;
> > >  reg.abs = src.abs;
> > >  reg.negate = src.negate;
> > > 
> > > @@ -2576,6 +2573,12 @@ vec4_visitor::apply_logical_swizzle(struct
> > > brw_reg
> > > *hw_reg,> 
> > > assert(brw_is_single_value_swizzle(reg.swizzle) ||
> > > 
> > >    is_supported_64bit_region(inst, arg));
> > > 
> > > +   /* Apply the region <2, 2, 1> for GRF or <0, 2, 1> for
> > > uniforms, as
> > > align16 +* HW can only do 32-bit swizzle channels.
> > > +*/
> > > +   if (reg.file == UNIFORM || reg.file == VGRF)
> > > +  hw_reg->width = BRW_WIDTH_2;
> > 
> > Any reason this is conditional on the register file?  Originally we
> > were
> > only setting the width to 2 for the UNIFORM and VGRF files, but
> > that was
> > probably an oversight...
> > 
> 
> No reason, this was an oversight. I have removed locally the
> conditional.
> 
> Do you get your R-b to it then?
> 

s/get/give

> Sam
> 
> > > +
> > > 
> > > if (is_supported_64bit_region(inst, arg) &&
> > > 
> > > !is_gen7_supported_64bit_swizzle(inst, arg)) {
> > >    
> > >    /* Supported 64-bit swizzles are those such that their
> > > first two
> > > 
> > > ___
> > > mesa-stable mailing list
> > > mesa-sta...@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/mesa-stable

signature.asc
Description: This is a digitally signed message part
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


<    1   2   3